@d-id/client-sdk 1.2.0-staging.339 → 1.2.1-staging.341

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
1
  var Ye = Object.defineProperty;
2
2
  var Qe = (e, t, r) => t in e ? Ye(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var ce = (e, t, r) => Qe(e, typeof t != "symbol" ? t + "" : t, r);
3
+ var Z = (e, t, r) => Qe(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  class G extends Error {
5
5
  constructor(t, r = "Error", a) {
6
6
  super(t), this.kind = r, this.originalError = a, Object.setPrototypeOf(this, new.target.prototype);
@@ -37,11 +37,11 @@ function tt(e) {
37
37
  }
38
38
  class ze extends G {
39
39
  constructor(r, a, c = {}) {
40
- const s = tt(a);
41
- super(((s == null ? void 0 : s.description) ?? a).slice(0, 256), (s == null ? void 0 : s.kind) ?? "HttpError");
42
- ce(this, "status");
43
- ce(this, "url");
44
- ce(this, "method");
40
+ const i = tt(a);
41
+ super(((i == null ? void 0 : i.description) ?? a).slice(0, 256), (i == null ? void 0 : i.kind) ?? "HttpError");
42
+ Z(this, "status");
43
+ Z(this, "url");
44
+ Z(this, "method");
45
45
  this.status = r, this.url = c.url, this.method = c.method;
46
46
  }
47
47
  toJson() {
@@ -54,8 +54,18 @@ class ze extends G {
54
54
  }
55
55
  }
56
56
  class rt extends G {
57
- constructor(t) {
58
- super("Network request failed", "NetworkError", t);
57
+ constructor(r, a = {}) {
58
+ super("Network request failed", "NetworkError", r);
59
+ Z(this, "endpoint");
60
+ Z(this, "method");
61
+ this.endpoint = a.url, this.method = a.method;
62
+ }
63
+ toJson() {
64
+ return {
65
+ ...super.toJson(),
66
+ ...this.endpoint ? { endpoint: this.endpoint } : {},
67
+ ...this.method ? { method: this.method } : {}
68
+ };
59
69
  }
60
70
  }
61
71
  class Ne extends G {
@@ -73,7 +83,7 @@ class nt extends G {
73
83
  super(t, "WSError");
74
84
  }
75
85
  }
76
- var at = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(at || {}), st = /* @__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))(st || {}), it = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(it || {}), ot = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(ot || {}), A = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(A || {}), z = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(z || {}), ct = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(ct || {}), dt = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(dt || {}), lt = /* @__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))(lt || {}), Fe = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(Fe || {});
86
+ var at = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(at || {}), it = /* @__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))(it || {}), st = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(st || {}), ot = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(ot || {}), A = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(A || {}), z = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(z || {}), ct = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(ct || {}), dt = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(dt || {}), lt = /* @__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))(lt || {}), Fe = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(Fe || {});
77
87
  const hr = (e) => {
78
88
  switch (e) {
79
89
  case "clip":
@@ -86,7 +96,7 @@ const hr = (e) => {
86
96
  throw new Error(`Unknown video type: ${e}`);
87
97
  }
88
98
  };
89
- 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 || {}), x = /* @__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))(x || {}), b = /* @__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))(b || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), pe = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(pe || {}), ut = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(ut || {}), mt = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(mt || {});
99
+ var S = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(S || {}), re = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(re || {}), ae = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(ae || {}), x = /* @__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))(x || {}), b = /* @__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))(b || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), pe = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(pe || {}), ut = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(ut || {}), mt = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(mt || {});
90
100
  const pr = (...e) => {
91
101
  }, Ve = (e) => new Promise((t) => setTimeout(t, e)), Q = (e = 16) => {
92
102
  const t = new Uint8Array(e);
@@ -144,8 +154,8 @@ function Rt(e) {
144
154
  for (De.lastIndex = 0; (r = De.exec(e)) !== null; )
145
155
  if (!t.some((o) => r.index >= o.index && r.index < o.index + o.length)) {
146
156
  const o = r[2], n = r[1];
147
- let i;
148
- kt(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 });
157
+ let s;
158
+ kt(o) ? s = { type: "video", src: o, alt: n } : (s = { type: "image", src: o, alt: n }, o.toLowerCase().endsWith(".gif") && (s.mimeType = "image/gif")), t.push({ index: r.index, length: r[0].length, part: s });
149
159
  }
150
160
  for (Ie.lastIndex = 0; (r = Ie.exec(e)) !== null; )
151
161
  t.some((o) => r.index >= o.index && r.index < o.index + o.length) || t.push({
@@ -161,22 +171,22 @@ function Rt(e) {
161
171
  });
162
172
  if (t.length === 0)
163
173
  return [{ type: "text", text: e }];
164
- t.sort((s, o) => s.index - o.index);
174
+ t.sort((i, o) => i.index - o.index);
165
175
  const a = [];
166
176
  let c = 0;
167
- for (const s of t)
168
- s.index > c && a.push({ type: "text", text: e.slice(c, s.index) }), a.push(s.part), c = s.index + s.length;
177
+ for (const i of t)
178
+ i.index > c && a.push({ type: "text", text: e.slice(c, i.index) }), a.push(i.part), c = i.index + i.length;
169
179
  return c < e.length && a.push({ type: "text", text: e.slice(c) }), a;
170
180
  }
171
181
  let Ee = "", ue = [];
172
- function re(e) {
182
+ function ne(e) {
173
183
  return e === Ee || (Ee = e, ue = Rt(e)), ue;
174
184
  }
175
185
  function Dt(e, t) {
176
186
  let r;
177
187
  return {
178
- promise: new Promise((c, s) => {
179
- r = setTimeout(() => s(new Error(t)), e);
188
+ promise: new Promise((c, i) => {
189
+ r = setTimeout(() => i(new Error(t)), e);
180
190
  }),
181
191
  clear: () => clearTimeout(r)
182
192
  };
@@ -196,12 +206,12 @@ async function fe(e, t) {
196
206
  try {
197
207
  if (!r.timeout)
198
208
  return await e();
199
- const { promise: s, clear: o } = Dt(r.timeout, r.timeoutErrorMessage), n = e().finally(o);
200
- return await Promise.race([n, s]);
201
- } catch (s) {
202
- if (a = s, !r.shouldRetryFn(s) || c >= r.limit)
203
- throw s;
204
- await Ve(r.delayMs), r.onRetry(s);
209
+ const { promise: i, clear: o } = Dt(r.timeout, r.timeoutErrorMessage), n = e().finally(o);
210
+ return await Promise.race([n, i]);
211
+ } catch (i) {
212
+ if (a = i, !r.shouldRetryFn(i) || c >= r.limit)
213
+ throw i;
214
+ await Ve(r.delayMs), r.onRetry(i);
205
215
  }
206
216
  throw a;
207
217
  }
@@ -212,15 +222,15 @@ const It = (e) => fe(e, {
212
222
  shouldRetryFn: (t) => t.status === 429
213
223
  });
214
224
  function He(e, t = le, r, a) {
215
- const c = async (s, o) => {
216
- const { skipErrorHandler: n, ...i } = o || {};
225
+ const c = async (i, o) => {
226
+ const { skipErrorHandler: n, ...s } = o || {};
217
227
  let d;
218
228
  try {
219
229
  d = await It(
220
- () => fetch(t + (s != null && s.startsWith("/") ? s : `/${s}`), {
221
- ...i,
230
+ () => fetch(t + (i != null && i.startsWith("/") ? i : `/${i}`), {
231
+ ...s,
222
232
  headers: {
223
- ...i.headers,
233
+ ...s.headers,
224
234
  Authorization: Ue(e, a),
225
235
  "Content-Type": "application/json"
226
236
  }
@@ -229,73 +239,73 @@ function He(e, t = le, r, a) {
229
239
  } catch (u) {
230
240
  if ((u == null ? void 0 : u.name) === "AbortError")
231
241
  throw u;
232
- const m = new rt(u);
233
- throw n || r == null || r(m, { url: s, options: i }), m;
242
+ const m = new rt(u, { url: i, method: s.method ?? "GET" });
243
+ throw n || r == null || r(m, { url: i, options: s }), m;
234
244
  }
235
245
  if (!d.ok) {
236
- const u = await d.text().catch(() => `Failed to fetch with status ${d.status}`), f = new ze(d.status, u, { url: s, method: i.method ?? "GET" });
237
- throw n || r == null || r(f, { url: s, options: i, headers: d.headers }), f;
246
+ const u = await d.text().catch(() => `Failed to fetch with status ${d.status}`), f = new ze(d.status, u, { url: i, method: s.method ?? "GET" });
247
+ throw n || r == null || r(f, { url: i, options: s, headers: d.headers }), f;
238
248
  }
239
249
  return d.json();
240
250
  };
241
251
  return {
242
- get(s, o) {
243
- return c(s, { ...o, method: "GET" });
252
+ get(i, o) {
253
+ return c(i, { ...o, method: "GET" });
244
254
  },
245
- post(s, o, n) {
246
- return c(s, { ...n, body: JSON.stringify(o), method: "POST" });
255
+ post(i, o, n) {
256
+ return c(i, { ...n, body: JSON.stringify(o), method: "POST" });
247
257
  },
248
- delete(s, o, n) {
249
- return c(s, { ...n, body: JSON.stringify(o), method: "DELETE" });
258
+ delete(i, o, n) {
259
+ return c(i, { ...n, body: JSON.stringify(o), method: "DELETE" });
250
260
  },
251
- patch(s, o, n) {
252
- return c(s, { ...n, body: JSON.stringify(o), method: "PATCH" });
261
+ patch(i, o, n) {
262
+ return c(i, { ...n, body: JSON.stringify(o), method: "PATCH" });
253
263
  }
254
264
  };
255
265
  }
256
266
  function Mt(e, t = le, r, a) {
257
267
  const c = He(e, `${t}/agents`, r, a);
258
268
  return {
259
- create(s, o) {
260
- return c.post("/", s, o);
269
+ create(i, o) {
270
+ return c.post("/", i, o);
261
271
  },
262
- getAgents(s, o) {
263
- return c.get(`/${s ? `?tag=${s}` : ""}`, o).then((n) => n ?? []);
272
+ getAgents(i, o) {
273
+ return c.get(`/${i ? `?tag=${i}` : ""}`, o).then((n) => n ?? []);
264
274
  },
265
- getById(s, o) {
266
- return c.get(`/${s}`, o);
275
+ getById(i, o) {
276
+ return c.get(`/${i}`, o);
267
277
  },
268
- delete(s, o) {
269
- return c.delete(`/${s}`, void 0, o);
278
+ delete(i, o) {
279
+ return c.delete(`/${i}`, void 0, o);
270
280
  },
271
- update(s, o, n) {
272
- return c.patch(`/${s}`, o, n);
281
+ update(i, o, n) {
282
+ return c.patch(`/${i}`, o, n);
273
283
  },
274
- newChat(s, o, n) {
275
- return c.post(`/${s}/chat`, o, n);
284
+ newChat(i, o, n) {
285
+ return c.post(`/${i}/chat`, o, n);
276
286
  },
277
- chat(s, o, n, i) {
278
- return c.post(`/${s}/chat/${o}`, n, i);
287
+ chat(i, o, n, s) {
288
+ return c.post(`/${i}/chat/${o}`, n, s);
279
289
  },
280
- createRating(s, o, n, i) {
281
- return c.post(`/${s}/chat/${o}/ratings`, n, i);
290
+ createRating(i, o, n, s) {
291
+ return c.post(`/${i}/chat/${o}/ratings`, n, s);
282
292
  },
283
- updateRating(s, o, n, i, d) {
284
- return c.patch(`/${s}/chat/${o}/ratings/${n}`, i, d);
293
+ updateRating(i, o, n, s, d) {
294
+ return c.patch(`/${i}/chat/${o}/ratings/${n}`, s, d);
285
295
  },
286
- deleteRating(s, o, n, i) {
287
- return c.delete(`/${s}/chat/${o}/ratings/${n}`, i);
296
+ deleteRating(i, o, n, s) {
297
+ return c.delete(`/${i}/chat/${o}/ratings/${n}`, s);
288
298
  },
289
- getSTTToken(s, o) {
290
- return c.get(`/${s}/stt-token`, o);
299
+ getSTTToken(i, o) {
300
+ return c.get(`/${i}/stt-token`, o);
291
301
  }
292
302
  };
293
303
  }
294
304
  function Et(e) {
295
- var c, s, o, n;
305
+ var c, i, o, n;
296
306
  const t = () => /Mobi|Android/i.test(navigator.userAgent) ? "Mobile" : "Desktop", r = () => {
297
- const i = navigator.platform;
298
- return i.toLowerCase().includes("win") ? "Windows" : i.toLowerCase().includes("mac") ? "Mac OS X" : i.toLowerCase().includes("linux") ? "Linux" : "Unknown";
307
+ const s = navigator.platform;
308
+ return s.toLowerCase().includes("win") ? "Windows" : s.toLowerCase().includes("mac") ? "Mac OS X" : s.toLowerCase().includes("linux") ? "Linux" : "Unknown";
299
309
  }, a = e.presenter;
300
310
  return {
301
311
  $os: `${r()}`,
@@ -304,13 +314,13 @@ function Et(e) {
304
314
  origin: window.location.origin,
305
315
  agentType: Ke(a),
306
316
  agentVoice: {
307
- voiceId: (s = (c = e.presenter) == null ? void 0 : c.voice) == null ? void 0 : s.voice_id,
317
+ voiceId: (i = (c = e.presenter) == null ? void 0 : c.voice) == null ? void 0 : i.voice_id,
308
318
  provider: (n = (o = e.presenter) == null ? void 0 : o.voice) == null ? void 0 : n.type
309
319
  }
310
320
  };
311
321
  }
312
- function _t(e) {
313
- var r, a, c, s, o, n;
322
+ function Tt(e) {
323
+ var r, a, c, i, o, n;
314
324
  const t = (r = e.llm) == null ? void 0 : r.prompt_customization;
315
325
  return {
316
326
  agentType: Ke(e.presenter),
@@ -323,7 +333,7 @@ function _t(e) {
323
333
  personality: t == null ? void 0 : t.personality,
324
334
  instructions: (c = e.llm) == null ? void 0 : c.instructions
325
335
  },
326
- temperature: (s = e.llm) == null ? void 0 : s.temperature,
336
+ temperature: (i = e.llm) == null ? void 0 : i.temperature,
327
337
  knowledgeSource: t == null ? void 0 : t.knowledge_source,
328
338
  starterQuestionsCount: (n = (o = e.knowledge) == null ? void 0 : o.starter_message) == null ? void 0 : n.length,
329
339
  topicsToAvoid: t == null ? void 0 : t.topics_to_avoid,
@@ -334,29 +344,29 @@ function _t(e) {
334
344
  ...e.access === "public" ? { from: "agent-template" } : {}
335
345
  };
336
346
  }
337
- const Tt = (e) => {
347
+ const _t = (e) => {
338
348
  try {
339
349
  return String((e == null ? void 0 : e.message) ?? e ?? "").slice(0, 256);
340
350
  } catch {
341
351
  return "Unknown error";
342
352
  }
343
- }, At = (e) => e.reduce((t, r) => t + r, 0), _e = (e) => At(e) / e.length;
353
+ }, At = (e) => e.reduce((t, r) => t + r, 0), Te = (e) => At(e) / e.length;
344
354
  function bt(e, t, r) {
345
- var i, d, u;
346
- 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) || {};
355
+ var s, d, u;
356
+ const { event: a, ...c } = e, { template: i } = (t == null ? void 0 : t.llm) || {}, { language: o } = ((s = t == null ? void 0 : t.presenter) == null ? void 0 : s.voice) || {};
347
357
  return {
348
358
  ...c,
349
- llm: { ...c.llm, template: s },
359
+ llm: { ...c.llm, template: i },
350
360
  script: { ...c.script, provider: { ...(d = c == null ? void 0 : c.script) == null ? void 0 : d.provider, language: o } },
351
361
  stitch: (t == null ? void 0 : t.presenter.type) === "talk" ? (u = t == null ? void 0 : t.presenter) == null ? void 0 : u.stitch : void 0,
352
362
  ...r
353
363
  };
354
364
  }
355
- function Te(e) {
365
+ function _e(e) {
356
366
  "requestIdleCallback" in window ? requestIdleCallback(e, { timeout: 2e3 }) : setTimeout(e, 0);
357
367
  }
358
368
  function Ae(e) {
359
- return e instanceof G ? e.toJson() : { kind: "UnknownError", message: Tt(e) || "UnknownError" };
369
+ return e instanceof G ? e.toJson() : { kind: "UnknownError", message: _t(e) || "UnknownError" };
360
370
  }
361
371
  const xt = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
362
372
  function Lt(e) {
@@ -374,10 +384,10 @@ function Lt(e) {
374
384
  enrich(a) {
375
385
  this.additionalProperties = { ...this.additionalProperties, ...a };
376
386
  },
377
- async track(a, c, s) {
387
+ async track(a, c, i) {
378
388
  if (!this.isEnabled)
379
389
  return Promise.resolve();
380
- const { audioPath: o, ...n } = c || {}, i = s || Date.now(), d = {
390
+ const { audioPath: o, ...n } = c || {}, s = i || Date.now(), d = {
381
391
  method: "POST",
382
392
  headers: {
383
393
  "Content-Type": "application/x-www-form-urlencoded"
@@ -392,7 +402,7 @@ function Lt(e) {
392
402
  agentId: this.agentId,
393
403
  source: t,
394
404
  token: this.token,
395
- time: i,
405
+ time: s,
396
406
  $insert_id: this.getRandom(),
397
407
  origin: window.location.href,
398
408
  "Screen Height": window.screen.height || window.innerWidth,
@@ -405,10 +415,10 @@ function Lt(e) {
405
415
  };
406
416
  return fetch(xt, d).catch((u) => console.error("Analytics tracking error:", u)), Promise.resolve();
407
417
  },
408
- linkTrack(a, c, s, o) {
409
- r[a] || (r[a] = { events: {}, resolvedDependencies: [] }), o.includes(s) || o.push(s);
418
+ linkTrack(a, c, i, o) {
419
+ r[a] || (r[a] = { events: {}, resolvedDependencies: [] }), o.includes(i) || o.push(i);
410
420
  const n = r[a];
411
- if (n.events[s] = { props: c }, n.resolvedDependencies.push(s), o.every(
421
+ if (n.events[i] = { props: c }, n.resolvedDependencies.push(i), o.every(
412
422
  (d) => n.resolvedDependencies.includes(d)
413
423
  )) {
414
424
  const d = o.reduce((u, f) => n.events[f] ? { ...u, ...n.events[f].props } : u, {});
@@ -433,23 +443,23 @@ const q = ve(), ge = ve(), be = ve();
433
443
  function Oe(e) {
434
444
  return e === A.Playground ? { headers: { [ht]: "true" } } : {};
435
445
  }
436
- async function qe(e, t, r, a, c = !1, s) {
437
- return !s && !We(a) && (s = await t.newChat(e.id, { persist: c }, Oe(a)), r.track("agent-chat", {
446
+ async function qe(e, t, r, a, c = !1, i) {
447
+ return !i && !We(a) && (i = await t.newChat(e.id, { persist: c }, Oe(a)), r.track("agent-chat", {
438
448
  event: "created",
439
- chatId: s.id,
449
+ chatId: i.id,
440
450
  mode: a
441
- })), { chat: s, chatMode: (s == null ? void 0 : s.chat_mode) ?? a };
451
+ })), { chat: i, chatMode: (i == null ? void 0 : i.chat_mode) ?? a };
442
452
  }
443
453
  function Pt(e) {
444
454
  return e && e.length > 0 ? e : [];
445
455
  }
446
456
  function jt(e) {
447
457
  return new Promise((t, r) => {
448
- const { callbacks: a, host: c, auth: s, externalId: o } = e, { onMessage: n = null, onOpen: i = null, onClose: d = null, onError: u = null } = a || {}, f = new WebSocket(`${c}?authorization=${encodeURIComponent(Ue(s, o))}`);
458
+ const { callbacks: a, host: c, auth: i, externalId: o } = e, { onMessage: n = null, onOpen: s = null, onClose: d = null, onError: u = null } = a || {}, f = new WebSocket(`${c}?authorization=${encodeURIComponent(Ue(i, o))}`);
449
459
  f.onmessage = n, f.onclose = d, f.onerror = (m) => {
450
460
  console.error(m), u == null || u("Websocket failed to connect", m), r(m);
451
461
  }, f.onopen = (m) => {
452
- i == null || i(m), t(f);
462
+ s == null || s(m), t(f);
453
463
  };
454
464
  });
455
465
  }
@@ -467,7 +477,7 @@ async function Bt(e) {
467
477
  return r;
468
478
  }
469
479
  async function $t(e, t, r, a) {
470
- const c = r != null && r.onMessage ? [r.onMessage] : [], s = await Bt({
480
+ const c = r != null && r.onMessage ? [r.onMessage] : [], i = await Bt({
471
481
  auth: e,
472
482
  host: t,
473
483
  externalId: a,
@@ -478,13 +488,13 @@ async function $t(e, t, r, a) {
478
488
  },
479
489
  onMessage(o) {
480
490
  const n = JSON.parse(o.data);
481
- c.forEach((i) => i(n.event, n));
491
+ c.forEach((s) => s(n.event, n));
482
492
  }
483
493
  }
484
494
  });
485
495
  return {
486
- socket: s,
487
- disconnect: () => s.close(),
496
+ socket: i,
497
+ disconnect: () => i.close(),
488
498
  subscribeToEvents: (o) => c.push(o)
489
499
  };
490
500
  }
@@ -503,13 +513,13 @@ function zt(e, t, r) {
503
513
  id: e.id || `user-${Date.now()}`,
504
514
  role: e.role,
505
515
  content: e.content,
506
- parts: re(e.content),
516
+ parts: ne(e.content),
507
517
  created_at: e.created_at || (/* @__PURE__ */ new Date()).toISOString(),
508
518
  transcribed: !0
509
519
  };
510
520
  t.messages.push(a), r == null || r([...t.messages], "user");
511
521
  }
512
- function Nt(e, t, r, a, c, s, o) {
522
+ function Nt(e, t, r, a, c, i, o) {
513
523
  if (e === z.Transcribe && t.content) {
514
524
  zt(t, a, c);
515
525
  return;
@@ -524,7 +534,7 @@ function Nt(e, t, r, a, c, s, o) {
524
534
  if ((n == null ? void 0 : n.role) === "assistant" && !d)
525
535
  u = n;
526
536
  else if (!n || n.role === "user" || d)
527
- d && s(), u = {
537
+ d && i(), u = {
528
538
  id: t.id || `assistant-${Date.now()}`,
529
539
  role: t.role || "assistant",
530
540
  content: t.content || "",
@@ -541,15 +551,15 @@ function Nt(e, t, r, a, c, s, o) {
541
551
  !!(f && f.length < y.length) && (u.interrupted = !0), r.answer = f;
542
552
  }
543
553
  const w = xe(r);
544
- (u.content !== w || e === z.Answer) && (u.content = w, u.parts = re(w), c == null || c([...a.messages], e));
554
+ (u.content !== w || e === z.Answer) && (u.content = w, u.parts = ne(w), c == null || c([...a.messages], e));
545
555
  }
546
556
  function Ft(e, t, r, a, c) {
547
- const s = {}, o = () => {
548
- for (const d of Object.keys(s))
549
- delete s[d];
557
+ const i = {}, o = () => {
558
+ for (const d of Object.keys(i))
559
+ delete i[d];
550
560
  };
551
561
  let n = null;
552
- const i = (d, u) => {
562
+ const s = (d, u) => {
553
563
  var f, m;
554
564
  u === "user" && o(), (m = (f = r.callbacks).onNewMessage) == null || m.call(f, d, u);
555
565
  };
@@ -562,9 +572,9 @@ function Ft(e, t, r, a, c) {
562
572
  Nt(
563
573
  w,
564
574
  u,
565
- s,
566
- t,
567
575
  i,
576
+ t,
577
+ s,
568
578
  o,
569
579
  n
570
580
  ), w === z.Partial ? n = "partial" : w === z.Answer && (n = "answer", o()), w === z.Answer && e.track("agent-message-received", {
@@ -575,15 +585,15 @@ function Ft(e, t, r, a, c) {
575
585
  } else {
576
586
  const w = x, y = [w.StreamVideoDone, w.StreamVideoError, w.StreamVideoRejected], j = [w.StreamFailed, w.StreamVideoError, w.StreamVideoRejected], M = bt(u, a, { mode: t.chatMode });
577
587
  if (d = d, d === w.StreamVideoCreated && (e.linkTrack("agent-video", M, w.StreamVideoCreated, ["start"]), u.sentiment)) {
578
- const _ = t.messages[t.messages.length - 1];
579
- if ((_ == null ? void 0 : _.role) === "assistant") {
580
- const L = { ..._, sentiment: u.sentiment };
581
- t.messages[t.messages.length - 1] = L, i == null || i([...t.messages], n ?? "answer");
588
+ const T = t.messages[t.messages.length - 1];
589
+ if ((T == null ? void 0 : T.role) === "assistant") {
590
+ const L = { ...T, sentiment: u.sentiment };
591
+ t.messages[t.messages.length - 1] = L, s == null || s([...t.messages], n ?? "answer");
582
592
  }
583
593
  }
584
594
  if (y.includes(d)) {
585
- const _ = d.split("/")[1];
586
- j.includes(d) ? e.track("agent-video", { ...M, event: _ }) : e.linkTrack("agent-video", { ...M, event: _ }, d, ["done"]);
595
+ const T = d.split("/")[1];
596
+ j.includes(d) ? e.track("agent-video", { ...M, event: T }) : e.linkTrack("agent-video", { ...M, event: T }, d, ["done"]);
587
597
  }
588
598
  j.includes(d) && ((m = (f = r.callbacks).onError) == null || m.call(f, new Ne(`Stream failed with event ${d}`), { data: u })), u.event === w.StreamDone && c();
589
599
  }
@@ -593,37 +603,37 @@ function Ft(e, t, r, a, c) {
593
603
  function Vt(e, t, r, a) {
594
604
  const c = He(e, `${t}/agents/${r}`, a);
595
605
  return {
596
- createStream(s, o) {
597
- return c.post("/streams", s, { signal: o });
606
+ createStream(i, o) {
607
+ return c.post("/streams", i, { signal: o });
598
608
  },
599
- startConnection(s, o, n, i) {
609
+ startConnection(i, o, n, s) {
600
610
  return c.post(
601
- `/streams/${s}/sdp`,
611
+ `/streams/${i}/sdp`,
602
612
  {
603
613
  session_id: n,
604
614
  answer: o
605
615
  },
606
- { signal: i }
616
+ { signal: s }
607
617
  );
608
618
  },
609
- addIceCandidate(s, o, n, i) {
619
+ addIceCandidate(i, o, n, s) {
610
620
  return c.post(
611
- `/streams/${s}/ice`,
621
+ `/streams/${i}/ice`,
612
622
  {
613
623
  session_id: n,
614
624
  ...o
615
625
  },
616
- { signal: i }
626
+ { signal: s }
617
627
  );
618
628
  },
619
- sendStreamRequest(s, o, n) {
620
- return c.post(`/streams/${s}`, {
629
+ sendStreamRequest(i, o, n) {
630
+ return c.post(`/streams/${i}`, {
621
631
  session_id: o,
622
632
  ...n
623
633
  });
624
634
  },
625
- close(s, o) {
626
- return c.delete(`/streams/${s}`, { session_id: o });
635
+ close(i, o) {
636
+ return c.delete(`/streams/${i}`, { session_id: o });
627
637
  }
628
638
  };
629
639
  }
@@ -668,56 +678,17 @@ function Wt(e) {
668
678
  if (n.type === "codec" && ((o = n.mimeType) != null && o.startsWith("video")))
669
679
  c.set(n.id, n.mimeType.split("/")[1]);
670
680
  else if (n.type === "candidate-pair") {
671
- const i = n, d = i.currentRoundTripTime ?? 0;
672
- d > 0 && (i.nominated === !0 || r === 0) && (r = d);
681
+ const s = n, d = s.currentRoundTripTime ?? 0;
682
+ d > 0 && (s.nominated === !0 || r === 0) && (r = d);
673
683
  } else n.type === "inbound-rtp" && n.kind === "video" && (a = n);
674
684
  if (!a)
675
685
  return {};
676
- const s = a;
677
- return s.codecId && c.has(s.codecId) ? t = c.get(s.codecId) : c.size > 0 && (t = c.values().next().value ?? ""), {
686
+ const i = a;
687
+ return i.codecId && c.has(i.codecId) ? t = c.get(i.codecId) : c.size > 0 && (t = c.values().next().value ?? ""), {
678
688
  codec: t,
679
689
  rtt: r,
680
- timestamp: s.timestamp,
681
- bytesReceived: s.bytesReceived,
682
- packetsReceived: s.packetsReceived,
683
- packetsLost: s.packetsLost,
684
- framesDropped: s.framesDropped,
685
- framesDecoded: s.framesDecoded,
686
- jitter: s.jitter,
687
- jitterBufferDelay: s.jitterBufferDelay,
688
- jitterBufferEmittedCount: s.jitterBufferEmittedCount,
689
- avgJitterDelayInInterval: s.jitterBufferDelay / s.jitterBufferEmittedCount,
690
- frameWidth: s.frameWidth,
691
- frameHeight: s.frameHeight,
692
- framesPerSecond: s.framesPerSecond,
693
- freezeCount: s.freezeCount,
694
- freezeDuration: s.totalFreezesDuration
695
- };
696
- }
697
- function Le(e, t, r) {
698
- const a = e.map((i, d) => d === 0 ? r ? {
699
690
  timestamp: i.timestamp,
700
- duration: 0,
701
- rtt: i.rtt,
702
- bytesReceived: i.bytesReceived - r.bytesReceived,
703
- bitrate: (i.bytesReceived - r.bytesReceived) * 8 / (t / 1e3),
704
- packetsReceived: i.packetsReceived - r.packetsReceived,
705
- packetsLost: i.packetsLost - r.packetsLost,
706
- framesDropped: i.framesDropped - r.framesDropped,
707
- framesDecoded: i.framesDecoded - r.framesDecoded,
708
- jitter: i.jitter,
709
- jitterBufferDelay: i.jitterBufferDelay - r.jitterBufferDelay,
710
- jitterBufferEmittedCount: i.jitterBufferEmittedCount - r.jitterBufferEmittedCount,
711
- avgJitterDelayInInterval: (i.jitterBufferDelay - r.jitterBufferDelay) / (i.jitterBufferEmittedCount - r.jitterBufferEmittedCount),
712
- framesPerSecond: i.framesPerSecond,
713
- freezeCount: i.freezeCount - r.freezeCount,
714
- freezeDuration: i.freezeDuration - r.freezeDuration
715
- } : {
716
- timestamp: i.timestamp,
717
- rtt: i.rtt,
718
- duration: 0,
719
691
  bytesReceived: i.bytesReceived,
720
- bitrate: i.bytesReceived * 8 / (t / 1e3),
721
692
  packetsReceived: i.packetsReceived,
722
693
  packetsLost: i.packetsLost,
723
694
  framesDropped: i.framesDropped,
@@ -726,37 +697,76 @@ function Le(e, t, r) {
726
697
  jitterBufferDelay: i.jitterBufferDelay,
727
698
  jitterBufferEmittedCount: i.jitterBufferEmittedCount,
728
699
  avgJitterDelayInInterval: i.jitterBufferDelay / i.jitterBufferEmittedCount,
700
+ frameWidth: i.frameWidth,
701
+ frameHeight: i.frameHeight,
729
702
  framesPerSecond: i.framesPerSecond,
730
703
  freezeCount: i.freezeCount,
731
- freezeDuration: i.freezeDuration
704
+ freezeDuration: i.totalFreezesDuration
705
+ };
706
+ }
707
+ function Le(e, t, r) {
708
+ const a = e.map((s, d) => d === 0 ? r ? {
709
+ timestamp: s.timestamp,
710
+ duration: 0,
711
+ rtt: s.rtt,
712
+ bytesReceived: s.bytesReceived - r.bytesReceived,
713
+ bitrate: (s.bytesReceived - r.bytesReceived) * 8 / (t / 1e3),
714
+ packetsReceived: s.packetsReceived - r.packetsReceived,
715
+ packetsLost: s.packetsLost - r.packetsLost,
716
+ framesDropped: s.framesDropped - r.framesDropped,
717
+ framesDecoded: s.framesDecoded - r.framesDecoded,
718
+ jitter: s.jitter,
719
+ jitterBufferDelay: s.jitterBufferDelay - r.jitterBufferDelay,
720
+ jitterBufferEmittedCount: s.jitterBufferEmittedCount - r.jitterBufferEmittedCount,
721
+ avgJitterDelayInInterval: (s.jitterBufferDelay - r.jitterBufferDelay) / (s.jitterBufferEmittedCount - r.jitterBufferEmittedCount),
722
+ framesPerSecond: s.framesPerSecond,
723
+ freezeCount: s.freezeCount - r.freezeCount,
724
+ freezeDuration: s.freezeDuration - r.freezeDuration
732
725
  } : {
733
- timestamp: i.timestamp,
726
+ timestamp: s.timestamp,
727
+ rtt: s.rtt,
728
+ duration: 0,
729
+ bytesReceived: s.bytesReceived,
730
+ bitrate: s.bytesReceived * 8 / (t / 1e3),
731
+ packetsReceived: s.packetsReceived,
732
+ packetsLost: s.packetsLost,
733
+ framesDropped: s.framesDropped,
734
+ framesDecoded: s.framesDecoded,
735
+ jitter: s.jitter,
736
+ jitterBufferDelay: s.jitterBufferDelay,
737
+ jitterBufferEmittedCount: s.jitterBufferEmittedCount,
738
+ avgJitterDelayInInterval: s.jitterBufferDelay / s.jitterBufferEmittedCount,
739
+ framesPerSecond: s.framesPerSecond,
740
+ freezeCount: s.freezeCount,
741
+ freezeDuration: s.freezeDuration
742
+ } : {
743
+ timestamp: s.timestamp,
734
744
  duration: t * d / 1e3,
735
- rtt: i.rtt,
736
- bytesReceived: i.bytesReceived - e[d - 1].bytesReceived,
737
- bitrate: (i.bytesReceived - e[d - 1].bytesReceived) * 8 / (t / 1e3),
738
- packetsReceived: i.packetsReceived - e[d - 1].packetsReceived,
739
- packetsLost: i.packetsLost - e[d - 1].packetsLost,
740
- framesDropped: i.framesDropped - e[d - 1].framesDropped,
741
- framesDecoded: i.framesDecoded - e[d - 1].framesDecoded,
742
- jitter: i.jitter,
743
- jitterBufferDelay: i.jitterBufferDelay - e[d - 1].jitterBufferDelay,
744
- jitterBufferEmittedCount: i.jitterBufferEmittedCount - e[d - 1].jitterBufferEmittedCount,
745
- avgJitterDelayInInterval: (i.jitterBufferDelay - e[d - 1].jitterBufferDelay) / (i.jitterBufferEmittedCount - e[d - 1].jitterBufferEmittedCount),
746
- framesPerSecond: i.framesPerSecond,
747
- freezeCount: i.freezeCount - e[d - 1].freezeCount,
748
- freezeDuration: i.freezeDuration - e[d - 1].freezeDuration
749
- }), c = Kt(a), s = c.reduce((i, d) => i + (d.causes.includes("low fps") ? 1 : 0), 0), o = a.filter((i) => !!i.avgJitterDelayInInterval).map((i) => i.avgJitterDelayInInterval), n = a.filter((i) => !!i.rtt).map((i) => i.rtt);
745
+ rtt: s.rtt,
746
+ bytesReceived: s.bytesReceived - e[d - 1].bytesReceived,
747
+ bitrate: (s.bytesReceived - e[d - 1].bytesReceived) * 8 / (t / 1e3),
748
+ packetsReceived: s.packetsReceived - e[d - 1].packetsReceived,
749
+ packetsLost: s.packetsLost - e[d - 1].packetsLost,
750
+ framesDropped: s.framesDropped - e[d - 1].framesDropped,
751
+ framesDecoded: s.framesDecoded - e[d - 1].framesDecoded,
752
+ jitter: s.jitter,
753
+ jitterBufferDelay: s.jitterBufferDelay - e[d - 1].jitterBufferDelay,
754
+ jitterBufferEmittedCount: s.jitterBufferEmittedCount - e[d - 1].jitterBufferEmittedCount,
755
+ avgJitterDelayInInterval: (s.jitterBufferDelay - e[d - 1].jitterBufferDelay) / (s.jitterBufferEmittedCount - e[d - 1].jitterBufferEmittedCount),
756
+ framesPerSecond: s.framesPerSecond,
757
+ freezeCount: s.freezeCount - e[d - 1].freezeCount,
758
+ freezeDuration: s.freezeDuration - e[d - 1].freezeDuration
759
+ }), c = Kt(a), i = c.reduce((s, d) => s + (d.causes.includes("low fps") ? 1 : 0), 0), o = a.filter((s) => !!s.avgJitterDelayInInterval).map((s) => s.avgJitterDelayInInterval), n = a.filter((s) => !!s.rtt).map((s) => s.rtt);
750
760
  return {
751
761
  webRTCStats: {
752
762
  anomalies: c,
753
763
  minRtt: Math.min(...n),
754
- avgRtt: _e(n),
764
+ avgRtt: Te(n),
755
765
  maxRtt: Math.max(...n),
756
- aggregateReport: Ut(e[0], e[e.length - 1], s),
766
+ aggregateReport: Ut(e[0], e[e.length - 1], i),
757
767
  minJitterDelayInInterval: Math.min(...o),
758
768
  maxJitterDelayInInterval: Math.max(...o),
759
- avgJitterDelayInInterval: _e(o)
769
+ avgJitterDelayInInterval: Te(o)
760
770
  },
761
771
  codec: e[0].codec,
762
772
  resolution: `${e[0].frameWidth}x${e[0].frameHeight}`
@@ -768,40 +778,40 @@ function Ge(e, t) {
768
778
  return r;
769
779
  return null;
770
780
  }
771
- const ee = 10;
781
+ const te = 10;
772
782
  function wr(e, t) {
773
- let r = !1, a = !1, c = null, s = 0, o = 0, n = {};
774
- async function i() {
783
+ let r = !1, a = !1, c = null, i = 0, o = 0, n = {};
784
+ async function s() {
775
785
  if (r) {
776
786
  try {
777
787
  const d = await e();
778
788
  if (!d) {
779
- c = setTimeout(i, ee);
789
+ c = setTimeout(s, te);
780
790
  return;
781
791
  }
782
792
  const u = Ge(d, "audio");
783
793
  if (!u) {
784
- c = setTimeout(i, ee);
794
+ c = setTimeout(s, te);
785
795
  return;
786
796
  }
787
797
  const f = u.totalAudioEnergy ?? 0, m = u.totalSamplesReceived ?? 0;
788
798
  if (!a) {
789
- s = f, o = m, a = !0, c = setTimeout(i, ee);
799
+ i = f, o = m, a = !0, c = setTimeout(s, te);
790
800
  return;
791
801
  }
792
- const w = f - s, y = m - o;
793
- if (s = f, o = m, y > 0 && w > 0) {
802
+ const w = f - i, y = m - o;
803
+ if (i = f, o = m, y > 0 && w > 0) {
794
804
  r = !1, t(n);
795
805
  return;
796
806
  }
797
807
  } catch {
798
808
  }
799
- r && (c = setTimeout(i, ee));
809
+ r && (c = setTimeout(s, te));
800
810
  }
801
811
  }
802
812
  return {
803
813
  arm(d = {}) {
804
- n = d, r = !0, a = !1, performance.now(), c !== null && clearTimeout(c), c = setTimeout(i, ee);
814
+ n = d, r = !0, a = !1, performance.now(), c !== null && clearTimeout(c), c = setTimeout(s, te);
805
815
  },
806
816
  destroy() {
807
817
  r = !1, c !== null && (clearTimeout(c), c = null);
@@ -812,40 +822,40 @@ const de = 100, Ht = Math.max(Math.ceil(400 / de), 1), Ot = 0.25, qt = 0.28;
812
822
  function Gt() {
813
823
  let e = 0, t, r, a = 0;
814
824
  return (c) => {
815
- const s = Ge(c, "video");
816
- if (!s)
825
+ const i = Ge(c, "video");
826
+ if (!i)
817
827
  return { isReceiving: !1, avgJitterDelayInInterval: a };
818
- const o = s.jitterBufferDelay, n = s.jitterBufferEmittedCount;
828
+ const o = i.jitterBufferDelay, n = i.jitterBufferEmittedCount;
819
829
  if (r && n > r) {
820
830
  const u = o - t, f = n - r;
821
831
  a = u / f;
822
832
  }
823
833
  t = o, r = n;
824
- const i = s.framesDecoded, d = i - e > 0;
825
- return e = i, { isReceiving: d, avgJitterDelayInInterval: a, freezeCount: s.freezeCount };
834
+ const s = i.framesDecoded, d = s - e > 0;
835
+ return e = s, { isReceiving: d, avgJitterDelayInInterval: a, freezeCount: i.freezeCount };
826
836
  };
827
837
  }
828
838
  function Xt(e, t, r, a, c) {
829
- let s = null, o = [], n, i = 0, d = !1, u = te.Unknown, f = te.Unknown, m = 0, w = 0;
839
+ let i = null, o = [], n, s = 0, d = !1, u = re.Unknown, f = re.Unknown, m = 0, w = 0;
830
840
  const y = Gt();
831
841
  async function j() {
832
842
  const M = await e();
833
843
  if (!M)
834
844
  return;
835
- const { isReceiving: _, avgJitterDelayInInterval: L, freezeCount: E } = y(M), X = Wt(M);
836
- if (_)
837
- i = 0, m = E - w, f = L < Ot ? te.Strong : L > qt && m > 1 ? te.Weak : u, f !== u && (c == null || c(f), u = f, w += m, m = 0), d || (a == null || a(S.Start), n = o[o.length - 1], o = [], d = !0), o.push(X);
838
- else if (d && (i++, i >= Ht)) {
845
+ const { isReceiving: T, avgJitterDelayInInterval: L, freezeCount: E } = y(M), X = Wt(M);
846
+ if (T)
847
+ s = 0, m = E - w, f = L < Ot ? re.Strong : L > qt && m > 1 ? re.Weak : u, f !== u && (c == null || c(f), u = f, w += m, m = 0), d || (a == null || a(S.Start), n = o[o.length - 1], o = [], d = !0), o.push(X);
848
+ else if (d && (s++, s >= Ht)) {
839
849
  const H = Le(o, de, n);
840
850
  a == null || a(S.Stop, H), t() || r(), w = E, d = !1;
841
851
  }
842
852
  }
843
853
  return {
844
854
  start: () => {
845
- s || (s = setInterval(j, de));
855
+ i || (i = setInterval(j, de));
846
856
  },
847
857
  stop: () => {
848
- s && (clearInterval(s), s = null);
858
+ i && (clearInterval(i), i = null);
849
859
  },
850
860
  getReport: () => Le(o, de, n)
851
861
  };
@@ -895,9 +905,9 @@ function er({
895
905
  onVideoStateChange: r,
896
906
  onAgentActivityStateChange: a,
897
907
  report: c,
898
- log: s
908
+ log: i
899
909
  }) {
900
- 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));
910
+ e === S.Start ? (i("CALLBACK: onVideoStateChange(Start)"), r == null || r(S.Start)) : e === S.Stop && (i("CALLBACK: onVideoStateChange(Stop)"), r == null || r(S.Stop, c)), t === S.Start ? a == null || a(ae.Talking) : t === S.Stop && (a == null || a(ae.Idle));
901
911
  }
902
912
  function je({
903
913
  statsSignal: e,
@@ -905,25 +915,25 @@ function je({
905
915
  onVideoStateChange: r,
906
916
  onAgentActivityStateChange: a,
907
917
  streamType: c,
908
- report: s,
918
+ report: i,
909
919
  log: o
910
920
  }) {
911
- c === W.Legacy ? Zt({ statsSignal: e, dataChannelSignal: t, onVideoStateChange: r, report: s, log: o }) : c === W.Fluent && er({
921
+ c === W.Legacy ? Zt({ statsSignal: e, dataChannelSignal: t, onVideoStateChange: r, report: i, log: o }) : c === W.Fluent && er({
912
922
  statsSignal: e,
913
923
  dataChannelSignal: t,
914
924
  onVideoStateChange: r,
915
925
  onAgentActivityStateChange: a,
916
- report: s,
926
+ report: i,
917
927
  log: o
918
928
  });
919
929
  }
920
- async function tr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le, analytics: o }, n) {
930
+ async function tr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: i = le, analytics: o }, n) {
921
931
  var F;
922
- const i = Jt(r, "WebRTCStreamingManager"), d = Qt(i);
932
+ const s = Jt(r, "WebRTCStreamingManager"), d = Qt(s);
923
933
  let u = !1, f = !1, m = S.Stop, w = S.Stop;
924
- const { startConnection: y, sendStreamRequest: j, close: M, createStream: _, addIceCandidate: L } = Vt(
934
+ const { startConnection: y, sendStreamRequest: j, close: M, createStream: T, addIceCandidate: L } = Vt(
925
935
  c,
926
- s,
936
+ i,
927
937
  e,
928
938
  a.onError
929
939
  ), {
@@ -931,24 +941,24 @@ async function tr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
931
941
  offer: X,
932
942
  ice_servers: H,
933
943
  session_id: V,
934
- fluent: ae,
944
+ fluent: ie,
935
945
  interrupt_enabled: Y
936
- } = await _(t, n);
946
+ } = await T(t, n);
937
947
  (F = a.onStreamCreated) == null || F.call(a, { stream_id: E, session_id: V, agent_id: e });
938
948
  const D = new Yt({ iceServers: H }), O = D.createDataChannel("JanusDataChannel");
939
949
  if (!V)
940
950
  throw new Error("Could not create session_id");
941
- const J = ae ? W.Fluent : W.Legacy;
951
+ const J = ie ? W.Fluent : W.Legacy;
942
952
  o.enrich({
943
953
  "stream-type": J
944
954
  });
945
- const se = t.stream_warmup && !ae, ie = () => u, Z = () => {
955
+ const se = t.stream_warmup && !ie, oe = () => u, ee = () => {
946
956
  var g;
947
- u = !0, f && (i("CALLBACK: onConnectionStateChange(Connected)"), (g = a.onConnectionStateChange) == null || g.call(a, b.Connected));
957
+ u = !0, f && (s("CALLBACK: onConnectionStateChange(Connected)"), (g = a.onConnectionStateChange) == null || g.call(a, b.Connected));
948
958
  }, l = Xt(
949
959
  () => D.getStats(),
950
- ie,
951
- Z,
960
+ oe,
961
+ ee,
952
962
  (g, h) => je({
953
963
  statsSignal: w = g,
954
964
  dataChannelSignal: J === W.Legacy ? m : void 0,
@@ -956,7 +966,7 @@ async function tr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
956
966
  onAgentActivityStateChange: a.onAgentActivityStateChange,
957
967
  report: h,
958
968
  streamType: J,
959
- log: i
969
+ log: s
960
970
  }),
961
971
  (g) => {
962
972
  var h;
@@ -965,7 +975,7 @@ async function tr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
965
975
  );
966
976
  l.start(), D.onicecandidate = (g) => {
967
977
  var h;
968
- i("peerConnection.onicecandidate", g);
978
+ s("peerConnection.onicecandidate", g);
969
979
  try {
970
980
  g.candidate && g.candidate.sdpMid && g.candidate.sdpMLineIndex !== null ? L(
971
981
  E,
@@ -981,7 +991,7 @@ async function tr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
981
991
  (h = a.onError) == null || h.call(a, I, { streamId: E });
982
992
  }
983
993
  }, O.onopen = () => {
984
- f = !0, (!se || u) && Z();
994
+ f = !0, (!se || u) && ee();
985
995
  };
986
996
  let p = null;
987
997
  const v = (g) => {
@@ -999,7 +1009,7 @@ async function tr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
999
1009
  onVideoStateChange: a.onVideoStateChange,
1000
1010
  onAgentActivityStateChange: a.onAgentActivityStateChange,
1001
1011
  streamType: J,
1002
- log: i
1012
+ log: s
1003
1013
  });
1004
1014
  }
1005
1015
  function k(g, h) {
@@ -1018,19 +1028,19 @@ async function tr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
1018
1028
  (B = R[h]) == null || B.call(R, h, I);
1019
1029
  }, D.oniceconnectionstatechange = () => {
1020
1030
  var h;
1021
- i("peerConnection.oniceconnectionstatechange => " + D.iceConnectionState);
1031
+ s("peerConnection.oniceconnectionstatechange => " + D.iceConnectionState);
1022
1032
  const g = Pe(D.iceConnectionState);
1023
1033
  g !== b.Connected && ((h = a.onConnectionStateChange) == null || h.call(a, g));
1024
1034
  }, D.ontrack = (g) => {
1025
1035
  var h;
1026
- i("peerConnection.ontrack", g), i("CALLBACK: onSrcObjectReady"), (h = a.onSrcObjectReady) == null || h.call(a, g.streams[0]);
1027
- }, await D.setRemoteDescription(X), i("set remote description OK");
1036
+ s("peerConnection.ontrack", g), s("CALLBACK: onSrcObjectReady"), (h = a.onSrcObjectReady) == null || h.call(a, g.streams[0]);
1037
+ }, await D.setRemoteDescription(X), s("set remote description OK");
1028
1038
  const P = await D.createAnswer();
1029
- i("create answer OK"), await D.setLocalDescription(P), i("set local description OK"), await y(E, P, V, n), i("start connection OK");
1039
+ s("create answer OK"), await D.setLocalDescription(P), s("set local description OK"), await y(E, P, V, n), s("start connection OK");
1030
1040
  function N(g) {
1031
1041
  var h, I;
1032
1042
  if (!u || O.readyState !== "open") {
1033
- i("Data channel is not ready for sending messages"), (h = a.onError) == null || h.call(a, new Ne("Data channel is not ready for sending messages"), {
1043
+ s("Data channel is not ready for sending messages"), (h = a.onError) == null || h.call(a, new Ne("Data channel is not ready for sending messages"), {
1034
1044
  streamId: E
1035
1045
  });
1036
1046
  return;
@@ -1038,7 +1048,7 @@ async function tr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
1038
1048
  try {
1039
1049
  O.send(g);
1040
1050
  } catch (B) {
1041
- i("Error sending data channel message", B), (I = a.onError) == null || I.call(a, B, { streamId: E });
1051
+ s("Error sending data channel message", B), (I = a.onError) == null || I.call(a, B, { streamId: E });
1042
1052
  }
1043
1053
  }
1044
1054
  return {
@@ -1067,9 +1077,9 @@ async function tr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
1067
1077
  h === b.Connected && await M(E, V).catch((I) => {
1068
1078
  });
1069
1079
  } catch (I) {
1070
- i("Error on close stream connection", I);
1080
+ s("Error on close stream connection", I);
1071
1081
  }
1072
- (g = a.onAgentActivityStateChange) == null || g.call(a, ne.Idle), l.stop();
1082
+ (g = a.onAgentActivityStateChange) == null || g.call(a, ae.Idle), l.stop();
1073
1083
  }
1074
1084
  },
1075
1085
  sendDataChannelMessage: N,
@@ -1105,14 +1115,14 @@ async function rr(e, t, r, a) {
1105
1115
  const c = e.id;
1106
1116
  switch (t.version) {
1107
1117
  case "v1": {
1108
- const { version: s, ...o } = t;
1118
+ const { version: i, ...o } = t;
1109
1119
  return tr(c, o, r, a);
1110
1120
  }
1111
1121
  case "v2": {
1112
- const { version: s, ...o } = t;
1122
+ const { version: i, ...o } = t;
1113
1123
  switch (o.transport.provider) {
1114
1124
  case pe.Livekit:
1115
- const { createLiveKitStreamingManager: n } = await import("./livekit-manager-DXAfWjwR.js");
1125
+ const { createLiveKitStreamingManager: n } = await import("./livekit-manager-CFuAnjAa.js");
1116
1126
  return n(c, o, r);
1117
1127
  default:
1118
1128
  throw new Error(`Unsupported transport provider: ${o.transport.provider}`);
@@ -1130,10 +1140,10 @@ function ar() {
1130
1140
  }
1131
1141
  };
1132
1142
  }
1133
- function sr(e) {
1134
- var c, s;
1143
+ function ir(e) {
1144
+ var c, i;
1135
1145
  const { streamOptions: t } = e ?? {}, r = ((c = e == null ? void 0 : e.mixpanelAdditionalProperties) == null ? void 0 : c.plan) !== void 0 ? {
1136
- plan: (s = e.mixpanelAdditionalProperties) == null ? void 0 : s.plan
1146
+ plan: (i = e.mixpanelAdditionalProperties) == null ? void 0 : i.plan
1137
1147
  } : void 0;
1138
1148
  return { ...{
1139
1149
  output_resolution: t == null ? void 0 : t.outputResolution,
@@ -1143,8 +1153,8 @@ function sr(e) {
1143
1153
  fluent: t == null ? void 0 : t.fluent
1144
1154
  }, ...r && { end_user_data: r } };
1145
1155
  }
1146
- function ir(e, t) {
1147
- return we(e.presenter.type) ? { version: he.V2, ...ar() } : { version: he.V1, ...sr(t) };
1156
+ function sr(e, t) {
1157
+ return we(e.presenter.type) ? { version: he.V2, ...ar() } : { version: he.V1, ...ir(t) };
1148
1158
  }
1149
1159
  function or(e, t, r) {
1150
1160
  r.track("agent-connection-state-change", { state: e, ...t && { reason: t } });
@@ -1213,18 +1223,18 @@ function ur(e, t, r) {
1213
1223
  });
1214
1224
  }
1215
1225
  function $e(e, t, r, a) {
1216
- return q.reset(), be.update(), new Promise(async (c, s) => {
1226
+ return q.reset(), be.update(), new Promise(async (c, i) => {
1217
1227
  try {
1218
1228
  let o, n = !1;
1219
- const i = ir(e, t);
1229
+ const s = sr(e, t);
1220
1230
  r.enrich({
1221
- "stream-version": i.version.toString()
1231
+ "stream-version": s.version.toString()
1222
1232
  });
1223
1233
  let d = null;
1224
1234
  const u = e.presenter.type === "expressive";
1225
1235
  o = await rr(
1226
1236
  e,
1227
- i,
1237
+ s,
1228
1238
  {
1229
1239
  ...t,
1230
1240
  analytics: r,
@@ -1246,7 +1256,7 @@ function $e(e, t, r, a) {
1246
1256
  },
1247
1257
  onAgentActivityStateChange: (f) => {
1248
1258
  var m, w;
1249
- (w = (m = t.callbacks).onAgentActivityStateChange) == null || w.call(m, f), f === ne.Talking ? (ge.update(), d = (y) => {
1259
+ (w = (m = t.callbacks).onAgentActivityStateChange) == null || w.call(m, f), f === ae.Talking ? (ge.update(), d = (y) => {
1250
1260
  Be(
1251
1261
  S.Start,
1252
1262
  e,
@@ -1277,13 +1287,13 @@ function $e(e, t, r, a) {
1277
1287
  a
1278
1288
  ), n && c(o);
1279
1289
  } catch (o) {
1280
- s(o);
1290
+ i(o);
1281
1291
  }
1282
1292
  });
1283
1293
  }
1284
1294
  async function mr(e, t, r, a, c) {
1285
1295
  var u, f, m, w;
1286
- const s = async () => {
1296
+ const i = async () => {
1287
1297
  if (we(e.presenter.type)) {
1288
1298
  const y = await $e(e, t, a), j = `${nr}_${y.sessionId}`, M = (/* @__PURE__ */ new Date()).toISOString();
1289
1299
  return { chatResult: {
@@ -1304,58 +1314,58 @@ async function mr(e, t, r, a, c) {
1304
1314
  const y = new AbortController(), j = y.signal;
1305
1315
  let M;
1306
1316
  try {
1307
- const _ = qe(
1317
+ const T = qe(
1308
1318
  e,
1309
1319
  r,
1310
1320
  a,
1311
1321
  t.mode,
1312
1322
  t.persistentChat,
1313
1323
  c
1314
- ), L = $e(e, t, a, j).then((H) => (M = H, H)), [E, X] = await Promise.all([_, L]);
1324
+ ), L = $e(e, t, a, j).then((H) => (M = H, H)), [E, X] = await Promise.all([T, L]);
1315
1325
  return { chatResult: E, streamingManager: X };
1316
- } catch (_) {
1326
+ } catch (T) {
1317
1327
  throw y.abort(), M && await M.disconnect().catch(() => {
1318
- }), _;
1328
+ }), T;
1319
1329
  }
1320
1330
  }
1321
- }, { chatResult: o, streamingManager: n } = await s(), { chat: i, chatMode: d } = o;
1322
- return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (f = (u = t.callbacks).onModeChange) == null || f.call(u, d), d !== A.Functional) ? ((w = (m = t.callbacks).onError) == null || w.call(m, new et(d)), n == null || n.disconnect(), { chat: i }) : { chat: i, streamingManager: n };
1331
+ }, { chatResult: o, streamingManager: n } = await i(), { chat: s, chatMode: d } = o;
1332
+ return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (f = (u = t.callbacks).onModeChange) == null || f.call(u, d), d !== A.Functional) ? ((w = (m = t.callbacks).onError) == null || w.call(m, new et(d)), n == null || n.disconnect(), { chat: s }) : { chat: s, streamingManager: n };
1323
1333
  }
1324
1334
  async function vr(e, t) {
1325
- var J, se, ie, Z;
1335
+ var J, se, oe, ee;
1326
1336
  let r = !0;
1327
- const a = t.mixpanelKey || wt, c = t.wsURL || pt, s = t.baseURL || le, o = t.mode || A.Functional, n = {
1337
+ const a = t.mixpanelKey || wt, c = t.wsURL || pt, i = t.baseURL || le, o = t.mode || A.Functional, n = {
1328
1338
  messages: [],
1329
1339
  chatMode: o
1330
- }, i = Lt({
1340
+ }, s = Lt({
1331
1341
  token: a,
1332
1342
  agentId: e,
1333
1343
  isEnabled: t.enableAnalitics,
1334
1344
  externalId: t.externalId,
1335
1345
  mixpanelAdditionalProperties: t.mixpanelAdditionalProperties
1336
1346
  }), d = Date.now();
1337
- Te(() => {
1338
- i.track("agent-sdk", { event: "init" }, d);
1347
+ _e(() => {
1348
+ s.track("agent-sdk", { event: "init" }, d);
1339
1349
  });
1340
1350
  const u = t.callbacks.onError;
1341
1351
  t.callbacks.onError = (l, p) => {
1342
- i.track("agent-error", { error: Ae(l) }), u == null || u(l, p);
1352
+ s.track("agent-error", { error: Ae(l) }), u == null || u(l, p);
1343
1353
  };
1344
- const f = Mt(t.auth, s, t.callbacks.onError, t.externalId), m = await f.getById(e);
1354
+ const f = Mt(t.auth, i, t.callbacks.onError, t.externalId), m = await f.getById(e);
1345
1355
  t.debug = t.debug || ((J = m == null ? void 0 : m.advanced_settings) == null ? void 0 : J.ui_debug_mode);
1346
1356
  const w = we(m.presenter.type);
1347
- i.enrich(_t(m));
1348
- const { onMessage: y, clearQueue: j } = Ft(i, n, t, m, () => {
1357
+ s.enrich(Tt(m));
1358
+ const { onMessage: y, clearQueue: j } = Ft(s, n, t, m, () => {
1349
1359
  var l, p, v;
1350
1360
  (l = n.socketManager) == null || l.disconnect(), (v = (p = t.callbacks).onConnectionStateChange) == null || v.call(p, b.Disconnected);
1351
1361
  });
1352
- n.messages = Pt(t.initialMessages), (ie = (se = t.callbacks).onNewMessage) == null || ie.call(se, [...n.messages], "answer");
1362
+ n.messages = Pt(t.initialMessages), (oe = (se = t.callbacks).onNewMessage) == null || oe.call(se, [...n.messages], "answer");
1353
1363
  const M = (l) => {
1354
- }, _ = ({ type: l }) => {
1364
+ }, T = ({ type: l }) => {
1355
1365
  var v, C, k, R;
1356
1366
  if (!((v = n.streamingManager) != null && v.interruptAvailable) || !((C = n.streamingManager) != null && C.isInterruptible)) return;
1357
1367
  const p = n.messages[n.messages.length - 1];
1358
- i.track("agent-video-interrupt", {
1368
+ s.track("agent-video-interrupt", {
1359
1369
  type: l || "click",
1360
1370
  video_duration_to_interrupt: ge.get(!0),
1361
1371
  message_duration_to_interrupt: q.get(!0)
@@ -1388,9 +1398,9 @@ async function vr(e, t) {
1388
1398
  var p, v;
1389
1399
  L.delete(l), (v = (p = n.streamingManager) == null ? void 0 : p.unregisterRpcMethod) == null || v.call(p, l);
1390
1400
  }
1391
- const ae = Date.now();
1392
- Te(() => {
1393
- i.track("agent-sdk", { event: "loaded", ...Et(m) }, ae);
1401
+ const ie = Date.now();
1402
+ _e(() => {
1403
+ s.track("agent-sdk", { event: "loaded", ...Et(m) }, ie);
1394
1404
  });
1395
1405
  async function Y(l) {
1396
1406
  var P, N, F, g, h, I, B;
@@ -1413,7 +1423,7 @@ async function vr(e, t) {
1413
1423
  }
1414
1424
  },
1415
1425
  f,
1416
- i,
1426
+ s,
1417
1427
  n.chat
1418
1428
  ),
1419
1429
  {
@@ -1424,10 +1434,10 @@ async function vr(e, t) {
1424
1434
  delayMs: 1e3
1425
1435
  }
1426
1436
  ).catch((K) => {
1427
- var T, U;
1428
- throw O(A.Maintenance), (U = (T = t.callbacks).onConnectionStateChange) == null || U.call(T, b.Fail), K;
1437
+ var _, U;
1438
+ throw O(A.Maintenance), (U = (_ = t.callbacks).onConnectionStateChange) == null || U.call(_, b.Fail), K;
1429
1439
  }), [C, { streamingManager: k, chat: R }] = await Promise.all([p, v]);
1430
- R && R.id !== ((h = n.chat) == null ? void 0 : h.id) && ((B = (I = t.callbacks).onNewChat) == null || B.call(I, R.id)), n.streamingManager = k, n.socketManager = C, n.chat = R, X(), r = !1, i.enrich({
1440
+ R && R.id !== ((h = n.chat) == null ? void 0 : h.id) && ((B = (I = t.callbacks).onNewChat) == null || B.call(I, R.id)), n.streamingManager = k, n.socketManager = C, n.chat = R, X(), r = !1, s.enrich({
1431
1441
  chatId: R == null ? void 0 : R.id,
1432
1442
  streamId: k == null ? void 0 : k.streamId,
1433
1443
  mode: n.chatMode
@@ -1439,7 +1449,7 @@ async function vr(e, t) {
1439
1449
  }
1440
1450
  async function O(l) {
1441
1451
  var p, v;
1442
- l !== n.chatMode && (i.track("agent-mode-change", { mode: l }), n.chatMode = l, n.chatMode !== A.Functional && await D(), (v = (p = t.callbacks).onModeChange) == null || v.call(p, l));
1452
+ l !== n.chatMode && (s.track("agent-mode-change", { mode: l }), n.chatMode = l, n.chatMode !== A.Functional && await D(), (v = (p = t.callbacks).onModeChange) == null || v.call(p, l));
1443
1453
  }
1444
1454
  return {
1445
1455
  agent: m,
@@ -1451,12 +1461,12 @@ async function vr(e, t) {
1451
1461
  var l;
1452
1462
  return ((l = n.streamingManager) == null ? void 0 : l.interruptAvailable) ?? !1;
1453
1463
  },
1454
- starterMessages: ((Z = m.knowledge) == null ? void 0 : Z.starter_message) || [],
1464
+ starterMessages: ((ee = m.knowledge) == null ? void 0 : ee.starter_message) || [],
1455
1465
  getSTTToken: () => f.getSTTToken(m.id),
1456
1466
  changeMode: O,
1457
- enrichAnalytics: i.enrich,
1467
+ enrichAnalytics: s.enrich,
1458
1468
  async connect() {
1459
- await Y(!0), i.track("agent-chat", {
1469
+ await Y(!0), s.track("agent-chat", {
1460
1470
  event: "connect",
1461
1471
  mode: n.chatMode
1462
1472
  });
@@ -1465,7 +1475,7 @@ async function vr(e, t) {
1465
1475
  const l = n.streamingManager;
1466
1476
  if (w && (l != null && l.reconnect)) {
1467
1477
  try {
1468
- await l.reconnect(), i.track("agent-chat", {
1478
+ await l.reconnect(), s.track("agent-chat", {
1469
1479
  event: "reconnect",
1470
1480
  mode: n.chatMode
1471
1481
  });
@@ -1474,13 +1484,13 @@ async function vr(e, t) {
1474
1484
  }
1475
1485
  return;
1476
1486
  }
1477
- await D(), await Y(!1), i.track("agent-chat", {
1487
+ await D(), await Y(!1), s.track("agent-chat", {
1478
1488
  event: "reconnect",
1479
1489
  mode: n.chatMode
1480
1490
  });
1481
1491
  },
1482
1492
  async disconnect() {
1483
- await D(), i.track("agent-chat", {
1493
+ await D(), s.track("agent-chat", {
1484
1494
  event: "disconnect",
1485
1495
  mode: n.chatMode
1486
1496
  });
@@ -1528,7 +1538,7 @@ async function vr(e, t) {
1528
1538
  const I = await qe(
1529
1539
  m,
1530
1540
  f,
1531
- i,
1541
+ s,
1532
1542
  n.chatMode,
1533
1543
  t.persistentChat
1534
1544
  );
@@ -1540,18 +1550,18 @@ async function vr(e, t) {
1540
1550
  }, C = async (g, h) => {
1541
1551
  const I = n.chatMode === A.Playground;
1542
1552
  return fe(w && !I ? async () => {
1543
- var T, U;
1544
- return await ((U = (T = n.streamingManager) == null ? void 0 : T.sendTextMessage) == null ? void 0 : U.call(T, l)), Promise.resolve({});
1553
+ var _, U;
1554
+ return await ((U = (_ = n.streamingManager) == null ? void 0 : _.sendTextMessage) == null ? void 0 : U.call(_, l)), Promise.resolve({});
1545
1555
  } : async () => {
1546
- var T, U;
1556
+ var _, U;
1547
1557
  return f.chat(
1548
1558
  m.id,
1549
1559
  h,
1550
1560
  {
1551
1561
  chatMode: n.chatMode,
1552
- streamId: (T = n.streamingManager) == null ? void 0 : T.streamId,
1562
+ streamId: (_ = n.streamingManager) == null ? void 0 : _.streamId,
1553
1563
  sessionId: (U = n.streamingManager) == null ? void 0 : U.sessionId,
1554
- messages: g.map(({ matches: Xe, ...oe }) => oe)
1564
+ messages: g.map(({ matches: Xe, ...ce }) => ce)
1555
1565
  },
1556
1566
  {
1557
1567
  ...Oe(n.chatMode),
@@ -1560,10 +1570,10 @@ async function vr(e, t) {
1560
1570
  );
1561
1571
  }, {
1562
1572
  limit: 2,
1563
- shouldRetryFn: (T) => {
1564
- var oe, ye, Ce, Se;
1565
- const U = (oe = T == null ? void 0 : T.message) == null ? void 0 : oe.includes("missing or invalid session_id");
1566
- return !((ye = T == null ? void 0 : T.message) == null ? void 0 : ye.includes("Stream Error")) && !U ? ((Se = (Ce = t.callbacks).onError) == null || Se.call(Ce, T), !1) : !0;
1573
+ shouldRetryFn: (_) => {
1574
+ var ce, ye, Ce, Se;
1575
+ const U = (ce = _ == null ? void 0 : _.message) == null ? void 0 : ce.includes("missing or invalid session_id");
1576
+ return !((ye = _ == null ? void 0 : _.message) == null ? void 0 : ye.includes("Stream Error")) && !U ? ((Se = (Ce = t.callbacks).onError) == null || Se.call(Ce, _), !1) : !0;
1567
1577
  },
1568
1578
  onRetry: async () => {
1569
1579
  await D(), await Y(!1);
@@ -1575,7 +1585,7 @@ async function vr(e, t) {
1575
1585
  id: Q(),
1576
1586
  role: "user",
1577
1587
  content: l,
1578
- parts: re(l),
1588
+ parts: ne(l),
1579
1589
  created_at: new Date(q.update()).toISOString()
1580
1590
  }), (R = (k = t.callbacks).onNewMessage) == null || R.call(k, [...n.messages], "user");
1581
1591
  const g = await v(), h = await C([...n.messages], g);
@@ -1583,19 +1593,19 @@ async function vr(e, t) {
1583
1593
  id: Q(),
1584
1594
  role: "assistant",
1585
1595
  content: h.result,
1586
- parts: re(h.result),
1596
+ parts: ne(h.result),
1587
1597
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1588
1598
  context: h.context,
1589
1599
  matches: h.matches
1590
- }), i.track("agent-message-send", {
1600
+ }), s.track("agent-message-send", {
1591
1601
  event: "success",
1592
1602
  messages: n.messages.length + 1
1593
- }), h.result && ((N = (P = t.callbacks).onNewMessage) == null || N.call(P, [...n.messages], "answer"), i.track("agent-message-received", {
1603
+ }), h.result && ((N = (P = t.callbacks).onNewMessage) == null || N.call(P, [...n.messages], "answer"), s.track("agent-message-received", {
1594
1604
  latency: q.get(!0),
1595
1605
  messages: n.messages.length
1596
1606
  })), h;
1597
1607
  } catch (g) {
1598
- throw ((F = n.messages[n.messages.length - 1]) == null ? void 0 : F.role) === "assistant" && n.messages.pop(), i.track("agent-message-send", {
1608
+ throw ((F = n.messages[n.messages.length - 1]) == null ? void 0 : F.role) === "assistant" && n.messages.pop(), s.track("agent-message-send", {
1599
1609
  event: "error",
1600
1610
  messages: n.messages.length,
1601
1611
  error: Ae(g)
@@ -1610,7 +1620,7 @@ async function vr(e, t) {
1610
1620
  throw new $("Message not found");
1611
1621
  } else throw new $("Chat is not initialized");
1612
1622
  const k = ((R = C.matches) == null ? void 0 : R.map((g) => [g.document_id, g.id])) ?? [];
1613
- return i.track("agent-rate", {
1623
+ return s.track("agent-rate", {
1614
1624
  event: v ? "update" : "create",
1615
1625
  thumb: p === 1 ? "up" : "down",
1616
1626
  knowledge_id: ((P = m.knowledge) == null ? void 0 : P.id) ?? "",
@@ -1631,7 +1641,7 @@ async function vr(e, t) {
1631
1641
  deleteRate(l) {
1632
1642
  if (!n.chat)
1633
1643
  throw new $("Chat is not initialized");
1634
- return i.track("agent-rate-delete", { type: "text" }), f.deleteRating(m.id, n.chat.id, l);
1644
+ return s.track("agent-rate-delete", { type: "text" }), f.deleteRating(m.id, n.chat.id, l);
1635
1645
  },
1636
1646
  async speak(l) {
1637
1647
  var k, R, P;
@@ -1659,11 +1669,11 @@ async function vr(e, t) {
1659
1669
  return l;
1660
1670
  }
1661
1671
  const v = p();
1662
- if (i.track("agent-speak", v), q.update(), n.messages && v.type === "text" && (n.messages.push({
1672
+ if (s.track("agent-speak", v), q.update(), n.messages && v.type === "text" && (n.messages.push({
1663
1673
  id: Q(),
1664
1674
  role: "assistant",
1665
1675
  content: v.input,
1666
- parts: re(v.input),
1676
+ parts: ne(v.input),
1667
1677
  created_at: (/* @__PURE__ */ new Date()).toISOString()
1668
1678
  }), (R = (k = t.callbacks).onNewMessage) == null || R.call(k, [...n.messages], "answer")), Ct(n.chatMode))
1669
1679
  return {
@@ -1678,20 +1688,20 @@ async function vr(e, t) {
1678
1688
  metadata: { chat_id: (P = n.chat) == null ? void 0 : P.id, agent_id: m.id }
1679
1689
  });
1680
1690
  },
1681
- interrupt: _,
1691
+ interrupt: T,
1682
1692
  registerClientTool: H,
1683
1693
  unregisterClientTool: V
1684
1694
  };
1685
1695
  }
1686
1696
  export {
1687
- ne as A,
1697
+ ae as A,
1688
1698
  G as B,
1689
1699
  z as C,
1690
1700
  lt as D,
1691
1701
  ze as H,
1692
1702
  dt as K,
1693
1703
  rt as N,
1694
- st as P,
1704
+ it as P,
1695
1705
  ot as R,
1696
1706
  x as S,
1697
1707
  pe as T,
@@ -1704,11 +1714,11 @@ export {
1704
1714
  le as d,
1705
1715
  Ne as e,
1706
1716
  b as f,
1707
- te as g,
1717
+ re as g,
1708
1718
  Xt as h,
1709
1719
  wr as i,
1710
1720
  S as j,
1711
- it as k,
1721
+ st as k,
1712
1722
  q as l,
1713
1723
  Ze as m,
1714
1724
  pr as n,