@d-id/client-sdk 1.2.5 → 1.2.6

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.
@@ -35,7 +35,7 @@ function dt(e) {
35
35
  } catch {
36
36
  }
37
37
  }
38
- class Oe extends G {
38
+ class Ke extends G {
39
39
  constructor(n, i, c = {}) {
40
40
  const o = dt(i);
41
41
  super(((o == null ? void 0 : o.description) ?? i).slice(0, 256), (o == null ? void 0 : o.kind) ?? "HttpError");
@@ -74,12 +74,12 @@ class lt extends G {
74
74
  };
75
75
  }
76
76
  }
77
- class Ke extends G {
77
+ class We extends G {
78
78
  constructor(t, n) {
79
79
  super(t, "StreamError", n);
80
80
  }
81
81
  }
82
- class $ extends G {
82
+ class B extends G {
83
83
  constructor(t, n) {
84
84
  super(t, "ValidationError"), this.key = n;
85
85
  }
@@ -89,7 +89,7 @@ class ut extends G {
89
89
  super(t, "WSError");
90
90
  }
91
91
  }
92
- var ft = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(ft || {}), mt = /* @__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))(mt || {}), ht = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(ht || {}), gt = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(gt || {}), b = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(b || {}), z = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(z || {}), pt = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(pt || {}), wt = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(wt || {}), yt = /* @__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))(yt || {}), We = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(We || {});
92
+ var ft = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(ft || {}), mt = /* @__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))(mt || {}), ht = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(ht || {}), gt = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(gt || {}), b = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(b || {}), z = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(z || {}), pt = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(pt || {}), wt = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(wt || {}), yt = /* @__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))(yt || {}), He = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(He || {});
93
93
  const An = (e) => {
94
94
  switch (e) {
95
95
  case "clip":
@@ -102,13 +102,13 @@ const An = (e) => {
102
102
  throw new Error(`Unknown video type: ${e}`);
103
103
  }
104
104
  };
105
- 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 || {}), ie = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(ie || {}), 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 || {}), A = /* @__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))(A || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), Se = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(Se || {}), vt = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(vt || {}), Ct = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(Ct || {});
105
+ 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 || {}), ie = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(ie || {}), 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 || {}), A = /* @__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))(A || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), ke = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(ke || {}), vt = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(vt || {}), Ct = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(Ct || {});
106
106
  const xn = (...e) => {
107
- }, He = (e) => new Promise((t) => setTimeout(t, e)), ee = (e = 16) => {
107
+ }, qe = (e) => new Promise((t) => setTimeout(t, e)), ee = (e = 16) => {
108
108
  const t = new Uint8Array(e);
109
109
  return window.crypto.getRandomValues(t), Array.from(t, (n) => n.toString(16).padStart(2, "0")).join("").slice(0, 13);
110
110
  };
111
- function pe(e) {
111
+ function we(e) {
112
112
  if (e !== void 0)
113
113
  return window.localStorage.setItem("did_external_key_id", e), e;
114
114
  let t = window.localStorage.getItem("did_external_key_id");
@@ -118,20 +118,20 @@ function pe(e) {
118
118
  }
119
119
  return t;
120
120
  }
121
- let qe = ee();
121
+ let ue = ee();
122
122
  function St() {
123
- qe = ee();
123
+ ue = ee();
124
124
  }
125
125
  function Xe(e, t) {
126
126
  if (e.type === "bearer")
127
- return `Bearer ${e.token}`;
127
+ return `Bearer ${e.token}~${ue}`;
128
128
  if (e.type === "basic")
129
- return `Basic ${"token" in e ? e.token : btoa(`${e.username}:${e.password}`)}`;
129
+ return `Basic ${"token" in e ? e.token : btoa(`${e.username}:${e.password}`)}~${ue}`;
130
130
  if (e.type === "key")
131
- return `Client-Key ${e.clientKey}.${pe(t)}_${qe}`;
131
+ return `Client-Key ${e.clientKey}.${we(t)}_${ue}`;
132
132
  throw new Error(`Unknown auth type: ${e}`);
133
133
  }
134
- const kt = 45 * 1e3, Mt = "X-Playground-Chat", Ee = 2e3, fe = "https://api.d-id.com", Rt = "wss://notifications.d-id.com", Dt = "79f81a83a67430be2bc0fd61042b8faa", Ge = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type, It = (e) => {
134
+ const kt = 45 * 1e3, Mt = "X-Playground-Chat", Te = 2e3, me = "https://api.d-id.com", Rt = "wss://notifications.d-id.com", Dt = "79f81a83a67430be2bc0fd61042b8faa", Ge = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type, It = (e) => {
135
135
  switch (e.type) {
136
136
  case "expressive":
137
137
  return "v4";
@@ -140,36 +140,36 @@ const kt = 45 * 1e3, Mt = "X-Playground-Chat", Ee = 2e3, fe = "https://api.d-id.
140
140
  case "talk":
141
141
  return "v2";
142
142
  }
143
- }, Et = (e) => e.type === "talk" ? e.source_url : e.presenter_id, ke = (e) => e === We.Expressive, Tt = (e) => [b.TextOnly, b.Playground, b.Maintenance].includes(e), Qe = (e) => e && [b.DirectPlayback, b.Off].includes(e), Te = /\[!\[([^\[\]]*)\]\(([^)\s]+)\)\]\(([^)\s]+)\)/g, _e = /!\[([^\[\]]*)\]\(([^)\s]+)\)/g, _t = [".mp4", ".webm", ".mkv", ".mov", ".m4v", ".ogv"];
143
+ }, Et = (e) => e.type === "talk" ? e.source_url : e.presenter_id, Me = (e) => e === He.Expressive, Tt = (e) => [b.TextOnly, b.Playground, b.Maintenance].includes(e), Qe = (e) => e && [b.DirectPlayback, b.Off].includes(e), _e = /\[!\[([^\[\]]*)\]\(([^)\s]+)\)\]\(([^)\s]+)\)/g, be = /!\[([^\[\]]*)\]\(([^)\s]+)\)/g, _t = [".mp4", ".webm", ".mkv", ".mov", ".m4v", ".ogv"];
144
144
  function bt(e) {
145
145
  const t = e.split("?")[0].split("#")[0].toLowerCase();
146
146
  return _t.some((n) => t.endsWith(n));
147
147
  }
148
- const be = new RegExp("(?<!!)\\[([^\\[\\]]+)\\]\\(([^)\\s]+)\\)", "g"), Ae = /<a\s+href="([^"]*)"[^>]*?>([^<]*)<\/a>/gi;
148
+ const Ae = new RegExp("(?<!!)\\[([^\\[\\]]+)\\]\\(([^)\\s]+)\\)", "g"), xe = /<a\s+href="([^"]*)"[^>]*?>([^<]*)<\/a>/gi;
149
149
  function At(e) {
150
150
  if (e.length === 0)
151
151
  return [];
152
152
  const t = [];
153
153
  let n;
154
- for (Te.lastIndex = 0; (n = Te.exec(e)) !== null; )
154
+ for (_e.lastIndex = 0; (n = _e.exec(e)) !== null; )
155
155
  t.push({
156
156
  index: n.index,
157
157
  length: n[0].length,
158
158
  part: { type: "video", src: n[3], alt: n[1], thumbnail: n[2] }
159
159
  });
160
- for (_e.lastIndex = 0; (n = _e.exec(e)) !== null; )
160
+ for (be.lastIndex = 0; (n = be.exec(e)) !== null; )
161
161
  if (!t.some((s) => n.index >= s.index && n.index < s.index + s.length)) {
162
162
  const s = n[2], r = n[1];
163
163
  let a;
164
164
  bt(s) ? a = { type: "video", src: s, alt: r } : (a = { type: "image", src: s, alt: r }, s.toLowerCase().endsWith(".gif") && (a.mimeType = "image/gif")), t.push({ index: n.index, length: n[0].length, part: a });
165
165
  }
166
- for (be.lastIndex = 0; (n = be.exec(e)) !== null; )
166
+ for (Ae.lastIndex = 0; (n = Ae.exec(e)) !== null; )
167
167
  t.some((s) => n.index >= s.index && n.index < s.index + s.length) || t.push({
168
168
  index: n.index,
169
169
  length: n[0].length,
170
170
  part: { type: "link", href: n[2], label: n[1] }
171
171
  });
172
- for (Ae.lastIndex = 0; (n = Ae.exec(e)) !== null; )
172
+ for (xe.lastIndex = 0; (n = xe.exec(e)) !== null; )
173
173
  t.some((s) => n.index >= s.index && n.index < s.index + s.length) || t.push({
174
174
  index: n.index,
175
175
  length: n[0].length,
@@ -184,9 +184,9 @@ function At(e) {
184
184
  o.index > c && i.push({ type: "text", text: e.slice(c, o.index) }), i.push(o.part), c = o.index + o.length;
185
185
  return c < e.length && i.push({ type: "text", text: e.slice(c) }), i;
186
186
  }
187
- let xe = "", me = [];
187
+ let Pe = "", he = [];
188
188
  function ae(e) {
189
- return e === xe || (xe = e, me = At(e)), me;
189
+ return e === Pe || (Pe = e, he = At(e)), he;
190
190
  }
191
191
  function xt(e, t) {
192
192
  let n;
@@ -197,7 +197,7 @@ function xt(e, t) {
197
197
  clear: () => clearTimeout(n)
198
198
  };
199
199
  }
200
- async function we(e, t) {
200
+ async function ye(e, t) {
201
201
  const n = {
202
202
  limit: (t == null ? void 0 : t.limit) ?? 3,
203
203
  delayMs: (t == null ? void 0 : t.delayMs) ?? 0,
@@ -217,17 +217,17 @@ async function we(e, t) {
217
217
  } catch (o) {
218
218
  if (i = o, !n.shouldRetryFn(o) || c >= n.limit)
219
219
  throw o;
220
- await He(n.delayMs), n.onRetry(o);
220
+ await qe(n.delayMs), n.onRetry(o);
221
221
  }
222
222
  throw i;
223
223
  }
224
- const Pt = (e) => we(e, {
224
+ const Pt = (e) => ye(e, {
225
225
  limit: 3,
226
226
  delayMs: 1e3,
227
227
  timeout: 0,
228
228
  shouldRetryFn: (t) => t.status === 429
229
229
  });
230
- function Ye(e, t = fe, n, i) {
230
+ function Ye(e, t = me, n, i) {
231
231
  const c = async (o, s) => {
232
232
  const { skipErrorHandler: r, ...a } = s || {}, d = a.method ?? "GET", m = performance.now();
233
233
  let u;
@@ -255,7 +255,7 @@ function Ye(e, t = fe, n, i) {
255
255
  throw r || n == null || n(v, { url: o, options: a }), v;
256
256
  }
257
257
  if (!u.ok) {
258
- const f = await u.text().catch(() => `Failed to fetch with status ${u.status}`), w = new Oe(u.status, f, { url: o, method: d });
258
+ const f = await u.text().catch(() => `Failed to fetch with status ${u.status}`), w = new Ke(u.status, f, { url: o, method: d });
259
259
  throw r || n == null || n(w, { url: o, options: a, headers: u.headers }), w;
260
260
  }
261
261
  return u.json();
@@ -275,7 +275,7 @@ function Ye(e, t = fe, n, i) {
275
275
  }
276
276
  };
277
277
  }
278
- function Lt(e, t = fe, n, i) {
278
+ function Lt(e, t = me, n, i) {
279
279
  const c = Ye(e, `${t}/agents`, n, i);
280
280
  return {
281
281
  create(o, s) {
@@ -331,7 +331,7 @@ function jt(e) {
331
331
  }
332
332
  };
333
333
  }
334
- function Bt(e) {
334
+ function $t(e) {
335
335
  var n, i, c, o, s, r;
336
336
  const t = (n = e.llm) == null ? void 0 : n.prompt_customization;
337
337
  return {
@@ -356,13 +356,13 @@ function Bt(e) {
356
356
  ...e.access === "public" ? { from: "agent-template" } : {}
357
357
  };
358
358
  }
359
- const $t = (e) => {
359
+ const Bt = (e) => {
360
360
  try {
361
361
  return String((e == null ? void 0 : e.message) ?? e ?? "").slice(0, 256);
362
362
  } catch {
363
363
  return "Unknown error";
364
364
  }
365
- }, zt = (e) => e.reduce((t, n) => t + n, 0), Pe = (e) => zt(e) / e.length, Le = (e) => Math.min(...e), je = (e) => Math.max(...e), le = (e, t = 0) => {
365
+ }, zt = (e) => e.reduce((t, n) => t + n, 0), Le = (e) => zt(e) / e.length, je = (e) => Math.min(...e), $e = (e) => Math.max(...e), le = (e, t = 0) => {
366
366
  const n = 10 ** t;
367
367
  return Math.round(e * n) / n;
368
368
  }, Nt = (e, t) => {
@@ -389,11 +389,11 @@ function Ut(e, t, n) {
389
389
  function Be(e) {
390
390
  "requestIdleCallback" in window ? requestIdleCallback(e, { timeout: 2e3 }) : setTimeout(e, 0);
391
391
  }
392
- function he(e) {
393
- return e instanceof G ? e.toJson() : { kind: "UnknownError", message: $t(e) || "UnknownError" };
392
+ function ge(e) {
393
+ return e instanceof G ? e.toJson() : { kind: "UnknownError", message: Bt(e) || "UnknownError" };
394
394
  }
395
- const Jt = "1.2.5", Ot = "https://api-js.mixpanel.com/track/?verbose=1&ip=1", Ze = 50, Z = [];
396
- let ge = !1;
395
+ const Jt = "1.2.6", Ot = "https://api-js.mixpanel.com/track/?verbose=1&ip=1", Ze = 50, Z = [];
396
+ let pe = !1;
397
397
  async function et(e) {
398
398
  const t = await fetch(Ot, {
399
399
  method: "POST",
@@ -406,28 +406,28 @@ async function et(e) {
406
406
  function Kt(e) {
407
407
  Z.push(e), Z.splice(Ze);
408
408
  }
409
- function ye() {
410
- if (ge || !Z.length)
409
+ function ve() {
410
+ if (pe || !Z.length)
411
411
  return;
412
- ge = !0;
412
+ pe = !0;
413
413
  const e = Z.splice(0, Z.length);
414
414
  et(e).catch(() => {
415
415
  Z.unshift(...e), Z.splice(Ze);
416
416
  }).finally(() => {
417
- ge = !1;
417
+ pe = !1;
418
418
  });
419
419
  }
420
- typeof window < "u" && typeof window.addEventListener == "function" && (window.addEventListener("online", ye), typeof document < "u" && document.addEventListener("visibilitychange", () => {
421
- document.visibilityState === "visible" && ye();
420
+ typeof window < "u" && typeof window.addEventListener == "function" && (window.addEventListener("online", ve), typeof document < "u" && document.addEventListener("visibilitychange", () => {
421
+ document.visibilityState === "visible" && ve();
422
422
  }));
423
423
  function Wt(e) {
424
424
  const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk", n = {};
425
425
  return {
426
426
  token: e.token || "testKey",
427
- distinct_id: pe(e.externalId),
427
+ distinct_id: we(e.externalId),
428
428
  agentId: e.agentId,
429
429
  additionalProperties: {
430
- id: pe(e.externalId),
430
+ id: we(e.externalId),
431
431
  ...e.mixpanelAdditionalProperties || {}
432
432
  },
433
433
  isEnabled: e.isEnabled ?? !0,
@@ -456,7 +456,7 @@ function Wt(e) {
456
456
  "User Agent": navigator.userAgent
457
457
  }
458
458
  };
459
- return ye(), et([d]).catch(() => Kt(d)), Promise.resolve();
459
+ return ve(), et([d]).catch(() => Kt(d)), Promise.resolve();
460
460
  },
461
461
  linkTrack(i, c, o, s) {
462
462
  n[i] || (n[i] = { events: {}, resolvedDependencies: [] }), s.includes(o) || s.push(o);
@@ -474,7 +474,7 @@ function Wt(e) {
474
474
  }
475
475
  };
476
476
  }
477
- function Me() {
477
+ function Re() {
478
478
  let e = 0;
479
479
  return {
480
480
  reset: () => e = 0,
@@ -482,7 +482,7 @@ function Me() {
482
482
  get: (t = !1) => t ? Date.now() - e : e
483
483
  };
484
484
  }
485
- const X = Me(), ve = Me(), $e = Me();
485
+ const X = Re(), Ce = Re(), ze = Re();
486
486
  function tt(e) {
487
487
  return e === b.Playground ? { headers: { [Mt]: "true" } } : {};
488
488
  }
@@ -515,7 +515,7 @@ async function Xt(e) {
515
515
  } catch (c) {
516
516
  if (i === t)
517
517
  throw c;
518
- await He(i * 500);
518
+ await qe(i * 500);
519
519
  }
520
520
  return n;
521
521
  }
@@ -541,7 +541,7 @@ async function Gt(e, t, n, i) {
541
541
  subscribeToEvents: (s) => c.push(s)
542
542
  };
543
543
  }
544
- function ze(e) {
544
+ function Ne(e) {
545
545
  if (e.answer !== void 0)
546
546
  return e.answer;
547
547
  let t = 0, n = "";
@@ -590,10 +590,10 @@ function Yt(e, t, n, i, c, o, s) {
590
590
  if (e === z.Partial)
591
591
  n[f] = u;
592
592
  else {
593
- const v = ze(n);
593
+ const v = Ne(n);
594
594
  !!(u && u.length < v.length) && (m.interrupted = !0), n.answer = u;
595
595
  }
596
- const w = ze(n);
596
+ const w = Ne(n);
597
597
  (m.content !== w || e === z.Answer) && (m.content = w, m.parts = ae(w), c == null || c([...i.messages], e));
598
598
  }
599
599
  function Zt(e, t, n, i, c) {
@@ -638,7 +638,7 @@ function Zt(e, t, n, i, c) {
638
638
  const T = d.split("/")[1];
639
639
  j.includes(d) ? e.track("agent-video", { ...I, event: T }) : e.linkTrack("agent-video", { ...I, event: T }, d, ["done"]);
640
640
  }
641
- j.includes(d) && ((f = (u = n.callbacks).onError) == null || f.call(u, new Ke(`Stream failed with event ${d}`), { data: m })), m.event === w.StreamDone && c();
641
+ j.includes(d) && ((f = (u = n.callbacks).onError) == null || f.call(u, new We(`Stream failed with event ${d}`), { data: m })), m.event === w.StreamDone && c();
642
642
  }
643
643
  }
644
644
  };
@@ -768,7 +768,7 @@ function on(e) {
768
768
  localTs: s.timestamp
769
769
  }), r;
770
770
  }
771
- function Ne(e, t, n) {
771
+ function Fe(e, t, n) {
772
772
  const i = e.map((a, d) => d === 0 ? n ? {
773
773
  timestamp: a.timestamp,
774
774
  duration: 0,
@@ -825,13 +825,13 @@ function Ne(e, t, n) {
825
825
  webRTCStats: {
826
826
  anomalies: c,
827
827
  avSync: Vt(() => rn(e), null),
828
- minRtt: Le(r),
829
- avgRtt: Pe(r),
830
- maxRtt: je(r),
828
+ minRtt: je(r),
829
+ avgRtt: Le(r),
830
+ maxRtt: $e(r),
831
831
  aggregateReport: an(e[0], e[e.length - 1], o),
832
- minJitterDelayInInterval: Le(s),
833
- maxJitterDelayInInterval: je(s),
834
- avgJitterDelayInInterval: Pe(s)
832
+ minJitterDelayInInterval: je(s),
833
+ maxJitterDelayInInterval: $e(s),
834
+ avgJitterDelayInInterval: Le(s)
835
835
  },
836
836
  codec: e[0].codec,
837
837
  resolution: `${e[0].frameWidth}x${e[0].frameHeight}`
@@ -883,7 +883,7 @@ function Pn(e, t) {
883
883
  }
884
884
  };
885
885
  }
886
- const ue = 100, cn = Math.max(Math.ceil(400 / ue), 1), dn = 0.25, ln = 0.28;
886
+ const fe = 100, cn = Math.max(Math.ceil(400 / fe), 1), dn = 0.25, ln = 0.28;
887
887
  function un() {
888
888
  let e = 0, t, n, i = 0;
889
889
  return (c) => {
@@ -911,22 +911,22 @@ function fn(e, t, n, i, c) {
911
911
  if (T)
912
912
  a = 0, f = E - w, u = P < dn ? re.Strong : P > ln && f > 1 ? re.Weak : m, u !== m && (c == null || c(u), m = u, w += f, f = 0), d || (i == null || i(S.Start), r = s[s.length - 1], s = [], d = !0), s.push(Q);
913
913
  else if (d && (a++, a >= cn)) {
914
- const H = Ne(s, ue, r);
914
+ const H = Fe(s, fe, r);
915
915
  i == null || i(S.Stop, H), t() || n(), w = E, d = !1;
916
916
  }
917
917
  }
918
918
  return {
919
919
  start: () => {
920
- o || (o = setInterval(j, ue));
920
+ o || (o = setInterval(j, fe));
921
921
  },
922
922
  stop: () => {
923
923
  o && (clearInterval(o), o = null);
924
924
  },
925
- getReport: () => Ne(s, ue, r)
925
+ getReport: () => Fe(s, fe, r)
926
926
  };
927
927
  }
928
928
  const mn = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
929
- function Fe(e) {
929
+ function Ve(e) {
930
930
  switch (e) {
931
931
  case "connected":
932
932
  return A.Connected;
@@ -974,7 +974,7 @@ function pn({
974
974
  }) {
975
975
  e === S.Start ? (o("CALLBACK: onVideoStateChange(Start)"), n == null || n(S.Start)) : e === S.Stop && (o("CALLBACK: onVideoStateChange(Stop)"), n == null || n(S.Stop, c)), t === S.Start ? i == null || i(ie.Talking) : t === S.Stop && (i == null || i(ie.Idle));
976
976
  }
977
- function Ve({
977
+ function Ue({
978
978
  statsSignal: e,
979
979
  dataChannelSignal: t,
980
980
  onVideoStateChange: n,
@@ -992,7 +992,7 @@ function Ve({
992
992
  log: s
993
993
  });
994
994
  }
995
- async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = fe, analytics: s }, r) {
995
+ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = me, analytics: s }, r) {
996
996
  var F;
997
997
  const a = tn(n, "WebRTCStreamingManager"), d = hn(a);
998
998
  let m = !1, u = !1, f = S.Stop, w = S.Stop;
@@ -1024,7 +1024,7 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = fe,
1024
1024
  () => R.getStats(),
1025
1025
  ce,
1026
1026
  te,
1027
- (h, g) => Ve({
1027
+ (h, g) => Ue({
1028
1028
  statsSignal: w = h,
1029
1029
  dataChannelSignal: U === W.Legacy ? f : void 0,
1030
1030
  onVideoStateChange: i.onVideoStateChange,
@@ -1068,7 +1068,7 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = fe,
1068
1068
  const D = g.metadata;
1069
1069
  y(D.videoId);
1070
1070
  }
1071
- h === x.StreamDone && y(null), f = h === x.StreamStarted ? S.Start : S.Stop, Ve({
1071
+ h === x.StreamDone && y(null), f = h === x.StreamStarted ? S.Start : S.Stop, Ue({
1072
1072
  statsSignal: U === W.Legacy ? w : void 0,
1073
1073
  dataChannelSignal: f,
1074
1074
  onVideoStateChange: i.onVideoStateChange,
@@ -1078,9 +1078,9 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = fe,
1078
1078
  });
1079
1079
  }
1080
1080
  function k(h, g) {
1081
- var B;
1081
+ var $;
1082
1082
  const D = typeof g == "string" ? g : g == null ? void 0 : g.metadata;
1083
- D && s.enrich({ streamMetadata: D }), (B = i.onStreamReady) == null || B.call(i);
1083
+ D && s.enrich({ streamMetadata: D }), ($ = i.onStreamReady) == null || $.call(i);
1084
1084
  }
1085
1085
  const M = {
1086
1086
  [x.StreamStarted]: C,
@@ -1088,13 +1088,13 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = fe,
1088
1088
  [x.StreamReady]: k
1089
1089
  };
1090
1090
  q.onmessage = (h) => {
1091
- var B;
1091
+ var $;
1092
1092
  const { subject: g, data: D } = d(h.data);
1093
- (B = M[g]) == null || B.call(M, g, D);
1093
+ ($ = M[g]) == null || $.call(M, g, D);
1094
1094
  }, R.oniceconnectionstatechange = () => {
1095
1095
  var g;
1096
1096
  a("peerConnection.oniceconnectionstatechange => " + R.iceConnectionState);
1097
- const h = Fe(R.iceConnectionState);
1097
+ const h = Ve(R.iceConnectionState);
1098
1098
  h !== A.Connected && ((g = i.onConnectionStateChange) == null || g.call(i, h, `webrtc:ice-${R.iceConnectionState}`));
1099
1099
  }, R.ontrack = (h) => {
1100
1100
  var g;
@@ -1105,15 +1105,15 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = fe,
1105
1105
  function N(h) {
1106
1106
  var g, D;
1107
1107
  if (!m || q.readyState !== "open") {
1108
- a("Data channel is not ready for sending messages"), (g = i.onError) == null || g.call(i, new Ke("Data channel is not ready for sending messages"), {
1108
+ a("Data channel is not ready for sending messages"), (g = i.onError) == null || g.call(i, new We("Data channel is not ready for sending messages"), {
1109
1109
  streamId: E
1110
1110
  });
1111
1111
  return;
1112
1112
  }
1113
1113
  try {
1114
1114
  q.send(h);
1115
- } catch (B) {
1116
- a("Error sending data channel message", B), (D = i.onError) == null || D.call(i, B, { streamId: E });
1115
+ } catch ($) {
1116
+ a("Error sending data channel message", $), (D = i.onError) == null || D.call(i, $, { streamId: E });
1117
1117
  }
1118
1118
  }
1119
1119
  return {
@@ -1130,7 +1130,7 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = fe,
1130
1130
  async disconnect() {
1131
1131
  var h;
1132
1132
  if (E) {
1133
- const g = Fe(R.iceConnectionState);
1133
+ const g = Ve(R.iceConnectionState);
1134
1134
  if (R) {
1135
1135
  if (g === A.New) {
1136
1136
  l.stop();
@@ -1175,7 +1175,7 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = fe,
1175
1175
  }
1176
1176
  };
1177
1177
  }
1178
- var Ce = /* @__PURE__ */ ((e) => (e.V1 = "v1", e.V2 = "v2", e))(Ce || {});
1178
+ var Se = /* @__PURE__ */ ((e) => (e.V1 = "v1", e.V2 = "v2", e))(Se || {});
1179
1179
  async function yn(e, t, n, i) {
1180
1180
  const c = e.id;
1181
1181
  switch (t.version) {
@@ -1186,8 +1186,8 @@ async function yn(e, t, n, i) {
1186
1186
  case "v2": {
1187
1187
  const { version: o, ...s } = t;
1188
1188
  switch (s.transport.provider) {
1189
- case Se.Livekit:
1190
- const { createLiveKitStreamingManager: r } = await import("./livekit-manager-BLc5LMRQ.js");
1189
+ case ke.Livekit:
1190
+ const { createLiveKitStreamingManager: r } = await import("./livekit-manager-ni7hYg9q.js");
1191
1191
  return r(c, s, n);
1192
1192
  default:
1193
1193
  throw new Error(`Unsupported transport provider: ${s.transport.provider}`);
@@ -1201,7 +1201,7 @@ const vn = "cht";
1201
1201
  function Cn() {
1202
1202
  return {
1203
1203
  transport: {
1204
- provider: Se.Livekit
1204
+ provider: ke.Livekit
1205
1205
  }
1206
1206
  };
1207
1207
  }
@@ -1219,7 +1219,7 @@ function Sn(e) {
1219
1219
  }, ...n && { end_user_data: n } };
1220
1220
  }
1221
1221
  function kn(e, t) {
1222
- return ke(e.presenter.type) ? { version: Ce.V2, ...Cn() } : { version: Ce.V1, ...Sn(t) };
1222
+ return Me(e.presenter.type) ? { version: Se.V2, ...Cn() } : { version: Se.V1, ...Sn(t) };
1223
1223
  }
1224
1224
  function Mn(e, t, n) {
1225
1225
  n.track("agent-connection-state-change", { state: e, ...t && { reason: t } });
@@ -1236,7 +1236,7 @@ function Dn(e, t, n, i, c) {
1236
1236
  ...n
1237
1237
  });
1238
1238
  }
1239
- function Ue(e, t, n, i, c) {
1239
+ function Je(e, t, n, i, c) {
1240
1240
  e === S.Start ? n.linkTrack("agent-video", { event: "start", ...c, "stream-type": i }, "start", [
1241
1241
  x.StreamVideoCreated
1242
1242
  ]) : e === S.Stop && n.linkTrack(
@@ -1287,8 +1287,8 @@ function En(e, t, n) {
1287
1287
  extra_keys: c.extra ? Object.keys(c.extra).length : 0
1288
1288
  });
1289
1289
  }
1290
- function Je(e, t, n, i) {
1291
- return X.reset(), $e.update(), new Promise(async (c, o) => {
1290
+ function Oe(e, t, n, i) {
1291
+ return X.reset(), ze.update(), new Promise(async (c, o) => {
1292
1292
  try {
1293
1293
  let s, r = !1;
1294
1294
  const a = kn(e, t);
@@ -1321,15 +1321,15 @@ function Je(e, t, n, i) {
1321
1321
  },
1322
1322
  onAgentActivityStateChange: (u) => {
1323
1323
  var f, w;
1324
- (w = (f = t.callbacks).onAgentActivityStateChange) == null || w.call(f, u), u === ie.Talking ? (ve.update(), d = (v) => {
1325
- Ue(
1324
+ (w = (f = t.callbacks).onAgentActivityStateChange) == null || w.call(f, u), u === ie.Talking ? (Ce.update(), d = (v) => {
1325
+ Je(
1326
1326
  S.Start,
1327
1327
  e,
1328
1328
  n,
1329
1329
  s.streamType,
1330
1330
  v
1331
1331
  ), d = null;
1332
- }, m || d({ latency: X.get(!0) })) : (ve.reset(), d = null, Ue(
1332
+ }, m || d({ latency: X.get(!0) })) : (Ce.reset(), d = null, Je(
1333
1333
  S.Stop,
1334
1334
  e,
1335
1335
  n,
@@ -1340,7 +1340,7 @@ function Je(e, t, n, i) {
1340
1340
  d == null || d(u);
1341
1341
  },
1342
1342
  onStreamReady: () => {
1343
- const u = $e.get(!0);
1343
+ const u = ze.get(!0);
1344
1344
  n.track("agent-chat", { event: "ready", latency: u });
1345
1345
  },
1346
1346
  onToolEvent: ((u, f) => {
@@ -1359,8 +1359,8 @@ function Je(e, t, n, i) {
1359
1359
  async function Tn(e, t, n, i, c) {
1360
1360
  var m, u, f, w;
1361
1361
  const o = async () => {
1362
- if (ke(e.presenter.type)) {
1363
- const v = await Je(e, t, i), j = `${vn}_${v.sessionId}`, I = (/* @__PURE__ */ new Date()).toISOString();
1362
+ if (Me(e.presenter.type)) {
1363
+ const v = await Oe(e, t, i), j = `${vn}_${v.sessionId}`, I = (/* @__PURE__ */ new Date()).toISOString();
1364
1364
  return { chatResult: {
1365
1365
  chatMode: b.Functional,
1366
1366
  chat: {
@@ -1386,7 +1386,7 @@ async function Tn(e, t, n, i, c) {
1386
1386
  t.mode,
1387
1387
  t.persistentChat,
1388
1388
  c
1389
- ), P = Je(e, t, i, j).then((H) => (I = H, H)), [E, Q] = await Promise.all([T, P]);
1389
+ ), P = Oe(e, t, i, j).then((H) => (I = H, H)), [E, Q] = await Promise.all([T, P]);
1390
1390
  return { chatResult: E, streamingManager: Q };
1391
1391
  } catch (T) {
1392
1392
  throw v.abort(), I && await I.disconnect().catch(() => {
@@ -1399,7 +1399,7 @@ async function Tn(e, t, n, i, c) {
1399
1399
  async function Ln(e, t) {
1400
1400
  var U, oe, ce, te;
1401
1401
  let n = !0;
1402
- const i = t.mixpanelKey || Dt, c = t.wsURL || Rt, o = t.baseURL || fe, s = t.mode || b.Functional, r = {
1402
+ const i = t.mixpanelKey || Dt, c = t.wsURL || Rt, o = t.baseURL || me, s = t.mode || b.Functional, r = {
1403
1403
  messages: [],
1404
1404
  chatMode: s
1405
1405
  }, a = Wt({
@@ -1414,12 +1414,12 @@ async function Ln(e, t) {
1414
1414
  });
1415
1415
  const m = t.callbacks.onError;
1416
1416
  t.callbacks.onError = (l, p) => {
1417
- a.track("agent-error", { error: he(l) }), m == null || m(l, p);
1417
+ a.track("agent-error", { error: ge(l) }), m == null || m(l, p);
1418
1418
  };
1419
1419
  const u = Lt(t.auth, o, t.callbacks.onError, t.externalId), f = await u.getById(e);
1420
1420
  t.debug = t.debug || ((U = f == null ? void 0 : f.advanced_settings) == null ? void 0 : U.ui_debug_mode);
1421
- const w = ke(f.presenter.type);
1422
- a.enrich(Bt(f));
1421
+ const w = Me(f.presenter.type);
1422
+ a.enrich($t(f));
1423
1423
  const { onMessage: v, clearQueue: j } = Zt(a, r, t, f, () => {
1424
1424
  var l, p, y;
1425
1425
  (l = r.socketManager) == null || l.disconnect(), (y = (p = t.callbacks).onConnectionStateChange) == null || y.call(p, A.Disconnected);
@@ -1433,7 +1433,7 @@ async function Ln(e, t) {
1433
1433
  const p = r.messages[r.messages.length - 1];
1434
1434
  a.track("agent-video-interrupt", {
1435
1435
  type: l || "click",
1436
- video_duration_to_interrupt: ve.get(!0),
1436
+ video_duration_to_interrupt: Ce.get(!0),
1437
1437
  message_duration_to_interrupt: X.get(!0)
1438
1438
  }), p.interrupted = !0, (M = (k = t.callbacks).onNewMessage) == null || M.call(k, [...r.messages], "answer"), r.streamingManager.interrupt(l);
1439
1439
  }, P = /* @__PURE__ */ new Map();
@@ -1469,14 +1469,14 @@ async function Ln(e, t) {
1469
1469
  a.track("agent-sdk", { event: "loaded", ...jt(f) }, se);
1470
1470
  });
1471
1471
  async function Y(l) {
1472
- var L, N, F, h, g, D, B;
1472
+ var L, N, F, h, g, D, $;
1473
1473
  St(), (N = (L = t.callbacks).onConnectionStateChange) == null || N.call(L, A.Connecting), X.reset(), l && !n && (delete r.chat, (h = (F = t.callbacks).onNewMessage) == null || h.call(F, [...r.messages], "answer"));
1474
1474
  const p = s === b.DirectPlayback || w ? Promise.resolve(void 0) : Gt(
1475
1475
  t.auth,
1476
1476
  c,
1477
1477
  { onMessage: v, onError: t.callbacks.onError },
1478
1478
  t.externalId
1479
- ), y = we(
1479
+ ), y = ye(
1480
1480
  () => Tn(
1481
1481
  f,
1482
1482
  {
@@ -1496,14 +1496,14 @@ async function Ln(e, t) {
1496
1496
  limit: 3,
1497
1497
  timeout: kt,
1498
1498
  timeoutErrorMessage: "Timeout initializing the stream",
1499
- shouldRetryFn: (O) => (O == null ? void 0 : O.message) !== "Could not connect" && !(O instanceof Oe && (O.status === 429 || O.kind === "InsufficientCreditsError")),
1499
+ shouldRetryFn: (O) => (O == null ? void 0 : O.message) !== "Could not connect" && !(O instanceof Ke && (O.status === 429 || O.kind === "InsufficientCreditsError")),
1500
1500
  delayMs: 1e3
1501
1501
  }
1502
1502
  ).catch((O) => {
1503
1503
  var _, J;
1504
1504
  throw q(b.Maintenance), (J = (_ = t.callbacks).onConnectionStateChange) == null || J.call(_, A.Fail), O;
1505
1505
  }), [C, { streamingManager: k, chat: M }] = await Promise.all([p, y]);
1506
- M && M.id !== ((g = r.chat) == null ? void 0 : g.id) && ((B = (D = t.callbacks).onNewChat) == null || B.call(D, M.id)), r.streamingManager = k, r.socketManager = C, r.chat = M, Q(), n = !1, a.enrich({
1506
+ M && M.id !== ((g = r.chat) == null ? void 0 : g.id) && (($ = (D = t.callbacks).onNewChat) == null || $.call(D, M.id)), r.streamingManager = k, r.socketManager = C, r.chat = M, Q(), n = !1, a.enrich({
1507
1507
  chatId: M == null ? void 0 : M.id,
1508
1508
  streamId: k == null ? void 0 : k.streamId,
1509
1509
  mode: r.chatMode
@@ -1544,7 +1544,7 @@ async function Ln(e, t) {
1544
1544
  try {
1545
1545
  await l.reconnect();
1546
1546
  } catch (y) {
1547
- p = he(y).kind, await R(), await Y(!1);
1547
+ p = ge(y).kind, await R(), await Y(!1);
1548
1548
  }
1549
1549
  else
1550
1550
  await R(), await Y(!1);
@@ -1585,18 +1585,18 @@ async function Ln(e, t) {
1585
1585
  var k, M, L, N, F;
1586
1586
  const p = () => {
1587
1587
  if (Qe(s))
1588
- throw new $(`${s} is enabled, chat is disabled`);
1589
- if (l.length >= Ee)
1590
- throw new $(`Message cannot be more than ${Ee} characters`);
1588
+ throw new B(`${s} is enabled, chat is disabled`);
1589
+ if (l.length >= Te)
1590
+ throw new B(`Message cannot be more than ${Te} characters`);
1591
1591
  if (l.length === 0)
1592
- throw new $("Message cannot be empty");
1592
+ throw new B("Message cannot be empty");
1593
1593
  if (r.chatMode === b.Maintenance)
1594
- throw new $("Chat is in maintenance mode");
1594
+ throw new B("Chat is in maintenance mode");
1595
1595
  if (![b.TextOnly, b.Playground].includes(r.chatMode)) {
1596
1596
  if (!r.streamingManager)
1597
- throw new $("Streaming manager is not initialized");
1597
+ throw new B("Streaming manager is not initialized");
1598
1598
  if (!r.chat)
1599
- throw new $("Chat is not initialized");
1599
+ throw new B("Chat is not initialized");
1600
1600
  }
1601
1601
  }, y = async () => {
1602
1602
  var h, g;
@@ -1615,7 +1615,7 @@ async function Ln(e, t) {
1615
1615
  return r.chat.id;
1616
1616
  }, C = async (h, g) => {
1617
1617
  const D = r.chatMode === b.Playground;
1618
- return we(w && !D ? async () => {
1618
+ return ye(w && !D ? async () => {
1619
1619
  var _, J;
1620
1620
  return await ((J = (_ = r.streamingManager) == null ? void 0 : _.sendTextMessage) == null ? void 0 : J.call(_, l)), Promise.resolve({});
1621
1621
  } : async () => {
@@ -1637,9 +1637,9 @@ async function Ln(e, t) {
1637
1637
  }, {
1638
1638
  limit: 2,
1639
1639
  shouldRetryFn: (_) => {
1640
- var de, Re, De, Ie;
1640
+ var de, De, Ie, Ee;
1641
1641
  const J = (de = _ == null ? void 0 : _.message) == null ? void 0 : de.includes("missing or invalid session_id");
1642
- return !((Re = _ == null ? void 0 : _.message) == null ? void 0 : Re.includes("Stream Error")) && !J ? ((Ie = (De = t.callbacks).onError) == null || Ie.call(De, _), !1) : !0;
1642
+ return !((De = _ == null ? void 0 : _.message) == null ? void 0 : De.includes("Stream Error")) && !J ? ((Ee = (Ie = t.callbacks).onError) == null || Ee.call(Ie, _), !1) : !0;
1643
1643
  },
1644
1644
  onRetry: async () => {
1645
1645
  await R(), await Y(!1);
@@ -1674,7 +1674,7 @@ async function Ln(e, t) {
1674
1674
  throw ((F = r.messages[r.messages.length - 1]) == null ? void 0 : F.role) === "assistant" && r.messages.pop(), a.track("agent-message-send", {
1675
1675
  event: "error",
1676
1676
  messages: r.messages.length,
1677
- error: he(h)
1677
+ error: ge(h)
1678
1678
  }), h;
1679
1679
  }
1680
1680
  },
@@ -1683,8 +1683,8 @@ async function Ln(e, t) {
1683
1683
  const C = r.messages.find((h) => h.id === l);
1684
1684
  if (r.chat) {
1685
1685
  if (!C)
1686
- throw new $("Message not found");
1687
- } else throw new $("Chat is not initialized");
1686
+ throw new B("Message not found");
1687
+ } else throw new B("Chat is not initialized");
1688
1688
  const k = ((M = C.matches) == null ? void 0 : M.map((h) => [h.document_id, h.id])) ?? [];
1689
1689
  return a.track("agent-rate", {
1690
1690
  event: y ? "update" : "create",
@@ -1706,7 +1706,7 @@ async function Ln(e, t) {
1706
1706
  },
1707
1707
  deleteRate(l) {
1708
1708
  if (!r.chat)
1709
- throw new $("Chat is not initialized");
1709
+ throw new B("Chat is not initialized");
1710
1710
  return a.track("agent-rate-delete", { type: "text" }), u.deleteRating(f.id, r.chat.id, l);
1711
1711
  },
1712
1712
  async speak(l) {
@@ -1714,7 +1714,7 @@ async function Ln(e, t) {
1714
1714
  function p() {
1715
1715
  if (typeof l == "string") {
1716
1716
  if (!f.presenter.voice)
1717
- throw new $("Presenter voice is not initialized");
1717
+ throw new B("Presenter voice is not initialized");
1718
1718
  return {
1719
1719
  type: "text",
1720
1720
  provider: f.presenter.voice,
@@ -1724,7 +1724,7 @@ async function Ln(e, t) {
1724
1724
  }
1725
1725
  if (l.type === "text" && !l.provider) {
1726
1726
  if (!f.presenter.voice)
1727
- throw new $("Presenter voice is not initialized");
1727
+ throw new B("Presenter voice is not initialized");
1728
1728
  return {
1729
1729
  type: "text",
1730
1730
  provider: f.presenter.voice,
@@ -1748,7 +1748,7 @@ async function Ln(e, t) {
1748
1748
  status: "success"
1749
1749
  };
1750
1750
  if (!r.streamingManager)
1751
- throw new $("Please connect to the agent first");
1751
+ throw new B("Please connect to the agent first");
1752
1752
  return r.streamingManager.speak({
1753
1753
  script: y,
1754
1754
  metadata: { chat_id: (L = r.chat) == null ? void 0 : L.id, agent_id: f.id }
@@ -1764,21 +1764,21 @@ export {
1764
1764
  G as B,
1765
1765
  z as C,
1766
1766
  yt as D,
1767
- Oe as H,
1767
+ Ke as H,
1768
1768
  wt as K,
1769
1769
  lt as N,
1770
1770
  mt as P,
1771
1771
  gt as R,
1772
1772
  x as S,
1773
- Se as T,
1773
+ ke as T,
1774
1774
  ft as U,
1775
- $ as V,
1775
+ B as V,
1776
1776
  ut as W,
1777
1777
  tn as a,
1778
1778
  W as b,
1779
1779
  Ye as c,
1780
- fe as d,
1781
- Ke as e,
1780
+ me as d,
1781
+ We as e,
1782
1782
  A as f,
1783
1783
  re as g,
1784
1784
  fn as h,
@@ -1793,8 +1793,8 @@ export {
1793
1793
  vt as q,
1794
1794
  Jt as r,
1795
1795
  pt as s,
1796
- he as t,
1797
- We as u,
1796
+ ge as t,
1797
+ He as u,
1798
1798
  Ct as v,
1799
1799
  Ln as w,
1800
1800
  bn as x,