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

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