@livelayer/react 0.10.7 → 0.13.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,10 +1,11 @@
1
1
  "use client";
2
- import { jsxs as g, jsx as n, Fragment as Ye } from "react/jsx-runtime";
3
- import { Component as On, useState as C, useRef as N, useEffect as I, useCallback as E, useMemo as Ge, useLayoutEffect as mn, forwardRef as ut, useImperativeHandle as Hn, createElement as Wn } from "react";
4
- import { createPortal as It } from "react-dom";
5
- import { LiveKitSession as Bn } from "@livelayer/sdk";
6
- import { createLocalAudioTrack as qn, Track as gn, createLocalVideoTrack as Fn } from "livekit-client";
7
- class Un extends On {
2
+ import { jsxs as w, jsx as n, Fragment as Pe } from "react/jsx-runtime";
3
+ import { Component as Un, useState as E, useRef as N, useEffect as I, useCallback as C, useMemo as Ge, useLayoutEffect as wn, forwardRef as Dt, useImperativeHandle as jn, createElement as Vn } from "react";
4
+ import { createPortal as Pt } from "react-dom";
5
+ import { LiveKitSession as Yn, registerFields as Gn } from "@livelayer/sdk";
6
+ import { clearFieldRegistry as Do, getRegisteredFields as Po, registerFields as $o, setFieldValue as zo } from "@livelayer/sdk";
7
+ import { createLocalAudioTrack as Jn, Track as _n, createLocalVideoTrack as Kn } from "livekit-client";
8
+ class Xn extends Un {
8
9
  constructor() {
9
10
  super(...arguments), this.state = { hasError: !1, error: null }, this.reset = () => {
10
11
  this.setState({ hasError: !1, error: null });
@@ -19,7 +20,7 @@ class Un extends On {
19
20
  }
20
21
  render() {
21
22
  var t;
22
- return this.state.hasError ? this.props.fallback ? this.props.fallback : /* @__PURE__ */ g("div", { className: "ll-error-boundary", role: "alert", children: [
23
+ return this.state.hasError ? this.props.fallback ? this.props.fallback : /* @__PURE__ */ w("div", { className: "ll-error-boundary", role: "alert", children: [
23
24
  /* @__PURE__ */ n("p", { className: "ll-error-boundary__title", children: "Widget crashed" }),
24
25
  /* @__PURE__ */ n("p", { className: "ll-error-boundary__message", children: ((t = this.state.error) == null ? void 0 : t.message) || "Something went wrong." }),
25
26
  /* @__PURE__ */ n(
@@ -34,26 +35,26 @@ class Un extends On {
34
35
  ] }) : this.props.children;
35
36
  }
36
37
  }
37
- function jn(e) {
38
- const [t, r] = C("idle"), [o, i] = C("idle"), [l, d] = C([]), [a, s] = C(null), [u, y] = C(null), [f, c] = C(null), [A, x] = C(!1), [_, v] = C(null), b = N(null), S = N(e.onDataMessage);
38
+ function Qn(e) {
39
+ const [t, r] = E("idle"), [o, i] = E("idle"), [l, s] = E([]), [a, c] = E(null), [p, v] = E(null), [f, u] = E(null), [R, L] = E(!1), [_, h] = E(null), b = N(null), S = N(e.onDataMessage);
39
40
  S.current = e.onDataMessage, I(() => {
40
- const R = {
41
- onConnectionStateChange: (q) => {
42
- r(q), q === "connected" && v(null);
41
+ const g = {
42
+ onConnectionStateChange: (H) => {
43
+ r(H), H === "connected" && h(null);
43
44
  },
44
45
  onAgentStateChange: i,
45
- onTranscript: (q) => d([...q]),
46
- onAgentConfig: s,
47
- onAudioTrack: (q) => c(q),
48
- onVideoTrack: (q) => y(q),
49
- onVideoTrackRemoved: () => y(null),
50
- onError: (q) => v(q),
51
- onDataMessage: (q) => {
52
- var F;
53
- (F = S.current) == null || F.call(S, q);
46
+ onTranscript: (H) => s([...H]),
47
+ onAgentConfig: c,
48
+ onAudioTrack: (H) => u(H),
49
+ onVideoTrack: (H) => v(H),
50
+ onVideoTrackRemoved: () => v(null),
51
+ onError: (H) => h(H),
52
+ onDataMessage: (H) => {
53
+ var q;
54
+ (q = S.current) == null || q.call(S, H);
54
55
  },
55
- onResumabilityChange: x
56
- }, B = new Bn(
56
+ onResumabilityChange: L
57
+ }, P = new Yn(
57
58
  {
58
59
  agentId: e.agentId,
59
60
  baseUrl: e.baseUrl,
@@ -61,11 +62,11 @@ function jn(e) {
61
62
  sessionEndpoint: e.sessionEndpoint,
62
63
  sessionBody: e.sessionBody
63
64
  },
64
- R
65
+ g
65
66
  );
66
- return b.current = B, r("idle"), i("idle"), d([]), s(null), y(null), c(null), x(!1), v(null), () => {
67
- var q;
68
- (q = B.destroy) == null || q.call(B), b.current = null;
67
+ return b.current = P, r("idle"), i("idle"), s([]), c(null), v(null), u(null), L(!1), h(null), () => {
68
+ var H;
69
+ (H = P.destroy) == null || H.call(P), b.current = null;
69
70
  };
70
71
  }, [
71
72
  e.agentId,
@@ -74,38 +75,38 @@ function jn(e) {
74
75
  e.sessionEndpoint,
75
76
  JSON.stringify(e.sessionBody ?? {})
76
77
  ]);
77
- const M = E(async () => {
78
- const R = b.current;
79
- if (R)
78
+ const T = C(async () => {
79
+ const g = b.current;
80
+ if (g)
80
81
  try {
81
- await R.connect();
82
- } catch (B) {
83
- throw v(B instanceof Error ? B.message : String(B)), B;
82
+ await g.connect();
83
+ } catch (P) {
84
+ throw h(P instanceof Error ? P.message : String(P)), P;
84
85
  }
85
- }, []), D = E(() => {
86
- const R = b.current;
87
- R && R.disconnect();
88
- }, []), k = E(() => {
89
- var R;
90
- return ((R = b.current) == null ? void 0 : R.getRoom()) ?? null;
86
+ }, []), A = C(() => {
87
+ const g = b.current;
88
+ g && g.disconnect();
89
+ }, []), F = C(() => {
90
+ var g;
91
+ return ((g = b.current) == null ? void 0 : g.getRoom()) ?? null;
91
92
  }, []);
92
93
  return {
93
94
  connectionState: t,
94
95
  agentState: o,
95
96
  transcript: l,
96
97
  agentConfig: a,
97
- videoElement: u,
98
+ videoElement: p,
98
99
  audioElement: f,
99
- canResume: A,
100
+ canResume: R,
100
101
  error: _,
101
- connect: M,
102
- disconnect: D,
103
- getRoom: k,
102
+ connect: T,
103
+ disconnect: A,
104
+ getRoom: F,
104
105
  session: b.current
105
106
  };
106
107
  }
107
- function Vn() {
108
- const e = N(null), t = N(null), r = N(null), o = N(null), i = N(/* @__PURE__ */ new Set()), l = N(null), d = E(() => {
108
+ function Zn() {
109
+ const e = N(null), t = N(null), r = N(null), o = N(null), i = N(/* @__PURE__ */ new Set()), l = N(null), s = C(() => {
109
110
  const f = t.current;
110
111
  if (!f) {
111
112
  o.current = null;
@@ -114,23 +115,23 @@ function Vn() {
114
115
  (!l.current || l.current.length !== f.frequencyBinCount) && (l.current = new Uint8Array(
115
116
  new ArrayBuffer(f.frequencyBinCount)
116
117
  ));
117
- const c = l.current;
118
- f.getByteFrequencyData(c);
119
- let A = 0;
120
- for (let _ = 0; _ < c.length; _++) A += c[_];
121
- const x = A / c.length / 255;
118
+ const u = l.current;
119
+ f.getByteFrequencyData(u);
120
+ let R = 0;
121
+ for (let _ = 0; _ < u.length; _++) R += u[_];
122
+ const L = R / u.length / 255;
122
123
  for (const _ of i.current)
123
124
  try {
124
- _(x);
125
- } catch (v) {
126
- console.error("[useAudioLevel] subscriber threw:", v);
125
+ _(L);
126
+ } catch (h) {
127
+ console.error("[useAudioLevel] subscriber threw:", h);
127
128
  }
128
- o.current = requestAnimationFrame(d);
129
- }, []), a = E(() => {
129
+ o.current = requestAnimationFrame(s);
130
+ }, []), a = C(() => {
130
131
  if (e.current || typeof window > "u" || typeof AudioContext > "u") return;
131
- const f = new AudioContext(), c = f.createAnalyser();
132
- c.fftSize = 64, c.connect(f.destination), e.current = f, t.current = c;
133
- }, []), s = E(
132
+ const f = new AudioContext(), u = f.createAnalyser();
133
+ u.fftSize = 64, u.connect(f.destination), e.current = f, t.current = u;
134
+ }, []), c = C(
134
135
  (f) => {
135
136
  if (a(), !(!e.current || !t.current)) {
136
137
  if (r.current) {
@@ -141,17 +142,17 @@ function Vn() {
141
142
  r.current = null;
142
143
  }
143
144
  try {
144
- const c = e.current.createMediaElementSource(f);
145
- c.connect(t.current), r.current = c;
146
- } catch (c) {
147
- console.warn("[useAudioLevel] createMediaElementSource failed:", c);
145
+ const u = e.current.createMediaElementSource(f);
146
+ u.connect(t.current), r.current = u;
147
+ } catch (u) {
148
+ console.warn("[useAudioLevel] createMediaElementSource failed:", u);
148
149
  return;
149
150
  }
150
- o.current === null && (o.current = requestAnimationFrame(d));
151
+ o.current === null && (o.current = requestAnimationFrame(s));
151
152
  }
152
153
  },
153
- [a, d]
154
- ), u = E(() => {
154
+ [a, s]
155
+ ), p = C(() => {
155
156
  if (o.current !== null && (cancelAnimationFrame(o.current), o.current = null), r.current) {
156
157
  try {
157
158
  r.current.disconnect();
@@ -159,11 +160,11 @@ function Vn() {
159
160
  }
160
161
  r.current = null;
161
162
  }
162
- }, []), y = E((f) => (i.current.add(f), () => {
163
+ }, []), v = C((f) => (i.current.add(f), () => {
163
164
  i.current.delete(f);
164
165
  }), []);
165
166
  return I(() => () => {
166
- if (u(), t.current) {
167
+ if (p(), t.current) {
167
168
  try {
168
169
  t.current.disconnect();
169
170
  } catch {
@@ -178,102 +179,102 @@ function Vn() {
178
179
  e.current = null;
179
180
  }
180
181
  i.current.clear(), l.current = null;
181
- }, [u]), { attach: s, detach: u, subscribe: y };
182
+ }, [p]), { attach: c, detach: p, subscribe: v };
182
183
  }
183
- function Yn() {
184
- const [e, t] = C(!1), [r, o] = C(""), [i, l] = C(null), d = N(null), a = N(null), s = E(async (x) => {
185
- var _, v;
186
- if (d.current && a.current) {
184
+ function er() {
185
+ const [e, t] = E(!1), [r, o] = E(""), [i, l] = E(null), s = N(null), a = N(null), c = C(async (L) => {
186
+ var _, h;
187
+ if (s.current && a.current) {
187
188
  try {
188
- await a.current.localParticipant.unpublishTrack(d.current);
189
+ await a.current.localParticipant.unpublishTrack(s.current);
189
190
  } catch {
190
191
  }
191
- d.current.stop(), d.current = null;
192
+ s.current.stop(), s.current = null;
192
193
  }
193
- a.current = x, l(null);
194
+ a.current = L, l(null);
194
195
  try {
195
- const b = await qn({
196
+ const b = await Jn({
196
197
  echoCancellation: !0,
197
198
  noiseSuppression: !0
198
199
  });
199
- await x.localParticipant.publishTrack(b), d.current = b, t(b.isMuted);
200
- const S = (v = (_ = b.mediaStreamTrack) == null ? void 0 : _.getSettings) == null ? void 0 : v.call(_);
200
+ await L.localParticipant.publishTrack(b), s.current = b, t(b.isMuted);
201
+ const S = (h = (_ = b.mediaStreamTrack) == null ? void 0 : _.getSettings) == null ? void 0 : h.call(_);
201
202
  S != null && S.deviceId && o(S.deviceId);
202
203
  } catch (b) {
203
204
  const S = b instanceof Error && b.name === "NotAllowedError" ? "Enable your microphone to talk with the agent." : "Microphone unavailable. Check browser permissions and try again.";
204
205
  throw l(S), b;
205
206
  }
206
- }, []), u = E((x) => {
207
- a.current = x;
208
- }, []), y = E(async (x) => {
207
+ }, []), p = C((L) => {
208
+ a.current = L;
209
+ }, []), v = C(async (L) => {
209
210
  const _ = a.current;
210
211
  if (_)
211
212
  try {
212
- await _.switchActiveDevice("audioinput", x), o(x);
213
- } catch (v) {
214
- console.warn("[useMicrophoneState] switchDevice failed:", v);
213
+ await _.switchActiveDevice("audioinput", L), o(L);
214
+ } catch (h) {
215
+ console.warn("[useMicrophoneState] switchDevice failed:", h);
215
216
  }
216
- }, []), f = E(async () => {
217
- const x = a.current, _ = !e;
218
- if (t(_), !!x)
217
+ }, []), f = C(async () => {
218
+ const L = a.current, _ = !e;
219
+ if (t(_), !!L)
219
220
  try {
220
- await x.localParticipant.setMicrophoneEnabled(!_);
221
- } catch (v) {
222
- console.warn("[useMicrophoneState] setMicrophoneEnabled failed:", v), t(!_);
221
+ await L.localParticipant.setMicrophoneEnabled(!_);
222
+ } catch (h) {
223
+ console.warn("[useMicrophoneState] setMicrophoneEnabled failed:", h), t(!_);
223
224
  }
224
- }, [e]), c = E(() => {
225
- const x = d.current, _ = a.current;
226
- if (x && _) {
225
+ }, [e]), u = C(() => {
226
+ const L = s.current, _ = a.current;
227
+ if (L && _) {
227
228
  try {
228
- _.localParticipant.unpublishTrack(x);
229
+ _.localParticipant.unpublishTrack(L);
229
230
  } catch {
230
231
  }
231
- x.stop();
232
+ L.stop();
232
233
  }
233
- d.current = null, a.current = null, t(!1), o("");
234
- }, []), A = E(() => l(null), []);
234
+ s.current = null, a.current = null, t(!1), o("");
235
+ }, []), R = C(() => l(null), []);
235
236
  return {
236
237
  isMuted: e,
237
238
  activeDeviceId: r,
238
239
  micError: i,
239
240
  toggleMute: f,
240
- setupMic: s,
241
- attachRoom: u,
242
- switchDevice: y,
243
- teardownMic: c,
244
- clearError: A
241
+ setupMic: c,
242
+ attachRoom: p,
243
+ switchDevice: v,
244
+ teardownMic: u,
245
+ clearError: R
245
246
  };
246
247
  }
247
- const Gn = { resolution: { width: 640, height: 480, frameRate: 24 } };
248
- function Jn() {
249
- const [e, t] = C(!1), [r, o] = C(null), [i, l] = C(null), [d, a] = C(""), s = N(null), u = N(null), y = E((b) => {
250
- s.current = b;
251
- }, []), f = E(() => {
252
- var M;
253
- const b = s.current, S = u.current;
248
+ const tr = { resolution: { width: 640, height: 480, frameRate: 24 } };
249
+ function nr() {
250
+ const [e, t] = E(!1), [r, o] = E(null), [i, l] = E(null), [s, a] = E(""), c = N(null), p = N(null), v = C((b) => {
251
+ c.current = b;
252
+ }, []), f = C(() => {
253
+ var T;
254
+ const b = c.current, S = p.current;
254
255
  if (S && b) {
255
- const D = b.localParticipant.getTrackPublication(gn.Source.Camera), R = (D == null ? void 0 : D.track) ?? S;
256
+ const A = b.localParticipant.getTrackPublication(_n.Source.Camera), g = (A == null ? void 0 : A.track) ?? S;
256
257
  try {
257
- b.localParticipant.unpublishTrack(R);
258
+ b.localParticipant.unpublishTrack(g);
258
259
  } catch {
259
260
  }
260
261
  try {
261
- (M = R.stop) == null || M.call(R);
262
+ (T = g.stop) == null || T.call(g);
262
263
  } catch {
263
264
  }
264
265
  }
265
- u.current = null, l(null), t(!1);
266
- }, []), c = E(async (b) => {
267
- const S = s.current;
266
+ p.current = null, l(null), t(!1);
267
+ }, []), u = C(async (b) => {
268
+ const S = c.current;
268
269
  if (S) {
269
270
  o(null);
270
271
  try {
271
- const M = { ...Gn };
272
- b && (M.deviceId = b);
273
- const D = await Fn(M);
274
- await S.localParticipant.publishTrack(D), u.current = D;
275
- const k = D.attach();
276
- l(k), t(!0), b && a(b);
272
+ const T = { ...tr };
273
+ b && (T.deviceId = b);
274
+ const A = await Kn(T);
275
+ await S.localParticipant.publishTrack(A), p.current = A;
276
+ const F = A.attach();
277
+ l(F), t(!0), b && a(b);
277
278
  try {
278
279
  S.localParticipant.publishData(
279
280
  new TextEncoder().encode(JSON.stringify({ type: "user_camera_on" })),
@@ -281,57 +282,57 @@ function Jn() {
281
282
  );
282
283
  } catch {
283
284
  }
284
- } catch (M) {
285
- const D = M instanceof Error && M.name === "NotAllowedError" ? "Enable your camera in the browser to share video." : "Camera unavailable. Check permissions and try again.";
286
- o(D);
285
+ } catch (T) {
286
+ const A = T instanceof Error && T.name === "NotAllowedError" ? "Enable your camera in the browser to share video." : "Camera unavailable. Check permissions and try again.";
287
+ o(A);
287
288
  }
288
289
  }
289
- }, []), A = E(async () => {
290
- e ? f() : await c(d || void 0);
291
- }, [e, d, f, c]), x = E(async (b) => {
292
- f(), await c(b);
293
- }, [f, c]), _ = E(() => {
294
- f(), s.current = null, o(null), a("");
295
- }, [f]), v = E(() => o(null), []);
290
+ }, []), R = C(async () => {
291
+ e ? f() : await u(s || void 0);
292
+ }, [e, s, f, u]), L = C(async (b) => {
293
+ f(), await u(b);
294
+ }, [f, u]), _ = C(() => {
295
+ f(), c.current = null, o(null), a("");
296
+ }, [f]), h = C(() => o(null), []);
296
297
  return I(() => () => {
297
- u.current && u.current.stop();
298
+ p.current && p.current.stop();
298
299
  }, []), {
299
300
  isEnabled: e,
300
301
  error: r,
301
302
  previewEl: i,
302
- activeDeviceId: d,
303
- toggle: A,
304
- switchDevice: x,
305
- attachRoom: y,
303
+ activeDeviceId: s,
304
+ toggle: R,
305
+ switchDevice: L,
306
+ attachRoom: v,
306
307
  teardown: _,
307
- clearError: v
308
+ clearError: h
308
309
  };
309
310
  }
310
- function Kn() {
311
- const [e, t] = C(!1), [r, o] = C(null), [i, l] = C(null), d = N(null), a = E((c) => {
312
- d.current = c;
313
- }, []), s = E(() => l(null), []), u = E(async () => {
314
- const c = d.current;
315
- if (c) {
311
+ function rr() {
312
+ const [e, t] = E(!1), [r, o] = E(null), [i, l] = E(null), s = N(null), a = C((u) => {
313
+ s.current = u;
314
+ }, []), c = C(() => l(null), []), p = C(async () => {
315
+ const u = s.current;
316
+ if (u) {
316
317
  if (e) {
317
318
  try {
318
- await c.localParticipant.setScreenShareEnabled(!1);
319
+ await u.localParticipant.setScreenShareEnabled(!1);
319
320
  } catch {
320
321
  }
321
- s(), t(!1);
322
+ c(), t(!1);
322
323
  return;
323
324
  }
324
325
  o(null);
325
326
  try {
326
- await c.localParticipant.setScreenShareEnabled(!0);
327
- let A = 0;
328
- const x = () => {
329
- const _ = c.localParticipant.getTrackPublication(gn.Source.ScreenShare);
327
+ await u.localParticipant.setScreenShareEnabled(!0);
328
+ let R = 0;
329
+ const L = () => {
330
+ const _ = u.localParticipant.getTrackPublication(_n.Source.ScreenShare);
330
331
  if (_ != null && _.track) {
331
- const v = _.track.attach();
332
- l(v), t(!0);
332
+ const h = _.track.attach();
333
+ l(h), t(!0);
333
334
  try {
334
- c.localParticipant.publishData(
335
+ u.localParticipant.publishData(
335
336
  new TextEncoder().encode(JSON.stringify({ type: "user_screen_share_on" })),
336
337
  { reliable: !0 }
337
338
  );
@@ -339,31 +340,31 @@ function Kn() {
339
340
  }
340
341
  return;
341
342
  }
342
- A++ < 10 ? setTimeout(x, 100) : t(!0);
343
+ R++ < 10 ? setTimeout(L, 100) : t(!0);
343
344
  };
344
- x();
345
- } catch (A) {
346
- const x = A instanceof Error ? A.name : "";
347
- x !== "NotAllowedError" && x !== "AbortError" && o("Screen share unavailable. Try again."), t(!1);
345
+ L();
346
+ } catch (R) {
347
+ const L = R instanceof Error ? R.name : "";
348
+ L !== "NotAllowedError" && L !== "AbortError" && o("Screen share unavailable. Try again."), t(!1);
348
349
  }
349
350
  }
350
- }, [e, s]), y = E(() => {
351
- const c = d.current;
352
- if (c && e)
351
+ }, [e, c]), v = C(() => {
352
+ const u = s.current;
353
+ if (u && e)
353
354
  try {
354
- c.localParticipant.setScreenShareEnabled(!1);
355
+ u.localParticipant.setScreenShareEnabled(!1);
355
356
  } catch {
356
357
  }
357
- s(), t(!1), o(null), d.current = null;
358
- }, [e, s]), f = E(() => o(null), []);
359
- return { isEnabled: e, error: r, previewEl: i, toggle: u, attachRoom: a, teardown: y, clearError: f };
358
+ c(), t(!1), o(null), s.current = null;
359
+ }, [e, c]), f = C(() => o(null), []);
360
+ return { isEnabled: e, error: r, previewEl: i, toggle: p, attachRoom: a, teardown: v, clearError: f };
360
361
  }
361
- function Xn() {
362
- const [e, t] = C([]), [r, o] = C([]), i = E(async () => {
362
+ function or() {
363
+ const [e, t] = E([]), [r, o] = E([]), i = C(async () => {
363
364
  if (!(typeof navigator > "u" || !navigator.mediaDevices))
364
365
  try {
365
366
  const l = await navigator.mediaDevices.enumerateDevices();
366
- t(l.filter((d) => d.kind === "audioinput")), o(l.filter((d) => d.kind === "videoinput"));
367
+ t(l.filter((s) => s.kind === "audioinput")), o(l.filter((s) => s.kind === "videoinput"));
367
368
  } catch {
368
369
  }
369
370
  }, []);
@@ -373,30 +374,30 @@ function Xn() {
373
374
  return navigator.mediaDevices.addEventListener("devicechange", l), () => navigator.mediaDevices.removeEventListener("devicechange", l);
374
375
  }, [i]), { mics: e, cameras: r, refresh: i };
375
376
  }
376
- function Qn(e, t, r = !1) {
377
- const [o, i] = C(null), [l, d] = C(null), [a, s] = C(!r && !!e);
377
+ function ir(e, t, r = !1) {
378
+ const [o, i] = E(null), [l, s] = E(null), [a, c] = E(!r && !!e);
378
379
  return I(() => {
379
380
  if (r || !e) {
380
- s(!1);
381
+ c(!1);
381
382
  return;
382
383
  }
383
- const u = new AbortController(), y = t || "https://app.livelayer.studio";
384
- return s(!0), d(null), fetch(`${y}/api/widget/agent/${encodeURIComponent(e)}`, {
385
- signal: u.signal
384
+ const p = new AbortController(), v = t || "https://app.livelayer.studio";
385
+ return c(!0), s(null), fetch(`${v}/api/widget/agent/${encodeURIComponent(e)}`, {
386
+ signal: p.signal
386
387
  }).then(async (f) => {
387
388
  if (!f.ok) {
388
- const c = await f.json().catch(() => ({}));
389
- throw new Error(c.error || `HTTP ${f.status}`);
389
+ const u = await f.json().catch(() => ({}));
390
+ throw new Error(u.error || `HTTP ${f.status}`);
390
391
  }
391
392
  return f.json();
392
393
  }).then((f) => {
393
- u.signal.aborted || (i(f), s(!1));
394
+ p.signal.aborted || (i(f), c(!1));
394
395
  }).catch((f) => {
395
- u.signal.aborted || (d(f instanceof Error ? f.message : "Agent lookup failed"), s(!1));
396
- }), () => u.abort();
396
+ p.signal.aborted || (s(f instanceof Error ? f.message : "Agent lookup failed"), c(!1));
397
+ }), () => p.abort();
397
398
  }, [e, t, r]), { info: o, error: l, loading: a };
398
399
  }
399
- function Zn(e) {
400
+ function lr(e) {
400
401
  if (typeof window > "u") return null;
401
402
  try {
402
403
  return window.localStorage.getItem(e);
@@ -404,53 +405,53 @@ function Zn(e) {
404
405
  return null;
405
406
  }
406
407
  }
407
- function er(e, t) {
408
+ function ar(e, t) {
408
409
  if (!(typeof window > "u"))
409
410
  try {
410
411
  window.localStorage.setItem(e, t);
411
412
  } catch {
412
413
  }
413
414
  }
414
- function tr({
415
+ function sr({
415
416
  value: e,
416
417
  defaultValue: t = "expanded",
417
418
  onChange: r
418
419
  } = {}) {
419
- const o = e !== void 0, [i, l] = C(t), d = o ? e : i, a = E(
420
- (s) => {
421
- s !== d && (o || l(s), r == null || r(s));
420
+ const o = e !== void 0, [i, l] = E(t), s = o ? e : i, a = C(
421
+ (c) => {
422
+ c !== s && (o || l(c), r == null || r(c));
422
423
  },
423
- [d, o, r]
424
+ [s, o, r]
424
425
  );
425
- return [d, a];
426
+ return [s, a];
426
427
  }
427
- const nr = ["hidden", "minimized", "expanded"];
428
- function rr(e) {
429
- return e && nr.includes(e) ? e : null;
428
+ const cr = ["hidden", "minimized", "expanded"];
429
+ function dr(e) {
430
+ return e && cr.includes(e) ? e : null;
430
431
  }
431
- function or({
432
+ function ur({
432
433
  value: e,
433
434
  defaultValue: t = "expanded",
434
435
  onChange: r,
435
436
  persistKey: o = "ll-widget",
436
437
  disablePersistence: i = !1
437
438
  } = {}) {
438
- const l = `${o}:display-mode`, d = N(!1), [a, s] = tr({
439
+ const l = `${o}:display-mode`, s = N(!1), [a, c] = sr({
439
440
  value: e,
440
441
  defaultValue: t,
441
- onChange: (u) => {
442
- e === void 0 && !i && er(l, u), r == null || r(u);
442
+ onChange: (p) => {
443
+ e === void 0 && !i && ar(l, p), r == null || r(p);
443
444
  }
444
445
  });
445
446
  return I(() => {
446
- if (d.current || (d.current = !0, i || e !== void 0)) return;
447
- const u = rr(Zn(l));
448
- u && u !== a && s(u);
449
- }, []), [a, s];
450
- }
451
- const ir = 640;
452
- function lr(e = ir) {
453
- const [t, r] = C(!1);
447
+ if (s.current || (s.current = !0, i || e !== void 0)) return;
448
+ const p = dr(lr(l));
449
+ p && p !== a && c(p);
450
+ }, []), [a, c];
451
+ }
452
+ const fr = 640;
453
+ function pr(e = fr) {
454
+ const [t, r] = E(!1);
454
455
  return I(() => {
455
456
  if (e === !1) {
456
457
  r(!1);
@@ -464,9 +465,9 @@ function lr(e = ir) {
464
465
  });
465
466
  }, [e]), t;
466
467
  }
467
- const Kt = "__llHistoryPatched", _t = "ll:pathname";
468
- function ar() {
469
- if (typeof window > "u" || window.history[Kt]) return;
468
+ const en = "__llHistoryPatched", _t = "ll:pathname";
469
+ function hr() {
470
+ if (typeof window > "u" || window.history[en]) return;
470
471
  const e = window.history.pushState, t = window.history.replaceState;
471
472
  window.history.pushState = function(...r) {
472
473
  const o = e.apply(this, r);
@@ -474,79 +475,79 @@ function ar() {
474
475
  }, window.history.replaceState = function(...r) {
475
476
  const o = t.apply(this, r);
476
477
  return window.dispatchEvent(new Event(_t)), o;
477
- }, window.history[Kt] = !0;
478
+ }, window.history[en] = !0;
478
479
  }
479
- function Xt() {
480
+ function tn() {
480
481
  return typeof window > "u" ? "/" : window.location.pathname || "/";
481
482
  }
482
- function cr(e) {
483
- const [t, r] = C(
484
- () => e ?? Xt()
483
+ function mr(e) {
484
+ const [t, r] = E(
485
+ () => e ?? tn()
485
486
  );
486
487
  return I(() => {
487
488
  if (e !== void 0) return;
488
- ar();
489
- const o = () => r(Xt());
489
+ hr();
490
+ const o = () => r(tn());
490
491
  return o(), window.addEventListener("popstate", o), window.addEventListener(_t, o), () => {
491
492
  window.removeEventListener("popstate", o), window.removeEventListener(_t, o);
492
493
  };
493
494
  }, [e]), e ?? t;
494
495
  }
495
- const Qt = /* @__PURE__ */ new Map(), sr = /[\\^$+?.()|{}[\]]/g;
496
- function dr(e) {
497
- return e.replace(sr, "\\$&");
496
+ const nn = /* @__PURE__ */ new Map(), gr = /[\\^$+?.()|{}[\]]/g;
497
+ function yr(e) {
498
+ return e.replace(gr, "\\$&");
498
499
  }
499
- function ur(e) {
500
- const t = Qt.get(e);
500
+ function vr(e) {
501
+ const t = nn.get(e);
501
502
  if (t) return t;
502
- const r = e.length > 1 && e.endsWith("/") ? e.slice(0, -1) : e, o = "", i = "", l = r.replace(/\*\*/g, o).replace(/\*/g, i), a = dr(l).replace(new RegExp(`\\/${o}`, "g"), "(?:\\/.*)?").replace(new RegExp(o, "g"), ".*").replace(new RegExp(i, "g"), "[^/]+"), s = new RegExp(`^${a}\\/?$`);
503
- return Qt.set(e, s), s;
503
+ const r = e.length > 1 && e.endsWith("/") ? e.slice(0, -1) : e, o = "", i = "", l = r.replace(/\*\*/g, o).replace(/\*/g, i), a = yr(l).replace(new RegExp(`\\/${o}`, "g"), "(?:\\/.*)?").replace(new RegExp(o, "g"), ".*").replace(new RegExp(i, "g"), "[^/]+"), c = new RegExp(`^${a}\\/?$`);
504
+ return nn.set(e, c), c;
504
505
  }
505
- function fr(e, t) {
506
+ function br(e, t) {
506
507
  const r = t.length > 1 && t.endsWith("/") ? t.slice(0, -1) : t;
507
- return ur(e).test(r);
508
+ return vr(e).test(r);
508
509
  }
509
- function pr(e, t) {
510
- return typeof e == "function" ? e(t) : e instanceof RegExp ? e.test(t) : fr(e, t);
510
+ function wr(e, t) {
511
+ return typeof e == "function" ? e(t) : e instanceof RegExp ? e.test(t) : br(e, t);
511
512
  }
512
- function Zt(e, t) {
513
+ function rn(e, t) {
513
514
  if (!e || e.length === 0) return !1;
514
515
  for (const r of e)
515
- if (pr(r, t)) return !0;
516
+ if (wr(r, t)) return !0;
516
517
  return !1;
517
518
  }
518
- function hr(e, t, r) {
519
- return e === void 0 ? !0 : Zt(r, e) ? !1 : t && t.length > 0 ? Zt(t, e) : !0;
519
+ function _r(e, t, r) {
520
+ return e === void 0 ? !0 : rn(r, e) ? !1 : t && t.length > 0 ? rn(t, e) : !0;
520
521
  }
521
- function mr(e, t, r) {
522
+ function xr(e, t, r) {
522
523
  return Ge(
523
- () => hr(e, t, r),
524
+ () => _r(e, t, r),
524
525
  [e, t, r]
525
526
  );
526
527
  }
527
- function gr(e) {
528
+ function kr(e) {
528
529
  return e === !1 ? { navigate: !1, thinking: !1, action: !1 } : e === void 0 || e === !0 ? { navigate: !0, thinking: !0, action: !0 } : {
529
530
  navigate: e.navigate !== !1,
530
531
  thinking: e.thinking !== !1,
531
532
  action: e.action !== !1
532
533
  };
533
534
  }
534
- function yr(e) {
535
- const t = Ge(() => gr(e.config), [e.config]), r = e.baseUrl.replace(/\/+$/, ""), o = N(null), i = E(
536
- (s) => {
535
+ function Lr(e) {
536
+ const t = Ge(() => kr(e.config), [e.config]), r = e.baseUrl.replace(/\/+$/, ""), o = N(null), i = C(
537
+ (c) => {
537
538
  try {
538
- new Audio(`${r}${s}`).play().catch(() => {
539
+ new Audio(`${r}${c}`).play().catch(() => {
539
540
  });
540
541
  } catch {
541
542
  }
542
543
  },
543
544
  [r]
544
- ), l = E(() => {
545
+ ), l = C(() => {
545
546
  t.navigate && i("/audio/page-change-sound.mp3");
546
- }, [t.navigate, i]), d = E(() => {
547
+ }, [t.navigate, i]), s = C(() => {
547
548
  t.action && i("/audio/confirmation-sound.mp3");
548
- }, [t.action, i]), a = E(
549
- (s) => {
549
+ }, [t.action, i]), a = C(
550
+ (c) => {
550
551
  if (!t.thinking) {
551
552
  if (o.current) {
552
553
  try {
@@ -557,13 +558,13 @@ function yr(e) {
557
558
  }
558
559
  return;
559
560
  }
560
- if (s) {
561
+ if (c) {
561
562
  if (o.current) return;
562
563
  try {
563
- const u = new Audio(`${r}/audio/thinking-sound.mp3`);
564
- u.loop = !0, u.volume = 0.3, u.play().catch(() => {
564
+ const p = new Audio(`${r}/audio/thinking-sound.mp3`);
565
+ p.loop = !0, p.volume = 0.3, p.play().catch(() => {
565
566
  o.current = null;
566
- }), o.current = u;
567
+ }), o.current = p;
567
568
  } catch {
568
569
  }
569
570
  } else if (o.current) {
@@ -585,11 +586,11 @@ function yr(e) {
585
586
  o.current = null;
586
587
  }
587
588
  }, []), Ge(
588
- () => ({ playPageChange: l, playConfirmation: d, setThinking: a }),
589
- [l, d, a]
589
+ () => ({ playPageChange: l, playConfirmation: s, setThinking: a }),
590
+ [l, s, a]
590
591
  );
591
592
  }
592
- const en = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ g(
593
+ const on = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ w(
593
594
  "svg",
594
595
  {
595
596
  className: t,
@@ -635,7 +636,7 @@ const en = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ g(
635
636
  }
636
637
  )
637
638
  }
638
- ), tn = ({ className: e }) => /* @__PURE__ */ n(
639
+ ), ln = ({ className: e }) => /* @__PURE__ */ n(
639
640
  "svg",
640
641
  {
641
642
  className: e,
@@ -653,7 +654,7 @@ const en = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ g(
653
654
  }
654
655
  )
655
656
  }
656
- ), vr = ({ className: e }) => /* @__PURE__ */ n(
657
+ ), Cr = ({ className: e }) => /* @__PURE__ */ n(
657
658
  "svg",
658
659
  {
659
660
  className: e,
@@ -664,12 +665,12 @@ const en = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ g(
664
665
  "aria-hidden": "true",
665
666
  children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
666
667
  }
667
- ), br = {
668
+ ), Er = {
668
669
  left: 180,
669
670
  right: 0,
670
671
  up: -90,
671
672
  down: 90
672
- }, nn = ({ direction: e = "right", className: t }) => /* @__PURE__ */ n(
673
+ }, an = ({ direction: e = "right", className: t }) => /* @__PURE__ */ n(
673
674
  "svg",
674
675
  {
675
676
  className: t,
@@ -677,19 +678,19 @@ const en = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ g(
677
678
  viewBox: "0 0 24 24",
678
679
  stroke: "currentColor",
679
680
  strokeWidth: 2,
680
- style: { transform: `rotate(${br[e]}deg)` },
681
+ style: { transform: `rotate(${Er[e]}deg)` },
681
682
  "aria-hidden": "true",
682
683
  children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 6l6 6-6 6" })
683
684
  }
684
685
  );
685
- function wr(e) {
686
+ function Sr(e) {
686
687
  return e === "top-left" || e === "bottom-left" ? "left" : "right";
687
688
  }
688
- const yn = "ll-hidden-tab-center-y", _r = 5, rn = 16;
689
- function xr() {
689
+ const xn = "ll-hidden-tab-center-y", Nr = 5, sn = 16;
690
+ function Ar() {
690
691
  if (typeof window > "u") return null;
691
692
  try {
692
- const e = window.localStorage.getItem(yn);
693
+ const e = window.localStorage.getItem(xn);
693
694
  if (!e) return null;
694
695
  const t = Number.parseFloat(e);
695
696
  return Number.isFinite(t) ? t : null;
@@ -697,130 +698,130 @@ function xr() {
697
698
  return null;
698
699
  }
699
700
  }
700
- function on(e) {
701
+ function cn(e) {
701
702
  if (!(typeof window > "u"))
702
703
  try {
703
- window.localStorage.setItem(yn, String(e));
704
+ window.localStorage.setItem(xn, String(e));
704
705
  } catch {
705
706
  }
706
707
  }
707
- const kr = ({
708
+ const Rr = ({
708
709
  position: e,
709
710
  isMobile: t,
710
711
  isSpeaking: r,
711
712
  onExpand: o,
712
713
  label: i = "Open widget",
713
714
  avatarImageUrl: l,
714
- agentName: d,
715
+ agentName: s,
715
716
  containerEl: a
716
717
  }) => {
717
- const s = wr(e), u = s === "right" ? "left" : "right", y = t ? 80 : 72, f = !!l, c = !!a, [A, x] = C(null), [_, v] = C(!1), b = N(null), S = N(!1), M = E(
718
- (O) => {
719
- if (typeof window > "u") return O;
720
- const j = y / 2, H = rn + j, G = window.innerHeight - rn - j;
721
- return G < H ? Math.max(H, O) : Math.max(H, Math.min(G, O));
718
+ const c = Sr(e), p = c === "right" ? "left" : "right", v = t ? 80 : 72, f = !!l, u = !!a, [R, L] = E(null), [_, h] = E(!1), b = N(null), S = N(!1), T = C(
719
+ (M) => {
720
+ if (typeof window > "u") return M;
721
+ const U = v / 2, B = sn + U, J = window.innerHeight - sn - U;
722
+ return J < B ? Math.max(B, M) : Math.max(B, Math.min(J, M));
722
723
  },
723
- [y]
724
+ [v]
724
725
  );
725
726
  I(() => {
726
- if (c) {
727
- x(null);
727
+ if (u) {
728
+ L(null);
728
729
  return;
729
730
  }
730
- const O = xr();
731
- x(M(O ?? window.innerHeight / 2));
732
- const j = () => {
733
- x((H) => H === null ? null : M(H));
731
+ const M = Ar();
732
+ L(T(M ?? window.innerHeight / 2));
733
+ const U = () => {
734
+ L((B) => B === null ? null : T(B));
734
735
  };
735
- return window.addEventListener("resize", j), () => window.removeEventListener("resize", j);
736
- }, [M, c]);
737
- const D = E(
738
- (O) => {
739
- if (!c && !(O.pointerType === "mouse" && O.button !== 0) && A !== null) {
736
+ return window.addEventListener("resize", U), () => window.removeEventListener("resize", U);
737
+ }, [T, u]);
738
+ const A = C(
739
+ (M) => {
740
+ if (!u && !(M.pointerType === "mouse" && M.button !== 0) && R !== null) {
740
741
  try {
741
- O.currentTarget.setPointerCapture(O.pointerId);
742
+ M.currentTarget.setPointerCapture(M.pointerId);
742
743
  } catch {
743
744
  }
744
745
  b.current = {
745
- startClientY: O.clientY,
746
- startCenterY: A,
746
+ startClientY: M.clientY,
747
+ startCenterY: R,
747
748
  moved: !1
748
749
  };
749
750
  }
750
751
  },
751
- [A, c]
752
- ), k = E(
753
- (O) => {
754
- const j = b.current;
755
- if (!j) return;
756
- const H = O.clientY - j.startClientY;
757
- !j.moved && Math.abs(H) > _r && (j.moved = !0, v(!0)), j.moved && x(M(j.startCenterY + H));
752
+ [R, u]
753
+ ), F = C(
754
+ (M) => {
755
+ const U = b.current;
756
+ if (!U) return;
757
+ const B = M.clientY - U.startClientY;
758
+ !U.moved && Math.abs(B) > Nr && (U.moved = !0, h(!0)), U.moved && L(T(U.startCenterY + B));
758
759
  },
759
- [M]
760
- ), R = E(
761
- (O) => {
762
- const j = b.current;
763
- if (j) {
760
+ [T]
761
+ ), g = C(
762
+ (M) => {
763
+ const U = b.current;
764
+ if (U) {
764
765
  try {
765
- O.currentTarget.releasePointerCapture(O.pointerId);
766
+ M.currentTarget.releasePointerCapture(M.pointerId);
766
767
  } catch {
767
768
  }
768
- b.current = null, j.moved && (v(!1), S.current = !0, x((H) => (H !== null && on(H), H)));
769
+ b.current = null, U.moved && (h(!1), S.current = !0, L((B) => (B !== null && cn(B), B)));
769
770
  }
770
771
  },
771
772
  []
772
- ), B = E(() => {
773
+ ), P = C(() => {
773
774
  if (S.current) {
774
775
  S.current = !1;
775
776
  return;
776
777
  }
777
778
  o();
778
- }, [o]), q = E(
779
- (O) => {
780
- if (O.key === "ArrowUp" || O.key === "ArrowDown") {
781
- O.preventDefault();
782
- const j = O.key === "ArrowUp" ? -8 : 8;
783
- x((H) => {
784
- if (H === null) return H;
785
- const G = M(H + j);
786
- return on(G), G;
779
+ }, [o]), H = C(
780
+ (M) => {
781
+ if (M.key === "ArrowUp" || M.key === "ArrowDown") {
782
+ M.preventDefault();
783
+ const U = M.key === "ArrowUp" ? -8 : 8;
784
+ L((B) => {
785
+ if (B === null) return B;
786
+ const J = T(B + U);
787
+ return cn(J), J;
787
788
  });
788
789
  }
789
790
  },
790
- [M]
791
- ), F = [
791
+ [T]
792
+ ), q = [
792
793
  "ll-hidden",
793
- `ll-hidden--${s}`,
794
+ `ll-hidden--${c}`,
794
795
  t ? "ll-hidden--mobile" : "ll-hidden--desktop",
795
796
  r ? "ll-hidden--speaking" : null,
796
797
  _ ? "is-dragging" : null,
797
798
  f ? "ll-hidden--with-avatar" : null,
798
- c ? "ll-hidden--scoped" : null
799
- ].filter(Boolean).join(" "), U = A === null ? void 0 : { top: `${A - y / 2}px`, transform: "none" };
799
+ u ? "ll-hidden--scoped" : null
800
+ ].filter(Boolean).join(" "), Z = R === null ? void 0 : { top: `${R - v / 2}px`, transform: "none" };
800
801
  return /* @__PURE__ */ n(
801
802
  "button",
802
803
  {
803
804
  type: "button",
804
- className: F,
805
- onPointerDown: D,
806
- onPointerMove: k,
807
- onPointerUp: R,
808
- onPointerCancel: R,
809
- onClick: B,
810
- onKeyDown: q,
805
+ className: q,
806
+ onPointerDown: A,
807
+ onPointerMove: F,
808
+ onPointerUp: g,
809
+ onPointerCancel: g,
810
+ onClick: P,
811
+ onKeyDown: H,
811
812
  "aria-label": i,
812
813
  "data-position": e,
813
- style: U,
814
+ style: Z,
814
815
  children: f ? (
815
816
  // Layout: tiny chevron flush against the inward edge (peeks out
816
817
  // as the click affordance), then the circular avatar photo
817
818
  // taking the rest of the tab. Reinforces "this is an
818
819
  // avatar-based experience" even when collapsed.
819
- /* @__PURE__ */ g(Ye, { children: [
820
+ /* @__PURE__ */ w(Pe, { children: [
820
821
  /* @__PURE__ */ n(
821
- nn,
822
+ an,
822
823
  {
823
- direction: u,
824
+ direction: p,
824
825
  className: "ll-hidden__chevron ll-hidden__chevron--mini"
825
826
  }
826
827
  ),
@@ -828,22 +829,22 @@ const kr = ({
828
829
  "img",
829
830
  {
830
831
  src: l,
831
- alt: d ? `${d} avatar` : "Agent avatar",
832
+ alt: s ? `${s} avatar` : "Agent avatar",
832
833
  className: "ll-hidden__avatar",
833
834
  draggable: !1
834
835
  }
835
836
  )
836
837
  ] })
837
838
  ) : /* @__PURE__ */ n(
838
- nn,
839
+ an,
839
840
  {
840
- direction: u,
841
+ direction: p,
841
842
  className: "ll-hidden__chevron"
842
843
  }
843
844
  )
844
845
  }
845
846
  );
846
- }, Lr = ({
847
+ }, Ir = ({
847
848
  audioLevel: e,
848
849
  bars: t = 20,
849
850
  maxHeight: r = 20,
@@ -851,48 +852,48 @@ const kr = ({
851
852
  className: i,
852
853
  barClassName: l
853
854
  }) => {
854
- const d = N(null), a = N([]), s = Ge(() => {
855
- const y = (Math.sqrt(5) - 1) / 2;
856
- return Array.from({ length: t }, (f, c) => 0.5 + c * y % 1 * 0.5);
855
+ const s = N(null), a = N([]), c = Ge(() => {
856
+ const v = (Math.sqrt(5) - 1) / 2;
857
+ return Array.from({ length: t }, (f, u) => 0.5 + u * v % 1 * 0.5);
857
858
  }, [t]);
858
859
  I(() => e.subscribe((f) => {
859
- for (let c = 0; c < t; c++) {
860
- const A = a.current[c];
861
- if (!A) continue;
862
- const x = Math.max(o, f * r * s[c]);
863
- A.style.height = `${x}px`;
860
+ for (let u = 0; u < t; u++) {
861
+ const R = a.current[u];
862
+ if (!R) continue;
863
+ const L = Math.max(o, f * r * c[u]);
864
+ R.style.height = `${L}px`;
864
865
  }
865
- }), [e, t, r, o, s]);
866
- const u = ["ll-waveform", i].filter(Boolean).join(" ");
867
- return /* @__PURE__ */ n("div", { ref: d, className: u, "aria-hidden": "true", children: Array.from({ length: t }, (y, f) => /* @__PURE__ */ n(
866
+ }), [e, t, r, o, c]);
867
+ const p = ["ll-waveform", i].filter(Boolean).join(" ");
868
+ return /* @__PURE__ */ n("div", { ref: s, className: p, "aria-hidden": "true", children: Array.from({ length: t }, (v, f) => /* @__PURE__ */ n(
868
869
  "div",
869
870
  {
870
- ref: (c) => {
871
- a.current[f] = c;
871
+ ref: (u) => {
872
+ a.current[f] = u;
872
873
  },
873
874
  className: ["ll-waveform__bar", l].filter(Boolean).join(" "),
874
875
  style: { height: `${o}px` }
875
876
  },
876
877
  f
877
878
  )) });
878
- }, Er = ({
879
+ }, Mr = ({
879
880
  position: e,
880
881
  isMobile: t,
881
882
  agentName: r,
882
883
  avatarImageUrl: o,
883
884
  agentState: i,
884
885
  isMuted: l,
885
- audioLevel: d,
886
+ audioLevel: s,
886
887
  onExpand: a,
887
- onToggleMute: s,
888
- onClose: u
888
+ onToggleMute: c,
889
+ onClose: p
889
890
  }) => t ? /* @__PURE__ */ n(
890
891
  "div",
891
892
  {
892
893
  className: "ll-minimized ll-minimized--mobile",
893
894
  role: "region",
894
895
  "aria-label": `${r} widget`,
895
- children: /* @__PURE__ */ g(
896
+ children: /* @__PURE__ */ w(
896
897
  "button",
897
898
  {
898
899
  type: "button",
@@ -912,33 +913,33 @@ const kr = ({
912
913
  )
913
914
  ) : /* @__PURE__ */ n("div", { className: "ll-minimized__avatar ll-minimized__avatar--placeholder" }),
914
915
  /* @__PURE__ */ n(
915
- Lr,
916
+ Ir,
916
917
  {
917
- audioLevel: d,
918
+ audioLevel: s,
918
919
  bars: 16,
919
920
  maxHeight: 18,
920
921
  className: "ll-minimized__waveform"
921
922
  }
922
923
  ),
923
924
  /* @__PURE__ */ n("span", { className: "ll-minimized__name", children: r }),
924
- /* @__PURE__ */ g("div", { className: "ll-minimized__controls", children: [
925
+ /* @__PURE__ */ w("div", { className: "ll-minimized__controls", children: [
925
926
  /* @__PURE__ */ n(
926
927
  "span",
927
928
  {
928
929
  className: "ll-minimized__btn",
929
930
  role: "button",
930
931
  tabIndex: 0,
931
- onClick: (y) => {
932
- y.stopPropagation(), s();
932
+ onClick: (v) => {
933
+ v.stopPropagation(), c();
933
934
  },
934
- onKeyDown: (y) => {
935
- (y.key === "Enter" || y.key === " ") && (y.stopPropagation(), y.preventDefault(), s());
935
+ onKeyDown: (v) => {
936
+ (v.key === "Enter" || v.key === " ") && (v.stopPropagation(), v.preventDefault(), c());
936
937
  },
937
938
  "aria-label": l ? "Unmute microphone" : "Mute microphone",
938
- children: /* @__PURE__ */ n(en, { muted: l, className: "ll-minimized__icon" })
939
+ children: /* @__PURE__ */ n(on, { muted: l, className: "ll-minimized__icon" })
939
940
  }
940
941
  ),
941
- /* @__PURE__ */ n(tn, { className: "ll-minimized__icon ll-minimized__icon--expand" })
942
+ /* @__PURE__ */ n(ln, { className: "ll-minimized__icon ll-minimized__icon--expand" })
942
943
  ] })
943
944
  ]
944
945
  }
@@ -951,7 +952,7 @@ const kr = ({
951
952
  "data-position": e,
952
953
  role: "region",
953
954
  "aria-label": `${r} widget`,
954
- children: /* @__PURE__ */ g("div", { className: "ll-minimized__surface", children: [
955
+ children: /* @__PURE__ */ w("div", { className: "ll-minimized__surface", children: [
955
956
  o ? (
956
957
  // eslint-disable-next-line @next/next/no-img-element
957
958
  /* @__PURE__ */ n(
@@ -963,19 +964,19 @@ const kr = ({
963
964
  }
964
965
  )
965
966
  ) : /* @__PURE__ */ n("div", { className: "ll-minimized__avatar ll-minimized__avatar--placeholder" }),
966
- /* @__PURE__ */ g("div", { className: "ll-minimized__meta", children: [
967
+ /* @__PURE__ */ w("div", { className: "ll-minimized__meta", children: [
967
968
  /* @__PURE__ */ n("span", { className: "ll-minimized__name", children: r }),
968
969
  /* @__PURE__ */ n("span", { className: "ll-minimized__state", children: i === "speaking" ? "Speaking" : i === "thinking" ? "Thinking" : "Listening" })
969
970
  ] }),
970
- /* @__PURE__ */ g("div", { className: "ll-minimized__controls", children: [
971
+ /* @__PURE__ */ w("div", { className: "ll-minimized__controls", children: [
971
972
  /* @__PURE__ */ n(
972
973
  "button",
973
974
  {
974
975
  type: "button",
975
976
  className: "ll-minimized__btn",
976
- onClick: s,
977
+ onClick: c,
977
978
  "aria-label": l ? "Unmute microphone" : "Mute microphone",
978
- children: /* @__PURE__ */ n(en, { muted: l, className: "ll-minimized__icon" })
979
+ children: /* @__PURE__ */ n(on, { muted: l, className: "ll-minimized__icon" })
979
980
  }
980
981
  ),
981
982
  /* @__PURE__ */ n(
@@ -985,7 +986,7 @@ const kr = ({
985
986
  className: "ll-minimized__btn",
986
987
  onClick: a,
987
988
  "aria-label": `Expand ${r} widget`,
988
- children: /* @__PURE__ */ n(tn, { className: "ll-minimized__icon" })
989
+ children: /* @__PURE__ */ n(ln, { className: "ll-minimized__icon" })
989
990
  }
990
991
  ),
991
992
  /* @__PURE__ */ n(
@@ -993,26 +994,26 @@ const kr = ({
993
994
  {
994
995
  type: "button",
995
996
  className: "ll-minimized__btn ll-minimized__btn--close",
996
- onClick: u,
997
+ onClick: p,
997
998
  "aria-label": "Close widget",
998
- children: /* @__PURE__ */ n(vr, { className: "ll-minimized__icon" })
999
+ children: /* @__PURE__ */ n(Cr, { className: "ll-minimized__icon" })
999
1000
  }
1000
1001
  )
1001
1002
  ] })
1002
1003
  ] })
1003
1004
  }
1004
- ), Cr = ({
1005
+ ), Tr = ({
1005
1006
  src: e,
1006
1007
  alt: t,
1007
1008
  preCannedPlaying: r = !1,
1008
1009
  className: o,
1009
1010
  style: i
1010
1011
  }) => {
1011
- const [l, d] = C(!1), a = N(e);
1012
+ const [l, s] = E(!1), a = N(e);
1012
1013
  if (I(() => {
1013
- a.current !== e && (a.current = e, d(!1));
1014
+ a.current !== e && (a.current = e, s(!1));
1014
1015
  }, [e]), !e) return null;
1015
- const s = {
1016
+ const c = {
1016
1017
  position: "absolute",
1017
1018
  inset: 0,
1018
1019
  width: "100%",
@@ -1032,49 +1033,49 @@ const kr = ({
1032
1033
  src: e,
1033
1034
  alt: t,
1034
1035
  className: o,
1035
- style: s,
1036
+ style: c,
1036
1037
  loading: "eager",
1037
1038
  fetchPriority: "high",
1038
- onLoad: () => d(!0)
1039
+ onLoad: () => s(!0)
1039
1040
  }
1040
1041
  )
1041
1042
  );
1042
- }, Sr = 8, ln = 8, Nr = ({
1043
+ }, Dr = 8, dn = 8, Pr = ({
1043
1044
  open: e,
1044
1045
  onClose: t,
1045
1046
  anchorRef: r,
1046
1047
  children: o
1047
1048
  }) => {
1048
- const i = N(null), [l, d] = C(null);
1049
- return mn(() => {
1049
+ const i = N(null), [l, s] = E(null);
1050
+ return wn(() => {
1050
1051
  if (!e) {
1051
- d(null);
1052
+ s(null);
1052
1053
  return;
1053
1054
  }
1054
1055
  const a = r.current;
1055
1056
  if (!a) return;
1056
- const s = () => {
1057
- const u = a.getBoundingClientRect(), y = {
1058
- top: u.top - Sr,
1059
- left: u.left + u.width / 2
1060
- }, f = ln + 90, c = window.innerWidth - ln - 90;
1061
- y.left < f && (y.left = f), y.left > c && (y.left = c), d(y);
1057
+ const c = () => {
1058
+ const p = a.getBoundingClientRect(), v = {
1059
+ top: p.top - Dr,
1060
+ left: p.left + p.width / 2
1061
+ }, f = dn + 90, u = window.innerWidth - dn - 90;
1062
+ v.left < f && (v.left = f), v.left > u && (v.left = u), s(v);
1062
1063
  };
1063
- return s(), window.addEventListener("scroll", s, !0), window.addEventListener("resize", s), () => {
1064
- window.removeEventListener("scroll", s, !0), window.removeEventListener("resize", s);
1064
+ return c(), window.addEventListener("scroll", c, !0), window.addEventListener("resize", c), () => {
1065
+ window.removeEventListener("scroll", c, !0), window.removeEventListener("resize", c);
1065
1066
  };
1066
1067
  }, [e, r]), I(() => {
1067
1068
  if (!e) return;
1068
- const a = (u) => {
1069
- const y = u.target, f = i.current, c = r.current;
1070
- f && f.contains(y) || c && c.contains(y) || t();
1071
- }, s = (u) => {
1072
- u.key === "Escape" && (u.stopPropagation(), t());
1069
+ const a = (p) => {
1070
+ const v = p.target, f = i.current, u = r.current;
1071
+ f && f.contains(v) || u && u.contains(v) || t();
1072
+ }, c = (p) => {
1073
+ p.key === "Escape" && (p.stopPropagation(), t());
1073
1074
  };
1074
- return document.addEventListener("mousedown", a), document.addEventListener("keydown", s), () => {
1075
- document.removeEventListener("mousedown", a), document.removeEventListener("keydown", s);
1075
+ return document.addEventListener("mousedown", a), document.addEventListener("keydown", c), () => {
1076
+ document.removeEventListener("mousedown", a), document.removeEventListener("keydown", c);
1076
1077
  };
1077
- }, [e, t, r]), !e || l === null || typeof document > "u" ? null : It(
1078
+ }, [e, t, r]), !e || l === null || typeof document > "u" ? null : Pt(
1078
1079
  /* @__PURE__ */ n(
1079
1080
  "div",
1080
1081
  {
@@ -1094,25 +1095,25 @@ const kr = ({
1094
1095
  ),
1095
1096
  document.body
1096
1097
  );
1097
- }, Ar = ({
1098
+ }, $r = ({
1098
1099
  isMuted: e,
1099
1100
  onToggleMute: t,
1100
1101
  isCameraEnabled: r,
1101
1102
  onToggleCamera: o,
1102
1103
  allowCamera: i,
1103
1104
  isScreenShareEnabled: l,
1104
- onToggleScreenShare: d,
1105
+ onToggleScreenShare: s,
1105
1106
  allowScreenShare: a,
1106
- isSpeakerMuted: s,
1107
- onToggleSpeaker: u,
1108
- allowTyping: y,
1107
+ isSpeakerMuted: c,
1108
+ onToggleSpeaker: p,
1109
+ allowTyping: v,
1109
1110
  isTypingOpen: f,
1110
- onToggleTyping: c,
1111
- onDisconnect: A
1111
+ onToggleTyping: u,
1112
+ onDisconnect: R
1112
1113
  }) => {
1113
- const [x, _] = C(!1), v = N(null);
1114
- return /* @__PURE__ */ g(Ye, { children: [
1115
- /* @__PURE__ */ g(
1114
+ const [L, _] = E(!1), h = N(null);
1115
+ return /* @__PURE__ */ w(Pe, { children: [
1116
+ /* @__PURE__ */ w(
1116
1117
  "div",
1117
1118
  {
1118
1119
  className: "ll-toolbar ll-toolbar--compact",
@@ -1126,20 +1127,20 @@ const kr = ({
1126
1127
  className: `ll-tool ${e ? "is-muted" : ""}`,
1127
1128
  onClick: t,
1128
1129
  "aria-label": e ? "Unmute microphone" : "Mute microphone",
1129
- children: /* @__PURE__ */ n(wn, { muted: e })
1130
+ children: /* @__PURE__ */ n(Cn, { muted: e })
1130
1131
  }
1131
1132
  ),
1132
1133
  /* @__PURE__ */ n(
1133
1134
  "button",
1134
1135
  {
1135
- ref: v,
1136
+ ref: h,
1136
1137
  type: "button",
1137
- className: `ll-tool ${x ? "is-on" : ""}`,
1138
+ className: `ll-tool ${L ? "is-on" : ""}`,
1138
1139
  onClick: () => _((b) => !b),
1139
1140
  "aria-label": "More controls",
1140
1141
  "aria-haspopup": "menu",
1141
- "aria-expanded": x,
1142
- children: /* @__PURE__ */ n(Rr, {})
1142
+ "aria-expanded": L,
1143
+ children: /* @__PURE__ */ n(zr, {})
1143
1144
  }
1144
1145
  ),
1145
1146
  /* @__PURE__ */ n(
@@ -1147,22 +1148,22 @@ const kr = ({
1147
1148
  {
1148
1149
  type: "button",
1149
1150
  className: "ll-tool ll-tool--danger",
1150
- onClick: A,
1151
+ onClick: R,
1151
1152
  "aria-label": "End conversation",
1152
- children: /* @__PURE__ */ n(xn, {})
1153
+ children: /* @__PURE__ */ n(Sn, {})
1153
1154
  }
1154
1155
  )
1155
1156
  ]
1156
1157
  }
1157
1158
  ),
1158
- /* @__PURE__ */ g(
1159
- Nr,
1159
+ /* @__PURE__ */ w(
1160
+ Pr,
1160
1161
  {
1161
- open: x,
1162
+ open: L,
1162
1163
  onClose: () => _(!1),
1163
- anchorRef: v,
1164
+ anchorRef: h,
1164
1165
  children: [
1165
- i && /* @__PURE__ */ g(
1166
+ i && /* @__PURE__ */ w(
1166
1167
  "button",
1167
1168
  {
1168
1169
  type: "button",
@@ -1171,54 +1172,54 @@ const kr = ({
1171
1172
  o(), _(!1);
1172
1173
  },
1173
1174
  children: [
1174
- /* @__PURE__ */ n(bn, {}),
1175
+ /* @__PURE__ */ n(Ln, {}),
1175
1176
  /* @__PURE__ */ n("span", { children: r ? "Stop camera" : "Start camera" })
1176
1177
  ]
1177
1178
  }
1178
1179
  ),
1179
- a && /* @__PURE__ */ g(
1180
+ a && /* @__PURE__ */ w(
1180
1181
  "button",
1181
1182
  {
1182
1183
  type: "button",
1183
1184
  className: `ll-overflow-popover__item ${l ? "is-on" : ""}`,
1184
1185
  onClick: () => {
1185
- d(), _(!1);
1186
+ s(), _(!1);
1186
1187
  },
1187
1188
  children: [
1188
- /* @__PURE__ */ n(vn, {}),
1189
+ /* @__PURE__ */ n(kn, {}),
1189
1190
  /* @__PURE__ */ n("span", { children: l ? "Stop sharing" : "Share screen" })
1190
1191
  ]
1191
1192
  }
1192
1193
  ),
1193
- /* @__PURE__ */ g(
1194
+ /* @__PURE__ */ w(
1194
1195
  "button",
1195
1196
  {
1196
1197
  type: "button",
1197
- className: `ll-overflow-popover__item ${s ? "is-on" : ""}`,
1198
+ className: `ll-overflow-popover__item ${c ? "is-on" : ""}`,
1198
1199
  onClick: () => {
1199
- u(), _(!1);
1200
+ p(), _(!1);
1200
1201
  },
1201
1202
  children: [
1202
- /* @__PURE__ */ n(_n, { muted: s }),
1203
- /* @__PURE__ */ n("span", { children: s ? "Unmute speaker" : "Mute speaker" })
1203
+ /* @__PURE__ */ n(En, { muted: c }),
1204
+ /* @__PURE__ */ n("span", { children: c ? "Unmute speaker" : "Mute speaker" })
1204
1205
  ]
1205
1206
  }
1206
1207
  ),
1207
- y && /* @__PURE__ */ g(
1208
+ v && /* @__PURE__ */ w(
1208
1209
  "button",
1209
1210
  {
1210
1211
  type: "button",
1211
1212
  className: `ll-overflow-popover__item ${f ? "is-on" : ""}`,
1212
1213
  onClick: () => {
1213
- c(), _(!1);
1214
+ u(), _(!1);
1214
1215
  },
1215
1216
  children: [
1216
- /* @__PURE__ */ n(Ir, {}),
1217
+ /* @__PURE__ */ n(Or, {}),
1217
1218
  /* @__PURE__ */ n("span", { children: f ? "Hide typing" : "Type a message" })
1218
1219
  ]
1219
1220
  }
1220
1221
  ),
1221
- /* @__PURE__ */ g(
1222
+ /* @__PURE__ */ w(
1222
1223
  "button",
1223
1224
  {
1224
1225
  type: "button",
@@ -1236,8 +1237,8 @@ const kr = ({
1236
1237
  )
1237
1238
  ] });
1238
1239
  };
1239
- function Rr() {
1240
- return /* @__PURE__ */ g(
1240
+ function zr() {
1241
+ return /* @__PURE__ */ w(
1241
1242
  "svg",
1242
1243
  {
1243
1244
  width: "16",
@@ -1253,7 +1254,7 @@ function Rr() {
1253
1254
  }
1254
1255
  );
1255
1256
  }
1256
- function Ir() {
1257
+ function Or() {
1257
1258
  return /* @__PURE__ */ n(
1258
1259
  "svg",
1259
1260
  {
@@ -1270,151 +1271,151 @@ function Ir() {
1270
1271
  }
1271
1272
  );
1272
1273
  }
1273
- const Mr = ({
1274
+ const Hr = ({
1274
1275
  position: e,
1275
1276
  isMobile: t,
1276
1277
  agentName: r,
1277
1278
  avatarImageUrl: o,
1278
1279
  idleLoopUrl: i,
1279
1280
  greeting: l,
1280
- branding: d,
1281
+ branding: s,
1281
1282
  teamMembers: a,
1282
- currentTeamMemberId: s,
1283
- isSwitchingTeamMember: u,
1284
- teamSwitcherOpen: y,
1283
+ currentTeamMemberId: c,
1284
+ isSwitchingTeamMember: p,
1285
+ teamSwitcherOpen: v,
1285
1286
  onToggleTeamSwitcher: f,
1286
- onSelectTeamMember: c,
1287
- languageMenuOpen: A,
1288
- onToggleLanguageMenu: x,
1287
+ onSelectTeamMember: u,
1288
+ languageMenuOpen: R,
1289
+ onToggleLanguageMenu: L,
1289
1290
  connectionState: _,
1290
- agentState: v,
1291
+ agentState: h,
1291
1292
  transcript: b,
1292
1293
  canResume: S,
1293
- needsUserGesture: M,
1294
- error: D,
1295
- isMuted: k,
1296
- micError: R,
1297
- micDevices: B,
1298
- activeMicId: q,
1299
- isCameraEnabled: F,
1300
- cameraPreviewEl: U,
1301
- cameraDevices: O,
1302
- activeCameraId: j,
1303
- isScreenShareEnabled: H,
1304
- screenPreviewEl: G,
1305
- isSpeakerMuted: ce,
1306
- allowCamera: se,
1307
- allowScreenShare: ge,
1308
- allowTyping: pe,
1294
+ needsUserGesture: T,
1295
+ error: A,
1296
+ isMuted: F,
1297
+ micError: g,
1298
+ micDevices: P,
1299
+ activeMicId: H,
1300
+ isCameraEnabled: q,
1301
+ cameraPreviewEl: Z,
1302
+ cameraDevices: M,
1303
+ activeCameraId: U,
1304
+ isScreenShareEnabled: B,
1305
+ screenPreviewEl: J,
1306
+ isSpeakerMuted: oe,
1307
+ allowCamera: _e,
1308
+ allowScreenShare: K,
1309
+ allowTyping: xe,
1309
1310
  showMinimize: ye = !0,
1310
- showClose: Ee = !0,
1311
- chromeless: Pe = !1,
1312
- compactControls: ne = !1,
1313
- transforming: ft,
1311
+ showClose: ke = !0,
1312
+ chromeless: ve = !1,
1313
+ compactControls: ie = !1,
1314
+ transforming: dt,
1314
1315
  transformingLabel: Je,
1315
- avatarVideoContainerRef: pt,
1316
- agentVideoEl: le,
1316
+ avatarVideoContainerRef: ut,
1317
+ agentVideoEl: se,
1317
1318
  onConnect: Ke,
1318
1319
  onDisconnect: Xe,
1319
- onRetry: ht,
1320
+ onRetry: ft,
1320
1321
  onResumeAudio: Qe,
1321
- onToggleMute: Ce,
1322
+ onToggleMute: Se,
1322
1323
  onSwitchMicDevice: $e,
1323
- onToggleCamera: Se,
1324
+ onToggleCamera: Ne,
1324
1325
  onSwitchCameraDevice: ze,
1325
- onToggleScreenShare: Ne,
1326
- onToggleSpeaker: Ae,
1327
- onSendMessage: Re,
1328
- onMinimize: P,
1329
- onClose: mt,
1326
+ onToggleScreenShare: Ae,
1327
+ onToggleSpeaker: Re,
1328
+ onSendMessage: Ie,
1329
+ onMinimize: Me,
1330
+ onClose: $,
1330
1331
  onClearMicError: kt
1331
1332
  }) => {
1332
- var De;
1333
- const Ie = ((a == null ? void 0 : a.length) ?? 0) > 1, Me = _ === "connecting" || _ === "connected", re = _ === "connected", Ze = _ === "idle" || _ === "disconnected" || _ === "error", [et, Oe] = C(!1);
1333
+ var mt;
1334
+ const Te = ((a == null ? void 0 : a.length) ?? 0) > 1, Oe = _ === "connecting" || _ === "connected", ce = _ === "connected", Ze = _ === "idle" || _ === "disconnected" || _ === "error", [De, He] = E(!1);
1334
1335
  I(() => {
1335
- if (!le) {
1336
- Oe(!1);
1336
+ if (!se) {
1337
+ He(!1);
1337
1338
  return;
1338
1339
  }
1339
- if (!le.paused && le.readyState >= 2) {
1340
- Oe(!0);
1340
+ if (!se.paused && se.readyState >= 2) {
1341
+ He(!0);
1341
1342
  return;
1342
1343
  }
1343
- Oe(!1);
1344
- const h = () => Oe(!0);
1345
- return le.addEventListener("playing", h), le.addEventListener("loadeddata", h), () => {
1346
- le.removeEventListener("playing", h), le.removeEventListener("loadeddata", h);
1344
+ He(!1);
1345
+ const m = () => He(!0);
1346
+ return se.addEventListener("playing", m), se.addEventListener("loadeddata", m), () => {
1347
+ se.removeEventListener("playing", m), se.removeEventListener("loadeddata", m);
1347
1348
  };
1348
- }, [le]);
1349
- const [Te, ee] = C(!1);
1349
+ }, [se]);
1350
+ const [Lt, Le] = E(!1);
1350
1351
  I(() => {
1351
- if (!re) {
1352
- ee(!1);
1352
+ if (!ce) {
1353
+ Le(!1);
1353
1354
  return;
1354
1355
  }
1355
- if (et) return;
1356
- const h = setTimeout(() => ee(!0), 8e3);
1357
- return () => clearTimeout(h);
1358
- }, [re, et]);
1359
- const gt = _ === "connecting" || re && !!o && !et && !Te, tt = N(null), oe = N(null);
1356
+ if (De) return;
1357
+ const m = setTimeout(() => Le(!0), 8e3);
1358
+ return () => clearTimeout(m);
1359
+ }, [ce, De]);
1360
+ const ee = _ === "connecting" || ce && !!o && !De && !Lt, et = N(null), ue = N(null);
1360
1361
  I(() => {
1361
- const h = tt.current;
1362
- h && (h.innerHTML = "", U && (U.style.width = "100%", U.style.height = "100%", U.style.objectFit = "cover", U.style.transform = "scaleX(-1)", h.appendChild(U)));
1363
- }, [U]), I(() => {
1364
- const h = oe.current;
1365
- h && (h.innerHTML = "", G && (G.style.width = "100%", G.style.height = "100%", G.style.objectFit = "contain", h.appendChild(G)));
1366
- }, [G]);
1367
- const [ie, de] = C(!1), [ve, X] = C(!1), ue = N(null), be = N(null);
1362
+ const m = et.current;
1363
+ m && (m.innerHTML = "", Z && (Z.style.width = "100%", Z.style.height = "100%", Z.style.objectFit = "cover", Z.style.transform = "scaleX(-1)", m.appendChild(Z)));
1364
+ }, [Z]), I(() => {
1365
+ const m = ue.current;
1366
+ m && (m.innerHTML = "", J && (J.style.width = "100%", J.style.height = "100%", J.style.objectFit = "contain", m.appendChild(J)));
1367
+ }, [J]);
1368
+ const [Be, We] = E(!1), [te, le] = E(!1), pt = N(null), ht = N(null);
1368
1369
  I(() => {
1369
- if (!ie && !ve && !A && !y) return;
1370
- const h = () => {
1371
- de(!1), X(!1), A && x(), y && f();
1370
+ if (!Be && !te && !R && !v) return;
1371
+ const m = () => {
1372
+ We(!1), le(!1), R && L(), v && f();
1372
1373
  };
1373
- return document.addEventListener("click", h), () => document.removeEventListener("click", h);
1374
+ return document.addEventListener("click", m), () => document.removeEventListener("click", m);
1374
1375
  }, [
1375
- ie,
1376
- ve,
1377
- A,
1378
- y,
1379
- x,
1376
+ Be,
1377
+ te,
1378
+ R,
1379
+ v,
1380
+ L,
1380
1381
  f
1381
1382
  ]);
1382
- const [He, Lt] = C(!1), nt = E(() => Lt((h) => !h), []), [we, rt] = C(""), ot = E(
1383
- (h) => {
1384
- h.preventDefault();
1385
- const J = we.trim();
1386
- J && (Re(J), rt(""));
1383
+ const [Ce, tt] = E(!1), re = C(() => tt((m) => !m), []), [ae, Ee] = E(""), nt = C(
1384
+ (m) => {
1385
+ m.preventDefault();
1386
+ const Y = ae.trim();
1387
+ Y && (Ie(Y), Ee(""));
1387
1388
  },
1388
- [we, Re]
1389
- ), it = d.productName || "Live Layer";
1390
- let _e = null, xe = null;
1391
- for (let h = b.length - 1; h >= 0; h--) {
1392
- const J = b[h];
1393
- if (!_e && J.role === "agent" ? _e = J : !xe && J.role === "user" && (xe = J), _e && xe) break;
1389
+ [ae, Ie]
1390
+ ), Ct = s.productName || "Live Layer";
1391
+ let fe = null, pe = null;
1392
+ for (let m = b.length - 1; m >= 0; m--) {
1393
+ const Y = b[m];
1394
+ if (!fe && Y.role === "agent" ? fe = Y : !pe && Y.role === "user" && (pe = Y), fe && pe) break;
1394
1395
  }
1395
- const We = re ? (_e == null ? void 0 : _e.text) || null : l || null, yt = re && (xe == null ? void 0 : xe.text) || null, Be = [
1396
+ const rt = ce ? (fe == null ? void 0 : fe.text) || null : l || null, qe = ce && (pe == null ? void 0 : pe.text) || null, ot = [
1396
1397
  "ll-expanded",
1397
1398
  t ? "ll-expanded--mobile" : "ll-expanded--desktop"
1398
1399
  ].join(" ");
1399
- return /* @__PURE__ */ g(
1400
+ return /* @__PURE__ */ w(
1400
1401
  "div",
1401
1402
  {
1402
- className: Be,
1403
+ className: ot,
1403
1404
  "data-position": e,
1404
- "data-state": re ? "connected" : Me ? "connecting" : "idle",
1405
+ "data-state": ce ? "connected" : Oe ? "connecting" : "idle",
1405
1406
  role: "dialog",
1406
1407
  "aria-label": `${r} widget`,
1407
1408
  children: [
1408
- /* @__PURE__ */ g("div", { className: "ll-expanded__bg", children: [
1409
+ /* @__PURE__ */ w("div", { className: "ll-expanded__bg", children: [
1409
1410
  o ? /* @__PURE__ */ n(
1410
- Cr,
1411
+ Tr,
1411
1412
  {
1412
1413
  src: o,
1413
1414
  alt: r,
1414
1415
  className: "ll-expanded__bg-img"
1415
1416
  }
1416
- ) : /* @__PURE__ */ n("div", { className: "ll-expanded__bg-fallback", children: /* @__PURE__ */ n("span", { className: "ll-expanded__bg-initial", children: ((De = r == null ? void 0 : r.charAt(0)) == null ? void 0 : De.toUpperCase()) || "A" }) }),
1417
- i && !re && /* @__PURE__ */ n(
1417
+ ) : /* @__PURE__ */ n("div", { className: "ll-expanded__bg-fallback", children: /* @__PURE__ */ n("span", { className: "ll-expanded__bg-initial", children: ((mt = r == null ? void 0 : r.charAt(0)) == null ? void 0 : mt.toUpperCase()) || "A" }) }),
1418
+ i && !ce && /* @__PURE__ */ n(
1418
1419
  "video",
1419
1420
  {
1420
1421
  className: "ll-expanded__bg-idle",
@@ -1426,12 +1427,12 @@ const Mr = ({
1426
1427
  }
1427
1428
  )
1428
1429
  ] }),
1429
- /* @__PURE__ */ n("div", { ref: pt, className: "ll-expanded__video" }),
1430
- gt && /* @__PURE__ */ g("div", { className: "ll-expanded__overlay ll-expanded__overlay--connecting", children: [
1430
+ /* @__PURE__ */ n("div", { ref: ut, className: "ll-expanded__video" }),
1431
+ ee && /* @__PURE__ */ w("div", { className: "ll-expanded__overlay ll-expanded__overlay--connecting", children: [
1431
1432
  /* @__PURE__ */ n("div", { className: "ll-expanded__spinner" }),
1432
- /* @__PURE__ */ n("p", { className: "ll-expanded__overlay-text", children: u ? "Switching..." : "Connecting..." })
1433
+ /* @__PURE__ */ n("p", { className: "ll-expanded__overlay-text", children: p ? "Switching..." : "Connecting..." })
1433
1434
  ] }),
1434
- M && re && /* @__PURE__ */ g(
1435
+ T && ce && /* @__PURE__ */ w(
1435
1436
  "button",
1436
1437
  {
1437
1438
  type: "button",
@@ -1443,7 +1444,7 @@ const Mr = ({
1443
1444
  ]
1444
1445
  }
1445
1446
  ),
1446
- ft && /* @__PURE__ */ g(
1447
+ dt && /* @__PURE__ */ w(
1447
1448
  "div",
1448
1449
  {
1449
1450
  className: "ll-expanded__overlay ll-expanded__overlay--transforming",
@@ -1456,69 +1457,69 @@ const Mr = ({
1456
1457
  ]
1457
1458
  }
1458
1459
  ),
1459
- Me ? /* @__PURE__ */ g(Ye, { children: [
1460
- !ne && /* @__PURE__ */ g("div", { className: "ll-expanded__topbar", children: [
1461
- !Pe && /* @__PURE__ */ g("div", { className: "ll-expanded__topbar-left", children: [
1462
- /* @__PURE__ */ g("div", { className: "ll-expanded__pill-wrap", children: [
1463
- /* @__PURE__ */ g(
1460
+ Oe ? /* @__PURE__ */ w(Pe, { children: [
1461
+ !ie && /* @__PURE__ */ w("div", { className: "ll-expanded__topbar", children: [
1462
+ !ve && /* @__PURE__ */ w("div", { className: "ll-expanded__topbar-left", children: [
1463
+ /* @__PURE__ */ w("div", { className: "ll-expanded__pill-wrap", children: [
1464
+ /* @__PURE__ */ w(
1464
1465
  "button",
1465
1466
  {
1466
1467
  type: "button",
1467
1468
  className: "ll-hpill",
1468
- onClick: (h) => {
1469
- Ie && (h.stopPropagation(), f());
1469
+ onClick: (m) => {
1470
+ Te && (m.stopPropagation(), f());
1470
1471
  },
1471
- "aria-haspopup": Ie ? "listbox" : void 0,
1472
- "aria-expanded": Ie ? y : void 0,
1472
+ "aria-haspopup": Te ? "listbox" : void 0,
1473
+ "aria-expanded": Te ? v : void 0,
1473
1474
  children: [
1474
1475
  /* @__PURE__ */ n("span", { className: "ll-hpill__label", children: r }),
1475
- Ie && /* @__PURE__ */ n(bt, {})
1476
+ Te && /* @__PURE__ */ n(bt, {})
1476
1477
  ]
1477
1478
  }
1478
1479
  ),
1479
- Ie && y && /* @__PURE__ */ n(
1480
+ Te && v && /* @__PURE__ */ n(
1480
1481
  "div",
1481
1482
  {
1482
1483
  className: "ll-hmenu",
1483
- onClick: (h) => h.stopPropagation(),
1484
+ onClick: (m) => m.stopPropagation(),
1484
1485
  role: "listbox",
1485
- children: a == null ? void 0 : a.map((h) => /* @__PURE__ */ g(
1486
+ children: a == null ? void 0 : a.map((m) => /* @__PURE__ */ w(
1486
1487
  "button",
1487
1488
  {
1488
1489
  type: "button",
1489
- className: `ll-hmenu__item ${h.id === s ? "is-active" : ""}`,
1490
- onClick: () => c(h.id),
1490
+ className: `ll-hmenu__item ${m.id === c ? "is-active" : ""}`,
1491
+ onClick: () => u(m.id),
1491
1492
  role: "option",
1492
- "aria-selected": h.id === s,
1493
+ "aria-selected": m.id === c,
1493
1494
  children: [
1494
- h.avatarImageUrl && /* @__PURE__ */ n(
1495
+ m.avatarImageUrl && /* @__PURE__ */ n(
1495
1496
  "img",
1496
1497
  {
1497
- src: h.avatarImageUrl,
1498
+ src: m.avatarImageUrl,
1498
1499
  alt: "",
1499
1500
  className: "ll-hmenu__avatar"
1500
1501
  }
1501
1502
  ),
1502
- /* @__PURE__ */ n("span", { className: "ll-hmenu__name", children: h.name }),
1503
- h.role && /* @__PURE__ */ n("span", { className: "ll-hmenu__role", children: h.role })
1503
+ /* @__PURE__ */ n("span", { className: "ll-hmenu__name", children: m.name }),
1504
+ m.role && /* @__PURE__ */ n("span", { className: "ll-hmenu__role", children: m.role })
1504
1505
  ]
1505
1506
  },
1506
- h.id
1507
+ m.id
1507
1508
  ))
1508
1509
  }
1509
1510
  )
1510
1511
  ] }),
1511
- /* @__PURE__ */ g("div", { className: "ll-expanded__pill-wrap", children: [
1512
- /* @__PURE__ */ g(
1512
+ /* @__PURE__ */ w("div", { className: "ll-expanded__pill-wrap", children: [
1513
+ /* @__PURE__ */ w(
1513
1514
  "button",
1514
1515
  {
1515
1516
  type: "button",
1516
1517
  className: "ll-hpill ll-hpill--compact",
1517
- onClick: (h) => {
1518
- h.stopPropagation(), x();
1518
+ onClick: (m) => {
1519
+ m.stopPropagation(), L();
1519
1520
  },
1520
1521
  "aria-haspopup": "listbox",
1521
- "aria-expanded": A,
1522
+ "aria-expanded": R,
1522
1523
  "aria-label": "Language: English",
1523
1524
  title: "Language: English",
1524
1525
  children: [
@@ -1527,11 +1528,11 @@ const Mr = ({
1527
1528
  ]
1528
1529
  }
1529
1530
  ),
1530
- A && /* @__PURE__ */ n(
1531
+ R && /* @__PURE__ */ n(
1531
1532
  "div",
1532
1533
  {
1533
1534
  className: "ll-hmenu",
1534
- onClick: (h) => h.stopPropagation(),
1535
+ onClick: (m) => m.stopPropagation(),
1535
1536
  role: "listbox",
1536
1537
  children: /* @__PURE__ */ n(
1537
1538
  "button",
@@ -1549,88 +1550,88 @@ const Mr = ({
1549
1550
  /* @__PURE__ */ n(
1550
1551
  "span",
1551
1552
  {
1552
- className: `ll-expanded__state ll-expanded__state--${v}`,
1553
- children: v
1553
+ className: `ll-expanded__state ll-expanded__state--${h}`,
1554
+ children: h
1554
1555
  }
1555
1556
  )
1556
1557
  ] }),
1557
- /* @__PURE__ */ g("div", { className: "ll-expanded__header-actions", children: [
1558
+ /* @__PURE__ */ w("div", { className: "ll-expanded__header-actions", children: [
1558
1559
  ye !== !1 && /* @__PURE__ */ n(
1559
1560
  "button",
1560
1561
  {
1561
1562
  type: "button",
1562
1563
  className: "ll-hbtn",
1563
- onClick: P,
1564
+ onClick: Me,
1564
1565
  "aria-label": "Minimize widget",
1565
1566
  title: "Minimize",
1566
- children: /* @__PURE__ */ n(cn, {})
1567
+ children: /* @__PURE__ */ n(fn, {})
1567
1568
  }
1568
1569
  ),
1569
- Ee !== !1 && /* @__PURE__ */ n(
1570
+ ke !== !1 && /* @__PURE__ */ n(
1570
1571
  "button",
1571
1572
  {
1572
1573
  type: "button",
1573
1574
  className: "ll-hbtn ll-hbtn--danger",
1574
- onClick: mt,
1575
+ onClick: $,
1575
1576
  "aria-label": "End call",
1576
1577
  title: "End call",
1577
- children: /* @__PURE__ */ n(an, {})
1578
+ children: /* @__PURE__ */ n(un, {})
1578
1579
  }
1579
1580
  )
1580
1581
  ] })
1581
1582
  ] }),
1582
- ne && /* @__PURE__ */ g("div", { className: "ll-compact-status", "data-state": v, children: [
1583
+ ie && /* @__PURE__ */ w("div", { className: "ll-compact-status", "data-state": h, children: [
1583
1584
  /* @__PURE__ */ n("span", { className: "ll-compact-status__dot", "aria-hidden": !0 }),
1584
- /* @__PURE__ */ n("span", { className: "ll-compact-status__label", children: v })
1585
+ /* @__PURE__ */ n("span", { className: "ll-compact-status__label", children: h })
1585
1586
  ] })
1586
1587
  ] }) : (
1587
1588
  // Idle-state header with Live Layer product name + minimize/close.
1588
1589
  // Hidden in compact mode — on a 140×210 docked slot the brand pill
1589
1590
  // and 40px buttons crowded out the central "Start video call"
1590
1591
  // affordance. The user can dismiss by scrolling past the slot.
1591
- !ne && /* @__PURE__ */ g("div", { className: "ll-expanded__header ll-expanded__header--idle", children: [
1592
- /* @__PURE__ */ n("span", { className: "ll-expanded__brand", children: it }),
1593
- /* @__PURE__ */ g("div", { className: "ll-expanded__header-actions", children: [
1592
+ !ie && /* @__PURE__ */ w("div", { className: "ll-expanded__header ll-expanded__header--idle", children: [
1593
+ /* @__PURE__ */ n("span", { className: "ll-expanded__brand", children: Ct }),
1594
+ /* @__PURE__ */ w("div", { className: "ll-expanded__header-actions", children: [
1594
1595
  ye !== !1 && /* @__PURE__ */ n(
1595
1596
  "button",
1596
1597
  {
1597
1598
  type: "button",
1598
1599
  className: "ll-hbtn ll-hbtn--ghost",
1599
- onClick: P,
1600
+ onClick: Me,
1600
1601
  "aria-label": "Minimize widget",
1601
- children: /* @__PURE__ */ n(cn, {})
1602
+ children: /* @__PURE__ */ n(fn, {})
1602
1603
  }
1603
1604
  ),
1604
- Ee !== !1 && /* @__PURE__ */ n(
1605
+ ke !== !1 && /* @__PURE__ */ n(
1605
1606
  "button",
1606
1607
  {
1607
1608
  type: "button",
1608
1609
  className: "ll-hbtn ll-hbtn--danger",
1609
- onClick: mt,
1610
+ onClick: $,
1610
1611
  "aria-label": "Close widget",
1611
- children: /* @__PURE__ */ n(an, {})
1612
+ children: /* @__PURE__ */ n(un, {})
1612
1613
  }
1613
1614
  )
1614
1615
  ] })
1615
1616
  ] })
1616
1617
  ),
1617
1618
  Ze && /* @__PURE__ */ (() => {
1618
- const h = S ? "Resume session" : _ === "disconnected" ? "Reconnect to agent" : "Start video call";
1619
- return /* @__PURE__ */ g(Ye, { children: [
1620
- !D && /* @__PURE__ */ g(
1619
+ const m = S ? "Resume session" : _ === "disconnected" ? "Reconnect to agent" : "Start video call";
1620
+ return /* @__PURE__ */ w(Pe, { children: [
1621
+ !A && /* @__PURE__ */ w(
1621
1622
  "button",
1622
1623
  {
1623
1624
  type: "button",
1624
1625
  className: "ll-expanded__play",
1625
1626
  onClick: Ke,
1626
- "aria-label": h,
1627
+ "aria-label": m,
1627
1628
  children: [
1628
1629
  /* @__PURE__ */ n("div", { className: "ll-expanded__play-circle", children: /* @__PURE__ */ n("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": !0, children: /* @__PURE__ */ n("polygon", { points: "6 3 20 12 6 21 6 3" }) }) }),
1629
- ne && /* @__PURE__ */ n("span", { className: "ll-expanded__play-label", children: h })
1630
+ ie && /* @__PURE__ */ n("span", { className: "ll-expanded__play-label", children: m })
1630
1631
  ]
1631
1632
  }
1632
1633
  ),
1633
- !ne && /* @__PURE__ */ g("div", { className: "ll-expanded__bottom ll-expanded__bottom--idle", children: [
1634
+ !ie && /* @__PURE__ */ w("div", { className: "ll-expanded__bottom ll-expanded__bottom--idle", children: [
1634
1635
  l && /* @__PURE__ */ n("div", { className: "ll-expanded__transcript", children: /* @__PURE__ */ n("p", { className: "ll-expanded__transcript-text", children: l }) }),
1635
1636
  /* @__PURE__ */ n(
1636
1637
  "button",
@@ -1638,140 +1639,140 @@ const Mr = ({
1638
1639
  type: "button",
1639
1640
  className: "ll-expanded__cta",
1640
1641
  onClick: Ke,
1641
- "aria-label": h,
1642
- children: h
1642
+ "aria-label": m,
1643
+ children: m
1643
1644
  }
1644
1645
  )
1645
1646
  ] })
1646
1647
  ] });
1647
1648
  })(),
1648
- /* @__PURE__ */ g(
1649
+ /* @__PURE__ */ w(
1649
1650
  "div",
1650
1651
  {
1651
- className: `ll-expanded__pip ${Me && (F || H) ? "is-visible" : ""}`,
1652
+ className: `ll-expanded__pip ${Oe && (q || B) ? "is-visible" : ""}`,
1652
1653
  children: [
1653
1654
  /* @__PURE__ */ n(
1654
1655
  "div",
1655
1656
  {
1656
- ref: oe,
1657
- className: H ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1657
+ ref: ue,
1658
+ className: B ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1658
1659
  }
1659
1660
  ),
1660
1661
  /* @__PURE__ */ n(
1661
1662
  "div",
1662
1663
  {
1663
- ref: tt,
1664
- className: !H && F ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1664
+ ref: et,
1665
+ className: !B && q ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1665
1666
  }
1666
1667
  )
1667
1668
  ]
1668
1669
  }
1669
1670
  ),
1670
- Me ? /* @__PURE__ */ g("div", { className: "ll-expanded__bottom", children: [
1671
- !ne && We && /* @__PURE__ */ n(
1671
+ Oe ? /* @__PURE__ */ w("div", { className: "ll-expanded__bottom", children: [
1672
+ !ie && rt && /* @__PURE__ */ n(
1672
1673
  "div",
1673
1674
  {
1674
1675
  className: "ll-expanded__transcript ll-expanded__transcript--agent",
1675
1676
  "data-role": "agent",
1676
- children: /* @__PURE__ */ n("p", { className: "ll-expanded__transcript-text", children: We })
1677
+ children: /* @__PURE__ */ n("p", { className: "ll-expanded__transcript-text", children: rt })
1677
1678
  }
1678
1679
  ),
1679
- !ne && yt && /* @__PURE__ */ n(
1680
+ !ie && qe && /* @__PURE__ */ n(
1680
1681
  "div",
1681
1682
  {
1682
1683
  className: "ll-expanded__transcript ll-expanded__transcript--user",
1683
1684
  "data-role": "user",
1684
- children: /* @__PURE__ */ n("p", { className: "ll-expanded__transcript-text", children: yt })
1685
+ children: /* @__PURE__ */ n("p", { className: "ll-expanded__transcript-text", children: qe })
1685
1686
  }
1686
1687
  ),
1687
- !Pe && !ne && /* @__PURE__ */ g("div", { className: "ll-toolbar", onClick: (h) => h.stopPropagation(), children: [
1688
- ge && /* @__PURE__ */ n(
1688
+ !ve && !ie && /* @__PURE__ */ w("div", { className: "ll-toolbar", onClick: (m) => m.stopPropagation(), children: [
1689
+ K && /* @__PURE__ */ n(
1689
1690
  "button",
1690
1691
  {
1691
1692
  type: "button",
1692
- className: `ll-tool ${H ? "is-on" : ""}`,
1693
- onClick: Ne,
1694
- "aria-label": H ? "Stop sharing screen" : "Share screen",
1695
- title: H ? "Stop sharing" : "Share screen",
1696
- children: /* @__PURE__ */ n(vn, {})
1693
+ className: `ll-tool ${B ? "is-on" : ""}`,
1694
+ onClick: Ae,
1695
+ "aria-label": B ? "Stop sharing screen" : "Share screen",
1696
+ title: B ? "Stop sharing" : "Share screen",
1697
+ children: /* @__PURE__ */ n(kn, {})
1697
1698
  }
1698
1699
  ),
1699
- se && /* @__PURE__ */ g("div", { className: "ll-tool-split", children: [
1700
+ _e && /* @__PURE__ */ w("div", { className: "ll-tool-split", children: [
1700
1701
  /* @__PURE__ */ n(
1701
1702
  "button",
1702
1703
  {
1703
1704
  type: "button",
1704
- className: `ll-tool ll-tool--left ${F ? "is-on" : ""}`,
1705
- onClick: Se,
1706
- "aria-label": F ? "Turn off camera" : "Turn on camera",
1707
- title: F ? "Stop camera" : "Start camera",
1708
- children: /* @__PURE__ */ n(bn, {})
1705
+ className: `ll-tool ll-tool--left ${q ? "is-on" : ""}`,
1706
+ onClick: Ne,
1707
+ "aria-label": q ? "Turn off camera" : "Turn on camera",
1708
+ title: q ? "Stop camera" : "Start camera",
1709
+ children: /* @__PURE__ */ n(Ln, {})
1709
1710
  }
1710
1711
  ),
1711
1712
  /* @__PURE__ */ n(
1712
1713
  "button",
1713
1714
  {
1714
- ref: be,
1715
+ ref: ht,
1715
1716
  type: "button",
1716
- className: `ll-tool ll-tool--right ${F ? "is-on" : ""}`,
1717
- onClick: (h) => {
1718
- h.stopPropagation(), X((J) => !J), de(!1);
1717
+ className: `ll-tool ll-tool--right ${q ? "is-on" : ""}`,
1718
+ onClick: (m) => {
1719
+ m.stopPropagation(), le((Y) => !Y), We(!1);
1719
1720
  },
1720
1721
  "aria-label": "Camera devices",
1721
1722
  "aria-haspopup": "listbox",
1722
- "aria-expanded": ve,
1723
+ "aria-expanded": te,
1723
1724
  children: /* @__PURE__ */ n(bt, {})
1724
1725
  }
1725
1726
  ),
1726
- ve && O.length > 0 && /* @__PURE__ */ n(
1727
- sn,
1727
+ te && M.length > 0 && /* @__PURE__ */ n(
1728
+ pn,
1728
1729
  {
1729
1730
  label: "Camera",
1730
- devices: O,
1731
- activeId: j,
1732
- anchorRef: be,
1733
- onPick: (h) => {
1734
- X(!1), ze(h);
1731
+ devices: M,
1732
+ activeId: U,
1733
+ anchorRef: ht,
1734
+ onPick: (m) => {
1735
+ le(!1), ze(m);
1735
1736
  }
1736
1737
  }
1737
1738
  )
1738
1739
  ] }),
1739
- /* @__PURE__ */ g("div", { className: "ll-tool-split", children: [
1740
+ /* @__PURE__ */ w("div", { className: "ll-tool-split", children: [
1740
1741
  /* @__PURE__ */ n(
1741
1742
  "button",
1742
1743
  {
1743
1744
  type: "button",
1744
- className: `ll-tool ll-tool--left ${k ? "is-muted" : ""}`,
1745
- onClick: Ce,
1746
- "aria-label": k ? "Unmute microphone" : "Mute microphone",
1747
- title: k ? "Unmute" : "Mute",
1748
- children: /* @__PURE__ */ n(wn, { muted: k })
1745
+ className: `ll-tool ll-tool--left ${F ? "is-muted" : ""}`,
1746
+ onClick: Se,
1747
+ "aria-label": F ? "Unmute microphone" : "Mute microphone",
1748
+ title: F ? "Unmute" : "Mute",
1749
+ children: /* @__PURE__ */ n(Cn, { muted: F })
1749
1750
  }
1750
1751
  ),
1751
1752
  /* @__PURE__ */ n(
1752
1753
  "button",
1753
1754
  {
1754
- ref: ue,
1755
+ ref: pt,
1755
1756
  type: "button",
1756
- className: `ll-tool ll-tool--right ${k ? "is-muted" : ""}`,
1757
- onClick: (h) => {
1758
- h.stopPropagation(), de((J) => !J), X(!1);
1757
+ className: `ll-tool ll-tool--right ${F ? "is-muted" : ""}`,
1758
+ onClick: (m) => {
1759
+ m.stopPropagation(), We((Y) => !Y), le(!1);
1759
1760
  },
1760
1761
  "aria-label": "Microphone devices",
1761
1762
  "aria-haspopup": "listbox",
1762
- "aria-expanded": ie,
1763
+ "aria-expanded": Be,
1763
1764
  children: /* @__PURE__ */ n(bt, {})
1764
1765
  }
1765
1766
  ),
1766
- ie && B.length > 0 && /* @__PURE__ */ n(
1767
- sn,
1767
+ Be && P.length > 0 && /* @__PURE__ */ n(
1768
+ pn,
1768
1769
  {
1769
1770
  label: "Microphone",
1770
- devices: B,
1771
- activeId: q,
1772
- anchorRef: ue,
1773
- onPick: (h) => {
1774
- de(!1), $e(h);
1771
+ devices: P,
1772
+ activeId: H,
1773
+ anchorRef: pt,
1774
+ onPick: (m) => {
1775
+ We(!1), $e(m);
1775
1776
  }
1776
1777
  }
1777
1778
  )
@@ -1780,11 +1781,11 @@ const Mr = ({
1780
1781
  "button",
1781
1782
  {
1782
1783
  type: "button",
1783
- className: `ll-tool ${ce ? "is-muted" : ""}`,
1784
- onClick: Ae,
1785
- "aria-label": ce ? "Unmute speaker" : "Mute speaker",
1786
- title: ce ? "Unmute speaker" : "Mute speaker",
1787
- children: /* @__PURE__ */ n(_n, { muted: ce })
1784
+ className: `ll-tool ${oe ? "is-muted" : ""}`,
1785
+ onClick: Re,
1786
+ "aria-label": oe ? "Unmute speaker" : "Mute speaker",
1787
+ title: oe ? "Unmute speaker" : "Mute speaker",
1788
+ children: /* @__PURE__ */ n(En, { muted: oe })
1788
1789
  }
1789
1790
  ),
1790
1791
  /* @__PURE__ */ n(
@@ -1795,56 +1796,56 @@ const Mr = ({
1795
1796
  onClick: Xe,
1796
1797
  "aria-label": "End conversation",
1797
1798
  title: "End conversation",
1798
- children: /* @__PURE__ */ n(xn, {})
1799
+ children: /* @__PURE__ */ n(Sn, {})
1799
1800
  }
1800
1801
  )
1801
1802
  ] }),
1802
- !Pe && ne && /* @__PURE__ */ n(
1803
- Ar,
1803
+ !ve && ie && /* @__PURE__ */ n(
1804
+ $r,
1804
1805
  {
1805
- isMuted: k,
1806
- onToggleMute: Ce,
1807
- isCameraEnabled: F,
1808
- onToggleCamera: Se,
1809
- allowCamera: se,
1810
- isScreenShareEnabled: H,
1811
- onToggleScreenShare: Ne,
1812
- allowScreenShare: ge,
1813
- isSpeakerMuted: ce,
1814
- onToggleSpeaker: Ae,
1815
- allowTyping: pe,
1816
- isTypingOpen: He,
1817
- onToggleTyping: nt,
1806
+ isMuted: F,
1807
+ onToggleMute: Se,
1808
+ isCameraEnabled: q,
1809
+ onToggleCamera: Ne,
1810
+ allowCamera: _e,
1811
+ isScreenShareEnabled: B,
1812
+ onToggleScreenShare: Ae,
1813
+ allowScreenShare: K,
1814
+ isSpeakerMuted: oe,
1815
+ onToggleSpeaker: Re,
1816
+ allowTyping: xe,
1817
+ isTypingOpen: Ce,
1818
+ onToggleTyping: re,
1818
1819
  onDisconnect: Xe
1819
1820
  }
1820
1821
  ),
1821
- !Pe && pe && (ne ? He : !0) && /* @__PURE__ */ g("form", { className: "ll-message-input", onSubmit: ot, children: [
1822
+ !ve && xe && (ie ? Ce : !0) && /* @__PURE__ */ w("form", { className: "ll-message-input", onSubmit: nt, children: [
1822
1823
  /* @__PURE__ */ n(
1823
1824
  "input",
1824
1825
  {
1825
1826
  type: "text",
1826
1827
  className: "ll-message-input__field",
1827
1828
  placeholder: "Message...",
1828
- value: we,
1829
- onChange: (h) => rt(h.target.value),
1829
+ value: ae,
1830
+ onChange: (m) => Ee(m.target.value),
1830
1831
  "aria-label": "Message the agent"
1831
1832
  }
1832
1833
  ),
1833
- we.trim() && /* @__PURE__ */ n(
1834
+ ae.trim() && /* @__PURE__ */ n(
1834
1835
  "button",
1835
1836
  {
1836
1837
  type: "submit",
1837
1838
  className: "ll-message-input__send",
1838
1839
  "aria-label": "Send message",
1839
- children: /* @__PURE__ */ n(Tr, {})
1840
+ children: /* @__PURE__ */ n(Br, {})
1840
1841
  }
1841
1842
  )
1842
1843
  ] })
1843
1844
  ] }) : null,
1844
1845
  (() => {
1845
- if (R && _ !== "error")
1846
- return /* @__PURE__ */ g("div", { className: "ll-expanded__banner", role: "alert", children: [
1847
- /* @__PURE__ */ n("span", { children: R }),
1846
+ if (g && _ !== "error")
1847
+ return /* @__PURE__ */ w("div", { className: "ll-expanded__banner", role: "alert", children: [
1848
+ /* @__PURE__ */ n("span", { children: g }),
1848
1849
  /* @__PURE__ */ n(
1849
1850
  "button",
1850
1851
  {
@@ -1856,17 +1857,17 @@ const Mr = ({
1856
1857
  }
1857
1858
  )
1858
1859
  ] });
1859
- if (!D || _ !== "error") return null;
1860
- let h = "Failed to connect", J = "Try again";
1861
- return D === "MIC_PERMISSION_DENIED" ? h = "Microphone blocked. Allow access to talk." : D === "MIC_NOT_FOUND" ? h = "No microphone found. Plug one in + retry." : D === "MIC_UNAVAILABLE" ? h = "Mic unavailable. Check other apps using it." : D === "AGENT_TIMEOUT" ? h = "Agent didn't pick up. Try again." : D === "CONNECT_FAILED" ? h = "Connection failed. Check your network." : D.length < 80 && (h = D), /* @__PURE__ */ g("div", { className: "ll-expanded__banner ll-expanded__banner--error", role: "alert", children: [
1862
- /* @__PURE__ */ n("span", { children: h }),
1860
+ if (!A || _ !== "error") return null;
1861
+ let m = "Failed to connect", Y = "Try again";
1862
+ return A === "MIC_PERMISSION_DENIED" ? m = "Microphone blocked. Allow access to talk." : A === "MIC_NOT_FOUND" ? m = "No microphone found. Plug one in + retry." : A === "MIC_UNAVAILABLE" ? m = "Mic unavailable. Check other apps using it." : A === "AGENT_TIMEOUT" ? m = "Agent didn't pick up. Try again." : A === "CONNECT_FAILED" ? m = "Connection failed. Check your network." : A.length < 80 && (m = A), /* @__PURE__ */ w("div", { className: "ll-expanded__banner ll-expanded__banner--error", role: "alert", children: [
1863
+ /* @__PURE__ */ n("span", { children: m }),
1863
1864
  /* @__PURE__ */ n(
1864
1865
  "button",
1865
1866
  {
1866
1867
  type: "button",
1867
1868
  className: "ll-expanded__banner-retry",
1868
- onClick: ht,
1869
- children: J
1869
+ onClick: ft,
1870
+ children: Y
1870
1871
  }
1871
1872
  )
1872
1873
  ] });
@@ -1878,52 +1879,52 @@ const Mr = ({
1878
1879
  function bt() {
1879
1880
  return /* @__PURE__ */ n("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": !0, children: /* @__PURE__ */ n("polyline", { points: "6 9 12 15 18 9" }) });
1880
1881
  }
1881
- function an() {
1882
- return /* @__PURE__ */ g("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", "aria-hidden": !0, children: [
1882
+ function un() {
1883
+ 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: [
1883
1884
  /* @__PURE__ */ n("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1884
1885
  /* @__PURE__ */ n("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1885
1886
  ] });
1886
1887
  }
1887
- function cn() {
1888
+ function fn() {
1888
1889
  return /* @__PURE__ */ n("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", "aria-hidden": !0, children: /* @__PURE__ */ n("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) });
1889
1890
  }
1890
- function vn() {
1891
- return /* @__PURE__ */ g("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: [
1891
+ function kn() {
1892
+ 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: [
1892
1893
  /* @__PURE__ */ n("rect", { x: "2", y: "3", width: "20", height: "14", rx: "2" }),
1893
1894
  /* @__PURE__ */ n("line", { x1: "8", y1: "21", x2: "16", y2: "21" }),
1894
1895
  /* @__PURE__ */ n("line", { x1: "12", y1: "17", x2: "12", y2: "21" })
1895
1896
  ] });
1896
1897
  }
1897
- function bn() {
1898
- return /* @__PURE__ */ g("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: [
1898
+ function Ln() {
1899
+ 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: [
1899
1900
  /* @__PURE__ */ n("path", { d: "M23 7l-7 5 7 5V7z" }),
1900
1901
  /* @__PURE__ */ n("rect", { x: "1", y: "5", width: "15", height: "14", rx: "2" })
1901
1902
  ] });
1902
1903
  }
1903
- function wn({ muted: e }) {
1904
- return /* @__PURE__ */ g("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: [
1904
+ function Cn({ muted: e }) {
1905
+ 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: [
1905
1906
  /* @__PURE__ */ n("path", { d: "M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z" }),
1906
1907
  /* @__PURE__ */ n("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }),
1907
1908
  /* @__PURE__ */ n("line", { x1: "12", y1: "19", x2: "12", y2: "23" }),
1908
1909
  e && /* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1909
1910
  ] });
1910
1911
  }
1911
- function _n({ muted: e }) {
1912
- return /* @__PURE__ */ g("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: [
1912
+ function En({ muted: e }) {
1913
+ 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: [
1913
1914
  /* @__PURE__ */ n("polygon", { points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5" }),
1914
- e ? /* @__PURE__ */ n("line", { x1: "23", y1: "9", x2: "17", y2: "15" }) : /* @__PURE__ */ g(Ye, { children: [
1915
+ e ? /* @__PURE__ */ n("line", { x1: "23", y1: "9", x2: "17", y2: "15" }) : /* @__PURE__ */ w(Pe, { children: [
1915
1916
  /* @__PURE__ */ n("path", { d: "M19.07 4.93a10 10 0 0 1 0 14.14" }),
1916
1917
  /* @__PURE__ */ n("path", { d: "M15.54 8.46a5 5 0 0 1 0 7.07" })
1917
1918
  ] })
1918
1919
  ] });
1919
1920
  }
1920
- function Tr() {
1921
- return /* @__PURE__ */ g("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1921
+ function Br() {
1922
+ 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: [
1922
1923
  /* @__PURE__ */ n("line", { x1: "5", y1: "12", x2: "19", y2: "12" }),
1923
1924
  /* @__PURE__ */ n("polyline", { points: "12 5 19 12 12 19" })
1924
1925
  ] });
1925
1926
  }
1926
- function xn() {
1927
+ function Sn() {
1927
1928
  return /* @__PURE__ */ n("svg", { width: "16", height: "16", viewBox: "-4 -4 32 32", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: /* @__PURE__ */ n(
1928
1929
  "path",
1929
1930
  {
@@ -1932,29 +1933,29 @@ function xn() {
1932
1933
  }
1933
1934
  ) });
1934
1935
  }
1935
- const sn = ({
1936
+ const pn = ({
1936
1937
  label: e,
1937
1938
  devices: t,
1938
1939
  activeId: r,
1939
1940
  onPick: o,
1940
1941
  anchorRef: i
1941
1942
  }) => {
1942
- const [l, d] = C(null);
1943
- return mn(() => {
1943
+ const [l, s] = E(null);
1944
+ return wn(() => {
1944
1945
  const a = () => {
1945
- const s = i.current;
1946
- if (!s) return;
1947
- const u = s.getBoundingClientRect(), y = 126, f = window.innerWidth - 16 - 110, c = u.left + u.width / 2;
1948
- d({
1949
- top: u.top - 8,
1950
- left: Math.max(y, Math.min(f, c))
1946
+ const c = i.current;
1947
+ if (!c) return;
1948
+ const p = c.getBoundingClientRect(), v = 126, f = window.innerWidth - 16 - 110, u = p.left + p.width / 2;
1949
+ s({
1950
+ top: p.top - 8,
1951
+ left: Math.max(v, Math.min(f, u))
1951
1952
  });
1952
1953
  };
1953
1954
  return a(), window.addEventListener("scroll", a, !0), window.addEventListener("resize", a), () => {
1954
1955
  window.removeEventListener("scroll", a, !0), window.removeEventListener("resize", a);
1955
1956
  };
1956
- }, [i]), l === null || typeof document > "u" ? null : It(
1957
- /* @__PURE__ */ g(
1957
+ }, [i]), l === null || typeof document > "u" ? null : Pt(
1958
+ /* @__PURE__ */ w(
1958
1959
  "div",
1959
1960
  {
1960
1961
  className: "ll-device-menu ll-device-menu--floating",
@@ -1969,22 +1970,22 @@ const sn = ({
1969
1970
  },
1970
1971
  children: [
1971
1972
  /* @__PURE__ */ n("p", { className: "ll-device-menu__label", children: e }),
1972
- t.map((a, s) => {
1973
- const u = r === a.deviceId;
1974
- return /* @__PURE__ */ g(
1973
+ t.map((a, c) => {
1974
+ const p = r === a.deviceId;
1975
+ return /* @__PURE__ */ w(
1975
1976
  "button",
1976
1977
  {
1977
1978
  type: "button",
1978
- className: `ll-device-menu__item ${u ? "is-active" : ""}`,
1979
+ className: `ll-device-menu__item ${p ? "is-active" : ""}`,
1979
1980
  onClick: () => o(a.deviceId),
1980
1981
  role: "option",
1981
- "aria-selected": u,
1982
+ "aria-selected": p,
1982
1983
  children: [
1983
- u && /* @__PURE__ */ n("span", { className: "ll-device-menu__dot", children: "●" }),
1984
- /* @__PURE__ */ n("span", { className: "ll-device-menu__name", children: a.label || `${e} ${s + 1}` })
1984
+ p && /* @__PURE__ */ n("span", { className: "ll-device-menu__dot", children: "●" }),
1985
+ /* @__PURE__ */ n("span", { className: "ll-device-menu__name", children: a.label || `${e} ${c + 1}` })
1985
1986
  ]
1986
1987
  },
1987
- a.deviceId || s
1988
+ a.deviceId || c
1988
1989
  );
1989
1990
  })
1990
1991
  ]
@@ -1992,21 +1993,25 @@ const sn = ({
1992
1993
  ),
1993
1994
  document.body
1994
1995
  );
1995
- }, Dr = [
1996
- '[data-ll-private="true"]',
1996
+ }, Wr = [
1997
+ // Accept any value (or empty) — `<input data-ll-private />` and
1998
+ // `<input data-ll-private="true" />` both opt out. The bare attribute
1999
+ // is the recommended spelling; "true" is preserved for back-compat.
2000
+ "[data-ll-private]",
2001
+ "[data-ll-skip]",
1997
2002
  ".ll-widget"
1998
2003
  ];
1999
- function Mt(e) {
2004
+ function $t(e) {
2000
2005
  let t = e;
2001
2006
  for (; t; ) {
2002
- for (const r of Dr)
2007
+ for (const r of Wr)
2003
2008
  if (t.matches(r)) return !0;
2004
2009
  t = t.parentElement;
2005
2010
  }
2006
2011
  return !1;
2007
2012
  }
2008
2013
  function xt(e) {
2009
- if (Mt(e)) return !1;
2014
+ if ($t(e)) return !1;
2010
2015
  if (e instanceof HTMLInputElement) {
2011
2016
  if (e.type === "password") return !1;
2012
2017
  const t = (e.getAttribute("autocomplete") || "").toLowerCase();
@@ -2014,7 +2019,7 @@ function xt(e) {
2014
2019
  }
2015
2020
  return !0;
2016
2021
  }
2017
- const wt = 4096, Pr = 20, $r = 20, zr = 10, Or = 10, Hr = 30, Wr = 20, dn = 500, Br = [
2022
+ const wt = 4096, qr = 20, Fr = 20, Ur = 10, jr = 10, Vr = 30, Yr = 20, hn = 500, Gr = [
2018
2023
  '[data-ll-private="true"]',
2019
2024
  ".ll-widget",
2020
2025
  "script",
@@ -2026,24 +2031,24 @@ function st(e) {
2026
2031
  if (e.getAttribute("aria-hidden") === "true" || e.hasAttribute("hidden")) return !0;
2027
2032
  let t = e;
2028
2033
  for (; t; ) {
2029
- for (const r of Br)
2034
+ for (const r of Gr)
2030
2035
  if (t.matches(r)) return !0;
2031
2036
  t = t.parentElement;
2032
2037
  }
2033
2038
  return !1;
2034
2039
  }
2035
- function dt(e) {
2040
+ function ct(e) {
2036
2041
  if (typeof window > "u") return !0;
2037
2042
  const t = e.getBoundingClientRect();
2038
2043
  if (t.width <= 0 || t.height <= 0) return !1;
2039
2044
  const r = window.innerHeight || document.documentElement.clientHeight, o = window.innerWidth || document.documentElement.clientWidth;
2040
2045
  return t.bottom > 0 && t.right > 0 && t.top < r && t.left < o;
2041
2046
  }
2042
- function un(e) {
2047
+ function mn(e) {
2043
2048
  const t = e.getAttribute("id");
2044
2049
  if (t) {
2045
- const l = document.querySelector(`label[for="${CSS.escape(t)}"]`);
2046
- if (l != null && l.textContent) return l.textContent.trim();
2050
+ const l = typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(t) : t.replace(/"/g, '\\"'), s = document.querySelector(`label[for="${l}"]`);
2051
+ if (s != null && s.textContent) return s.textContent.trim();
2047
2052
  }
2048
2053
  const r = e.getAttribute("aria-label");
2049
2054
  if (r) return r.trim();
@@ -2052,13 +2057,42 @@ function un(e) {
2052
2057
  const i = e.closest("label");
2053
2058
  return i != null && i.textContent ? i.textContent.trim() : "";
2054
2059
  }
2055
- function me(e, t) {
2060
+ function we(e, t) {
2056
2061
  return e.length <= t ? e : e.slice(0, t - 1) + "…";
2057
2062
  }
2058
- function Ue(e) {
2063
+ function Jr(e) {
2064
+ return e && e.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || null;
2065
+ }
2066
+ function Kr(e) {
2067
+ const t = e.getAttribute("aria-label");
2068
+ if (t) return t.trim().slice(0, 80);
2069
+ const r = e.getAttribute("aria-labelledby");
2070
+ if (r) {
2071
+ const l = document.getElementById(r);
2072
+ if (l != null && l.textContent) return l.textContent.trim().slice(0, 80);
2073
+ }
2074
+ const o = e.querySelector(
2075
+ 'button[type="submit"], input[type="submit"], button:not([type])'
2076
+ );
2077
+ if (o) {
2078
+ const l = o instanceof HTMLInputElement ? o.value : (o.textContent ?? "").trim();
2079
+ if (l && l.length < 60 && !/^(submit|ok|continue)$/i.test(l))
2080
+ return l;
2081
+ }
2082
+ let i = e.parentElement;
2083
+ for (let l = 0; i && l < 4; l++, i = i.parentElement) {
2084
+ const s = i.querySelector("h1, h2, h3, h4");
2085
+ if (s != null && s.textContent) {
2086
+ const a = s.textContent.trim();
2087
+ if (a && a.length < 80) return a;
2088
+ }
2089
+ }
2090
+ return null;
2091
+ }
2092
+ function je(e) {
2059
2093
  return e.length;
2060
2094
  }
2061
- function qr(e, t = {}) {
2095
+ function Xr(e, t = {}) {
2062
2096
  const r = t.doc ?? (typeof document < "u" ? document : null);
2063
2097
  if (!r)
2064
2098
  return {
@@ -2072,120 +2106,121 @@ function qr(e, t = {}) {
2072
2106
  forms: [],
2073
2107
  extras: e
2074
2108
  };
2075
- const o = typeof window < "u" && window.location.href || "", i = typeof window < "u" && window.location.pathname || "/", l = r.title || "", d = Array.from(
2109
+ const o = typeof window < "u" && window.location.href || "", i = typeof window < "u" && window.location.pathname || "/", l = r.title || "", s = Array.from(
2076
2110
  r.querySelectorAll("[data-ll-region]")
2077
2111
  ), a = [];
2078
- for (const k of d) {
2079
- if (a.length >= zr) break;
2080
- if (st(k) || !dt(k)) continue;
2081
- const R = k.getAttribute("data-ll-region") ?? "", B = k.getAttribute("data-ll-intent") ?? void 0, q = me(
2082
- (k.innerText || k.textContent || "").trim(),
2083
- dn * 2
2112
+ for (const g of s) {
2113
+ if (a.length >= Ur) break;
2114
+ if (st(g) || !ct(g)) continue;
2115
+ const P = g.getAttribute("data-ll-region") ?? "", H = g.getAttribute("data-ll-intent") ?? void 0, q = we(
2116
+ (g.innerText || g.textContent || "").trim(),
2117
+ hn * 2
2084
2118
  );
2085
- !R || !q || a.push({ id: R, intent: B, text: q });
2119
+ !P || !q || a.push({ id: P, intent: H, text: q });
2086
2120
  }
2087
- const s = [], u = ["H1", "H2", "H3", "H4", "H5", "H6"], y = Array.from(
2121
+ const c = [], p = ["H1", "H2", "H3", "H4", "H5", "H6"], v = Array.from(
2088
2122
  r.querySelectorAll("h1, h2, h3, h4, h5, h6")
2089
2123
  );
2090
- for (const k of y) {
2091
- if (st(k) || !dt(k)) continue;
2092
- const R = (k.textContent || "").trim();
2093
- R && s.push(`${k.tagName}: ${me(R, 200)}`);
2124
+ for (const g of v) {
2125
+ if (st(g) || !ct(g)) continue;
2126
+ const P = (g.textContent || "").trim();
2127
+ P && c.push(`${g.tagName}: ${we(P, 200)}`);
2094
2128
  }
2095
2129
  const f = Array.from(r.querySelectorAll("p, li"));
2096
- for (const k of f) {
2097
- if (st(k) || !dt(k) || u.includes(k.tagName)) continue;
2098
- const R = (k.textContent || "").trim();
2099
- R.length > 10 && s.push(me(R, dn));
2130
+ for (const g of f) {
2131
+ if (st(g) || !ct(g) || p.includes(g.tagName)) continue;
2132
+ const P = (g.textContent || "").trim();
2133
+ P.length > 10 && c.push(we(P, hn));
2100
2134
  }
2101
- const c = s.join(`
2102
- `), A = [], x = Array.from(r.querySelectorAll("a[href]"));
2103
- for (const k of x) {
2104
- if (A.length >= Pr) break;
2105
- if (st(k) || !dt(k)) continue;
2106
- const R = k.getAttribute("href") || "", B = (k.textContent || "").trim();
2107
- !R || !B || A.push({ href: R, text: me(B, 100) });
2135
+ const u = c.join(`
2136
+ `), R = [], L = Array.from(r.querySelectorAll("a[href]"));
2137
+ for (const g of L) {
2138
+ if (R.length >= qr) break;
2139
+ if (st(g) || !ct(g)) continue;
2140
+ const P = g.getAttribute("href") || "", H = (g.textContent || "").trim();
2141
+ !P || !H || R.push({ href: P, text: we(H, 100) });
2108
2142
  }
2109
- const _ = [], v = Array.from(
2143
+ const _ = [], h = Array.from(
2110
2144
  r.querySelectorAll(
2111
2145
  "input, textarea, select"
2112
2146
  )
2113
2147
  );
2114
- for (const k of v) {
2115
- if (_.length >= $r) break;
2116
- if (st(k) || !xt(k) || !dt(k)) continue;
2117
- const R = un(k), B = k instanceof HTMLInputElement ? k.type : k.tagName.toLowerCase();
2118
- R && _.push({ label: me(R, 100), type: B });
2148
+ for (const g of h) {
2149
+ if (_.length >= Fr) break;
2150
+ if (st(g) || !xt(g) || !ct(g)) continue;
2151
+ const P = mn(g), H = g instanceof HTMLInputElement ? g.type : g.tagName.toLowerCase();
2152
+ P && _.push({ label: we(P, 100), type: H });
2119
2153
  }
2120
- const b = Array.from(
2121
- r.querySelectorAll("[data-ll-form]")
2122
- ), S = [];
2123
- for (const k of b) {
2124
- if (S.length >= Or) break;
2125
- if (Mt(k)) continue;
2126
- const R = k.getAttribute("data-ll-form") || "";
2127
- if (!R) continue;
2128
- const B = k.getAttribute("data-ll-intent") || void 0, q = Array.from(
2129
- k.querySelectorAll(
2130
- "[data-ll-field]"
2154
+ const b = Array.from(r.querySelectorAll("form")), S = [];
2155
+ let T = 0;
2156
+ for (const g of b) {
2157
+ if (S.length >= jr) break;
2158
+ if ($t(g) || g.matches(".ll-widget *, .ll-widget")) continue;
2159
+ const P = g.getAttribute("id") || g.getAttribute("name") || Jr(g.getAttribute("data-ll-intent")) || `form_${T++}`, H = g.getAttribute("data-ll-intent") || Kr(g) || void 0, q = Array.from(
2160
+ g.querySelectorAll(
2161
+ "input[name], textarea[name], select[name]"
2131
2162
  )
2132
- ), F = [];
2133
- for (const U of q) {
2134
- if (F.length >= Hr) break;
2135
- if (!xt(U)) continue;
2136
- const O = U.getAttribute("data-ll-field") || "";
2137
- if (!O) continue;
2138
- const j = un(U) || O, H = U instanceof HTMLInputElement ? U.type : U.tagName.toLowerCase(), G = {
2139
- name: O,
2140
- label: me(j, 100),
2141
- type: H
2163
+ ), Z = [];
2164
+ for (const M of q) {
2165
+ if (Z.length >= Vr) break;
2166
+ if (!xt(M)) continue;
2167
+ if (M instanceof HTMLInputElement) {
2168
+ const K = M.type;
2169
+ if (K === "submit" || K === "button" || K === "reset" || K === "hidden" || K === "image" || K === "file") continue;
2170
+ }
2171
+ const U = M.getAttribute("name") || "";
2172
+ if (!U) continue;
2173
+ const B = mn(M) || U, J = M instanceof HTMLInputElement ? M.type : M.tagName.toLowerCase(), oe = {
2174
+ name: U,
2175
+ label: we(B, 100),
2176
+ type: J
2142
2177
  };
2143
- if (U.required === !0 && (G.required = !0), U instanceof HTMLSelectElement) {
2144
- const se = [];
2145
- for (let ge = 0; ge < U.options.length && !(se.length >= Wr); ge++) {
2146
- const pe = U.options[ge];
2147
- if (!pe || pe.disabled) continue;
2148
- const ye = pe.value || "", Ee = (pe.textContent || "").trim() || ye;
2149
- !ye && !Ee || se.push({ value: ye, label: me(Ee, 60) });
2178
+ if (M.required === !0 && (oe.required = !0), M instanceof HTMLSelectElement) {
2179
+ const K = [];
2180
+ for (let xe = 0; xe < M.options.length && !(K.length >= Yr); xe++) {
2181
+ const ye = M.options[xe];
2182
+ if (!ye || ye.disabled) continue;
2183
+ const ke = ye.value || "", ve = (ye.textContent || "").trim() || ke;
2184
+ !ke && !ve || K.push({ value: ke, label: we(ve, 60) });
2150
2185
  }
2151
- se.length > 0 && (G.options = se);
2186
+ K.length > 0 && (oe.options = K);
2152
2187
  }
2153
- const ce = typeof U.validationMessage == "string" ? U.validationMessage : "";
2154
- ce && (G.validationMessage = me(ce, 200)), F.push(G);
2188
+ const _e = typeof M.validationMessage == "string" ? M.validationMessage : "";
2189
+ _e && (oe.validationMessage = we(_e, 200)), Z.push(oe);
2155
2190
  }
2156
- S.push({ id: R, intent: B, fields: F });
2191
+ S.push({ id: P, intent: H, fields: Z });
2157
2192
  }
2158
- const M = {
2193
+ const A = {
2159
2194
  url: o,
2160
2195
  title: l,
2161
2196
  pathname: i,
2162
2197
  regions: a,
2163
- visibleText: c,
2164
- visibleLinks: A,
2198
+ visibleText: u,
2199
+ visibleLinks: R,
2165
2200
  visibleFields: _,
2166
2201
  forms: S,
2167
2202
  extras: e
2168
2203
  };
2169
- let D = Ue(JSON.stringify(M.regions)) + Ue(M.visibleText) + Ue(JSON.stringify(M.visibleLinks)) + Ue(JSON.stringify(M.visibleFields));
2170
- for (; D > wt && M.visibleFields.length > 0; )
2171
- M.visibleFields.pop(), D = Ue(JSON.stringify(M.visibleFields));
2172
- for (; D > wt && M.visibleLinks.length > 0; )
2173
- M.visibleLinks.pop(), D -= 80;
2174
- return Ue(M.visibleText) > wt && (M.visibleText = me(M.visibleText, wt - 100)), M;
2175
- }
2176
- let je = null;
2177
- function fn(e, t = {}) {
2204
+ let F = je(JSON.stringify(A.regions)) + je(A.visibleText) + je(JSON.stringify(A.visibleLinks)) + je(JSON.stringify(A.visibleFields));
2205
+ for (; F > wt && A.visibleFields.length > 0; )
2206
+ A.visibleFields.pop(), F = je(JSON.stringify(A.visibleFields));
2207
+ for (; F > wt && A.visibleLinks.length > 0; )
2208
+ A.visibleLinks.pop(), F -= 80;
2209
+ return je(A.visibleText) > wt && (A.visibleText = we(A.visibleText, wt - 100)), A;
2210
+ }
2211
+ let Ve = null;
2212
+ function gn(e, t = {}) {
2178
2213
  const r = Date.now(), i = `${typeof window < "u" && window.location.pathname || "/"}::${typeof window < "u" ? window.scrollY : 0}`;
2179
- if (je && je.key === i && r - je.at < 1e3)
2180
- return je.ctx;
2181
- const l = qr(e, t);
2182
- return je = { key: i, at: r, ctx: l }, l;
2214
+ if (Ve && Ve.key === i && r - Ve.at < 1e3)
2215
+ return Ve.ctx;
2216
+ const l = Xr(e, t);
2217
+ return Ve = { key: i, at: r, ctx: l }, l;
2183
2218
  }
2184
- function Fr() {
2185
- je = null;
2219
+ function Qr() {
2220
+ Ve = null;
2186
2221
  }
2187
- const Ur = 200;
2188
- function jr(e) {
2222
+ const Zr = 200;
2223
+ function eo(e) {
2189
2224
  const t = String(e.href || "");
2190
2225
  return {
2191
2226
  href: t,
@@ -2195,63 +2230,100 @@ function jr(e) {
2195
2230
  description: e.description
2196
2231
  };
2197
2232
  }
2198
- function Vr(e) {
2233
+ function to(e) {
2199
2234
  return !(!e || e.startsWith("#") || e.startsWith("javascript:") || e.startsWith("mailto:") || e.startsWith("tel:"));
2200
2235
  }
2201
- function Yr(e) {
2236
+ function no(e) {
2202
2237
  const t = e ?? (typeof document < "u" ? document : null);
2203
2238
  if (!t) return [];
2204
2239
  const r = typeof window < "u" && window.location.origin || "", o = /* @__PURE__ */ new Set(), i = [], l = Array.from(t.querySelectorAll("a[href]"));
2205
- for (const d of l) {
2206
- if (i.length >= Ur) break;
2207
- if (Mt(d)) continue;
2208
- const a = d.getAttribute("href") || "";
2209
- if (!Vr(a)) continue;
2210
- let s = a, u = !0;
2240
+ for (const s of l) {
2241
+ if (i.length >= Zr) break;
2242
+ if ($t(s)) continue;
2243
+ const a = s.getAttribute("href") || "";
2244
+ if (!to(a)) continue;
2245
+ let c = a, p = !0;
2211
2246
  try {
2212
2247
  if (typeof window < "u") {
2213
2248
  const f = new URL(a, r);
2214
- u = f.origin === r, u && a.startsWith("http") && (s = f.pathname + f.search + f.hash);
2249
+ p = f.origin === r, p && a.startsWith("http") && (c = f.pathname + f.search + f.hash);
2215
2250
  }
2216
2251
  } catch {
2217
2252
  continue;
2218
2253
  }
2219
- if (o.has(s)) continue;
2220
- o.add(s);
2221
- const y = (d.textContent || "").trim().slice(0, 120);
2222
- i.push({ href: s, text: y, internal: u });
2254
+ if (o.has(c)) continue;
2255
+ o.add(c);
2256
+ const v = (s.textContent || "").trim().slice(0, 120);
2257
+ i.push({ href: c, text: v, internal: p });
2223
2258
  }
2224
2259
  return i;
2225
2260
  }
2226
- let Ve = null;
2227
- const Gr = 5e3;
2228
- function At() {
2261
+ let Ye = null;
2262
+ const ro = 5e3;
2263
+ function Mt() {
2229
2264
  const e = Date.now(), t = typeof window < "u" && window.location.pathname || "/";
2230
- if (Ve && Ve.pathname === t && e - Ve.at < Gr)
2231
- return Ve.routes;
2232
- const r = Yr();
2233
- return Ve = { at: e, pathname: t, routes: r }, r;
2265
+ if (Ye && Ye.pathname === t && e - Ye.at < ro)
2266
+ return Ye.routes;
2267
+ const r = no();
2268
+ return Ye = { at: e, pathname: t, routes: r }, r;
2234
2269
  }
2235
- function Jr() {
2236
- Ve = null;
2270
+ function oo() {
2271
+ Ye = null;
2237
2272
  }
2238
- function Kr(e, t) {
2273
+ function io(e, t) {
2239
2274
  const r = e instanceof HTMLInputElement ? HTMLInputElement.prototype : e instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLSelectElement.prototype, o = Object.getOwnPropertyDescriptor(r, "value"), i = o == null ? void 0 : o.set;
2240
2275
  i ? i.call(e, t) : e.value = t;
2241
2276
  }
2242
- function Xr(e, t, r = {}) {
2277
+ function lo(e, t, r = {}) {
2243
2278
  const o = r.triggerInput ?? !0, i = r.triggerChange ?? !0;
2244
2279
  if (e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio")) {
2245
2280
  const l = Object.getOwnPropertyDescriptor(
2246
2281
  HTMLInputElement.prototype,
2247
2282
  "checked"
2248
- ), d = l == null ? void 0 : l.set, a = t === "true" || t === "1" || t === "on";
2249
- d ? d.call(e, a) : e.checked = a, o && e.dispatchEvent(new Event("input", { bubbles: !0 })), i && e.dispatchEvent(new Event("change", { bubbles: !0 }));
2283
+ ), s = l == null ? void 0 : l.set, a = t === "true" || t === "1" || t === "on";
2284
+ s ? s.call(e, a) : e.checked = a, o && e.dispatchEvent(new Event("input", { bubbles: !0 })), i && e.dispatchEvent(new Event("change", { bubbles: !0 }));
2250
2285
  return;
2251
2286
  }
2252
- Kr(e, t), o && e.dispatchEvent(new Event("input", { bubbles: !0 })), i && e.dispatchEvent(new Event("change", { bubbles: !0 }));
2287
+ io(e, t), o && e.dispatchEvent(new Event("input", { bubbles: !0 })), i && e.dispatchEvent(new Event("change", { bubbles: !0 }));
2253
2288
  }
2254
- function Qr() {
2289
+ function yn(e, t) {
2290
+ if (!t) return null;
2291
+ const r = t.replace(/"/g, '\\"');
2292
+ try {
2293
+ const s = e.querySelector(
2294
+ `form#${CSS.escape(t)}`
2295
+ );
2296
+ if (s) return s;
2297
+ } catch {
2298
+ }
2299
+ const o = e.querySelector(
2300
+ `form[name="${r}"]`
2301
+ );
2302
+ if (o) return o;
2303
+ const i = e.querySelector(
2304
+ `form[data-ll-intent="${r}"]`
2305
+ );
2306
+ if (i) return i;
2307
+ const l = Array.from(e.querySelectorAll("form"));
2308
+ for (const s of l) {
2309
+ const a = s.getAttribute("data-ll-intent");
2310
+ if (a && ao(a) === t) return s;
2311
+ }
2312
+ if (/^form_\d+$/.test(t)) {
2313
+ const s = parseInt(t.slice(5), 10);
2314
+ let a = 0;
2315
+ for (const c of l)
2316
+ if (!(c.id || c.getAttribute("name") || c.getAttribute("data-ll-intent"))) {
2317
+ if (a === s) return c;
2318
+ a++;
2319
+ }
2320
+ }
2321
+ return null;
2322
+ }
2323
+ function ao(e) {
2324
+ return e.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || null;
2325
+ }
2326
+ function so() {
2255
2327
  if (typeof window > "u" || typeof document > "u")
2256
2328
  return !1;
2257
2329
  const e = document.scrollingElement || document.documentElement;
@@ -2259,19 +2331,19 @@ function Qr() {
2259
2331
  const t = window.getComputedStyle(e);
2260
2332
  return !(t.overflowY === "hidden" || t.overflowY === "clip");
2261
2333
  }
2262
- function Zr(e) {
2334
+ function co(e) {
2263
2335
  if (!(e instanceof HTMLElement)) return !1;
2264
2336
  const r = window.getComputedStyle(e).overflowY;
2265
2337
  return !(r !== "auto" && r !== "scroll" || e.scrollHeight <= e.clientHeight + 2);
2266
2338
  }
2267
- function eo() {
2339
+ function uo() {
2268
2340
  if (typeof document > "u") return null;
2269
2341
  const e = Array.from(
2270
2342
  document.querySelectorAll("body, body *")
2271
2343
  );
2272
2344
  let t = null, r = 0;
2273
2345
  for (const o of e) {
2274
- if (!Zr(o)) continue;
2346
+ if (!co(o)) continue;
2275
2347
  const i = o.getBoundingClientRect();
2276
2348
  if (i.bottom <= 0 || i.top >= window.innerHeight || i.right <= 0 || i.left >= window.innerWidth || i.width <= 0 || i.height <= 0 || o.closest(".ll-widget")) continue;
2277
2349
  const l = i.width * i.height;
@@ -2279,24 +2351,24 @@ function eo() {
2279
2351
  }
2280
2352
  return t;
2281
2353
  }
2282
- function to() {
2354
+ function fo() {
2283
2355
  if (typeof window > "u")
2284
2356
  return null;
2285
- if (Qr()) return window;
2286
- const e = eo();
2357
+ if (so()) return window;
2358
+ const e = uo();
2287
2359
  return e || window;
2288
2360
  }
2289
- function pn(e) {
2361
+ function vn(e) {
2290
2362
  return e instanceof Window ? e.innerHeight || 0 : e.clientHeight || 0;
2291
2363
  }
2292
- function no(e) {
2364
+ function po(e) {
2293
2365
  var t, r;
2294
2366
  return e instanceof Window ? typeof document > "u" ? 0 : Math.max(
2295
2367
  ((t = document.body) == null ? void 0 : t.scrollHeight) ?? 0,
2296
2368
  ((r = document.documentElement) == null ? void 0 : r.scrollHeight) ?? 0
2297
2369
  ) : e.scrollHeight - e.clientHeight;
2298
2370
  }
2299
- const ro = /* @__PURE__ */ new Set([
2371
+ const ho = /* @__PURE__ */ new Set([
2300
2372
  "agent_state",
2301
2373
  "avatar_stream_ready",
2302
2374
  "avatar_active",
@@ -2317,156 +2389,166 @@ const ro = /* @__PURE__ */ new Set([
2317
2389
  "fill_form",
2318
2390
  "focus_field",
2319
2391
  "submit_form",
2320
- "request_routes"
2321
- ]), kn = ut(
2392
+ "request_routes",
2393
+ // 0.12.0 structured collection (unified API).
2394
+ // Both `task_field_updated` and `task_completed` data-channel commands
2395
+ // fan out into a single document-level `ll-collected` CustomEvent
2396
+ // (discriminated on phase) that `useCollect()` listens for, plus
2397
+ // `onCollect` on AvatarWidget for one-shot delivery. Not bubbled
2398
+ // to onAgentCommand.
2399
+ "task_field_updated",
2400
+ "task_completed"
2401
+ ]), Nn = Dt(
2322
2402
  function(t, r) {
2323
- var Ft, Ut, jt, Vt, Yt, Gt, Jt;
2403
+ var Yt, Gt, Jt, Kt, Xt, Qt, Zt;
2324
2404
  const {
2325
2405
  agentId: o,
2326
2406
  apiKey: i,
2327
2407
  baseUrl: l = "https://app.livelayer.studio",
2328
- sessionEndpoint: d,
2408
+ sessionEndpoint: s,
2329
2409
  sessionBody: a,
2330
- soundEffects: s,
2331
- experienceMode: u = "WIDGET",
2332
- autoConnect: y = !1,
2410
+ soundEffects: c,
2411
+ experienceMode: p = "WIDGET",
2412
+ autoConnect: v = !1,
2333
2413
  displayMode: f,
2334
- defaultDisplayMode: c = "expanded",
2335
- onDisplayModeChange: A,
2336
- position: x = "bottom-right",
2414
+ defaultDisplayMode: u = "expanded",
2415
+ onDisplayModeChange: R,
2416
+ position: L = "bottom-right",
2337
2417
  mobileBreakpoint: _ = 640,
2338
- persistKey: v = "ll-widget",
2418
+ persistKey: h = "ll-widget",
2339
2419
  disablePersistence: b = !1,
2340
2420
  teamMembers: S,
2341
- currentTeamMemberId: M,
2342
- onTeamMemberChange: D,
2343
- idleLoopUrl: k,
2344
- greeting: R,
2345
- avatarImageUrl: B,
2346
- agentName: q,
2347
- branding: F = {},
2348
- allowCamera: U = !0,
2349
- allowScreenShare: O = !0,
2350
- allowTyping: j = !0,
2351
- showMinimize: H = !0,
2352
- showClose: G = !0,
2353
- chromeless: ce = !1,
2354
- floatingChromeContainer: se = null,
2355
- compactControls: ge = !1,
2356
- transforming: pe = !1,
2421
+ currentTeamMemberId: T,
2422
+ onTeamMemberChange: A,
2423
+ idleLoopUrl: F,
2424
+ greeting: g,
2425
+ avatarImageUrl: P,
2426
+ agentName: H,
2427
+ branding: q = {},
2428
+ allowCamera: Z = !0,
2429
+ allowScreenShare: M = !0,
2430
+ allowTyping: U = !0,
2431
+ showMinimize: B,
2432
+ showClose: J,
2433
+ chromeless: oe = !1,
2434
+ floatingChromeContainer: _e = null,
2435
+ compactControls: K = !1,
2436
+ transforming: xe = !1,
2357
2437
  transformingLabel: ye = "Transforming…",
2358
- showOn: Ee,
2359
- hideOn: Pe,
2360
- pathname: ne,
2361
- onNavigate: ft,
2438
+ showOn: ke,
2439
+ hideOn: ve,
2440
+ pathname: ie,
2441
+ onNavigate: dt,
2362
2442
  onScrollToSelector: Je,
2363
- getPageContext: pt,
2364
- pageContextExtras: le,
2443
+ getPageContext: ut,
2444
+ pageContextExtras: se,
2365
2445
  getRoutes: Ke,
2366
2446
  onScrollPage: Xe,
2367
- onClick: ht,
2447
+ onClick: ft,
2368
2448
  capabilities: Qe,
2369
- onConnect: Ce,
2449
+ onConnect: Se,
2370
2450
  onDisconnect: $e,
2371
- onTranscript: Se,
2451
+ onTranscript: Ne,
2372
2452
  onAgentState: ze,
2373
- onConnectionStateChange: Ne,
2374
- onAgentEvent: Ae,
2375
- onAgentCommand: Re,
2376
- controlledSession: P,
2377
- className: mt,
2378
- style: kt,
2379
- zIndex: Ie = 2147483647
2380
- } = t, Me = cr(ne), re = mr(Me, Ee, Pe);
2453
+ onConnectionStateChange: Ae,
2454
+ onAgentEvent: Re,
2455
+ onAgentCommand: Ie,
2456
+ onCollect: Me,
2457
+ controlledSession: $,
2458
+ className: kt,
2459
+ style: Te,
2460
+ zIndex: Oe = 2147483647
2461
+ } = t, ce = mr(ie), Ze = xr(ce, ke, ve);
2381
2462
  I(() => {
2382
- Fr(), Jr();
2383
- }, [Me]);
2384
- const Ze = M !== void 0, [et, Oe] = C(() => {
2385
- var m;
2386
- return M ?? ((m = S == null ? void 0 : S[0]) == null ? void 0 : m.id);
2387
- }), Te = Ze ? M : et, ee = Ge(
2388
- () => (S == null ? void 0 : S.find((m) => m.id === Te)) ?? null,
2389
- [S, Te]
2390
- ), gt = (ee == null ? void 0 : ee.agentId) ?? o, tt = u === "EMBEDDED", [oe, ie] = or({
2463
+ Qr(), oo();
2464
+ }, [ce]);
2465
+ const De = T !== void 0, [He, Lt] = E(() => {
2466
+ var y;
2467
+ return T ?? ((y = S == null ? void 0 : S[0]) == null ? void 0 : y.id);
2468
+ }), Le = De ? T : He, ee = Ge(
2469
+ () => (S == null ? void 0 : S.find((y) => y.id === Le)) ?? null,
2470
+ [S, Le]
2471
+ ), et = (ee == null ? void 0 : ee.agentId) ?? o, ue = p === "EMBEDDED", [Be, We] = ur({
2391
2472
  value: f,
2392
- defaultValue: c,
2393
- onChange: A,
2394
- persistKey: v,
2395
- disablePersistence: tt || b
2396
- }), de = lr(_), ve = Vn(), X = Yn(), ue = Jn(), be = Kn(), He = Xn(), [Lt, nt] = C(!1), [we, rt] = C(!1), [ot, it] = C(!1), [_e, xe] = C(!1), [We, yt] = C(!1), Be = yr({ baseUrl: l, config: s }), De = N(Be);
2397
- De.current = Be;
2398
- const h = N(ft), J = N(Je), Et = N(Xe), Ct = N(ht), Tt = N(pt), Dt = N(le), Pt = N(Ke), St = N(Qe), fe = N(null);
2399
- h.current = ft, J.current = Je, Et.current = Xe, Ct.current = ht, Tt.current = pt, Dt.current = le, Pt.current = Ke, St.current = Qe;
2400
- function ke(m) {
2401
- const p = St.current;
2402
- return p ? p.includes(m) : !0;
2473
+ defaultValue: u,
2474
+ onChange: R,
2475
+ persistKey: h,
2476
+ disablePersistence: ue || b
2477
+ }), te = ue ? "expanded" : Be, le = ue ? () => {
2478
+ } : We, pt = B ?? !ue, ht = J ?? !ue, Ce = pr(_), tt = Zn(), re = er(), ae = nr(), Ee = rr(), nt = or(), [Ct, fe] = E(!1), [pe, rt] = E(!1), [qe, ot] = E(!1), [mt, m] = E(!1), [Y, An] = E(!1), gt = Lr({ baseUrl: l, config: c }), yt = N(gt);
2479
+ yt.current = gt;
2480
+ const Et = N(dt), St = N(Je), Nt = N(Xe), At = N(ft), zt = N(ut), Ot = N(se), Ht = N(Ke), Rt = N(Qe), he = N(null);
2481
+ Et.current = dt, St.current = Je, Nt.current = Xe, At.current = ft, zt.current = ut, Ot.current = se, Ht.current = Ke, Rt.current = Qe;
2482
+ function me(y) {
2483
+ const d = Rt.current;
2484
+ return d ? d.includes(y) : !0;
2403
2485
  }
2404
- function Le(m, p) {
2486
+ function ge(y, d) {
2405
2487
  console.warn(
2406
- `[LiveLayer] Agent command "${m}" blocked — capability "${p}" not in allowlist. See https://livelayer.studio/docs/react/capabilities`
2488
+ `[LiveLayer] Agent command "${y}" blocked — capability "${d}" not in allowlist. See https://livelayer.studio/docs/react/capabilities`
2407
2489
  );
2408
2490
  }
2409
- const lt = E(
2410
- (m) => {
2411
- var K, ae, he, ct;
2412
- const p = m;
2413
- if (!(!p.type || typeof p.type != "string")) {
2414
- if (Ae == null || Ae({ eventName: p.type, data: m }), p.type === "navigate") {
2415
- if (!ke("navigate")) {
2416
- Le("navigate", "navigate");
2491
+ const it = C(
2492
+ (y) => {
2493
+ var G, de, be, at;
2494
+ const d = y;
2495
+ if (!(!d.type || typeof d.type != "string")) {
2496
+ if (Re == null || Re({ eventName: d.type, data: y }), d.type === "navigate") {
2497
+ if (!me("navigate")) {
2498
+ ge("navigate", "navigate");
2417
2499
  return;
2418
2500
  }
2419
- const L = typeof p.href == "string" ? p.href : null;
2420
- if (!L) {
2501
+ const x = typeof d.href == "string" ? d.href : null;
2502
+ if (!x) {
2421
2503
  console.warn(
2422
2504
  `[LiveLayer] Agent emitted "navigate" without href. Skipping. Check your agent's tool schema. See https://livelayer.studio/docs/errors/navigate-missing-href`
2423
2505
  );
2424
2506
  return;
2425
2507
  }
2426
- if (De.current.playPageChange(), h.current) {
2508
+ if (yt.current.playPageChange(), Et.current) {
2427
2509
  try {
2428
- h.current(L);
2429
- } catch (T) {
2510
+ Et.current(x);
2511
+ } catch (D) {
2430
2512
  console.warn(
2431
- `[LiveLayer] onNavigate threw for "${L}". Falling back. Error:`,
2432
- T
2513
+ `[LiveLayer] onNavigate threw for "${x}". Falling back. Error:`,
2514
+ D
2433
2515
  );
2434
2516
  }
2435
2517
  return;
2436
2518
  }
2437
2519
  if (typeof document < "u") {
2438
- const T = document.querySelector(
2439
- `a[href="${L.replace(/"/g, '\\"')}"]`
2520
+ const D = document.querySelector(
2521
+ `a[href="${x.replace(/"/g, '\\"')}"]`
2440
2522
  );
2441
- if (T) {
2442
- T.click();
2523
+ if (D) {
2524
+ D.click();
2443
2525
  return;
2444
2526
  }
2445
2527
  }
2446
2528
  if (typeof window < "u" && typeof history < "u")
2447
2529
  try {
2448
- history.pushState({}, "", L), window.dispatchEvent(new PopStateEvent("popstate"));
2449
- } catch (T) {
2530
+ history.pushState({}, "", x), window.dispatchEvent(new PopStateEvent("popstate"));
2531
+ } catch (D) {
2450
2532
  console.warn(
2451
- `[LiveLayer] history.pushState fallback failed for "${L}". Pass an onNavigate prop to use your router directly. See https://livelayer.studio/docs/react/navigation`,
2452
- T
2533
+ `[LiveLayer] history.pushState fallback failed for "${x}". Pass an onNavigate prop to use your router directly. See https://livelayer.studio/docs/react/navigation`,
2534
+ D
2453
2535
  );
2454
2536
  }
2455
2537
  return;
2456
2538
  }
2457
- if (p.type === "scroll_to") {
2458
- if (!ke("scroll")) {
2459
- Le("scroll_to", "scroll");
2539
+ if (d.type === "scroll_to") {
2540
+ if (!me("scroll")) {
2541
+ ge("scroll_to", "scroll");
2460
2542
  return;
2461
2543
  }
2462
- const L = typeof p.selector == "string" ? p.selector : null;
2463
- if (!L) return;
2464
- const T = p.behavior === "instant" ? "instant" : "smooth";
2465
- if (J.current) {
2544
+ const x = typeof d.selector == "string" ? d.selector : null;
2545
+ if (!x) return;
2546
+ const D = d.behavior === "instant" ? "instant" : "smooth";
2547
+ if (St.current) {
2466
2548
  try {
2467
- J.current(
2468
- L,
2469
- T
2549
+ St.current(
2550
+ x,
2551
+ D
2470
2552
  );
2471
2553
  } catch (W) {
2472
2554
  console.warn("[LiveLayer] onScrollToSelector threw.", W);
@@ -2476,701 +2558,751 @@ const ro = /* @__PURE__ */ new Set([
2476
2558
  if (typeof document < "u") {
2477
2559
  let W = null;
2478
2560
  try {
2479
- W = document.querySelector(L);
2561
+ W = document.querySelector(x);
2480
2562
  } catch {
2481
2563
  console.warn(
2482
- `[LiveLayer] scroll_to: invalid selector "${L}".`
2564
+ `[LiveLayer] scroll_to: invalid selector "${x}".`
2483
2565
  );
2484
2566
  return;
2485
2567
  }
2486
2568
  if (!W) {
2487
2569
  console.warn(
2488
- `[LiveLayer] scroll_to: no element matched "${L}". The user may be on a different page. See https://livelayer.studio/docs/errors/scroll-no-match`
2570
+ `[LiveLayer] scroll_to: no element matched "${x}". The user may be on a different page. See https://livelayer.studio/docs/errors/scroll-no-match`
2489
2571
  );
2490
2572
  return;
2491
2573
  }
2492
2574
  W.scrollIntoView({
2493
- behavior: T,
2575
+ behavior: D,
2494
2576
  block: "start"
2495
2577
  });
2496
2578
  }
2497
2579
  return;
2498
2580
  }
2499
- if (p.type === "request_page_context") {
2500
- if (!ke("read_page")) {
2501
- Le("request_page_context", "read_page");
2581
+ if (d.type === "request_page_context") {
2582
+ if (!me("read_page")) {
2583
+ ge("request_page_context", "read_page");
2502
2584
  return;
2503
2585
  }
2504
- const L = typeof p.requestId == "string" ? p.requestId : void 0, T = (K = fe.current) == null ? void 0 : K.call(fe), W = (Y) => {
2505
- const $ = T, Z = $ == null ? void 0 : $.localParticipant;
2506
- if (Z != null && Z.publishData)
2586
+ const x = typeof d.requestId == "string" ? d.requestId : void 0, D = (G = he.current) == null ? void 0 : G.call(he), W = (V) => {
2587
+ const z = D, Q = z == null ? void 0 : z.localParticipant;
2588
+ if (Q != null && Q.publishData)
2507
2589
  try {
2508
- const te = L ? { ...Y, requestId: L } : Y, Fe = new TextEncoder().encode(JSON.stringify(te));
2509
- Z.publishData(Fe, { reliable: !0 });
2510
- } catch (te) {
2511
- console.warn("[LiveLayer] publishData failed.", te);
2590
+ const ne = x ? { ...V, requestId: x } : V, Ue = new TextEncoder().encode(JSON.stringify(ne));
2591
+ Q.publishData(Ue, { reliable: !0 });
2592
+ } catch (ne) {
2593
+ console.warn("[LiveLayer] publishData failed.", ne);
2512
2594
  }
2513
- }, z = Dt.current, V = Tt.current;
2595
+ }, O = Ot.current, j = zt.current;
2514
2596
  try {
2515
- if (V) {
2516
- const Y = V(z);
2517
- if (Y instanceof Promise) {
2518
- W({ type: "page_context_pending" }), Y.then(($) => W({ type: "page_context", context: $ })).catch(($) => {
2597
+ if (j) {
2598
+ const V = j(O);
2599
+ if (V instanceof Promise) {
2600
+ W({ type: "page_context_pending" }), V.then((z) => W({ type: "page_context", context: z })).catch((z) => {
2519
2601
  console.warn(
2520
2602
  "[LiveLayer] getPageContext rejected; falling back to default walker.",
2521
- $
2603
+ z
2522
2604
  ), W({
2523
2605
  type: "page_context",
2524
- context: fn(z)
2606
+ context: gn(O)
2525
2607
  });
2526
2608
  });
2527
2609
  return;
2528
2610
  }
2529
- W({ type: "page_context", context: Y });
2611
+ W({ type: "page_context", context: V });
2530
2612
  return;
2531
2613
  }
2532
2614
  W({
2533
2615
  type: "page_context",
2534
- context: fn(z)
2616
+ context: gn(O)
2535
2617
  });
2536
- } catch (Y) {
2618
+ } catch (V) {
2537
2619
  console.warn(
2538
2620
  "[LiveLayer] page-context extraction threw. Sending empty context.",
2539
- Y
2621
+ V
2540
2622
  ), W({
2541
2623
  type: "page_context",
2542
- context: { url: "", title: "", pathname: "/", regions: [], visibleText: "", visibleLinks: [], visibleFields: [], forms: [], extras: z }
2624
+ context: { url: "", title: "", pathname: "/", regions: [], visibleText: "", visibleLinks: [], visibleFields: [], forms: [], extras: O }
2543
2625
  });
2544
2626
  }
2545
2627
  return;
2546
2628
  }
2547
- if (p.type === "scroll_page") {
2548
- if (!ke("scroll")) {
2549
- Le("scroll_page", "scroll");
2629
+ if (d.type === "scroll_page") {
2630
+ if (!me("scroll")) {
2631
+ ge("scroll_page", "scroll");
2550
2632
  return;
2551
2633
  }
2552
- const L = p.direction;
2553
- if (L !== "up" && L !== "down" && L !== "top" && L !== "bottom") {
2634
+ const x = d.direction;
2635
+ if (x !== "up" && x !== "down" && x !== "top" && x !== "bottom") {
2554
2636
  console.warn(
2555
- `[LiveLayer] scroll_page: invalid direction "${String(L)}". Expected up | down | top | bottom.`
2637
+ `[LiveLayer] scroll_page: invalid direction "${String(x)}". Expected up | down | top | bottom.`
2556
2638
  );
2557
2639
  return;
2558
2640
  }
2559
- const T = p.behavior === "instant" ? "instant" : "smooth";
2560
- if (Et.current) {
2641
+ const D = d.behavior === "instant" ? "instant" : "smooth";
2642
+ if (Nt.current) {
2561
2643
  try {
2562
- Et.current(
2563
- L,
2564
- T
2644
+ Nt.current(
2645
+ x,
2646
+ D
2565
2647
  );
2566
- } catch ($) {
2567
- console.warn("[LiveLayer] onScrollPage threw.", $);
2648
+ } catch (z) {
2649
+ console.warn("[LiveLayer] onScrollPage threw.", z);
2568
2650
  }
2569
2651
  return;
2570
2652
  }
2571
2653
  if (typeof window > "u") return;
2572
- const W = { behavior: T }, z = to(), V = ($) => {
2573
- z instanceof Window ? z.scrollBy({ top: $, ...W }) : z.scrollBy({ top: $, ...W });
2574
- }, Y = ($) => {
2575
- z instanceof Window ? z.scrollTo({ top: $, ...W }) : z.scrollTo({ top: $, ...W });
2654
+ const W = { behavior: D }, O = fo(), j = (z) => {
2655
+ O instanceof Window ? O.scrollBy({ top: z, ...W }) : O.scrollBy({ top: z, ...W });
2656
+ }, V = (z) => {
2657
+ O instanceof Window ? O.scrollTo({ top: z, ...W }) : O.scrollTo({ top: z, ...W });
2576
2658
  };
2577
- L === "up" ? V(-pn(z)) : L === "down" ? V(pn(z)) : Y(L === "top" ? 0 : no(z));
2659
+ x === "up" ? j(-vn(O)) : x === "down" ? j(vn(O)) : V(x === "top" ? 0 : po(O));
2578
2660
  return;
2579
2661
  }
2580
- if (p.type === "click") {
2581
- if (!ke("click")) {
2582
- Le("click", "click");
2662
+ if (d.type === "click") {
2663
+ if (!me("click")) {
2664
+ ge("click", "click");
2583
2665
  return;
2584
2666
  }
2585
- const L = typeof p.selector == "string" ? p.selector : null;
2586
- if (!L) {
2667
+ const x = typeof d.selector == "string" ? d.selector : null;
2668
+ if (!x) {
2587
2669
  console.warn("[LiveLayer] click: missing selector.");
2588
2670
  return;
2589
2671
  }
2590
- if (Ct.current) {
2672
+ if (At.current) {
2591
2673
  try {
2592
- Ct.current(L);
2674
+ At.current(x);
2593
2675
  } catch (W) {
2594
2676
  console.warn("[LiveLayer] onClick threw.", W);
2595
2677
  }
2596
2678
  return;
2597
2679
  }
2598
2680
  if (typeof document > "u") return;
2599
- let T = null;
2681
+ let D = null;
2600
2682
  try {
2601
- T = document.querySelector(L);
2683
+ D = document.querySelector(x);
2602
2684
  } catch {
2603
2685
  console.warn(
2604
- `[LiveLayer] click: invalid selector "${L}".`
2686
+ `[LiveLayer] click: invalid selector "${x}".`
2605
2687
  );
2606
2688
  return;
2607
2689
  }
2608
- if (!T) {
2690
+ if (!D) {
2609
2691
  console.warn(
2610
- `[LiveLayer] click: no element matched "${L}". See https://livelayer.studio/docs/errors/click-no-match`
2692
+ `[LiveLayer] click: no element matched "${x}". See https://livelayer.studio/docs/errors/click-no-match`
2611
2693
  );
2612
2694
  return;
2613
2695
  }
2614
- if (T.closest('[data-ll-private="true"], .ll-widget')) {
2696
+ if (D.closest('[data-ll-private="true"], .ll-widget')) {
2615
2697
  console.warn(
2616
2698
  "[LiveLayer] click: refusing to click element inside a private subtree."
2617
2699
  );
2618
2700
  return;
2619
2701
  }
2620
- (ae = T.click) == null || ae.call(T);
2702
+ (de = D.click) == null || de.call(D);
2621
2703
  return;
2622
2704
  }
2623
- if (p.type === "fill_form" || p.type === "focus_field") {
2624
- if (!ke("fill_forms")) {
2625
- Le(p.type, "fill_forms");
2705
+ if (d.type === "fill_form" || d.type === "focus_field") {
2706
+ if (!me("fill_forms")) {
2707
+ ge(d.type, "fill_forms");
2626
2708
  return;
2627
2709
  }
2628
2710
  if (typeof document > "u") return;
2629
- p.type === "fill_form" && De.current.playConfirmation();
2630
- const L = typeof p.formId == "string" ? p.formId : null;
2631
- if (!L) {
2632
- console.warn(`[LiveLayer] ${p.type}: missing formId.`);
2711
+ d.type === "fill_form" && yt.current.playConfirmation();
2712
+ const x = typeof d.formId == "string" ? d.formId : null;
2713
+ if (!x) {
2714
+ console.warn(`[LiveLayer] ${d.type}: missing formId.`);
2633
2715
  return;
2634
2716
  }
2635
- const T = document.querySelector(
2636
- `[data-ll-form="${L.replace(/"/g, '\\"')}"]`
2637
- );
2638
- if (!T) {
2717
+ const D = yn(document, x);
2718
+ if (!D) {
2639
2719
  console.warn(
2640
- `[LiveLayer] ${p.type}: no form with data-ll-form="${L}". Tag your form with <LiveLayerForm id> or data-ll-form. See https://livelayer.studio/docs/react/forms`
2720
+ `[LiveLayer] ${d.type}: no <form> matched id="${x}" (or matching name / data-ll-intent slug). Forms are auto-discovered — make sure the form has an \`id\`, \`name\`, or \`data-ll-intent\` attribute the agent observed in PageContext.forms.`
2641
2721
  );
2642
2722
  return;
2643
2723
  }
2644
- if (T.closest('[data-ll-private="true"], .ll-widget')) {
2724
+ if (D.closest('[data-ll-private="true"], [data-ll-skip], .ll-widget')) {
2645
2725
  console.warn(
2646
- `[LiveLayer] ${p.type}: refusing to touch a form in a private subtree.`
2726
+ `[LiveLayer] ${d.type}: refusing to touch a form in a private / opted-out subtree.`
2647
2727
  );
2648
2728
  return;
2649
2729
  }
2650
- if (p.type === "focus_field") {
2651
- const z = typeof p.fieldName == "string" ? p.fieldName : null;
2652
- if (!z) {
2730
+ if (d.type === "focus_field") {
2731
+ const O = typeof d.fieldName == "string" ? d.fieldName : null;
2732
+ if (!O) {
2653
2733
  console.warn("[LiveLayer] focus_field: missing fieldName.");
2654
2734
  return;
2655
2735
  }
2656
- const V = T.querySelector(`[data-ll-field="${z.replace(/"/g, '\\"')}"]`);
2657
- if (!V) {
2736
+ const j = D.querySelector(`[name="${O.replace(/"/g, '\\"')}"]`);
2737
+ if (!j) {
2658
2738
  console.warn(
2659
- `[LiveLayer] focus_field: no field "${z}" in form "${L}".`
2739
+ `[LiveLayer] focus_field: no input with name="${O}" in form "${x}".`
2660
2740
  );
2661
2741
  return;
2662
2742
  }
2663
- if (!xt(V)) {
2743
+ if (!xt(j)) {
2664
2744
  console.warn(
2665
- `[LiveLayer] focus_field: field "${z}" is privacy-protected and not focusable.`
2745
+ `[LiveLayer] focus_field: field "${O}" is privacy-protected and not focusable.`
2666
2746
  );
2667
2747
  return;
2668
2748
  }
2669
- V.focus();
2749
+ j.focus();
2670
2750
  return;
2671
2751
  }
2672
- const W = p.values && typeof p.values == "object" ? p.values : null;
2752
+ const W = d.values && typeof d.values == "object" ? d.values : null;
2673
2753
  if (!W) {
2674
2754
  console.warn("[LiveLayer] fill_form: missing or invalid values.");
2675
2755
  return;
2676
2756
  }
2677
- for (const [z, V] of Object.entries(W)) {
2678
- if (typeof V != "string") continue;
2679
- const Y = T.querySelector(`[data-ll-field="${z.replace(/"/g, '\\"')}"]`);
2680
- if (!Y) {
2757
+ for (const [O, j] of Object.entries(W)) {
2758
+ if (typeof j != "string") continue;
2759
+ const V = D.querySelector(`[name="${O.replace(/"/g, '\\"')}"]`);
2760
+ if (!V) {
2681
2761
  console.warn(
2682
- `[LiveLayer] fill_form: no field "${z}" in form "${L}". Skipping.`
2762
+ `[LiveLayer] fill_form: no input with name="${O}" in form "${x}". Skipping.`
2683
2763
  );
2684
2764
  continue;
2685
2765
  }
2686
- if (!xt(Y)) {
2766
+ if (!xt(V)) {
2687
2767
  console.warn(
2688
- `[LiveLayer] fill_form: field "${z}" is privacy-protected (password / cc-* / private). Skipping.`
2768
+ `[LiveLayer] fill_form: field "${O}" is privacy-protected (password / cc-* / private). Skipping.`
2689
2769
  );
2690
2770
  continue;
2691
2771
  }
2692
2772
  try {
2693
- Xr(Y, V);
2694
- } catch ($) {
2773
+ lo(V, j);
2774
+ } catch (z) {
2695
2775
  console.warn(
2696
- `[LiveLayer] fill_form: failed to set "${z}".`,
2697
- $
2776
+ `[LiveLayer] fill_form: failed to set "${O}".`,
2777
+ z
2698
2778
  );
2699
2779
  }
2700
2780
  }
2701
2781
  return;
2702
2782
  }
2703
- if (p.type === "submit_form") {
2704
- if (!ke("submit_forms")) {
2705
- Le("submit_form", "submit_forms");
2783
+ if (d.type === "submit_form") {
2784
+ if (!me("submit_forms")) {
2785
+ ge("submit_form", "submit_forms");
2706
2786
  return;
2707
2787
  }
2708
2788
  if (typeof document > "u") return;
2709
- const L = typeof p.formId == "string" ? p.formId : null;
2710
- if (!L) {
2789
+ const x = typeof d.formId == "string" ? d.formId : null;
2790
+ if (!x) {
2711
2791
  console.warn("[LiveLayer] submit_form: missing formId.");
2712
2792
  return;
2713
2793
  }
2714
- De.current.playConfirmation();
2715
- const T = document.querySelector(
2716
- `[data-ll-form="${L.replace(/"/g, '\\"')}"]`
2717
- );
2718
- if (!T) {
2794
+ yt.current.playConfirmation();
2795
+ const D = yn(document, x);
2796
+ if (!D) {
2719
2797
  console.warn(
2720
- `[LiveLayer] submit_form: no form with data-ll-form="${L}".`
2798
+ `[LiveLayer] submit_form: no <form> matched id="${x}" (or matching name / data-ll-intent slug).`
2721
2799
  );
2722
2800
  return;
2723
2801
  }
2724
- if (T.closest('[data-ll-private="true"], .ll-widget')) {
2802
+ if (D.closest('[data-ll-private="true"], [data-ll-skip], .ll-widget')) {
2725
2803
  console.warn(
2726
- "[LiveLayer] submit_form: refusing to submit a form in a private subtree."
2804
+ "[LiveLayer] submit_form: refusing to submit a form in a private / opted-out subtree."
2727
2805
  );
2728
2806
  return;
2729
2807
  }
2730
- const W = typeof p.requestId == "string" ? p.requestId : void 0, z = (he = fe.current) == null ? void 0 : he.call(fe), V = (Z) => {
2731
- const te = z, Fe = te == null ? void 0 : te.localParticipant;
2732
- if (Fe != null && Fe.publishData)
2808
+ const W = typeof d.requestId == "string" ? d.requestId : void 0, O = (be = he.current) == null ? void 0 : be.call(he), j = (Q) => {
2809
+ const ne = O, Ue = ne == null ? void 0 : ne.localParticipant;
2810
+ if (Ue != null && Ue.publishData)
2733
2811
  try {
2734
- const $n = W ? { ...Z, requestId: W } : Z, zn = new TextEncoder().encode(JSON.stringify($n));
2735
- Fe.publishData(zn, { reliable: !0 });
2812
+ const qn = W ? { ...Q, requestId: W } : Q, Fn = new TextEncoder().encode(JSON.stringify(qn));
2813
+ Ue.publishData(Fn, { reliable: !0 });
2736
2814
  } catch {
2737
2815
  }
2738
2816
  };
2739
- let Y = !1;
2740
- const $ = () => {
2741
- Y = !0, V({ type: "form_submitted", formId: L });
2817
+ let V = !1;
2818
+ const z = () => {
2819
+ V = !0, j({ type: "form_submitted", formId: x });
2742
2820
  };
2743
- T.addEventListener("submit", $, { once: !0 });
2821
+ D.addEventListener("submit", z, { once: !0 });
2744
2822
  try {
2745
- typeof T.requestSubmit == "function" ? T.requestSubmit() : T.submit();
2746
- } catch (Z) {
2747
- console.warn("[LiveLayer] submit_form: requestSubmit threw.", Z), T.removeEventListener("submit", $), V({
2823
+ typeof D.requestSubmit == "function" ? D.requestSubmit() : D.submit();
2824
+ } catch (Q) {
2825
+ console.warn("[LiveLayer] submit_form: requestSubmit threw.", Q), D.removeEventListener("submit", z), j({
2748
2826
  type: "form_submit_blocked",
2749
- formId: L,
2827
+ formId: x,
2750
2828
  reason: "exception"
2751
2829
  });
2752
2830
  return;
2753
2831
  }
2754
2832
  setTimeout(() => {
2755
- Y || (T.removeEventListener("submit", $), V({
2833
+ V || (D.removeEventListener("submit", z), j({
2756
2834
  type: "form_submit_blocked",
2757
- formId: L,
2835
+ formId: x,
2758
2836
  reason: "validation"
2759
2837
  }));
2760
2838
  }, 500);
2761
2839
  return;
2762
2840
  }
2763
- if (p.type === "request_routes") {
2764
- if (!ke("read_page")) {
2765
- Le("request_routes", "read_page");
2841
+ if (d.type === "request_routes") {
2842
+ if (!me("read_page")) {
2843
+ ge("request_routes", "read_page");
2766
2844
  return;
2767
2845
  }
2768
- const L = typeof p.requestId == "string" ? p.requestId : void 0, W = (ct = fe.current) == null ? void 0 : ct.call(fe), z = W == null ? void 0 : W.localParticipant;
2769
- if (!(z != null && z.publishData)) return;
2770
- const V = ($) => {
2846
+ const x = typeof d.requestId == "string" ? d.requestId : void 0, W = (at = he.current) == null ? void 0 : at.call(he), O = W == null ? void 0 : W.localParticipant;
2847
+ if (!(O != null && O.publishData)) return;
2848
+ const j = (z) => {
2771
2849
  try {
2772
- const Z = L ? { type: "routes", routes: $, requestId: L } : { type: "routes", routes: $ }, te = new TextEncoder().encode(JSON.stringify(Z));
2773
- z.publishData(te, { reliable: !0 });
2774
- } catch (Z) {
2775
- console.warn("[LiveLayer] request_routes: publishData failed.", Z);
2850
+ const Q = x ? { type: "routes", routes: z, requestId: x } : { type: "routes", routes: z }, ne = new TextEncoder().encode(JSON.stringify(Q));
2851
+ O.publishData(ne, { reliable: !0 });
2852
+ } catch (Q) {
2853
+ console.warn("[LiveLayer] request_routes: publishData failed.", Q);
2776
2854
  }
2777
- }, Y = Pt.current;
2778
- if (Y) {
2855
+ }, V = Ht.current;
2856
+ if (V) {
2779
2857
  try {
2780
- const $ = Y(), Z = (te) => {
2781
- if (!Array.isArray(te)) {
2782
- V([]);
2858
+ const z = V(), Q = (ne) => {
2859
+ if (!Array.isArray(ne)) {
2860
+ j([]);
2783
2861
  return;
2784
2862
  }
2785
- V(te.map(jr).slice(0, 200));
2863
+ j(ne.map(eo).slice(0, 200));
2786
2864
  };
2787
- $ instanceof Promise ? $.then(Z).catch((te) => {
2865
+ z instanceof Promise ? z.then(Q).catch((ne) => {
2788
2866
  console.warn(
2789
2867
  "[LiveLayer] getRoutes rejected; falling back to DOM walker.",
2790
- te
2791
- ), V(At());
2792
- }) : Z($);
2793
- } catch ($) {
2868
+ ne
2869
+ ), j(Mt());
2870
+ }) : Q(z);
2871
+ } catch (z) {
2794
2872
  console.warn(
2795
2873
  "[LiveLayer] getRoutes threw; falling back to DOM walker.",
2796
- $
2797
- ), V(At());
2874
+ z
2875
+ ), j(Mt());
2798
2876
  }
2799
2877
  return;
2800
2878
  }
2801
2879
  try {
2802
- V(At());
2803
- } catch ($) {
2804
- console.warn("[LiveLayer] request_routes: extractRoutes threw.", $);
2880
+ j(Mt());
2881
+ } catch (z) {
2882
+ console.warn("[LiveLayer] request_routes: extractRoutes threw.", z);
2805
2883
  }
2806
2884
  return;
2807
2885
  }
2808
- ro.has(p.type) || Re == null || Re(p);
2886
+ if (d.type === "task_field_updated") {
2887
+ if (!me("collect_data")) {
2888
+ ge("task_field_updated", "collect_data");
2889
+ return;
2890
+ }
2891
+ const x = {
2892
+ phase: "field",
2893
+ fieldId: typeof d.fieldId == "string" ? d.fieldId : "",
2894
+ fieldName: typeof d.fieldName == "string" ? d.fieldName : typeof d.fieldId == "string" ? d.fieldId : "",
2895
+ value: typeof d.value == "string" ? d.value : "",
2896
+ kind: typeof d.kind == "string" ? d.kind : "text",
2897
+ source: d.source === "slide" ? "slide" : d.source === "page" ? "page" : "agent",
2898
+ ...typeof d.slideId == "string" ? { slideId: d.slideId } : {},
2899
+ ...typeof d.formId == "string" ? { formId: d.formId } : {}
2900
+ };
2901
+ if (typeof document < "u")
2902
+ try {
2903
+ document.dispatchEvent(
2904
+ new CustomEvent("ll-collected", { detail: x })
2905
+ );
2906
+ } catch {
2907
+ }
2908
+ return;
2909
+ }
2910
+ if (d.type === "task_completed") {
2911
+ if (!me("collect_data")) {
2912
+ ge("task_completed", "collect_data");
2913
+ return;
2914
+ }
2915
+ const x = d.result;
2916
+ if (!x || typeof x != "object") {
2917
+ console.warn(
2918
+ "[LiveLayer] task_completed missing `result` payload."
2919
+ );
2920
+ return;
2921
+ }
2922
+ if (typeof document < "u")
2923
+ try {
2924
+ document.dispatchEvent(
2925
+ new CustomEvent("ll-collected", {
2926
+ detail: { phase: "complete", result: x }
2927
+ })
2928
+ );
2929
+ } catch {
2930
+ }
2931
+ try {
2932
+ Me == null || Me(
2933
+ x
2934
+ );
2935
+ } catch (D) {
2936
+ console.warn("[LiveLayer] onCollect threw.", D);
2937
+ }
2938
+ return;
2939
+ }
2940
+ ho.has(d.type) || Ie == null || Ie(d);
2809
2941
  }
2810
2942
  },
2811
- [Re, Ae]
2812
- ), Q = jn({
2813
- agentId: P ? "__controlled__" : gt,
2943
+ [Ie, Re, Me]
2944
+ ), X = Qn({
2945
+ agentId: $ ? "__controlled__" : et,
2814
2946
  baseUrl: l,
2815
2947
  apiKey: i,
2816
- sessionEndpoint: d,
2948
+ sessionEndpoint: s,
2817
2949
  sessionBody: a,
2818
- onDataMessage: P ? void 0 : lt
2950
+ onDataMessage: $ ? void 0 : it
2819
2951
  });
2820
2952
  I(() => {
2821
- if (P != null && P.subscribeToDataMessages)
2822
- return P.subscribeToDataMessages(lt);
2823
- }, [P, lt]), fe.current = () => {
2824
- var m;
2825
- return (m = Q.getRoom) == null ? void 0 : m.call(Q);
2953
+ if ($ != null && $.subscribeToDataMessages)
2954
+ return $.subscribeToDataMessages(it);
2955
+ }, [$, it]), he.current = () => {
2956
+ var y;
2957
+ return (y = X.getRoom) == null ? void 0 : y.call(X);
2826
2958
  }, I(() => {
2827
- var K;
2959
+ var G;
2828
2960
  if (typeof window > "u") return;
2829
- const m = ((K = window.location) == null ? void 0 : K.hostname) || "";
2830
- if (m === "localhost" || m === "127.0.0.1" || m === "0.0.0.0" || m.endsWith(".local") || m.endsWith(".test"))
2831
- return window.__livelayerSimulateCommand = (ae) => {
2961
+ const y = ((G = window.location) == null ? void 0 : G.hostname) || "";
2962
+ if (y === "localhost" || y === "127.0.0.1" || y === "0.0.0.0" || y.endsWith(".local") || y.endsWith(".test"))
2963
+ return window.__livelayerSimulateCommand = (de) => {
2832
2964
  try {
2833
- lt(ae);
2834
- } catch (he) {
2835
- console.warn("[LiveLayer] simulate-command threw:", he);
2965
+ it(de);
2966
+ } catch (be) {
2967
+ console.warn("[LiveLayer] simulate-command threw:", be);
2836
2968
  }
2837
2969
  }, () => {
2838
2970
  delete window.__livelayerSimulateCommand;
2839
2971
  };
2840
- }, [lt]);
2841
- const w = Ge(() => P ? {
2842
- connectionState: P.connectionState,
2843
- agentState: P.agentState,
2844
- transcript: P.transcript,
2845
- videoElement: P.videoElement,
2846
- audioElement: P.audioElement,
2847
- canResume: P.canResume,
2848
- error: P.error,
2972
+ }, [it]);
2973
+ const k = Ge(() => $ ? {
2974
+ connectionState: $.connectionState,
2975
+ agentState: $.agentState,
2976
+ transcript: $.transcript,
2977
+ videoElement: $.videoElement,
2978
+ audioElement: $.audioElement,
2979
+ canResume: $.canResume,
2980
+ error: $.error,
2849
2981
  agentConfig: null,
2850
2982
  connect: async () => {
2851
- await P.onConnect();
2983
+ await $.onConnect();
2852
2984
  },
2853
- disconnect: () => P.onDisconnect(),
2985
+ disconnect: () => $.onDisconnect(),
2854
2986
  // Dummy getRoom for shape compatibility — controlled consumers own the Room.
2855
2987
  // Internal session's getRoom returns null when no real connect has happened,
2856
2988
  // so we reuse its reference for type consistency.
2857
- getRoom: Q.getRoom,
2989
+ getRoom: X.getRoom,
2858
2990
  isControlled: !0
2859
2991
  } : {
2860
- connectionState: Q.connectionState,
2861
- agentState: Q.agentState,
2862
- transcript: Q.transcript,
2863
- videoElement: Q.videoElement,
2864
- audioElement: Q.audioElement,
2865
- canResume: Q.canResume,
2866
- error: Q.error,
2867
- agentConfig: Q.agentConfig,
2868
- connect: Q.connect,
2869
- disconnect: Q.disconnect,
2870
- getRoom: Q.getRoom,
2992
+ connectionState: X.connectionState,
2993
+ agentState: X.agentState,
2994
+ transcript: X.transcript,
2995
+ videoElement: X.videoElement,
2996
+ audioElement: X.audioElement,
2997
+ canResume: X.canResume,
2998
+ error: X.error,
2999
+ agentConfig: X.agentConfig,
3000
+ connect: X.connect,
3001
+ disconnect: X.disconnect,
3002
+ getRoom: X.getRoom,
2871
3003
  isControlled: !1
2872
- }, [P, Q]), $t = N(w);
2873
- $t.current = w;
2874
- const zt = N(P);
2875
- zt.current = P, Hn(
3004
+ }, [$, X]), Bt = N(k);
3005
+ Bt.current = k;
3006
+ const Wt = N($);
3007
+ Wt.current = $, jn(
2876
3008
  r,
2877
3009
  () => ({
2878
- sendData: async (m) => {
2879
- var he, ct;
2880
- const p = zt.current;
2881
- if (p != null && p.publishData) {
3010
+ sendData: async (y) => {
3011
+ var be, at;
3012
+ const d = Wt.current;
3013
+ if (d != null && d.publishData) {
2882
3014
  try {
2883
- await p.publishData(m);
2884
- } catch (L) {
2885
- console.warn("[AvatarWidget] sendData (controlled) failed:", L);
3015
+ await d.publishData(y);
3016
+ } catch (x) {
3017
+ console.warn("[AvatarWidget] sendData (controlled) failed:", x);
2886
3018
  }
2887
3019
  return;
2888
3020
  }
2889
- const K = (ct = (he = $t.current) == null ? void 0 : he.getRoom) == null ? void 0 : ct.call(he), ae = K == null ? void 0 : K.localParticipant;
2890
- if (ae != null && ae.publishData)
3021
+ const G = (at = (be = Bt.current) == null ? void 0 : be.getRoom) == null ? void 0 : at.call(be), de = G == null ? void 0 : G.localParticipant;
3022
+ if (de != null && de.publishData)
2891
3023
  try {
2892
- const L = new TextEncoder().encode(JSON.stringify(m));
2893
- await ae.publishData(L, { reliable: !0 });
2894
- } catch (L) {
2895
- console.warn("[AvatarWidget] sendData failed:", L);
3024
+ const x = new TextEncoder().encode(JSON.stringify(y));
3025
+ await de.publishData(x, { reliable: !0 });
3026
+ } catch (x) {
3027
+ console.warn("[AvatarWidget] sendData failed:", x);
2896
3028
  }
2897
3029
  }
2898
3030
  }),
2899
3031
  []
2900
3032
  );
2901
- const Ot = N(null);
3033
+ const qt = N(null);
2902
3034
  I(() => {
2903
- const m = w.videoElement, p = Ot.current;
2904
- if (!(!m || !p))
2905
- return p.appendChild(m), () => {
2906
- m.parentNode === p && p.removeChild(m);
3035
+ const y = k.videoElement, d = qt.current;
3036
+ if (!(!y || !d))
3037
+ return d.appendChild(y), () => {
3038
+ y.parentNode === d && d.removeChild(y);
2907
3039
  };
2908
- }, [w.videoElement]), I(() => {
2909
- const m = w.audioElement;
2910
- if (!m) return;
2911
- ve.attach(m);
2912
- const p = m.play();
2913
- return p && typeof p.catch == "function" && p.catch((K) => {
2914
- (K == null ? void 0 : K.name) === "NotAllowedError" && nt(!0);
3040
+ }, [k.videoElement]), I(() => {
3041
+ const y = k.audioElement;
3042
+ if (!y) return;
3043
+ tt.attach(y);
3044
+ const d = y.play();
3045
+ return d && typeof d.catch == "function" && d.catch((G) => {
3046
+ (G == null ? void 0 : G.name) === "NotAllowedError" && fe(!0);
2915
3047
  }), () => {
2916
- ve.detach();
3048
+ tt.detach();
2917
3049
  };
2918
- }, [w.audioElement]), I(() => {
2919
- if (w.isControlled || w.connectionState !== "connected") return;
2920
- const m = w.getRoom();
2921
- if (m)
2922
- return X.setupMic(m).catch(() => {
3050
+ }, [k.audioElement]), I(() => {
3051
+ if (k.isControlled || k.connectionState !== "connected") return;
3052
+ const y = k.getRoom();
3053
+ if (y)
3054
+ return re.setupMic(y).catch(() => {
2923
3055
  }), () => {
2924
- X.teardownMic();
3056
+ re.teardownMic();
2925
3057
  };
2926
- }, [w.isControlled, w.connectionState]), I(() => {
2927
- var p;
2928
- if (w.connectionState !== "connected") return;
2929
- const m = w.isControlled ? (p = P == null ? void 0 : P.getRoom) == null ? void 0 : p.call(P) : w.getRoom();
2930
- if (m)
2931
- return ue.attachRoom(m), be.attachRoom(m), w.isControlled && X.attachRoom(m), He.refresh(), () => {
2932
- ue.teardown(), be.teardown();
3058
+ }, [k.isControlled, k.connectionState]), I(() => {
3059
+ var d;
3060
+ if (k.connectionState !== "connected") return;
3061
+ const y = k.isControlled ? (d = $ == null ? void 0 : $.getRoom) == null ? void 0 : d.call($) : k.getRoom();
3062
+ if (y)
3063
+ return ae.attachRoom(y), Ee.attachRoom(y), k.isControlled && re.attachRoom(y), nt.refresh(), () => {
3064
+ ae.teardown(), Ee.teardown();
2933
3065
  };
2934
- }, [w.isControlled, w.connectionState, P]), I(() => {
2935
- const m = w.audioElement;
2936
- m && (m.muted = We);
2937
- }, [w.audioElement, We]);
2938
- const Ln = E((m) => {
2939
- const p = { type: "user_message", text: m };
2940
- if (P != null && P.publishData) {
3066
+ }, [k.isControlled, k.connectionState, $]), I(() => {
3067
+ const y = k.audioElement;
3068
+ y && (y.muted = Y);
3069
+ }, [k.audioElement, Y]);
3070
+ const Rn = C((y) => {
3071
+ const d = { type: "user_message", text: y };
3072
+ if ($ != null && $.publishData) {
2941
3073
  try {
2942
- P.publishData(p);
3074
+ $.publishData(d);
2943
3075
  } catch {
2944
3076
  }
2945
3077
  return;
2946
3078
  }
2947
- const K = w.getRoom();
2948
- if (K)
3079
+ const G = k.getRoom();
3080
+ if (G)
2949
3081
  try {
2950
- const ae = new TextEncoder().encode(JSON.stringify(p));
2951
- K.localParticipant.publishData(ae, { reliable: !0 });
3082
+ const de = new TextEncoder().encode(JSON.stringify(d));
3083
+ G.localParticipant.publishData(de, { reliable: !0 });
2952
3084
  } catch {
2953
3085
  }
2954
- }, [w, P]), En = E(() => {
2955
- yt((m) => !m);
3086
+ }, [k, $]), In = C(() => {
3087
+ An((y) => !y);
2956
3088
  }, []);
2957
3089
  I(() => {
2958
- Ne == null || Ne(w.connectionState), w.connectionState === "connected" ? Ce == null || Ce() : w.connectionState === "disconnected" && ($e == null || $e());
2959
- }, [w.connectionState, Ce, $e, Ne]), I(() => {
2960
- Se == null || Se(w.transcript);
2961
- }, [w.transcript, Se]), I(() => {
2962
- ze == null || ze(w.agentState);
2963
- }, [w.agentState, ze]), I(() => {
2964
- Be.setThinking(w.agentState === "thinking");
2965
- }, [w.agentState, Be]);
2966
- const Ht = N(!1);
3090
+ Ae == null || Ae(k.connectionState), k.connectionState === "connected" ? Se == null || Se() : k.connectionState === "disconnected" && ($e == null || $e());
3091
+ }, [k.connectionState, Se, $e, Ae]), I(() => {
3092
+ Ne == null || Ne(k.transcript);
3093
+ }, [k.transcript, Ne]), I(() => {
3094
+ ze == null || ze(k.agentState);
3095
+ }, [k.agentState, ze]), I(() => {
3096
+ gt.setThinking(k.agentState === "thinking");
3097
+ }, [k.agentState, gt]);
3098
+ const Ft = N(!1);
2967
3099
  I(() => {
2968
- w.isControlled || !y || Ht.current || re && w.connectionState === "idle" && (Ht.current = !0, w.connect());
2969
- }, [y, w.connectionState, w, re]);
2970
- const Cn = E(
2971
- (m) => {
2972
- const p = S == null ? void 0 : S.find((K) => K.id === m);
2973
- p && (it(!1), m !== Te && (rt(!0), w.disconnect(), Ze || Oe(m), D == null || D(p)));
3100
+ !v || Ft.current || Ze && k.connectionState === "idle" && (Ft.current = !0, k.connect());
3101
+ }, [v, k.connectionState, k, Ze]);
3102
+ const Mn = C(
3103
+ (y) => {
3104
+ const d = S == null ? void 0 : S.find((G) => G.id === y);
3105
+ d && (ot(!1), y !== Le && (rt(!0), k.disconnect(), De || Lt(y), A == null || A(d)));
2974
3106
  },
2975
3107
  [
2976
3108
  S,
2977
- Te,
2978
- w,
2979
- Ze,
2980
- D
3109
+ Le,
3110
+ k,
3111
+ De,
3112
+ A
2981
3113
  ]
2982
3114
  );
2983
3115
  I(() => {
2984
- we && w.connectionState === "connected" && rt(!1);
2985
- }, [w.connectionState, we]), I(() => {
2986
- if (!ot) return;
2987
- const m = (p) => {
2988
- p.key === "Escape" && it(!1);
3116
+ pe && k.connectionState === "connected" && rt(!1);
3117
+ }, [k.connectionState, pe]), I(() => {
3118
+ if (!qe) return;
3119
+ const y = (d) => {
3120
+ d.key === "Escape" && ot(!1);
2989
3121
  };
2990
- return window.addEventListener("keydown", m), () => window.removeEventListener("keydown", m);
2991
- }, [ot]);
2992
- const Sn = !!B || !!(ee != null && ee.avatarImageUrl) || w.isControlled, at = Qn(gt, l, Sn);
2993
- Qe === void 0 && ((Ft = at.info) != null && Ft.capabilities) && (St.current = at.info.capabilities);
2994
- const vt = (ee == null ? void 0 : ee.name) ?? q ?? ((Ut = w.agentConfig) == null ? void 0 : Ut.name) ?? ((jt = at.info) == null ? void 0 : jt.name) ?? "Live Layer", Nt = (ee == null ? void 0 : ee.avatarImageUrl) ?? B ?? ((Vt = w.agentConfig) == null ? void 0 : Vt.avatarImageUrl) ?? ((Yt = at.info) == null ? void 0 : Yt.avatarImageUrl) ?? null, Nn = k ?? ((Gt = w.agentConfig) == null ? void 0 : Gt.idleLoopUrl) ?? ((Jt = at.info) == null ? void 0 : Jt.idleLoopUrl) ?? null, An = R ?? null, Rn = E(() => ie("expanded"), [ie]), In = E(
2995
- () => ie("minimized"),
2996
- [ie]
2997
- ), Wt = E(() => {
2998
- w.disconnect(), ie("hidden");
2999
- }, [w, ie]), Mn = E(() => {
3000
- const m = w.audioElement;
3001
- m && m.play().then(() => nt(!1)).catch(() => {
3122
+ return window.addEventListener("keydown", y), () => window.removeEventListener("keydown", y);
3123
+ }, [qe]);
3124
+ const Tn = !!P || !!(ee != null && ee.avatarImageUrl) || k.isControlled, lt = ir(et, l, Tn);
3125
+ Qe === void 0 && ((Yt = lt.info) != null && Yt.capabilities) && (Rt.current = lt.info.capabilities);
3126
+ const vt = (ee == null ? void 0 : ee.name) ?? H ?? ((Gt = k.agentConfig) == null ? void 0 : Gt.name) ?? ((Jt = lt.info) == null ? void 0 : Jt.name) ?? "Live Layer", It = (ee == null ? void 0 : ee.avatarImageUrl) ?? P ?? ((Kt = k.agentConfig) == null ? void 0 : Kt.avatarImageUrl) ?? ((Xt = lt.info) == null ? void 0 : Xt.avatarImageUrl) ?? null, Dn = F ?? ((Qt = k.agentConfig) == null ? void 0 : Qt.idleLoopUrl) ?? ((Zt = lt.info) == null ? void 0 : Zt.idleLoopUrl) ?? null, Pn = g ?? null, $n = C(() => le("expanded"), [le]), zn = C(
3127
+ () => le("minimized"),
3128
+ [le]
3129
+ ), Ut = C(() => {
3130
+ k.disconnect(), le("hidden");
3131
+ }, [k, le]), On = C(() => {
3132
+ const y = k.audioElement;
3133
+ y && y.play().then(() => fe(!1)).catch(() => {
3002
3134
  });
3003
- }, [w.audioElement]), Tn = E(() => {
3004
- nt(!1), w.connect();
3005
- }, [w]), qe = {
3006
- ...kt,
3007
- ...tt ? {} : { zIndex: Ie }
3135
+ }, [k.audioElement]), Hn = C(() => {
3136
+ fe(!1), k.connect();
3137
+ }, [k]), Fe = {
3138
+ ...Te,
3139
+ ...ue ? {} : { zIndex: Oe }
3008
3140
  };
3009
- F.primaryColor && (qe["--ll-color-primary"] = F.primaryColor), F.accentColor && (qe["--ll-color-accent"] = F.accentColor), F.backgroundColor && (qe["--ll-color-bg"] = F.backgroundColor), F.textColor && (qe["--ll-color-fg"] = F.textColor);
3010
- const Dn = [
3141
+ q.primaryColor && (Fe["--ll-color-primary"] = q.primaryColor), q.accentColor && (Fe["--ll-color-accent"] = q.accentColor), q.backgroundColor && (Fe["--ll-color-bg"] = q.backgroundColor), q.textColor && (Fe["--ll-color-fg"] = q.textColor);
3142
+ const Bn = [
3011
3143
  "ll-widget",
3012
- `ll-widget--${oe}`,
3013
- `ll-widget--${de ? "mobile" : "desktop"}`,
3014
- mt
3144
+ `ll-widget--${te}`,
3145
+ `ll-widget--${Ce ? "mobile" : "desktop"}`,
3146
+ kt
3015
3147
  ].filter(Boolean).join(" ");
3016
- if (!re) return null;
3017
- const Pn = /* @__PURE__ */ n(
3148
+ if (!Ze) return null;
3149
+ const Wn = /* @__PURE__ */ n(
3018
3150
  "div",
3019
3151
  {
3020
- className: Dn,
3021
- style: qe,
3022
- "data-display-mode": oe,
3023
- "data-position": x,
3024
- "data-experience-mode": u === "EMBEDDED" ? "embedded" : "widget",
3025
- children: oe === "expanded" && /* @__PURE__ */ n(
3026
- Mr,
3152
+ className: Bn,
3153
+ style: Fe,
3154
+ "data-display-mode": te,
3155
+ "data-position": L,
3156
+ "data-experience-mode": p === "EMBEDDED" ? "embedded" : "widget",
3157
+ children: te === "expanded" && /* @__PURE__ */ n(
3158
+ Hr,
3027
3159
  {
3028
- position: x,
3029
- isMobile: de,
3160
+ position: L,
3161
+ isMobile: Ce,
3030
3162
  agentName: vt,
3031
- avatarImageUrl: Nt,
3032
- idleLoopUrl: Nn,
3033
- greeting: An,
3034
- branding: F,
3163
+ avatarImageUrl: It,
3164
+ idleLoopUrl: Dn,
3165
+ greeting: Pn,
3166
+ branding: q,
3035
3167
  teamMembers: S,
3036
- currentTeamMemberId: Te,
3037
- isSwitchingTeamMember: we,
3038
- teamSwitcherOpen: ot,
3039
- onToggleTeamSwitcher: () => it((m) => !m),
3040
- onSelectTeamMember: Cn,
3041
- connectionState: w.connectionState,
3042
- agentState: w.agentState,
3043
- transcript: w.transcript,
3044
- isMuted: X.isMuted,
3045
- micDevices: He.mics,
3046
- activeMicId: X.activeDeviceId,
3047
- isCameraEnabled: ue.isEnabled,
3048
- cameraPreviewEl: ue.previewEl,
3049
- cameraDevices: He.cameras,
3050
- activeCameraId: ue.activeDeviceId,
3051
- isScreenShareEnabled: be.isEnabled,
3052
- screenPreviewEl: be.previewEl,
3053
- isSpeakerMuted: We,
3054
- allowCamera: U,
3055
- allowScreenShare: O,
3056
- allowTyping: j,
3057
- showMinimize: H,
3058
- showClose: G,
3059
- chromeless: ce,
3060
- compactControls: ge,
3061
- transforming: pe,
3168
+ currentTeamMemberId: Le,
3169
+ isSwitchingTeamMember: pe,
3170
+ teamSwitcherOpen: qe,
3171
+ onToggleTeamSwitcher: () => ot((y) => !y),
3172
+ onSelectTeamMember: Mn,
3173
+ connectionState: k.connectionState,
3174
+ agentState: k.agentState,
3175
+ transcript: k.transcript,
3176
+ isMuted: re.isMuted,
3177
+ micDevices: nt.mics,
3178
+ activeMicId: re.activeDeviceId,
3179
+ isCameraEnabled: ae.isEnabled,
3180
+ cameraPreviewEl: ae.previewEl,
3181
+ cameraDevices: nt.cameras,
3182
+ activeCameraId: ae.activeDeviceId,
3183
+ isScreenShareEnabled: Ee.isEnabled,
3184
+ screenPreviewEl: Ee.previewEl,
3185
+ isSpeakerMuted: Y,
3186
+ allowCamera: Z,
3187
+ allowScreenShare: M,
3188
+ allowTyping: U,
3189
+ showMinimize: pt,
3190
+ showClose: ht,
3191
+ chromeless: oe,
3192
+ compactControls: K,
3193
+ transforming: xe,
3062
3194
  transformingLabel: ye,
3063
- languageMenuOpen: _e,
3064
- onToggleLanguageMenu: () => xe((m) => !m),
3065
- needsUserGesture: Lt,
3066
- canResume: w.canResume,
3067
- micError: X.micError,
3068
- error: w.error,
3069
- avatarVideoContainerRef: Ot,
3070
- agentVideoEl: w.videoElement,
3071
- onConnect: () => void w.connect(),
3072
- onDisconnect: () => w.disconnect(),
3073
- onRetry: Tn,
3074
- onResumeAudio: Mn,
3075
- onToggleMute: X.toggleMute,
3076
- onSwitchMicDevice: (m) => void X.switchDevice(m),
3077
- onToggleCamera: () => void ue.toggle(),
3078
- onSwitchCameraDevice: (m) => void ue.switchDevice(m),
3079
- onToggleScreenShare: () => void be.toggle(),
3080
- onToggleSpeaker: En,
3081
- onSendMessage: Ln,
3082
- onMinimize: In,
3083
- onClose: Wt,
3084
- onClearMicError: X.clearError
3195
+ languageMenuOpen: mt,
3196
+ onToggleLanguageMenu: () => m((y) => !y),
3197
+ needsUserGesture: Ct,
3198
+ canResume: k.canResume,
3199
+ micError: re.micError,
3200
+ error: k.error,
3201
+ avatarVideoContainerRef: qt,
3202
+ agentVideoEl: k.videoElement,
3203
+ onConnect: () => void k.connect(),
3204
+ onDisconnect: () => k.disconnect(),
3205
+ onRetry: Hn,
3206
+ onResumeAudio: On,
3207
+ onToggleMute: re.toggleMute,
3208
+ onSwitchMicDevice: (y) => void re.switchDevice(y),
3209
+ onToggleCamera: () => void ae.toggle(),
3210
+ onSwitchCameraDevice: (y) => void ae.switchDevice(y),
3211
+ onToggleScreenShare: () => void Ee.toggle(),
3212
+ onToggleSpeaker: In,
3213
+ onSendMessage: Rn,
3214
+ onMinimize: zn,
3215
+ onClose: Ut,
3216
+ onClearMicError: re.clearError
3085
3217
  }
3086
3218
  )
3087
3219
  }
3088
- ), Bt = oe === "hidden" || oe === "minimized" ? /* @__PURE__ */ g(
3220
+ ), jt = !ue && (te === "hidden" || te === "minimized") ? /* @__PURE__ */ w(
3089
3221
  "div",
3090
3222
  {
3091
3223
  className: [
3092
3224
  "ll-widget",
3093
3225
  "ll-widget--floating",
3094
- `ll-widget--${oe}`,
3095
- `ll-widget--${de ? "mobile" : "desktop"}`
3226
+ `ll-widget--${te}`,
3227
+ `ll-widget--${Ce ? "mobile" : "desktop"}`
3096
3228
  ].join(" "),
3097
- style: qe,
3098
- "data-display-mode": oe,
3099
- "data-position": x,
3229
+ style: Fe,
3230
+ "data-display-mode": te,
3231
+ "data-position": L,
3100
3232
  children: [
3101
- oe === "hidden" && /* @__PURE__ */ n(
3102
- kr,
3233
+ te === "hidden" && /* @__PURE__ */ n(
3234
+ Rr,
3103
3235
  {
3104
- position: x,
3105
- isMobile: de,
3106
- isSpeaking: w.agentState === "speaking",
3107
- onExpand: () => ie("expanded"),
3236
+ position: L,
3237
+ isMobile: Ce,
3238
+ isSpeaking: k.agentState === "speaking",
3239
+ onExpand: () => le("expanded"),
3108
3240
  label: `Open ${vt} widget`,
3109
- avatarImageUrl: Nt,
3241
+ avatarImageUrl: It,
3110
3242
  agentName: vt,
3111
- containerEl: se
3243
+ containerEl: _e
3112
3244
  }
3113
3245
  ),
3114
- oe === "minimized" && /* @__PURE__ */ n(
3115
- Er,
3246
+ te === "minimized" && /* @__PURE__ */ n(
3247
+ Mr,
3116
3248
  {
3117
- position: x,
3118
- isMobile: de,
3249
+ position: L,
3250
+ isMobile: Ce,
3119
3251
  agentName: vt,
3120
- avatarImageUrl: Nt,
3121
- agentState: w.agentState,
3122
- isMuted: X.isMuted,
3123
- audioLevel: ve,
3124
- onExpand: Rn,
3125
- onToggleMute: X.toggleMute,
3126
- onClose: Wt
3252
+ avatarImageUrl: It,
3253
+ agentState: k.agentState,
3254
+ isMuted: re.isMuted,
3255
+ audioLevel: tt,
3256
+ onExpand: $n,
3257
+ onToggleMute: re.toggleMute,
3258
+ onClose: Ut
3127
3259
  }
3128
3260
  )
3129
3261
  ]
3130
3262
  }
3131
- ) : null, qt = se ?? (typeof document < "u" ? document.body : null);
3132
- return /* @__PURE__ */ g(Ye, { children: [
3133
- Pn,
3134
- Bt && qt && It(Bt, qt)
3263
+ ) : null, Vt = _e ?? (typeof document < "u" ? document.body : null);
3264
+ return /* @__PURE__ */ w(Pe, { children: [
3265
+ Wn,
3266
+ jt && Vt && Pt(jt, Vt)
3135
3267
  ] });
3136
3268
  }
3137
3269
  );
3138
- kn.displayName = "AvatarWidgetInner";
3139
- const oo = ut(
3270
+ Nn.displayName = "AvatarWidgetInner";
3271
+ const mo = Dt(
3140
3272
  function(t, r) {
3141
- return /* @__PURE__ */ n(Un, { children: /* @__PURE__ */ n(kn, { ...t, ref: r }) });
3273
+ return /* @__PURE__ */ n(Xn, { children: /* @__PURE__ */ n(Nn, { ...t, ref: r }) });
3142
3274
  }
3143
3275
  );
3144
- oo.displayName = "AvatarWidget";
3145
- const mo = ({
3276
+ mo.displayName = "AvatarWidget";
3277
+ const Eo = ({
3146
3278
  agentId: e,
3147
3279
  baseUrl: t,
3148
3280
  apiKey: r,
3149
3281
  mode: o,
3150
3282
  onAgentEvent: i,
3151
3283
  className: l,
3152
- style: d
3284
+ style: s
3153
3285
  }) => {
3154
- const a = N(null), s = N(null), u = N(i);
3155
- u.current = i;
3156
- const y = E((f) => {
3157
- var A;
3158
- const c = f.detail;
3159
- (A = u.current) == null || A.call(u, c);
3286
+ const a = N(null), c = N(null), p = N(i);
3287
+ p.current = i;
3288
+ const v = C((f) => {
3289
+ var R;
3290
+ const u = f.detail;
3291
+ (R = p.current) == null || R.call(p, u);
3160
3292
  }, []);
3161
3293
  return I(() => {
3162
3294
  const f = a.current;
3163
3295
  if (!f) return;
3164
- const c = document.createElement("livelayer-widget");
3165
- return c.setAttribute("agent-id", e), t && c.setAttribute("base-url", t), r && c.setAttribute("api-key", r), o && c.setAttribute("mode", o), c.addEventListener("agent-event", y), f.appendChild(c), s.current = c, () => {
3166
- c.removeEventListener("agent-event", y), f.removeChild(c), s.current = null;
3296
+ const u = document.createElement("livelayer-widget");
3297
+ return u.setAttribute("agent-id", e), t && u.setAttribute("base-url", t), r && u.setAttribute("api-key", r), o && u.setAttribute("mode", o), u.addEventListener("agent-event", v), f.appendChild(u), c.current = u, () => {
3298
+ u.removeEventListener("agent-event", v), f.removeChild(u), c.current = null;
3167
3299
  };
3168
3300
  }, [e]), I(() => {
3169
- s.current && (o ? s.current.setAttribute("mode", o) : s.current.removeAttribute("mode"));
3170
- }, [o]), /* @__PURE__ */ n("div", { ref: a, className: l, style: d });
3171
- }, go = ut(
3172
- function({ id: t, intent: r, as: o = "div", className: i, style: l, children: d }, a) {
3173
- return Wn(
3301
+ c.current && (o ? c.current.setAttribute("mode", o) : c.current.removeAttribute("mode"));
3302
+ }, [o]), /* @__PURE__ */ n("div", { ref: a, className: l, style: s });
3303
+ }, So = Dt(
3304
+ function({ id: t, intent: r, as: o = "div", className: i, style: l, children: s }, a) {
3305
+ return Vn(
3174
3306
  o,
3175
3307
  {
3176
3308
  ref: a,
@@ -3179,75 +3311,64 @@ const mo = ({
3179
3311
  className: i,
3180
3312
  style: l
3181
3313
  },
3182
- d
3183
- );
3184
- }
3185
- ), yo = ut(
3186
- function({ id: t, intent: r, children: o, ...i }, l) {
3187
- return /* @__PURE__ */ n(
3188
- "form",
3189
- {
3190
- ref: l,
3191
- "data-ll-form": t,
3192
- "data-ll-intent": r,
3193
- ...i,
3194
- children: o
3195
- }
3314
+ s
3196
3315
  );
3197
3316
  }
3198
- ), vo = ut(
3199
- function(t, r) {
3200
- const { name: o, label: i, labelClassName: l } = t, d = { name: o, "data-ll-field": o };
3201
- let a;
3202
- if ("as" in t && t.as === "textarea") {
3203
- const { name: s, label: u, labelClassName: y, as: f, ...c } = t;
3204
- a = /* @__PURE__ */ n(
3205
- "textarea",
3206
- {
3207
- ref: r,
3208
- ...d,
3209
- ...c
3210
- }
3211
- );
3212
- } else if ("as" in t && t.as === "select") {
3213
- const { name: s, label: u, labelClassName: y, as: f, children: c, ...A } = t;
3214
- a = /* @__PURE__ */ n(
3215
- "select",
3216
- {
3217
- ref: r,
3218
- ...d,
3219
- ...A,
3220
- children: c
3317
+ );
3318
+ function No(e = {}) {
3319
+ const { onFieldUpdate: t, onComplete: r, source: o = "all" } = e, [i, l] = E({}), [s, a] = E(!1), [c, p] = E(null), v = N(t), f = N(r), u = N(o);
3320
+ I(() => {
3321
+ v.current = t, f.current = r, u.current = o;
3322
+ }, [t, r, o]);
3323
+ const R = C(() => {
3324
+ l({}), a(!1);
3325
+ }, []);
3326
+ return I(() => {
3327
+ if (typeof window > "u") return;
3328
+ const L = (_) => {
3329
+ var b, S;
3330
+ const h = _.detail;
3331
+ if (h) {
3332
+ if (h.phase === "field") {
3333
+ if (u.current !== "all" && h.source !== u.current)
3334
+ return;
3335
+ a(!0), l(
3336
+ (T) => T[h.fieldName] === h.value ? T : { ...T, [h.fieldName]: h.value }
3337
+ );
3338
+ try {
3339
+ (b = v.current) == null || b.call(v, h);
3340
+ } catch (T) {
3341
+ console.warn("[LiveLayer] useCollect onFieldUpdate threw.", T);
3342
+ }
3343
+ return;
3221
3344
  }
3222
- );
3223
- } else {
3224
- const { name: s, label: u, labelClassName: y, as: f, ...c } = t;
3225
- a = /* @__PURE__ */ n(
3226
- "input",
3227
- {
3228
- ref: r,
3229
- ...d,
3230
- ...c
3345
+ if (h.phase === "complete") {
3346
+ const T = h.result;
3347
+ if (u.current !== "all" && T.source !== u.current)
3348
+ return;
3349
+ p(T), a(!1);
3350
+ try {
3351
+ (S = f.current) == null || S.call(f, T);
3352
+ } catch (A) {
3353
+ console.warn("[LiveLayer] useCollect onComplete threw.", A);
3354
+ }
3231
3355
  }
3232
- );
3233
- }
3234
- return i === void 0 ? a : /* @__PURE__ */ g("label", { className: l, children: [
3235
- i,
3236
- a
3237
- ] });
3238
- }
3239
- );
3240
- let hn = 1;
3241
- function bo({
3356
+ }
3357
+ };
3358
+ return document.addEventListener("ll-collected", L), () => document.removeEventListener("ll-collected", L);
3359
+ }, []), { fields: i, isCollecting: s, lastResult: c, reset: R };
3360
+ }
3361
+ let bn = 1;
3362
+ function Ao({
3242
3363
  onMount: e,
3243
3364
  defaultOpen: t = !1,
3244
3365
  storageKey: r = "ll-debug-open"
3245
3366
  }) {
3246
- const [o, i] = C(t), [l, d] = C([]), [a, s] = C(""), [u, y] = C(!1), f = N(/* @__PURE__ */ new Set()), c = N([]), A = N(u);
3247
- A.current = u, I(() => {
3367
+ const [o, i] = E(t), [l, s] = E([]), [a, c] = E(""), [p, v] = E(!1), f = N(/* @__PURE__ */ new Set()), u = N([]), R = N(p);
3368
+ R.current = p, I(() => {
3248
3369
  try {
3249
- const v = localStorage.getItem(r);
3250
- v === "1" && i(!0), v === "0" && i(!1);
3370
+ const h = localStorage.getItem(r);
3371
+ h === "1" && i(!0), h === "0" && i(!1);
3251
3372
  } catch {
3252
3373
  }
3253
3374
  }, [r]), I(() => {
@@ -3256,48 +3377,48 @@ function bo({
3256
3377
  } catch {
3257
3378
  }
3258
3379
  }, [o, r]), I(() => {
3259
- const v = (b) => {
3380
+ const h = (b) => {
3260
3381
  (b.metaKey || b.ctrlKey) && b.shiftKey && b.key.toLowerCase() === "l" && (b.preventDefault(), i((S) => !S));
3261
3382
  };
3262
- return window.addEventListener("keydown", v), () => window.removeEventListener("keydown", v);
3383
+ return window.addEventListener("keydown", h), () => window.removeEventListener("keydown", h);
3263
3384
  }, []), I(() => {
3264
- const v = setInterval(() => {
3265
- if (c.current.length === 0 || A.current) return;
3266
- const b = c.current.splice(0, c.current.length);
3267
- d(
3385
+ const h = setInterval(() => {
3386
+ if (u.current.length === 0 || R.current) return;
3387
+ const b = u.current.splice(0, u.current.length);
3388
+ s(
3268
3389
  (S) => [...b.reverse(), ...S].slice(0, 200)
3269
3390
  );
3270
3391
  }, 100);
3271
- return () => clearInterval(v);
3392
+ return () => clearInterval(h);
3272
3393
  }, []);
3273
- const x = N(!1);
3394
+ const L = N(!1);
3274
3395
  if (I(() => {
3275
- !e || x.current || (x.current = !0, e((v) => {
3276
- c.current.push({
3277
- id: hn++,
3396
+ !e || L.current || (L.current = !0, e((h) => {
3397
+ u.current.push({
3398
+ id: bn++,
3278
3399
  ts: Date.now(),
3279
3400
  kind: "event",
3280
- type: v.eventName,
3281
- data: v.data
3401
+ type: h.eventName,
3402
+ data: h.data
3282
3403
  });
3283
3404
  }));
3284
3405
  }, [e]), I(() => {
3285
- const v = console.warn, b = console.log, S = (M, D) => function(...k) {
3406
+ const h = console.warn, b = console.log, S = (T, A) => function(...F) {
3286
3407
  try {
3287
- const R = typeof k[0] == "string" ? k[0] : "";
3288
- R.startsWith("[LiveLayer]") && c.current.push({
3289
- id: hn++,
3408
+ const g = typeof F[0] == "string" ? F[0] : "";
3409
+ g.startsWith("[LiveLayer]") && u.current.push({
3410
+ id: bn++,
3290
3411
  ts: Date.now(),
3291
- kind: M,
3292
- type: R.slice(0, 120),
3293
- data: { args: k.slice(1).map((B) => lo(B)) }
3412
+ kind: T,
3413
+ type: g.slice(0, 120),
3414
+ data: { args: F.slice(1).map((P) => yo(P)) }
3294
3415
  });
3295
3416
  } catch {
3296
3417
  }
3297
- return D.apply(this, k);
3418
+ return A.apply(this, F);
3298
3419
  };
3299
- return console.warn = S("warn", v), console.log = S("log", b), () => {
3300
- console.warn = v, console.log = b;
3420
+ return console.warn = S("warn", h), console.log = S("log", b), () => {
3421
+ console.warn = h, console.log = b;
3301
3422
  };
3302
3423
  }, []), !o)
3303
3424
  return /* @__PURE__ */ n(
@@ -3326,12 +3447,12 @@ function bo({
3326
3447
  children: "🛰 LL debug"
3327
3448
  }
3328
3449
  );
3329
- const _ = l.filter((v) => {
3450
+ const _ = l.filter((h) => {
3330
3451
  if (!a) return !0;
3331
3452
  const b = a.toLowerCase();
3332
- return v.type.toLowerCase().includes(b) || JSON.stringify(v.data || {}).toLowerCase().includes(b);
3453
+ return h.type.toLowerCase().includes(b) || JSON.stringify(h.data || {}).toLowerCase().includes(b);
3333
3454
  });
3334
- return /* @__PURE__ */ g(
3455
+ return /* @__PURE__ */ w(
3335
3456
  "div",
3336
3457
  {
3337
3458
  style: {
@@ -3353,7 +3474,7 @@ function bo({
3353
3474
  overflow: "hidden"
3354
3475
  },
3355
3476
  children: [
3356
- /* @__PURE__ */ g(
3477
+ /* @__PURE__ */ w(
3357
3478
  "div",
3358
3479
  {
3359
3480
  style: {
@@ -3366,7 +3487,7 @@ function bo({
3366
3487
  },
3367
3488
  children: [
3368
3489
  /* @__PURE__ */ n("span", { style: { fontWeight: 600, fontSize: 12 }, children: "LiveLayer debug" }),
3369
- /* @__PURE__ */ g("span", { style: { fontSize: 10, color: "rgba(255,255,255,0.4)" }, children: [
3490
+ /* @__PURE__ */ w("span", { style: { fontSize: 10, color: "rgba(255,255,255,0.4)" }, children: [
3370
3491
  l.length,
3371
3492
  " event",
3372
3493
  l.length === 1 ? "" : "s"
@@ -3376,10 +3497,10 @@ function bo({
3376
3497
  "button",
3377
3498
  {
3378
3499
  type: "button",
3379
- onClick: () => y((v) => !v),
3380
- style: Rt(u ? "#f59e0b" : "transparent"),
3500
+ onClick: () => v((h) => !h),
3501
+ style: Tt(p ? "#f59e0b" : "transparent"),
3381
3502
  title: "Pause / resume capture",
3382
- children: u ? "▶ resume" : "⏸ pause"
3503
+ children: p ? "▶ resume" : "⏸ pause"
3383
3504
  }
3384
3505
  ),
3385
3506
  /* @__PURE__ */ n(
@@ -3387,9 +3508,9 @@ function bo({
3387
3508
  {
3388
3509
  type: "button",
3389
3510
  onClick: () => {
3390
- d([]), c.current = [];
3511
+ s([]), u.current = [];
3391
3512
  },
3392
- style: Rt("transparent"),
3513
+ style: Tt("transparent"),
3393
3514
  title: "Clear buffer",
3394
3515
  children: "clear"
3395
3516
  }
@@ -3399,7 +3520,7 @@ function bo({
3399
3520
  {
3400
3521
  type: "button",
3401
3522
  onClick: () => i(!1),
3402
- style: Rt("transparent"),
3523
+ style: Tt("transparent"),
3403
3524
  "aria-label": "Close",
3404
3525
  title: "Close (Cmd/Ctrl + Shift + L)",
3405
3526
  children: "✕"
@@ -3413,7 +3534,7 @@ function bo({
3413
3534
  {
3414
3535
  type: "text",
3415
3536
  value: a,
3416
- onChange: (v) => s(v.target.value),
3537
+ onChange: (h) => c(h.target.value),
3417
3538
  placeholder: "filter by type or data…",
3418
3539
  style: {
3419
3540
  margin: 8,
@@ -3435,7 +3556,7 @@ function bo({
3435
3556
  overflowY: "auto",
3436
3557
  padding: "0 8px 8px"
3437
3558
  },
3438
- children: _.length === 0 ? /* @__PURE__ */ g(
3559
+ children: _.length === 0 ? /* @__PURE__ */ w(
3439
3560
  "div",
3440
3561
  {
3441
3562
  style: {
@@ -3465,16 +3586,16 @@ function bo({
3465
3586
  )
3466
3587
  ]
3467
3588
  }
3468
- ) : _.map((v) => /* @__PURE__ */ n(
3469
- io,
3589
+ ) : _.map((h) => /* @__PURE__ */ n(
3590
+ go,
3470
3591
  {
3471
- entry: v,
3472
- expanded: f.current.has(v.id),
3592
+ entry: h,
3593
+ expanded: f.current.has(h.id),
3473
3594
  onToggle: () => {
3474
- f.current.has(v.id) ? f.current.delete(v.id) : f.current.add(v.id), d((b) => [...b]);
3595
+ f.current.has(h.id) ? f.current.delete(h.id) : f.current.add(h.id), s((b) => [...b]);
3475
3596
  }
3476
3597
  },
3477
- v.id
3598
+ h.id
3478
3599
  ))
3479
3600
  }
3480
3601
  )
@@ -3482,7 +3603,7 @@ function bo({
3482
3603
  }
3483
3604
  );
3484
3605
  }
3485
- function io({
3606
+ function go({
3486
3607
  entry: e,
3487
3608
  expanded: t,
3488
3609
  onToggle: r
@@ -3490,7 +3611,7 @@ function io({
3490
3611
  const o = e.kind === "warn" ? "#f59e0b" : e.type.startsWith("[LiveLayer]") ? "#94a3b8" : e.type === "navigate" || e.type === "scroll_page" || e.type === "scroll_to" || e.type === "click" ? "#22c55e" : e.type === "fill_form" || e.type === "submit_form" || e.type === "focus_field" ? "#a78bfa" : e.type === "request_page_context" || e.type === "request_routes" ? "#38bdf8" : e.type === "agent_state" ? "#facc15" : "#cbd5e1", i = new Date(e.ts).toLocaleTimeString("en-US", {
3491
3612
  hour12: !1
3492
3613
  });
3493
- return /* @__PURE__ */ g(
3614
+ return /* @__PURE__ */ w(
3494
3615
  "button",
3495
3616
  {
3496
3617
  type: "button",
@@ -3508,7 +3629,7 @@ function io({
3508
3629
  lineHeight: 1.4
3509
3630
  },
3510
3631
  children: [
3511
- /* @__PURE__ */ g("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
3632
+ /* @__PURE__ */ w("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
3512
3633
  /* @__PURE__ */ n(
3513
3634
  "span",
3514
3635
  {
@@ -3552,7 +3673,7 @@ function io({
3552
3673
  }
3553
3674
  );
3554
3675
  }
3555
- function Rt(e) {
3676
+ function Tt(e) {
3556
3677
  return {
3557
3678
  background: e,
3558
3679
  color: "#fff",
@@ -3563,24 +3684,31 @@ function Rt(e) {
3563
3684
  cursor: "pointer"
3564
3685
  };
3565
3686
  }
3566
- function lo(e) {
3687
+ function yo(e) {
3567
3688
  try {
3568
3689
  return e instanceof Error ? { message: e.message, stack: e.stack } : (JSON.stringify(e), e);
3569
3690
  } catch {
3570
3691
  return String(e);
3571
3692
  }
3572
3693
  }
3573
- function wo() {
3574
- const [e, t] = C([]), r = E((i) => {
3694
+ function vo(e) {
3695
+ const t = JSON.stringify(e);
3696
+ I(() => Gn(e), [t]);
3697
+ }
3698
+ function Ro({ fields: e, children: t }) {
3699
+ return vo(e), /* @__PURE__ */ n(Pe, { children: t });
3700
+ }
3701
+ function Io() {
3702
+ const [e, t] = E([]), r = C((i) => {
3575
3703
  t((l) => {
3576
- const d = l.findIndex((a) => a.id === i.id);
3577
- if (d >= 0) {
3704
+ const s = l.findIndex((a) => a.id === i.id);
3705
+ if (s >= 0) {
3578
3706
  const a = l.slice();
3579
- return a[d] = i, a;
3707
+ return a[s] = i, a;
3580
3708
  }
3581
3709
  return [...l, i];
3582
3710
  });
3583
- }, []), o = E(() => t([]), []);
3711
+ }, []), o = C(() => t([]), []);
3584
3712
  return {
3585
3713
  entries: e,
3586
3714
  pushSegment: r,
@@ -3589,33 +3717,38 @@ function wo() {
3589
3717
  };
3590
3718
  }
3591
3719
  export {
3592
- oo as AvatarWidget,
3593
- Un as ErrorBoundary,
3594
- bo as LiveLayerDebugPanel,
3595
- vo as LiveLayerField,
3596
- yo as LiveLayerForm,
3597
- go as LiveLayerRegion,
3598
- mo as LiveLayerWidget,
3599
- Fr as clearPageContextCache,
3600
- Jr as clearRoutesCache,
3601
- qr as extractPageContext,
3602
- Yr as extractRoutes,
3603
- fn as getCachedPageContext,
3604
- At as getCachedRoutes,
3605
- pr as matchesPattern,
3606
- jr as normalizeRouteInput,
3607
- hr as shouldRenderAtPath,
3608
- Qn as useAgentInfo,
3609
- Vn as useAudioLevel,
3610
- Jn as useCameraState,
3611
- tr as useDisplayMode,
3612
- or as useDisplayModePersistence,
3613
- lr as useIsMobile,
3614
- jn as useLiveKitSession,
3615
- Xn as useMediaDevices,
3616
- Yn as useMicrophoneState,
3617
- cr as usePathname,
3618
- mr as useRouteMatch,
3619
- Kn as useScreenShareState,
3620
- wo as useTranscript
3720
+ mo as AvatarWidget,
3721
+ Xn as ErrorBoundary,
3722
+ Ro as FieldProvider,
3723
+ Ao as LiveLayerDebugPanel,
3724
+ So as LiveLayerRegion,
3725
+ Eo as LiveLayerWidget,
3726
+ Do as clearFieldRegistry,
3727
+ Qr as clearPageContextCache,
3728
+ oo as clearRoutesCache,
3729
+ Xr as extractPageContext,
3730
+ no as extractRoutes,
3731
+ gn as getCachedPageContext,
3732
+ Mt as getCachedRoutes,
3733
+ Po as getRegisteredFields,
3734
+ wr as matchesPattern,
3735
+ eo as normalizeRouteInput,
3736
+ $o as registerFields,
3737
+ zo as setFieldValue,
3738
+ _r as shouldRenderAtPath,
3739
+ ir as useAgentInfo,
3740
+ Zn as useAudioLevel,
3741
+ nr as useCameraState,
3742
+ No as useCollect,
3743
+ sr as useDisplayMode,
3744
+ ur as useDisplayModePersistence,
3745
+ pr as useIsMobile,
3746
+ Qn as useLiveKitSession,
3747
+ or as useMediaDevices,
3748
+ er as useMicrophoneState,
3749
+ mr as usePathname,
3750
+ vo as useRegisterFields,
3751
+ xr as useRouteMatch,
3752
+ rr as useScreenShareState,
3753
+ Io as useTranscript
3621
3754
  };