@d-id/client-sdk 1.1.31-staging.143 → 1.1.31-staging.145

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,42 +1,42 @@
1
- var Xe = Object.defineProperty;
2
- var Ye = (e, t, a) => t in e ? Xe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
3
- var fe = (e, t, a) => Ye(e, typeof t != "symbol" ? t + "" : t, a);
1
+ var Qe = Object.defineProperty;
2
+ var Xe = (e, t, i) => t in e ? Qe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
3
+ var fe = (e, t, i) => Xe(e, typeof t != "symbol" ? t + "" : t, i);
4
4
  class we extends Error {
5
- constructor({ kind: a, description: n, error: s }) {
6
- super(JSON.stringify({ kind: a, description: n }));
5
+ constructor({ kind: i, description: n, error: s }) {
6
+ super(JSON.stringify({ kind: i, description: n }));
7
7
  fe(this, "kind");
8
8
  fe(this, "description");
9
9
  fe(this, "error");
10
- this.kind = a, this.description = n, this.error = s;
10
+ this.kind = i, this.description = n, this.error = s;
11
11
  }
12
12
  }
13
- class Ge extends we {
14
- constructor(t, a) {
13
+ class Ye extends we {
14
+ constructor(t, i) {
15
15
  super({
16
16
  kind: "ChatCreationFailed",
17
- description: `Failed to create ${a ? "persistent" : ""} chat, mode: ${t}`
17
+ description: `Failed to create ${i ? "persistent" : ""} chat, mode: ${t}`
18
18
  });
19
19
  }
20
20
  }
21
- class Ze extends we {
21
+ class Ge extends we {
22
22
  constructor(t) {
23
23
  super({ kind: "ChatModeDowngraded", description: `Chat mode downgraded to ${t}` });
24
24
  }
25
25
  }
26
- class de extends we {
27
- constructor(a, n) {
28
- super({ kind: "ValidationError", description: a });
26
+ class ue extends we {
27
+ constructor(i, n) {
28
+ super({ kind: "ValidationError", description: i });
29
29
  fe(this, "key");
30
30
  this.key = n;
31
31
  }
32
32
  }
33
- class et extends we {
33
+ class Ze extends we {
34
34
  constructor(t) {
35
35
  super({ kind: "WSError", description: t });
36
36
  }
37
37
  }
38
- var tt = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(tt || {}), nt = /* @__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))(nt || {}), rt = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(rt || {}), it = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(it || {}), N = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(N || {}), Y = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(Y || {}), at = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(at || {}), ot = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(ot || {}), st = /* @__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))(st || {}), Je = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(Je || {});
39
- const gn = (e) => {
38
+ var et = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(et || {}), tt = /* @__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))(tt || {}), nt = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(nt || {}), rt = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(rt || {}), F = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(F || {}), X = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(X || {}), it = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(it || {}), at = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(at || {}), ot = /* @__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))(ot || {}), Ke = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(Ke || {});
39
+ const mn = (e) => {
40
40
  switch (e) {
41
41
  case "clip":
42
42
  return "clip";
@@ -48,22 +48,22 @@ const gn = (e) => {
48
48
  throw new Error(`Unknown video type: ${e}`);
49
49
  }
50
50
  };
51
- var C = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(C || {}), ie = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(ie || {}), q = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e))(q || {}), j = /* @__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))(j || {}), S = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnected = "disconnected", e))(S || {}), ae = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(ae || {}), ye = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(ye || {}), ct = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(ct || {}), dt = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(dt || {});
52
- const ut = 45 * 1e3, lt = "X-Playground-Chat", ge = "https://api.d-id.com", ft = "wss://notifications.d-id.com", mt = "79f81a83a67430be2bc0fd61042b8faa", Ue = (e) => new Promise((t) => setTimeout(t, e)), ue = (e = 16) => {
51
+ var S = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(S || {}), ie = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(ie || {}), W = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e))(W || {}), j = /* @__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))(j || {}), R = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnected = "disconnected", e))(R || {}), ae = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(ae || {}), ye = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(ye || {}), st = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(st || {}), ct = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(ct || {});
52
+ const dt = 45 * 1e3, ut = "X-Playground-Chat", ge = "https://api.d-id.com", lt = "wss://notifications.d-id.com", ft = "79f81a83a67430be2bc0fd61042b8faa", Je = (e) => new Promise((t) => setTimeout(t, e)), le = (e = 16) => {
53
53
  const t = new Uint8Array(e);
54
- return window.crypto.getRandomValues(t), Array.from(t, (a) => a.toString(16).padStart(2, "0")).join("").slice(0, 13);
55
- }, We = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type, Ie = (e) => e === Je.Expressive, gt = (e) => [N.TextOnly, N.Playground, N.Maintenance].includes(e), Ve = (e) => e && [N.DirectPlayback, N.Off].includes(e);
56
- function ht(e, t) {
57
- let a;
54
+ return window.crypto.getRandomValues(t), Array.from(t, (i) => i.toString(16).padStart(2, "0")).join("").slice(0, 13);
55
+ }, Ue = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type, Ie = (e) => e === Ke.Expressive, mt = (e) => [F.TextOnly, F.Playground, F.Maintenance].includes(e), Ve = (e) => e && [F.DirectPlayback, F.Off].includes(e);
56
+ function gt(e, t) {
57
+ let i;
58
58
  return {
59
59
  promise: new Promise((s, o) => {
60
- a = setTimeout(() => o(new Error(t)), e);
60
+ i = setTimeout(() => o(new Error(t)), e);
61
61
  }),
62
- clear: () => clearTimeout(a)
62
+ clear: () => clearTimeout(i)
63
63
  };
64
64
  }
65
- async function Ce(e, t) {
66
- const a = {
65
+ async function Se(e, t) {
66
+ const i = {
67
67
  limit: (t == null ? void 0 : t.limit) ?? 3,
68
68
  delayMs: (t == null ? void 0 : t.delayMs) ?? 0,
69
69
  timeout: (t == null ? void 0 : t.timeout) ?? 3e4,
@@ -73,16 +73,16 @@ async function Ce(e, t) {
73
73
  })
74
74
  };
75
75
  let n;
76
- for (let s = 1; s <= a.limit; s++)
76
+ for (let s = 1; s <= i.limit; s++)
77
77
  try {
78
- if (!a.timeout)
78
+ if (!i.timeout)
79
79
  return await e();
80
- const { promise: o, clear: c } = ht(a.timeout, a.timeoutErrorMessage), i = e().finally(c);
81
- return await Promise.race([i, o]);
80
+ const { promise: o, clear: c } = gt(i.timeout, i.timeoutErrorMessage), a = e().finally(c);
81
+ return await Promise.race([a, o]);
82
82
  } catch (o) {
83
- if (n = o, !a.shouldRetryFn(o) || s >= a.limit)
83
+ if (n = o, !i.shouldRetryFn(o) || s >= i.limit)
84
84
  throw o;
85
- await Ue(a.delayMs), a.onRetry(o);
85
+ await Je(i.delayMs), i.onRetry(o);
86
86
  }
87
87
  throw n;
88
88
  }
@@ -91,35 +91,35 @@ function ke(e) {
91
91
  return window.localStorage.setItem("did_external_key_id", e), e;
92
92
  let t = window.localStorage.getItem("did_external_key_id");
93
93
  if (!t) {
94
- let a = ue();
95
- window.localStorage.setItem("did_external_key_id", a), t = a;
94
+ let i = le();
95
+ window.localStorage.setItem("did_external_key_id", i), t = i;
96
96
  }
97
97
  return t;
98
98
  }
99
- let pt = ue();
100
- function Oe(e, t) {
99
+ let ht = le();
100
+ function We(e, t) {
101
101
  if (e.type === "bearer")
102
102
  return `Bearer ${e.token}`;
103
103
  if (e.type === "basic")
104
104
  return `Basic ${btoa(`${e.username}:${e.password}`)}`;
105
105
  if (e.type === "key")
106
- return `Client-Key ${e.clientKey}.${ke(t)}_${pt}`;
106
+ return `Client-Key ${e.clientKey}.${ke(t)}_${ht}`;
107
107
  throw new Error(`Unknown auth type: ${e}`);
108
108
  }
109
- const wt = (e) => Ce(e, {
109
+ const pt = (e) => Se(e, {
110
110
  limit: 3,
111
111
  delayMs: 1e3,
112
112
  timeout: 0,
113
113
  shouldRetryFn: (t) => t.status === 429
114
114
  });
115
- function Te(e, t = ge, a, n) {
115
+ function Te(e, t = ge, i, n) {
116
116
  const s = async (o, c) => {
117
- const { skipErrorHandler: i, ...r } = c || {}, d = await wt(
117
+ const { skipErrorHandler: a, ...r } = c || {}, d = await pt(
118
118
  () => fetch(t + (o != null && o.startsWith("/") ? o : `/${o}`), {
119
119
  ...r,
120
120
  headers: {
121
121
  ...r.headers,
122
- Authorization: Oe(e, n),
122
+ Authorization: We(e, n),
123
123
  "Content-Type": "application/json"
124
124
  }
125
125
  })
@@ -127,7 +127,7 @@ function Te(e, t = ge, a, n) {
127
127
  if (!d.ok) {
128
128
  let w = await d.text().catch(() => `Failed to fetch with status ${d.status}`);
129
129
  const p = new Error(w);
130
- throw a && !i && a(p, { url: o, options: r, headers: d.headers }), p;
130
+ throw i && !a && i(p, { url: o, options: r, headers: d.headers }), p;
131
131
  }
132
132
  return d.json();
133
133
  };
@@ -135,25 +135,25 @@ function Te(e, t = ge, a, n) {
135
135
  get(o, c) {
136
136
  return s(o, { ...c, method: "GET" });
137
137
  },
138
- post(o, c, i) {
139
- return s(o, { ...i, body: JSON.stringify(c), method: "POST" });
138
+ post(o, c, a) {
139
+ return s(o, { ...a, body: JSON.stringify(c), method: "POST" });
140
140
  },
141
- delete(o, c, i) {
142
- return s(o, { ...i, body: JSON.stringify(c), method: "DELETE" });
141
+ delete(o, c, a) {
142
+ return s(o, { ...a, body: JSON.stringify(c), method: "DELETE" });
143
143
  },
144
- patch(o, c, i) {
145
- return s(o, { ...i, body: JSON.stringify(c), method: "PATCH" });
144
+ patch(o, c, a) {
145
+ return s(o, { ...a, body: JSON.stringify(c), method: "PATCH" });
146
146
  }
147
147
  };
148
148
  }
149
- function yt(e, t = ge, a, n) {
150
- const s = Te(e, `${t}/agents`, a, n);
149
+ function wt(e, t = ge, i, n) {
150
+ const s = Te(e, `${t}/agents`, i, n);
151
151
  return {
152
152
  create(o, c) {
153
153
  return s.post("/", o, c);
154
154
  },
155
155
  getAgents(o, c) {
156
- return s.get(`/${o ? `?tag=${o}` : ""}`, c).then((i) => i ?? []);
156
+ return s.get(`/${o ? `?tag=${o}` : ""}`, c).then((a) => a ?? []);
157
157
  },
158
158
  getById(o, c) {
159
159
  return s.get(`/${o}`, c);
@@ -161,52 +161,52 @@ function yt(e, t = ge, a, n) {
161
161
  delete(o, c) {
162
162
  return s.delete(`/${o}`, void 0, c);
163
163
  },
164
- update(o, c, i) {
165
- return s.patch(`/${o}`, c, i);
164
+ update(o, c, a) {
165
+ return s.patch(`/${o}`, c, a);
166
166
  },
167
- newChat(o, c, i) {
168
- return s.post(`/${o}/chat`, c, i);
167
+ newChat(o, c, a) {
168
+ return s.post(`/${o}/chat`, c, a);
169
169
  },
170
- chat(o, c, i, r) {
171
- return s.post(`/${o}/chat/${c}`, i, r);
170
+ chat(o, c, a, r) {
171
+ return s.post(`/${o}/chat/${c}`, a, r);
172
172
  },
173
- createRating(o, c, i, r) {
174
- return s.post(`/${o}/chat/${c}/ratings`, i, r);
173
+ createRating(o, c, a, r) {
174
+ return s.post(`/${o}/chat/${c}/ratings`, a, r);
175
175
  },
176
- updateRating(o, c, i, r, d) {
177
- return s.patch(`/${o}/chat/${c}/ratings/${i}`, r, d);
176
+ updateRating(o, c, a, r, d) {
177
+ return s.patch(`/${o}/chat/${c}/ratings/${a}`, r, d);
178
178
  },
179
- deleteRating(o, c, i, r) {
180
- return s.delete(`/${o}/chat/${c}/ratings/${i}`, r);
179
+ deleteRating(o, c, a, r) {
180
+ return s.delete(`/${o}/chat/${c}/ratings/${a}`, r);
181
181
  },
182
182
  getSTTToken(o, c) {
183
183
  return s.get(`/${o}/stt-token`, c);
184
184
  }
185
185
  };
186
186
  }
187
- function vt(e) {
188
- var s, o, c, i;
189
- const t = () => /Mobi|Android/i.test(navigator.userAgent) ? "Mobile" : "Desktop", a = () => {
187
+ function yt(e) {
188
+ var s, o, c, a;
189
+ const t = () => /Mobi|Android/i.test(navigator.userAgent) ? "Mobile" : "Desktop", i = () => {
190
190
  const r = navigator.platform;
191
191
  return r.toLowerCase().includes("win") ? "Windows" : r.toLowerCase().includes("mac") ? "Mac OS X" : r.toLowerCase().includes("linux") ? "Linux" : "Unknown";
192
192
  }, n = e.presenter;
193
193
  return {
194
- $os: `${a()}`,
194
+ $os: `${i()}`,
195
195
  isMobile: `${t() == "Mobile"}`,
196
196
  browser: navigator.userAgent,
197
197
  origin: window.location.origin,
198
- agentType: We(n),
198
+ agentType: Ue(n),
199
199
  agentVoice: {
200
200
  voiceId: (o = (s = e.presenter) == null ? void 0 : s.voice) == null ? void 0 : o.voice_id,
201
- provider: (i = (c = e.presenter) == null ? void 0 : c.voice) == null ? void 0 : i.type
201
+ provider: (a = (c = e.presenter) == null ? void 0 : c.voice) == null ? void 0 : a.type
202
202
  }
203
203
  };
204
204
  }
205
- function St(e) {
206
- var a, n, s, o, c, i;
207
- const t = (a = e.llm) == null ? void 0 : a.prompt_customization;
205
+ function vt(e) {
206
+ var i, n, s, o, c, a;
207
+ const t = (i = e.llm) == null ? void 0 : i.prompt_customization;
208
208
  return {
209
- agentType: We(e.presenter),
209
+ agentType: Ue(e.presenter),
210
210
  owner_id: e.owner_id ?? "",
211
211
  promptVersion: (n = e.llm) == null ? void 0 : n.prompt_version,
212
212
  behavior: {
@@ -216,7 +216,7 @@ function St(e) {
216
216
  },
217
217
  temperature: (o = e.llm) == null ? void 0 : o.temperature,
218
218
  knowledgeSource: t == null ? void 0 : t.knowledge_source,
219
- starterQuestionsCount: (i = (c = e.knowledge) == null ? void 0 : c.starter_message) == null ? void 0 : i.length,
219
+ starterQuestionsCount: (a = (c = e.knowledge) == null ? void 0 : c.starter_message) == null ? void 0 : a.length,
220
220
  topicsToAvoid: t == null ? void 0 : t.topics_to_avoid,
221
221
  maxResponseLength: t == null ? void 0 : t.max_response_length,
222
222
  agentId: e.id,
@@ -225,8 +225,8 @@ function St(e) {
225
225
  ...e.access === "public" ? { from: "agent-template" } : {}
226
226
  };
227
227
  }
228
- const Ct = (e) => e.reduce((t, a) => t + a, 0), xe = (e) => Ct(e) / e.length;
229
- function kt(e, t, a) {
228
+ const Ct = (e) => e.reduce((t, i) => t + i, 0), $e = (e) => Ct(e) / e.length;
229
+ function St(e, t, i) {
230
230
  var r, d, w;
231
231
  const { event: n, ...s } = e, { template: o } = (t == null ? void 0 : t.llm) || {}, { language: c } = ((r = t == null ? void 0 : t.presenter) == null ? void 0 : r.voice) || {};
232
232
  return {
@@ -234,15 +234,15 @@ function kt(e, t, a) {
234
234
  llm: { ...s.llm, template: o },
235
235
  script: { ...s.script, provider: { ...(d = s == null ? void 0 : s.script) == null ? void 0 : d.provider, language: c } },
236
236
  stitch: (t == null ? void 0 : t.presenter.type) === "talk" ? (w = t == null ? void 0 : t.presenter) == null ? void 0 : w.stitch : void 0,
237
- ...a
237
+ ...i
238
238
  };
239
239
  }
240
240
  function Be(e) {
241
241
  "requestIdleCallback" in window ? requestIdleCallback(e, { timeout: 2e3 }) : setTimeout(e, 0);
242
242
  }
243
243
  let ve = {};
244
- const Rt = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
245
- function Dt(e) {
244
+ const kt = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
245
+ function Rt(e) {
246
246
  const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk";
247
247
  return {
248
248
  token: e.token || "testKey",
@@ -253,14 +253,14 @@ function Dt(e) {
253
253
  ...e.mixpanelAdditionalProperties || {}
254
254
  },
255
255
  isEnabled: e.isEnabled ?? !0,
256
- getRandom: ue,
257
- enrich(a) {
258
- this.additionalProperties = { ...this.additionalProperties, ...a };
256
+ getRandom: le,
257
+ enrich(i) {
258
+ this.additionalProperties = { ...this.additionalProperties, ...i };
259
259
  },
260
- async track(a, n, s) {
260
+ async track(i, n, s) {
261
261
  if (!this.isEnabled)
262
262
  return Promise.resolve();
263
- const { audioPath: o, ...c } = n || {}, i = s || Date.now(), r = {
263
+ const { audioPath: o, ...c } = n || {}, a = s || Date.now(), r = {
264
264
  method: "POST",
265
265
  headers: {
266
266
  "Content-Type": "application/x-www-form-urlencoded"
@@ -268,14 +268,14 @@ function Dt(e) {
268
268
  body: new URLSearchParams({
269
269
  data: JSON.stringify([
270
270
  {
271
- event: a,
271
+ event: i,
272
272
  properties: {
273
273
  ...this.additionalProperties,
274
274
  ...c,
275
275
  agentId: this.agentId,
276
276
  source: t,
277
277
  token: this.token,
278
- time: i,
278
+ time: a,
279
279
  $insert_id: this.getRandom(),
280
280
  origin: window.location.href,
281
281
  "Screen Height": window.screen.height || window.innerWidth,
@@ -286,19 +286,19 @@ function Dt(e) {
286
286
  ])
287
287
  })
288
288
  };
289
- return fetch(Rt, {
289
+ return fetch(kt, {
290
290
  ...r,
291
291
  keepalive: !0
292
292
  }).catch((d) => console.error("Analytics tracking error:", d)), Promise.resolve();
293
293
  },
294
- linkTrack(a, n, s, o) {
295
- ve[a] || (ve[a] = { events: {}, resolvedDependencies: [] }), o.includes(s) || o.push(s);
296
- const c = ve[a];
294
+ linkTrack(i, n, s, o) {
295
+ ve[i] || (ve[i] = { events: {}, resolvedDependencies: [] }), o.includes(s) || o.push(s);
296
+ const c = ve[i];
297
297
  if (c.events[s] = { props: n }, c.resolvedDependencies.push(s), o.every(
298
298
  (r) => c.resolvedDependencies.includes(r)
299
299
  )) {
300
300
  const r = o.reduce((d, w) => c.events[w] ? { ...d, ...c.events[w].props } : d, {});
301
- this.track(a, r), c.resolvedDependencies = c.resolvedDependencies.filter(
301
+ this.track(i, r), c.resolvedDependencies = c.resolvedDependencies.filter(
302
302
  (d) => !o.includes(d)
303
303
  ), o.forEach((d) => {
304
304
  delete c.events[d];
@@ -315,22 +315,22 @@ function _e() {
315
315
  get: (t = !1) => t ? Date.now() - e : e
316
316
  };
317
317
  }
318
- const ee = _e(), Re = _e(), Fe = _e();
319
- function qe(e) {
320
- return e === N.Playground ? { headers: { [lt]: "true" } } : {};
318
+ const ee = _e(), Re = _e(), xe = _e();
319
+ function Oe(e) {
320
+ return e === F.Playground ? { headers: { [ut]: "true" } } : {};
321
321
  }
322
- async function He(e, t, a, n, s = !1, o) {
322
+ async function He(e, t, i, n, s = !1, o) {
323
323
  try {
324
- return !o && !Ve(n) && (o = await t.newChat(e.id, { persist: s }, qe(n)), a.track("agent-chat", {
324
+ return !o && !Ve(n) && (o = await t.newChat(e.id, { persist: s }, Oe(n)), i.track("agent-chat", {
325
325
  event: "created",
326
326
  chatId: o.id,
327
327
  mode: n
328
328
  })), { chat: o, chatMode: (o == null ? void 0 : o.chat_mode) ?? n };
329
329
  } catch (c) {
330
- throw Mt(c) === "InsufficientCreditsError" ? new Error("InsufficientCreditsError") : new Error("Cannot create new chat");
330
+ throw Dt(c) === "InsufficientCreditsError" ? new Error("InsufficientCreditsError") : new Error("Cannot create new chat");
331
331
  }
332
332
  }
333
- const Mt = (e) => {
333
+ const Dt = (e) => {
334
334
  try {
335
335
  const t = JSON.parse(e.message);
336
336
  return t == null ? void 0 : t.kind;
@@ -338,19 +338,19 @@ const Mt = (e) => {
338
338
  return "UnknownError";
339
339
  }
340
340
  };
341
- function Et(e) {
341
+ function Mt(e) {
342
342
  return e && e.length > 0 ? e : [];
343
343
  }
344
- function It(e, t, a, n) {
345
- const s = Te(e, `${t}/v2/agents/${a}`, n);
344
+ function Et(e, t, i, n) {
345
+ const s = Te(e, `${t}/v2/agents/${i}`, n);
346
346
  return {
347
347
  async createStream(o) {
348
348
  return s.post("/sessions", o);
349
349
  }
350
350
  };
351
351
  }
352
- const Qe = (e, t) => (a, n) => e && console.log(`[${t}] ${a}`, n ?? "");
353
- async function Se() {
352
+ const qe = (e, t) => (i, n) => e && console.log(`[${t}] ${i}`, n ?? "");
353
+ async function Ce() {
354
354
  try {
355
355
  return await import("./livekit-client.esm-C1GRQdZY.js");
356
356
  } catch {
@@ -359,7 +359,7 @@ async function Se() {
359
359
  );
360
360
  }
361
361
  }
362
- const Tt = {
362
+ const It = {
363
363
  excellent: ie.Strong,
364
364
  good: ie.Strong,
365
365
  poor: ie.Weak,
@@ -370,142 +370,135 @@ const Tt = {
370
370
  description: "Stream Error"
371
371
  });
372
372
  var Ae = /* @__PURE__ */ ((e) => (e.Chat = "lk.chat", e.Speak = "did.speak", e.Interrupt = "did.interrupt", e))(Ae || {});
373
- function De(e, t, a, n) {
374
- var s, o;
375
- throw t("Failed to connect to LiveKit room:", e), n(), (s = a.onConnectionStateChange) == null || s.call(a, S.Fail), (o = a.onError) == null || o.call(a, e, { sessionId: "" }), e;
373
+ function De(e, t, i) {
374
+ var n, s;
375
+ throw t("Failed to connect to LiveKit room:", e), (n = i.onConnectionStateChange) == null || n.call(i, R.Fail), (s = i.onError) == null || s.call(i, e, { sessionId: "" }), e;
376
376
  }
377
- async function _t(e, t, a) {
378
- var Pe, be;
379
- const n = Qe(a.debug || !1, "LiveKitStreamingManager"), { Room: s, RoomEvent: o, ConnectionState: c } = await Se(), { callbacks: i, auth: r, baseURL: d, analytics: w, microphoneStream: p } = a;
380
- let u = null, P = !1;
377
+ async function Tt(e, t, i) {
378
+ var Pe;
379
+ const n = qe(i.debug || !1, "LiveKitStreamingManager"), { Room: s, RoomEvent: o, ConnectionState: c } = await Ce(), { callbacks: a, auth: r, baseURL: d, analytics: w, microphoneStream: p } = i;
380
+ let u = null, _ = !1;
381
381
  const $ = ae.Fluent;
382
- let B = !0, R = null, M = null;
382
+ let A = null, C = null, B = !1;
383
383
  u = new s({
384
384
  adaptiveStream: !1,
385
385
  // Must be false to use mediaStreamTrack directly
386
386
  dynacast: !0
387
387
  });
388
388
  let z = null;
389
- const T = 2e4;
390
- let W = q.Idle;
391
- const te = It(r, d || ge, e, i.onError);
392
- let E, G, Z;
389
+ const I = 2e4;
390
+ let U = W.Idle;
391
+ const te = Et(r, d || ge, e, a.onError);
392
+ let M, Y, Z;
393
393
  try {
394
394
  const l = await te.createStream({
395
395
  transport_provider: ye.Livekit,
396
396
  chat_persist: t.chat_persist ?? !0
397
397
  }), { id: g, session_token: v, session_url: D } = l;
398
- (Pe = i.onStreamCreated) == null || Pe.call(i, { session_id: g, stream_id: g, agent_id: e }), E = g, G = v, Z = D, await u.prepareConnection(Z, G);
398
+ (Pe = a.onStreamCreated) == null || Pe.call(a, { session_id: g, stream_id: g, agent_id: e }), M = g, Y = v, Z = D, await u.prepareConnection(Z, Y);
399
399
  } catch (l) {
400
- De(l, n, i, () => {
401
- B = !1;
402
- });
400
+ De(l, n, a);
403
401
  }
404
- if (!Z || !G || !E)
402
+ if (!Z || !Y || !M)
405
403
  return Promise.reject(new Error("Failed to initialize LiveKit stream"));
406
- u.on(o.ConnectionStateChanged, y).on(o.ConnectionQualityChanged, k).on(o.ActiveSpeakersChanged, _).on(o.ParticipantConnected, b).on(o.ParticipantDisconnected, I).on(o.TrackSubscribed, U).on(o.TrackUnsubscribed, H).on(o.DataReceived, Q).on(o.MediaDevicesError, L).on(o.TranscriptionReceived, f).on(o.EncryptionError, K).on(o.TrackSubscriptionFailed, X), (be = i.onConnectionStateChange) == null || be.call(i, S.New);
404
+ u.on(o.ConnectionStateChanged, y).on(o.ConnectionQualityChanged, k).on(o.ActiveSpeakersChanged, T).on(o.ParticipantConnected, P).on(o.ParticipantDisconnected, E).on(o.TrackSubscribed, J).on(o.TrackUnsubscribed, O).on(o.DataReceived, H).on(o.MediaDevicesError, L).on(o.TranscriptionReceived, f).on(o.EncryptionError, N).on(o.TrackSubscriptionFailed, q);
407
405
  function f(l, g) {
408
406
  var v;
409
- g != null && g.isLocal && (ee.update(), W === q.Talking && ((v = i.onInterruptDetected) == null || v.call(i, { type: "audio" }), W = q.Idle));
407
+ g != null && g.isLocal && (ee.update(), U === W.Talking && ((v = a.onInterruptDetected) == null || v.call(a, { type: "audio" }), U = W.Idle));
410
408
  }
411
409
  try {
412
- await u.connect(Z, G), n("LiveKit room joined successfully"), z = setTimeout(() => {
410
+ await u.connect(Z, Y), n("LiveKit room joined successfully"), z = setTimeout(() => {
413
411
  var l;
414
412
  n("Track subscription timeout - no track subscribed within 30 seconds after connect"), z = null, w.track("connectivity-error", {
415
413
  error: "Track subscription timeout",
416
- sessionId: E
417
- }), (l = i.onError) == null || l.call(i, new Error("Track subscription timeout"), { sessionId: E }), se();
418
- }, T), B = !1;
414
+ sessionId: M
415
+ }), (l = a.onError) == null || l.call(a, new Error("Track subscription timeout"), { sessionId: M }), ce();
416
+ }, I);
419
417
  } catch (l) {
420
- De(l, n, i, () => {
421
- B = !1;
422
- });
418
+ De(l, n, a);
423
419
  }
424
420
  w.enrich({
425
421
  "stream-type": $
426
422
  });
427
423
  function y(l) {
428
- var g, v, D, A, O;
424
+ var g, v, D, b;
429
425
  switch (n("Connection state changed:", l), l) {
430
426
  case c.Connecting:
431
- (g = i.onConnectionStateChange) == null || g.call(i, S.Connecting);
427
+ n("CALLBACK: onConnectionStateChange(Connecting)"), (g = a.onConnectionStateChange) == null || g.call(a, R.Connecting);
432
428
  break;
433
429
  case c.Connected:
434
- n("LiveKit room connected successfully"), P = !0, B ? queueMicrotask(() => {
435
- var x;
436
- (x = i.onConnectionStateChange) == null || x.call(i, S.Connected);
437
- }) : (v = i.onConnectionStateChange) == null || v.call(i, S.Connected);
430
+ n("LiveKit room connected successfully"), _ = !0;
438
431
  break;
439
432
  case c.Disconnected:
440
- n("LiveKit room disconnected"), P = !1, (D = i.onConnectionStateChange) == null || D.call(i, S.Disconnected);
433
+ n("LiveKit room disconnected"), _ = !1, B = !1, (v = a.onConnectionStateChange) == null || v.call(a, R.Disconnected);
441
434
  break;
442
435
  case c.Reconnecting:
443
- n("LiveKit room reconnecting..."), (A = i.onConnectionStateChange) == null || A.call(i, S.Connecting);
436
+ n("LiveKit room reconnecting..."), (D = a.onConnectionStateChange) == null || D.call(a, R.Connecting);
444
437
  break;
445
438
  case c.SignalReconnecting:
446
- n("LiveKit room signal reconnecting..."), (O = i.onConnectionStateChange) == null || O.call(i, S.Connecting);
439
+ n("LiveKit room signal reconnecting..."), (b = a.onConnectionStateChange) == null || b.call(a, R.Connecting);
447
440
  break;
448
441
  }
449
442
  }
450
443
  function k(l, g) {
451
444
  var v;
452
- n("Connection quality:", l), g != null && g.isLocal && ((v = i.onConnectivityStateChange) == null || v.call(i, Tt[l]));
445
+ n("Connection quality:", l), g != null && g.isLocal && ((v = a.onConnectivityStateChange) == null || v.call(a, It[l]));
453
446
  }
454
- function _(l) {
447
+ function T(l) {
455
448
  n("Active speakers changed:", l);
456
449
  }
457
- function b(l) {
450
+ function P(l) {
458
451
  n("Participant connected:", l.identity);
459
452
  }
460
- function I(l) {
461
- n("Participant disconnected:", l.identity), se();
453
+ function E(l) {
454
+ n("Participant disconnected:", l.identity), ce();
462
455
  }
463
- function U(l, g, v) {
464
- var A, O, x;
456
+ function J(l, g, v) {
457
+ var b, Q, G, se;
465
458
  n(`Track subscribed: ${l.kind} from ${v.identity}`), z && (clearTimeout(z), z = null, n("Track subscription timeout cleared"));
466
459
  const D = l.mediaStreamTrack;
467
460
  if (!D) {
468
461
  n(`No mediaStreamTrack available for ${l.kind}`);
469
462
  return;
470
463
  }
471
- R ? (R.addTrack(D), n(`Added ${l.kind} track to shared MediaStream`)) : (R = new MediaStream([D]), n(`Created shared MediaStream with ${l.kind} track`)), l.kind === "video" && ((A = i.onStreamReady) == null || A.call(i), (O = i.onSrcObjectReady) == null || O.call(i, R), (x = i.onVideoStateChange) == null || x.call(i, C.Start));
464
+ A ? (A.addTrack(D), n(`Added ${l.kind} track to shared MediaStream`)) : (A = new MediaStream([D]), n(`Created shared MediaStream with ${l.kind} track`)), l.kind === "video" && ((b = a.onStreamReady) == null || b.call(a), n("CALLBACK: onSrcObjectReady"), (Q = a.onSrcObjectReady) == null || Q.call(a, A), B || (B = !0, n("CALLBACK: onConnectionStateChange(Connected)"), (G = a.onConnectionStateChange) == null || G.call(a, R.Connected)), n("CALLBACK: onVideoStateChange(Start)"), (se = a.onVideoStateChange) == null || se.call(a, S.Start));
472
465
  }
473
- function H(l, g, v) {
466
+ function O(l, g, v) {
474
467
  var D;
475
- n(`Track unsubscribed: ${l.kind} from ${v.identity}`), l.kind === "video" && ((D = i.onVideoStateChange) == null || D.call(i, C.Stop));
468
+ n(`Track unsubscribed: ${l.kind} from ${v.identity}`), l.kind === "video" && ((D = a.onVideoStateChange) == null || D.call(a, S.Stop));
476
469
  }
477
- function Q(l, g, v, D) {
478
- var O, x, le, Le, je;
479
- const A = new TextDecoder().decode(l);
480
- n("Data received:", A);
470
+ function H(l, g, v, D) {
471
+ var Q, G, se, Le, be;
472
+ const b = new TextDecoder().decode(l);
473
+ n("Data received:", b);
481
474
  try {
482
- const ne = JSON.parse(A), ce = D || ne.subject;
483
- if (ce === j.ChatAnswer) {
484
- const re = Y.Answer;
485
- (O = i.onMessage) == null || O.call(i, re, {
475
+ const ne = JSON.parse(b), de = D || ne.subject;
476
+ if (de === j.ChatAnswer) {
477
+ const re = X.Answer;
478
+ (Q = a.onMessage) == null || Q.call(a, re, {
486
479
  event: re,
487
480
  ...ne
488
481
  });
489
- } else if (ce === j.ChatPartial) {
490
- const re = Y.Partial;
491
- (x = i.onMessage) == null || x.call(i, re, {
482
+ } else if (de === j.ChatPartial) {
483
+ const re = X.Partial;
484
+ (G = a.onMessage) == null || G.call(a, re, {
492
485
  event: re,
493
486
  ...ne
494
487
  });
495
- } else if ([j.StreamVideoCreated, j.StreamVideoDone].includes(ce)) {
496
- W = ce === j.StreamVideoCreated ? q.Talking : q.Idle, (le = i.onAgentActivityStateChange) == null || le.call(i, W);
488
+ } else if ([j.StreamVideoCreated, j.StreamVideoDone].includes(de)) {
489
+ U = de === j.StreamVideoCreated ? W.Talking : W.Idle, (se = a.onAgentActivityStateChange) == null || se.call(a, U);
497
490
  const re = (ne == null ? void 0 : ne.role) || (g == null ? void 0 : g.identity) || "datachannel";
498
- (Le = i.onMessage) == null || Le.call(i, ce, {
491
+ (Le = a.onMessage) == null || Le.call(a, de, {
499
492
  [re]: ne
500
493
  });
501
- } else if (ce === j.ChatAudioTranscribed) {
502
- const re = Y.Transcribe;
503
- (je = i.onMessage) == null || je.call(i, re, {
494
+ } else if (de === j.ChatAudioTranscribed) {
495
+ const re = X.Transcribe;
496
+ (be = a.onMessage) == null || be.call(a, re, {
504
497
  event: re,
505
498
  ...ne
506
499
  }), queueMicrotask(() => {
507
- var $e;
508
- ($e = i.onAgentActivityStateChange) == null || $e.call(i, q.Loading);
500
+ var je;
501
+ (je = a.onAgentActivityStateChange) == null || je.call(a, W.Loading);
509
502
  });
510
503
  }
511
504
  } catch (ne) {
@@ -514,178 +507,177 @@ async function _t(e, t, a) {
514
507
  }
515
508
  function L(l) {
516
509
  var g;
517
- n("Media devices error:", l), (g = i.onError) == null || g.call(i, new Error(me), { sessionId: E });
510
+ n("Media devices error:", l), (g = a.onError) == null || g.call(a, new Error(me), { sessionId: M });
518
511
  }
519
- function K(l) {
512
+ function N(l) {
520
513
  var g;
521
- n("Encryption error:", l), (g = i.onError) == null || g.call(i, new Error(me), { sessionId: E });
514
+ n("Encryption error:", l), (g = a.onError) == null || g.call(a, new Error(me), { sessionId: M });
522
515
  }
523
- function X(l, g, v) {
516
+ function q(l, g, v) {
524
517
  n("Track subscription failed:", { trackSid: l, participant: g, reason: v });
525
518
  }
526
519
  async function oe(l) {
527
520
  if (!u) return null;
528
- const { Track: g } = await Se(), v = u.localParticipant.audioTrackPublications;
521
+ const { Track: g } = await Ce(), v = u.localParticipant.audioTrackPublications;
529
522
  if (v) {
530
- for (const [D, A] of v)
531
- if (A.source === g.Source.Microphone && A.track) {
532
- const x = A.track.mediaStreamTrack;
533
- if (x === l || x && x.id === l.id)
534
- return A;
523
+ for (const [D, b] of v)
524
+ if (b.source === g.Source.Microphone && b.track) {
525
+ const G = b.track.mediaStreamTrack;
526
+ if (G === l || G && G.id === l.id)
527
+ return b;
535
528
  }
536
529
  }
537
530
  return null;
538
531
  }
539
532
  function V(l) {
540
- if (!M || !M.track)
533
+ if (!C || !C.track)
541
534
  return !1;
542
- const g = M.track.mediaStreamTrack;
535
+ const g = C.track.mediaStreamTrack;
543
536
  return g !== l && (g == null ? void 0 : g.id) !== l.id;
544
537
  }
545
538
  async function m(l) {
546
- var O, x;
547
- if (!P || !u)
539
+ var Q, G;
540
+ if (!_ || !u)
548
541
  throw n("Room is not connected, cannot publish microphone stream"), new Error("Room is not connected");
549
542
  const g = l.getAudioTracks();
550
543
  if (g.length === 0) {
551
544
  n("No audio track found in the provided MediaStream");
552
545
  return;
553
546
  }
554
- const v = g[0], { Track: D } = await Se(), A = await oe(v);
555
- if (A) {
547
+ const v = g[0], { Track: D } = await Ce(), b = await oe(v);
548
+ if (b) {
556
549
  n("Microphone track is already published, skipping", {
557
550
  trackId: v.id,
558
- publishedTrackId: (x = (O = A.track) == null ? void 0 : O.mediaStreamTrack) == null ? void 0 : x.id
559
- }), M = A;
551
+ publishedTrackId: (G = (Q = b.track) == null ? void 0 : Q.mediaStreamTrack) == null ? void 0 : G.id
552
+ }), C = b;
560
553
  return;
561
554
  }
562
555
  V(v) && (n("Unpublishing existing microphone track before publishing new one"), await h()), n("Publishing microphone track from provided MediaStream", { trackId: v.id });
563
556
  try {
564
- M = await u.localParticipant.publishTrack(v, {
557
+ C = await u.localParticipant.publishTrack(v, {
565
558
  source: D.Source.Microphone
566
- }), n("Microphone track published successfully", { trackSid: M.trackSid });
567
- } catch (le) {
568
- throw n("Failed to publish microphone track:", le), le;
559
+ }), n("Microphone track published successfully", { trackSid: C.trackSid });
560
+ } catch (se) {
561
+ throw n("Failed to publish microphone track:", se), se;
569
562
  }
570
563
  }
571
564
  async function h() {
572
- if (!(!M || !M.track))
565
+ if (!(!C || !C.track))
573
566
  try {
574
- u && (await u.localParticipant.unpublishTrack(M.track), n("Microphone track unpublished"));
567
+ u && (await u.localParticipant.unpublishTrack(C.track), n("Microphone track unpublished"));
575
568
  } catch (l) {
576
569
  n("Error unpublishing microphone track:", l);
577
570
  } finally {
578
- M = null;
571
+ C = null;
579
572
  }
580
573
  }
581
- function F() {
582
- R && (R.getTracks().forEach((l) => l.stop()), R = null);
574
+ function x() {
575
+ A && (A.getTracks().forEach((l) => l.stop()), A = null);
583
576
  }
584
- async function J(l, g) {
577
+ async function K(l, g) {
585
578
  var v, D;
586
- if (!P || !u) {
587
- n("Room is not connected for sending messages"), (v = i.onError) == null || v.call(i, new Error(me), {
588
- sessionId: E
579
+ if (!_ || !u) {
580
+ n("Room is not connected for sending messages"), (v = a.onError) == null || v.call(a, new Error(me), {
581
+ sessionId: M
589
582
  });
590
583
  return;
591
584
  }
592
585
  try {
593
586
  await u.localParticipant.sendText(l, { topic: g }), n("Message sent successfully:", l);
594
- } catch (A) {
595
- n("Failed to send message:", A), (D = i.onError) == null || D.call(i, new Error(me), { sessionId: E });
587
+ } catch (b) {
588
+ n("Failed to send message:", b), (D = a.onError) == null || D.call(a, new Error(me), { sessionId: M });
596
589
  }
597
590
  }
598
591
  async function he(l) {
599
592
  var g;
600
593
  try {
601
594
  const D = JSON.parse(l).topic;
602
- return J("", D);
595
+ return K("", D);
603
596
  } catch (v) {
604
- n("Failed to send data channel message:", v), (g = i.onError) == null || g.call(i, new Error(me), { sessionId: E });
597
+ n("Failed to send data channel message:", v), (g = a.onError) == null || g.call(a, new Error(me), { sessionId: M });
605
598
  }
606
599
  }
607
600
  function pe(l) {
608
- return J(
601
+ return K(
609
602
  l,
610
603
  "lk.chat"
611
604
  /* Chat */
612
605
  );
613
606
  }
614
- async function se() {
607
+ async function ce() {
615
608
  var l, g;
616
- z && (clearTimeout(z), z = null), u && (await h(), await u.disconnect()), F(), P = !1, (l = i.onConnectionStateChange) == null || l.call(i, S.Disconnected), (g = i.onAgentActivityStateChange) == null || g.call(i, q.Idle), W = q.Idle;
609
+ z && (clearTimeout(z), z = null), u && (await h(), await u.disconnect()), x(), _ = !1, B = !1, (l = a.onConnectionStateChange) == null || l.call(a, R.Disconnected), (g = a.onAgentActivityStateChange) == null || g.call(a, W.Idle), U = W.Idle;
617
610
  }
618
611
  return {
619
612
  speak(l) {
620
613
  const g = typeof l == "string" ? l : JSON.stringify(l);
621
- return J(
614
+ return K(
622
615
  g,
623
616
  "did.speak"
624
617
  /* Speak */
625
618
  );
626
619
  },
627
- disconnect: se,
620
+ disconnect: ce,
628
621
  async reconnect() {
629
- var l, g, v;
622
+ var l, g;
630
623
  if ((u == null ? void 0 : u.state) === c.Connected) {
631
624
  n("Room is already connected");
632
625
  return;
633
626
  }
634
- if (!u || !Z || !G)
627
+ if (!u || !Z || !Y)
635
628
  throw n("Cannot reconnect: missing room, URL or token"), new Error("Cannot reconnect: session not available");
636
- n("Reconnecting to LiveKit room, state:", u.state), (l = i.onConnectionStateChange) == null || l.call(i, S.Connecting);
629
+ n("Reconnecting to LiveKit room, state:", u.state), B = !1, (l = a.onConnectionStateChange) == null || l.call(a, R.Connecting);
637
630
  try {
638
- if (await u.connect(Z, G), n("Room reconnected"), P = !0, u.remoteParticipants.size === 0) {
639
- if (n("Waiting for agent to join..."), !await new Promise((A) => {
640
- const O = setTimeout(() => {
641
- u == null || u.off(o.ParticipantConnected, x), A(!1);
642
- }, 5e3), x = () => {
643
- clearTimeout(O), u == null || u.off(o.ParticipantConnected, x), A(!0);
631
+ if (await u.connect(Z, Y), n("Room reconnected"), _ = !0, u.remoteParticipants.size === 0) {
632
+ if (n("Waiting for agent to join..."), !await new Promise((D) => {
633
+ const b = setTimeout(() => {
634
+ u == null || u.off(o.ParticipantConnected, Q), D(!1);
635
+ }, 5e3), Q = () => {
636
+ clearTimeout(b), u == null || u.off(o.ParticipantConnected, Q), D(!0);
644
637
  };
645
- u == null || u.on(o.ParticipantConnected, x);
638
+ u == null || u.on(o.ParticipantConnected, Q);
646
639
  }))
647
640
  throw n("Agent did not join within timeout"), await u.disconnect(), new Error("Agent did not rejoin the room");
648
641
  n("Agent joined");
649
642
  }
650
- (g = i.onConnectionStateChange) == null || g.call(i, S.Connected);
651
- } catch (D) {
652
- throw n("Failed to reconnect:", D), (v = i.onConnectionStateChange) == null || v.call(i, S.Fail), D;
643
+ } catch (v) {
644
+ throw n("Failed to reconnect:", v), (g = a.onConnectionStateChange) == null || g.call(a, R.Fail), v;
653
645
  }
654
646
  },
655
647
  sendDataChannelMessage: he,
656
648
  sendTextMessage: pe,
657
649
  publishMicrophoneStream: m,
658
650
  unpublishMicrophoneStream: h,
659
- sessionId: E,
660
- streamId: E,
651
+ sessionId: M,
652
+ streamId: M,
661
653
  streamType: $,
662
654
  interruptAvailable: !0,
663
655
  triggersAvailable: !1
664
656
  };
665
657
  }
666
- const At = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
658
+ const _t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
667
659
  __proto__: null,
668
660
  DataChannelTopic: Ae,
669
- createLiveKitStreamingManager: _t,
661
+ createLiveKitStreamingManager: Tt,
670
662
  handleInitError: De
671
663
  }, Symbol.toStringTag, { value: "Module" }));
672
- function Pt(e, t, a) {
664
+ function At(e, t, i) {
673
665
  if (!e)
674
666
  throw new Error("Please connect to the agent first");
675
667
  if (!e.interruptAvailable)
676
668
  throw new Error("Interrupt is not enabled for this stream");
677
669
  if (t !== ae.Fluent)
678
670
  throw new Error("Interrupt only available for Fluent streams");
679
- if (!a)
671
+ if (!i)
680
672
  throw new Error("No active video to interrupt");
681
673
  }
682
- async function bt(e, t) {
683
- const a = {
674
+ async function Pt(e, t) {
675
+ const i = {
684
676
  type: j.StreamInterrupt,
685
677
  videoId: t,
686
678
  timestamp: Date.now()
687
679
  };
688
- e.sendDataChannelMessage(JSON.stringify(a));
680
+ e.sendDataChannelMessage(JSON.stringify(i));
689
681
  }
690
682
  async function Lt(e) {
691
683
  const t = {
@@ -693,42 +685,42 @@ async function Lt(e) {
693
685
  };
694
686
  e.sendDataChannelMessage(JSON.stringify(t));
695
687
  }
696
- function jt(e) {
697
- return new Promise((t, a) => {
698
- const { callbacks: n, host: s, auth: o, externalId: c } = e, { onMessage: i = null, onOpen: r = null, onClose: d = null, onError: w = null } = n || {}, p = new WebSocket(`${s}?authorization=${encodeURIComponent(Oe(o, c))}`);
699
- p.onmessage = i, p.onclose = d, p.onerror = (u) => {
700
- console.error(u), w == null || w("Websocket failed to connect", u), a(u);
688
+ function bt(e) {
689
+ return new Promise((t, i) => {
690
+ const { callbacks: n, host: s, auth: o, externalId: c } = e, { onMessage: a = null, onOpen: r = null, onClose: d = null, onError: w = null } = n || {}, p = new WebSocket(`${s}?authorization=${encodeURIComponent(We(o, c))}`);
691
+ p.onmessage = a, p.onclose = d, p.onerror = (u) => {
692
+ console.error(u), w == null || w("Websocket failed to connect", u), i(u);
701
693
  }, p.onopen = (u) => {
702
694
  r == null || r(u), t(p);
703
695
  };
704
696
  });
705
697
  }
706
- async function $t(e) {
698
+ async function jt(e) {
707
699
  const { retries: t = 1 } = e;
708
- let a = null;
709
- for (let n = 0; (a == null ? void 0 : a.readyState) !== WebSocket.OPEN; n++)
700
+ let i = null;
701
+ for (let n = 0; (i == null ? void 0 : i.readyState) !== WebSocket.OPEN; n++)
710
702
  try {
711
- a = await jt(e);
703
+ i = await bt(e);
712
704
  } catch (s) {
713
705
  if (n === t)
714
706
  throw s;
715
- await Ue(n * 500);
707
+ await Je(n * 500);
716
708
  }
717
- return a;
709
+ return i;
718
710
  }
719
- async function xt(e, t, a, n) {
720
- const s = a != null && a.onMessage ? [a.onMessage] : [], o = await $t({
711
+ async function $t(e, t, i, n) {
712
+ const s = i != null && i.onMessage ? [i.onMessage] : [], o = await jt({
721
713
  auth: e,
722
714
  host: t,
723
715
  externalId: n,
724
716
  callbacks: {
725
717
  onError: (c) => {
726
- var i;
727
- return (i = a.onError) == null ? void 0 : i.call(a, new et(c));
718
+ var a;
719
+ return (a = i.onError) == null ? void 0 : a.call(i, new Ze(c));
728
720
  },
729
721
  onMessage(c) {
730
- const i = JSON.parse(c.data);
731
- s.forEach((r) => r(i.event, i));
722
+ const a = JSON.parse(c.data);
723
+ s.forEach((r) => r(a.event, a));
732
724
  }
733
725
  }
734
726
  });
@@ -741,12 +733,12 @@ async function xt(e, t, a, n) {
741
733
  function Bt(e) {
742
734
  if (e.answer !== void 0)
743
735
  return e.answer;
744
- let t = 0, a = "";
736
+ let t = 0, i = "";
745
737
  for (; t in e; )
746
- a += e[t++];
747
- return a;
738
+ i += e[t++];
739
+ return i;
748
740
  }
749
- function Ft(e, t, a) {
741
+ function xt(e, t, i) {
750
742
  if (!e.content)
751
743
  return;
752
744
  const n = t.messages[t.messages.length - 1];
@@ -758,19 +750,19 @@ function Ft(e, t, a) {
758
750
  created_at: e.created_at || (/* @__PURE__ */ new Date()).toISOString(),
759
751
  transcribed: !0
760
752
  };
761
- t.messages.push(s), a == null || a([...t.messages], "user");
753
+ t.messages.push(s), i == null || i([...t.messages], "user");
762
754
  }
763
- function Nt(e, t, a, n, s) {
764
- if (e === Y.Transcribe && t.content) {
765
- Ft(t, n, s);
755
+ function Ft(e, t, i, n, s) {
756
+ if (e === X.Transcribe && t.content) {
757
+ xt(t, n, s);
766
758
  return;
767
759
  }
768
- if (!(e === Y.Partial || e === Y.Answer))
760
+ if (!(e === X.Partial || e === X.Answer))
769
761
  return;
770
762
  const o = n.messages[n.messages.length - 1];
771
763
  let c;
772
764
  if (o != null && o.transcribed && o.role === "user")
773
- e === Y.Answer && t.content, c = {
765
+ e === X.Answer && t.content, c = {
774
766
  id: t.id || `assistant-${Date.now()}`,
775
767
  role: t.role || "assistant",
776
768
  content: t.content || "",
@@ -780,70 +772,70 @@ function Nt(e, t, a, n, s) {
780
772
  c = o;
781
773
  else
782
774
  return;
783
- const { content: i, sequence: r } = t;
784
- e === Y.Partial ? a[r] = i : a.answer = i;
785
- const d = Bt(a);
786
- (c.content !== d || e === Y.Answer) && (c.content = d, s == null || s([...n.messages], e));
775
+ const { content: a, sequence: r } = t;
776
+ e === X.Partial ? i[r] = a : i.answer = a;
777
+ const d = Bt(i);
778
+ (c.content !== d || e === X.Answer) && (c.content = d, s == null || s([...n.messages], e));
787
779
  }
788
- function zt(e, t, a, n, s) {
780
+ function zt(e, t, i, n, s) {
789
781
  let o = {};
790
- const c = () => o = {}, i = (r, d) => {
782
+ const c = () => o = {}, a = (r, d) => {
791
783
  var w, p;
792
- d === "user" && c(), (p = (w = a.callbacks).onNewMessage) == null || p.call(w, r, d);
784
+ d === "user" && c(), (p = (w = i.callbacks).onNewMessage) == null || p.call(w, r, d);
793
785
  };
794
786
  return {
795
787
  clearQueue: c,
796
788
  onMessage: (r, d) => {
797
789
  var w, p;
798
790
  if ("content" in d) {
799
- const u = r === j.ChatAnswer ? Y.Answer : r === j.ChatAudioTranscribed ? Y.Transcribe : r;
800
- Nt(u, d, o, t, i), u === Y.Answer && e.track("agent-message-received", {
791
+ const u = r === j.ChatAnswer ? X.Answer : r === j.ChatAudioTranscribed ? X.Transcribe : r;
792
+ Ft(u, d, o, t, a), u === X.Answer && e.track("agent-message-received", {
801
793
  messages: t.messages.length,
802
794
  mode: t.chatMode
803
795
  });
804
796
  } else {
805
- const u = j, P = [u.StreamVideoDone, u.StreamVideoError, u.StreamVideoRejected], $ = [u.StreamFailed, u.StreamVideoError, u.StreamVideoRejected], B = kt(d, n, { mode: t.chatMode });
797
+ const u = j, _ = [u.StreamVideoDone, u.StreamVideoError, u.StreamVideoRejected], $ = [u.StreamFailed, u.StreamVideoError, u.StreamVideoRejected], A = St(d, n, { mode: t.chatMode });
806
798
  if (r = r, r === u.StreamVideoCreated)
807
- e.linkTrack("agent-video", B, u.StreamVideoCreated, ["start"]);
808
- else if (P.includes(r)) {
809
- const R = r.split("/")[1];
810
- $.includes(r) ? e.track("agent-video", { ...B, event: R }) : e.linkTrack("agent-video", { ...B, event: R }, r, ["done"]);
799
+ e.linkTrack("agent-video", A, u.StreamVideoCreated, ["start"]);
800
+ else if (_.includes(r)) {
801
+ const C = r.split("/")[1];
802
+ $.includes(r) ? e.track("agent-video", { ...A, event: C }) : e.linkTrack("agent-video", { ...A, event: C }, r, ["done"]);
811
803
  }
812
- $.includes(r) && ((p = (w = a.callbacks).onError) == null || p.call(w, new Error(`Stream failed with event ${r}`), { data: d })), d.event === u.StreamDone && s();
804
+ $.includes(r) && ((p = (w = i.callbacks).onError) == null || p.call(w, new Error(`Stream failed with event ${r}`), { data: d })), d.event === u.StreamDone && s();
813
805
  }
814
806
  }
815
807
  };
816
808
  }
817
- function Kt(e, t, a, n) {
818
- const s = Te(e, `${t}/agents/${a}`, n);
809
+ function Nt(e, t, i, n) {
810
+ const s = Te(e, `${t}/agents/${i}`, n);
819
811
  return {
820
812
  createStream(o, c) {
821
813
  return s.post("/streams", o, { signal: c });
822
814
  },
823
- startConnection(o, c, i, r) {
815
+ startConnection(o, c, a, r) {
824
816
  return s.post(
825
817
  `/streams/${o}/sdp`,
826
818
  {
827
- session_id: i,
819
+ session_id: a,
828
820
  answer: c
829
821
  },
830
822
  { signal: r }
831
823
  );
832
824
  },
833
- addIceCandidate(o, c, i, r) {
825
+ addIceCandidate(o, c, a, r) {
834
826
  return s.post(
835
827
  `/streams/${o}/ice`,
836
828
  {
837
- session_id: i,
829
+ session_id: a,
838
830
  ...c
839
831
  },
840
832
  { signal: r }
841
833
  );
842
834
  },
843
- sendStreamRequest(o, c, i) {
835
+ sendStreamRequest(o, c, a) {
844
836
  return s.post(`/streams/${o}`, {
845
837
  session_id: c,
846
- ...i
838
+ ...a
847
839
  });
848
840
  },
849
841
  close(o, c) {
@@ -851,7 +843,7 @@ function Kt(e, t, a, n) {
851
843
  }
852
844
  };
853
845
  }
854
- function Jt(e, t, a) {
846
+ function Kt(e, t, i) {
855
847
  const n = (t.timestamp - e.timestamp) / 1e3;
856
848
  return {
857
849
  duration: n,
@@ -868,31 +860,31 @@ function Jt(e, t, a) {
868
860
  framesPerSecond: t.framesPerSecond,
869
861
  freezeCount: t.freezeCount - e.freezeCount,
870
862
  freezeDuration: t.freezeDuration - e.freezeDuration,
871
- lowFpsCount: a
863
+ lowFpsCount: i
872
864
  };
873
865
  }
874
- function Ut(e) {
866
+ function Jt(e) {
875
867
  return e.filter(
876
868
  (t) => t.freezeCount > 0 || t.framesPerSecond < 21 || t.framesDropped > 0 || t.packetsLost > 0
877
869
  ).map((t) => {
878
- const { timestamp: a, ...n } = t, s = [];
870
+ const { timestamp: i, ...n } = t, s = [];
879
871
  return t.freezeCount > 0 && s.push("freeze"), t.framesPerSecond < 21 && s.push("low fps"), t.framesDropped > 0 && s.push("frames dropped"), t.packetsLost > 0 && s.push("packet loss"), {
880
872
  ...n,
881
873
  causes: s
882
874
  };
883
875
  });
884
876
  }
885
- function Wt(e) {
886
- let t = "", a = 0;
877
+ function Ut(e) {
878
+ let t = "", i = 0;
887
879
  for (const n of e.values()) {
888
880
  if (n && n.type === "codec" && n.mimeType.startsWith("video") && (t = n.mimeType.split("/")[1]), n && n.type === "candidate-pair") {
889
881
  const s = n.currentRoundTripTime, c = n.nominated === !0;
890
- s > 0 && (c || a === 0) && (a = s);
882
+ s > 0 && (c || i === 0) && (i = s);
891
883
  }
892
884
  if (n && n.type === "inbound-rtp" && n.kind === "video")
893
885
  return {
894
886
  codec: t,
895
- rtt: a,
887
+ rtt: i,
896
888
  timestamp: n.timestamp,
897
889
  bytesReceived: n.bytesReceived,
898
890
  packetsReceived: n.packetsReceived,
@@ -912,24 +904,24 @@ function Wt(e) {
912
904
  }
913
905
  return {};
914
906
  }
915
- function Vt(e, t, a) {
916
- const n = e.map((r, d) => d === 0 ? a ? {
907
+ function Vt(e, t, i) {
908
+ const n = e.map((r, d) => d === 0 ? i ? {
917
909
  timestamp: r.timestamp,
918
910
  duration: 0,
919
911
  rtt: r.rtt,
920
- bytesReceived: r.bytesReceived - a.bytesReceived,
921
- bitrate: (r.bytesReceived - a.bytesReceived) * 8 / (t / 1e3),
922
- packetsReceived: r.packetsReceived - a.packetsReceived,
923
- packetsLost: r.packetsLost - a.packetsLost,
924
- framesDropped: r.framesDropped - a.framesDropped,
925
- framesDecoded: r.framesDecoded - a.framesDecoded,
912
+ bytesReceived: r.bytesReceived - i.bytesReceived,
913
+ bitrate: (r.bytesReceived - i.bytesReceived) * 8 / (t / 1e3),
914
+ packetsReceived: r.packetsReceived - i.packetsReceived,
915
+ packetsLost: r.packetsLost - i.packetsLost,
916
+ framesDropped: r.framesDropped - i.framesDropped,
917
+ framesDecoded: r.framesDecoded - i.framesDecoded,
926
918
  jitter: r.jitter,
927
- jitterBufferDelay: r.jitterBufferDelay - a.jitterBufferDelay,
928
- jitterBufferEmittedCount: r.jitterBufferEmittedCount - a.jitterBufferEmittedCount,
929
- avgJitterDelayInInterval: (r.jitterBufferDelay - a.jitterBufferDelay) / (r.jitterBufferEmittedCount - a.jitterBufferEmittedCount),
919
+ jitterBufferDelay: r.jitterBufferDelay - i.jitterBufferDelay,
920
+ jitterBufferEmittedCount: r.jitterBufferEmittedCount - i.jitterBufferEmittedCount,
921
+ avgJitterDelayInInterval: (r.jitterBufferDelay - i.jitterBufferDelay) / (r.jitterBufferEmittedCount - i.jitterBufferEmittedCount),
930
922
  framesPerSecond: r.framesPerSecond,
931
- freezeCount: r.freezeCount - a.freezeCount,
932
- freezeDuration: r.freezeDuration - a.freezeDuration
923
+ freezeCount: r.freezeCount - i.freezeCount,
924
+ freezeDuration: r.freezeDuration - i.freezeDuration
933
925
  } : {
934
926
  timestamp: r.timestamp,
935
927
  rtt: r.rtt,
@@ -964,156 +956,161 @@ function Vt(e, t, a) {
964
956
  framesPerSecond: r.framesPerSecond,
965
957
  freezeCount: r.freezeCount - e[d - 1].freezeCount,
966
958
  freezeDuration: r.freezeDuration - e[d - 1].freezeDuration
967
- }), s = Ut(n), o = s.reduce((r, d) => r + (d.causes.includes("low fps") ? 1 : 0), 0), c = n.filter((r) => !!r.avgJitterDelayInInterval).map((r) => r.avgJitterDelayInInterval), i = n.filter((r) => !!r.rtt).map((r) => r.rtt);
959
+ }), s = Jt(n), o = s.reduce((r, d) => r + (d.causes.includes("low fps") ? 1 : 0), 0), c = n.filter((r) => !!r.avgJitterDelayInInterval).map((r) => r.avgJitterDelayInInterval), a = n.filter((r) => !!r.rtt).map((r) => r.rtt);
968
960
  return {
969
961
  webRTCStats: {
970
962
  anomalies: s,
971
- minRtt: Math.min(...i),
972
- avgRtt: xe(i),
973
- maxRtt: Math.max(...i),
974
- aggregateReport: Jt(e[0], e[e.length - 1], o),
963
+ minRtt: Math.min(...a),
964
+ avgRtt: $e(a),
965
+ maxRtt: Math.max(...a),
966
+ aggregateReport: Kt(e[0], e[e.length - 1], o),
975
967
  minJitterDelayInInterval: Math.min(...c),
976
968
  maxJitterDelayInInterval: Math.max(...c),
977
- avgJitterDelayInInterval: xe(c)
969
+ avgJitterDelayInInterval: $e(c)
978
970
  },
979
971
  codec: e[0].codec,
980
972
  resolution: `${e[0].frameWidth}x${e[0].frameHeight}`
981
973
  };
982
974
  }
983
- const Me = 100, Ot = Math.max(Math.ceil(400 / Me), 1), qt = 0.25, Ht = 0.28;
984
- function Qt() {
985
- let e = 0, t, a, n = 0;
975
+ const Me = 100, Wt = Math.max(Math.ceil(400 / Me), 1), Ot = 0.25, Ht = 0.28;
976
+ function qt() {
977
+ let e = 0, t, i, n = 0;
986
978
  return (s) => {
987
979
  for (const o of s.values())
988
980
  if (o && o.type === "inbound-rtp" && o.kind === "video") {
989
- const c = o.jitterBufferDelay, i = o.jitterBufferEmittedCount;
990
- if (a && i > a) {
991
- const w = c - t, p = i - a;
981
+ const c = o.jitterBufferDelay, a = o.jitterBufferEmittedCount;
982
+ if (i && a > i) {
983
+ const w = c - t, p = a - i;
992
984
  n = w / p;
993
985
  }
994
- t = c, a = i;
986
+ t = c, i = a;
995
987
  const r = o.framesDecoded, d = r - e > 0;
996
988
  return e = r, { isReceiving: d, avgJitterDelayInInterval: n, freezeCount: o.freezeCount };
997
989
  }
998
990
  return { isReceiving: !1, avgJitterDelayInInterval: n };
999
991
  };
1000
992
  }
1001
- function Xt(e, t, a, n, s) {
1002
- let o = [], c, i = 0, r = !1, d = ie.Unknown, w = ie.Unknown, p = 0, u = 0;
1003
- const P = Qt();
993
+ function Qt(e, t, i, n, s) {
994
+ let o = [], c, a = 0, r = !1, d = ie.Unknown, w = ie.Unknown, p = 0, u = 0;
995
+ const _ = qt();
1004
996
  return setInterval(async () => {
1005
- const $ = await e.getStats(), { isReceiving: B, avgJitterDelayInInterval: R, freezeCount: M } = P($), z = Wt($);
1006
- if (B)
1007
- i = 0, p = M - u, w = R < qt ? ie.Strong : R > Ht && p > 1 ? ie.Weak : d, w !== d && (s == null || s(w), d = w, u += p, p = 0), r || (n == null || n(C.Start), c = o[o.length - 1], o = [], r = !0), o.push(z);
1008
- else if (r && (i++, i >= Ot)) {
1009
- const T = Vt(o, Me, c);
1010
- n == null || n(C.Stop, T), t() || a(), u = M, r = !1;
997
+ const $ = await e.getStats(), { isReceiving: A, avgJitterDelayInInterval: C, freezeCount: B } = _($), z = Ut($);
998
+ if (A)
999
+ a = 0, p = B - u, w = C < Ot ? ie.Strong : C > Ht && p > 1 ? ie.Weak : d, w !== d && (s == null || s(w), d = w, u += p, p = 0), r || (n == null || n(S.Start), c = o[o.length - 1], o = [], r = !0), o.push(z);
1000
+ else if (r && (a++, a >= Wt)) {
1001
+ const I = Vt(o, Me, c);
1002
+ n == null || n(S.Stop, I), t() || i(), u = B, r = !1;
1011
1003
  }
1012
1004
  }, Me);
1013
1005
  }
1014
- const Yt = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
1015
- function Ne(e) {
1006
+ const Xt = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
1007
+ function Fe(e) {
1016
1008
  switch (e) {
1017
1009
  case "connected":
1018
- return S.Connected;
1010
+ return R.Connected;
1019
1011
  case "checking":
1020
- return S.Connecting;
1012
+ return R.Connecting;
1021
1013
  case "failed":
1022
- return S.Fail;
1014
+ return R.Fail;
1023
1015
  case "new":
1024
- return S.New;
1016
+ return R.New;
1025
1017
  case "closed":
1026
- return S.Closed;
1018
+ return R.Closed;
1027
1019
  case "disconnected":
1028
- return S.Disconnected;
1020
+ return R.Disconnected;
1029
1021
  case "completed":
1030
- return S.Completed;
1022
+ return R.Completed;
1031
1023
  default:
1032
- return S.New;
1024
+ return R.New;
1033
1025
  }
1034
1026
  }
1035
- const Gt = (e) => (t) => {
1036
- const [a, n = ""] = t.split(/:(.+)/);
1027
+ const Yt = (e) => (t) => {
1028
+ const [i, n = ""] = t.split(/:(.+)/);
1037
1029
  try {
1038
1030
  const s = JSON.parse(n);
1039
- return e("parsed data channel message", { subject: a, data: s }), { subject: a, data: s };
1031
+ return e("parsed data channel message", { subject: i, data: s }), { subject: i, data: s };
1040
1032
  } catch (s) {
1041
- return e("Failed to parse data channel message, returning data as string", { subject: a, rawData: n, error: s }), { subject: a, data: n };
1033
+ return e("Failed to parse data channel message, returning data as string", { subject: i, rawData: n, error: s }), { subject: i, data: n };
1042
1034
  }
1043
1035
  };
1044
- function Zt({
1036
+ function Gt({
1045
1037
  statsSignal: e,
1046
1038
  dataChannelSignal: t,
1047
- onVideoStateChange: a,
1048
- report: n
1039
+ onVideoStateChange: i,
1040
+ report: n,
1041
+ log: s
1049
1042
  }) {
1050
- e === C.Start && t === C.Start ? a == null || a(C.Start) : e === C.Stop && t === C.Stop && (a == null || a(C.Stop, n));
1043
+ e === S.Start && t === S.Start ? (s("CALLBACK: onVideoStateChange(Start)"), i == null || i(S.Start)) : e === S.Stop && t === S.Stop && (s("CALLBACK: onVideoStateChange(Stop)"), i == null || i(S.Stop, n));
1051
1044
  }
1052
- function en({
1045
+ function Zt({
1053
1046
  statsSignal: e,
1054
1047
  dataChannelSignal: t,
1055
- onVideoStateChange: a,
1048
+ onVideoStateChange: i,
1056
1049
  onAgentActivityStateChange: n,
1057
- report: s
1050
+ report: s,
1051
+ log: o
1058
1052
  }) {
1059
- e === C.Start ? a == null || a(C.Start) : e === C.Stop && (a == null || a(C.Stop, s)), t === C.Start ? n == null || n(q.Talking) : t === C.Stop && (n == null || n(q.Idle));
1053
+ e === S.Start ? (o("CALLBACK: onVideoStateChange(Start)"), i == null || i(S.Start)) : e === S.Stop && (o("CALLBACK: onVideoStateChange(Stop)"), i == null || i(S.Stop, s)), t === S.Start ? n == null || n(W.Talking) : t === S.Stop && (n == null || n(W.Idle));
1060
1054
  }
1061
1055
  function ze({
1062
1056
  statsSignal: e,
1063
1057
  dataChannelSignal: t,
1064
- onVideoStateChange: a,
1058
+ onVideoStateChange: i,
1065
1059
  onAgentActivityStateChange: n,
1066
1060
  streamType: s,
1067
- report: o
1061
+ report: o,
1062
+ log: c
1068
1063
  }) {
1069
- s === ae.Legacy ? Zt({ statsSignal: e, dataChannelSignal: t, onVideoStateChange: a, report: o }) : s === ae.Fluent && en({
1064
+ s === ae.Legacy ? Gt({ statsSignal: e, dataChannelSignal: t, onVideoStateChange: i, report: o, log: c }) : s === ae.Fluent && Zt({
1070
1065
  statsSignal: e,
1071
1066
  dataChannelSignal: t,
1072
- onVideoStateChange: a,
1067
+ onVideoStateChange: i,
1073
1068
  onAgentActivityStateChange: n,
1074
- report: o
1069
+ report: o,
1070
+ log: c
1075
1071
  });
1076
1072
  }
1077
- async function tn(e, t, { debug: a = !1, callbacks: n, auth: s, baseURL: o = ge, analytics: c }, i) {
1073
+ async function en(e, t, { debug: i = !1, callbacks: n, auth: s, baseURL: o = ge, analytics: c }, a) {
1078
1074
  var V;
1079
- const r = Qe(a, "WebRTCStreamingManager"), d = Gt(r);
1080
- let w = !1, p = !1, u = C.Stop, P = C.Stop;
1081
- const { startConnection: $, sendStreamRequest: B, close: R, createStream: M, addIceCandidate: z } = Kt(
1075
+ const r = qe(i, "WebRTCStreamingManager"), d = Yt(r);
1076
+ let w = !1, p = !1, u = S.Stop, _ = S.Stop;
1077
+ const { startConnection: $, sendStreamRequest: A, close: C, createStream: B, addIceCandidate: z } = Nt(
1082
1078
  s,
1083
1079
  o,
1084
1080
  e,
1085
1081
  n.onError
1086
1082
  ), {
1087
- id: T,
1088
- offer: W,
1083
+ id: I,
1084
+ offer: U,
1089
1085
  ice_servers: te,
1090
- session_id: E,
1091
- fluent: G,
1086
+ session_id: M,
1087
+ fluent: Y,
1092
1088
  interrupt_enabled: Z,
1093
1089
  triggers_enabled: f
1094
- } = await M(t, i);
1095
- (V = n.onStreamCreated) == null || V.call(n, { stream_id: T, session_id: E, agent_id: e });
1096
- const y = new Yt({ iceServers: te }), k = y.createDataChannel("JanusDataChannel");
1097
- if (!E)
1090
+ } = await B(t, a);
1091
+ (V = n.onStreamCreated) == null || V.call(n, { stream_id: I, session_id: M, agent_id: e });
1092
+ const y = new Xt({ iceServers: te }), k = y.createDataChannel("JanusDataChannel");
1093
+ if (!M)
1098
1094
  throw new Error("Could not create session_id");
1099
- const _ = G ? ae.Fluent : ae.Legacy;
1095
+ const T = Y ? ae.Fluent : ae.Legacy;
1100
1096
  c.enrich({
1101
- "stream-type": _
1097
+ "stream-type": T
1102
1098
  });
1103
- const b = t.stream_warmup && !G, I = () => w, U = () => {
1099
+ const P = t.stream_warmup && !Y, E = () => w, J = () => {
1104
1100
  var m;
1105
- w = !0, p && ((m = n.onConnectionStateChange) == null || m.call(n, S.Connected));
1106
- }, H = Xt(
1101
+ w = !0, p && (r("CALLBACK: onConnectionStateChange(Connected)"), (m = n.onConnectionStateChange) == null || m.call(n, R.Connected));
1102
+ }, O = Qt(
1107
1103
  y,
1108
- I,
1109
- U,
1104
+ E,
1105
+ J,
1110
1106
  (m, h) => ze({
1111
- statsSignal: P = m,
1112
- dataChannelSignal: _ === ae.Legacy ? u : void 0,
1107
+ statsSignal: _ = m,
1108
+ dataChannelSignal: T === ae.Legacy ? u : void 0,
1113
1109
  onVideoStateChange: n.onVideoStateChange,
1114
1110
  onAgentActivityStateChange: n.onAgentActivityStateChange,
1115
1111
  report: h,
1116
- streamType: _
1112
+ streamType: T,
1113
+ log: r
1117
1114
  }),
1118
1115
  (m) => {
1119
1116
  var h;
@@ -1125,137 +1122,138 @@ async function tn(e, t, { debug: a = !1, callbacks: n, auth: s, baseURL: o = ge,
1125
1122
  r("peerConnection.onicecandidate", m);
1126
1123
  try {
1127
1124
  m.candidate && m.candidate.sdpMid && m.candidate.sdpMLineIndex !== null ? z(
1128
- T,
1125
+ I,
1129
1126
  {
1130
1127
  candidate: m.candidate.candidate,
1131
1128
  sdpMid: m.candidate.sdpMid,
1132
1129
  sdpMLineIndex: m.candidate.sdpMLineIndex
1133
1130
  },
1134
- E,
1135
- i
1136
- ) : z(T, { candidate: null }, E, i);
1137
- } catch (F) {
1138
- (h = n.onError) == null || h.call(n, F, { streamId: T });
1131
+ M,
1132
+ a
1133
+ ) : z(I, { candidate: null }, M, a);
1134
+ } catch (x) {
1135
+ (h = n.onError) == null || h.call(n, x, { streamId: I });
1139
1136
  }
1140
1137
  }, k.onopen = () => {
1141
- p = !0, (!b || w) && U();
1138
+ p = !0, (!P || w) && J();
1142
1139
  };
1143
- const Q = (m) => {
1140
+ const H = (m) => {
1144
1141
  var h;
1145
1142
  (h = n.onVideoIdChange) == null || h.call(n, m);
1146
1143
  };
1147
1144
  function L(m, h) {
1148
1145
  if (m === j.StreamStarted && typeof h == "object" && "metadata" in h) {
1149
- const F = h.metadata;
1150
- Q(F.videoId);
1146
+ const x = h.metadata;
1147
+ H(x.videoId);
1151
1148
  }
1152
- m === j.StreamDone && Q(null), u = m === j.StreamStarted ? C.Start : C.Stop, ze({
1153
- statsSignal: _ === ae.Legacy ? P : void 0,
1149
+ m === j.StreamDone && H(null), u = m === j.StreamStarted ? S.Start : S.Stop, ze({
1150
+ statsSignal: T === ae.Legacy ? _ : void 0,
1154
1151
  dataChannelSignal: u,
1155
1152
  onVideoStateChange: n.onVideoStateChange,
1156
1153
  onAgentActivityStateChange: n.onAgentActivityStateChange,
1157
- streamType: _
1154
+ streamType: T,
1155
+ log: r
1158
1156
  });
1159
1157
  }
1160
- function K(m, h) {
1161
- var J;
1162
- const F = typeof h == "string" ? h : h == null ? void 0 : h.metadata;
1163
- F && c.enrich({ streamMetadata: F }), (J = n.onStreamReady) == null || J.call(n);
1158
+ function N(m, h) {
1159
+ var K;
1160
+ const x = typeof h == "string" ? h : h == null ? void 0 : h.metadata;
1161
+ x && c.enrich({ streamMetadata: x }), (K = n.onStreamReady) == null || K.call(n);
1164
1162
  }
1165
- const X = {
1163
+ const q = {
1166
1164
  [j.StreamStarted]: L,
1167
1165
  [j.StreamDone]: L,
1168
- [j.StreamReady]: K
1166
+ [j.StreamReady]: N
1169
1167
  };
1170
1168
  k.onmessage = (m) => {
1171
- var J;
1172
- const { subject: h, data: F } = d(m.data);
1173
- (J = X[h]) == null || J.call(X, h, F);
1169
+ var K;
1170
+ const { subject: h, data: x } = d(m.data);
1171
+ (K = q[h]) == null || K.call(q, h, x);
1174
1172
  }, y.oniceconnectionstatechange = () => {
1175
1173
  var h;
1176
1174
  r("peerConnection.oniceconnectionstatechange => " + y.iceConnectionState);
1177
- const m = Ne(y.iceConnectionState);
1178
- m !== S.Connected && ((h = n.onConnectionStateChange) == null || h.call(n, m));
1175
+ const m = Fe(y.iceConnectionState);
1176
+ m !== R.Connected && ((h = n.onConnectionStateChange) == null || h.call(n, m));
1179
1177
  }, y.ontrack = (m) => {
1180
1178
  var h;
1181
- r("peerConnection.ontrack", m), (h = n.onSrcObjectReady) == null || h.call(n, m.streams[0]);
1182
- }, await y.setRemoteDescription(W), r("set remote description OK");
1179
+ r("peerConnection.ontrack", m), r("CALLBACK: onSrcObjectReady"), (h = n.onSrcObjectReady) == null || h.call(n, m.streams[0]);
1180
+ }, await y.setRemoteDescription(U), r("set remote description OK");
1183
1181
  const oe = await y.createAnswer();
1184
- return r("create answer OK"), await y.setLocalDescription(oe), r("set local description OK"), await $(T, oe, E, i), r("start connection OK"), {
1182
+ return r("create answer OK"), await y.setLocalDescription(oe), r("set local description OK"), await $(I, oe, M, a), r("start connection OK"), {
1185
1183
  /**
1186
1184
  * Method to send request to server to get clip or talk depend on you payload
1187
1185
  * @param payload
1188
1186
  */
1189
1187
  speak(m) {
1190
- return B(T, E, m);
1188
+ return A(I, M, m);
1191
1189
  },
1192
1190
  /**
1193
1191
  * Method to close RTC connection
1194
1192
  */
1195
1193
  async disconnect() {
1196
1194
  var m;
1197
- if (T) {
1198
- const h = Ne(y.iceConnectionState);
1195
+ if (I) {
1196
+ const h = Fe(y.iceConnectionState);
1199
1197
  if (y) {
1200
- if (h === S.New) {
1201
- clearInterval(H);
1198
+ if (h === R.New) {
1199
+ clearInterval(O);
1202
1200
  return;
1203
1201
  }
1204
1202
  y.close(), y.oniceconnectionstatechange = null, y.onnegotiationneeded = null, y.onicecandidate = null, y.ontrack = null;
1205
1203
  }
1206
1204
  try {
1207
- h === S.Connected && await R(T, E).catch((F) => {
1205
+ h === R.Connected && await C(I, M).catch((x) => {
1208
1206
  });
1209
- } catch (F) {
1210
- r("Error on close stream connection", F);
1207
+ } catch (x) {
1208
+ r("Error on close stream connection", x);
1211
1209
  }
1212
- (m = n.onAgentActivityStateChange) == null || m.call(n, q.Idle), clearInterval(H);
1210
+ (m = n.onAgentActivityStateChange) == null || m.call(n, W.Idle), clearInterval(O);
1213
1211
  }
1214
1212
  },
1215
1213
  /**
1216
1214
  * Method to send data channel messages to the server
1217
1215
  */
1218
1216
  sendDataChannelMessage(m) {
1219
- var h, F;
1217
+ var h, x;
1220
1218
  if (!w || k.readyState !== "open") {
1221
1219
  r("Data channel is not ready for sending messages"), (h = n.onError) == null || h.call(n, new Error("Data channel is not ready for sending messages"), {
1222
- streamId: T
1220
+ streamId: I
1223
1221
  });
1224
1222
  return;
1225
1223
  }
1226
1224
  try {
1227
1225
  k.send(m);
1228
- } catch (J) {
1229
- r("Error sending data channel message", J), (F = n.onError) == null || F.call(n, J, { streamId: T });
1226
+ } catch (K) {
1227
+ r("Error sending data channel message", K), (x = n.onError) == null || x.call(n, K, { streamId: I });
1230
1228
  }
1231
1229
  },
1232
1230
  /**
1233
1231
  * Session identifier information, should be returned in the body of all streaming requests
1234
1232
  */
1235
- sessionId: E,
1233
+ sessionId: M,
1236
1234
  /**
1237
1235
  * Id of current RTC stream
1238
1236
  */
1239
- streamId: T,
1240
- streamType: _,
1237
+ streamId: I,
1238
+ streamType: T,
1241
1239
  interruptAvailable: Z ?? !1,
1242
1240
  triggersAvailable: f ?? !1
1243
1241
  };
1244
1242
  }
1245
1243
  var Ee = /* @__PURE__ */ ((e) => (e.V1 = "v1", e.V2 = "v2", e))(Ee || {});
1246
- async function nn(e, t, a, n) {
1244
+ async function tn(e, t, i, n) {
1247
1245
  const s = e.id;
1248
1246
  switch (t.version) {
1249
1247
  case "v1": {
1250
1248
  const { version: o, ...c } = t;
1251
- return tn(s, c, a, n);
1249
+ return en(s, c, i, n);
1252
1250
  }
1253
1251
  case "v2": {
1254
1252
  const { version: o, ...c } = t;
1255
1253
  switch (c.transport_provider) {
1256
1254
  case ye.Livekit:
1257
- const { createLiveKitStreamingManager: i } = await Promise.resolve().then(() => At);
1258
- return i(s, c, a);
1255
+ const { createLiveKitStreamingManager: a } = await Promise.resolve().then(() => _t);
1256
+ return a(s, c, i);
1259
1257
  default:
1260
1258
  throw new Error(`Unsupported transport provider: ${c.transport_provider}`);
1261
1259
  }
@@ -1264,15 +1262,15 @@ async function nn(e, t, a, n) {
1264
1262
  throw new Error(`Invalid stream version: ${t.version}`);
1265
1263
  }
1266
1264
  }
1267
- const rn = "cht";
1268
- function an() {
1265
+ const nn = "cht";
1266
+ function rn() {
1269
1267
  return {
1270
1268
  transport_provider: ye.Livekit
1271
1269
  };
1272
1270
  }
1273
- function on(e) {
1271
+ function an(e) {
1274
1272
  var s, o;
1275
- const { streamOptions: t } = e ?? {}, a = ((s = e == null ? void 0 : e.mixpanelAdditionalProperties) == null ? void 0 : s.plan) !== void 0 ? {
1273
+ const { streamOptions: t } = e ?? {}, i = ((s = e == null ? void 0 : e.mixpanelAdditionalProperties) == null ? void 0 : s.plan) !== void 0 ? {
1276
1274
  plan: (o = e.mixpanelAdditionalProperties) == null ? void 0 : o.plan
1277
1275
  } : void 0;
1278
1276
  return { ...{
@@ -1281,30 +1279,30 @@ function on(e) {
1281
1279
  stream_warmup: t == null ? void 0 : t.streamWarmup,
1282
1280
  compatibility_mode: t == null ? void 0 : t.compatibilityMode,
1283
1281
  fluent: t == null ? void 0 : t.fluent
1284
- }, ...a && { end_user_data: a } };
1282
+ }, ...i && { end_user_data: i } };
1285
1283
  }
1286
- function sn(e, t) {
1287
- return Ie(e.presenter.type) ? { version: Ee.V2, ...an() } : { version: Ee.V1, ...on(t) };
1284
+ function on(e, t) {
1285
+ return Ie(e.presenter.type) ? { version: Ee.V2, ...rn() } : { version: Ee.V1, ...an(t) };
1288
1286
  }
1289
- function cn(e, t, a, n, s) {
1290
- s === ae.Fluent ? dn(e, t, a, n, s) : ln(e, t, a, n, s);
1287
+ function sn(e, t, i, n, s) {
1288
+ s === ae.Fluent ? cn(e, t, i, n, s) : un(e, t, i, n, s);
1291
1289
  }
1292
- function dn(e, t, a, n, s) {
1293
- e === C.Start ? n.track("stream-session", { event: "start", "stream-type": s }) : e === C.Stop && n.track("stream-session", {
1290
+ function cn(e, t, i, n, s) {
1291
+ e === S.Start ? n.track("stream-session", { event: "start", "stream-type": s }) : e === S.Stop && n.track("stream-session", {
1294
1292
  event: "stop",
1295
1293
  is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
1296
1294
  background: t.presenter.type === "clip" && t.presenter.background,
1297
1295
  "stream-type": s,
1298
- ...a
1296
+ ...i
1299
1297
  });
1300
1298
  }
1301
- function un(e, t, a, n) {
1302
- ee.get() <= 0 || (e === C.Start ? a.linkTrack(
1299
+ function dn(e, t, i, n) {
1300
+ ee.get() <= 0 || (e === S.Start ? i.linkTrack(
1303
1301
  "agent-video",
1304
1302
  { event: "start", latency: ee.get(!0), "stream-type": n },
1305
1303
  "start",
1306
1304
  [j.StreamVideoCreated]
1307
- ) : e === C.Stop && a.linkTrack(
1305
+ ) : e === S.Stop && i.linkTrack(
1308
1306
  "agent-video",
1309
1307
  {
1310
1308
  event: "stop",
@@ -1316,123 +1314,123 @@ function un(e, t, a, n) {
1316
1314
  [j.StreamVideoDone]
1317
1315
  ));
1318
1316
  }
1319
- function ln(e, t, a, n, s) {
1320
- ee.get() <= 0 || (e === C.Start ? n.linkTrack(
1317
+ function un(e, t, i, n, s) {
1318
+ ee.get() <= 0 || (e === S.Start ? n.linkTrack(
1321
1319
  "agent-video",
1322
1320
  { event: "start", latency: ee.get(!0), "stream-type": s },
1323
1321
  "start",
1324
1322
  [j.StreamVideoCreated]
1325
- ) : e === C.Stop && n.linkTrack(
1323
+ ) : e === S.Stop && n.linkTrack(
1326
1324
  "agent-video",
1327
1325
  {
1328
1326
  event: "stop",
1329
1327
  is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
1330
1328
  background: t.presenter.type === "clip" && t.presenter.background,
1331
1329
  "stream-type": s,
1332
- ...a
1330
+ ...i
1333
1331
  },
1334
1332
  "done",
1335
1333
  [j.StreamVideoDone]
1336
1334
  ));
1337
1335
  }
1338
- function Ke(e, t, a, n) {
1339
- return ee.reset(), Fe.update(), new Promise(async (s, o) => {
1336
+ function Ne(e, t, i, n) {
1337
+ return ee.reset(), xe.update(), new Promise(async (s, o) => {
1340
1338
  try {
1341
- let c, i = !1;
1342
- const r = sn(e, t);
1343
- a.enrich({
1339
+ let c, a = !1;
1340
+ const r = on(e, t);
1341
+ i.enrich({
1344
1342
  "stream-version": r.version.toString()
1345
- }), c = await nn(
1343
+ }), c = await tn(
1346
1344
  e,
1347
1345
  r,
1348
1346
  {
1349
1347
  ...t,
1350
- analytics: a,
1348
+ analytics: i,
1351
1349
  callbacks: {
1352
1350
  ...t.callbacks,
1353
1351
  onConnectionStateChange: (d) => {
1354
1352
  var w, p;
1355
- (p = (w = t.callbacks).onConnectionStateChange) == null || p.call(w, d), d === S.Connected && (c ? s(c) : i = !0);
1353
+ (p = (w = t.callbacks).onConnectionStateChange) == null || p.call(w, d), d === R.Connected && (c ? s(c) : a = !0);
1356
1354
  },
1357
1355
  onVideoStateChange: (d, w) => {
1358
1356
  var p, u;
1359
- (u = (p = t.callbacks).onVideoStateChange) == null || u.call(p, d), cn(
1357
+ (u = (p = t.callbacks).onVideoStateChange) == null || u.call(p, d), sn(
1360
1358
  d,
1361
1359
  e,
1362
1360
  w,
1363
- a,
1361
+ i,
1364
1362
  c.streamType
1365
1363
  );
1366
1364
  },
1367
1365
  onAgentActivityStateChange: (d) => {
1368
1366
  var w, p;
1369
- (p = (w = t.callbacks).onAgentActivityStateChange) == null || p.call(w, d), d === q.Talking ? Re.update() : Re.reset(), un(
1370
- d === q.Talking ? C.Start : C.Stop,
1367
+ (p = (w = t.callbacks).onAgentActivityStateChange) == null || p.call(w, d), d === W.Talking ? Re.update() : Re.reset(), dn(
1368
+ d === W.Talking ? S.Start : S.Stop,
1371
1369
  e,
1372
- a,
1370
+ i,
1373
1371
  c.streamType
1374
1372
  );
1375
1373
  },
1376
1374
  onStreamReady: () => {
1377
- const d = Fe.get(!0);
1378
- a.track("agent-chat", { event: "ready", latency: d });
1375
+ const d = xe.get(!0);
1376
+ i.track("agent-chat", { event: "ready", latency: d });
1379
1377
  }
1380
1378
  }
1381
1379
  },
1382
1380
  n
1383
- ), i && s(c);
1381
+ ), a && s(c);
1384
1382
  } catch (c) {
1385
1383
  o(c);
1386
1384
  }
1387
1385
  });
1388
1386
  }
1389
- async function fn(e, t, a, n, s) {
1390
- var w, p, u, P;
1387
+ async function ln(e, t, i, n, s) {
1388
+ var w, p, u, _;
1391
1389
  const o = async () => {
1392
1390
  if (Ie(e.presenter.type)) {
1393
- const $ = await Ke(e, t, n), B = `${rn}_${$.sessionId}`, R = (/* @__PURE__ */ new Date()).toISOString();
1391
+ const $ = await Ne(e, t, n), A = `${nn}_${$.sessionId}`, C = (/* @__PURE__ */ new Date()).toISOString();
1394
1392
  return { chatResult: {
1395
- chatMode: N.Functional,
1393
+ chatMode: F.Functional,
1396
1394
  chat: {
1397
- id: B,
1395
+ id: A,
1398
1396
  agent_id: e.id,
1399
1397
  owner_id: e.owner_id ?? "",
1400
- created: R,
1401
- modified: R,
1402
- agent_id__created_at: R,
1403
- agent_id__modified_at: R,
1404
- chat_mode: N.Functional,
1398
+ created: C,
1399
+ modified: C,
1400
+ agent_id__created_at: C,
1401
+ agent_id__modified_at: C,
1402
+ chat_mode: F.Functional,
1405
1403
  messages: []
1406
1404
  }
1407
1405
  }, streamingManager: $ };
1408
1406
  } else {
1409
- const $ = new AbortController(), B = $.signal;
1410
- let R;
1407
+ const $ = new AbortController(), A = $.signal;
1408
+ let C;
1411
1409
  try {
1412
- const M = He(
1410
+ const B = He(
1413
1411
  e,
1414
- a,
1412
+ i,
1415
1413
  n,
1416
1414
  t.mode,
1417
1415
  t.persistentChat,
1418
1416
  s
1419
- ), z = Ke(e, t, n, B).then((te) => (R = te, te)), [T, W] = await Promise.all([M, z]);
1420
- return { chatResult: T, streamingManager: W };
1421
- } catch (M) {
1422
- throw $.abort(), R && await R.disconnect().catch(() => {
1423
- }), M;
1417
+ ), z = Ne(e, t, n, A).then((te) => (C = te, te)), [I, U] = await Promise.all([B, z]);
1418
+ return { chatResult: I, streamingManager: U };
1419
+ } catch (B) {
1420
+ throw $.abort(), C && await C.disconnect().catch(() => {
1421
+ }), B;
1424
1422
  }
1425
1423
  }
1426
- }, { chatResult: c, streamingManager: i } = await o(), { chat: r, chatMode: d } = c;
1427
- return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (p = (w = t.callbacks).onModeChange) == null || p.call(w, d), d !== N.Functional) ? ((P = (u = t.callbacks).onError) == null || P.call(u, new Ze(d)), i == null || i.disconnect(), { chat: r }) : { chat: r, streamingManager: i };
1424
+ }, { chatResult: c, streamingManager: a } = await o(), { chat: r, chatMode: d } = c;
1425
+ return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (p = (w = t.callbacks).onModeChange) == null || p.call(w, d), d !== F.Functional) ? ((_ = (u = t.callbacks).onError) == null || _.call(u, new Ge(d)), a == null || a.disconnect(), { chat: r }) : { chat: r, streamingManager: a };
1428
1426
  }
1429
- async function hn(e, t) {
1430
- var E, G, Z;
1431
- let a = !0, n = null;
1432
- const s = t.mixpanelKey || mt, o = t.wsURL || ft, c = t.baseURL || ge, i = t.mode || N.Functional, r = {
1427
+ async function gn(e, t) {
1428
+ var M, Y, Z;
1429
+ let i = !0, n = null;
1430
+ const s = t.mixpanelKey || ft, o = t.wsURL || lt, c = t.baseURL || ge, a = t.mode || F.Functional, r = {
1433
1431
  messages: [],
1434
- chatMode: i
1435
- }, d = Dt({
1432
+ chatMode: a
1433
+ }, d = Rt({
1436
1434
  token: s,
1437
1435
  agentId: e,
1438
1436
  isEnabled: t.enableAnalitics,
@@ -1442,9 +1440,9 @@ async function hn(e, t) {
1442
1440
  Be(() => {
1443
1441
  d.track("agent-sdk", { event: "init" }, w);
1444
1442
  });
1445
- const p = yt(t.auth, c, t.callbacks.onError, t.externalId), u = await p.getById(e), P = Ie(u.presenter.type);
1446
- d.enrich(St(u));
1447
- const { onMessage: $, clearQueue: B } = zt(
1443
+ const p = wt(t.auth, c, t.callbacks.onError, t.externalId), u = await p.getById(e), _ = Ie(u.presenter.type);
1444
+ d.enrich(vt(u));
1445
+ const { onMessage: $, clearQueue: A } = zt(
1448
1446
  d,
1449
1447
  r,
1450
1448
  t,
@@ -1454,40 +1452,40 @@ async function hn(e, t) {
1454
1452
  return (f = r.socketManager) == null ? void 0 : f.disconnect();
1455
1453
  }
1456
1454
  );
1457
- r.messages = Et(t.initialMessages), (G = (E = t.callbacks).onNewMessage) == null || G.call(E, [...r.messages], "answer");
1458
- const R = (f) => {
1455
+ r.messages = Mt(t.initialMessages), (Y = (M = t.callbacks).onNewMessage) == null || Y.call(M, [...r.messages], "answer");
1456
+ const C = (f) => {
1459
1457
  n = f;
1460
- }, M = ({ type: f }) => {
1461
- var k, _, b;
1458
+ }, B = ({ type: f }) => {
1459
+ var k, T, P;
1462
1460
  const y = r.messages[r.messages.length - 1];
1463
1461
  d.track("agent-video-interrupt", {
1464
1462
  type: f || "click",
1465
1463
  video_duration_to_interrupt: Re.get(!0),
1466
1464
  message_duration_to_interrupt: ee.get(!0)
1467
- }), y.interrupted = !0, (_ = (k = t.callbacks).onNewMessage) == null || _.call(k, [...r.messages], "answer"), P ? Lt(r.streamingManager) : (Pt(r.streamingManager, (b = r.streamingManager) == null ? void 0 : b.streamType, n), bt(r.streamingManager, n));
1465
+ }), y.interrupted = !0, (T = (k = t.callbacks).onNewMessage) == null || T.call(k, [...r.messages], "answer"), _ ? Lt(r.streamingManager) : (At(r.streamingManager, (P = r.streamingManager) == null ? void 0 : P.streamType, n), Pt(r.streamingManager, n));
1468
1466
  }, z = Date.now();
1469
1467
  Be(() => {
1470
- d.track("agent-sdk", { event: "loaded", ...vt(u) }, z);
1468
+ d.track("agent-sdk", { event: "loaded", ...yt(u) }, z);
1471
1469
  });
1472
- async function T(f) {
1473
- var U, H, Q, L, K, X, oe;
1474
- (H = (U = t.callbacks).onConnectionStateChange) == null || H.call(U, S.Connecting), ee.reset(), f && !a && (delete r.chat, (L = (Q = t.callbacks).onNewMessage) == null || L.call(Q, [...r.messages], "answer"));
1475
- const y = i === N.DirectPlayback || P ? Promise.resolve(void 0) : xt(
1470
+ async function I(f) {
1471
+ var J, O, H, L, N, q, oe;
1472
+ (O = (J = t.callbacks).onConnectionStateChange) == null || O.call(J, R.Connecting), ee.reset(), f && !i && (delete r.chat, (L = (H = t.callbacks).onNewMessage) == null || L.call(H, [...r.messages], "answer"));
1473
+ const y = a === F.DirectPlayback || _ ? Promise.resolve(void 0) : $t(
1476
1474
  t.auth,
1477
1475
  o,
1478
1476
  { onMessage: $, onError: t.callbacks.onError },
1479
1477
  t.externalId
1480
- ), k = Ce(
1481
- () => fn(
1478
+ ), k = Se(
1479
+ () => ln(
1482
1480
  u,
1483
1481
  {
1484
1482
  ...t,
1485
- mode: i,
1483
+ mode: a,
1486
1484
  callbacks: {
1487
1485
  ...t.callbacks,
1488
- onVideoIdChange: R,
1486
+ onVideoIdChange: C,
1489
1487
  onMessage: $,
1490
- onInterruptDetected: M
1488
+ onInterruptDetected: B
1491
1489
  }
1492
1490
  },
1493
1491
  p,
@@ -1496,28 +1494,28 @@ async function hn(e, t) {
1496
1494
  ),
1497
1495
  {
1498
1496
  limit: 3,
1499
- timeout: ut,
1497
+ timeout: dt,
1500
1498
  timeoutErrorMessage: "Timeout initializing the stream",
1501
1499
  shouldRetryFn: (V) => (V == null ? void 0 : V.message) !== "Could not connect" && V.status !== 429 && (V == null ? void 0 : V.message) !== "InsufficientCreditsError",
1502
1500
  delayMs: 1e3
1503
1501
  }
1504
1502
  ).catch((V) => {
1505
1503
  var m, h;
1506
- throw te(N.Maintenance), (h = (m = t.callbacks).onConnectionStateChange) == null || h.call(m, S.Fail), V;
1507
- }), [_, { streamingManager: b, chat: I }] = await Promise.all([y, k]);
1508
- I && I.id !== ((K = r.chat) == null ? void 0 : K.id) && ((oe = (X = t.callbacks).onNewChat) == null || oe.call(X, I.id)), r.streamingManager = b, r.socketManager = _, r.chat = I, a = !1, d.enrich({
1509
- chatId: I == null ? void 0 : I.id,
1510
- streamId: b == null ? void 0 : b.streamId,
1504
+ throw te(F.Maintenance), (h = (m = t.callbacks).onConnectionStateChange) == null || h.call(m, R.Fail), V;
1505
+ }), [T, { streamingManager: P, chat: E }] = await Promise.all([y, k]);
1506
+ E && E.id !== ((N = r.chat) == null ? void 0 : N.id) && ((oe = (q = t.callbacks).onNewChat) == null || oe.call(q, E.id)), r.streamingManager = P, r.socketManager = T, r.chat = E, i = !1, d.enrich({
1507
+ chatId: E == null ? void 0 : E.id,
1508
+ streamId: P == null ? void 0 : P.streamId,
1511
1509
  mode: r.chatMode
1512
- }), te((I == null ? void 0 : I.chat_mode) ?? i);
1510
+ }), te((E == null ? void 0 : E.chat_mode) ?? a);
1513
1511
  }
1514
- async function W() {
1515
- var f, y, k, _;
1516
- (f = r.socketManager) == null || f.disconnect(), await ((y = r.streamingManager) == null ? void 0 : y.disconnect()), delete r.streamingManager, delete r.socketManager, (_ = (k = t.callbacks).onConnectionStateChange) == null || _.call(k, S.Disconnected);
1512
+ async function U() {
1513
+ var f, y, k, T;
1514
+ (f = r.socketManager) == null || f.disconnect(), await ((y = r.streamingManager) == null ? void 0 : y.disconnect()), delete r.streamingManager, delete r.socketManager, (T = (k = t.callbacks).onConnectionStateChange) == null || T.call(k, R.Disconnected);
1517
1515
  }
1518
1516
  async function te(f) {
1519
1517
  var y, k;
1520
- f !== r.chatMode && (d.track("agent-mode-change", { mode: f }), r.chatMode = f, r.chatMode !== N.Functional && await W(), (k = (y = t.callbacks).onModeChange) == null || k.call(y, f));
1518
+ f !== r.chatMode && (d.track("agent-mode-change", { mode: f }), r.chatMode = f, r.chatMode !== F.Functional && await U(), (k = (y = t.callbacks).onModeChange) == null || k.call(y, f));
1521
1519
  }
1522
1520
  return {
1523
1521
  agent: u,
@@ -1538,31 +1536,31 @@ async function hn(e, t) {
1538
1536
  changeMode: te,
1539
1537
  enrichAnalytics: d.enrich,
1540
1538
  async connect() {
1541
- await T(!0), d.track("agent-chat", {
1539
+ await I(!0), d.track("agent-chat", {
1542
1540
  event: "connect",
1543
1541
  mode: r.chatMode
1544
1542
  });
1545
1543
  },
1546
1544
  async reconnect() {
1547
1545
  const f = r.streamingManager;
1548
- if (P && (f != null && f.reconnect)) {
1546
+ if (_ && (f != null && f.reconnect)) {
1549
1547
  try {
1550
1548
  await f.reconnect(), d.track("agent-chat", {
1551
1549
  event: "reconnect",
1552
1550
  mode: r.chatMode
1553
1551
  });
1554
1552
  } catch {
1555
- await W(), await T(!1);
1553
+ await U(), await I(!1);
1556
1554
  }
1557
1555
  return;
1558
1556
  }
1559
- await W(), await T(!1), d.track("agent-chat", {
1557
+ await U(), await I(!1), d.track("agent-chat", {
1560
1558
  event: "reconnect",
1561
1559
  mode: r.chatMode
1562
1560
  });
1563
1561
  },
1564
1562
  async disconnect() {
1565
- await W(), d.track("agent-chat", {
1563
+ await U(), d.track("agent-chat", {
1566
1564
  event: "disconnect",
1567
1565
  mode: r.chatMode
1568
1566
  });
@@ -1580,122 +1578,122 @@ async function hn(e, t) {
1580
1578
  return r.streamingManager.unpublishMicrophoneStream();
1581
1579
  },
1582
1580
  async chat(f) {
1583
- var b, I, U, H, Q;
1581
+ var P, E, J, O, H;
1584
1582
  const y = () => {
1585
- if (Ve(i))
1586
- throw new de(`${i} is enabled, chat is disabled`);
1583
+ if (Ve(a))
1584
+ throw new ue(`${a} is enabled, chat is disabled`);
1587
1585
  if (f.length >= 800)
1588
- throw new de("Message cannot be more than 800 characters");
1586
+ throw new ue("Message cannot be more than 800 characters");
1589
1587
  if (f.length === 0)
1590
- throw new de("Message cannot be empty");
1591
- if (r.chatMode === N.Maintenance)
1592
- throw new de("Chat is in maintenance mode");
1593
- if (![N.TextOnly, N.Playground].includes(r.chatMode)) {
1588
+ throw new ue("Message cannot be empty");
1589
+ if (r.chatMode === F.Maintenance)
1590
+ throw new ue("Chat is in maintenance mode");
1591
+ if (![F.TextOnly, F.Playground].includes(r.chatMode)) {
1594
1592
  if (!r.streamingManager)
1595
- throw new de("Streaming manager is not initialized");
1593
+ throw new ue("Streaming manager is not initialized");
1596
1594
  if (!r.chat)
1597
- throw new de("Chat is not initialized");
1595
+ throw new ue("Chat is not initialized");
1598
1596
  }
1599
1597
  }, k = async () => {
1600
- var L, K;
1598
+ var L, N;
1601
1599
  if (!r.chat) {
1602
- const X = await He(
1600
+ const q = await He(
1603
1601
  u,
1604
1602
  p,
1605
1603
  d,
1606
1604
  r.chatMode,
1607
1605
  t.persistentChat
1608
1606
  );
1609
- if (!X.chat)
1610
- throw new Ge(r.chatMode, !!t.persistentChat);
1611
- r.chat = X.chat, (K = (L = t.callbacks).onNewChat) == null || K.call(L, r.chat.id);
1607
+ if (!q.chat)
1608
+ throw new Ye(r.chatMode, !!t.persistentChat);
1609
+ r.chat = q.chat, (N = (L = t.callbacks).onNewChat) == null || N.call(L, r.chat.id);
1612
1610
  }
1613
1611
  return r.chat.id;
1614
- }, _ = async (L, K) => {
1615
- const X = r.chatMode === N.Playground;
1616
- return Ce(P && !X ? async () => {
1612
+ }, T = async (L, N) => {
1613
+ const q = r.chatMode === F.Playground;
1614
+ return Se(_ && !q ? async () => {
1617
1615
  var m, h;
1618
1616
  return await ((h = (m = r.streamingManager) == null ? void 0 : m.sendTextMessage) == null ? void 0 : h.call(m, f)), Promise.resolve({});
1619
1617
  } : async () => {
1620
1618
  var m, h;
1621
1619
  return p.chat(
1622
1620
  u.id,
1623
- K,
1621
+ N,
1624
1622
  {
1625
1623
  chatMode: r.chatMode,
1626
1624
  streamId: (m = r.streamingManager) == null ? void 0 : m.streamId,
1627
1625
  sessionId: (h = r.streamingManager) == null ? void 0 : h.sessionId,
1628
- messages: L.map(({ matches: F, ...J }) => J)
1626
+ messages: L.map(({ matches: x, ...K }) => K)
1629
1627
  },
1630
1628
  {
1631
- ...qe(r.chatMode),
1629
+ ...Oe(r.chatMode),
1632
1630
  skipErrorHandler: !0
1633
1631
  }
1634
1632
  );
1635
1633
  }, {
1636
1634
  limit: 2,
1637
1635
  shouldRetryFn: (m) => {
1638
- var J, he, pe, se;
1639
- const h = (J = m == null ? void 0 : m.message) == null ? void 0 : J.includes("missing or invalid session_id");
1640
- return !((he = m == null ? void 0 : m.message) == null ? void 0 : he.includes("Stream Error")) && !h ? ((se = (pe = t.callbacks).onError) == null || se.call(pe, m), !1) : !0;
1636
+ var K, he, pe, ce;
1637
+ const h = (K = m == null ? void 0 : m.message) == null ? void 0 : K.includes("missing or invalid session_id");
1638
+ return !((he = m == null ? void 0 : m.message) == null ? void 0 : he.includes("Stream Error")) && !h ? ((ce = (pe = t.callbacks).onError) == null || ce.call(pe, m), !1) : !0;
1641
1639
  },
1642
1640
  onRetry: async () => {
1643
- await W(), await T(!1);
1641
+ await U(), await I(!1);
1644
1642
  }
1645
1643
  });
1646
1644
  };
1647
1645
  try {
1648
- B(), y(), r.messages.push({
1649
- id: ue(),
1646
+ A(), y(), r.messages.push({
1647
+ id: le(),
1650
1648
  role: "user",
1651
1649
  content: f,
1652
1650
  created_at: new Date(ee.update()).toISOString()
1653
- }), (I = (b = t.callbacks).onNewMessage) == null || I.call(b, [...r.messages], "user");
1654
- const L = await k(), K = await _([...r.messages], L);
1651
+ }), (E = (P = t.callbacks).onNewMessage) == null || E.call(P, [...r.messages], "user");
1652
+ const L = await k(), N = await T([...r.messages], L);
1655
1653
  return r.messages.push({
1656
- id: ue(),
1654
+ id: le(),
1657
1655
  role: "assistant",
1658
- content: K.result || "",
1656
+ content: N.result || "",
1659
1657
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1660
- context: K.context,
1661
- matches: K.matches
1658
+ context: N.context,
1659
+ matches: N.matches
1662
1660
  }), d.track("agent-message-send", {
1663
1661
  event: "success",
1664
1662
  messages: r.messages.length + 1
1665
- }), K.result && ((H = (U = t.callbacks).onNewMessage) == null || H.call(U, [...r.messages], "answer"), d.track("agent-message-received", {
1663
+ }), N.result && ((O = (J = t.callbacks).onNewMessage) == null || O.call(J, [...r.messages], "answer"), d.track("agent-message-received", {
1666
1664
  latency: ee.get(!0),
1667
1665
  messages: r.messages.length
1668
- })), K;
1666
+ })), N;
1669
1667
  } catch (L) {
1670
- throw ((Q = r.messages[r.messages.length - 1]) == null ? void 0 : Q.role) === "assistant" && r.messages.pop(), d.track("agent-message-send", {
1668
+ throw ((H = r.messages[r.messages.length - 1]) == null ? void 0 : H.role) === "assistant" && r.messages.pop(), d.track("agent-message-send", {
1671
1669
  event: "error",
1672
1670
  messages: r.messages.length
1673
1671
  }), L;
1674
1672
  }
1675
1673
  },
1676
1674
  rate(f, y, k) {
1677
- var I, U, H, Q;
1678
- const _ = r.messages.find((L) => L.id === f);
1675
+ var E, J, O, H;
1676
+ const T = r.messages.find((L) => L.id === f);
1679
1677
  if (r.chat) {
1680
- if (!_)
1678
+ if (!T)
1681
1679
  throw new Error("Message not found");
1682
1680
  } else throw new Error("Chat is not initialized");
1683
- const b = ((I = _.matches) == null ? void 0 : I.map((L) => [L.document_id, L.id])) ?? [];
1681
+ const P = ((E = T.matches) == null ? void 0 : E.map((L) => [L.document_id, L.id])) ?? [];
1684
1682
  return d.track("agent-rate", {
1685
1683
  event: k ? "update" : "create",
1686
1684
  thumb: y === 1 ? "up" : "down",
1687
- knowledge_id: ((U = u.knowledge) == null ? void 0 : U.id) ?? "",
1688
- matches: b,
1685
+ knowledge_id: ((J = u.knowledge) == null ? void 0 : J.id) ?? "",
1686
+ matches: P,
1689
1687
  score: y
1690
1688
  }), k ? p.updateRating(u.id, r.chat.id, k, {
1691
- knowledge_id: ((H = u.knowledge) == null ? void 0 : H.id) ?? "",
1689
+ knowledge_id: ((O = u.knowledge) == null ? void 0 : O.id) ?? "",
1692
1690
  message_id: f,
1693
- matches: b,
1691
+ matches: P,
1694
1692
  score: y
1695
1693
  }) : p.createRating(u.id, r.chat.id, {
1696
- knowledge_id: ((Q = u.knowledge) == null ? void 0 : Q.id) ?? "",
1694
+ knowledge_id: ((H = u.knowledge) == null ? void 0 : H.id) ?? "",
1697
1695
  message_id: f,
1698
- matches: b,
1696
+ matches: P,
1699
1697
  score: y
1700
1698
  });
1701
1699
  },
@@ -1705,7 +1703,7 @@ async function hn(e, t) {
1705
1703
  return d.track("agent-rate-delete", { type: "text" }), p.deleteRating(u.id, r.chat.id, f);
1706
1704
  },
1707
1705
  async speak(f) {
1708
- var b, I, U;
1706
+ var P, E, J;
1709
1707
  function y() {
1710
1708
  if (typeof f == "string") {
1711
1709
  if (!u.presenter.voice)
@@ -1731,11 +1729,11 @@ async function hn(e, t) {
1731
1729
  }
1732
1730
  const k = y();
1733
1731
  if (d.track("agent-speak", k), ee.update(), r.messages && k.type === "text" && (r.messages.push({
1734
- id: ue(),
1732
+ id: le(),
1735
1733
  role: "assistant",
1736
1734
  content: k.input,
1737
1735
  created_at: (/* @__PURE__ */ new Date()).toISOString()
1738
- }), (I = (b = t.callbacks).onNewMessage) == null || I.call(b, [...r.messages], "answer")), gt(r.chatMode))
1736
+ }), (E = (P = t.callbacks).onNewMessage) == null || E.call(P, [...r.messages], "answer")), mt(r.chatMode))
1739
1737
  return {
1740
1738
  duration: 0,
1741
1739
  video_id: "",
@@ -1745,36 +1743,36 @@ async function hn(e, t) {
1745
1743
  throw new Error("Please connect to the agent first");
1746
1744
  return r.streamingManager.speak({
1747
1745
  script: k,
1748
- metadata: { chat_id: (U = r.chat) == null ? void 0 : U.id, agent_id: u.id }
1746
+ metadata: { chat_id: (J = r.chat) == null ? void 0 : J.id, agent_id: u.id }
1749
1747
  });
1750
1748
  },
1751
- interrupt: M
1749
+ interrupt: B
1752
1750
  };
1753
1751
  }
1754
1752
  export {
1755
- q as AgentActivityState,
1756
- rt as AgentStatus,
1757
- Ge as ChatCreationFailed,
1758
- N as ChatMode,
1759
- Ze as ChatModeDowngraded,
1760
- Y as ChatProgress,
1761
- S as ConnectionState,
1753
+ W as AgentActivityState,
1754
+ nt as AgentStatus,
1755
+ Ye as ChatCreationFailed,
1756
+ F as ChatMode,
1757
+ Ge as ChatModeDowngraded,
1758
+ X as ChatProgress,
1759
+ R as ConnectionState,
1762
1760
  ie as ConnectivityState,
1763
- st as DocumentType,
1764
- ot as KnowledgeType,
1765
- nt as PlanGroup,
1766
- ct as Providers,
1767
- it as RateState,
1761
+ ot as DocumentType,
1762
+ at as KnowledgeType,
1763
+ tt as PlanGroup,
1764
+ st as Providers,
1765
+ rt as RateState,
1768
1766
  j as StreamEvents,
1769
1767
  ae as StreamType,
1770
- C as StreamingState,
1771
- at as Subject,
1768
+ S as StreamingState,
1769
+ it as Subject,
1772
1770
  ye as TransportProvider,
1773
- tt as UserPlan,
1774
- de as ValidationError,
1775
- Je as VideoType,
1776
- dt as VoiceAccess,
1777
- et as WsError,
1778
- hn as createAgentManager,
1779
- gn as mapVideoType
1771
+ et as UserPlan,
1772
+ ue as ValidationError,
1773
+ Ke as VideoType,
1774
+ ct as VoiceAccess,
1775
+ Ze as WsError,
1776
+ gn as createAgentManager,
1777
+ mn as mapVideoType
1780
1778
  };