@d-id/client-sdk 1.1.68-staging.315 → 1.1.68-staging.317

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.
@@ -1,6 +1,6 @@
1
- var We = Object.defineProperty;
2
- var Je = (e, t, r) => t in e ? We(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var Z = (e, t, r) => Je(e, typeof t != "symbol" ? t + "" : t, r);
1
+ var Je = Object.defineProperty;
2
+ var Oe = (e, t, r) => t in e ? Je(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var Z = (e, t, r) => Oe(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  class ce extends Error {
5
5
  constructor({ kind: r, description: a, error: c }) {
6
6
  super(JSON.stringify({ kind: r, description: a }));
@@ -10,7 +10,7 @@ class ce extends Error {
10
10
  this.kind = r, this.description = a, this.error = c;
11
11
  }
12
12
  }
13
- class Oe extends ce {
13
+ class He extends ce {
14
14
  constructor(t, r) {
15
15
  super({
16
16
  kind: "ChatCreationFailed",
@@ -18,7 +18,7 @@ class Oe extends ce {
18
18
  });
19
19
  }
20
20
  }
21
- class He extends ce {
21
+ class qe extends ce {
22
22
  constructor(t) {
23
23
  super({ kind: "ChatModeDowngraded", description: `Chat mode downgraded to ${t}` });
24
24
  }
@@ -30,12 +30,12 @@ class G extends ce {
30
30
  this.key = a;
31
31
  }
32
32
  }
33
- class qe extends ce {
33
+ class Xe extends ce {
34
34
  constructor(t) {
35
35
  super({ kind: "WSError", description: t });
36
36
  }
37
37
  }
38
- var Xe = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(Xe || {}), Ye = /* @__PURE__ */ ((e) => (e.TRIAL = "deid-trial", e.PRO = "deid-pro", e.ENTERPRISE = "deid-enterprise", e.LITE = "deid-lite", e.ADVANCED = "deid-advanced", e.BUILD = "deid-api-build", e.LAUNCH = "deid-api-launch", e.SCALE = "deid-api-scale", e))(Ye || {}), Ge = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(Ge || {}), Qe = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(Qe || {}), x = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(x || {}), N = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(N || {}), Ze = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(Ze || {}), et = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(et || {}), tt = /* @__PURE__ */ ((e) => (e.Pdf = "pdf", e.Text = "text", e.Html = "html", e.Word = "word", e.Json = "json", e.Markdown = "markdown", e.Csv = "csv", e.Excel = "excel", e.Powerpoint = "powerpoint", e.Archive = "archive", e.Image = "image", e.Audio = "audio", e.Video = "video", e))(tt || {}), Pe = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(Pe || {});
38
+ var Ye = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(Ye || {}), Ge = /* @__PURE__ */ ((e) => (e.TRIAL = "deid-trial", e.PRO = "deid-pro", e.ENTERPRISE = "deid-enterprise", e.LITE = "deid-lite", e.ADVANCED = "deid-advanced", e.BUILD = "deid-api-build", e.LAUNCH = "deid-api-launch", e.SCALE = "deid-api-scale", e))(Ge || {}), Qe = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(Qe || {}), Ze = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(Ze || {}), x = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(x || {}), N = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(N || {}), et = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(et || {}), tt = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(tt || {}), rt = /* @__PURE__ */ ((e) => (e.Pdf = "pdf", e.Text = "text", e.Html = "html", e.Word = "word", e.Json = "json", e.Markdown = "markdown", e.Csv = "csv", e.Excel = "excel", e.Powerpoint = "powerpoint", e.Archive = "archive", e.Image = "image", e.Audio = "audio", e.Video = "video", e))(rt || {}), je = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(je || {});
39
39
  const sr = (e) => {
40
40
  switch (e) {
41
41
  case "clip":
@@ -48,12 +48,12 @@ const sr = (e) => {
48
48
  throw new Error(`Unknown video type: ${e}`);
49
49
  }
50
50
  };
51
- var S = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(S || {}), te = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(te || {}), ne = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(ne || {}), P = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.ChatAudioTranscribed = "chat/audio-transcribed", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.StreamCreated = "stream/created", e.StreamInterrupt = "stream/interrupt", e.StreamVideoCreated = "stream-video/started", e.StreamVideoDone = "stream-video/done", e.StreamVideoError = "stream-video/error", e.StreamVideoRejected = "stream-video/rejected", e.ToolCallStarted = "tool-call/started", e.ToolCallDone = "tool-call/done", e.ToolCallError = "tool-call/error", e))(P || {}), L = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnecting = "disconnecting", e.Disconnected = "disconnected", e))(L || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), he = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(he || {}), rt = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(rt || {}), nt = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(nt || {});
52
- const at = 45 * 1e3, it = "X-Playground-Chat", de = "https://api.d-id.com", st = "wss://notifications.d-id.com", ot = "79f81a83a67430be2bc0fd61042b8faa", or = (...e) => {
53
- }, je = (e) => new Promise((t) => setTimeout(t, e)), Q = (e = 16) => {
51
+ var k = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(k || {}), te = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(te || {}), ne = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(ne || {}), P = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.ChatAudioTranscribed = "chat/audio-transcribed", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.StreamCreated = "stream/created", e.StreamInterrupt = "stream/interrupt", e.StreamVideoCreated = "stream-video/started", e.StreamVideoDone = "stream-video/done", e.StreamVideoError = "stream-video/error", e.StreamVideoRejected = "stream-video/rejected", e.ToolCallStarted = "tool-call/started", e.ToolCallDone = "tool-call/done", e.ToolCallError = "tool-call/error", e))(P || {}), L = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnecting = "disconnecting", e.Disconnected = "disconnected", e))(L || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), pe = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(pe || {}), nt = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(nt || {}), at = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(at || {});
52
+ const it = 45 * 1e3, st = "X-Playground-Chat", de = "https://api.d-id.com", ot = "wss://notifications.d-id.com", ct = "79f81a83a67430be2bc0fd61042b8faa", or = (...e) => {
53
+ }, Be = (e) => new Promise((t) => setTimeout(t, e)), Q = (e = 16) => {
54
54
  const t = new Uint8Array(e);
55
55
  return window.crypto.getRandomValues(t), Array.from(t, (r) => r.toString(16).padStart(2, "0")).join("").slice(0, 13);
56
- }, Be = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type, ct = (e) => {
56
+ }, $e = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type, dt = (e) => {
57
57
  switch (e.type) {
58
58
  case "expressive":
59
59
  return "v4";
@@ -62,13 +62,13 @@ const at = 45 * 1e3, it = "X-Playground-Chat", de = "https://api.d-id.com", st =
62
62
  case "talk":
63
63
  return "v2";
64
64
  }
65
- }, dt = (e) => e.type === "talk" ? e.source_url : e.presenter_id, pe = (e) => e === Pe.Expressive, lt = (e) => [x.TextOnly, x.Playground, x.Maintenance].includes(e), $e = (e) => e && [x.DirectPlayback, x.Off].includes(e), Se = /\[!\[([^\[\]]*)\]\(([^)\s]+)\)\]\(([^)\s]+)\)/g, ke = /!\[([^\[\]]*)\]\(([^)\s]+)\)/g, ut = [".mp4", ".webm", ".mkv", ".mov", ".m4v", ".ogv"];
66
- function mt(e) {
65
+ }, lt = (e) => e.type === "talk" ? e.source_url : e.presenter_id, he = (e) => e === je.Expressive, ut = (e) => [x.TextOnly, x.Playground, x.Maintenance].includes(e), ze = (e) => e && [x.DirectPlayback, x.Off].includes(e), Se = /\[!\[([^\[\]]*)\]\(([^)\s]+)\)\]\(([^)\s]+)\)/g, ke = /!\[([^\[\]]*)\]\(([^)\s]+)\)/g, mt = [".mp4", ".webm", ".mkv", ".mov", ".m4v", ".ogv"];
66
+ function ft(e) {
67
67
  const t = e.split("?")[0].split("#")[0].toLowerCase();
68
- return ut.some((r) => t.endsWith(r));
68
+ return mt.some((r) => t.endsWith(r));
69
69
  }
70
70
  const Re = new RegExp("(?<!!)\\[([^\\[\\]]+)\\]\\(([^)\\s]+)\\)", "g"), De = /<a\s+href="([^"]*)"[^>]*?>([^<]*)<\/a>/gi;
71
- function ft(e) {
71
+ function gt(e) {
72
72
  if (e.length === 0)
73
73
  return [];
74
74
  const t = [];
@@ -83,7 +83,7 @@ function ft(e) {
83
83
  if (!t.some((o) => r.index >= o.index && r.index < o.index + o.length)) {
84
84
  const o = r[2], n = r[1];
85
85
  let i;
86
- mt(o) ? i = { type: "video", src: o, alt: n } : (i = { type: "image", src: o, alt: n }, o.toLowerCase().endsWith(".gif") && (i.mimeType = "image/gif")), t.push({ index: r.index, length: r[0].length, part: i });
86
+ ft(o) ? i = { type: "video", src: o, alt: n } : (i = { type: "image", src: o, alt: n }, o.toLowerCase().endsWith(".gif") && (i.mimeType = "image/gif")), t.push({ index: r.index, length: r[0].length, part: i });
87
87
  }
88
88
  for (Re.lastIndex = 0; (r = Re.exec(e)) !== null; )
89
89
  t.some((o) => r.index >= o.index && r.index < o.index + o.length) || t.push({
@@ -108,9 +108,9 @@ function ft(e) {
108
108
  }
109
109
  let Ie = "", le = [];
110
110
  function re(e) {
111
- return e === Ie || (Ie = e, le = ft(e)), le;
111
+ return e === Ie || (Ie = e, le = gt(e)), le;
112
112
  }
113
- function gt(e, t) {
113
+ function pt(e, t) {
114
114
  let r;
115
115
  return {
116
116
  promise: new Promise((c, s) => {
@@ -134,12 +134,12 @@ async function ue(e, t) {
134
134
  try {
135
135
  if (!r.timeout)
136
136
  return await e();
137
- const { promise: s, clear: o } = gt(r.timeout, r.timeoutErrorMessage), n = e().finally(o);
137
+ const { promise: s, clear: o } = pt(r.timeout, r.timeoutErrorMessage), n = e().finally(o);
138
138
  return await Promise.race([n, s]);
139
139
  } catch (s) {
140
140
  if (a = s, !r.shouldRetryFn(s) || c >= r.limit)
141
141
  throw s;
142
- await je(r.delayMs), r.onRetry(s);
142
+ await Be(r.delayMs), r.onRetry(s);
143
143
  }
144
144
  throw a;
145
145
  }
@@ -154,7 +154,7 @@ function me(e) {
154
154
  return t;
155
155
  }
156
156
  let ht = Q();
157
- function ze(e, t) {
157
+ function Fe(e, t) {
158
158
  if (e.type === "bearer")
159
159
  return `Bearer ${e.token}`;
160
160
  if (e.type === "basic")
@@ -163,23 +163,23 @@ function ze(e, t) {
163
163
  return `Client-Key ${e.clientKey}.${me(t)}_${ht}`;
164
164
  throw new Error(`Unknown auth type: ${e}`);
165
165
  }
166
- const pt = (e) => ue(e, {
166
+ const wt = (e) => ue(e, {
167
167
  limit: 3,
168
168
  delayMs: 1e3,
169
169
  timeout: 0,
170
170
  shouldRetryFn: (t) => t.status === 429
171
171
  });
172
- function Fe(e, t = de, r, a) {
172
+ function Ne(e, t = de, r, a) {
173
173
  const c = async (s, o) => {
174
174
  const { skipErrorHandler: n, ...i } = o || {};
175
175
  let d;
176
176
  try {
177
- d = await pt(
177
+ d = await wt(
178
178
  () => fetch(t + (s != null && s.startsWith("/") ? s : `/${s}`), {
179
179
  ...i,
180
180
  headers: {
181
181
  ...i.headers,
182
- Authorization: ze(e, a),
182
+ Authorization: Fe(e, a),
183
183
  "Content-Type": "application/json"
184
184
  }
185
185
  })
@@ -209,8 +209,8 @@ function Fe(e, t = de, r, a) {
209
209
  }
210
210
  };
211
211
  }
212
- function wt(e, t = de, r, a) {
213
- const c = Fe(e, `${t}/agents`, r, a);
212
+ function vt(e, t = de, r, a) {
213
+ const c = Ne(e, `${t}/agents`, r, a);
214
214
  return {
215
215
  create(s, o) {
216
216
  return c.post("/", s, o);
@@ -247,7 +247,7 @@ function wt(e, t = de, r, a) {
247
247
  }
248
248
  };
249
249
  }
250
- function vt(e) {
250
+ function yt(e) {
251
251
  var c, s, o, n;
252
252
  const t = () => /Mobi|Android/i.test(navigator.userAgent) ? "Mobile" : "Desktop", r = () => {
253
253
  const i = navigator.platform;
@@ -258,20 +258,20 @@ function vt(e) {
258
258
  isMobile: `${t() == "Mobile"}`,
259
259
  browser: navigator.userAgent,
260
260
  origin: window.location.origin,
261
- agentType: Be(a),
261
+ agentType: $e(a),
262
262
  agentVoice: {
263
263
  voiceId: (s = (c = e.presenter) == null ? void 0 : c.voice) == null ? void 0 : s.voice_id,
264
264
  provider: (n = (o = e.presenter) == null ? void 0 : o.voice) == null ? void 0 : n.type
265
265
  }
266
266
  };
267
267
  }
268
- function yt(e) {
268
+ function Ct(e) {
269
269
  var r, a, c, s, o, n;
270
270
  const t = (r = e.llm) == null ? void 0 : r.prompt_customization;
271
271
  return {
272
- agentType: Be(e.presenter),
273
- presenterType: ct(e.presenter),
274
- presenter: dt(e.presenter),
272
+ agentType: $e(e.presenter),
273
+ presenterType: dt(e.presenter),
274
+ presenter: lt(e.presenter),
275
275
  owner_id: e.owner_id ?? "",
276
276
  promptVersion: (a = e.llm) == null ? void 0 : a.prompt_version,
277
277
  behavior: {
@@ -290,8 +290,8 @@ function yt(e) {
290
290
  ...e.access === "public" ? { from: "agent-template" } : {}
291
291
  };
292
292
  }
293
- const Ct = (e) => e.reduce((t, r) => t + r, 0), Me = (e) => Ct(e) / e.length;
294
- function St(e, t, r) {
293
+ const St = (e) => e.reduce((t, r) => t + r, 0), Me = (e) => St(e) / e.length;
294
+ function kt(e, t, r) {
295
295
  var i, d, m;
296
296
  const { event: a, ...c } = e, { template: s } = (t == null ? void 0 : t.llm) || {}, { language: o } = ((i = t == null ? void 0 : t.presenter) == null ? void 0 : i.voice) || {};
297
297
  return {
@@ -305,8 +305,8 @@ function St(e, t, r) {
305
305
  function Ee(e) {
306
306
  "requestIdleCallback" in window ? requestIdleCallback(e, { timeout: 2e3 }) : setTimeout(e, 0);
307
307
  }
308
- const kt = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
309
- function Rt(e) {
308
+ const Rt = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
309
+ function Dt(e) {
310
310
  const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk", r = {};
311
311
  return {
312
312
  token: e.token || "testKey",
@@ -350,7 +350,7 @@ function Rt(e) {
350
350
  ])
351
351
  })
352
352
  };
353
- return fetch(kt, d).catch((m) => console.error("Analytics tracking error:", m)), Promise.resolve();
353
+ return fetch(Rt, d).catch((m) => console.error("Analytics tracking error:", m)), Promise.resolve();
354
354
  },
355
355
  linkTrack(a, c, s, o) {
356
356
  r[a] || (r[a] = { events: {}, resolvedDependencies: [] }), o.includes(s) || o.push(s);
@@ -377,21 +377,21 @@ function we() {
377
377
  };
378
378
  }
379
379
  const H = we(), fe = we(), Te = we();
380
- function Ne(e) {
381
- return e === x.Playground ? { headers: { [it]: "true" } } : {};
380
+ function Ve(e) {
381
+ return e === x.Playground ? { headers: { [st]: "true" } } : {};
382
382
  }
383
- async function Ve(e, t, r, a, c = !1, s) {
383
+ async function Ke(e, t, r, a, c = !1, s) {
384
384
  try {
385
- return !s && !$e(a) && (s = await t.newChat(e.id, { persist: c }, Ne(a)), r.track("agent-chat", {
385
+ return !s && !ze(a) && (s = await t.newChat(e.id, { persist: c }, Ve(a)), r.track("agent-chat", {
386
386
  event: "created",
387
387
  chatId: s.id,
388
388
  mode: a
389
389
  })), { chat: s, chatMode: (s == null ? void 0 : s.chat_mode) ?? a };
390
390
  } catch (o) {
391
- throw Dt(o) === "InsufficientCreditsError" ? new Error("InsufficientCreditsError") : new Error("Cannot create new chat");
391
+ throw It(o) === "InsufficientCreditsError" ? new Error("InsufficientCreditsError") : new Error("Cannot create new chat");
392
392
  }
393
393
  }
394
- const Dt = (e) => {
394
+ const It = (e) => {
395
395
  try {
396
396
  const t = JSON.parse(e.message);
397
397
  return t == null ? void 0 : t.kind;
@@ -399,41 +399,41 @@ const Dt = (e) => {
399
399
  return "UnknownError";
400
400
  }
401
401
  };
402
- function It(e) {
402
+ function Mt(e) {
403
403
  return e && e.length > 0 ? e : [];
404
404
  }
405
- function Mt(e) {
405
+ function Et(e) {
406
406
  return new Promise((t, r) => {
407
- const { callbacks: a, host: c, auth: s, externalId: o } = e, { onMessage: n = null, onOpen: i = null, onClose: d = null, onError: m = null } = a || {}, l = new WebSocket(`${c}?authorization=${encodeURIComponent(ze(s, o))}`);
408
- l.onmessage = n, l.onclose = d, l.onerror = (h) => {
409
- console.error(h), m == null || m("Websocket failed to connect", h), r(h);
410
- }, l.onopen = (h) => {
411
- i == null || i(h), t(l);
407
+ const { callbacks: a, host: c, auth: s, externalId: o } = e, { onMessage: n = null, onOpen: i = null, onClose: d = null, onError: m = null } = a || {}, l = new WebSocket(`${c}?authorization=${encodeURIComponent(Fe(s, o))}`);
408
+ l.onmessage = n, l.onclose = d, l.onerror = (p) => {
409
+ console.error(p), m == null || m("Websocket failed to connect", p), r(p);
410
+ }, l.onopen = (p) => {
411
+ i == null || i(p), t(l);
412
412
  };
413
413
  });
414
414
  }
415
- async function Et(e) {
415
+ async function Tt(e) {
416
416
  const { retries: t = 1 } = e;
417
417
  let r = null;
418
418
  for (let a = 0; (r == null ? void 0 : r.readyState) !== WebSocket.OPEN; a++)
419
419
  try {
420
- r = await Mt(e);
420
+ r = await Et(e);
421
421
  } catch (c) {
422
422
  if (a === t)
423
423
  throw c;
424
- await je(a * 500);
424
+ await Be(a * 500);
425
425
  }
426
426
  return r;
427
427
  }
428
- async function Tt(e, t, r, a) {
429
- const c = r != null && r.onMessage ? [r.onMessage] : [], s = await Et({
428
+ async function _t(e, t, r, a) {
429
+ const c = r != null && r.onMessage ? [r.onMessage] : [], s = await Tt({
430
430
  auth: e,
431
431
  host: t,
432
432
  externalId: a,
433
433
  callbacks: {
434
434
  onError: (o) => {
435
435
  var n;
436
- return (n = r.onError) == null ? void 0 : n.call(r, new qe(o));
436
+ return (n = r.onError) == null ? void 0 : n.call(r, new Xe(o));
437
437
  },
438
438
  onMessage(o) {
439
439
  const n = JSON.parse(o.data);
@@ -447,7 +447,7 @@ async function Tt(e, t, r, a) {
447
447
  subscribeToEvents: (o) => c.push(o)
448
448
  };
449
449
  }
450
- function _t(e) {
450
+ function _e(e) {
451
451
  if (e.answer !== void 0)
452
452
  return e.answer;
453
453
  let t = 0, r = "";
@@ -458,9 +458,7 @@ function _t(e) {
458
458
  function bt(e, t, r) {
459
459
  if (!e.content)
460
460
  return;
461
- const a = t.messages[t.messages.length - 1];
462
- (a == null ? void 0 : a.role) === "assistant" && !a.interrupted && (a.interrupted = !0);
463
- const c = {
461
+ const a = {
464
462
  id: e.id || `user-${Date.now()}`,
465
463
  role: e.role,
466
464
  content: e.content,
@@ -468,7 +466,7 @@ function bt(e, t, r) {
468
466
  created_at: e.created_at || (/* @__PURE__ */ new Date()).toISOString(),
469
467
  transcribed: !0
470
468
  };
471
- t.messages.push(c), r == null || r([...t.messages], "user");
469
+ t.messages.push(a), r == null || r([...t.messages], "user");
472
470
  }
473
471
  function At(e, t, r, a, c, s, o) {
474
472
  if (e === N.Transcribe && t.content) {
@@ -492,9 +490,14 @@ function At(e, t, r, a, c, s, o) {
492
490
  else
493
491
  return;
494
492
  const { content: m, sequence: l } = t;
495
- e === N.Partial ? r[l] = m : r.answer = m;
496
- const h = _t(r);
497
- (d.content !== h || e === N.Answer) && (d.content = h, d.parts = re(h), c == null || c([...a.messages], e));
493
+ if (e === N.Partial)
494
+ r[l] = m;
495
+ else {
496
+ const w = _e(r);
497
+ !!(m && m.length < w.length) && (d.interrupted = !0), r.answer = m;
498
+ }
499
+ const p = _e(r);
500
+ (d.content !== p || e === N.Answer) && (d.content = p, d.parts = re(p), c == null || c([...a.messages], e));
498
501
  }
499
502
  function xt(e, t, r, a, c) {
500
503
  const s = {}, o = () => {
@@ -503,48 +506,48 @@ function xt(e, t, r, a, c) {
503
506
  };
504
507
  let n = null;
505
508
  const i = (d, m) => {
506
- var l, h;
507
- m === "user" && o(), (h = (l = r.callbacks).onNewMessage) == null || h.call(l, d, m);
509
+ var l, p;
510
+ m === "user" && o(), (p = (l = r.callbacks).onNewMessage) == null || p.call(l, d, m);
508
511
  };
509
512
  return {
510
513
  clearQueue: o,
511
514
  onMessage: (d, m) => {
512
- var l, h;
515
+ var l, p;
513
516
  if ("content" in m) {
514
- const v = d === P.ChatAnswer ? N.Answer : d === P.ChatAudioTranscribed ? N.Transcribe : d;
517
+ const w = d === P.ChatAnswer ? N.Answer : d === P.ChatAudioTranscribed ? N.Transcribe : d;
515
518
  At(
516
- v,
519
+ w,
517
520
  m,
518
521
  s,
519
522
  t,
520
523
  i,
521
524
  o,
522
525
  n
523
- ), v === N.Partial ? n = "partial" : v === N.Answer && (n = "answer", o()), v === N.Answer && e.track("agent-message-received", {
526
+ ), w === N.Partial ? n = "partial" : w === N.Answer && (n = "answer", o()), w === N.Answer && e.track("agent-message-received", {
524
527
  content: m.content,
525
528
  messages: t.messages.length,
526
529
  mode: t.chatMode
527
530
  });
528
531
  } else {
529
- const v = P, k = [v.StreamVideoDone, v.StreamVideoError, v.StreamVideoRejected], B = [v.StreamFailed, v.StreamVideoError, v.StreamVideoRejected], M = St(m, a, { mode: t.chatMode });
530
- if (d = d, d === v.StreamVideoCreated && (e.linkTrack("agent-video", M, v.StreamVideoCreated, ["start"]), m.sentiment)) {
532
+ const w = P, C = [w.StreamVideoDone, w.StreamVideoError, w.StreamVideoRejected], B = [w.StreamFailed, w.StreamVideoError, w.StreamVideoRejected], M = kt(m, a, { mode: t.chatMode });
533
+ if (d = d, d === w.StreamVideoCreated && (e.linkTrack("agent-video", M, w.StreamVideoCreated, ["start"]), m.sentiment)) {
531
534
  const D = t.messages[t.messages.length - 1];
532
535
  if ((D == null ? void 0 : D.role) === "assistant") {
533
536
  const $ = { ...D, sentiment: m.sentiment };
534
537
  t.messages[t.messages.length - 1] = $, i == null || i([...t.messages], n ?? "answer");
535
538
  }
536
539
  }
537
- if (k.includes(d)) {
540
+ if (C.includes(d)) {
538
541
  const D = d.split("/")[1];
539
542
  B.includes(d) ? e.track("agent-video", { ...M, event: D }) : e.linkTrack("agent-video", { ...M, event: D }, d, ["done"]);
540
543
  }
541
- B.includes(d) && ((h = (l = r.callbacks).onError) == null || h.call(l, new Error(`Stream failed with event ${d}`), { data: m })), m.event === v.StreamDone && c();
544
+ B.includes(d) && ((p = (l = r.callbacks).onError) == null || p.call(l, new Error(`Stream failed with event ${d}`), { data: m })), m.event === w.StreamDone && c();
542
545
  }
543
546
  }
544
547
  };
545
548
  }
546
549
  function Lt(e, t, r, a) {
547
- const c = Fe(e, `${t}/agents/${r}`, a);
550
+ const c = Ne(e, `${t}/agents/${r}`, a);
548
551
  return {
549
552
  createStream(s, o) {
550
553
  return c.post("/streams", s, { signal: o });
@@ -647,7 +650,7 @@ function $t(e) {
647
650
  freezeDuration: s.totalFreezesDuration
648
651
  };
649
652
  }
650
- function _e(e, t, r) {
653
+ function be(e, t, r) {
651
654
  const a = e.map((i, d) => d === 0 ? r ? {
652
655
  timestamp: i.timestamp,
653
656
  duration: 0,
@@ -715,7 +718,7 @@ function _e(e, t, r) {
715
718
  resolution: `${e[0].frameWidth}x${e[0].frameHeight}`
716
719
  };
717
720
  }
718
- function Ke(e, t) {
721
+ function Ue(e, t) {
719
722
  for (const r of e.values())
720
723
  if ((r == null ? void 0 : r.type) === "inbound-rtp" && r.kind === t)
721
724
  return r;
@@ -732,18 +735,18 @@ function cr(e, t) {
732
735
  c = setTimeout(i, ee);
733
736
  return;
734
737
  }
735
- const m = Ke(d, "audio");
738
+ const m = Ue(d, "audio");
736
739
  if (!m) {
737
740
  c = setTimeout(i, ee);
738
741
  return;
739
742
  }
740
- const l = m.totalAudioEnergy ?? 0, h = m.totalSamplesReceived ?? 0;
743
+ const l = m.totalAudioEnergy ?? 0, p = m.totalSamplesReceived ?? 0;
741
744
  if (!a) {
742
- s = l, o = h, a = !0, c = setTimeout(i, ee);
745
+ s = l, o = p, a = !0, c = setTimeout(i, ee);
743
746
  return;
744
747
  }
745
- const v = l - s, k = h - o;
746
- if (s = l, o = h, k > 0 && v > 0) {
748
+ const w = l - s, C = p - o;
749
+ if (s = l, o = p, C > 0 && w > 0) {
747
750
  r = !1, t(n);
748
751
  return;
749
752
  }
@@ -765,7 +768,7 @@ const oe = 100, zt = Math.max(Math.ceil(400 / oe), 1), Ft = 0.25, Nt = 0.28;
765
768
  function Vt() {
766
769
  let e = 0, t, r, a = 0;
767
770
  return (c) => {
768
- const s = Ke(c, "video");
771
+ const s = Ue(c, "video");
769
772
  if (!s)
770
773
  return { isReceiving: !1, avgJitterDelayInInterval: a };
771
774
  const o = s.jitterBufferDelay, n = s.jitterBufferEmittedCount;
@@ -779,18 +782,18 @@ function Vt() {
779
782
  };
780
783
  }
781
784
  function Kt(e, t, r, a, c) {
782
- let s = null, o = [], n, i = 0, d = !1, m = te.Unknown, l = te.Unknown, h = 0, v = 0;
783
- const k = Vt();
785
+ let s = null, o = [], n, i = 0, d = !1, m = te.Unknown, l = te.Unknown, p = 0, w = 0;
786
+ const C = Vt();
784
787
  async function B() {
785
788
  const M = await e();
786
789
  if (!M)
787
790
  return;
788
- const { isReceiving: D, avgJitterDelayInInterval: $, freezeCount: _ } = k(M), q = $t(M);
791
+ const { isReceiving: D, avgJitterDelayInInterval: $, freezeCount: _ } = C(M), q = $t(M);
789
792
  if (D)
790
- i = 0, h = _ - v, l = $ < Ft ? te.Strong : $ > Nt && h > 1 ? te.Weak : m, l !== m && (c == null || c(l), m = l, v += h, h = 0), d || (a == null || a(S.Start), n = o[o.length - 1], o = [], d = !0), o.push(q);
793
+ i = 0, p = _ - w, l = $ < Ft ? te.Strong : $ > Nt && p > 1 ? te.Weak : m, l !== m && (c == null || c(l), m = l, w += p, p = 0), d || (a == null || a(k.Start), n = o[o.length - 1], o = [], d = !0), o.push(q);
791
794
  else if (d && (i++, i >= zt)) {
792
- const J = _e(o, oe, n);
793
- a == null || a(S.Stop, J), t() || r(), v = _, d = !1;
795
+ const J = be(o, oe, n);
796
+ a == null || a(k.Stop, J), t() || r(), w = _, d = !1;
794
797
  }
795
798
  }
796
799
  return {
@@ -800,11 +803,11 @@ function Kt(e, t, r, a, c) {
800
803
  stop: () => {
801
804
  s && (clearInterval(s), s = null);
802
805
  },
803
- getReport: () => _e(o, oe, n)
806
+ getReport: () => be(o, oe, n)
804
807
  };
805
808
  }
806
809
  const Ut = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
807
- function be(e) {
810
+ function Ae(e) {
808
811
  switch (e) {
809
812
  case "connected":
810
813
  return L.Connected;
@@ -840,7 +843,7 @@ function Jt({
840
843
  report: a,
841
844
  log: c
842
845
  }) {
843
- e === S.Start && t === S.Start ? (c("CALLBACK: onVideoStateChange(Start)"), r == null || r(S.Start)) : e === S.Stop && t === S.Stop && (c("CALLBACK: onVideoStateChange(Stop)"), r == null || r(S.Stop, a));
846
+ e === k.Start && t === k.Start ? (c("CALLBACK: onVideoStateChange(Start)"), r == null || r(k.Start)) : e === k.Stop && t === k.Stop && (c("CALLBACK: onVideoStateChange(Stop)"), r == null || r(k.Stop, a));
844
847
  }
845
848
  function Ot({
846
849
  statsSignal: e,
@@ -850,9 +853,9 @@ function Ot({
850
853
  report: c,
851
854
  log: s
852
855
  }) {
853
- e === S.Start ? (s("CALLBACK: onVideoStateChange(Start)"), r == null || r(S.Start)) : e === S.Stop && (s("CALLBACK: onVideoStateChange(Stop)"), r == null || r(S.Stop, c)), t === S.Start ? a == null || a(ne.Talking) : t === S.Stop && (a == null || a(ne.Idle));
856
+ e === k.Start ? (s("CALLBACK: onVideoStateChange(Start)"), r == null || r(k.Start)) : e === k.Stop && (s("CALLBACK: onVideoStateChange(Stop)"), r == null || r(k.Stop, c)), t === k.Start ? a == null || a(ne.Talking) : t === k.Stop && (a == null || a(ne.Idle));
854
857
  }
855
- function Ae({
858
+ function xe({
856
859
  statsSignal: e,
857
860
  dataChannelSignal: t,
858
861
  onVideoStateChange: r,
@@ -873,8 +876,8 @@ function Ae({
873
876
  async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de, analytics: o }, n) {
874
877
  var E;
875
878
  const i = Pt(r, "WebRTCStreamingManager"), d = Wt(i);
876
- let m = !1, l = !1, h = S.Stop, v = S.Stop;
877
- const { startConnection: k, sendStreamRequest: B, close: M, createStream: D, addIceCandidate: $ } = Lt(
879
+ let m = !1, l = !1, p = k.Stop, w = k.Stop;
880
+ const { startConnection: C, sendStreamRequest: B, close: M, createStream: D, addIceCandidate: $ } = Lt(
878
881
  c,
879
882
  s,
880
883
  e,
@@ -902,22 +905,22 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
902
905
  () => I.getStats(),
903
906
  ie,
904
907
  u,
905
- (f, p) => Ae({
906
- statsSignal: v = f,
907
- dataChannelSignal: K === W.Legacy ? h : void 0,
908
+ (f, h) => xe({
909
+ statsSignal: w = f,
910
+ dataChannelSignal: K === W.Legacy ? p : void 0,
908
911
  onVideoStateChange: a.onVideoStateChange,
909
912
  onAgentActivityStateChange: a.onAgentActivityStateChange,
910
- report: p,
913
+ report: h,
911
914
  streamType: K,
912
915
  log: i
913
916
  }),
914
917
  (f) => {
915
- var p;
916
- return (p = a.onConnectivityStateChange) == null ? void 0 : p.call(a, f);
918
+ var h;
919
+ return (h = a.onConnectivityStateChange) == null ? void 0 : h.call(a, f);
917
920
  }
918
921
  );
919
922
  g.start(), I.onicecandidate = (f) => {
920
- var p;
923
+ var h;
921
924
  i("peerConnection.onicecandidate", f);
922
925
  try {
923
926
  f.candidate && f.candidate.sdpMid && f.candidate.sdpMLineIndex !== null ? $(
@@ -931,59 +934,59 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
931
934
  n
932
935
  ) : $(_, { candidate: null }, V, n);
933
936
  } catch (b) {
934
- (p = a.onError) == null || p.call(a, b, { streamId: _ });
937
+ (h = a.onError) == null || h.call(a, b, { streamId: _ });
935
938
  }
936
939
  }, Y.onopen = () => {
937
940
  l = !0, (!ae || m) && u();
938
941
  };
939
- let w = null;
942
+ let v = null;
940
943
  const y = (f) => {
941
- var p;
942
- w = f, (p = a.onVideoIdChange) == null || p.call(a, f);
944
+ var h;
945
+ v = f, (h = a.onVideoIdChange) == null || h.call(a, f);
943
946
  };
944
- function C(f, p) {
945
- if (f === P.StreamStarted && typeof p == "object" && "metadata" in p) {
946
- const b = p.metadata;
947
+ function S(f, h) {
948
+ if (f === P.StreamStarted && typeof h == "object" && "metadata" in h) {
949
+ const b = h.metadata;
947
950
  y(b.videoId);
948
951
  }
949
- f === P.StreamDone && y(null), h = f === P.StreamStarted ? S.Start : S.Stop, Ae({
950
- statsSignal: K === W.Legacy ? v : void 0,
951
- dataChannelSignal: h,
952
+ f === P.StreamDone && y(null), p = f === P.StreamStarted ? k.Start : k.Stop, xe({
953
+ statsSignal: K === W.Legacy ? w : void 0,
954
+ dataChannelSignal: p,
952
955
  onVideoStateChange: a.onVideoStateChange,
953
956
  onAgentActivityStateChange: a.onAgentActivityStateChange,
954
957
  streamType: K,
955
958
  log: i
956
959
  });
957
960
  }
958
- function R(f, p) {
961
+ function R(f, h) {
959
962
  var T;
960
- const b = typeof p == "string" ? p : p == null ? void 0 : p.metadata;
963
+ const b = typeof h == "string" ? h : h == null ? void 0 : h.metadata;
961
964
  b && o.enrich({ streamMetadata: b }), (T = a.onStreamReady) == null || T.call(a);
962
965
  }
963
966
  const j = {
964
- [P.StreamStarted]: C,
965
- [P.StreamDone]: C,
967
+ [P.StreamStarted]: S,
968
+ [P.StreamDone]: S,
966
969
  [P.StreamReady]: R
967
970
  };
968
971
  Y.onmessage = (f) => {
969
972
  var T;
970
- const { subject: p, data: b } = d(f.data);
971
- (T = j[p]) == null || T.call(j, p, b);
973
+ const { subject: h, data: b } = d(f.data);
974
+ (T = j[h]) == null || T.call(j, h, b);
972
975
  }, I.oniceconnectionstatechange = () => {
973
- var p;
976
+ var h;
974
977
  i("peerConnection.oniceconnectionstatechange => " + I.iceConnectionState);
975
- const f = be(I.iceConnectionState);
976
- f !== L.Connected && ((p = a.onConnectionStateChange) == null || p.call(a, f));
978
+ const f = Ae(I.iceConnectionState);
979
+ f !== L.Connected && ((h = a.onConnectionStateChange) == null || h.call(a, f));
977
980
  }, I.ontrack = (f) => {
978
- var p;
979
- i("peerConnection.ontrack", f), i("CALLBACK: onSrcObjectReady"), (p = a.onSrcObjectReady) == null || p.call(a, f.streams[0]);
981
+ var h;
982
+ i("peerConnection.ontrack", f), i("CALLBACK: onSrcObjectReady"), (h = a.onSrcObjectReady) == null || h.call(a, f.streams[0]);
980
983
  }, await I.setRemoteDescription(q), i("set remote description OK");
981
984
  const z = await I.createAnswer();
982
- i("create answer OK"), await I.setLocalDescription(z), i("set local description OK"), await k(_, z, V, n), i("start connection OK");
985
+ i("create answer OK"), await I.setLocalDescription(z), i("set local description OK"), await C(_, z, V, n), i("start connection OK");
983
986
  function F(f) {
984
- var p, b;
987
+ var h, b;
985
988
  if (!m || Y.readyState !== "open") {
986
- i("Data channel is not ready for sending messages"), (p = a.onError) == null || p.call(a, new Error("Data channel is not ready for sending messages"), {
989
+ i("Data channel is not ready for sending messages"), (h = a.onError) == null || h.call(a, new Error("Data channel is not ready for sending messages"), {
987
990
  streamId: _
988
991
  });
989
992
  return;
@@ -1008,16 +1011,16 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
1008
1011
  async disconnect() {
1009
1012
  var f;
1010
1013
  if (_) {
1011
- const p = be(I.iceConnectionState);
1014
+ const h = Ae(I.iceConnectionState);
1012
1015
  if (I) {
1013
- if (p === L.New) {
1016
+ if (h === L.New) {
1014
1017
  g.stop();
1015
1018
  return;
1016
1019
  }
1017
1020
  I.close(), I.oniceconnectionstatechange = null, I.onnegotiationneeded = null, I.onicecandidate = null, I.ontrack = null;
1018
1021
  }
1019
1022
  try {
1020
- p === L.Connected && await M(_, V).catch((b) => {
1023
+ h === L.Connected && await M(_, V).catch((b) => {
1021
1024
  });
1022
1025
  } catch (b) {
1023
1026
  i("Error on close stream connection", b);
@@ -1042,14 +1045,14 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
1042
1045
  throw new Error("Interrupt is not enabled for this stream");
1043
1046
  if (K !== W.Fluent)
1044
1047
  throw new Error("Interrupt only available for Fluent streams");
1045
- if (!w)
1048
+ if (!v)
1046
1049
  throw new Error("No active video to interrupt");
1047
- const p = {
1050
+ const h = {
1048
1051
  type: P.StreamInterrupt,
1049
- videoId: w,
1052
+ videoId: v,
1050
1053
  timestamp: Date.now()
1051
1054
  };
1052
- F(JSON.stringify(p));
1055
+ F(JSON.stringify(h));
1053
1056
  }
1054
1057
  };
1055
1058
  }
@@ -1064,8 +1067,8 @@ async function qt(e, t, r, a) {
1064
1067
  case "v2": {
1065
1068
  const { version: s, ...o } = t;
1066
1069
  switch (o.transport.provider) {
1067
- case he.Livekit:
1068
- const { createLiveKitStreamingManager: n } = await import("./livekit-manager-B7gYoJ6B.js");
1070
+ case pe.Livekit:
1071
+ const { createLiveKitStreamingManager: n } = await import("./livekit-manager-Zdv-HZDQ.js");
1069
1072
  return n(c, o, r);
1070
1073
  default:
1071
1074
  throw new Error(`Unsupported transport provider: ${o.transport.provider}`);
@@ -1079,7 +1082,7 @@ const Xt = "cht";
1079
1082
  function Yt() {
1080
1083
  return {
1081
1084
  transport: {
1082
- provider: he.Livekit
1085
+ provider: pe.Livekit
1083
1086
  }
1084
1087
  };
1085
1088
  }
@@ -1097,7 +1100,7 @@ function Gt(e) {
1097
1100
  }, ...r && { end_user_data: r } };
1098
1101
  }
1099
1102
  function Qt(e, t) {
1100
- return pe(e.presenter.type) ? { version: ge.V2, ...Yt() } : { version: ge.V1, ...Gt(t) };
1103
+ return he(e.presenter.type) ? { version: ge.V2, ...Yt() } : { version: ge.V1, ...Gt(t) };
1101
1104
  }
1102
1105
  function Zt(e, t, r) {
1103
1106
  r.track("agent-connection-state-change", { state: e, ...t && { reason: t } });
@@ -1106,7 +1109,7 @@ function er(e, t, r, a, c) {
1106
1109
  c === W.Fluent ? tr(e, t, r, a, c) : rr(e, t, r, a, c);
1107
1110
  }
1108
1111
  function tr(e, t, r, a, c) {
1109
- e === S.Start ? a.track("stream-session", { event: "start", "stream-type": c }) : e === S.Stop && a.track("stream-session", {
1112
+ e === k.Start ? a.track("stream-session", { event: "start", "stream-type": c }) : e === k.Stop && a.track("stream-session", {
1110
1113
  event: "stop",
1111
1114
  is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
1112
1115
  background: t.presenter.type === "clip" && t.presenter.background,
@@ -1114,10 +1117,10 @@ function tr(e, t, r, a, c) {
1114
1117
  ...r
1115
1118
  });
1116
1119
  }
1117
- function xe(e, t, r, a, c) {
1118
- e === S.Start ? r.linkTrack("agent-video", { event: "start", ...c, "stream-type": a }, "start", [
1120
+ function Le(e, t, r, a, c) {
1121
+ e === k.Start ? r.linkTrack("agent-video", { event: "start", ...c, "stream-type": a }, "start", [
1119
1122
  P.StreamVideoCreated
1120
- ]) : e === S.Stop && r.linkTrack(
1123
+ ]) : e === k.Stop && r.linkTrack(
1121
1124
  "agent-video",
1122
1125
  {
1123
1126
  event: "stop",
@@ -1130,12 +1133,12 @@ function xe(e, t, r, a, c) {
1130
1133
  );
1131
1134
  }
1132
1135
  function rr(e, t, r, a, c) {
1133
- e === S.Start ? a.linkTrack(
1136
+ e === k.Start ? a.linkTrack(
1134
1137
  "agent-video",
1135
1138
  { event: "start", latency: H.get(!0), "stream-type": c },
1136
1139
  "start",
1137
1140
  [P.StreamVideoCreated]
1138
- ) : e === S.Stop && a.linkTrack(
1141
+ ) : e === k.Stop && a.linkTrack(
1139
1142
  "agent-video",
1140
1143
  {
1141
1144
  event: "stop",
@@ -1165,7 +1168,7 @@ function nr(e, t, r) {
1165
1168
  extra_keys: c.extra ? Object.keys(c.extra).length : 0
1166
1169
  });
1167
1170
  }
1168
- function Le(e, t, r, a) {
1171
+ function Pe(e, t, r, a) {
1169
1172
  return H.reset(), Te.update(), new Promise(async (c, s) => {
1170
1173
  try {
1171
1174
  let o, n = !1;
@@ -1183,32 +1186,32 @@ function Le(e, t, r, a) {
1183
1186
  analytics: r,
1184
1187
  callbacks: {
1185
1188
  ...t.callbacks,
1186
- onConnectionStateChange: (l, h) => {
1187
- var v, k;
1188
- (k = (v = t.callbacks).onConnectionStateChange) == null || k.call(v, l), Zt(l, h, r), l === L.Connected && (o ? c(o) : n = !0);
1189
+ onConnectionStateChange: (l, p) => {
1190
+ var w, C;
1191
+ (C = (w = t.callbacks).onConnectionStateChange) == null || C.call(w, l), Zt(l, p, r), l === L.Connected && (o ? c(o) : n = !0);
1189
1192
  },
1190
- onVideoStateChange: (l, h) => {
1191
- var v, k;
1192
- (k = (v = t.callbacks).onVideoStateChange) == null || k.call(v, l), er(
1193
+ onVideoStateChange: (l, p) => {
1194
+ var w, C;
1195
+ (C = (w = t.callbacks).onVideoStateChange) == null || C.call(w, l), er(
1193
1196
  l,
1194
1197
  e,
1195
- h,
1198
+ p,
1196
1199
  r,
1197
1200
  o.streamType
1198
1201
  );
1199
1202
  },
1200
1203
  onAgentActivityStateChange: (l) => {
1201
- var h, v;
1202
- (v = (h = t.callbacks).onAgentActivityStateChange) == null || v.call(h, l), l === ne.Talking ? (fe.update(), d = (k) => {
1203
- xe(
1204
- S.Start,
1204
+ var p, w;
1205
+ (w = (p = t.callbacks).onAgentActivityStateChange) == null || w.call(p, l), l === ne.Talking ? (fe.update(), d = (C) => {
1206
+ Le(
1207
+ k.Start,
1205
1208
  e,
1206
1209
  r,
1207
1210
  o.streamType,
1208
- k
1211
+ C
1209
1212
  ), d = null;
1210
- }, m || d({ latency: H.get(!0) })) : (fe.reset(), d = null, xe(
1211
- S.Stop,
1213
+ }, m || d({ latency: H.get(!0) })) : (fe.reset(), d = null, Le(
1214
+ k.Stop,
1212
1215
  e,
1213
1216
  r,
1214
1217
  o.streamType
@@ -1221,9 +1224,9 @@ function Le(e, t, r, a) {
1221
1224
  const l = Te.get(!0);
1222
1225
  r.track("agent-chat", { event: "ready", latency: l });
1223
1226
  },
1224
- onToolEvent: (l, h) => {
1225
- var v, k;
1226
- (k = (v = t.callbacks).onToolEvent) == null || k.call(v, l, h), nr(l, h, r);
1227
+ onToolEvent: (l, p) => {
1228
+ var w, C;
1229
+ (C = (w = t.callbacks).onToolEvent) == null || C.call(w, l, p), nr(l, p, r);
1227
1230
  }
1228
1231
  }
1229
1232
  },
@@ -1235,10 +1238,10 @@ function Le(e, t, r, a) {
1235
1238
  });
1236
1239
  }
1237
1240
  async function ar(e, t, r, a, c) {
1238
- var m, l, h, v;
1241
+ var m, l, p, w;
1239
1242
  const s = async () => {
1240
- if (pe(e.presenter.type)) {
1241
- const k = await Le(e, t, a), B = `${Xt}_${k.sessionId}`, M = (/* @__PURE__ */ new Date()).toISOString();
1243
+ if (he(e.presenter.type)) {
1244
+ const C = await Pe(e, t, a), B = `${Xt}_${C.sessionId}`, M = (/* @__PURE__ */ new Date()).toISOString();
1242
1245
  return { chatResult: {
1243
1246
  chatMode: x.Functional,
1244
1247
  chat: {
@@ -1252,35 +1255,35 @@ async function ar(e, t, r, a, c) {
1252
1255
  chat_mode: x.Functional,
1253
1256
  messages: []
1254
1257
  }
1255
- }, streamingManager: k };
1258
+ }, streamingManager: C };
1256
1259
  } else {
1257
- const k = new AbortController(), B = k.signal;
1260
+ const C = new AbortController(), B = C.signal;
1258
1261
  let M;
1259
1262
  try {
1260
- const D = Ve(
1263
+ const D = Ke(
1261
1264
  e,
1262
1265
  r,
1263
1266
  a,
1264
1267
  t.mode,
1265
1268
  t.persistentChat,
1266
1269
  c
1267
- ), $ = Le(e, t, a, B).then((J) => (M = J, J)), [_, q] = await Promise.all([D, $]);
1270
+ ), $ = Pe(e, t, a, B).then((J) => (M = J, J)), [_, q] = await Promise.all([D, $]);
1268
1271
  return { chatResult: _, streamingManager: q };
1269
1272
  } catch (D) {
1270
- throw k.abort(), M && await M.disconnect().catch(() => {
1273
+ throw C.abort(), M && await M.disconnect().catch(() => {
1271
1274
  }), D;
1272
1275
  }
1273
1276
  }
1274
1277
  }, { chatResult: o, streamingManager: n } = await s(), { chat: i, chatMode: d } = o;
1275
- return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (l = (m = t.callbacks).onModeChange) == null || l.call(m, d), d !== x.Functional) ? ((v = (h = t.callbacks).onError) == null || v.call(h, new He(d)), n == null || n.disconnect(), { chat: i }) : { chat: i, streamingManager: n };
1278
+ return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (l = (m = t.callbacks).onModeChange) == null || l.call(m, d), d !== x.Functional) ? ((w = (p = t.callbacks).onError) == null || w.call(p, new qe(d)), n == null || n.disconnect(), { chat: i }) : { chat: i, streamingManager: n };
1276
1279
  }
1277
1280
  async function dr(e, t) {
1278
1281
  var Y, K, ae, ie;
1279
1282
  let r = !0;
1280
- const a = t.mixpanelKey || ot, c = t.wsURL || st, s = t.baseURL || de, o = t.mode || x.Functional, n = {
1283
+ const a = t.mixpanelKey || ct, c = t.wsURL || ot, s = t.baseURL || de, o = t.mode || x.Functional, n = {
1281
1284
  messages: [],
1282
1285
  chatMode: o
1283
- }, i = Rt({
1286
+ }, i = Dt({
1284
1287
  token: a,
1285
1288
  agentId: e,
1286
1289
  isEnabled: t.enableAnalitics,
@@ -1290,66 +1293,66 @@ async function dr(e, t) {
1290
1293
  Ee(() => {
1291
1294
  i.track("agent-sdk", { event: "init" }, d);
1292
1295
  });
1293
- const m = wt(t.auth, s, t.callbacks.onError, t.externalId), l = await m.getById(e);
1296
+ const m = vt(t.auth, s, t.callbacks.onError, t.externalId), l = await m.getById(e);
1294
1297
  t.debug = t.debug || ((Y = l == null ? void 0 : l.advanced_settings) == null ? void 0 : Y.ui_debug_mode);
1295
- const h = pe(l.presenter.type);
1296
- i.enrich(yt(l));
1297
- const { onMessage: v, clearQueue: k } = xt(i, n, t, l, () => {
1298
- var u, g, w;
1299
- (u = n.socketManager) == null || u.disconnect(), (w = (g = t.callbacks).onConnectionStateChange) == null || w.call(g, L.Disconnected);
1298
+ const p = he(l.presenter.type);
1299
+ i.enrich(Ct(l));
1300
+ const { onMessage: w, clearQueue: C } = xt(i, n, t, l, () => {
1301
+ var u, g, v;
1302
+ (u = n.socketManager) == null || u.disconnect(), (v = (g = t.callbacks).onConnectionStateChange) == null || v.call(g, L.Disconnected);
1300
1303
  });
1301
- n.messages = It(t.initialMessages), (ae = (K = t.callbacks).onNewMessage) == null || ae.call(K, [...n.messages], "answer");
1304
+ n.messages = Mt(t.initialMessages), (ae = (K = t.callbacks).onNewMessage) == null || ae.call(K, [...n.messages], "answer");
1302
1305
  const B = (u) => {
1303
1306
  }, M = ({ type: u }) => {
1304
- var w, y, C, R;
1305
- if (!((w = n.streamingManager) != null && w.interruptAvailable) || !((y = n.streamingManager) != null && y.isInterruptible)) return;
1307
+ var v, y, S, R;
1308
+ if (!((v = n.streamingManager) != null && v.interruptAvailable) || !((y = n.streamingManager) != null && y.isInterruptible)) return;
1306
1309
  const g = n.messages[n.messages.length - 1];
1307
1310
  i.track("agent-video-interrupt", {
1308
1311
  type: u || "click",
1309
1312
  video_duration_to_interrupt: fe.get(!0),
1310
1313
  message_duration_to_interrupt: H.get(!0)
1311
- }), g.interrupted = !0, (R = (C = t.callbacks).onNewMessage) == null || R.call(C, [...n.messages], "answer"), n.streamingManager.interrupt(u);
1314
+ }), g.interrupted = !0, (R = (S = t.callbacks).onNewMessage) == null || R.call(S, [...n.messages], "answer"), n.streamingManager.interrupt(u);
1312
1315
  }, D = /* @__PURE__ */ new Map();
1313
1316
  function $(u) {
1314
1317
  return async (g) => {
1315
- const w = D.get(u);
1316
- if (!w)
1318
+ const v = D.get(u);
1319
+ if (!v)
1317
1320
  throw new Error(`No handler registered for client tool: ${u}`);
1318
1321
  try {
1319
1322
  const y = JSON.parse(g.payload);
1320
- return await w(y);
1323
+ return await v(y);
1321
1324
  } catch (y) {
1322
1325
  throw new Error(`Client tool "${u}" failed: ${y.message}`);
1323
1326
  }
1324
1327
  };
1325
1328
  }
1326
1329
  function _() {
1327
- var u, g, w, y;
1328
- for (const [C] of D)
1329
- (g = (u = n.streamingManager) == null ? void 0 : u.unregisterRpcMethod) == null || g.call(u, C), (y = (w = n.streamingManager) == null ? void 0 : w.registerRpcMethod) == null || y.call(w, C, $(C));
1330
+ var u, g, v, y;
1331
+ for (const [S] of D)
1332
+ (g = (u = n.streamingManager) == null ? void 0 : u.unregisterRpcMethod) == null || g.call(u, S), (y = (v = n.streamingManager) == null ? void 0 : v.registerRpcMethod) == null || y.call(v, S, $(S));
1330
1333
  }
1331
1334
  function q(u, g) {
1332
- var y, C;
1333
- const w = !D.has(u);
1334
- D.set(u, g), w && ((C = (y = n.streamingManager) == null ? void 0 : y.registerRpcMethod) == null || C.call(y, u, $(u)));
1335
+ var y, S;
1336
+ const v = !D.has(u);
1337
+ D.set(u, g), v && ((S = (y = n.streamingManager) == null ? void 0 : y.registerRpcMethod) == null || S.call(y, u, $(u)));
1335
1338
  }
1336
1339
  function J(u) {
1337
- var g, w;
1338
- D.delete(u), (w = (g = n.streamingManager) == null ? void 0 : g.unregisterRpcMethod) == null || w.call(g, u);
1340
+ var g, v;
1341
+ D.delete(u), (v = (g = n.streamingManager) == null ? void 0 : g.unregisterRpcMethod) == null || v.call(g, u);
1339
1342
  }
1340
1343
  const V = Date.now();
1341
1344
  Ee(() => {
1342
- i.track("agent-sdk", { event: "loaded", ...vt(l) }, V);
1345
+ i.track("agent-sdk", { event: "loaded", ...yt(l) }, V);
1343
1346
  });
1344
1347
  async function X(u) {
1345
- var j, z, F, E, f, p, b;
1348
+ var j, z, F, E, f, h, b;
1346
1349
  (z = (j = t.callbacks).onConnectionStateChange) == null || z.call(j, L.Connecting), H.reset(), u && !r && (delete n.chat, (E = (F = t.callbacks).onNewMessage) == null || E.call(F, [...n.messages], "answer"));
1347
- const g = o === x.DirectPlayback || h ? Promise.resolve(void 0) : Tt(
1350
+ const g = o === x.DirectPlayback || p ? Promise.resolve(void 0) : _t(
1348
1351
  t.auth,
1349
1352
  c,
1350
- { onMessage: v, onError: t.callbacks.onError },
1353
+ { onMessage: w, onError: t.callbacks.onError },
1351
1354
  t.externalId
1352
- ), w = ue(
1355
+ ), v = ue(
1353
1356
  () => ar(
1354
1357
  l,
1355
1358
  {
@@ -1358,7 +1361,7 @@ async function dr(e, t) {
1358
1361
  callbacks: {
1359
1362
  ...t.callbacks,
1360
1363
  onVideoIdChange: B,
1361
- onMessage: v
1364
+ onMessage: w
1362
1365
  }
1363
1366
  },
1364
1367
  m,
@@ -1367,7 +1370,7 @@ async function dr(e, t) {
1367
1370
  ),
1368
1371
  {
1369
1372
  limit: 3,
1370
- timeout: at,
1373
+ timeout: it,
1371
1374
  timeoutErrorMessage: "Timeout initializing the stream",
1372
1375
  shouldRetryFn: (T) => (T == null ? void 0 : T.message) !== "Could not connect" && T.status !== 429 && (T == null ? void 0 : T.message) !== "InsufficientCreditsError",
1373
1376
  delayMs: 1e3
@@ -1375,20 +1378,20 @@ async function dr(e, t) {
1375
1378
  ).catch((T) => {
1376
1379
  var A, U;
1377
1380
  throw I(x.Maintenance), (U = (A = t.callbacks).onConnectionStateChange) == null || U.call(A, L.Fail), T;
1378
- }), [y, { streamingManager: C, chat: R }] = await Promise.all([g, w]);
1379
- R && R.id !== ((f = n.chat) == null ? void 0 : f.id) && ((b = (p = t.callbacks).onNewChat) == null || b.call(p, R.id)), n.streamingManager = C, n.socketManager = y, n.chat = R, _(), r = !1, i.enrich({
1381
+ }), [y, { streamingManager: S, chat: R }] = await Promise.all([g, v]);
1382
+ R && R.id !== ((f = n.chat) == null ? void 0 : f.id) && ((b = (h = t.callbacks).onNewChat) == null || b.call(h, R.id)), n.streamingManager = S, n.socketManager = y, n.chat = R, _(), r = !1, i.enrich({
1380
1383
  chatId: R == null ? void 0 : R.id,
1381
- streamId: C == null ? void 0 : C.streamId,
1384
+ streamId: S == null ? void 0 : S.streamId,
1382
1385
  mode: n.chatMode
1383
1386
  }), I((R == null ? void 0 : R.chat_mode) ?? o);
1384
1387
  }
1385
1388
  async function O() {
1386
- var u, g, w, y;
1387
- (u = n.socketManager) == null || u.disconnect(), await ((g = n.streamingManager) == null ? void 0 : g.disconnect()), delete n.streamingManager, delete n.socketManager, (y = (w = t.callbacks).onConnectionStateChange) == null || y.call(w, L.Disconnected);
1389
+ var u, g, v, y;
1390
+ (u = n.socketManager) == null || u.disconnect(), await ((g = n.streamingManager) == null ? void 0 : g.disconnect()), delete n.streamingManager, delete n.socketManager, (y = (v = t.callbacks).onConnectionStateChange) == null || y.call(v, L.Disconnected);
1388
1391
  }
1389
1392
  async function I(u) {
1390
- var g, w;
1391
- u !== n.chatMode && (i.track("agent-mode-change", { mode: u }), n.chatMode = u, n.chatMode !== x.Functional && await O(), (w = (g = t.callbacks).onModeChange) == null || w.call(g, u));
1393
+ var g, v;
1394
+ u !== n.chatMode && (i.track("agent-mode-change", { mode: u }), n.chatMode = u, n.chatMode !== x.Functional && await O(), (v = (g = t.callbacks).onModeChange) == null || v.call(g, u));
1392
1395
  }
1393
1396
  return {
1394
1397
  agent: l,
@@ -1412,7 +1415,7 @@ async function dr(e, t) {
1412
1415
  },
1413
1416
  async reconnect() {
1414
1417
  const u = n.streamingManager;
1415
- if (h && (u != null && u.reconnect)) {
1418
+ if (p && (u != null && u.reconnect)) {
1416
1419
  try {
1417
1420
  await u.reconnect(), i.track("agent-chat", {
1418
1421
  event: "reconnect",
@@ -1455,9 +1458,9 @@ async function dr(e, t) {
1455
1458
  return (u = n.streamingManager) != null && u.unpublishCameraStream ? n.streamingManager.unpublishCameraStream() : Promise.resolve();
1456
1459
  },
1457
1460
  async chat(u) {
1458
- var C, R, j, z, F;
1461
+ var S, R, j, z, F;
1459
1462
  const g = () => {
1460
- if ($e(o))
1463
+ if (ze(o))
1461
1464
  throw new G(`${o} is enabled, chat is disabled`);
1462
1465
  if (u.length >= 800)
1463
1466
  throw new G("Message cannot be more than 800 characters");
@@ -1471,24 +1474,24 @@ async function dr(e, t) {
1471
1474
  if (!n.chat)
1472
1475
  throw new G("Chat is not initialized");
1473
1476
  }
1474
- }, w = async () => {
1477
+ }, v = async () => {
1475
1478
  var E, f;
1476
1479
  if (!n.chat) {
1477
- const p = await Ve(
1480
+ const h = await Ke(
1478
1481
  l,
1479
1482
  m,
1480
1483
  i,
1481
1484
  n.chatMode,
1482
1485
  t.persistentChat
1483
1486
  );
1484
- if (!p.chat)
1485
- throw new Oe(n.chatMode, !!t.persistentChat);
1486
- n.chat = p.chat, (f = (E = t.callbacks).onNewChat) == null || f.call(E, n.chat.id);
1487
+ if (!h.chat)
1488
+ throw new He(n.chatMode, !!t.persistentChat);
1489
+ n.chat = h.chat, (f = (E = t.callbacks).onNewChat) == null || f.call(E, n.chat.id);
1487
1490
  }
1488
1491
  return n.chat.id;
1489
1492
  }, y = async (E, f) => {
1490
- const p = n.chatMode === x.Playground;
1491
- return ue(h && !p ? async () => {
1493
+ const h = n.chatMode === x.Playground;
1494
+ return ue(p && !h ? async () => {
1492
1495
  var A, U;
1493
1496
  return await ((U = (A = n.streamingManager) == null ? void 0 : A.sendTextMessage) == null ? void 0 : U.call(A, u)), Promise.resolve({});
1494
1497
  } : async () => {
@@ -1500,10 +1503,10 @@ async function dr(e, t) {
1500
1503
  chatMode: n.chatMode,
1501
1504
  streamId: (A = n.streamingManager) == null ? void 0 : A.streamId,
1502
1505
  sessionId: (U = n.streamingManager) == null ? void 0 : U.sessionId,
1503
- messages: E.map(({ matches: Ue, ...se }) => se)
1506
+ messages: E.map(({ matches: We, ...se }) => se)
1504
1507
  },
1505
1508
  {
1506
- ...Ne(n.chatMode),
1509
+ ...Ve(n.chatMode),
1507
1510
  skipErrorHandler: !0
1508
1511
  }
1509
1512
  );
@@ -1520,14 +1523,14 @@ async function dr(e, t) {
1520
1523
  });
1521
1524
  };
1522
1525
  try {
1523
- k(), g(), n.messages.push({
1526
+ C(), g(), n.messages.push({
1524
1527
  id: Q(),
1525
1528
  role: "user",
1526
1529
  content: u,
1527
1530
  parts: re(u),
1528
1531
  created_at: new Date(H.update()).toISOString()
1529
- }), (R = (C = t.callbacks).onNewMessage) == null || R.call(C, [...n.messages], "user");
1530
- const E = await w(), f = await y([...n.messages], E);
1532
+ }), (R = (S = t.callbacks).onNewMessage) == null || R.call(S, [...n.messages], "user");
1533
+ const E = await v(), f = await y([...n.messages], E);
1531
1534
  return f.result && n.messages.push({
1532
1535
  id: Q(),
1533
1536
  role: "assistant",
@@ -1550,29 +1553,29 @@ async function dr(e, t) {
1550
1553
  }), E;
1551
1554
  }
1552
1555
  },
1553
- rate(u, g, w) {
1556
+ rate(u, g, v) {
1554
1557
  var R, j, z, F;
1555
1558
  const y = n.messages.find((E) => E.id === u);
1556
1559
  if (n.chat) {
1557
1560
  if (!y)
1558
1561
  throw new Error("Message not found");
1559
1562
  } else throw new Error("Chat is not initialized");
1560
- const C = ((R = y.matches) == null ? void 0 : R.map((E) => [E.document_id, E.id])) ?? [];
1563
+ const S = ((R = y.matches) == null ? void 0 : R.map((E) => [E.document_id, E.id])) ?? [];
1561
1564
  return i.track("agent-rate", {
1562
- event: w ? "update" : "create",
1565
+ event: v ? "update" : "create",
1563
1566
  thumb: g === 1 ? "up" : "down",
1564
1567
  knowledge_id: ((j = l.knowledge) == null ? void 0 : j.id) ?? "",
1565
- matches: C,
1568
+ matches: S,
1566
1569
  score: g
1567
- }), w ? m.updateRating(l.id, n.chat.id, w, {
1570
+ }), v ? m.updateRating(l.id, n.chat.id, v, {
1568
1571
  knowledge_id: ((z = l.knowledge) == null ? void 0 : z.id) ?? "",
1569
1572
  message_id: u,
1570
- matches: C,
1573
+ matches: S,
1571
1574
  score: g
1572
1575
  }) : m.createRating(l.id, n.chat.id, {
1573
1576
  knowledge_id: ((F = l.knowledge) == null ? void 0 : F.id) ?? "",
1574
1577
  message_id: u,
1575
- matches: C,
1578
+ matches: S,
1576
1579
  score: g
1577
1580
  });
1578
1581
  },
@@ -1582,7 +1585,7 @@ async function dr(e, t) {
1582
1585
  return i.track("agent-rate-delete", { type: "text" }), m.deleteRating(l.id, n.chat.id, u);
1583
1586
  },
1584
1587
  async speak(u) {
1585
- var C, R, j;
1588
+ var S, R, j;
1586
1589
  function g() {
1587
1590
  if (typeof u == "string") {
1588
1591
  if (!l.presenter.voice)
@@ -1606,14 +1609,14 @@ async function dr(e, t) {
1606
1609
  }
1607
1610
  return u;
1608
1611
  }
1609
- const w = g();
1610
- if (i.track("agent-speak", w), H.update(), n.messages && w.type === "text" && (n.messages.push({
1612
+ const v = g();
1613
+ if (i.track("agent-speak", v), H.update(), n.messages && v.type === "text" && (n.messages.push({
1611
1614
  id: Q(),
1612
1615
  role: "assistant",
1613
- content: w.input,
1614
- parts: re(w.input),
1616
+ content: v.input,
1617
+ parts: re(v.input),
1615
1618
  created_at: (/* @__PURE__ */ new Date()).toISOString()
1616
- }), (R = (C = t.callbacks).onNewMessage) == null || R.call(C, [...n.messages], "answer")), lt(n.chatMode))
1619
+ }), (R = (S = t.callbacks).onNewMessage) == null || R.call(S, [...n.messages], "answer")), ut(n.chatMode))
1617
1620
  return {
1618
1621
  duration: 0,
1619
1622
  video_id: "",
@@ -1622,7 +1625,7 @@ async function dr(e, t) {
1622
1625
  if (!n.streamingManager)
1623
1626
  throw new Error("Please connect to the agent first");
1624
1627
  return n.streamingManager.speak({
1625
- script: w,
1628
+ script: v,
1626
1629
  metadata: { chat_id: (j = n.chat) == null ? void 0 : j.id, agent_id: l.id }
1627
1630
  });
1628
1631
  },
@@ -1634,35 +1637,35 @@ async function dr(e, t) {
1634
1637
  export {
1635
1638
  ne as A,
1636
1639
  N as C,
1637
- tt as D,
1638
- et as K,
1639
- Ye as P,
1640
- Qe as R,
1640
+ rt as D,
1641
+ tt as K,
1642
+ Ge as P,
1643
+ Ze as R,
1641
1644
  P as S,
1642
- he as T,
1643
- Xe as U,
1645
+ pe as T,
1646
+ Ye as U,
1644
1647
  G as V,
1645
- qe as W,
1648
+ Xe as W,
1646
1649
  Pt as a,
1647
1650
  W as b,
1648
- Fe as c,
1651
+ Ne as c,
1649
1652
  de as d,
1650
1653
  L as e,
1651
1654
  te as f,
1652
1655
  Kt as g,
1653
1656
  cr as h,
1654
- S as i,
1655
- Oe as j,
1656
- He as k,
1657
+ k as i,
1658
+ He as j,
1659
+ qe as k,
1657
1660
  H as l,
1658
1661
  dr as m,
1659
1662
  or as n,
1660
- Ge as o,
1661
- ft as p,
1663
+ Qe as o,
1664
+ gt as p,
1662
1665
  x as q,
1663
- Ze as r,
1664
- Pe as s,
1666
+ et as r,
1667
+ je as s,
1665
1668
  sr as t,
1666
- rt as u,
1667
- nt as v
1669
+ nt as u,
1670
+ at as v
1668
1671
  };