@telnyx/ai-agent-lib 0.2.2 → 0.2.4

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,5 +1,5 @@
1
- import ht, { useReducer as Tn, useEffect as pe, useDebugValue as An, useCallback as Rn, useContext as Gt, createContext as Wt, useState as xn } from "react";
2
- function Ht(t, e) {
1
+ import ut, { useReducer as En, useEffect as pe, useDebugValue as Tn, useCallback as An, useContext as Vt, createContext as Gt, useState as Rn } from "react";
2
+ function Wt(t, e) {
3
3
  var n = {};
4
4
  for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
5
5
  if (t != null && typeof Object.getOwnPropertySymbols == "function") {
@@ -8,62 +8,62 @@ function Ht(t, e) {
8
8
  }
9
9
  return n;
10
10
  }
11
- function L(t, e, n, i) {
12
- return new (n || (n = Promise))((function(s, r) {
11
+ function O(t, e, n, i) {
12
+ return new (n || (n = Promise))((function(s, a) {
13
13
  function o(h) {
14
14
  try {
15
- l(i.next(h));
15
+ d(i.next(h));
16
16
  } catch (f) {
17
- r(f);
17
+ a(f);
18
18
  }
19
19
  }
20
- function d(h) {
20
+ function l(h) {
21
21
  try {
22
- l(i.throw(h));
22
+ d(i.throw(h));
23
23
  } catch (f) {
24
- r(f);
24
+ a(f);
25
25
  }
26
26
  }
27
- function l(h) {
27
+ function d(h) {
28
28
  var f;
29
29
  h.done ? s(h.value) : (f = h.value, f instanceof n ? f : new n((function(v) {
30
30
  v(f);
31
- }))).then(o, d);
31
+ }))).then(o, l);
32
32
  }
33
- l((i = i.apply(t, [])).next());
33
+ d((i = i.apply(t, [])).next());
34
34
  }));
35
35
  }
36
- var vt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), On = new Uint8Array(16);
36
+ var gt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), xn = new Uint8Array(16);
37
37
  function Ln() {
38
- if (!vt) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
39
- return vt(On);
38
+ if (!gt) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
39
+ return gt(xn);
40
40
  }
41
- for (var qt = [], xe = 0; xe < 256; ++xe) qt[xe] = (xe + 256).toString(16).substr(1);
41
+ for (var Ht = [], xe = 0; xe < 256; ++xe) Ht[xe] = (xe + 256).toString(16).substr(1);
42
42
  function me(t, e, n) {
43
43
  var i = e && n || 0;
44
44
  typeof t == "string" && (e = t === "binary" ? new Array(16) : null, t = null);
45
45
  var s = (t = t || {}).random || (t.rng || Ln)();
46
- if (s[6] = 15 & s[6] | 64, s[8] = 63 & s[8] | 128, e) for (var r = 0; r < 16; ++r) e[i + r] = s[r];
47
- return e || (function(o, d) {
48
- var l = 0, h = qt;
49
- return [h[o[l++]], h[o[l++]], h[o[l++]], h[o[l++]], "-", h[o[l++]], h[o[l++]], "-", h[o[l++]], h[o[l++]], "-", h[o[l++]], h[o[l++]], "-", h[o[l++]], h[o[l++]], h[o[l++]], h[o[l++]], h[o[l++]], h[o[l++]]].join("");
46
+ if (s[6] = 15 & s[6] | 64, s[8] = 63 & s[8] | 128, e) for (var a = 0; a < 16; ++a) e[i + a] = s[a];
47
+ return e || (function(o, l) {
48
+ var d = 0, h = Ht;
49
+ return [h[o[d++]], h[o[d++]], h[o[d++]], h[o[d++]], "-", h[o[d++]], h[o[d++]], "-", h[o[d++]], h[o[d++]], "-", h[o[d++]], h[o[d++]], "-", h[o[d++]], h[o[d++]], h[o[d++]], h[o[d++]], h[o[d++]], h[o[d++]]].join("");
50
50
  })(s);
51
51
  }
52
- const mt = "wss://rtc.telnyx.com", Jt = { urls: "stun:stun.l.google.com:19302" }, Mn = [{ urls: "stun:stun.telnyx.com:3478" }, Jt, { urls: "turn:turn.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }], Pn = [{ urls: "stun:stundev.telnyx.com:3478" }, Jt, { urls: "turn:turndev.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }];
53
- var O;
52
+ const vt = "wss://rtc.telnyx.com", qt = { urls: "stun:stun.l.google.com:19302" }, On = [{ urls: "stun:stun.telnyx.com:3478" }, qt, { urls: "turn:turn.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }], Mn = [{ urls: "stun:stundev.telnyx.com:3478" }, qt, { urls: "turn:turndev.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }];
53
+ var L;
54
54
  (function(t) {
55
55
  t.SocketOpen = "telnyx.socket.open", t.SocketClose = "telnyx.socket.close", t.SocketError = "telnyx.socket.error", t.SocketMessage = "telnyx.socket.message", t.SpeedTest = "telnyx.internal.speedtest", t.Ready = "telnyx.ready", t.Error = "telnyx.error", t.Notification = "telnyx.notification", t.StatsFrame = "telnyx.stats.frame", t.StatsReport = "telnyx.stats.report", t.Messages = "telnyx.messages", t.Calls = "telnyx.calls", t.MediaError = "telnyx.rtc.mediaError", t.PeerConnectionFailureError = "telnyx.rtc.peerConnectionFailureError";
56
- })(O || (O = {}));
57
- var Dn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
58
- function Yt(t, e) {
56
+ })(L || (L = {}));
57
+ var Pn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
58
+ function Jt(t, e) {
59
59
  return t(e = { exports: {} }, e.exports), e.exports;
60
60
  }
61
- var Nn = Yt((function(t) {
61
+ var Dn = Jt((function(t) {
62
62
  var e, n;
63
- e = Dn, n = function() {
63
+ e = Pn, n = function() {
64
64
  var i = function() {
65
- }, s = "undefined", r = typeof window !== s && typeof window.navigator !== s && /Trident\/|MSIE /.test(window.navigator.userAgent), o = ["trace", "debug", "info", "warn", "error"];
66
- function d(p, S) {
65
+ }, s = "undefined", a = typeof window !== s && typeof window.navigator !== s && /Trident\/|MSIE /.test(window.navigator.userAgent), o = ["trace", "debug", "info", "warn", "error"];
66
+ function l(p, S) {
67
67
  var A = p[S];
68
68
  if (typeof A.bind == "function") return A.bind(p);
69
69
  try {
@@ -74,7 +74,7 @@ var Nn = Yt((function(t) {
74
74
  };
75
75
  }
76
76
  }
77
- function l() {
77
+ function d() {
78
78
  console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
79
79
  }
80
80
  function h(p, S) {
@@ -91,7 +91,7 @@ var Nn = Yt((function(t) {
91
91
  }
92
92
  function v(p, S, A) {
93
93
  return (function(E) {
94
- return E === "debug" && (E = "log"), typeof console !== s && (E === "trace" && r ? l : console[E] !== void 0 ? d(console, E) : console.log !== void 0 ? d(console, "log") : i);
94
+ return E === "debug" && (E = "log"), typeof console !== s && (E === "trace" && a ? d : console[E] !== void 0 ? l(console, E) : console.log !== void 0 ? l(console, "log") : i);
95
95
  })(p) || f.apply(this, arguments);
96
96
  }
97
97
  function _(p, S, A) {
@@ -106,8 +106,8 @@ var Nn = Yt((function(t) {
106
106
  } catch {
107
107
  }
108
108
  if (typeof x === s) try {
109
- var a = window.document.cookie, c = a.indexOf(encodeURIComponent(D) + "=");
110
- c !== -1 && (x = /^([^;]+)/.exec(a.slice(c))[1]);
109
+ var r = window.document.cookie, c = r.indexOf(encodeURIComponent(D) + "=");
110
+ c !== -1 && (x = /^([^;]+)/.exec(r.slice(c))[1]);
111
111
  } catch {
112
112
  }
113
113
  return P.levels[x] === void 0 && (x = void 0), x;
@@ -115,9 +115,9 @@ var Nn = Yt((function(t) {
115
115
  }
116
116
  typeof p == "string" ? D += ":" + p : typeof p == "symbol" && (D = void 0), P.name = p, P.levels = { TRACE: 0, DEBUG: 1, INFO: 2, WARN: 3, ERROR: 4, SILENT: 5 }, P.methodFactory = A || v, P.getLevel = function() {
117
117
  return E;
118
- }, P.setLevel = function(x, a) {
118
+ }, P.setLevel = function(x, r) {
119
119
  if (typeof x == "string" && P.levels[x.toUpperCase()] !== void 0 && (x = P.levels[x.toUpperCase()]), !(typeof x == "number" && x >= 0 && x <= P.levels.SILENT)) throw "log.setLevel() called with invalid level: " + x;
120
- if (E = x, a !== !1 && (function(c) {
120
+ if (E = x, r !== !1 && (function(c) {
121
121
  var u = (o[c] || "silent").toUpperCase();
122
122
  if (typeof window !== s && D) {
123
123
  try {
@@ -167,131 +167,131 @@ var Nn = Yt((function(t) {
167
167
  }, w.default = w, w;
168
168
  }, t.exports ? t.exports = n() : e.log = n();
169
169
  }));
170
- const y = Nn.getLogger("telnyx"), jn = y.methodFactory;
170
+ const y = Dn.getLogger("telnyx"), Nn = y.methodFactory;
171
171
  y.methodFactory = (t, e, n) => {
172
- const i = jn(t, e, n);
172
+ const i = Nn(t, e, n);
173
173
  return function() {
174
174
  const s = [(/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), "-"];
175
- for (let r = 0; r < arguments.length; r++) s.push(arguments[r]);
175
+ for (let a = 0; a < arguments.length; a++) s.push(arguments[a]);
176
176
  i.apply(void 0, s);
177
177
  };
178
178
  }, y.setLevel("info");
179
- const Oe = (t) => {
180
- const [e, n, i, s, r, o] = t;
181
- let d = {};
179
+ const Le = (t) => {
180
+ const [e, n, i, s, a, o] = t;
181
+ let l = {};
182
182
  try {
183
- d = JSON.parse(r.replace(/ID"/g, 'Id"'));
183
+ l = JSON.parse(a.replace(/ID"/g, 'Id"'));
184
184
  } catch {
185
- y.warn("Verto LA invalid media JSON string:", r);
185
+ y.warn("Verto LA invalid media JSON string:", a);
186
186
  }
187
- return { participantId: Number(e), participantNumber: n, participantName: i, codec: s, media: d, participantData: o };
188
- }, zt = (t) => {
187
+ return { participantId: Number(e), participantNumber: n, participantName: i, codec: s, media: l, participantData: o };
188
+ }, Yt = (t) => {
189
189
  if (typeof t != "string") return t;
190
190
  try {
191
191
  return JSON.parse(t);
192
192
  } catch {
193
193
  return t;
194
194
  }
195
- }, ye = (t) => t instanceof Function || typeof t == "function", De = (t) => typeof document == "object" && "getElementById" in document ? typeof t == "string" ? document.getElementById(t) || null : typeof t == "function" ? t() : t instanceof HTMLMediaElement ? t : null : null, Un = /^(ws|wss):\/\//, Kt = (t, e = null) => {
195
+ }, ye = (t) => t instanceof Function || typeof t == "function", De = (t) => typeof document == "object" && "getElementById" in document ? typeof t == "string" ? document.getElementById(t) || null : typeof t == "function" ? t() : t instanceof HTMLMediaElement ? t : null : null, Un = /^(ws|wss):\/\//, zt = (t, e = null) => {
196
196
  const { result: n = {}, error: i } = t;
197
197
  if (i) return { error: i };
198
198
  const { result: s = null } = n;
199
199
  if (s === null) return e !== null && (n.node_id = e), { result: n };
200
- const { code: r = null, node_id: o = null, result: d = null } = s;
201
- return r && r !== "200" ? { error: s } : d ? Kt(d, o) : { result: s };
202
- }, Qt = (t, e) => Math.floor(Math.random() * (e - t + 1) + t), Ne = ({ login: t, passwd: e, password: n, login_token: i }) => !!(t && (e || n) || i), Ie = ({ anonymous_login: t }) => !!t && !!t.target_id && !!t.target_type, pt = (t) => {
203
- var e, n, i, s, r, o;
204
- let d = "", l = "";
205
- return !((n = (e = t?.result) === null || e === void 0 ? void 0 : e.params) === null || n === void 0) && n.state && (d = (s = (i = t?.result) === null || i === void 0 ? void 0 : i.params) === null || s === void 0 ? void 0 : s.state), !((r = t?.params) === null || r === void 0) && r.state && (l = (o = t?.params) === null || o === void 0 ? void 0 : o.state), d || l;
200
+ const { code: a = null, node_id: o = null, result: l = null } = s;
201
+ return a && a !== "200" ? { error: s } : l ? zt(l, o) : { result: s };
202
+ }, Kt = (t, e) => Math.floor(Math.random() * (e - t + 1) + t), Ne = ({ login: t, passwd: e, password: n, login_token: i }) => !!(t && (e || n) || i), Ie = ({ anonymous_login: t }) => !!t && !!t.target_id && !!t.target_type, ht = (t) => {
203
+ var e, n, i, s, a, o;
204
+ let l = "", d = "";
205
+ return !((n = (e = t?.result) === null || e === void 0 ? void 0 : e.params) === null || n === void 0) && n.state && (l = (s = (i = t?.result) === null || i === void 0 ? void 0 : i.params) === null || s === void 0 ? void 0 : s.state), !((a = t?.params) === null || a === void 0) && a.state && (d = (o = t?.params) === null || o === void 0 ? void 0 : o.state), l || d;
206
206
  };
207
- function yt({ debounceTime: t }) {
207
+ function mt({ debounceTime: t }) {
208
208
  let e, n;
209
209
  return { promise: new Promise(((i, s) => {
210
- e = t ? $n(i, t) : i, n = s;
210
+ e = t ? jn(i, t) : i, n = s;
211
211
  })), resolve: e, reject: n };
212
212
  }
213
- const $n = (t, e) => {
213
+ const jn = (t, e) => {
214
214
  let n;
215
215
  return (...i) => {
216
216
  clearTimeout(n), n = window.setTimeout((() => {
217
217
  t(...i);
218
218
  }), e);
219
219
  };
220
- }, ft = "telnyx-voice-sdk-id";
220
+ }, pt = "telnyx-voice-sdk-id";
221
221
  function fe() {
222
- return sessionStorage.getItem(ft);
222
+ return sessionStorage.getItem(pt);
223
223
  }
224
- var K, de, F;
224
+ var K, le, $;
225
225
  typeof window < "u" && window.addEventListener("beforeunload", (() => {
226
- sessionStorage.removeItem(ft);
226
+ sessionStorage.removeItem(pt);
227
227
  })), (function(t) {
228
228
  t.Offer = "offer", t.Answer = "answer";
229
229
  })(K || (K = {})), (function(t) {
230
230
  t.Inbound = "inbound", t.Outbound = "outbound";
231
- })(de || (de = {})), (function(t) {
231
+ })(le || (le = {})), (function(t) {
232
232
  t.Invite = "telnyx_rtc.invite", t.Attach = "telnyx_rtc.attach", t.Answer = "telnyx_rtc.answer", t.Info = "telnyx_rtc.info", t.Candidate = "telnyx_rtc.candidate", t.EndOfCandidates = "telnyx_rtc.endOfCandidates", t.Display = "telnyx_rtc.display", t.Media = "telnyx_rtc.media", t.Event = "telnyx_rtc.event", t.Bye = "telnyx_rtc.bye", t.Punt = "telnyx_rtc.punt", t.Broadcast = "telnyx_rtc.broadcast", t.Subscribe = "telnyx_rtc.subscribe", t.Unsubscribe = "telnyx_rtc.unsubscribe", t.ClientReady = "telnyx_rtc.clientReady", t.Modify = "telnyx_rtc.modify", t.Ringing = "telnyx_rtc.ringing", t.GatewayState = "telnyx_rtc.gatewayState", t.Ping = "telnyx_rtc.ping", t.Pong = "telnyx_rtc.pong";
233
- })(F || (F = {}));
234
- const oe = { generic: "event", [F.Display]: "participantData", [F.Attach]: "participantData", conferenceUpdate: "conferenceUpdate", callUpdate: "callUpdate", vertoClientReady: "vertoClientReady", userMediaError: "userMediaError", peerConnectionFailureError: "peerConnectionFailureError" }, Fn = { destinationNumber: "", remoteCallerName: "Outbound Call", remoteCallerNumber: "", callerName: "", callerNumber: "", audio: !0, useStereo: !1, debug: !1, debugOutput: "socket", attach: !1, screenShare: !1, userVariables: {}, mediaSettings: { useSdpASBandwidthKbps: !1, sdpASBandwidthKbps: 0 }, mutedMicOnStart: !1 };
235
- var N, tt, se, ae, te;
233
+ })($ || ($ = {}));
234
+ const oe = { generic: "event", [$.Display]: "participantData", [$.Attach]: "participantData", conferenceUpdate: "conferenceUpdate", callUpdate: "callUpdate", vertoClientReady: "vertoClientReady", userMediaError: "userMediaError", peerConnectionFailureError: "peerConnectionFailureError" }, Fn = { destinationNumber: "", remoteCallerName: "Outbound Call", remoteCallerNumber: "", callerName: "", callerNumber: "", audio: !0, useStereo: !1, debug: !1, debugOutput: "socket", attach: !1, screenShare: !1, userVariables: {}, mediaSettings: { useSdpASBandwidthKbps: !1, sdpASBandwidthKbps: 0 }, mutedMicOnStart: !1 };
235
+ var N, et, se, ae, te;
236
236
  (function(t) {
237
237
  t[t.New = 0] = "New", t[t.Requesting = 1] = "Requesting", t[t.Trying = 2] = "Trying", t[t.Recovering = 3] = "Recovering", t[t.Ringing = 4] = "Ringing", t[t.Answering = 5] = "Answering", t[t.Early = 6] = "Early", t[t.Active = 7] = "Active", t[t.Held = 8] = "Held", t[t.Hangup = 9] = "Hangup", t[t.Destroy = 10] = "Destroy", t[t.Purge = 11] = "Purge";
238
238
  })(N || (N = {})), (function(t) {
239
239
  t.Participant = "participant", t.Moderator = "moderator";
240
- })(tt || (tt = {})), (function(t) {
240
+ })(et || (et = {})), (function(t) {
241
241
  t.Join = "join", t.Leave = "leave", t.Bootstrap = "bootstrap", t.Add = "add", t.Modify = "modify", t.Delete = "delete", t.Clear = "clear", t.ChatMessage = "chatMessage", t.LayerInfo = "layerInfo", t.LogoInfo = "logoInfo", t.LayoutInfo = "layoutInfo", t.LayoutList = "layoutList", t.ModCmdResponse = "modCommandResponse";
242
242
  })(se || (se = {})), (function(t) {
243
243
  t.Video = "videoinput", t.AudioIn = "audioinput", t.AudioOut = "audiooutput";
244
244
  })(ae || (ae = {})), (function(t) {
245
245
  t.REGED = "REGED", t.UNREGED = "UNREGED", t.NOREG = "NOREG", t.FAILED = "FAILED", t.FAIL_WAIT = "FAIL_WAIT", t.REGISTER = "REGISTER", t.TRYING = "TRYING", t.EXPIRED = "EXPIRED", t.UNREGISTER = "UNREGISTER";
246
246
  })(te || (te = {}));
247
- const be = "GLOBAL", ie = {}, Ae = (t, e) => `${t}|${e}`, Xt = (t, e = be) => Ae(t, e) in ie, le = (t, e, n = be) => {
247
+ const be = "GLOBAL", ie = {}, Ae = (t, e) => `${t}|${e}`, Qt = (t, e = be) => Ae(t, e) in ie, de = (t, e, n = be) => {
248
248
  const i = Ae(t, n);
249
249
  i in ie || (ie[i] = []), ie[i].push(e);
250
- }, Zt = (t, e, n = be) => {
250
+ }, Xt = (t, e, n = be) => {
251
251
  const i = function(s) {
252
252
  ue(t, i, n), e(s);
253
253
  };
254
- return i.prototype.targetRef = e, le(t, i, n);
254
+ return i.prototype.targetRef = e, de(t, i, n);
255
255
  }, ue = (t, e, n = be) => {
256
- if (!Xt(t, n)) return !1;
256
+ if (!Qt(t, n)) return !1;
257
257
  const i = Ae(t, n);
258
258
  if (ye(e))
259
259
  for (let s = ie[i].length - 1; s >= 0; s--) {
260
- const r = ie[i][s];
261
- (e === r || r.prototype && e === r.prototype.targetRef) && ie[i].splice(s, 1);
260
+ const a = ie[i][s];
261
+ (e === a || a.prototype && e === a.prototype.targetRef) && ie[i].splice(s, 1);
262
262
  }
263
263
  else ie[i] = [];
264
264
  return ie[i].length === 0 && delete ie[i], !0;
265
- }, $ = (t, e, n = be, i = !0) => {
265
+ }, F = (t, e, n = be, i = !0) => {
266
266
  const s = i && n !== be;
267
- if (!Xt(t, n)) return s && $(t, e), !1;
268
- const r = Ae(t, n), o = ie[r].length;
269
- if (!o) return s && $(t, e), !1;
270
- for (let d = o - 1; d >= 0; d--) ie[r][d](e);
271
- return s && $(t, e), !0;
267
+ if (!Qt(t, n)) return s && F(t, e), !1;
268
+ const a = Ae(t, n), o = ie[a].length;
269
+ if (!o) return s && F(t, e), !1;
270
+ for (let l = o - 1; l >= 0; l--) ie[a][l](e);
271
+ return s && F(t, e), !0;
272
272
  }, Ke = (t) => {
273
273
  const e = Ae(t, "");
274
274
  Object.keys(ie).filter(((n) => n.indexOf(e) === 0)).forEach(((n) => delete ie[n]));
275
275
  };
276
- let Bn = typeof WebSocket < "u" ? WebSocket : null;
277
- const Vn = 0, Gn = 1, Wn = 2, Hn = 3;
278
- class bt {
276
+ let $n = typeof WebSocket < "u" ? WebSocket : null;
277
+ const Bn = 0, Vn = 1, Gn = 2, Wn = 3;
278
+ class yt {
279
279
  constructor(e) {
280
- this.session = e, this.previousGatewayState = "", this._wsClient = null, this._host = mt, this._timers = {}, this._useCanaryRtcServer = !1, this._hasCanaryBeenUsed = !1, this.upDur = null, this.downDur = null;
281
- const { host: n, env: i, region: s, trickleIce: r, useCanaryRtcServer: o } = e.options;
282
- i && (this._host = i === "development" ? "wss://rtcdev.telnyx.com" : mt), n && (this._host = ((d) => `${Un.test(d) ? "" : "wss://"}${d}`)(n)), s && (this._host = this._host.replace(/rtc(dev)?/, `${s}.rtc$1`)), (r || o) && (this._useCanaryRtcServer = !0);
280
+ this.session = e, this.previousGatewayState = "", this._wsClient = null, this._host = vt, this._timers = {}, this._useCanaryRtcServer = !1, this._hasCanaryBeenUsed = !1, this.upDur = null, this.downDur = null;
281
+ const { host: n, env: i, region: s, trickleIce: a, useCanaryRtcServer: o } = e.options;
282
+ i && (this._host = i === "development" ? "wss://rtcdev.telnyx.com" : vt), n && (this._host = ((l) => `${Un.test(l) ? "" : "wss://"}${l}`)(n)), s && (this._host = this._host.replace(/rtc(dev)?/, `${s}.rtc$1`)), (a || o) && (this._useCanaryRtcServer = !0);
283
283
  }
284
284
  get connected() {
285
- return this._wsClient && this._wsClient.readyState === Gn;
285
+ return this._wsClient && this._wsClient.readyState === Vn;
286
286
  }
287
287
  get connecting() {
288
- return this._wsClient && this._wsClient.readyState === Vn;
288
+ return this._wsClient && this._wsClient.readyState === Bn;
289
289
  }
290
290
  get closing() {
291
- return this._wsClient && this._wsClient.readyState === Wn;
291
+ return this._wsClient && this._wsClient.readyState === Gn;
292
292
  }
293
293
  get closed() {
294
- return this._wsClient && this._wsClient.readyState === Hn;
294
+ return this._wsClient && this._wsClient.readyState === Wn;
295
295
  }
296
296
  get isAlive() {
297
297
  return this.connecting || this.connected;
@@ -302,16 +302,16 @@ class bt {
302
302
  connect() {
303
303
  const e = new URL(this._host);
304
304
  let n = fe();
305
- this.session.options.rtcIp && this.session.options.rtcPort && (n = null, this._useCanaryRtcServer = !1, e.searchParams.set("rtc_ip", this.session.options.rtcIp), e.searchParams.set("rtc_port", this.session.options.rtcPort.toString())), n && e.searchParams.set("voice_sdk_id", n), this._useCanaryRtcServer && (e.searchParams.set("canary", "true"), n && !this._hasCanaryBeenUsed && (e.searchParams.delete("voice_sdk_id"), y.debug("first canary connection. Refreshing voice_sdk_id")), this._hasCanaryBeenUsed = !0), this._wsClient = new Bn(e.toString()), this._wsClient.onopen = (i) => $(O.SocketOpen, i, this.session.uuid), this._wsClient.onclose = (i) => $(O.SocketClose, i, this.session.uuid), this._wsClient.onerror = (i) => $(O.SocketError, { error: i, sessionId: this.session.sessionid }, this.session.uuid), this._wsClient.onmessage = (i) => {
306
- var s, r;
307
- const o = zt(i.data);
308
- var d;
305
+ this.session.options.rtcIp && this.session.options.rtcPort && (n = null, this._useCanaryRtcServer = !1, e.searchParams.set("rtc_ip", this.session.options.rtcIp), e.searchParams.set("rtc_port", this.session.options.rtcPort.toString())), n && e.searchParams.set("voice_sdk_id", n), this._useCanaryRtcServer && (e.searchParams.set("canary", "true"), n && !this._hasCanaryBeenUsed && (e.searchParams.delete("voice_sdk_id"), y.debug("first canary connection. Refreshing voice_sdk_id")), this._hasCanaryBeenUsed = !0), this._wsClient = new $n(e.toString()), this._wsClient.onopen = (i) => F(L.SocketOpen, i, this.session.uuid), this._wsClient.onclose = (i) => F(L.SocketClose, i, this.session.uuid), this._wsClient.onerror = (i) => F(L.SocketError, { error: i, sessionId: this.session.sessionid }, this.session.uuid), this._wsClient.onmessage = (i) => {
306
+ var s, a;
307
+ const o = Yt(i.data);
308
+ var l;
309
309
  if (typeof o != "string") {
310
- if (o.voice_sdk_id && (d = o.voice_sdk_id, sessionStorage.setItem(ft, d)), this._unsetTimer(o.id), y.debug(`RECV:
310
+ if (o.voice_sdk_id && (l = o.voice_sdk_id, sessionStorage.setItem(pt, l)), this._unsetTimer(o.id), y.debug(`RECV:
311
311
  `, JSON.stringify(o, null, 2), `
312
- `), te[`${(r = (s = o?.result) === null || s === void 0 ? void 0 : s.params) === null || r === void 0 ? void 0 : r.state}`] || !$(o.id, o)) {
313
- const l = pt(o);
314
- $(O.SocketMessage, o, this.session.uuid), l && (this.previousGatewayState = l);
312
+ `), te[`${(a = (s = o?.result) === null || s === void 0 ? void 0 : s.params) === null || a === void 0 ? void 0 : a.state}`] || !F(o.id, o)) {
313
+ const d = ht(o);
314
+ F(L.SocketMessage, o, this.session.uuid), d && (this.previousGatewayState = d);
315
315
  }
316
316
  } else this._handleStringResponse(o);
317
317
  };
@@ -320,11 +320,11 @@ class bt {
320
320
  this._wsClient.send(e);
321
321
  }
322
322
  send(e) {
323
- const { request: n } = e, i = new Promise(((s, r) => {
323
+ const { request: n } = e, i = new Promise(((s, a) => {
324
324
  if (n.hasOwnProperty("result")) return s();
325
- Zt(n.id, ((o) => {
326
- const { result: d, error: l } = Kt(o);
327
- return l ? r(l) : s(d);
325
+ Xt(n.id, ((o) => {
326
+ const { result: l, error: d } = zt(o);
327
+ return d ? a(d) : s(l);
328
328
  }));
329
329
  }));
330
330
  return y.debug(`SEND:
@@ -343,7 +343,7 @@ class bt {
343
343
  this.upDur = parseInt(e.substring(4));
344
344
  break;
345
345
  case "D":
346
- this.downDur = parseInt(e.substring(4)), $(O.SpeedTest, { upDur: this.upDur, downDur: this.downDur }, this.session.uuid);
346
+ this.downDur = parseInt(e.substring(4)), F(L.SpeedTest, { upDur: this.upDur, downDur: this.downDur }, this.session.uuid);
347
347
  }
348
348
  else y.warn("Unknown message from socket", e);
349
349
  }
@@ -353,43 +353,43 @@ class Re {
353
353
  this.request = Object.assign({ jsonrpc: "2.0", id: me() }, e);
354
354
  }
355
355
  }
356
- const _t = { id: "callID", destinationNumber: "destination_number", remoteCallerName: "remote_caller_id_name", remoteCallerNumber: "remote_caller_id_number", callerName: "caller_id_name", callerNumber: "caller_id_number", customHeaders: "custom_headers" };
356
+ const bt = { id: "callID", destinationNumber: "destination_number", remoteCallerName: "remote_caller_id_name", remoteCallerNumber: "remote_caller_id_number", callerName: "caller_id_name", callerNumber: "caller_id_number", customHeaders: "custom_headers" };
357
357
  class Z extends Re {
358
358
  constructor(e = {}) {
359
359
  if (super(), e.hasOwnProperty("dialogParams")) {
360
- const n = Ht(e.dialogParams, ["remoteSdp", "localStream", "remoteStream", "onNotification", "camId", "micId", "speakerId"]);
361
- for (const i in _t) i && n.hasOwnProperty(i) && (n[_t[i]] = n[i], delete n[i]);
360
+ const n = Wt(e.dialogParams, ["remoteSdp", "localStream", "remoteStream", "onNotification", "camId", "micId", "speakerId"]);
361
+ for (const i in bt) i && n.hasOwnProperty(i) && (n[bt[i]] = n[i], delete n[i]);
362
362
  e.dialogParams = n;
363
363
  }
364
364
  this.buildRequest({ method: this.toString(), params: e });
365
365
  }
366
366
  }
367
- class en extends Z {
367
+ class Zt extends Z {
368
368
  constructor(e) {
369
- super(), this.method = F.GatewayState, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
369
+ super(), this.method = $.GatewayState, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
370
370
  }
371
371
  }
372
- class qn {
372
+ class Hn {
373
373
  constructor(e) {
374
- this.pendingRequestId = null, this.onSocketMessage = (n) => L(this, void 0, void 0, (function* () {
375
- n.id === this.pendingRequestId && this.gatewayStateTask.resolve(pt(n));
376
- })), this.getIsRegistered = () => L(this, void 0, void 0, (function* () {
377
- const n = new en(fe());
378
- this.pendingRequestId = n.request.id, this.gatewayStateTask = yt({}), this.session.execute(n);
374
+ this.pendingRequestId = null, this.onSocketMessage = (n) => O(this, void 0, void 0, (function* () {
375
+ n.id === this.pendingRequestId && this.gatewayStateTask.resolve(ht(n));
376
+ })), this.getIsRegistered = () => O(this, void 0, void 0, (function* () {
377
+ const n = new Zt(fe());
378
+ this.pendingRequestId = n.request.id, this.gatewayStateTask = mt({}), this.session.execute(n);
379
379
  const i = yield this.gatewayStateTask.promise;
380
380
  return !!i && [te.REGISTER, te.REGED].includes(i);
381
- })), this.session = e, this.gatewayStateTask = yt({}), this.session.on("telnyx.socket.message", this.onSocketMessage);
381
+ })), this.session = e, this.gatewayStateTask = mt({}), this.session.on("telnyx.socket.message", this.onSocketMessage);
382
382
  }
383
383
  }
384
- class tn extends Z {
384
+ class en extends Z {
385
385
  constructor(e) {
386
- super(), this.method = F.Ping, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
386
+ super(), this.method = $.Ping, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
387
387
  }
388
388
  }
389
- class Jn {
389
+ class qn {
390
390
  constructor(e) {
391
391
  if (this.options = e, this.uuid = me(), this.sessionid = "", this.subscriptions = {}, this.signature = null, this.relayProtocol = null, this.contexts = [], this.timeoutErrorCode = -32e3, this.invalidMethodErrorCode = -32601, this.authenticationRequiredErrorCode = -32e3, this.connection = null, this._jwtAuth = !1, this._autoReconnect = !0, this._idle = !1, this._executeQueue = [], !this.validateOptions()) throw new Error("Invalid init options");
392
- e.debug && y.setLevel("debug"), this._onSocketOpen = this._onSocketOpen.bind(this), this.onNetworkClose = this.onNetworkClose.bind(this), this._onSocketMessage = this._onSocketMessage.bind(this), this._handleLoginError = this._handleLoginError.bind(this), this._attachListeners(), this.connection = new bt(this), this.registerAgent = new qn(this);
392
+ y.setLevel(e.debug ? "debug" : "info"), this._onSocketOpen = this._onSocketOpen.bind(this), this.onNetworkClose = this.onNetworkClose.bind(this), this._onSocketMessage = this._onSocketMessage.bind(this), this._handleLoginError = this._handleLoginError.bind(this), this._attachListeners(), this.connection = new yt(this), this.registerAgent = new Hn(this);
393
393
  }
394
394
  get __logger() {
395
395
  return y;
@@ -398,12 +398,12 @@ class Jn {
398
398
  return this.connection && this.connection.connected;
399
399
  }
400
400
  getIsRegistered() {
401
- return L(this, void 0, void 0, (function* () {
401
+ return O(this, void 0, void 0, (function* () {
402
402
  return this.registerAgent.getIsRegistered();
403
403
  }));
404
404
  }
405
405
  get reconnectDelay() {
406
- return 1e3 * Qt(2, 6);
406
+ return 1e3 * Kt(2, 6);
407
407
  }
408
408
  execute(e) {
409
409
  return this._idle ? new Promise(((n) => this._executeQueue.push({ resolve: n, msg: e }))) : this.connected ? this.connection.send(e) : new Promise(((n) => {
@@ -419,26 +419,26 @@ class Jn {
419
419
  broadcast(e) {
420
420
  }
421
421
  disconnect() {
422
- return L(this, void 0, void 0, (function* () {
422
+ return O(this, void 0, void 0, (function* () {
423
423
  clearTimeout(this._reconnectTimeout), this.subscriptions = {}, this._autoReconnect = !1, this.relayProtocol = null, this._closeConnection(), yield sessionStorage.removeItem(this.signature), this._executeQueue = [], this._detachListeners();
424
424
  }));
425
425
  }
426
426
  on(e, n) {
427
- return le(e, n, this.uuid), this;
427
+ return de(e, n, this.uuid), this;
428
428
  }
429
429
  off(e, n) {
430
430
  return ue(e, n, this.uuid), this;
431
431
  }
432
432
  connect() {
433
- return L(this, void 0, void 0, (function* () {
434
- this.connection || (this.connection = new bt(this)), this._attachListeners(), this.connection.isAlive || this.connection.connect();
433
+ return O(this, void 0, void 0, (function* () {
434
+ this.connection || (this.connection = new yt(this)), this._attachListeners(), this.connection.isAlive || this.connection.connect();
435
435
  }));
436
436
  }
437
437
  _handleLoginError(e) {
438
- $(O.Error, { error: e, sessionId: this.sessionid }, this.uuid);
438
+ F(L.Error, { error: e, sessionId: this.sessionid }, this.uuid);
439
439
  }
440
440
  _onSocketOpen() {
441
- return L(this, void 0, void 0, (function* () {
441
+ return O(this, void 0, void 0, (function* () {
442
442
  }));
443
443
  }
444
444
  onNetworkClose() {
@@ -452,16 +452,16 @@ class Jn {
452
452
  this._existsSubscription(e, n) && (n ? (delete this.subscriptions[e][n], ue(e, null, n)) : (delete this.subscriptions[e], Ke(e)));
453
453
  }
454
454
  _addSubscription(e, n = null, i) {
455
- this._existsSubscription(e, i) || (this._existsSubscription(e) || (this.subscriptions[e] = {}), this.subscriptions[e][i] = {}, ye(n) && le(e, n, i));
455
+ this._existsSubscription(e, i) || (this._existsSubscription(e) || (this.subscriptions[e] = {}), this.subscriptions[e][i] = {}, ye(n) && de(e, n, i));
456
456
  }
457
457
  _existsSubscription(e, n) {
458
458
  return !(!this.subscriptions.hasOwnProperty(e) || !(!n || n && this.subscriptions[e].hasOwnProperty(n)));
459
459
  }
460
460
  _attachListeners() {
461
- this._detachListeners(), this.on(O.SocketOpen, this._onSocketOpen), this.on(O.SocketClose, this.onNetworkClose), this.on(O.SocketError, this.onNetworkClose), this.on(O.SocketMessage, this._onSocketMessage);
461
+ this._detachListeners(), this.on(L.SocketOpen, this._onSocketOpen), this.on(L.SocketClose, this.onNetworkClose), this.on(L.SocketError, this.onNetworkClose), this.on(L.SocketMessage, this._onSocketMessage);
462
462
  }
463
463
  _detachListeners() {
464
- this.off(O.SocketOpen, this._onSocketOpen), this.off(O.SocketClose, this.onNetworkClose), this.off(O.SocketError, this.onNetworkClose), this.off(O.SocketMessage, this._onSocketMessage);
464
+ this.off(L.SocketOpen, this._onSocketOpen), this.off(L.SocketClose, this.onNetworkClose), this.off(L.SocketError, this.onNetworkClose), this.off(L.SocketMessage, this._onSocketMessage);
465
465
  }
466
466
  _emptyExecuteQueues() {
467
467
  this._executeQueue.forEach((({ resolve: e, msg: n }) => {
@@ -472,7 +472,7 @@ class Jn {
472
472
  this._idle = !0, clearTimeout(this._keepAliveTimeout), this.connection && this.connection.close();
473
473
  }
474
474
  _resetKeepAlive() {
475
- this._pong === !1 && (y.warn("No ping/pong received, forcing PING ACK to keep alive"), this.execute(new tn(fe()))), clearTimeout(this._keepAliveTimeout), this._triggerKeepAliveTimeoutCheck();
475
+ this._pong === !1 && (y.warn("No ping/pong received, forcing PING ACK to keep alive"), this.execute(new en(fe()))), clearTimeout(this._keepAliveTimeout), this._triggerKeepAliveTimeoutCheck();
476
476
  }
477
477
  _triggerKeepAliveTimeoutCheck() {
478
478
  this._pong = !1, this._keepAliveTimeout = setTimeout((() => this._resetKeepAlive()), 35e3);
@@ -481,7 +481,7 @@ class Jn {
481
481
  y.debug("Ping received"), this._pong = !0;
482
482
  }
483
483
  static on(e, n) {
484
- le(e, n);
484
+ de(e, n);
485
485
  }
486
486
  static off(e) {
487
487
  ue(e);
@@ -496,10 +496,10 @@ class Jn {
496
496
  return this._autoReconnect;
497
497
  }
498
498
  }
499
- const nt = (t) => navigator.mediaDevices.getUserMedia(t), ge = (t) => t && t instanceof MediaStream, Ee = (t, e) => {
499
+ const tt = (t) => navigator.mediaDevices.getUserMedia(t), ge = (t) => t && t instanceof MediaStream, Ee = (t, e) => {
500
500
  const n = De(t);
501
501
  n !== null && (n.getAttribute("autoplay") || n.setAttribute("autoplay", "autoplay"), n.getAttribute("playsinline") || n.setAttribute("playsinline", "playsinline"), n.srcObject = e);
502
- }, nn = (t, e) => L(void 0, void 0, void 0, (function* () {
502
+ }, tn = (t, e) => O(void 0, void 0, void 0, (function* () {
503
503
  const n = De(t);
504
504
  if (n === null) return y.info("No HTMLMediaElement to attach the speakerId"), !1;
505
505
  if (typeof e != "string") return y.info(`Invalid speaker deviceId: '${e}'`), !1;
@@ -508,49 +508,49 @@ const nt = (t) => navigator.mediaDevices.getUserMedia(t), ge = (t) => t && t ins
508
508
  } catch {
509
509
  return !1;
510
510
  }
511
- })), Yn = (t) => {
511
+ })), Jn = (t) => {
512
512
  t && t.readyState === "live" && t.stop();
513
513
  }, Te = (t) => {
514
- ge(t) && t.getTracks().forEach(Yn), t = null;
515
- }, je = (t) => L(void 0, void 0, void 0, (function* () {
514
+ ge(t) && t.getTracks().forEach(Jn), t = null;
515
+ }, Ue = (t) => O(void 0, void 0, void 0, (function* () {
516
516
  y.info("RTCService.getUserMedia", t);
517
517
  const { audio: e, video: n } = t;
518
518
  if (!e && !n) return null;
519
519
  try {
520
- return yield nt(t);
520
+ return yield tt(t);
521
521
  } catch (i) {
522
522
  throw y.error("getUserMedia error: ", i), i;
523
523
  }
524
- })), ke = (t = null, e = !1) => L(void 0, void 0, void 0, (function* () {
524
+ })), ke = (t = null, e = !1) => O(void 0, void 0, void 0, (function* () {
525
525
  let n = [];
526
526
  const i = yield navigator.mediaDevices.getUserMedia(((s = null) => ({ audio: !s || s === ae.AudioIn || s === ae.AudioOut, video: !s || s === ae.Video }))(t)).catch(((s) => (y.error(s), null)));
527
527
  if (i) {
528
- if (Te(i), n = yield navigator.mediaDevices.enumerateDevices(), t && (n = n.filter(((r) => r.kind === t))), e === !0) return n;
528
+ if (Te(i), n = yield navigator.mediaDevices.enumerateDevices(), t && (n = n.filter(((a) => a.kind === t))), e === !0) return n;
529
529
  const s = [];
530
- n = n.filter(((r) => {
531
- if (!r.groupId) return !0;
532
- const o = `${r.kind}-${r.groupId}`;
530
+ n = n.filter(((a) => {
531
+ if (!a.groupId) return !0;
532
+ const o = `${a.kind}-${a.groupId}`;
533
533
  return !s.includes(o) && (s.push(o), !0);
534
534
  }));
535
535
  }
536
536
  return n;
537
- })), St = [[320, 240], [640, 360], [640, 480], [1280, 720], [1920, 1080]], Ue = (t, e, n) => L(void 0, void 0, void 0, (function* () {
537
+ })), _t = [[320, 240], [640, 360], [640, 480], [1280, 720], [1920, 1080]], je = (t, e, n) => O(void 0, void 0, void 0, (function* () {
538
538
  const i = yield ke(n, !0);
539
539
  for (let s = 0; s < i.length; s++) {
540
- const { deviceId: r, label: o } = i[s];
541
- if (t === r || e === o) return r;
540
+ const { deviceId: a, label: o } = i[s];
541
+ if (t === a || e === o) return a;
542
542
  }
543
543
  return null;
544
- })), zn = (t) => {
544
+ })), Yn = (t) => {
545
545
  const e = navigator.mediaDevices.getSupportedConstraints();
546
546
  Object.keys(t).map(((n) => {
547
547
  e.hasOwnProperty(n) && t[n] !== null && t[n] !== void 0 || delete t[n];
548
548
  }));
549
- }, it = (t, e) => {
549
+ }, nt = (t, e) => {
550
550
  if (!t) return !1;
551
- const { subscribed: n, alreadySubscribed: i } = st(t);
551
+ const { subscribed: n, alreadySubscribed: i } = it(t);
552
552
  return n.includes(e) || i.includes(e);
553
- }, st = (t) => {
553
+ }, it = (t) => {
554
554
  const e = { subscribed: [], alreadySubscribed: [], unauthorized: [], unsubscribed: [], notSubscribed: [] };
555
555
  return Object.keys(e).forEach(((n) => {
556
556
  e[n] = t[`${n}Channels`] || [];
@@ -582,13 +582,13 @@ const nt = (t) => navigator.mediaDevices.getUserMedia(t), ge = (t) => t && t ins
582
582
  s.enabled = !s.enabled;
583
583
  }
584
584
  }));
585
- }, wt = (t) => {
585
+ }, St = (t) => {
586
586
  ve(t, "audio", !0);
587
- }, ot = (t) => {
587
+ }, st = (t) => {
588
588
  ve(t, "audio", !1);
589
- }, Ct = (t) => {
589
+ }, wt = (t) => {
590
590
  ve(t, "audio", null);
591
- }, Kn = (t) => ((e, n = null) => {
591
+ }, zn = (t) => ((e, n = null) => {
592
592
  if (!ge(e)) return null;
593
593
  let i = [];
594
594
  switch (n) {
@@ -603,7 +603,7 @@ const nt = (t) => navigator.mediaDevices.getUserMedia(t), ge = (t) => t && t ins
603
603
  }
604
604
  return i.some(((s) => s.enabled));
605
605
  })(t, "audio");
606
- function Qn() {
606
+ function Kn() {
607
607
  try {
608
608
  const { browserInfo: t, name: e, version: n, supportAudio: i, supportVideo: s } = (function() {
609
609
  if (!window || !window.navigator || !window.navigator.userAgent) throw new Error("You should use @telnyx/webrtc in a web browser such as Chrome|Firefox|Safari");
@@ -624,14 +624,14 @@ function Qn() {
624
624
  return { browserInfo: navigator.userAgent, name: v, version: _, supportAudio: !0, supportVideo: !0 };
625
625
  }
626
626
  throw new Error("This browser does not support @telnyx/webrtc. To see browser support list: `TelnyxRTC.webRTCSupportedBrowserList()`");
627
- })(), r = window.RTCPeerConnection, o = window.RTCSessionDescription, d = window.RTCIceCandidate, l = window.navigator && window.navigator.mediaDevices, h = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia || navigator.mozGetUserMedia;
628
- return { browserInfo: t, browserName: e, browserVersion: n, supportWebRTC: !!(r && o && d && l && h), supportWebRTCAudio: i, supportWebRTCVideo: s, supportRTCPeerConnection: !!r, supportSessionDescription: !!o, supportIceCandidate: !!d, supportMediaDevices: !!l, supportGetUserMedia: !!je };
627
+ })(), a = window.RTCPeerConnection, o = window.RTCSessionDescription, l = window.RTCIceCandidate, d = window.navigator && window.navigator.mediaDevices, h = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia || navigator.mozGetUserMedia;
628
+ return { browserInfo: t, browserName: e, browserVersion: n, supportWebRTC: !!(a && o && l && d && h), supportWebRTCAudio: i, supportWebRTCVideo: s, supportRTCPeerConnection: !!a, supportSessionDescription: !!o, supportIceCandidate: !!l, supportMediaDevices: !!d, supportGetUserMedia: !!Ue };
629
629
  } catch (t) {
630
630
  return t.message;
631
631
  }
632
632
  }
633
633
  var H;
634
- function kt(t, e) {
634
+ function Ct(t, e) {
635
635
  const n = document.getElementById(e);
636
636
  if (n) return n;
637
637
  if (t && e) {
@@ -640,14 +640,14 @@ function kt(t, e) {
640
640
  }
641
641
  return null;
642
642
  }
643
- function It(t) {
643
+ function kt(t) {
644
644
  t && (t._playFulfilled = !1, t._promise = t.play(), t._promise.then((() => {
645
645
  t._playFulfilled = !0;
646
646
  })).catch(((e) => {
647
647
  y.error("playAudio", e), t._playFulfilled = !0;
648
648
  })));
649
649
  }
650
- function Et(t) {
650
+ function It(t) {
651
651
  t && (t._playFulfilled ? (t.pause(), t.currentTime = 0) : t._promise && t._promise.then ? t._promise.then((() => {
652
652
  t.pause(), t.currentTime = 0;
653
653
  })) : setTimeout((() => {
@@ -657,135 +657,135 @@ function Et(t) {
657
657
  (function(t) {
658
658
  t.not_supported = "not supported", t.full = "full", t.partial = "partial";
659
659
  })(H || (H = {}));
660
- var sn = "2.25.12", We = sn;
661
- class on extends Z {
662
- constructor(e, n, i, s, r = {}, o) {
660
+ var nn = "2.25.14", We = nn;
661
+ class sn extends Z {
662
+ constructor(e, n, i, s, a = {}, o) {
663
663
  super(), this.method = "login";
664
- const d = { login: e, passwd: n, login_token: i, userVariables: r, reconnection: o, loginParams: {}, "User-Agent": { sdkVersion: We, data: navigator.userAgent } };
665
- s && (d.sessid = s), this.buildRequest({ method: this.method, params: d });
664
+ const l = { login: e, passwd: n, login_token: i, userVariables: a, reconnection: o, loginParams: {}, "User-Agent": { sdkVersion: We, data: navigator.userAgent } };
665
+ s && (l.sessid = s), this.buildRequest({ method: this.method, params: l });
666
666
  }
667
667
  }
668
- class Xn extends Z {
668
+ class Qn extends Z {
669
669
  constructor(e, n) {
670
670
  super(), this.buildRequest({ id: e, result: { method: n } });
671
671
  }
672
672
  }
673
- class Tt extends Z {
673
+ class Et extends Z {
674
674
  toString() {
675
- return F.Invite;
675
+ return $.Invite;
676
676
  }
677
677
  }
678
- class At extends Z {
678
+ class Tt extends Z {
679
679
  toString() {
680
- return F.Answer;
680
+ return $.Answer;
681
681
  }
682
682
  }
683
- class rt extends Z {
683
+ class ot extends Z {
684
684
  toString() {
685
- return F.Attach;
685
+ return $.Attach;
686
686
  }
687
687
  }
688
- class Zn extends Z {
688
+ class Xn extends Z {
689
689
  toString() {
690
- return F.Bye;
690
+ return $.Bye;
691
691
  }
692
692
  }
693
- class rn extends Z {
693
+ class on extends Z {
694
694
  toString() {
695
- return F.Candidate;
695
+ return $.Candidate;
696
696
  }
697
697
  }
698
- class ei extends Z {
698
+ class Zn extends Z {
699
699
  toString() {
700
- return F.EndOfCandidates;
700
+ return $.EndOfCandidates;
701
701
  }
702
702
  }
703
703
  class Qe extends Z {
704
704
  toString() {
705
- return F.Modify;
705
+ return $.Modify;
706
706
  }
707
707
  }
708
- class Rt extends Z {
708
+ class At extends Z {
709
709
  toString() {
710
- return F.Info;
710
+ return $.Info;
711
711
  }
712
712
  }
713
- class ti extends Z {
713
+ class ei extends Z {
714
714
  toString() {
715
- return F.Broadcast;
715
+ return $.Broadcast;
716
716
  }
717
717
  }
718
- class ni extends Z {
718
+ class ti extends Z {
719
719
  toString() {
720
- return F.Subscribe;
720
+ return $.Subscribe;
721
721
  }
722
722
  }
723
- class ii extends Z {
723
+ class ni extends Z {
724
724
  toString() {
725
- return F.Unsubscribe;
725
+ return $.Unsubscribe;
726
726
  }
727
727
  }
728
- class si extends Re {
728
+ class ii extends Re {
729
729
  constructor(e, n) {
730
730
  super(), this.method = "ai_conversation", this.buildRequest({ method: this.method, params: { type: "conversation.item.create", previous_item_id: null, item: { id: me(), type: "message", role: "user", content: [{ type: "input_text", text: e }, ...n?.map(((i) => ({ type: "image_url", image_url: { url: i } })))] } } });
731
731
  }
732
732
  }
733
- var Le, an = Yt((function(t, e) {
733
+ var Oe, rn = Jt((function(t, e) {
734
734
  var n;
735
735
  function i() {
736
736
  }
737
737
  function s() {
738
738
  s.init.call(this);
739
739
  }
740
- function r(a) {
741
- return a._maxListeners === void 0 ? s.defaultMaxListeners : a._maxListeners;
740
+ function a(r) {
741
+ return r._maxListeners === void 0 ? s.defaultMaxListeners : r._maxListeners;
742
742
  }
743
- function o(a, c, u, g) {
743
+ function o(r, c, u, g) {
744
744
  var b, T, I;
745
745
  if (typeof u != "function") throw new TypeError('"listener" argument must be a function');
746
- if ((T = a._events) ? (T.newListener && (a.emit("newListener", c, u.listener ? u.listener : u), T = a._events), I = T[c]) : (T = a._events = new i(), a._eventsCount = 0), I) {
747
- if (typeof I == "function" ? I = T[c] = g ? [u, I] : [I, u] : g ? I.unshift(u) : I.push(u), !I.warned && (b = r(a)) && 0 < b && I.length > b) {
746
+ if ((T = r._events) ? (T.newListener && (r.emit("newListener", c, u.listener ? u.listener : u), T = r._events), I = T[c]) : (T = r._events = new i(), r._eventsCount = 0), I) {
747
+ if (typeof I == "function" ? I = T[c] = g ? [u, I] : [I, u] : g ? I.unshift(u) : I.push(u), !I.warned && (b = a(r)) && 0 < b && I.length > b) {
748
748
  I.warned = !0;
749
749
  var R = new Error("Possible EventEmitter memory leak detected. " + I.length + " " + c + " listeners added. Use emitter.setMaxListeners() to increase limit");
750
- R.name = "MaxListenersExceededWarning", R.emitter = a, R.type = c, R.count = I.length, (function(U) {
751
- typeof console.warn == "function" ? console.warn(U) : console.log(U);
750
+ R.name = "MaxListenersExceededWarning", R.emitter = r, R.type = c, R.count = I.length, (function(j) {
751
+ typeof console.warn == "function" ? console.warn(j) : console.log(j);
752
752
  })(R);
753
753
  }
754
- } else I = T[c] = u, ++a._eventsCount;
755
- return a;
754
+ } else I = T[c] = u, ++r._eventsCount;
755
+ return r;
756
756
  }
757
- function d(a, c, u) {
757
+ function l(r, c, u) {
758
758
  function g() {
759
- a.removeListener(c, g), b || (b = !0, u.apply(a, arguments));
759
+ r.removeListener(c, g), b || (b = !0, u.apply(r, arguments));
760
760
  }
761
761
  var b = !1;
762
762
  return g.listener = u, g;
763
763
  }
764
- function l(a) {
764
+ function d(r) {
765
765
  var c = this._events;
766
766
  if (c) {
767
- var u = c[a];
767
+ var u = c[r];
768
768
  if (typeof u == "function") return 1;
769
769
  if (u) return u.length;
770
770
  }
771
771
  return 0;
772
772
  }
773
- function h(a, c) {
774
- for (var u = Array(c); c--; ) u[c] = a[c];
773
+ function h(r, c) {
774
+ for (var u = Array(c); c--; ) u[c] = r[c];
775
775
  return u;
776
776
  }
777
777
  Object.defineProperty(e, "__esModule", { value: !0 }), i.prototype = /* @__PURE__ */ Object.create(null), s.EventEmitter = s, s.usingDomains = !1, s.prototype.domain = void 0, s.prototype._events = void 0, s.prototype._maxListeners = void 0, s.defaultMaxListeners = 10, s.init = function() {
778
778
  this.domain = null, s.usingDomains && n.active && !(this instanceof n.Domain) && (this.domain = n.active), this._events && this._events !== Object.getPrototypeOf(this)._events || (this._events = new i(), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
779
- }, s.prototype.setMaxListeners = function(a) {
780
- if (typeof a != "number" || 0 > a || isNaN(a)) throw new TypeError('"n" argument must be a positive number');
781
- return this._maxListeners = a, this;
779
+ }, s.prototype.setMaxListeners = function(r) {
780
+ if (typeof r != "number" || 0 > r || isNaN(r)) throw new TypeError('"n" argument must be a positive number');
781
+ return this._maxListeners = r, this;
782
782
  }, s.prototype.getMaxListeners = function() {
783
- return r(this);
784
- }, s.prototype.emit = function(a) {
785
- var c, u, g, b, T, I, R, U = a === "error";
786
- if (I = this._events) U = U && I.error == null;
787
- else if (!U) return !1;
788
- if (R = this.domain, U) {
783
+ return a(this);
784
+ }, s.prototype.emit = function(r) {
785
+ var c, u, g, b, T, I, R, j = r === "error";
786
+ if (I = this._events) j = j && I.error == null;
787
+ else if (!j) return !1;
788
+ if (R = this.domain, j) {
789
789
  if (c = arguments[1], !R) {
790
790
  if (c instanceof Error) throw c;
791
791
  var ee = new Error('Uncaught, unspecified "error" event. (' + c + ")");
@@ -793,57 +793,57 @@ var Le, an = Yt((function(t, e) {
793
793
  }
794
794
  return c || (c = new Error('Uncaught, unspecified "error" event')), c.domainEmitter = this, c.domain = R, c.domainThrown = !1, R.emit("error", c), !1;
795
795
  }
796
- if (!(u = I[a])) return !1;
796
+ if (!(u = I[r])) return !1;
797
797
  var ne = typeof u == "function";
798
798
  switch (g = arguments.length) {
799
799
  case 1:
800
800
  (function(G, m, M) {
801
801
  if (m) G.call(M);
802
- else for (var j = G.length, V = h(G, j), Y = 0; Y < j; ++Y) V[Y].call(M);
802
+ else for (var U = G.length, V = h(G, U), Y = 0; Y < U; ++Y) V[Y].call(M);
803
803
  })(u, ne, this);
804
804
  break;
805
805
  case 2:
806
- (function(G, m, M, j) {
807
- if (m) G.call(M, j);
808
- else for (var V = G.length, Y = h(G, V), Q = 0; Q < V; ++Q) Y[Q].call(M, j);
806
+ (function(G, m, M, U) {
807
+ if (m) G.call(M, U);
808
+ else for (var V = G.length, Y = h(G, V), Q = 0; Q < V; ++Q) Y[Q].call(M, U);
809
809
  })(u, ne, this, arguments[1]);
810
810
  break;
811
811
  case 3:
812
- (function(G, m, M, j, V) {
813
- if (m) G.call(M, j, V);
814
- else for (var Y = G.length, Q = h(G, Y), W = 0; W < Y; ++W) Q[W].call(M, j, V);
812
+ (function(G, m, M, U, V) {
813
+ if (m) G.call(M, U, V);
814
+ else for (var Y = G.length, Q = h(G, Y), W = 0; W < Y; ++W) Q[W].call(M, U, V);
815
815
  })(u, ne, this, arguments[1], arguments[2]);
816
816
  break;
817
817
  case 4:
818
- (function(G, m, M, j, V, Y) {
819
- if (m) G.call(M, j, V, Y);
820
- else for (var Q = G.length, W = h(G, Q), re = 0; re < Q; ++re) W[re].call(M, j, V, Y);
818
+ (function(G, m, M, U, V, Y) {
819
+ if (m) G.call(M, U, V, Y);
820
+ else for (var Q = G.length, W = h(G, Q), re = 0; re < Q; ++re) W[re].call(M, U, V, Y);
821
821
  })(u, ne, this, arguments[1], arguments[2], arguments[3]);
822
822
  break;
823
823
  default:
824
824
  for (b = Array(g - 1), T = 1; T < g; T++) b[T - 1] = arguments[T];
825
- (function(G, m, M, j) {
826
- if (m) G.apply(M, j);
827
- else for (var V = G.length, Y = h(G, V), Q = 0; Q < V; ++Q) Y[Q].apply(M, j);
825
+ (function(G, m, M, U) {
826
+ if (m) G.apply(M, U);
827
+ else for (var V = G.length, Y = h(G, V), Q = 0; Q < V; ++Q) Y[Q].apply(M, U);
828
828
  })(u, ne, this, b);
829
829
  }
830
830
  return !0;
831
- }, s.prototype.addListener = function(a, c) {
832
- return o(this, a, c, !1);
833
- }, s.prototype.on = s.prototype.addListener, s.prototype.prependListener = function(a, c) {
834
- return o(this, a, c, !0);
835
- }, s.prototype.once = function(a, c) {
831
+ }, s.prototype.addListener = function(r, c) {
832
+ return o(this, r, c, !1);
833
+ }, s.prototype.on = s.prototype.addListener, s.prototype.prependListener = function(r, c) {
834
+ return o(this, r, c, !0);
835
+ }, s.prototype.once = function(r, c) {
836
836
  if (typeof c != "function") throw new TypeError('"listener" argument must be a function');
837
- return this.on(a, d(this, a, c)), this;
838
- }, s.prototype.prependOnceListener = function(a, c) {
837
+ return this.on(r, l(this, r, c)), this;
838
+ }, s.prototype.prependOnceListener = function(r, c) {
839
839
  if (typeof c != "function") throw new TypeError('"listener" argument must be a function');
840
- return this.prependListener(a, d(this, a, c)), this;
841
- }, s.prototype.removeListener = function(a, c) {
840
+ return this.prependListener(r, l(this, r, c)), this;
841
+ }, s.prototype.removeListener = function(r, c) {
842
842
  var u, g, b, T, I;
843
843
  if (typeof c != "function") throw new TypeError('"listener" argument must be a function');
844
844
  if (!(g = this._events)) return this;
845
- if (!(u = g[a])) return this;
846
- if (u === c || u.listener && u.listener === c) --this._eventsCount == 0 ? this._events = new i() : (delete g[a], g.removeListener && this.emit("removeListener", a, u.listener || c));
845
+ if (!(u = g[r])) return this;
846
+ if (u === c || u.listener && u.listener === c) --this._eventsCount == 0 ? this._events = new i() : (delete g[r], g.removeListener && this.emit("removeListener", r, u.listener || c));
847
847
  else if (typeof u != "function") {
848
848
  for (b = -1, T = u.length; 0 < T--; ) if (u[T] === c || u[T].listener && u[T].listener === c) {
849
849
  I = u[T].listener, b = T;
@@ -852,36 +852,36 @@ var Le, an = Yt((function(t, e) {
852
852
  if (0 > b) return this;
853
853
  if (u.length === 1) {
854
854
  if (u[0] = void 0, --this._eventsCount == 0) return this._events = new i(), this;
855
- delete g[a];
856
- } else (function(R, U) {
857
- for (var ee = U, ne = ee + 1, G = R.length; ne < G; ee += 1, ne += 1) R[ee] = R[ne];
855
+ delete g[r];
856
+ } else (function(R, j) {
857
+ for (var ee = j, ne = ee + 1, G = R.length; ne < G; ee += 1, ne += 1) R[ee] = R[ne];
858
858
  R.pop();
859
859
  })(u, b);
860
- g.removeListener && this.emit("removeListener", a, I || c);
860
+ g.removeListener && this.emit("removeListener", r, I || c);
861
861
  }
862
862
  return this;
863
- }, s.prototype.removeAllListeners = function(a) {
863
+ }, s.prototype.removeAllListeners = function(r) {
864
864
  var c, u;
865
865
  if (!(u = this._events)) return this;
866
- if (!u.removeListener) return arguments.length === 0 ? (this._events = new i(), this._eventsCount = 0) : u[a] && (--this._eventsCount == 0 ? this._events = new i() : delete u[a]), this;
866
+ if (!u.removeListener) return arguments.length === 0 ? (this._events = new i(), this._eventsCount = 0) : u[r] && (--this._eventsCount == 0 ? this._events = new i() : delete u[r]), this;
867
867
  if (arguments.length === 0) {
868
868
  for (var g, b = Object.keys(u), T = 0; T < b.length; ++T) (g = b[T]) !== "removeListener" && this.removeAllListeners(g);
869
869
  return this.removeAllListeners("removeListener"), this._events = new i(), this._eventsCount = 0, this;
870
870
  }
871
- if (typeof (c = u[a]) == "function") this.removeListener(a, c);
871
+ if (typeof (c = u[r]) == "function") this.removeListener(r, c);
872
872
  else if (c) do
873
- this.removeListener(a, c[c.length - 1]);
873
+ this.removeListener(r, c[c.length - 1]);
874
874
  while (c[0]);
875
875
  return this;
876
- }, s.prototype.listeners = function(a) {
876
+ }, s.prototype.listeners = function(r) {
877
877
  var c, u, g = this._events;
878
- return g ? u = (c = g[a]) ? typeof c == "function" ? [c.listener || c] : (function(b) {
878
+ return g ? u = (c = g[r]) ? typeof c == "function" ? [c.listener || c] : (function(b) {
879
879
  for (var T = Array(b.length), I = 0; I < T.length; ++I) T[I] = b[I].listener || b[I];
880
880
  return T;
881
881
  })(c) : [] : u = [], u;
882
- }, s.listenerCount = function(a, c) {
883
- return typeof a.listenerCount == "function" ? a.listenerCount(c) : l.call(a, c);
884
- }, s.prototype.listenerCount = l, s.prototype.eventNames = function() {
882
+ }, s.listenerCount = function(r, c) {
883
+ return typeof r.listenerCount == "function" ? r.listenerCount(c) : d.call(r, c);
884
+ }, s.prototype.listenerCount = d, s.prototype.eventNames = function() {
885
885
  return 0 < this._eventsCount ? Reflect.ownKeys(this._events) : [];
886
886
  };
887
887
  var f, v = new Uint8Array(16);
@@ -890,20 +890,20 @@ var Le, an = Yt((function(t, e) {
890
890
  return f(v);
891
891
  }
892
892
  for (var w = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i, C = [], k = 0; 256 > k; ++k) C.push((k + 256).toString(16).substr(1));
893
- function p(a) {
894
- var c = 1 < arguments.length && arguments[1] !== void 0 ? arguments[1] : 0, u = (C[a[c + 0]] + C[a[c + 1]] + C[a[c + 2]] + C[a[c + 3]] + "-" + C[a[c + 4]] + C[a[c + 5]] + "-" + C[a[c + 6]] + C[a[c + 7]] + "-" + C[a[c + 8]] + C[a[c + 9]] + "-" + C[a[c + 10]] + C[a[c + 11]] + C[a[c + 12]] + C[a[c + 13]] + C[a[c + 14]] + C[a[c + 15]]).toLowerCase();
893
+ function p(r) {
894
+ var c = 1 < arguments.length && arguments[1] !== void 0 ? arguments[1] : 0, u = (C[r[c + 0]] + C[r[c + 1]] + C[r[c + 2]] + C[r[c + 3]] + "-" + C[r[c + 4]] + C[r[c + 5]] + "-" + C[r[c + 6]] + C[r[c + 7]] + "-" + C[r[c + 8]] + C[r[c + 9]] + "-" + C[r[c + 10]] + C[r[c + 11]] + C[r[c + 12]] + C[r[c + 13]] + C[r[c + 14]] + C[r[c + 15]]).toLowerCase();
895
895
  if (!(function(g) {
896
896
  return typeof g == "string" && w.test(g);
897
897
  })(u)) throw TypeError("Stringified UUID is invalid");
898
898
  return u;
899
899
  }
900
- function S(a, c, u) {
901
- var g = (a = a || {}).random || (a.rng || _)();
900
+ function S(r, c, u) {
901
+ var g = (r = r || {}).random || (r.rng || _)();
902
902
  return g[6] = 64 | 15 & g[6], g[8] = 128 | 63 & g[8], p(g);
903
903
  }
904
- function A(a, c) {
905
- if (!a || !c) return {};
906
- const u = { ...a };
904
+ function A(r, c) {
905
+ if (!r || !c) return {};
906
+ const u = { ...r };
907
907
  if (u.localCandidateId) {
908
908
  const g = c.get(u.localCandidateId);
909
909
  u.local = { ...g };
@@ -914,33 +914,33 @@ var Le, an = Yt((function(t, e) {
914
914
  }
915
915
  return u;
916
916
  }
917
- function E(a, c, u) {
917
+ function E(r, c, u) {
918
918
  return 8 * (function(g, b, T) {
919
919
  const I = g[T], R = b ? b[T] : null;
920
920
  return I === null || R === null ? null : (I - R) / (g.timestamp - b.timestamp) * 1e3;
921
- })(a, c, u);
921
+ })(r, c, u);
922
922
  }
923
- function P(a) {
924
- if (!a.entries) return a;
923
+ function P(r) {
924
+ if (!r.entries) return r;
925
925
  const c = {};
926
- return a.forEach((function(u, g) {
926
+ return r.forEach((function(u, g) {
927
927
  c[g] = u;
928
928
  })), c;
929
929
  }
930
- function D(a, c, u = {}) {
931
- if (!a) return null;
930
+ function D(r, c, u = {}) {
931
+ if (!r) return null;
932
932
  let g = { audio: { inbound: [], outbound: [] }, video: { inbound: [], outbound: [] }, connection: { inbound: [], outbound: [] } };
933
933
  u.remote && (g.remote = { audio: { inbound: [], outbound: [] }, video: { inbound: [], outbound: [] } });
934
- for (const b of a.values()) switch (b.type) {
934
+ for (const b of r.values()) switch (b.type) {
935
935
  case "outbound-rtp": {
936
936
  const T = b.mediaType || b.kind, I = {};
937
937
  let R = {};
938
938
  if (!["audio", "video"].includes(T)) continue;
939
939
  if (b.codecId) {
940
- const U = a.get(b.codecId);
941
- U && (I.clockRate = U.clockRate, I.mimeType = U.mimeType, I.payloadType = U.payloadType);
940
+ const j = r.get(b.codecId);
941
+ j && (I.clockRate = j.clockRate, I.mimeType = j.mimeType, I.payloadType = j.payloadType);
942
942
  }
943
- R = a.get(b.mediaSourceId) || a.get(b.trackId) || {}, g[T].outbound.push({ ...b, ...I, track: { ...R } });
943
+ R = r.get(b.mediaSourceId) || r.get(b.trackId) || {}, g[T].outbound.push({ ...b, ...I, track: { ...R } });
944
944
  break;
945
945
  }
946
946
  case "inbound-rtp": {
@@ -952,17 +952,17 @@ var Le, an = Yt((function(t, e) {
952
952
  T = "audio";
953
953
  }
954
954
  if (b.codecId) {
955
- const U = a.get(b.codecId);
956
- U && (R.clockRate = U.clockRate, R.mimeType = U.mimeType, R.payloadType = U.payloadType);
955
+ const j = r.get(b.codecId);
956
+ j && (R.clockRate = j.clockRate, R.mimeType = j.mimeType, R.payloadType = j.payloadType);
957
957
  }
958
958
  if (!g.connection.id && b.transportId) {
959
- const U = a.get(b.transportId);
960
- if (U && U.selectedCandidatePairId) {
961
- const ee = a.get(U.selectedCandidatePairId);
962
- g.connection = A(ee, a);
959
+ const j = r.get(b.transportId);
960
+ if (j && j.selectedCandidatePairId) {
961
+ const ee = r.get(j.selectedCandidatePairId);
962
+ g.connection = A(ee, r);
963
963
  }
964
964
  }
965
- I = a.get(b.mediaSourceId) || a.get(b.trackId) || {}, g[T].inbound.push({ ...b, ...R, track: { ...I } });
965
+ I = r.get(b.mediaSourceId) || r.get(b.trackId) || {}, g[T].inbound.push({ ...b, ...R, track: { ...I } });
966
966
  break;
967
967
  }
968
968
  case "peer-connection":
@@ -978,14 +978,14 @@ var Le, an = Yt((function(t, e) {
978
978
  T = "audio";
979
979
  }
980
980
  if (b.codecId) {
981
- const R = a.get(b.codecId);
981
+ const R = r.get(b.codecId);
982
982
  R && (I.clockRate = R.clockRate, I.mimeType = R.mimeType, I.payloadType = R.payloadType);
983
983
  }
984
984
  if (!g.connection.id && b.transportId) {
985
- const R = a.get(b.transportId);
985
+ const R = r.get(b.transportId);
986
986
  if (R && R.selectedCandidatePairId) {
987
- const U = a.get(R.selectedCandidatePairId);
988
- g.connection = A(U, a);
987
+ const j = r.get(R.selectedCandidatePairId);
988
+ g.connection = A(j, r);
989
989
  }
990
990
  }
991
991
  g.remote[T].inbound.push({ ...b, ...I });
@@ -996,43 +996,43 @@ var Le, an = Yt((function(t, e) {
996
996
  const T = b.mediaType || b.kind, I = {};
997
997
  if (!["audio", "video"].includes(T)) continue;
998
998
  if (b.codecId) {
999
- const R = a.get(b.codecId);
999
+ const R = r.get(b.codecId);
1000
1000
  R && (I.clockRate = R.clockRate, I.mimeType = R.mimeType, I.payloadType = R.payloadType);
1001
1001
  }
1002
1002
  g.remote[T].outbound.push({ ...b, ...I });
1003
1003
  break;
1004
1004
  }
1005
1005
  }
1006
- if (!g.connection.id) for (const b of a.values()) b.type === "candidate-pair" && b.nominated && b.state === "succeeded" && (g.connection = A(b, a));
1006
+ if (!g.connection.id) for (const b of r.values()) b.type === "candidate-pair" && b.nominated && b.state === "succeeded" && (g.connection = A(b, r));
1007
1007
  return g = (function(b, T) {
1008
1008
  return T && (b.audio.inbound.map(((I) => {
1009
- let R = T.audio.inbound.find(((U) => U.id === I.id));
1009
+ let R = T.audio.inbound.find(((j) => j.id === I.id));
1010
1010
  I.bitrate = E(I, R, "bytesReceived"), I.packetRate = E(I, R, "packetsReceived");
1011
1011
  })), b.audio.outbound.map(((I) => {
1012
- let R = T.audio.outbound.find(((U) => U.id === I.id));
1012
+ let R = T.audio.outbound.find(((j) => j.id === I.id));
1013
1013
  I.bitrate = E(I, R, "bytesSent"), I.packetRate = E(I, R, "packetsSent");
1014
1014
  })), b.video.inbound.map(((I) => {
1015
- let R = T.video.inbound.find(((U) => U.id === I.id));
1015
+ let R = T.video.inbound.find(((j) => j.id === I.id));
1016
1016
  I.bitrate = E(I, R, "bytesReceived"), I.packetRate = E(I, R, "packetsReceived");
1017
1017
  })), b.video.outbound.map(((I) => {
1018
- let R = T.video.outbound.find(((U) => U.id === I.id));
1018
+ let R = T.video.outbound.find(((j) => j.id === I.id));
1019
1019
  I.bitrate = E(I, R, "bytesSent"), I.packetRate = E(I, R, "packetsSent");
1020
1020
  }))), b;
1021
1021
  })(g, c), g;
1022
1022
  }
1023
1023
  let q, B = {}, x = [];
1024
1024
  e.WebRTCStats = class extends s {
1025
- constructor(a) {
1025
+ constructor(r) {
1026
1026
  if (super(), this.monitoringSetInterval = 0, this.connectionMonitoringSetInterval = 0, this.connectionMonitoringInterval = 1e3, this.remote = !0, this.peersToMonitor = {}, this.timeline = [], this.statsToMonitor = ["inbound-rtp", "outbound-rtp", "remote-inbound-rtp", "remote-outbound-rtp", "peer-connection", "data-channel", "stream", "track", "sender", "receiver", "transport", "candidate-pair", "local-candidate", "remote-candidate"], typeof window > "u") throw new Error("WebRTCStats only works in browser");
1027
- const c = { ...a };
1027
+ const c = { ...r };
1028
1028
  this.isEdge = !!window.RTCIceGatherer, this.getStatsInterval = c.getStatsInterval || 1e3, this.rawStats = !!c.rawStats, this.statsObject = !!c.statsObject, this.filteredStats = !!c.filteredStats, this.shouldWrapGetUserMedia = !!c.wrapGetUserMedia, typeof c.remote == "boolean" && (this.remote = c.remote), this.debug = !!c.debug, this.logLevel = c.logLevel || "none", this.shouldWrapGetUserMedia && this.wrapGetUserMedia();
1029
1029
  }
1030
- async addPeer(a, c) {
1031
- return console.warn("The addPeer() method has been deprecated, please use addConnection()"), this.addConnection({ peerId: a, pc: c });
1030
+ async addPeer(r, c) {
1031
+ return console.warn("The addPeer() method has been deprecated, please use addConnection()"), this.addConnection({ peerId: r, pc: c });
1032
1032
  }
1033
- async addConnection(a) {
1034
- const { pc: c, peerId: u } = a;
1035
- let { connectionId: g, remote: b } = a;
1033
+ async addConnection(r) {
1034
+ const { pc: c, peerId: u } = r;
1035
+ let { connectionId: g, remote: b } = r;
1036
1036
  if (b = typeof b == "boolean" ? b : this.remote, !(c && c instanceof RTCPeerConnection)) throw new Error("Missing argument 'pc' or is not of instance RTCPeerConnection");
1037
1037
  if (!u) throw new Error("Missing argument peerId");
1038
1038
  if (this.isEdge) throw new Error("Can't monitor peers in Edge at this time.");
@@ -1047,28 +1047,28 @@ var Le, an = Yt((function(t, e) {
1047
1047
  const T = c.getConfiguration();
1048
1048
  return T.iceServers && T.iceServers.forEach((function(I) {
1049
1049
  delete I.credential;
1050
- })), g || (g = S()), this.emitEvent({ event: "addConnection", tag: "peer", peerId: u, connectionId: g, data: { options: a, peerConfiguration: T } }), this.monitorPeer({ peerId: u, connectionId: g, pc: c, remote: b }), { connectionId: g };
1050
+ })), g || (g = S()), this.emitEvent({ event: "addConnection", tag: "peer", peerId: u, connectionId: g, data: { options: r, peerConfiguration: T } }), this.monitorPeer({ peerId: u, connectionId: g, pc: c, remote: b }), { connectionId: g };
1051
1051
  }
1052
- getTimeline(a) {
1053
- return this.timeline = this.timeline.sort(((c, u) => c.timestamp.getTime() - u.timestamp.getTime())), a ? this.timeline.filter(((c) => c.tag === a)) : this.timeline;
1052
+ getTimeline(r) {
1053
+ return this.timeline = this.timeline.sort(((c, u) => c.timestamp.getTime() - u.timestamp.getTime())), r ? this.timeline.filter(((c) => c.tag === r)) : this.timeline;
1054
1054
  }
1055
1055
  get logger() {
1056
- const a = (c) => {
1056
+ const r = (c) => {
1057
1057
  const u = ["none", "error", "warn", "info", "debug"];
1058
1058
  return u.slice(0, u.indexOf(this.logLevel) + 1).indexOf(c) > -1;
1059
1059
  };
1060
1060
  return { error(...c) {
1061
- this.debug && a("error") && console.error("[webrtc-stats][error] ", ...c);
1061
+ this.debug && r("error") && console.error("[webrtc-stats][error] ", ...c);
1062
1062
  }, warn(...c) {
1063
- this.debug && a("warn") && console.warn("[webrtc-stats][warn] ", ...c);
1063
+ this.debug && r("warn") && console.warn("[webrtc-stats][warn] ", ...c);
1064
1064
  }, info(...c) {
1065
- this.debug && a("info") && console.log("[webrtc-stats][info] ", ...c);
1065
+ this.debug && r("info") && console.log("[webrtc-stats][info] ", ...c);
1066
1066
  }, debug(...c) {
1067
- this.debug && a("debug") && console.debug("[webrtc-stats][debug] ", ...c);
1067
+ this.debug && r("debug") && console.debug("[webrtc-stats][debug] ", ...c);
1068
1068
  } };
1069
1069
  }
1070
- removeConnection(a) {
1071
- let c, { connectionId: u, pc: g } = a;
1070
+ removeConnection(r) {
1071
+ let c, { connectionId: u, pc: g } = r;
1072
1072
  if (!g && !u) throw new Error("Missing arguments. You need to either send pc or a connectionId.");
1073
1073
  if (u) {
1074
1074
  if (typeof u != "string") throw new Error("connectionId must be a string.");
@@ -1081,24 +1081,24 @@ var Le, an = Yt((function(t, e) {
1081
1081
  return this.removePeerConnectionEventListeners(u, g), delete this.peersToMonitor[c][u], Object.values(this.peersToMonitor[c]).length === 0 && delete this.peersToMonitor[c], { connectionId: u };
1082
1082
  }
1083
1083
  removeAllPeers() {
1084
- for (let a in this.peersToMonitor) this.removePeer(a);
1084
+ for (let r in this.peersToMonitor) this.removePeer(r);
1085
1085
  }
1086
- removePeer(a) {
1087
- if (this.logger.info(`Removing PeerConnection with id ${a}.`), this.peersToMonitor[a]) {
1088
- for (let c in this.peersToMonitor[a]) {
1089
- let u = this.peersToMonitor[a][c].pc;
1086
+ removePeer(r) {
1087
+ if (this.logger.info(`Removing PeerConnection with id ${r}.`), this.peersToMonitor[r]) {
1088
+ for (let c in this.peersToMonitor[r]) {
1089
+ let u = this.peersToMonitor[r][c].pc;
1090
1090
  this.removePeerConnectionEventListeners(c, u);
1091
1091
  }
1092
- delete this.peersToMonitor[a];
1092
+ delete this.peersToMonitor[r];
1093
1093
  }
1094
1094
  }
1095
1095
  destroy() {
1096
- this.removeAllPeers(), x.forEach(((a) => {
1097
- this.removeTrackEventListeners(a);
1096
+ this.removeAllPeers(), x.forEach(((r) => {
1097
+ this.removeTrackEventListeners(r);
1098
1098
  })), x = [], this.shouldWrapGetUserMedia && q && (navigator.mediaDevices.getUserMedia = q);
1099
1099
  }
1100
- monitorPeer(a) {
1101
- let { peerId: c, connectionId: u, pc: g, remote: b } = a;
1100
+ monitorPeer(r) {
1101
+ let { peerId: c, connectionId: u, pc: g, remote: b } = r;
1102
1102
  if (!g) return void this.logger.warn("Did not receive pc argument when calling monitorPeer()");
1103
1103
  const T = { pc: g, connectionId: u, stream: null, stats: { parsed: null, raw: null }, options: { remote: b } };
1104
1104
  if (this.peersToMonitor[c]) {
@@ -1109,8 +1109,8 @@ var Le, an = Yt((function(t, e) {
1109
1109
  }
1110
1110
  startStatsMonitoring() {
1111
1111
  this.monitoringSetInterval || (this.monitoringSetInterval = window.setInterval((() => {
1112
- this.numberOfMonitoredPeers || this.stopStatsMonitoring(), this.getStats().then(((a) => {
1113
- a.forEach(((c) => {
1112
+ this.numberOfMonitoredPeers || this.stopStatsMonitoring(), this.getStats().then(((r) => {
1113
+ r.forEach(((c) => {
1114
1114
  this.emitEvent(c);
1115
1115
  }));
1116
1116
  }));
@@ -1119,21 +1119,21 @@ var Le, an = Yt((function(t, e) {
1119
1119
  stopStatsMonitoring() {
1120
1120
  this.monitoringSetInterval && (window.clearInterval(this.monitoringSetInterval), this.monitoringSetInterval = 0);
1121
1121
  }
1122
- async getStats(a = null) {
1123
- this.logger.info(a ? `Getting stats from peer ${a}` : "Getting stats from all peers");
1122
+ async getStats(r = null) {
1123
+ this.logger.info(r ? `Getting stats from peer ${r}` : "Getting stats from all peers");
1124
1124
  let c = {};
1125
- if (a) {
1126
- if (!this.peersToMonitor[a]) throw new Error(`Cannot get stats. Peer with id ${a} does not exist`);
1127
- c[a] = this.peersToMonitor[a];
1125
+ if (r) {
1126
+ if (!this.peersToMonitor[r]) throw new Error(`Cannot get stats. Peer with id ${r} does not exist`);
1127
+ c[r] = this.peersToMonitor[r];
1128
1128
  } else c = this.peersToMonitor;
1129
1129
  let u = [];
1130
1130
  for (const g in c) for (const b in c[g]) {
1131
1131
  const T = c[g][b], I = T.pc;
1132
1132
  if (I && !this.checkIfConnectionIsClosed(g, b, I)) try {
1133
- const R = this.getTimestamp(), U = I.getStats(null);
1134
- if (U) {
1135
- const ee = await U, ne = this.getTimestamp(), G = P(ee), m = { remote: T.options.remote }, M = D(ee, T.stats.parsed, m), j = { event: "stats", tag: "stats", peerId: g, connectionId: b, timeTaken: ne - R, data: M };
1136
- this.rawStats === !0 && (j.rawStats = ee), this.statsObject === !0 && (j.statsObject = G), this.filteredStats === !0 && (j.filteredStats = this.filteroutStats(G)), u.push(j), T.stats.parsed = M;
1133
+ const R = this.getTimestamp(), j = I.getStats(null);
1134
+ if (j) {
1135
+ const ee = await j, ne = this.getTimestamp(), G = P(ee), m = { remote: T.options.remote }, M = D(ee, T.stats.parsed, m), U = { event: "stats", tag: "stats", peerId: g, connectionId: b, timeTaken: ne - R, data: M };
1136
+ this.rawStats === !0 && (U.rawStats = ee), this.statsObject === !0 && (U.statsObject = G), this.filteredStats === !0 && (U.filteredStats = this.filteroutStats(G)), u.push(U), T.stats.parsed = M;
1137
1137
  } else this.logger.error(`PeerConnection from peer ${g} did not return any stats data`);
1138
1138
  } catch (R) {
1139
1139
  this.logger.error(R);
@@ -1144,23 +1144,23 @@ var Le, an = Yt((function(t, e) {
1144
1144
  startConnectionStateMonitoring() {
1145
1145
  this.connectionMonitoringSetInterval = window.setInterval((() => {
1146
1146
  this.numberOfMonitoredPeers || this.stopConnectionStateMonitoring();
1147
- for (const a in this.peersToMonitor) for (const c in this.peersToMonitor[a]) {
1148
- const u = this.peersToMonitor[a][c].pc;
1149
- this.checkIfConnectionIsClosed(a, c, u);
1147
+ for (const r in this.peersToMonitor) for (const c in this.peersToMonitor[r]) {
1148
+ const u = this.peersToMonitor[r][c].pc;
1149
+ this.checkIfConnectionIsClosed(r, c, u);
1150
1150
  }
1151
1151
  }), this.connectionMonitoringInterval);
1152
1152
  }
1153
- checkIfConnectionIsClosed(a, c, u) {
1153
+ checkIfConnectionIsClosed(r, c, u) {
1154
1154
  const g = this.isConnectionClosed(u);
1155
1155
  if (g) {
1156
1156
  this.removeConnection({ pc: u });
1157
1157
  let b = u.connectionState === "closed" ? "onconnectionstatechange" : "oniceconnectionstatechange";
1158
- this.emitEvent({ event: b, peerId: a, connectionId: c, tag: "connection", data: "closed" });
1158
+ this.emitEvent({ event: b, peerId: r, connectionId: c, tag: "connection", data: "closed" });
1159
1159
  }
1160
1160
  return g;
1161
1161
  }
1162
- isConnectionClosed(a) {
1163
- return a.connectionState === "closed" || a.iceConnectionState === "closed";
1162
+ isConnectionClosed(r) {
1163
+ return r.connectionState === "closed" || r.iceConnectionState === "closed";
1164
1164
  }
1165
1165
  stopConnectionStateMonitoring() {
1166
1166
  this.connectionMonitoringSetInterval && (window.clearInterval(this.connectionMonitoringSetInterval), this.connectionMonitoringSetInterval = 0);
@@ -1168,13 +1168,13 @@ var Le, an = Yt((function(t, e) {
1168
1168
  wrapGetUserMedia() {
1169
1169
  if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) return void this.logger.warn("'navigator.mediaDevices.getUserMedia' is not available in browser. Will not wrap getUserMedia.");
1170
1170
  this.logger.info("Wrapping getUsermedia functions."), q = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
1171
- const a = this.parseGetUserMedia.bind(this);
1171
+ const r = this.parseGetUserMedia.bind(this);
1172
1172
  navigator.mediaDevices.getUserMedia = (function() {
1173
- return a({ constraints: arguments[0] }), q.apply(navigator.mediaDevices, arguments).then(((c) => (a({ stream: c }), c)), ((c) => (a({ error: c }), Promise.reject(c))));
1173
+ return r({ constraints: arguments[0] }), q.apply(navigator.mediaDevices, arguments).then(((c) => (r({ stream: c }), c)), ((c) => (r({ error: c }), Promise.reject(c))));
1174
1174
  }).bind(navigator.mediaDevices);
1175
1175
  }
1176
- filteroutStats(a = {}) {
1177
- const c = { ...a };
1176
+ filteroutStats(r = {}) {
1177
+ const c = { ...r };
1178
1178
  for (const g in c) {
1179
1179
  var u = c[g];
1180
1180
  this.statsToMonitor.includes(u.type) || delete c[g];
@@ -1182,105 +1182,105 @@ var Le, an = Yt((function(t, e) {
1182
1182
  return c;
1183
1183
  }
1184
1184
  get peerConnectionListeners() {
1185
- return { icecandidate: (a, c, u, g) => {
1186
- this.logger.debug("[pc-event] icecandidate | peerId: ${peerId}", g), this.emitEvent({ event: "onicecandidate", tag: "connection", peerId: a, connectionId: c, data: g.candidate });
1187
- }, track: (a, c, u, g) => {
1188
- this.logger.debug(`[pc-event] track | peerId: ${a}`, g);
1185
+ return { icecandidate: (r, c, u, g) => {
1186
+ this.logger.debug("[pc-event] icecandidate | peerId: ${peerId}", g), this.emitEvent({ event: "onicecandidate", tag: "connection", peerId: r, connectionId: c, data: g.candidate });
1187
+ }, track: (r, c, u, g) => {
1188
+ this.logger.debug(`[pc-event] track | peerId: ${r}`, g);
1189
1189
  const b = g.track, T = g.streams[0];
1190
- a in this.peersToMonitor && c in this.peersToMonitor[a] && (this.peersToMonitor[a][c].stream = T), this.addTrackEventListeners(b, c), this.emitEvent({ event: "ontrack", tag: "track", peerId: a, connectionId: c, data: { stream: T ? this.getStreamDetails(T) : null, track: b ? this.getMediaTrackDetails(b) : null, title: g.track.kind + ":" + g.track.id + " " + g.streams.map((function(I) {
1190
+ r in this.peersToMonitor && c in this.peersToMonitor[r] && (this.peersToMonitor[r][c].stream = T), this.addTrackEventListeners(b, c), this.emitEvent({ event: "ontrack", tag: "track", peerId: r, connectionId: c, data: { stream: T ? this.getStreamDetails(T) : null, track: b ? this.getMediaTrackDetails(b) : null, title: g.track.kind + ":" + g.track.id + " " + g.streams.map((function(I) {
1191
1191
  return "stream:" + I.id;
1192
1192
  })) } });
1193
- }, signalingstatechange: (a, c, u) => {
1194
- this.logger.debug(`[pc-event] signalingstatechange | peerId: ${a}`), this.emitEvent({ event: "onsignalingstatechange", tag: "connection", peerId: a, connectionId: c, data: { signalingState: u.signalingState, localDescription: u.localDescription, remoteDescription: u.remoteDescription } });
1195
- }, iceconnectionstatechange: (a, c, u) => {
1196
- this.logger.debug(`[pc-event] iceconnectionstatechange | peerId: ${a}`), this.emitEvent({ event: "oniceconnectionstatechange", tag: "connection", peerId: a, connectionId: c, data: u.iceConnectionState });
1197
- }, icegatheringstatechange: (a, c, u) => {
1198
- this.logger.debug(`[pc-event] icegatheringstatechange | peerId: ${a}`), this.emitEvent({ event: "onicegatheringstatechange", tag: "connection", peerId: a, connectionId: c, data: u.iceGatheringState });
1199
- }, icecandidateerror: (a, c, u, g) => {
1200
- this.logger.debug(`[pc-event] icecandidateerror | peerId: ${a}`), this.emitEvent({ event: "onicecandidateerror", tag: "connection", peerId: a, connectionId: c, error: { errorCode: g.errorCode } });
1201
- }, connectionstatechange: (a, c, u) => {
1202
- this.logger.debug(`[pc-event] connectionstatechange | peerId: ${a}`), this.emitEvent({ event: "onconnectionstatechange", tag: "connection", peerId: a, connectionId: c, data: u.connectionState });
1203
- }, negotiationneeded: (a, c, u) => {
1204
- this.logger.debug(`[pc-event] negotiationneeded | peerId: ${a}`), this.emitEvent({ event: "onnegotiationneeded", tag: "connection", peerId: a, connectionId: c });
1205
- }, datachannel: (a, c, u, g) => {
1206
- this.logger.debug(`[pc-event] datachannel | peerId: ${a}`, g), this.emitEvent({ event: "ondatachannel", tag: "datachannel", peerId: a, connectionId: c, data: g.channel });
1193
+ }, signalingstatechange: (r, c, u) => {
1194
+ this.logger.debug(`[pc-event] signalingstatechange | peerId: ${r}`), this.emitEvent({ event: "onsignalingstatechange", tag: "connection", peerId: r, connectionId: c, data: { signalingState: u.signalingState, localDescription: u.localDescription, remoteDescription: u.remoteDescription } });
1195
+ }, iceconnectionstatechange: (r, c, u) => {
1196
+ this.logger.debug(`[pc-event] iceconnectionstatechange | peerId: ${r}`), this.emitEvent({ event: "oniceconnectionstatechange", tag: "connection", peerId: r, connectionId: c, data: u.iceConnectionState });
1197
+ }, icegatheringstatechange: (r, c, u) => {
1198
+ this.logger.debug(`[pc-event] icegatheringstatechange | peerId: ${r}`), this.emitEvent({ event: "onicegatheringstatechange", tag: "connection", peerId: r, connectionId: c, data: u.iceGatheringState });
1199
+ }, icecandidateerror: (r, c, u, g) => {
1200
+ this.logger.debug(`[pc-event] icecandidateerror | peerId: ${r}`), this.emitEvent({ event: "onicecandidateerror", tag: "connection", peerId: r, connectionId: c, error: { errorCode: g.errorCode } });
1201
+ }, connectionstatechange: (r, c, u) => {
1202
+ this.logger.debug(`[pc-event] connectionstatechange | peerId: ${r}`), this.emitEvent({ event: "onconnectionstatechange", tag: "connection", peerId: r, connectionId: c, data: u.connectionState });
1203
+ }, negotiationneeded: (r, c, u) => {
1204
+ this.logger.debug(`[pc-event] negotiationneeded | peerId: ${r}`), this.emitEvent({ event: "onnegotiationneeded", tag: "connection", peerId: r, connectionId: c });
1205
+ }, datachannel: (r, c, u, g) => {
1206
+ this.logger.debug(`[pc-event] datachannel | peerId: ${r}`, g), this.emitEvent({ event: "ondatachannel", tag: "datachannel", peerId: r, connectionId: c, data: g.channel });
1207
1207
  } };
1208
1208
  }
1209
- addPeerConnectionEventListeners(a, c, u) {
1210
- this.logger.debug(`Adding event listeners for peer ${a} and connection ${c}.`), B[c] = {}, Object.keys(this.peerConnectionListeners).forEach(((g) => {
1211
- B[c][g] = this.peerConnectionListeners[g].bind(this, a, c, u), u.addEventListener(g, B[c][g], !1);
1209
+ addPeerConnectionEventListeners(r, c, u) {
1210
+ this.logger.debug(`Adding event listeners for peer ${r} and connection ${c}.`), B[c] = {}, Object.keys(this.peerConnectionListeners).forEach(((g) => {
1211
+ B[c][g] = this.peerConnectionListeners[g].bind(this, r, c, u), u.addEventListener(g, B[c][g], !1);
1212
1212
  }));
1213
1213
  }
1214
- parseGetUserMedia(a) {
1214
+ parseGetUserMedia(r) {
1215
1215
  try {
1216
- const c = { event: "getUserMedia", tag: "getUserMedia", data: { ...a } };
1217
- a.stream && (c.data.details = this.parseStream(a.stream), a.stream.getTracks().map(((u) => {
1216
+ const c = { event: "getUserMedia", tag: "getUserMedia", data: { ...r } };
1217
+ r.stream && (c.data.details = this.parseStream(r.stream), r.stream.getTracks().map(((u) => {
1218
1218
  this.addTrackEventListeners(u), x.push(u);
1219
1219
  }))), this.emitEvent(c);
1220
1220
  } catch {
1221
1221
  }
1222
1222
  }
1223
- parseStream(a) {
1223
+ parseStream(r) {
1224
1224
  const c = { audio: [], video: [] };
1225
- return a.getTracks().forEach(((u) => {
1225
+ return r.getTracks().forEach(((u) => {
1226
1226
  c[u.kind].push(this.getMediaTrackDetails(u));
1227
1227
  })), c;
1228
1228
  }
1229
- getMediaTrackDetails(a) {
1230
- return { enabled: a.enabled, id: a.id, contentHint: a.contentHint, kind: a.kind, label: a.label, muted: a.muted, readyState: a.readyState, constructorName: a.constructor.name, capabilities: a.getCapabilities ? a.getCapabilities() : {}, constraints: a.getConstraints ? a.getConstraints() : {}, settings: a.getSettings ? a.getSettings() : {}, _track: a };
1229
+ getMediaTrackDetails(r) {
1230
+ return { enabled: r.enabled, id: r.id, contentHint: r.contentHint, kind: r.kind, label: r.label, muted: r.muted, readyState: r.readyState, constructorName: r.constructor.name, capabilities: r.getCapabilities ? r.getCapabilities() : {}, constraints: r.getConstraints ? r.getConstraints() : {}, settings: r.getSettings ? r.getSettings() : {}, _track: r };
1231
1231
  }
1232
- getStreamDetails(a) {
1233
- return { active: a.active, id: a.id, _stream: a };
1232
+ getStreamDetails(r) {
1233
+ return { active: r.active, id: r.id, _stream: r };
1234
1234
  }
1235
- getTrackEventObject(a) {
1235
+ getTrackEventObject(r) {
1236
1236
  return { mute: (c) => {
1237
- this.emitEvent({ event: "mute", tag: "track", connectionId: a, data: { event: c } });
1237
+ this.emitEvent({ event: "mute", tag: "track", connectionId: r, data: { event: c } });
1238
1238
  }, unmute: (c) => {
1239
- this.emitEvent({ event: "unmute", tag: "track", connectionId: a, data: { event: c } });
1239
+ this.emitEvent({ event: "unmute", tag: "track", connectionId: r, data: { event: c } });
1240
1240
  }, overconstrained: (c) => {
1241
- this.emitEvent({ event: "overconstrained", tag: "track", connectionId: a, data: { event: c } });
1241
+ this.emitEvent({ event: "overconstrained", tag: "track", connectionId: r, data: { event: c } });
1242
1242
  }, ended: (c) => {
1243
- this.emitEvent({ event: "ended", tag: "track", connectionId: a, data: { event: c } }), this.removeTrackEventListeners(c.target);
1243
+ this.emitEvent({ event: "ended", tag: "track", connectionId: r, data: { event: c } }), this.removeTrackEventListeners(c.target);
1244
1244
  } };
1245
1245
  }
1246
- addTrackEventListeners(a, c) {
1247
- B[a.id] = {};
1246
+ addTrackEventListeners(r, c) {
1247
+ B[r.id] = {};
1248
1248
  const u = this.getTrackEventObject(c);
1249
1249
  Object.keys(u).forEach(((g) => {
1250
- B[a.id][g] = u[g].bind(this), a.addEventListener(g, B[a.id][g]);
1251
- })), B[a.id].readyState = setInterval((() => {
1252
- if (a.readyState === "ended") {
1250
+ B[r.id][g] = u[g].bind(this), r.addEventListener(g, B[r.id][g]);
1251
+ })), B[r.id].readyState = setInterval((() => {
1252
+ if (r.readyState === "ended") {
1253
1253
  let g = new CustomEvent("ended", { detail: { check: "readyState" } });
1254
- a.dispatchEvent(g);
1254
+ r.dispatchEvent(g);
1255
1255
  }
1256
1256
  }), 1e3);
1257
1257
  }
1258
- removeTrackEventListeners(a) {
1259
- if (a.id in B) {
1258
+ removeTrackEventListeners(r) {
1259
+ if (r.id in B) {
1260
1260
  const c = this.getTrackEventObject();
1261
1261
  Object.keys(c).forEach(((u) => {
1262
- a.removeEventListener(u, B[a.id][u]);
1263
- })), clearInterval(B[a.id].readyState), delete B[a.id];
1262
+ r.removeEventListener(u, B[r.id][u]);
1263
+ })), clearInterval(B[r.id].readyState), delete B[r.id];
1264
1264
  }
1265
1265
  }
1266
- addToTimeline(a) {
1267
- this.timeline.push(a), this.emit("timeline", a);
1266
+ addToTimeline(r) {
1267
+ this.timeline.push(r), this.emit("timeline", r);
1268
1268
  }
1269
- emitEvent(a) {
1270
- const c = { ...a, timestamp: /* @__PURE__ */ new Date() };
1269
+ emitEvent(r) {
1270
+ const c = { ...r, timestamp: /* @__PURE__ */ new Date() };
1271
1271
  this.addToTimeline(c), c.tag && this.emit(c.tag, c);
1272
1272
  }
1273
- set getStatsInterval(a) {
1274
- if (!Number.isInteger(a)) throw new Error(`getStatsInterval should be an integer, got: ${a}`);
1275
- this._getStatsInterval = a, this.monitoringSetInterval && (this.stopStatsMonitoring(), this.startStatsMonitoring());
1273
+ set getStatsInterval(r) {
1274
+ if (!Number.isInteger(r)) throw new Error(`getStatsInterval should be an integer, got: ${r}`);
1275
+ this._getStatsInterval = r, this.monitoringSetInterval && (this.stopStatsMonitoring(), this.startStatsMonitoring());
1276
1276
  }
1277
1277
  get numberOfMonitoredPeers() {
1278
1278
  return Object.keys(this.peersToMonitor).length;
1279
1279
  }
1280
- removePeerConnectionEventListeners(a, c) {
1281
- a in B && (Object.keys(this.peerConnectionListeners).forEach(((u) => {
1282
- c.removeEventListener(u, B[a][u], !1);
1283
- })), delete B[a]), c.getSenders().forEach(((u) => {
1280
+ removePeerConnectionEventListeners(r, c) {
1281
+ r in B && (Object.keys(this.peerConnectionListeners).forEach(((u) => {
1282
+ c.removeEventListener(u, B[r][u], !1);
1283
+ })), delete B[r]), c.getSenders().forEach(((u) => {
1284
1284
  u.track && this.removeTrackEventListeners(u.track);
1285
1285
  })), c.getReceivers().forEach(((u) => {
1286
1286
  u.track && this.removeTrackEventListeners(u.track);
@@ -1290,13 +1290,13 @@ var Le, an = Yt((function(t, e) {
1290
1290
  return Date.now();
1291
1291
  }
1292
1292
  wrapGetDisplayMedia() {
1293
- const a = this;
1293
+ const r = this;
1294
1294
  if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
1295
1295
  const c = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices), u = function() {
1296
- return a.debug("navigator.mediaDevices.getDisplayMedia", null, arguments[0]), c.apply(navigator.mediaDevices, arguments).then((function(g) {
1296
+ return r.debug("navigator.mediaDevices.getDisplayMedia", null, arguments[0]), c.apply(navigator.mediaDevices, arguments).then((function(g) {
1297
1297
  return g;
1298
1298
  }), (function(g) {
1299
- return a.debug("navigator.mediaDevices.getDisplayMediaOnFailure", null, g.name), Promise.reject(g);
1299
+ return r.debug("navigator.mediaDevices.getDisplayMediaOnFailure", null, g.name), Promise.reject(g);
1300
1300
  }));
1301
1301
  };
1302
1302
  navigator.mediaDevices.getDisplayMedia = u.bind(navigator.mediaDevices);
@@ -1304,27 +1304,27 @@ var Le, an = Yt((function(t, e) {
1304
1304
  }
1305
1305
  };
1306
1306
  }));
1307
- (Le = an) && Le.__esModule && Object.prototype.hasOwnProperty.call(Le, "default") && Le.default;
1308
- var oi = an.WebRTCStats;
1309
- function ri(t) {
1310
- const { packetsLost: e, packetsReceived: n, jitter: i, rtt: s } = t, r = (function(h) {
1307
+ (Oe = rn) && Oe.__esModule && Object.prototype.hasOwnProperty.call(Oe, "default") && Oe.default;
1308
+ var si = rn.WebRTCStats;
1309
+ function oi(t) {
1310
+ const { packetsLost: e, packetsReceived: n, jitter: i, rtt: s } = t, a = (function(h) {
1311
1311
  const { jitter: f, rtt: v } = h, _ = f + v / 2;
1312
1312
  return 0.024 * _ + 0.11 * (_ - 177.3) * (_ > 177.3 ? 1 : 0);
1313
1313
  })({ rtt: s, jitter: i }), o = (function(h) {
1314
1314
  const { packetsLost: f, packetsReceived: v } = h, _ = f / (v + f) * 100;
1315
1315
  return 20 * Math.log(1 + _);
1316
- })({ packetsLost: e, packetsReceived: n }), d = 93.2 - r - o + 0, l = 1 + 0.035 * d + 7e-6 * d * (d - 60) * (100 - d);
1317
- return Math.min(Math.max(l, 1), 5);
1316
+ })({ packetsLost: e, packetsReceived: n }), l = 93.2 - a - o + 0, d = 1 + 0.035 * l + 7e-6 * l * (l - 60) * (100 - l);
1317
+ return Math.min(Math.max(d, 1), 5);
1318
1318
  }
1319
- function ai(t) {
1319
+ function ri(t) {
1320
1320
  return isNaN(t) ? null : t > 4.2 ? "excellent" : t >= 4.1 && t <= 4.2 ? "good" : t >= 3.7 && t <= 4 ? "fair" : t >= 3.1 && t <= 3.6 ? "poor" : "bad";
1321
1321
  }
1322
- class ci extends Re {
1322
+ class ai extends Re {
1323
1323
  constructor(e, n) {
1324
1324
  super(), this.buildRequest({ type: "debug_report_start", debug_report_id: e, debug_report_version: 1, call_id: n });
1325
1325
  }
1326
1326
  }
1327
- class di extends Re {
1327
+ class ci extends Re {
1328
1328
  constructor(e, n) {
1329
1329
  super(), this.buildRequest({ type: "debug_report_stop", debug_report_id: e, debug_report_version: 1, call_id: n });
1330
1330
  }
@@ -1334,63 +1334,63 @@ class li extends Re {
1334
1334
  super(), this.buildRequest({ type: "debug_report_data", debug_report_id: e, debug_report_version: 1, debug_report_data: n });
1335
1335
  }
1336
1336
  }
1337
- function xt(t, e) {
1337
+ function Rt(t, e) {
1338
1338
  var n, i;
1339
1339
  return { errorCode: t.errorCode, errorText: t.errorText, url: t.url, address: t.address, port: t.port, connectionState: e.connectionState, iceConnectionState: e.iceConnectionState, iceGatheringState: e.iceGatheringState, signalingState: e.signalingState, localDescriptionType: (n = e.localDescription) === null || n === void 0 ? void 0 : n.type, remoteDescriptionType: (i = e.remoteDescription) === null || i === void 0 ? void 0 : i.type };
1340
1340
  }
1341
- function ui(t, e) {
1342
- const n = me(), i = new oi({ getStatsInterval: 1e3, rawStats: !1, statsObject: !0, filteredStats: !1, remote: !0, debug: !1, logLevel: "warn" }), s = (r) => L(this, void 0, void 0, (function* () {
1343
- r.event === "stats" && $(O.StatsFrame, (function({ data: o }) {
1344
- var d, l, h, f, v, _, w, C;
1345
- const { audio: k, remote: p } = o, { audio: S } = p, A = (l = (d = S.inbound[0]) === null || d === void 0 ? void 0 : d.jitter) !== null && l !== void 0 ? l : 1 / 0, E = (f = (h = S.inbound[0]) === null || h === void 0 ? void 0 : h.roundTripTime) !== null && f !== void 0 ? f : 1 / 0, P = (_ = (v = k.inbound[0]) === null || v === void 0 ? void 0 : v.packetsReceived) !== null && _ !== void 0 ? _ : -1, D = (C = (w = k.inbound[0]) === null || w === void 0 ? void 0 : w.packetsLost) !== null && C !== void 0 ? C : -1, q = ri({ jitter: 1e3 * A, rtt: 1e3 * E, packetsLost: D, packetsReceived: P });
1346
- return { jitter: A, rtt: E, mos: q, quality: ai(q), inboundAudio: k.inbound[0], outboundAudio: k.outbound[0], remoteInboundAudio: S.inbound[0], remoteOutboundAudio: S.outbound[0] };
1347
- })(r), t.uuid), yield t.execute(new li(n, r));
1341
+ function di(t, e) {
1342
+ const n = me(), i = new si({ getStatsInterval: 1e3, rawStats: !1, statsObject: !0, filteredStats: !1, remote: !0, debug: !1, logLevel: "warn" }), s = (a) => O(this, void 0, void 0, (function* () {
1343
+ a.event === "stats" && F(L.StatsFrame, (function({ data: o }) {
1344
+ var l, d, h, f, v, _, w, C;
1345
+ const { audio: k, remote: p } = o, { audio: S } = p, A = (d = (l = S.inbound[0]) === null || l === void 0 ? void 0 : l.jitter) !== null && d !== void 0 ? d : 1 / 0, E = (f = (h = S.inbound[0]) === null || h === void 0 ? void 0 : h.roundTripTime) !== null && f !== void 0 ? f : 1 / 0, P = (_ = (v = k.inbound[0]) === null || v === void 0 ? void 0 : v.packetsReceived) !== null && _ !== void 0 ? _ : -1, D = (C = (w = k.inbound[0]) === null || w === void 0 ? void 0 : w.packetsLost) !== null && C !== void 0 ? C : -1, q = oi({ jitter: 1e3 * A, rtt: 1e3 * E, packetsLost: D, packetsReceived: P });
1346
+ return { jitter: A, rtt: E, mos: q, quality: ri(q), inboundAudio: k.inbound[0], outboundAudio: k.outbound[0], remoteInboundAudio: S.inbound[0], remoteOutboundAudio: S.outbound[0] };
1347
+ })(a), t.uuid), yield t.execute(new li(n, a));
1348
1348
  }));
1349
- return { start: (r, o, d) => L(this, void 0, void 0, (function* () {
1350
- yield t.execute(new ci(n, e)), i.on("timeline", s), yield new Promise(((l) => setTimeout(l, 500))), i.addConnection({ pc: r, peerId: o, connectionId: d });
1351
- })), stop: (r) => L(this, void 0, void 0, (function* () {
1349
+ return { start: (a, o, l) => O(this, void 0, void 0, (function* () {
1350
+ yield t.execute(new ai(n, e)), i.on("timeline", s), yield new Promise(((d) => setTimeout(d, 500))), i.addConnection({ pc: a, peerId: o, connectionId: l });
1351
+ })), stop: (a) => O(this, void 0, void 0, (function* () {
1352
1352
  const o = i.getTimeline();
1353
- $(O.StatsReport, o, t.uuid), r === "file" && (function(d, l) {
1354
- const h = new Blob([JSON.stringify(d)], { type: "application/json" }), f = URL.createObjectURL(h), v = document.createElement("a");
1355
- v.href = f, v.download = `${l}.json`, v.click(), URL.revokeObjectURL(f);
1356
- })(o, `webrtc-stats-${n}-${Date.now()}`), yield t.execute(new di(n, e)), i.removeAllPeers(), i.destroy();
1357
- })), reportConnectionStateChange: (r) => {
1358
- const o = { event: "connectionstatechange-detailed", tag: "connection", timestamp: (/* @__PURE__ */ new Date()).toISOString(), data: r };
1353
+ F(L.StatsReport, o, t.uuid), a === "file" && (function(l, d) {
1354
+ const h = new Blob([JSON.stringify(l)], { type: "application/json" }), f = URL.createObjectURL(h), v = document.createElement("a");
1355
+ v.href = f, v.download = `${d}.json`, v.click(), URL.revokeObjectURL(f);
1356
+ })(o, `webrtc-stats-${n}-${Date.now()}`), yield t.execute(new ci(n, e)), i.removeAllPeers(), i.destroy();
1357
+ })), reportConnectionStateChange: (a) => {
1358
+ const o = { event: "connectionstatechange-detailed", tag: "connection", timestamp: (/* @__PURE__ */ new Date()).toISOString(), data: a };
1359
1359
  s(o);
1360
- }, reportIceCandidateError: (r) => {
1361
- const o = { event: "icecandidateerror-detailed", tag: "connection", timestamp: (/* @__PURE__ */ new Date()).toISOString(), data: r };
1360
+ }, reportIceCandidateError: (a) => {
1361
+ const o = { event: "icecandidateerror-detailed", tag: "connection", timestamp: (/* @__PURE__ */ new Date()).toISOString(), data: a };
1362
1362
  s(o);
1363
1363
  } };
1364
1364
  }
1365
- const cn = (t, e) => {
1366
- const { contentType: n, canvasType: i, callID: s, canvasInfo: r = null, currentLayerIdx: o = -1 } = e;
1367
- r && i !== "mcu-personal-canvas" && delete r.memberID;
1368
- const d = { type: oe.conferenceUpdate, call: t.calls[s], canvasInfo: hi(r), currentLayerIdx: o };
1365
+ const an = (t, e) => {
1366
+ const { contentType: n, canvasType: i, callID: s, canvasInfo: a = null, currentLayerIdx: o = -1 } = e;
1367
+ a && i !== "mcu-personal-canvas" && delete a.memberID;
1368
+ const l = { type: oe.conferenceUpdate, call: t.calls[s], canvasInfo: ui(a), currentLayerIdx: o };
1369
1369
  switch (n) {
1370
1370
  case "layer-info": {
1371
- const l = Object.assign({ action: se.LayerInfo }, d);
1372
- $(O.Notification, l, t.uuid);
1371
+ const d = Object.assign({ action: se.LayerInfo }, l);
1372
+ F(L.Notification, d, t.uuid);
1373
1373
  break;
1374
1374
  }
1375
1375
  case "layout-info": {
1376
- const l = Object.assign({ action: se.LayoutInfo }, d);
1377
- $(O.Notification, l, t.uuid);
1376
+ const d = Object.assign({ action: se.LayoutInfo }, l);
1377
+ F(L.Notification, d, t.uuid);
1378
1378
  break;
1379
1379
  }
1380
1380
  }
1381
- }, hi = (t) => {
1381
+ }, ui = (t) => {
1382
1382
  const e = JSON.stringify(t).replace(/memberID/g, "participantId").replace(/ID"/g, 'Id"').replace(/POS"/g, 'Pos"');
1383
- return zt(e);
1383
+ return Yt(e);
1384
1384
  };
1385
- class Ot {
1386
- constructor(e, n, i, s, r) {
1387
- this.type = e, this.options = n, this.onSdpReadyTwice = null, this.statsReporter = null, this._negotiating = !1, this._prevConnectionState = null, this._restartedIceOnConnectionStateFailed = !1, this._sleepWakeupIntervalId = null, this.handleConnectionStateChange = (o) => L(this, void 0, void 0, (function* () {
1388
- const { connectionState: d } = this.instance;
1389
- if (y.info(`[${(/* @__PURE__ */ new Date()).toISOString()}] Connection State changed: ${this._prevConnectionState} -> ${d}`), d === "failed" || d === "disconnected") {
1390
- const l = () => L(this, void 0, void 0, (function* () {
1385
+ class xt {
1386
+ constructor(e, n, i, s, a) {
1387
+ this.type = e, this.options = n, this.onSdpReadyTwice = null, this.statsReporter = null, this._negotiating = !1, this._prevConnectionState = null, this._restartedIceOnConnectionStateFailed = !1, this._sleepWakeupIntervalId = null, this.handleConnectionStateChange = (o) => O(this, void 0, void 0, (function* () {
1388
+ const { connectionState: l } = this.instance;
1389
+ if (y.info(`[${(/* @__PURE__ */ new Date()).toISOString()}] Connection State changed: ${this._prevConnectionState} -> ${l}`), l === "failed" || l === "disconnected") {
1390
+ const d = () => O(this, void 0, void 0, (function* () {
1391
1391
  if (this.isDebugEnabled && this.statsReporter) {
1392
1392
  const h = yield (function(f, v) {
1393
- return L(this, void 0, void 0, (function* () {
1393
+ return O(this, void 0, void 0, (function* () {
1394
1394
  const _ = { connectionState: f.connectionState, previousConnectionState: v, iceConnectionState: f.iceConnectionState, iceGatheringState: f.iceGatheringState, signalingState: f.signalingState }, w = f.getTransceivers();
1395
1395
  if (w.length > 0) {
1396
1396
  const C = w[0].sender, k = C?.transport;
@@ -1412,18 +1412,18 @@ class Ot {
1412
1412
  })(this.instance, this._prevConnectionState);
1413
1413
  this.statsReporter.reportConnectionStateChange(h);
1414
1414
  }
1415
- this._restartedIceOnConnectionStateFailed ? (y.debug("Peer Connection failed again after ICE restart. Recovering call via peer reconnection through error handling."), $(O.PeerConnectionFailureError, { error: new Error(`Peer Connection failed twice. previous state: ${this._prevConnectionState}, current state: ${d}`), sessionId: this._session.sessionid }, this.options.id)) : (this.instance.restartIce(), d === "failed" && (this._restartedIceOnConnectionStateFailed = !0, y.debug("ICE has been restarted on connection state failed.")), this._isTrickleIce() ? yield this.startTrickleIceNegotiation() : this.startNegotiation()), window.removeEventListener("online", l);
1415
+ this._restartedIceOnConnectionStateFailed ? (y.debug("Peer Connection failed again after ICE restart. Recovering call via peer reconnection through error handling."), F(L.PeerConnectionFailureError, { error: new Error(`Peer Connection failed twice. previous state: ${this._prevConnectionState}, current state: ${l}`), sessionId: this._session.sessionid }, this.options.id)) : (this.instance.restartIce(), l === "failed" && (this._restartedIceOnConnectionStateFailed = !0, y.debug("ICE has been restarted on connection state failed.")), this._isTrickleIce() ? yield this.startTrickleIceNegotiation() : this.startNegotiation()), window.removeEventListener("online", d);
1416
1416
  }));
1417
- navigator.onLine ? l() : window.addEventListener("online", l);
1417
+ navigator.onLine ? d() : window.addEventListener("online", d);
1418
1418
  }
1419
- this._prevConnectionState === "connected" && d === "disconnected" && (yield this._resetJitterBuffer()), this._prevConnectionState === "disconnected" && d === "connected" && (yield this._resetJitterBuffer()), this._prevConnectionState = d, this._isTrickleIce() && (d === "connecting" && performance.mark("peer-connection-connecting"), d === "connected" && (performance.mark("peer-connection-connected"), console.group("Performance Metrics"), console.table(this.trickleIcePerformanceMetrics), console.groupEnd(), performance.clearMarks())), this._restartNegotiationOnDeviceSleepWakeup();
1419
+ this._prevConnectionState === "connected" && l === "disconnected" && (yield this._resetJitterBuffer()), this._prevConnectionState === "disconnected" && l === "connected" && (yield this._resetJitterBuffer()), this._prevConnectionState = l, this._isTrickleIce() && (l === "connecting" && performance.mark("peer-connection-connecting"), l === "connected" && (performance.mark("peer-connection-connected"), console.group("Performance Metrics"), console.table(this.trickleIcePerformanceMetrics), console.groupEnd(), performance.clearMarks())), this._restartNegotiationOnDeviceSleepWakeup();
1420
1420
  })), this._handleIceConnectionStateChange = (o) => {
1421
1421
  y.debug(`[${(/* @__PURE__ */ new Date()).toISOString()}] ICE Connection State`, this.instance.iceConnectionState);
1422
1422
  }, this._handleIceGatheringStateChange = (o) => {
1423
1423
  y.debug(`[${(/* @__PURE__ */ new Date()).toISOString()}] ICE Gathering State`, this.instance.iceGatheringState);
1424
- }, this._setCodecs = (o, d) => {
1425
- if (o.setCodecPreferences) return o.setCodecPreferences(d);
1426
- }, y.info("New Peer with type:", this.type, "Options:", this.options), this._constraints = { offerToReceiveAudio: !0, offerToReceiveVideo: !!n.video }, this._sdpReady = this._sdpReady.bind(this), this.handleSignalingStateChangeEvent = this.handleSignalingStateChangeEvent.bind(this), this.handleNegotiationNeededEvent = this.handleNegotiationNeededEvent.bind(this), this.handleTrackEvent = this.handleTrackEvent.bind(this), this.createPeerConnection = this.createPeerConnection.bind(this), this._session = i, this._trickleIceSdpFn = s, this._registerPeerEvents = r;
1424
+ }, this._setCodecs = (o, l) => {
1425
+ if (o.setCodecPreferences) return o.setCodecPreferences(l);
1426
+ }, y.info("New Peer with type:", this.type, "Options:", this.options), this._constraints = { offerToReceiveAudio: !0, offerToReceiveVideo: !!n.video }, this._sdpReady = this._sdpReady.bind(this), this.handleSignalingStateChangeEvent = this.handleSignalingStateChangeEvent.bind(this), this.handleNegotiationNeededEvent = this.handleNegotiationNeededEvent.bind(this), this.handleTrackEvent = this.handleTrackEvent.bind(this), this.createPeerConnection = this.createPeerConnection.bind(this), this._session = i, this._trickleIceSdpFn = s, this._registerPeerEvents = a;
1427
1427
  }
1428
1428
  get isOffer() {
1429
1429
  return this.type === K.Offer;
@@ -1444,7 +1444,7 @@ class Ot {
1444
1444
  performance.mark("ice-gathering-start"), this._negotiating = !0, this._isOffer() ? this._createOffer() : this._createAnswer();
1445
1445
  }
1446
1446
  startTrickleIceNegotiation() {
1447
- return L(this, void 0, void 0, (function* () {
1447
+ return O(this, void 0, void 0, (function* () {
1448
1448
  performance.mark("ice-gathering-start"), this._negotiating = !0, this._isOffer() ? yield this._createOffer().then(this._trickleIceSdpFn.bind(this)) : yield this._createAnswer().then(this._trickleIceSdpFn.bind(this));
1449
1449
  }));
1450
1450
  }
@@ -1454,8 +1454,8 @@ class Ot {
1454
1454
  }));
1455
1455
  }
1456
1456
  get trickleIcePerformanceMetrics() {
1457
- const e = performance.measure("new-call", "new-call-start", "new-call-end"), n = performance.measure("peer-creation", "peer-creation-start", "peer-creation-end"), i = performance.measure("ice-gathering", "ice-gathering-start", "ice-gathering-end"), s = performance.measure("sdp-send", "sdp-send-start", "sdp-send-end"), r = performance.measure("invite-send", "new-call-start", "sdp-send-start"), o = performance.measure("total-duration", "peer-creation-start", "sdp-send-end"), d = (l) => `${l.toFixed(2)}ms`;
1458
- return { "New Call": { duration: d(e.duration) }, "Peer Creation": { duration: d(n.duration) }, "ICE Gathering": { duration: d(i.duration) }, [this._isOffer() ? "Invite Send" : "Answer Send"]: { duration: d(r.duration) }, "SDP Send": { duration: d(s.duration) }, "Total Duration": { duration: d(o.duration) } };
1457
+ const e = performance.measure("new-call", "new-call-start", "new-call-end"), n = performance.measure("peer-creation", "peer-creation-start", "peer-creation-end"), i = performance.measure("ice-gathering", "ice-gathering-start", "ice-gathering-end"), s = performance.measure("sdp-send", "sdp-send-start", "sdp-send-end"), a = performance.measure("invite-send", "new-call-start", "sdp-send-start"), o = performance.measure("total-duration", "peer-creation-start", "sdp-send-end"), l = (d) => `${d.toFixed(2)}ms`;
1458
+ return { "New Call": { duration: l(e.duration) }, "Peer Creation": { duration: l(n.duration) }, "ICE Gathering": { duration: l(i.duration) }, [this._isOffer() ? "Invite Send" : "Answer Send"]: { duration: l(a.duration) }, "SDP Send": { duration: l(s.duration) }, "Total Duration": { duration: l(o.duration) } };
1459
1459
  }
1460
1460
  handleSignalingStateChangeEvent(e) {
1461
1461
  switch (y.info("signalingState:", this.instance.signalingState), this.instance.signalingState) {
@@ -1475,34 +1475,34 @@ class Ot {
1475
1475
  }
1476
1476
  handleTrackEvent(e) {
1477
1477
  const { streams: [n] } = e, { remoteElement: i, screenShare: s } = this.options;
1478
- let { remoteStream: r } = this.options;
1479
- r = n, s === !1 && Ee(i, r);
1478
+ let { remoteStream: a } = this.options;
1479
+ a = n, s === !1 && Ee(i, a);
1480
1480
  }
1481
1481
  createPeerConnection() {
1482
- return L(this, void 0, void 0, (function* () {
1482
+ return O(this, void 0, void 0, (function* () {
1483
1483
  var e;
1484
1484
  this.instance = (e = this._config(), new window.RTCPeerConnection(e)), this.instance.onsignalingstatechange = this.handleSignalingStateChangeEvent, this.instance.onnegotiationneeded = this.handleNegotiationNeededEvent, this.instance.ontrack = this.handleTrackEvent, this.instance.addEventListener("connectionstatechange", this.handleConnectionStateChange), this.instance.addEventListener("iceconnectionstatechange", this._handleIceConnectionStateChange), this.instance.addEventListener("icegatheringstatechange", this._handleIceGatheringStateChange), this.instance.addEventListener("addstream", ((n) => {
1485
1485
  this.options.remoteStream = n.stream;
1486
- })), this._registerPeerEvents(this.instance), this._prevConnectionState = this.instance.connectionState, this.isAnswer && (yield this._setRemoteDescription({ sdp: this.options.remoteSdp, type: K.Offer })), this.options.localStream = yield this._retrieveLocalStream().catch(((n) => ($(O.MediaError, n, this.options.id), null))), this.options.mutedMicOnStart && ge(this.options.localStream) && (y.info("Muting local audio tracks on start"), ot(this.options.localStream)), performance.mark("peer-creation-end");
1486
+ })), this._registerPeerEvents(this.instance), this._prevConnectionState = this.instance.connectionState, this.isAnswer && (yield this._setRemoteDescription({ sdp: this.options.remoteSdp, type: K.Offer })), this.options.localStream = yield this._retrieveLocalStream().catch(((n) => (F(L.MediaError, n, this.options.id), null))), this.options.mutedMicOnStart && ge(this.options.localStream) && (y.info("Muting local audio tracks on start"), st(this.options.localStream)), performance.mark("peer-creation-end");
1487
1487
  }));
1488
1488
  }
1489
1489
  init() {
1490
1490
  var e;
1491
- return L(this, void 0, void 0, (function* () {
1492
- yield this.createPeerConnection(), this.isDebugEnabled && (this.statsReporter = ui(this._session, this.options.id), yield (e = this.statsReporter) === null || e === void 0 ? void 0 : e.start(this.instance, this._session.sessionid, this._session.sessionid));
1491
+ return O(this, void 0, void 0, (function* () {
1492
+ yield this.createPeerConnection(), this.isDebugEnabled && (this.statsReporter = di(this._session, this.options.id), yield (e = this.statsReporter) === null || e === void 0 ? void 0 : e.start(this.instance, this._session.sessionid, this._session.sessionid));
1493
1493
  const { localElement: n, localStream: i = null, screenShare: s = !1 } = this.options;
1494
1494
  if (ge(i)) {
1495
- const r = i.getAudioTracks();
1496
- let o = [...r];
1497
- if (y.info("Local audio tracks: ", r), typeof this.options.audio == "object" && r.forEach(((h) => {
1495
+ const a = i.getAudioTracks();
1496
+ let o = [...a];
1497
+ if (y.info("Local audio tracks: ", a), typeof this.options.audio == "object" && a.forEach(((h) => {
1498
1498
  y.info("Local audio tracks constraints: ", h.getConstraints());
1499
1499
  })), this.options.video) {
1500
1500
  const h = i.getVideoTracks();
1501
- o = [...r, ...h], y.info("Local video tracks: ", h), typeof this.options.video == "object" && h.forEach(((f) => {
1501
+ o = [...a, ...h], y.info("Local video tracks: ", h), typeof this.options.video == "object" && h.forEach(((f) => {
1502
1502
  y.info("Local video tracks constraints: ", f.getConstraints());
1503
1503
  }));
1504
1504
  }
1505
- const { audioCodecs: d, videoCodecs: l } = ((h) => {
1505
+ const { audioCodecs: l, videoCodecs: d } = ((h) => {
1506
1506
  const f = [], v = [];
1507
1507
  return h && h.length !== 0 ? (h.forEach(((_) => {
1508
1508
  const w = _.mimeType.toLocaleLowerCase();
@@ -1514,12 +1514,12 @@ class Ot {
1514
1514
  o.forEach(((f) => {
1515
1515
  f.kind === "audio" && (this.options.userVariables.microphoneLabel = f.label), f.kind === "video" && (this.options.userVariables.cameraLabel = f.label);
1516
1516
  const v = this.instance.addTransceiver(f, h);
1517
- f.kind === "audio" && d.length > 0 && this._setCodecs(v, d), f.kind === "video" && l.length > 0 && this._setCodecs(v, l);
1517
+ f.kind === "audio" && l.length > 0 && this._setCodecs(v, l), f.kind === "video" && d.length > 0 && this._setCodecs(v, d);
1518
1518
  }));
1519
1519
  } else typeof this.instance.addTrack == "function" ? (o.forEach(((h) => {
1520
1520
  h.kind === "audio" && (this.options.userVariables.microphoneLabel = h.label), h.kind === "video" && (this.options.userVariables.cameraLabel = h.label), this.instance.addTrack(h, i);
1521
1521
  })), this.instance.getTransceivers().forEach(((h) => {
1522
- h.receiver.track.kind === "audio" && d.length > 0 && this._setCodecs(h, d), h.receiver.track.kind === "video" && l.length > 0 && this._setCodecs(h, l);
1522
+ h.receiver.track.kind === "audio" && l.length > 0 && this._setCodecs(h, l), h.receiver.track.kind === "video" && d.length > 0 && this._setCodecs(h, d);
1523
1523
  }))) : this.instance.addStream(i);
1524
1524
  s === !1 && Ee(n, i);
1525
1525
  }
@@ -1536,9 +1536,9 @@ class Ot {
1536
1536
  }
1537
1537
  }
1538
1538
  _createOffer() {
1539
- return L(this, void 0, void 0, (function* () {
1539
+ return O(this, void 0, void 0, (function* () {
1540
1540
  if (this._isOffer()) {
1541
- this._constraints.offerToReceiveAudio = !!this.options.audio, this._constraints.offerToReceiveVideo = !!this.options.video, y.info("_createOffer - this._constraints", this._constraints);
1541
+ this._constraints.offerToReceiveAudio = this.options.audio !== !1, this._constraints.offerToReceiveVideo = !!this.options.video, y.info("_createOffer - this._constraints", this._constraints);
1542
1542
  try {
1543
1543
  const e = yield this.instance.createOffer(this._constraints);
1544
1544
  return yield this._setLocalDescription(e), this._isTrickleIce() || this._sdpReady(), e;
@@ -1549,12 +1549,12 @@ class Ot {
1549
1549
  }));
1550
1550
  }
1551
1551
  _setRemoteDescription(e) {
1552
- return L(this, void 0, void 0, (function* () {
1552
+ return O(this, void 0, void 0, (function* () {
1553
1553
  y.debug("Setting remote description", e), yield this.instance.setRemoteDescription(e);
1554
1554
  }));
1555
1555
  }
1556
1556
  _createAnswer() {
1557
- return L(this, void 0, void 0, (function* () {
1557
+ return O(this, void 0, void 0, (function* () {
1558
1558
  if (this._isAnswer()) {
1559
1559
  if (this.instance.signalingState !== "stable" && this.instance.signalingState !== "have-remote-offer") return y.debug("Skipping negotiation, state:", this.instance.signalingState), y.debug(" - But the signaling state isn't stable, so triggering rollback"), void (yield Promise.all([this.instance.setLocalDescription({ type: "rollback" }), this.instance.setRemoteDescription({ sdp: this.options.remoteSdp, type: K.Offer })]));
1560
1560
  this._logTransceivers();
@@ -1568,7 +1568,7 @@ class Ot {
1568
1568
  }));
1569
1569
  }
1570
1570
  _setLocalDescription(e) {
1571
- return L(this, void 0, void 0, (function* () {
1571
+ return O(this, void 0, void 0, (function* () {
1572
1572
  yield this.instance.setLocalDescription(e);
1573
1573
  }));
1574
1574
  }
@@ -1576,19 +1576,19 @@ class Ot {
1576
1576
  ye(this.onSdpReadyTwice) && this.onSdpReadyTwice(this.instance.localDescription);
1577
1577
  }
1578
1578
  _retrieveLocalStream() {
1579
- return L(this, void 0, void 0, (function* () {
1579
+ return O(this, void 0, void 0, (function* () {
1580
1580
  if (ge(this.options.localStream)) return this.options.localStream;
1581
- const e = yield (n = this.options, L(void 0, void 0, void 0, (function* () {
1582
- let { audio: i = !0, micId: s, video: r = !1, camId: o } = n;
1583
- const { micLabel: d = "", camLabel: l = "" } = n;
1584
- return s && (s = yield Ue(s, d, ae.AudioIn).catch(((h) => null)), s && (typeof i == "boolean" && (i = {}), i.deviceId = { exact: s })), o && (o = yield Ue(o, l, ae.Video).catch(((h) => null)), o && (typeof r == "boolean" && (r = {}), r.deviceId = { exact: o })), { audio: i, video: r };
1581
+ const e = yield (n = this.options, O(void 0, void 0, void 0, (function* () {
1582
+ let { audio: i = !0, micId: s, video: a = !1, camId: o } = n;
1583
+ const { micLabel: l = "", camLabel: d = "" } = n;
1584
+ return s && (s = yield je(s, l, ae.AudioIn).catch(((h) => null)), s && (typeof i == "boolean" && (i = {}), i.deviceId = { exact: s })), o && (o = yield je(o, d, ae.Video).catch(((h) => null)), o && (typeof a == "boolean" && (a = {}), a.deviceId = { exact: o })), { audio: i, video: a };
1585
1585
  })));
1586
1586
  var n;
1587
- return je(e);
1587
+ return Ue(e);
1588
1588
  }));
1589
1589
  }
1590
1590
  _resetJitterBuffer() {
1591
- return L(this, void 0, void 0, (function* () {
1591
+ return O(this, void 0, void 0, (function* () {
1592
1592
  try {
1593
1593
  const n = this.instance.getReceivers().find(((s) => s.track && s.track.kind === "audio")), i = this.instance.getReceivers().find(((s) => s.track && s.track.kind === "video"));
1594
1594
  n && "jitterBufferTarget" in n && (n.jitterBufferTarget = 20, y.debug("audio [jitter] target set to", n.jitterBufferTarget, "ms")), i && "jitterBufferTarget" in i && (i.jitterBufferTarget = 20, y.debug("video [jitter] target set to", i.jitterBufferTarget, "ms"));
@@ -1598,10 +1598,10 @@ class Ot {
1598
1598
  }));
1599
1599
  }
1600
1600
  _restartNegotiationOnDeviceSleepWakeup() {
1601
- return L(this, void 0, void 0, (function* () {
1601
+ return O(this, void 0, void 0, (function* () {
1602
1602
  this._sleepWakeupIntervalId !== null && (clearInterval(this._sleepWakeupIntervalId), this._sleepWakeupIntervalId = null);
1603
1603
  let e = Date.now();
1604
- this._sleepWakeupIntervalId = setInterval((() => L(this, void 0, void 0, (function* () {
1604
+ this._sleepWakeupIntervalId = setInterval((() => O(this, void 0, void 0, (function* () {
1605
1605
  var n;
1606
1606
  const i = Date.now();
1607
1607
  if (i - e > 5e3) {
@@ -1627,15 +1627,15 @@ class Ot {
1627
1627
  }
1628
1628
  close() {
1629
1629
  var e;
1630
- return L(this, void 0, void 0, (function* () {
1630
+ return O(this, void 0, void 0, (function* () {
1631
1631
  this._sleepWakeupIntervalId !== null && (clearInterval(this._sleepWakeupIntervalId), this._sleepWakeupIntervalId = null), yield (e = this.statsReporter) === null || e === void 0 ? void 0 : e.stop(this.debugOutput), this.instance && (this.instance.close(), this.instance = null);
1632
1632
  }));
1633
1633
  }
1634
1634
  }
1635
1635
  const Lt = We;
1636
- class dn {
1636
+ class cn {
1637
1637
  constructor(e, n) {
1638
- this.session = e, this.id = "", this.state = N[N.New], this.prevState = "", this.channels = [], this.role = tt.Participant, this.extension = null, this._state = N.New, this._prevState = N.New, this.gotAnswer = !1, this.gotEarly = !1, this._lastSerno = 0, this._targetNodeId = null, this._iceTimeout = null, this._iceDone = !1, this._statsBindings = [], this._statsIntervalId = null, this._pendingIceCandidates = [], this._isRemoteDescriptionSet = !1, this._checkConferenceSerno = (p) => {
1638
+ this.session = e, this.id = "", this.state = N[N.New], this.prevState = "", this.channels = [], this.role = et.Participant, this.extension = null, this._state = N.New, this._prevState = N.New, this.gotAnswer = !1, this.gotEarly = !1, this._lastSerno = 0, this._targetNodeId = null, this._iceTimeout = null, this._iceDone = !1, this._statsBindings = [], this._statsIntervalId = null, this._pendingIceCandidates = [], this._isRemoteDescriptionSet = !1, this._checkConferenceSerno = (p) => {
1639
1639
  const S = p < 0 || !this._lastSerno || this._lastSerno && p === this._lastSerno + 1;
1640
1640
  return S && p >= 0 && (this._lastSerno = p), S;
1641
1641
  }, this._doStats = () => {
@@ -1652,12 +1652,12 @@ class dn {
1652
1652
  }));
1653
1653
  }));
1654
1654
  };
1655
- const { iceServers: i, speaker: s, micId: r, micLabel: o, camId: d, camLabel: l, localElement: h, remoteElement: f, options: v, mediaConstraints: { audio: _, video: w }, ringtoneFile: C, ringbackFile: k } = e;
1656
- this.options = Object.assign({}, Fn, { audio: _, video: w, iceServers: n?.iceServers && Array.isArray(n.iceServers) ? n.iceServers : i, localElement: h, remoteElement: f, micId: r, micLabel: o, camId: d, camLabel: l, speakerId: s, ringtoneFile: C, ringbackFile: k, debug: v.debug, debugOutput: v.debugOutput, trickleIce: v.trickleIce, prefetchIceCandidates: v.prefetchIceCandidates, keepConnectionAliveOnSocketClose: v.keepConnectionAliveOnSocketClose, mutedMicOnStart: v.mutedMicOnStart }, n), this._onMediaError = this._onMediaError.bind(this), this._onPeerConnectionFailureError = this._onPeerConnectionFailureError.bind(this), this._onTrickleIceSdp = this._onTrickleIceSdp.bind(this), this._registerPeerEvents = this._registerPeerEvents.bind(this), this._registerTrickleIcePeerEvents = this._registerTrickleIcePeerEvents.bind(this), this._init(), this.options && (this._ringtone = kt(this.options.ringtoneFile, "_ringtone"), this._ringback = kt(this.options.ringbackFile, "_ringback"));
1655
+ const { iceServers: i, speaker: s, micId: a, micLabel: o, camId: l, camLabel: d, localElement: h, remoteElement: f, options: v, mediaConstraints: { audio: _, video: w }, ringtoneFile: C, ringbackFile: k } = e;
1656
+ this.options = Object.assign({}, Fn, { audio: _, video: w, iceServers: n?.iceServers && Array.isArray(n.iceServers) ? n.iceServers : i, localElement: h, remoteElement: f, micId: a, micLabel: o, camId: l, camLabel: d, speakerId: s, ringtoneFile: C, ringbackFile: k, debug: v.debug, debugOutput: v.debugOutput, trickleIce: v.trickleIce, prefetchIceCandidates: v.prefetchIceCandidates, keepConnectionAliveOnSocketClose: v.keepConnectionAliveOnSocketClose, mutedMicOnStart: v.mutedMicOnStart }, n), this._onMediaError = this._onMediaError.bind(this), this._onPeerConnectionFailureError = this._onPeerConnectionFailureError.bind(this), this._onTrickleIceSdp = this._onTrickleIceSdp.bind(this), this._registerPeerEvents = this._registerPeerEvents.bind(this), this._registerTrickleIcePeerEvents = this._registerTrickleIcePeerEvents.bind(this), this._init(), this.options && (this._ringtone = Ct(this.options.ringtoneFile, "_ringtone"), this._ringback = Ct(this.options.ringbackFile, "_ringback"));
1657
1657
  }
1658
1658
  get performanceMetrics() {
1659
- const e = performance.measure("peer-creation", "peer-creation-start", "peer-creation-end"), n = performance.measure("ice-gathering", "ice-gathering-start", "ice-gathering-end"), i = performance.measure("sdp-send", "sdp-send-start", "sdp-send-end"), s = performance.measure("total-duration", "peer-creation-start", "sdp-send-end"), r = (o) => `${o.toFixed(2)}ms`;
1660
- return { "Peer Creation": { duration: r(e.duration) }, "ICE Gathering": { duration: r(n.duration) }, "SDP Send": { duration: r(i.duration) }, "Total Duration": { duration: r(s.duration) } };
1659
+ const e = performance.measure("peer-creation", "peer-creation-start", "peer-creation-end"), n = performance.measure("ice-gathering", "ice-gathering-start", "ice-gathering-end"), i = performance.measure("sdp-send", "sdp-send-start", "sdp-send-end"), s = performance.measure("total-duration", "peer-creation-start", "sdp-send-end"), a = (o) => `${o.toFixed(2)}ms`;
1660
+ return { "Peer Creation": { duration: a(e.duration) }, "ICE Gathering": { duration: a(n.duration) }, "SDP Send": { duration: a(i.duration) }, "Total Duration": { duration: a(s.duration) } };
1661
1661
  }
1662
1662
  get nodeId() {
1663
1663
  return this._targetNodeId;
@@ -1681,45 +1681,45 @@ class dn {
1681
1681
  return `conference-member.${this.id}`;
1682
1682
  }
1683
1683
  get isAudioMuted() {
1684
- return !Kn(this.options.localStream);
1684
+ return !zn(this.options.localStream);
1685
1685
  }
1686
1686
  invite() {
1687
- return L(this, void 0, void 0, (function* () {
1688
- this.direction = de.Outbound, this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("peer-creation-start"), this.peer = new Ot(K.Offer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents), yield this.peer.init();
1687
+ return O(this, void 0, void 0, (function* () {
1688
+ this.direction = le.Outbound, this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("peer-creation-start"), this.peer = new xt(K.Offer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents), yield this.peer.init();
1689
1689
  }));
1690
1690
  }
1691
1691
  answer(e = {}) {
1692
1692
  var n;
1693
- return L(this, void 0, void 0, (function* () {
1694
- performance.mark("new-call-start"), this.stopRingtone(), this.direction = de.Inbound, ((n = e?.customHeaders) === null || n === void 0 ? void 0 : n.length) > 0 && (this.options = Object.assign(Object.assign({}, this.options), { customHeaders: e.customHeaders })), this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("peer-creation-start"), this.peer = new Ot(K.Answer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents), yield this.peer.init(), performance.mark("new-call-end");
1693
+ return O(this, void 0, void 0, (function* () {
1694
+ performance.mark("new-call-start"), this.stopRingtone(), this.direction = le.Inbound, ((n = e?.customHeaders) === null || n === void 0 ? void 0 : n.length) > 0 && (this.options = Object.assign(Object.assign({}, this.options), { customHeaders: e.customHeaders })), this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("peer-creation-start"), this.peer = new xt(K.Answer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents), yield this.peer.init(), performance.mark("new-call-end");
1695
1695
  }));
1696
1696
  }
1697
1697
  playRingtone() {
1698
- It(this._ringtone);
1698
+ kt(this._ringtone);
1699
1699
  }
1700
1700
  stopRingtone() {
1701
- Et(this._ringtone);
1701
+ It(this._ringtone);
1702
1702
  }
1703
1703
  playRingback() {
1704
- It(this._ringback);
1704
+ kt(this._ringback);
1705
1705
  }
1706
1706
  stopRingback() {
1707
- Et(this._ringback);
1707
+ It(this._ringback);
1708
1708
  }
1709
1709
  hangup(e, n) {
1710
- var i, s, r;
1711
- let o = e || {}, d = n !== !1;
1712
- this.cause = o.cause || "NORMAL_CLEARING", this.causeCode = o.causeCode || 16, this.sipCode = o.sipCode || null, this.sipReason = o.sipReason || null, this.sipCallId = o.sip_call_id || null, this.options.customHeaders = [...(i = this.options.customHeaders) !== null && i !== void 0 ? i : [], ...(r = (s = o?.dialogParams) === null || s === void 0 ? void 0 : s.customHeaders) !== null && r !== void 0 ? r : []], this.setState(N.Hangup);
1713
- const l = () => {
1710
+ var i, s, a;
1711
+ let o = e || {}, l = n !== !1;
1712
+ this.cause = o.cause || "NORMAL_CLEARING", this.causeCode = o.causeCode || 16, this.sipCode = o.sipCode || null, this.sipReason = o.sipReason || null, this.sipCallId = o.sip_call_id || null, this.options.customHeaders = [...(i = this.options.customHeaders) !== null && i !== void 0 ? i : [], ...(a = (s = o?.dialogParams) === null || s === void 0 ? void 0 : s.customHeaders) !== null && a !== void 0 ? a : []], this.setState(N.Hangup);
1713
+ const d = () => {
1714
1714
  var h;
1715
1715
  return (h = this.peer) === null || h === void 0 || h.close(), this.setState(N.Destroy);
1716
1716
  };
1717
- if (this.stopRingtone(), this.stopRingback(), d) {
1718
- const h = new Zn({ sipCode: this.sipCode, sip_call_id: this.sipCallId, sessid: this.session.sessionid, dialogParams: this.options, cause: "USER_BUSY", causeCode: 17 });
1717
+ if (this.stopRingtone(), this.stopRingback(), l) {
1718
+ const h = new Xn({ sipCode: this.sipCode, sip_call_id: this.sipCallId, sessid: this.session.sessionid, dialogParams: this.options, cause: "USER_BUSY", causeCode: 17 });
1719
1719
  this._execute(h).catch(((f) => {
1720
- y.error("telnyx_rtc.bye failed!", f), $(O.Error, { error: f, sessionId: this.session.sessionid }, this.session.uuid);
1721
- })).then(l.bind(this));
1722
- } else l();
1720
+ y.error("telnyx_rtc.bye failed!", f), F(L.Error, { error: f, sessionId: this.session.sessionid }, this.session.uuid);
1721
+ })).then(d.bind(this));
1722
+ } else d();
1723
1723
  }
1724
1724
  hold() {
1725
1725
  const e = new Qe({ sessid: this.session.sessionid, action: "hold", dialogParams: this.options });
@@ -1734,30 +1734,30 @@ class dn {
1734
1734
  return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this));
1735
1735
  }
1736
1736
  dtmf(e) {
1737
- const n = new Rt({ sessid: this.session.sessionid, dtmf: e, dialogParams: this.options });
1737
+ const n = new At({ sessid: this.session.sessionid, dtmf: e, dialogParams: this.options });
1738
1738
  this._execute(n);
1739
1739
  }
1740
1740
  message(e, n) {
1741
- const i = { from: this.session.options.login, to: e, body: n }, s = new Rt({ sessid: this.session.sessionid, msg: i, dialogParams: this.options });
1741
+ const i = { from: this.session.options.login, to: e, body: n }, s = new At({ sessid: this.session.sessionid, msg: i, dialogParams: this.options });
1742
1742
  this._execute(s);
1743
1743
  }
1744
1744
  muteAudio() {
1745
- ot(this.options.localStream);
1745
+ st(this.options.localStream);
1746
1746
  }
1747
1747
  unmuteAudio() {
1748
- wt(this.options.localStream);
1748
+ St(this.options.localStream);
1749
1749
  }
1750
1750
  toggleAudioMute() {
1751
- Ct(this.options.localStream);
1751
+ wt(this.options.localStream);
1752
1752
  }
1753
1753
  setAudioInDevice(e, n = this.options.mutedMicOnStart) {
1754
- return L(this, void 0, void 0, (function* () {
1755
- const { instance: i } = this.peer, s = i.getSenders().find((({ track: { kind: r } }) => r === "audio"));
1754
+ return O(this, void 0, void 0, (function* () {
1755
+ const { instance: i } = this.peer, s = i.getSenders().find((({ track: { kind: a } }) => a === "audio"));
1756
1756
  if (s) {
1757
- const r = yield nt({ audio: { deviceId: { exact: e } } }), o = r.getAudioTracks()[0];
1757
+ const a = yield tt({ audio: { deviceId: { exact: e } } }), o = a.getAudioTracks()[0];
1758
1758
  o.enabled = !n, s.replaceTrack(o), this.options.micId = e;
1759
- const { localStream: d } = this.options;
1760
- d.getAudioTracks().forEach(((l) => l.stop())), d.getVideoTracks().forEach(((l) => r.addTrack(l))), this.options.localStream = r;
1759
+ const { localStream: l } = this.options;
1760
+ l.getAudioTracks().forEach(((d) => d.stop())), l.getVideoTracks().forEach(((d) => a.addTrack(d))), this.options.localStream = a;
1761
1761
  }
1762
1762
  }));
1763
1763
  }
@@ -1774,36 +1774,36 @@ class dn {
1774
1774
  e = this.options.localStream, ve(e, "video", null);
1775
1775
  }
1776
1776
  setVideoDevice(e) {
1777
- return L(this, void 0, void 0, (function* () {
1777
+ return O(this, void 0, void 0, (function* () {
1778
1778
  const { instance: n } = this.peer, i = n.getSenders().find((({ track: { kind: s } }) => s === "video"));
1779
1779
  if (i) {
1780
- const s = yield nt({ video: { deviceId: { exact: e } } }), r = s.getVideoTracks()[0];
1781
- i.replaceTrack(r);
1782
- const { localElement: o, localStream: d } = this.options;
1783
- Ee(o, s), this.options.camId = e, d.getAudioTracks().forEach(((l) => s.addTrack(l))), d.getVideoTracks().forEach(((l) => l.stop())), this.options.localStream = s;
1780
+ const s = yield tt({ video: { deviceId: { exact: e } } }), a = s.getVideoTracks()[0];
1781
+ i.replaceTrack(a);
1782
+ const { localElement: o, localStream: l } = this.options;
1783
+ Ee(o, s), this.options.camId = e, l.getAudioTracks().forEach(((d) => s.addTrack(d))), l.getVideoTracks().forEach(((d) => d.stop())), this.options.localStream = s;
1784
1784
  }
1785
1785
  }));
1786
1786
  }
1787
1787
  deaf() {
1788
- ot(this.options.remoteStream);
1788
+ st(this.options.remoteStream);
1789
1789
  }
1790
1790
  undeaf() {
1791
- wt(this.options.remoteStream);
1791
+ St(this.options.remoteStream);
1792
1792
  }
1793
1793
  toggleDeaf() {
1794
- Ct(this.options.remoteStream);
1794
+ wt(this.options.remoteStream);
1795
1795
  }
1796
1796
  setBandwidthEncodingsMaxBps(e, n) {
1797
- return L(this, void 0, void 0, (function* () {
1797
+ return O(this, void 0, void 0, (function* () {
1798
1798
  if (!this || !this.peer) return void y.error("Could not set bandwidth (reason: no peer connection). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");
1799
1799
  const { instance: i } = this.peer, s = i.getSenders();
1800
1800
  if (!s) return void y.error("Could not set bandwidth (reason: no senders). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");
1801
- const r = s.find((({ track: { kind: o } }) => o === n));
1802
- if (r) {
1803
- const o = r.getParameters();
1804
- o.encodings || (o.encodings = [{ rid: "h" }]), y.info("Parameters: ", o), y.info("Setting max ", n === "audio" ? "audio" : "video", " bandwidth to: ", e, " [bps]"), o.encodings[0].maxBitrate = e, yield r.setParameters(o).then((() => {
1805
- y.info(n === "audio" ? "New audio" : "New video", " bandwidth settings in use: ", r.getParameters());
1806
- })).catch(((d) => y.error(d)));
1801
+ const a = s.find((({ track: { kind: o } }) => o === n));
1802
+ if (a) {
1803
+ const o = a.getParameters();
1804
+ o.encodings || (o.encodings = [{ rid: "h" }]), y.info("Parameters: ", o), y.info("Setting max ", n === "audio" ? "audio" : "video", " bandwidth to: ", e, " [bps]"), o.encodings[0].maxBitrate = e, yield a.setParameters(o).then((() => {
1805
+ y.info(n === "audio" ? "New audio" : "New video", " bandwidth settings in use: ", a.getParameters());
1806
+ })).catch(((l) => y.error(l)));
1807
1807
  } else y.error("Could not set bandwidth (reason: no " + n + " sender). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");
1808
1808
  }));
1809
1809
  }
@@ -1819,14 +1819,14 @@ class dn {
1819
1819
  this._statsBindings.push(i), !this._statsIntervalId && this._startStats(2e3);
1820
1820
  }
1821
1821
  setState(e) {
1822
- switch (this._prevState = this._state, this._state = e, this.state = N[this._state].toLowerCase(), this.prevState = N[this._prevState].toLowerCase(), y.info(`Call ${this.id} state change from ${this.prevState} to ${this.state}`), this._dispatchNotification({ type: oe.callUpdate, call: this }), e) {
1822
+ switch (this._prevState = this._state, this._state = e, this.state = N[this._state].toLowerCase(), this.prevState = N[this._prevState].toLowerCase(), y.debug(`Call ${this.id} state change from ${this.prevState} to ${this.state}`), this._dispatchNotification({ type: oe.callUpdate, call: this }), e) {
1823
1823
  case N.Purge:
1824
1824
  y.debug(`Call ${this.id} hangup call due to purge state`), this.hangup({ cause: "PURGE", causeCode: "01" }, !1);
1825
1825
  break;
1826
1826
  case N.Active:
1827
1827
  setTimeout((() => {
1828
1828
  const { remoteElement: n, speakerId: i } = this.options;
1829
- n && i && nn(n, i);
1829
+ n && i && tn(n, i);
1830
1830
  }), 0);
1831
1831
  break;
1832
1832
  case N.Destroy:
@@ -1836,67 +1836,67 @@ class dn {
1836
1836
  handleMessage(e) {
1837
1837
  const { method: n, params: i } = e;
1838
1838
  switch (n) {
1839
- case F.Answer:
1839
+ case $.Answer:
1840
1840
  if (this.gotAnswer = !0, this._state >= N.Active) return;
1841
1841
  this._state >= N.Early && this.setState(N.Active), this.gotEarly || this._onRemoteSdp(i.sdp), this.stopRingback(), this.stopRingtone();
1842
1842
  break;
1843
- case F.Media:
1843
+ case $.Media:
1844
1844
  if (this._state >= N.Early) return;
1845
1845
  this.gotEarly = !0, this._onRemoteSdp(i.sdp);
1846
1846
  break;
1847
- case F.Display:
1848
- case F.Attach: {
1849
- const { display_name: r, display_number: o, display_direction: d } = i;
1847
+ case $.Display:
1848
+ case $.Attach: {
1849
+ const { display_name: a, display_number: o, display_direction: l } = i;
1850
1850
  this.extension = o;
1851
- const l = d === de.Inbound ? de.Outbound : de.Inbound, h = { type: oe[n], call: this, displayName: r, displayNumber: o, displayDirection: l };
1852
- $(O.Notification, h, this.id) || $(O.Notification, h, this.session.uuid);
1851
+ const d = l === le.Inbound ? le.Outbound : le.Inbound, h = { type: oe[n], call: this, displayName: a, displayNumber: o, displayDirection: d };
1852
+ F(L.Notification, h, this.id) || F(L.Notification, h, this.session.uuid);
1853
1853
  break;
1854
1854
  }
1855
- case F.Candidate:
1855
+ case $.Candidate:
1856
1856
  this._addIceCandidate(i);
1857
1857
  break;
1858
- case F.Info:
1859
- case F.Event: {
1860
- const r = Object.assign(Object.assign({}, i), { type: oe.generic, call: this });
1861
- $(O.Notification, r, this.id) || $(O.Notification, r, this.session.uuid);
1858
+ case $.Info:
1859
+ case $.Event: {
1860
+ const a = Object.assign(Object.assign({}, i), { type: oe.generic, call: this });
1861
+ F(L.Notification, a, this.id) || F(L.Notification, a, this.session.uuid);
1862
1862
  break;
1863
1863
  }
1864
- case F.Ringing:
1864
+ case $.Ringing:
1865
1865
  this.playRingback(), i.telnyx_call_control_id && (this.options.telnyxCallControlId = i.telnyx_call_control_id), i.telnyx_session_id && (this.options.telnyxSessionId = i.telnyx_session_id), i.telnyx_leg_id && (this.options.telnyxLegId = i.telnyx_leg_id);
1866
1866
  break;
1867
- case F.Bye:
1867
+ case $.Bye:
1868
1868
  const s = i.client_state || i.clientState;
1869
1869
  s && (this.options.clientState = s), this.stopRingback(), this.stopRingtone(), this.hangup(i, !1);
1870
1870
  }
1871
1871
  }
1872
1872
  handleConferenceUpdate(e, n) {
1873
- return L(this, void 0, void 0, (function* () {
1873
+ return O(this, void 0, void 0, (function* () {
1874
1874
  if (!this._checkConferenceSerno(e.wireSerno) && e.name !== n.laName) return y.error("ConferenceUpdate invalid wireSerno or packet name:", e), "INVALID_PACKET";
1875
- const { action: i, data: s, hashKey: r = String(this._lastSerno), arrIndex: o } = e;
1875
+ const { action: i, data: s, hashKey: a = String(this._lastSerno), arrIndex: o } = e;
1876
1876
  switch (i) {
1877
1877
  case "bootObj": {
1878
1878
  this._lastSerno = 0;
1879
- const { chatChannel: d, infoChannel: l, modChannel: h, laName: f, conferenceMemberID: v, role: _ } = n;
1880
- this._dispatchConferenceUpdate({ action: se.Join, conferenceName: f, participantId: Number(v), role: _ }), d && (yield this._subscribeConferenceChat(d)), l && (yield this._subscribeConferenceInfo(l));
1879
+ const { chatChannel: l, infoChannel: d, modChannel: h, laName: f, conferenceMemberID: v, role: _ } = n;
1880
+ this._dispatchConferenceUpdate({ action: se.Join, conferenceName: f, participantId: Number(v), role: _ }), l && (yield this._subscribeConferenceChat(l)), d && (yield this._subscribeConferenceInfo(d));
1881
1881
  const w = [];
1882
- for (const C in s) w.push(Object.assign({ callId: s[C][0], index: Number(C) }, Oe(s[C][1])));
1882
+ for (const C in s) w.push(Object.assign({ callId: s[C][0], index: Number(C) }, Le(s[C][1])));
1883
1883
  this._dispatchConferenceUpdate({ action: se.Bootstrap, participants: w });
1884
1884
  break;
1885
1885
  }
1886
1886
  case "add":
1887
- this._dispatchConferenceUpdate(Object.assign({ action: se.Add, callId: r, index: o }, Oe(s)));
1887
+ this._dispatchConferenceUpdate(Object.assign({ action: se.Add, callId: a, index: o }, Le(s)));
1888
1888
  break;
1889
1889
  case "modify":
1890
- this._dispatchConferenceUpdate(Object.assign({ action: se.Modify, callId: r, index: o }, Oe(s)));
1890
+ this._dispatchConferenceUpdate(Object.assign({ action: se.Modify, callId: a, index: o }, Le(s)));
1891
1891
  break;
1892
1892
  case "del":
1893
- this._dispatchConferenceUpdate(Object.assign({ action: se.Delete, callId: r, index: o }, Oe(s)));
1893
+ this._dispatchConferenceUpdate(Object.assign({ action: se.Delete, callId: a, index: o }, Le(s)));
1894
1894
  break;
1895
1895
  case "clear":
1896
1896
  this._dispatchConferenceUpdate({ action: se.Clear });
1897
1897
  break;
1898
1898
  default:
1899
- this._dispatchConferenceUpdate({ action: i, data: s, callId: r, index: o });
1899
+ this._dispatchConferenceUpdate({ action: i, data: s, callId: a, index: o });
1900
1900
  }
1901
1901
  }));
1902
1902
  }
@@ -1906,27 +1906,27 @@ class dn {
1906
1906
  this.session._existsSubscription(n, e) && (this.session.subscriptions[n][e] = Object.assign(Object.assign({}, this.session.subscriptions[n][e]), { callId: this.id }));
1907
1907
  }
1908
1908
  _subscribeConferenceChat(e) {
1909
- return L(this, void 0, void 0, (function* () {
1909
+ return O(this, void 0, void 0, (function* () {
1910
1910
  const n = { nodeId: this.nodeId, channels: [e], handler: (s) => {
1911
- const { direction: r, from: o, fromDisplay: d, message: l, type: h } = s.data;
1912
- this._dispatchConferenceUpdate({ action: se.ChatMessage, direction: r, participantNumber: o, participantName: d, messageText: l, messageType: h, messageId: s.eventSerno });
1911
+ const { direction: a, from: o, fromDisplay: l, message: d, type: h } = s.data;
1912
+ this._dispatchConferenceUpdate({ action: se.ChatMessage, direction: a, participantNumber: o, participantName: l, messageText: d, messageType: h, messageId: s.eventSerno });
1913
1913
  } }, i = yield this.session.vertoSubscribe(n).catch(((s) => {
1914
1914
  y.error("ConfChat subscription error:", s);
1915
1915
  }));
1916
- it(i, e) && (this._addChannel(e), Object.defineProperties(this, { sendChatMessage: { configurable: !0, value: (s, r) => {
1917
- this.session.vertoBroadcast({ nodeId: this.nodeId, channel: e, data: { action: "send", message: s, type: r } });
1916
+ nt(i, e) && (this._addChannel(e), Object.defineProperties(this, { sendChatMessage: { configurable: !0, value: (s, a) => {
1917
+ this.session.vertoBroadcast({ nodeId: this.nodeId, channel: e, data: { action: "send", message: s, type: a } });
1918
1918
  } } }));
1919
1919
  }));
1920
1920
  }
1921
1921
  _subscribeConferenceInfo(e) {
1922
- return L(this, void 0, void 0, (function* () {
1922
+ return O(this, void 0, void 0, (function* () {
1923
1923
  const n = { nodeId: this.nodeId, channels: [e], handler: (s) => {
1924
- const { eventData: r } = s;
1925
- r.contentType === "layout-info" ? (r.callID = this.id, cn(this.session, r)) : y.error("Conference-Info unknown contentType", s);
1924
+ const { eventData: a } = s;
1925
+ a.contentType === "layout-info" ? (a.callID = this.id, an(this.session, a)) : y.error("Conference-Info unknown contentType", s);
1926
1926
  } }, i = yield this.session.vertoSubscribe(n).catch(((s) => {
1927
1927
  y.error("ConfInfo subscription error:", s);
1928
1928
  }));
1929
- it(i, e) && this._addChannel(e);
1929
+ nt(i, e) && this._addChannel(e);
1930
1930
  }));
1931
1931
  }
1932
1932
  _confControl(e, n = {}) {
@@ -1940,7 +1940,7 @@ class dn {
1940
1940
  return y.error(`Failed to ${e.action} on call ${this.id}`), !1;
1941
1941
  }
1942
1942
  _onRemoteSdp(e) {
1943
- return L(this, void 0, void 0, (function* () {
1943
+ return O(this, void 0, void 0, (function* () {
1944
1944
  const n = new RTCSessionDescription({ sdp: e, type: K.Answer });
1945
1945
  yield this.peer.instance.setRemoteDescription(n).then((() => {
1946
1946
  this.options.trickleIce && (this._isRemoteDescriptionSet = !0, this._flushPendingTrickleIceCandidates()), this.gotEarly && this.setState(N.Early), this.gotAnswer && this.setState(N.Active);
@@ -1950,32 +1950,32 @@ class dn {
1950
1950
  }));
1951
1951
  }
1952
1952
  _requestAnotherLocalDescription() {
1953
- ye(this.peer.onSdpReadyTwice) ? $(O.Error, { error: new Error("SDP without candidates for the second time!"), sessionId: this.session.sessionid }, this.session.uuid) : (Object.defineProperty(this.peer, "onSdpReadyTwice", { value: this._onIceSdp.bind(this) }), this._iceDone = !1, this.peer.startNegotiation());
1953
+ ye(this.peer.onSdpReadyTwice) ? F(L.Error, { error: new Error("SDP without candidates for the second time!"), sessionId: this.session.sessionid }, this.session.uuid) : (Object.defineProperty(this.peer, "onSdpReadyTwice", { value: this._onIceSdp.bind(this) }), this._iceDone = !1, this.peer.startNegotiation());
1954
1954
  }
1955
1955
  _onIceSdp(e) {
1956
1956
  var n, i;
1957
1957
  this._iceTimeout && clearTimeout(this._iceTimeout), this._iceTimeout = null, this._iceDone = !0;
1958
- const { sdp: s, type: r } = e;
1958
+ const { sdp: s, type: a } = e;
1959
1959
  if (s.indexOf("candidate") === -1) return y.info(`No candidate - retry
1960
1960
  `), void this._requestAnotherLocalDescription();
1961
1961
  (i = (n = this.peer) === null || n === void 0 ? void 0 : n.instance) === null || i === void 0 || i.removeEventListener("icecandidate", this._onIce), performance.mark("ice-gathering-end");
1962
1962
  let o = null;
1963
- const d = { sessid: this.session.sessionid, sdp: s, dialogParams: this.options, "User-Agent": `Web-${Lt}` };
1964
- switch (r) {
1963
+ const l = { sessid: this.session.sessionid, sdp: s, dialogParams: this.options, "User-Agent": `Web-${Lt}` };
1964
+ switch (a) {
1965
1965
  case K.Offer:
1966
- this.setState(N.Requesting), o = new Tt(d);
1966
+ this.setState(N.Requesting), o = new Et(l);
1967
1967
  break;
1968
1968
  case K.Answer:
1969
- this.setState(N.Answering), o = this.options.attach === !0 ? new rt(d) : new At(d);
1969
+ this.setState(N.Answering), o = this.options.attach === !0 ? new ot(l) : new Tt(l);
1970
1970
  break;
1971
1971
  default:
1972
1972
  return y.error(`${this.id} - Unknown local SDP type:`, e), this.hangup({}, !1);
1973
1973
  }
1974
- performance.mark("sdp-send-start"), this._execute(o).then(((l) => {
1975
- const { node_id: h = null } = l;
1976
- this._targetNodeId = h, r === K.Offer ? this.setState(N.Trying) : this.setState(N.Active);
1977
- })).catch(((l) => {
1978
- y.error(`${this.id} - Sending ${r} error:`, l), this.hangup();
1974
+ performance.mark("sdp-send-start"), this._execute(o).then(((d) => {
1975
+ const { node_id: h = null } = d;
1976
+ this._targetNodeId = h, a === K.Offer ? this.setState(N.Trying) : this.setState(N.Active);
1977
+ })).catch(((d) => {
1978
+ y.error(`${this.id} - Sending ${a} error:`, d), this.hangup();
1979
1979
  })).finally((() => {
1980
1980
  performance.mark("sdp-send-end"), console.group("Performance Metrics"), console.table(this.performanceMetrics), console.groupEnd(), performance.clearMarks();
1981
1981
  }));
@@ -1984,20 +1984,20 @@ class dn {
1984
1984
  if (!e) return y.error("No SDP data provided"), this.hangup({}, !1);
1985
1985
  const { sdp: n, type: i } = e;
1986
1986
  let s = null;
1987
- const r = { sessid: this.session.sessionid, sdp: n, dialogParams: this.options, trickle: !0, "User-Agent": `Web-${Lt}` };
1987
+ const a = { sessid: this.session.sessionid, sdp: n, dialogParams: this.options, trickle: !0, "User-Agent": `Web-${Lt}` };
1988
1988
  switch (i) {
1989
1989
  case K.Offer:
1990
- this.setState(N.Requesting), s = new Tt(r);
1990
+ this.setState(N.Requesting), s = new Et(a);
1991
1991
  break;
1992
1992
  case K.Answer:
1993
- this.setState(N.Answering), s = this.options.attach === !0 ? new rt(r) : new At(r);
1993
+ this.setState(N.Answering), s = this.options.attach === !0 ? new ot(a) : new Tt(a);
1994
1994
  break;
1995
1995
  default:
1996
1996
  return y.error(`${this.id} - Unknown local SDP type:`, e), this.hangup({}, !1);
1997
1997
  }
1998
1998
  performance.mark("sdp-send-start"), this._execute(s).then(((o) => {
1999
- const { node_id: d = null } = o;
2000
- this._targetNodeId = d, i === K.Offer ? this.setState(N.Trying) : this.setState(N.Active);
1999
+ const { node_id: l = null } = o;
2000
+ this._targetNodeId = l, i === K.Offer ? this.setState(N.Trying) : this.setState(N.Active);
2001
2001
  })).catch(((o) => {
2002
2002
  y.error(`${this.id} - Sending ${i} error:`, o), this.hangup();
2003
2003
  })).finally((() => {
@@ -2012,7 +2012,7 @@ class dn {
2012
2012
  e.candidate && e.candidate.candidate ? (y.debug("RTCPeer Candidate:", e.candidate), this._sendIceCandidate(e.candidate)) : this._sendEndOfCandidates();
2013
2013
  }
2014
2014
  _sendIceCandidate(e) {
2015
- const n = new rn({ sessid: this.session.sessionid, candidate: e.candidate, sdpMLineIndex: e.sdpMLineIndex, sdpMid: e.sdpMid, dialogParams: this.options });
2015
+ const n = new on({ sessid: this.session.sessionid, candidate: e.candidate, sdpMLineIndex: e.sdpMLineIndex, sdpMid: e.sdpMid, dialogParams: this.options });
2016
2016
  this._execute(n);
2017
2017
  }
2018
2018
  _addIceCandidate(e) {
@@ -2028,7 +2028,7 @@ class dn {
2028
2028
  }));
2029
2029
  }
2030
2030
  _sendEndOfCandidates() {
2031
- const e = new ei({ sessid: this.session.sessionid, endOfCandidates: !0, dialogParams: this.options });
2031
+ const e = new Zn({ sessid: this.session.sessionid, endOfCandidates: !0, dialogParams: this.options });
2032
2032
  this._execute(e), performance.mark("ice-gathering-end");
2033
2033
  }
2034
2034
  _resetTrickleIceCandidateState() {
@@ -2047,15 +2047,15 @@ class dn {
2047
2047
  }, e.onicecandidateerror = (n) => {
2048
2048
  var i;
2049
2049
  if (y.debug("ICE candidate error:", n), (i = this.peer) === null || i === void 0 ? void 0 : i.statsReporter) {
2050
- const s = xt(n, e);
2050
+ const s = Rt(n, e);
2051
2051
  this.peer.statsReporter.reportIceCandidateError(s);
2052
2052
  }
2053
2053
  }, e.addEventListener("addstream", ((n) => {
2054
2054
  this.options.remoteStream = n.stream;
2055
2055
  })), e.addEventListener("track", ((n) => {
2056
2056
  this.options.remoteStream = n.streams[0];
2057
- const { remoteElement: i, remoteStream: s, screenShare: r } = this.options;
2058
- r === !1 && Ee(i, s);
2057
+ const { remoteElement: i, remoteStream: s, screenShare: a } = this.options;
2058
+ a === !1 && Ee(i, s);
2059
2059
  }));
2060
2060
  }
2061
2061
  _registerTrickleIcePeerEvents(e) {
@@ -2066,15 +2066,15 @@ class dn {
2066
2066
  }, e.onicecandidateerror = (n) => {
2067
2067
  var i;
2068
2068
  if (y.debug("ICE candidate error:", n), (i = this.peer) === null || i === void 0 ? void 0 : i.statsReporter) {
2069
- const s = xt(n, e);
2069
+ const s = Rt(n, e);
2070
2070
  this.peer.statsReporter.reportIceCandidateError(s);
2071
2071
  }
2072
2072
  }, e.addEventListener("addstream", ((n) => {
2073
2073
  this.options.remoteStream = n.stream;
2074
2074
  })), e.addEventListener("track", ((n) => {
2075
2075
  this.options.remoteStream = n.streams[0];
2076
- const { remoteElement: i, remoteStream: s, screenShare: r } = this.options;
2077
- r === !1 && Ee(i, s);
2076
+ const { remoteElement: i, remoteStream: s, screenShare: a } = this.options;
2077
+ a === !1 && Ee(i, s);
2078
2078
  }));
2079
2079
  }
2080
2080
  _onMediaError(e) {
@@ -2087,30 +2087,30 @@ class dn {
2087
2087
  this._dispatchNotification(Object.assign({ type: oe.conferenceUpdate, call: this }, e));
2088
2088
  }
2089
2089
  _dispatchNotification(e) {
2090
- this.options.screenShare !== !0 && ($(O.Notification, e, this.id, !1) || $(O.Notification, e, this.session.uuid));
2090
+ this.options.screenShare !== !0 && (F(L.Notification, e, this.id, !1) || F(L.Notification, e, this.session.uuid));
2091
2091
  }
2092
2092
  _execute(e) {
2093
2093
  return this.nodeId && (e.targetNodeId = this.nodeId), this.session.execute(e);
2094
2094
  }
2095
2095
  _init() {
2096
2096
  const { id: e, userVariables: n, remoteCallerNumber: i, onNotification: s } = this.options;
2097
- var r;
2098
- this.options.id = e ? e.toString() : me(), this.id = this.options.id, n && (r = n, Object.keys(r).length !== 0) || (this.options.userVariables = this.session.options.userVariables || {}), i || (this.options.remoteCallerNumber = this.options.destinationNumber), this.session.calls[this.id] = this, le(O.MediaError, this._onMediaError, this.id), le(O.PeerConnectionFailureError, this._onPeerConnectionFailureError, this.id), ye(s) && le(O.Notification, s.bind(this), this.id), this.setState(N.New), y.info("New Call with Options:", this.options);
2097
+ var a;
2098
+ this.options.id = e ? e.toString() : me(), this.id = this.options.id, n && (a = n, Object.keys(a).length !== 0) || (this.options.userVariables = this.session.options.userVariables || {}), i || (this.options.remoteCallerNumber = this.options.destinationNumber), this.session.calls[this.id] = this, de(L.MediaError, this._onMediaError, this.id), de(L.PeerConnectionFailureError, this._onPeerConnectionFailureError, this.id), ye(s) && de(L.Notification, s.bind(this), this.id), this.setState(N.New), y.info("New Call with Options:", this.options);
2099
2099
  }
2100
2100
  _finalize() {
2101
2101
  var e;
2102
2102
  this._stopStats(), (e = this.peer) === null || e === void 0 || e.close();
2103
2103
  const { remoteStream: n, localStream: i } = this.options;
2104
- Te(n), Te(i), ue(O.MediaError, null, this.id), ue(O.PeerConnectionFailureError, null, this.id), this.session.calls[this.id] = null, delete this.session.calls[this.id];
2104
+ Te(n), Te(i), ue(L.MediaError, null, this.id), ue(L.PeerConnectionFailureError, null, this.id), this.session.calls[this.id] = null, delete this.session.calls[this.id];
2105
2105
  }
2106
2106
  _startStats(e) {
2107
2107
  this._statsIntervalId = setInterval(this._doStats, e), y.info("Stats started");
2108
2108
  }
2109
2109
  _stopStats() {
2110
- this._statsIntervalId && (clearInterval(this._statsIntervalId), this._statsIntervalId = null), y.info("Stats stopped");
2110
+ this._statsIntervalId && (clearInterval(this._statsIntervalId), this._statsIntervalId = null), y.debug("Stats stopped");
2111
2111
  }
2112
2112
  }
2113
- dn.setStateTelnyx = (t) => {
2113
+ cn.setStateTelnyx = (t) => {
2114
2114
  if (t) {
2115
2115
  switch (t._state) {
2116
2116
  case N.Requesting:
@@ -2138,15 +2138,15 @@ dn.setStateTelnyx = (t) => {
2138
2138
  return t;
2139
2139
  }
2140
2140
  };
2141
- class he extends dn {
2141
+ class he extends cn {
2142
2142
  constructor() {
2143
- super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e, n) => this.session.execute(new si(e, n));
2143
+ super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e, n) => this.session.execute(new ii(e, n));
2144
2144
  }
2145
2145
  hangup(e = {}, n = !0) {
2146
2146
  this.screenShare instanceof he && this.screenShare.hangup(e, n), super.hangup(e, n);
2147
2147
  }
2148
2148
  startScreenShare(e) {
2149
- return L(this, void 0, void 0, (function* () {
2149
+ return O(this, void 0, void 0, (function* () {
2150
2150
  const n = yield (i = { video: !0 }, navigator.mediaDevices.getDisplayMedia(i));
2151
2151
  var i;
2152
2152
  n.getTracks().forEach(((h) => {
@@ -2154,18 +2154,18 @@ class he extends dn {
2154
2154
  this.screenShare && this.screenShare.hangup();
2155
2155
  }));
2156
2156
  }));
2157
- const { remoteCallerName: s, remoteCallerNumber: r, callerName: o, callerNumber: d } = this.options, l = Object.assign({ screenShare: !0, localStream: n, destinationNumber: `${this.extension}-screen`, remoteCallerName: s, remoteCallerNumber: `${r}-screen`, callerName: `${o} (Screen)`, callerNumber: `${d} (Screen)` }, e);
2158
- return this.screenShare = new he(this.session, l), this.screenShare.invite(), this.screenShare;
2157
+ const { remoteCallerName: s, remoteCallerNumber: a, callerName: o, callerNumber: l } = this.options, d = Object.assign({ screenShare: !0, localStream: n, destinationNumber: `${this.extension}-screen`, remoteCallerName: s, remoteCallerNumber: `${a}-screen`, callerName: `${o} (Screen)`, callerNumber: `${l} (Screen)` }, e);
2158
+ return this.screenShare = new he(this.session, d), this.screenShare.invite(), this.screenShare;
2159
2159
  }));
2160
2160
  }
2161
2161
  stopScreenShare() {
2162
2162
  this.screenShare instanceof he && this.screenShare.hangup();
2163
2163
  }
2164
2164
  setAudioOutDevice(e) {
2165
- return L(this, void 0, void 0, (function* () {
2165
+ return O(this, void 0, void 0, (function* () {
2166
2166
  this.options.speakerId = e;
2167
2167
  const { remoteElement: n, speakerId: i } = this.options;
2168
- return !(!n || !i) && nn(n, i);
2168
+ return !(!n || !i) && tn(n, i);
2169
2169
  }));
2170
2170
  }
2171
2171
  _finalize() {
@@ -2173,44 +2173,44 @@ class he extends dn {
2173
2173
  }
2174
2174
  _stats(e = !0) {
2175
2175
  if (e === !1) return clearInterval(this._statsInterval);
2176
- y.setLevel(2), this._statsInterval = window.setInterval((() => L(this, void 0, void 0, (function* () {
2176
+ y.setLevel(2), this._statsInterval = window.setInterval((() => O(this, void 0, void 0, (function* () {
2177
2177
  const n = yield this.peer.instance.getStats(null);
2178
2178
  let i = "";
2179
- const s = ["certificate", "codec", "peer-connection", "stream", "local-candidate", "remote-candidate"], r = ["id", "type", "timestamp"];
2179
+ const s = ["certificate", "codec", "peer-connection", "stream", "local-candidate", "remote-candidate"], a = ["id", "type", "timestamp"];
2180
2180
  n.forEach(((o) => {
2181
2181
  s.includes(o.type) || (i += `
2182
2182
  ${o.type}
2183
- `, Object.keys(o).forEach(((d) => {
2184
- r.includes(d) || (i += ` ${d}: ${o[d]}
2183
+ `, Object.keys(o).forEach(((l) => {
2184
+ a.includes(l) || (i += ` ${l}: ${o[l]}
2185
2185
  `);
2186
2186
  })));
2187
2187
  })), y.info(i);
2188
2188
  }))), 2e3);
2189
2189
  }
2190
2190
  }
2191
- class pi extends Jn {
2191
+ class hi extends qn {
2192
2192
  constructor(e) {
2193
- super(e), this.calls = {}, this.autoRecoverCalls = !0, this._iceServers = [], this._localElement = null, this._remoteElement = null, this._jwtAuth = !0, this._audioConstraints = !0, this._videoConstraints = !1, this._speaker = null, this._onlineHandler = null, this._offlineHandler = null, this._wasOffline = !1, this._videoConstraints = e.video || !1, this.iceServers = e.iceServers, this.ringtoneFile = e.ringtoneFile, this.ringbackFile = e.ringbackFile, this._setupNetworkListeners();
2193
+ super(e), this.calls = {}, this.autoRecoverCalls = !0, this._iceServers = [], this._localElement = null, this._remoteElement = null, this._jwtAuth = !0, this._audioConstraints = !0, this._previousAudioConstraints = !0, this._videoConstraints = !1, this._speaker = null, this._onlineHandler = null, this._offlineHandler = null, this._wasOffline = !1, this._videoConstraints = e.video || !1, this.iceServers = e.iceServers, this.ringtoneFile = e.ringtoneFile, this.ringbackFile = e.ringbackFile, this._setupNetworkListeners();
2194
2194
  }
2195
2195
  get reconnectDelay() {
2196
2196
  return 1e3;
2197
2197
  }
2198
2198
  getIsRegistered() {
2199
2199
  const e = Object.create(null, { getIsRegistered: { get: () => super.getIsRegistered } });
2200
- return L(this, void 0, void 0, (function* () {
2200
+ return O(this, void 0, void 0, (function* () {
2201
2201
  return e.getIsRegistered.call(this);
2202
2202
  }));
2203
2203
  }
2204
2204
  connect() {
2205
2205
  const e = Object.create(null, { connect: { get: () => super.connect } });
2206
- return L(this, void 0, void 0, (function* () {
2206
+ return O(this, void 0, void 0, (function* () {
2207
2207
  e.connect.call(this);
2208
2208
  }));
2209
2209
  }
2210
2210
  checkPermissions(e = !0, n = !0) {
2211
- return L(this, void 0, void 0, (function* () {
2211
+ return O(this, void 0, void 0, (function* () {
2212
2212
  try {
2213
- const i = yield je({ audio: e, video: n });
2213
+ const i = yield Ue({ audio: e, video: n });
2214
2214
  return Te(i), !0;
2215
2215
  } catch {
2216
2216
  return !1;
@@ -2222,7 +2222,7 @@ class pi extends Jn {
2222
2222
  }
2223
2223
  disconnect() {
2224
2224
  const e = Object.create(null, { disconnect: { get: () => super.disconnect } });
2225
- return L(this, void 0, void 0, (function* () {
2225
+ return O(this, void 0, void 0, (function* () {
2226
2226
  Object.keys(this.calls).forEach(((n) => this.calls[n].setState(N.Purge))), this.calls = {}, this._cleanupNetworkListeners(), yield e.disconnect.call(this);
2227
2227
  }));
2228
2228
  }
@@ -2234,41 +2234,41 @@ class pi extends Jn {
2234
2234
  }
2235
2235
  speedTest(e) {
2236
2236
  return new Promise(((n, i) => {
2237
- if (Zt(O.SpeedTest, ((o) => {
2238
- const { upDur: d, downDur: l } = o, h = l ? 8 * e / (l / 1e3) / 1024 : 0;
2239
- n({ upDur: d, downDur: l, upKps: (d ? 8 * e / (d / 1e3) / 1024 : 0).toFixed(0), downKps: h.toFixed(0) });
2237
+ if (Xt(L.SpeedTest, ((o) => {
2238
+ const { upDur: l, downDur: d } = o, h = d ? 8 * e / (d / 1e3) / 1024 : 0;
2239
+ n({ upDur: l, downDur: d, upKps: (l ? 8 * e / (l / 1e3) / 1024 : 0).toFixed(0), downKps: h.toFixed(0) });
2240
2240
  }), this.uuid), !(e = Number(e))) return i(`Invalid parameter 'bytes': ${e}`);
2241
2241
  this.executeRaw(`#SPU ${e}`);
2242
2242
  let s = e / 1024;
2243
2243
  e % 1024 && s++;
2244
- const r = ".".repeat(1024);
2245
- for (let o = 0; o < s; o++) this.executeRaw(`#SPB ${r}`);
2244
+ const a = ".".repeat(1024);
2245
+ for (let o = 0; o < s; o++) this.executeRaw(`#SPB ${a}`);
2246
2246
  this.executeRaw("#SPE");
2247
2247
  }));
2248
2248
  }
2249
2249
  getDevices() {
2250
- return ke().catch(((e) => ($(O.MediaError, e, this.uuid), [])));
2250
+ return ke().catch(((e) => (F(L.MediaError, e, this.uuid), [])));
2251
2251
  }
2252
2252
  getVideoDevices() {
2253
- return ke(ae.Video).catch(((e) => ($(O.MediaError, e, this.uuid), [])));
2253
+ return ke(ae.Video).catch(((e) => (F(L.MediaError, e, this.uuid), [])));
2254
2254
  }
2255
2255
  getAudioInDevices() {
2256
- return ke(ae.AudioIn).catch(((e) => ($(O.MediaError, e, this.uuid), [])));
2256
+ return ke(ae.AudioIn).catch(((e) => (F(L.MediaError, e, this.uuid), [])));
2257
2257
  }
2258
2258
  getAudioOutDevices() {
2259
- return ke(ae.AudioOut).catch(((e) => (y.error("getAudioOutDevices", e), $(O.MediaError, e, this.uuid), [])));
2259
+ return ke(ae.AudioOut).catch(((e) => (y.error("getAudioOutDevices", e), F(L.MediaError, e, this.uuid), [])));
2260
2260
  }
2261
2261
  validateDeviceId(e, n, i) {
2262
- return Ue(e, n, i);
2262
+ return je(e, n, i);
2263
2263
  }
2264
2264
  getDeviceResolutions(e) {
2265
- return L(this, void 0, void 0, (function* () {
2265
+ return O(this, void 0, void 0, (function* () {
2266
2266
  try {
2267
- return yield ((n) => L(void 0, void 0, void 0, (function* () {
2268
- const i = [], s = yield je({ video: { deviceId: { exact: n } } }), r = s.getVideoTracks()[0];
2269
- for (let o = 0; o < St.length; o++) {
2270
- const [d, l] = St[o];
2271
- (yield r.applyConstraints({ width: { exact: d }, height: { exact: l } }).then((() => !0)).catch((() => !1))) && i.push({ resolution: `${d}x${l}`, width: d, height: l });
2267
+ return yield ((n) => O(void 0, void 0, void 0, (function* () {
2268
+ const i = [], s = yield Ue({ video: { deviceId: { exact: n } } }), a = s.getVideoTracks()[0];
2269
+ for (let o = 0; o < _t.length; o++) {
2270
+ const [l, d] = _t[o];
2271
+ (yield a.applyConstraints({ width: { exact: l }, height: { exact: d } }).then((() => !0)).catch((() => !1))) && i.push({ resolution: `${l}x${d}`, width: l, height: d });
2272
2272
  }
2273
2273
  return Te(s), i;
2274
2274
  })))(e);
@@ -2281,30 +2281,30 @@ class pi extends Jn {
2281
2281
  return { audio: this._audioConstraints, video: this._videoConstraints };
2282
2282
  }
2283
2283
  setAudioSettings(e) {
2284
- return L(this, void 0, void 0, (function* () {
2284
+ return O(this, void 0, void 0, (function* () {
2285
2285
  if (!e) throw new Error("You need to provide the settings object");
2286
- const { micId: n, micLabel: i } = e, s = Ht(e, ["micId", "micLabel"]);
2287
- return zn(s), this._audioConstraints = yield ((r, o, d, l) => L(void 0, void 0, void 0, (function* () {
2288
- const { deviceId: h } = l;
2289
- if (h === void 0 && (r || o)) {
2290
- const f = yield Ue(r, o, d).catch(((v) => null));
2291
- f && (l.deviceId = { exact: f });
2286
+ const { micId: n, micLabel: i } = e, s = Wt(e, ["micId", "micLabel"]);
2287
+ return Yn(s), this._audioConstraints = yield ((a, o, l, d) => O(void 0, void 0, void 0, (function* () {
2288
+ const { deviceId: h } = d;
2289
+ if (h === void 0 && (a || o)) {
2290
+ const f = yield je(a, o, l).catch(((v) => null));
2291
+ f && (d.deviceId = { exact: f });
2292
2292
  }
2293
- return l;
2293
+ return d;
2294
2294
  })))(n, i, "audioinput", s), this.micId = n, this.micLabel = i, this._audioConstraints;
2295
2295
  }));
2296
2296
  }
2297
2297
  disableMicrophone() {
2298
- this._audioConstraints = !1;
2298
+ this._previousAudioConstraints = this._audioConstraints, this._audioConstraints = !1;
2299
2299
  }
2300
2300
  enableMicrophone() {
2301
- this._audioConstraints = !0;
2301
+ this._audioConstraints = this._previousAudioConstraints || !0;
2302
2302
  }
2303
2303
  set iceServers(e) {
2304
2304
  if (e && Array.isArray(e)) this._iceServers = e;
2305
2305
  else {
2306
2306
  const n = this.options.env === "development";
2307
- this._iceServers = n ? Pn : Mn;
2307
+ this._iceServers = n ? Mn : On;
2308
2308
  }
2309
2309
  }
2310
2310
  get iceServers() {
@@ -2330,25 +2330,25 @@ class pi extends Jn {
2330
2330
  }
2331
2331
  vertoBroadcast({ nodeId: e, channel: n = "", data: i }) {
2332
2332
  if (!n) throw new Error(`Invalid channel for broadcast: ${n}`);
2333
- const s = new ti({ sessid: this.sessionid, eventChannel: n, data: i });
2334
- e && (s.targetNodeId = e), this.execute(s).catch(((r) => r));
2333
+ const s = new ei({ sessid: this.sessionid, eventChannel: n, data: i });
2334
+ e && (s.targetNodeId = e), this.execute(s).catch(((a) => a));
2335
2335
  }
2336
2336
  vertoSubscribe({ nodeId: e, channels: n = [], handler: i }) {
2337
- return L(this, void 0, void 0, (function* () {
2338
- if (!(n = n.filter(((l) => l && !this._existsSubscription(this.relayProtocol, l)))).length) return {};
2339
- const s = new ni({ sessid: this.sessionid, eventChannel: n });
2337
+ return O(this, void 0, void 0, (function* () {
2338
+ if (!(n = n.filter(((d) => d && !this._existsSubscription(this.relayProtocol, d)))).length) return {};
2339
+ const s = new ti({ sessid: this.sessionid, eventChannel: n });
2340
2340
  e && (s.targetNodeId = e);
2341
- const r = yield this.execute(s), { unauthorized: o = [], subscribed: d = [] } = st(r);
2342
- return o.length && o.forEach(((l) => this._removeSubscription(this.relayProtocol, l))), d.forEach(((l) => this._addSubscription(this.relayProtocol, i, l))), r;
2341
+ const a = yield this.execute(s), { unauthorized: o = [], subscribed: l = [] } = it(a);
2342
+ return o.length && o.forEach(((d) => this._removeSubscription(this.relayProtocol, d))), l.forEach(((d) => this._addSubscription(this.relayProtocol, i, d))), a;
2343
2343
  }));
2344
2344
  }
2345
2345
  vertoUnsubscribe({ nodeId: e, channels: n = [] }) {
2346
- return L(this, void 0, void 0, (function* () {
2347
- if (!(n = n.filter(((d) => d && this._existsSubscription(this.relayProtocol, d)))).length) return {};
2348
- const i = new ii({ sessid: this.sessionid, eventChannel: n });
2346
+ return O(this, void 0, void 0, (function* () {
2347
+ if (!(n = n.filter(((l) => l && this._existsSubscription(this.relayProtocol, l)))).length) return {};
2348
+ const i = new ni({ sessid: this.sessionid, eventChannel: n });
2349
2349
  e && (i.targetNodeId = e);
2350
- const s = yield this.execute(i), { unsubscribed: r = [], notSubscribed: o = [] } = st(s);
2351
- return r.forEach(((d) => this._removeSubscription(this.relayProtocol, d))), o.forEach(((d) => this._removeSubscription(this.relayProtocol, d))), s;
2350
+ const s = yield this.execute(i), { unsubscribed: a = [], notSubscribed: o = [] } = it(s);
2351
+ return a.forEach(((l) => this._removeSubscription(this.relayProtocol, l))), o.forEach(((l) => this._removeSubscription(this.relayProtocol, l))), s;
2352
2352
  }));
2353
2353
  }
2354
2354
  _setupNetworkListeners() {
@@ -2365,7 +2365,7 @@ class pi extends Jn {
2365
2365
  return he.setStateTelnyx(e);
2366
2366
  }
2367
2367
  }
2368
- class Mt {
2368
+ class Ot {
2369
2369
  constructor(e, n) {
2370
2370
  this.code = n, this.message = e;
2371
2371
  }
@@ -2373,94 +2373,94 @@ class Mt {
2373
2373
  class ln extends Z {
2374
2374
  constructor(e) {
2375
2375
  super(), this.method = "anonymous_login";
2376
- const { target_type: n, target_id: i, target_version_id: s, userVariables: r, sessionId: o, reconnection: d } = e, l = { target_type: n, target_id: i, userVariables: r, reconnection: d, "User-Agent": { sdkVersion: We, data: navigator.userAgent } };
2377
- o && (l.sessid = o), s && (l.target_version_id = s), this.buildRequest({ method: this.method, params: l });
2376
+ const { target_type: n, target_id: i, target_version_id: s, userVariables: a, sessionId: o, reconnection: l } = e, d = { target_type: n, target_id: i, userVariables: a, reconnection: l, "User-Agent": { sdkVersion: We, data: navigator.userAgent } };
2377
+ o && (d.sessid = o), s && (d.target_version_id = s), this.buildRequest({ method: this.method, params: d });
2378
2378
  }
2379
2379
  }
2380
- const fi = We;
2380
+ const pi = We;
2381
2381
  class J {
2382
2382
  constructor(e) {
2383
- this.session = e, this.handleLogin = () => L(this, void 0, void 0, (function* () {
2384
- const { login: n, password: i, passwd: s, login_token: r, userVariables: o } = this.session.options, d = new on(n, i || s, r, this.session.sessionid, o, !!fe()), l = yield this.session.execute(d).catch(this.session.handleLoginError);
2385
- l && (this.session.sessionid = l.sessid);
2386
- })), this.handleAnonymousLogin = () => L(this, void 0, void 0, (function* () {
2383
+ this.session = e, this.handleLogin = () => O(this, void 0, void 0, (function* () {
2384
+ const { login: n, password: i, passwd: s, login_token: a, userVariables: o } = this.session.options, l = new sn(n, i || s, a, this.session.sessionid, o, !!fe()), d = yield this.session.execute(l).catch(this.session.handleLoginError);
2385
+ d && (this.session.sessionid = d.sessid);
2386
+ })), this.handleAnonymousLogin = () => O(this, void 0, void 0, (function* () {
2387
2387
  const { anonymous_login: n } = this.session.options, i = new ln({ target_id: n.target_id, target_type: n.target_type, target_version_id: n.target_version_id, sessionId: this.session.sessionid, userVariables: this.session.options.userVariables, reconnection: !!fe() }), s = yield this.session.execute(i).catch(this.session.handleLoginError);
2388
2388
  s && (this.session.sessionid = s.sessid);
2389
2389
  }));
2390
2390
  }
2391
2391
  _ack(e, n) {
2392
- const i = new Xn(e, n);
2392
+ const i = new Qn(e, n);
2393
2393
  this.nodeId && (i.targetNodeId = this.nodeId), this.session.execute(i);
2394
2394
  }
2395
2395
  reconnectDelay() {
2396
- return 1e3 * Qt(2, 6);
2396
+ return 1e3 * Kt(2, 6);
2397
2397
  }
2398
2398
  handleMessage(e) {
2399
2399
  var n;
2400
- const { session: i } = this, { id: s, method: r, params: o = {}, voice_sdk_id: d } = e, l = o?.callID, h = o?.eventChannel, f = o?.eventType, v = r === F.Attach, _ = r === F.Punt;
2400
+ const { session: i } = this, { id: s, method: a, params: o = {}, voice_sdk_id: l } = e, d = o?.callID, h = o?.eventChannel, f = o?.eventType, v = a === $.Attach, _ = a === $.Punt;
2401
2401
  let w = !1;
2402
2402
  if (f === "channelPvtData") return this._handlePvtEvent(o.pvtData);
2403
- if (l && i.calls.hasOwnProperty(l)) {
2404
- if (!v) return i.calls[l].handleMessage(e), void this._ack(s, r);
2405
- w = (i.options.keepConnectionAliveOnSocketClose || i.calls[l].options.keepConnectionAliveOnSocketClose) && !!(!((n = this.session.calls[l].peer) === null || n === void 0) && n.instance), w ? y.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${l}] re-attaching call due to ATTACH and keepConnectionAliveOnSocketClose`) : (y.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${l}] Hanging up the call due to ATTACH`), i.calls[l].hangup({}, !1));
2403
+ if (d && i.calls.hasOwnProperty(d)) {
2404
+ if (!v) return i.calls[d].handleMessage(e), void this._ack(s, a);
2405
+ w = (i.options.keepConnectionAliveOnSocketClose || i.calls[d].options.keepConnectionAliveOnSocketClose) && !!(!((n = this.session.calls[d].peer) === null || n === void 0) && n.instance), w ? y.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${d}] re-attaching call due to ATTACH and keepConnectionAliveOnSocketClose`) : (y.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${d}] Hanging up the call due to ATTACH`), i.calls[d].hangup({}, !1));
2406
2406
  }
2407
- if (_ && i.options.keepConnectionAliveOnSocketClose) return y.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${l}] keeping call alive due to PUNT and keepConnectionAliveOnSocketClose. Disconnecting base session...`), this.session.socketDisconnect(), void this._ack(s, r);
2407
+ if (_ && i.options.keepConnectionAliveOnSocketClose) return y.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${d}] keeping call alive due to PUNT and keepConnectionAliveOnSocketClose. Disconnecting base session...`), this.session.socketDisconnect(), void this._ack(s, a);
2408
2408
  const C = () => {
2409
2409
  var S, A, E, P, D, q;
2410
- const B = { id: l, audio: !0, video: i.options.video, remoteSdp: o.sdp, destinationNumber: o.callee_id_number, remoteCallerName: o.caller_id_name, remoteCallerNumber: o.caller_id_number, callerName: o.callee_id_name, callerNumber: o.callee_id_number, attach: v, mediaSettings: o.mediaSettings, debug: (S = i.options.debug) !== null && S !== void 0 && S, debugOutput: (A = i.options.debugOutput) !== null && A !== void 0 ? A : "socket", trickleIce: (E = i.options.trickleIce) !== null && E !== void 0 && E, prefetchIceCandidates: (P = i.options.prefetchIceCandidates) !== null && P !== void 0 && P, forceRelayCandidate: (D = i.options.forceRelayCandidate) !== null && D !== void 0 && D, keepConnectionAliveOnSocketClose: (q = i.options.keepConnectionAliveOnSocketClose) !== null && q !== void 0 && q };
2410
+ const B = { id: d, audio: !0, video: i.options.video, remoteSdp: o.sdp, destinationNumber: o.callee_id_number, remoteCallerName: o.caller_id_name, remoteCallerNumber: o.caller_id_number, callerName: o.callee_id_name, callerNumber: o.callee_id_number, attach: v, mediaSettings: o.mediaSettings, debug: (S = i.options.debug) !== null && S !== void 0 && S, debugOutput: (A = i.options.debugOutput) !== null && A !== void 0 ? A : "socket", trickleIce: (E = i.options.trickleIce) !== null && E !== void 0 && E, prefetchIceCandidates: (P = i.options.prefetchIceCandidates) !== null && P !== void 0 && P, forceRelayCandidate: (D = i.options.forceRelayCandidate) !== null && D !== void 0 && D, keepConnectionAliveOnSocketClose: (q = i.options.keepConnectionAliveOnSocketClose) !== null && q !== void 0 && q };
2411
2411
  o.telnyx_call_control_id && (B.telnyxCallControlId = o.telnyx_call_control_id), o.telnyx_session_id && (B.telnyxSessionId = o.telnyx_session_id), o.telnyx_leg_id && (B.telnyxLegId = o.telnyx_leg_id), o.client_state && (B.clientState = o.client_state), o.dialogParams && o.dialogParams.custom_headers && o.dialogParams.custom_headers.length && (B.customHeaders = o.dialogParams.custom_headers);
2412
2412
  const x = new he(i, B);
2413
2413
  return x.nodeId = this.nodeId, x;
2414
- }, k = new en(d), p = new tn(d);
2415
- switch (r) {
2416
- case F.Ping:
2414
+ }, k = new Zt(l), p = new en(l);
2415
+ switch (a) {
2416
+ case $.Ping:
2417
2417
  this.session.setPingReceived(), this.session.execute(p).then((() => {
2418
2418
  J.receivedAuthenticationRequired = 0;
2419
- })).catch(((E) => L(this, void 0, void 0, (function* () {
2419
+ })).catch(((E) => O(this, void 0, void 0, (function* () {
2420
2420
  E.code === this.session.authenticationRequiredErrorCode && J.receivedAuthenticationRequired >= 0 && (J.receivedAuthenticationRequired += 1, J.receivedAuthenticationRequired > 1 && this.session.hasAutoReconnect() && (y.warn("Ping failed twice with Authentication Required. Re-logging in..."), Ne(this.session.options) ? this.handleLogin() : Ie(this.session.options) && this.handleAnonymousLogin(), J.receivedAuthenticationRequired = -1));
2421
2421
  }))));
2422
2422
  break;
2423
- case F.Punt:
2423
+ case $.Punt:
2424
2424
  i.disconnect();
2425
2425
  break;
2426
- case F.Invite: {
2426
+ case $.Invite: {
2427
2427
  const E = C();
2428
- E.playRingtone(), E.setState(N.Ringing), E.direction = de.Inbound, this._ack(s, r);
2428
+ E.playRingtone(), E.setState(N.Ringing), E.direction = le.Inbound, this._ack(s, a);
2429
2429
  break;
2430
2430
  }
2431
- case F.Attach: {
2432
- if (w) return void this.session.execute(new rt({ sessid: this.session.sessionid, sdp: this.session.calls[l].peer.instance.localDescription.sdp, dialogParams: this.session.calls[l].options, "User-Agent": `Web-${fi}` }));
2433
- y.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${l}] Re-creating call instance.`);
2431
+ case $.Attach: {
2432
+ if (w) return void this.session.execute(new ot({ sessid: this.session.sessionid, sdp: this.session.calls[d].peer.instance.localDescription.sdp, dialogParams: this.session.calls[d].options, "User-Agent": `Web-${pi}` }));
2433
+ y.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${d}] Re-creating call instance.`);
2434
2434
  const E = C();
2435
2435
  this.session.autoRecoverCalls ? E.answer() : E.setState(N.Recovering), E.handleMessage(e);
2436
2436
  break;
2437
2437
  }
2438
- case F.Event:
2438
+ case $.Event:
2439
2439
  case "webrtc.event":
2440
2440
  if (!h) return void y.error("Verto received an unknown event:", o);
2441
2441
  const S = i.relayProtocol, A = h.split(".")[0];
2442
- i._existsSubscription(S, h) ? $(S, o, h) : h === i.sessionid ? this._handleSessionEvent(o.eventData) : i._existsSubscription(S, A) ? $(S, o, A) : i.calls.hasOwnProperty(h) ? i.calls[h].handleMessage(e) : $(O.Notification, o, i.uuid);
2442
+ i._existsSubscription(S, h) ? F(S, o, h) : h === i.sessionid ? this._handleSessionEvent(o.eventData) : i._existsSubscription(S, A) ? F(S, o, A) : i.calls.hasOwnProperty(h) ? i.calls[h].handleMessage(e) : F(L.Notification, o, i.uuid);
2443
2443
  break;
2444
- case F.Info:
2445
- o.type = oe.generic, $(O.Notification, o, i.uuid);
2444
+ case $.Info:
2445
+ o.type = oe.generic, F(L.Notification, o, i.uuid);
2446
2446
  break;
2447
- case F.ClientReady:
2447
+ case $.ClientReady:
2448
2448
  this.session.execute(k);
2449
2449
  break;
2450
2450
  default: {
2451
- const E = pt(e);
2451
+ const E = ht(e);
2452
2452
  if (E) {
2453
2453
  switch (E) {
2454
2454
  case te.REGISTER:
2455
2455
  case te.REGED:
2456
- i.connection.previousGatewayState !== te.REGED && i.connection.previousGatewayState !== te.REGISTER && (this.session._triggerKeepAliveTimeoutCheck(), J.retriedRegister = 0, o.type = oe.vertoClientReady, $(O.Ready, o, i.uuid), i.options.trickleIce && (y.debug("Trickle ICE is enabled. Checking Gateway support"), this.session.execute(new rn({ candidate: "" })).catch(((P) => {
2456
+ i.connection.previousGatewayState !== te.REGED && i.connection.previousGatewayState !== te.REGISTER && (this.session._triggerKeepAliveTimeoutCheck(), J.retriedRegister = 0, o.type = oe.vertoClientReady, F(L.Ready, o, i.uuid), i.options.trickleIce && (y.debug("Trickle ICE is enabled. Checking Gateway support"), this.session.execute(new on({ candidate: "" })).catch(((P) => {
2457
2457
  P.code === this.session.invalidMethodErrorCode ? (y.warn("Trickle ICE is not supported by the server, disabling it."), y.debug("Trickle ICE check error:", JSON.stringify(P, null, 2)), i.options.trickleIce = !1) : y.debug("Trickle ICE check:", JSON.stringify(P, null, 2));
2458
2458
  }))));
2459
2459
  break;
2460
2460
  case te.UNREGED:
2461
2461
  case te.NOREG:
2462
2462
  if (J.retriedRegister += 1, J.retriedRegister === 5) {
2463
- J.retriedRegister = 0, $(O.Error, { error: new Mt("Fail to register the user, the server tried 5 times", "UNREGED|NOREG"), sessionId: i.sessionid }, i.uuid);
2463
+ J.retriedRegister = 0, F(L.Error, { error: new Ot("Fail to register the user, the server tried 5 times", "UNREGED|NOREG"), sessionId: i.sessionid }, i.uuid);
2464
2464
  break;
2465
2465
  }
2466
2466
  setTimeout((() => {
@@ -2471,11 +2471,11 @@ class J {
2471
2471
  case te.FAIL_WAIT:
2472
2472
  if (i.connection.previousGatewayState !== te.FAILED && i.connection.previousGatewayState !== te.FAIL_WAIT) {
2473
2473
  if (!this.session.hasAutoReconnect()) {
2474
- J.retriedConnect = 0, $(O.Error, { error: new Mt("Fail to connect the server, the server tried 5 times", "FAILED|FAIL_WAIT"), sessionId: i.sessionid }, i.uuid);
2474
+ J.retriedConnect = 0, F(L.Error, { error: new Ot("Fail to connect the server, the server tried 5 times", "FAILED|FAIL_WAIT"), sessionId: i.sessionid }, i.uuid);
2475
2475
  break;
2476
2476
  }
2477
2477
  if (J.retriedConnect += 1, J.retriedConnect === 5) {
2478
- J.retriedConnect = 0, $(O.Error, { error: new Error("Connection Retry Failed"), sessionId: i.sessionid }, i.uuid);
2478
+ J.retriedConnect = 0, F(L.Error, { error: new Error("Connection Retry Failed"), sessionId: i.sessionid }, i.uuid);
2479
2479
  break;
2480
2480
  }
2481
2481
  setTimeout((() => {
@@ -2500,41 +2500,41 @@ class J {
2500
2500
  const i = Object.keys(this.session.calls);
2501
2501
  if (e.action !== "bootObj") return i.find(((s) => this.session.calls[s].channels.includes(n)));
2502
2502
  {
2503
- const s = e.data.find(((r) => i.includes(r[0])));
2503
+ const s = e.data.find(((a) => i.includes(a[0])));
2504
2504
  if (s instanceof Array) return s[0];
2505
2505
  }
2506
2506
  }
2507
2507
  _handlePvtEvent(e) {
2508
- return L(this, void 0, void 0, (function* () {
2509
- const { session: n } = this, i = n.relayProtocol, { action: s, laChannel: r, laName: o, chatChannel: d, infoChannel: l, modChannel: h, conferenceMemberID: f, role: v, callID: _ } = e;
2508
+ return O(this, void 0, void 0, (function* () {
2509
+ const { session: n } = this, i = n.relayProtocol, { action: s, laChannel: a, laName: o, chatChannel: l, infoChannel: d, modChannel: h, conferenceMemberID: f, role: v, callID: _ } = e;
2510
2510
  switch (s) {
2511
2511
  case "conference-liveArray-join": {
2512
2512
  const w = () => {
2513
- n.vertoBroadcast({ nodeId: this.nodeId, channel: r, data: { liveArray: { command: "bootstrap", context: r, name: o } } });
2514
- }, C = { nodeId: this.nodeId, channels: [r], handler: ({ data: p }) => {
2515
- const S = _ || this._retrieveCallId(p, r);
2513
+ n.vertoBroadcast({ nodeId: this.nodeId, channel: a, data: { liveArray: { command: "bootstrap", context: a, name: o } } });
2514
+ }, C = { nodeId: this.nodeId, channels: [a], handler: ({ data: p }) => {
2515
+ const S = _ || this._retrieveCallId(p, a);
2516
2516
  if (S && n.calls.hasOwnProperty(S)) {
2517
2517
  const A = n.calls[S];
2518
- A._addChannel(r), A.extension = o, A.handleConferenceUpdate(p, e).then(((E) => {
2518
+ A._addChannel(a), A.extension = o, A.handleConferenceUpdate(p, e).then(((E) => {
2519
2519
  E === "INVALID_PACKET" && w();
2520
2520
  }));
2521
2521
  }
2522
2522
  } }, k = yield n.vertoSubscribe(C).catch(((p) => {
2523
2523
  y.error("liveArray subscription error:", p);
2524
2524
  }));
2525
- it(k, r) && w();
2525
+ nt(k, a) && w();
2526
2526
  break;
2527
2527
  }
2528
2528
  case "conference-liveArray-part": {
2529
2529
  let w = null;
2530
- if (r && n._existsSubscription(i, r)) {
2531
- const { callId: k = null } = n.subscriptions[i][r];
2530
+ if (a && n._existsSubscription(i, a)) {
2531
+ const { callId: k = null } = n.subscriptions[i][a];
2532
2532
  if (w = n.calls[k] || null, k !== null) {
2533
2533
  const p = { type: oe.conferenceUpdate, action: se.Leave, conferenceName: o, participantId: Number(f), role: v };
2534
- $(O.Notification, p, k, !1) || $(O.Notification, p, n.uuid), w === null && ue(O.Notification, null, k);
2534
+ F(L.Notification, p, k, !1) || F(L.Notification, p, n.uuid), w === null && ue(L.Notification, null, k);
2535
2535
  }
2536
2536
  }
2537
- const C = [r, d, l, h];
2537
+ const C = [a, l, d, h];
2538
2538
  n.vertoUnsubscribe({ nodeId: this.nodeId, channels: C }).then((({ unsubscribedChannels: k = [] }) => {
2539
2539
  w && (w.channels = w.channels.filter(((p) => !k.includes(p))));
2540
2540
  })).catch(((k) => {
@@ -2549,24 +2549,24 @@ class J {
2549
2549
  switch (e.contentType) {
2550
2550
  case "layout-info":
2551
2551
  case "layer-info":
2552
- cn(this.session, e);
2552
+ an(this.session, e);
2553
2553
  break;
2554
2554
  case "logo-info": {
2555
2555
  const n = { type: oe.conferenceUpdate, action: se.LogoInfo, logo: e.logoURL };
2556
- $(O.Notification, n, this.session.uuid);
2556
+ F(L.Notification, n, this.session.uuid);
2557
2557
  break;
2558
2558
  }
2559
2559
  }
2560
2560
  }
2561
2561
  }
2562
2562
  J.retriedConnect = 0, J.retriedRegister = 0, J.receivedAuthenticationRequired = 0;
2563
- class gi extends pi {
2563
+ class fi extends hi {
2564
2564
  constructor(e) {
2565
- super(e), this.relayProtocol = "verto-protocol", this.timeoutErrorCode = -329990, this.handleLoginOnSocketOpen = () => L(this, void 0, void 0, (function* () {
2565
+ super(e), this.relayProtocol = "verto-protocol", this.timeoutErrorCode = -329990, this.handleLoginOnSocketOpen = () => O(this, void 0, void 0, (function* () {
2566
2566
  this._idle = !1;
2567
- const { login: n, password: i, passwd: s, login_token: r, userVariables: o, autoReconnect: d = !0 } = this.options, l = new on(n, i || s, r, this.sessionid, o, !!fe()), h = yield this.execute(l).catch(this._handleLoginError);
2568
- h && (this._autoReconnect = d, this.sessionid = h.sessid);
2569
- })), this.handleAnonymousLoginOnSocketOpen = () => L(this, void 0, void 0, (function* () {
2567
+ const { login: n, password: i, passwd: s, login_token: a, userVariables: o, autoReconnect: l = !0 } = this.options, d = new sn(n, i || s, a, this.sessionid, o, !!fe()), h = yield this.execute(d).catch(this._handleLoginError);
2568
+ h && (this._autoReconnect = l, this.sessionid = h.sessid);
2569
+ })), this.handleAnonymousLoginOnSocketOpen = () => O(this, void 0, void 0, (function* () {
2570
2570
  this._idle = !1;
2571
2571
  const { anonymous_login: n } = this.options, i = new ln({ target_id: n.target_id, target_type: n.target_type, target_version_id: n.target_version_id, sessionId: this.sessionid, userVariables: this.options.userVariables, reconnection: !!fe() }), s = yield this.execute(i).catch(this._handleLoginError);
2572
2572
  s && (this.sessionid = s.sessid);
@@ -2598,7 +2598,7 @@ class gi extends pi {
2598
2598
  return !!Ie(this.options) || !!e.destinationNumber;
2599
2599
  }
2600
2600
  _onSocketOpen() {
2601
- return L(this, void 0, void 0, (function* () {
2601
+ return O(this, void 0, void 0, (function* () {
2602
2602
  return Ne(this.options) ? this.handleLoginOnSocketOpen() : Ie(this.options) ? this.handleAnonymousLoginOnSocketOpen() : void 0;
2603
2603
  }));
2604
2604
  }
@@ -2606,62 +2606,62 @@ class gi extends pi {
2606
2606
  new J(this).handleMessage(e);
2607
2607
  }
2608
2608
  }
2609
- class vi extends gi {
2609
+ class gi extends fi {
2610
2610
  constructor(e) {
2611
- super(e), y.info(`SDK version: ${sn}`);
2611
+ super(e), y.info(`SDK version: ${nn}`);
2612
2612
  }
2613
2613
  newCall(e) {
2614
2614
  return super.newCall(e);
2615
2615
  }
2616
2616
  static webRTCInfo() {
2617
- return Qn();
2617
+ return Kn();
2618
2618
  }
2619
2619
  static webRTCSupportedBrowserList() {
2620
2620
  return [{ operationSystem: "Android", supported: [{ browserName: "Chrome", features: ["audio"], supported: H.full }, { browserName: "Firefox", features: ["audio"], supported: H.partial }, { browserName: "Safari", supported: H.not_supported }, { browserName: "Edge", supported: H.not_supported }] }, { operationSystem: "iOS", supported: [{ browserName: "Chrome", supported: H.not_supported }, { browserName: "Firefox", supported: H.not_supported }, { browserName: "Safari", features: ["video", "audio"], supported: H.full }, { browserName: "Edge", supported: H.not_supported }] }, { operationSystem: "Linux", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: H.full }, { browserName: "Firefox", features: ["audio"], supported: H.partial }, { browserName: "Safari", supported: H.not_supported }, { browserName: "Edge", supported: H.not_supported }] }, { operationSystem: "MacOS", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: H.full }, { browserName: "Firefox", features: ["audio"], supported: H.partial }, { browserName: "Safari", features: ["video", "audio"], supported: H.full }, { browserName: "Edge", features: ["audio"], supported: H.partial }] }, { operationSystem: "Windows", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: H.full }, { browserName: "Firefox", features: ["audio"], supported: H.partial }, { browserName: "Safari", supported: H.not_supported }, { browserName: "Edge", features: ["audio"], supported: H.partial }] }];
2621
2621
  }
2622
2622
  }
2623
- function un(t) {
2623
+ function dn(t) {
2624
2624
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
2625
2625
  }
2626
- var Xe = { exports: {} }, Pt;
2627
- function mi() {
2628
- return Pt || (Pt = 1, (function(t) {
2626
+ var Xe = { exports: {} }, Mt;
2627
+ function vi() {
2628
+ return Mt || (Mt = 1, (function(t) {
2629
2629
  var e = Object.prototype.hasOwnProperty, n = "~";
2630
2630
  function i() {
2631
2631
  }
2632
2632
  Object.create && (i.prototype = /* @__PURE__ */ Object.create(null), new i().__proto__ || (n = !1));
2633
- function s(l, h, f) {
2634
- this.fn = l, this.context = h, this.once = f || !1;
2633
+ function s(d, h, f) {
2634
+ this.fn = d, this.context = h, this.once = f || !1;
2635
2635
  }
2636
- function r(l, h, f, v, _) {
2636
+ function a(d, h, f, v, _) {
2637
2637
  if (typeof f != "function")
2638
2638
  throw new TypeError("The listener must be a function");
2639
- var w = new s(f, v || l, _), C = n ? n + h : h;
2640
- return l._events[C] ? l._events[C].fn ? l._events[C] = [l._events[C], w] : l._events[C].push(w) : (l._events[C] = w, l._eventsCount++), l;
2639
+ var w = new s(f, v || d, _), C = n ? n + h : h;
2640
+ return d._events[C] ? d._events[C].fn ? d._events[C] = [d._events[C], w] : d._events[C].push(w) : (d._events[C] = w, d._eventsCount++), d;
2641
2641
  }
2642
- function o(l, h) {
2643
- --l._eventsCount === 0 ? l._events = new i() : delete l._events[h];
2642
+ function o(d, h) {
2643
+ --d._eventsCount === 0 ? d._events = new i() : delete d._events[h];
2644
2644
  }
2645
- function d() {
2645
+ function l() {
2646
2646
  this._events = new i(), this._eventsCount = 0;
2647
2647
  }
2648
- d.prototype.eventNames = function() {
2648
+ l.prototype.eventNames = function() {
2649
2649
  var h = [], f, v;
2650
2650
  if (this._eventsCount === 0) return h;
2651
2651
  for (v in f = this._events)
2652
2652
  e.call(f, v) && h.push(n ? v.slice(1) : v);
2653
2653
  return Object.getOwnPropertySymbols ? h.concat(Object.getOwnPropertySymbols(f)) : h;
2654
- }, d.prototype.listeners = function(h) {
2654
+ }, l.prototype.listeners = function(h) {
2655
2655
  var f = n ? n + h : h, v = this._events[f];
2656
2656
  if (!v) return [];
2657
2657
  if (v.fn) return [v.fn];
2658
2658
  for (var _ = 0, w = v.length, C = new Array(w); _ < w; _++)
2659
2659
  C[_] = v[_].fn;
2660
2660
  return C;
2661
- }, d.prototype.listenerCount = function(h) {
2661
+ }, l.prototype.listenerCount = function(h) {
2662
2662
  var f = n ? n + h : h, v = this._events[f];
2663
2663
  return v ? v.fn ? 1 : v.length : 0;
2664
- }, d.prototype.emit = function(h, f, v, _, w, C) {
2664
+ }, l.prototype.emit = function(h, f, v, _, w, C) {
2665
2665
  var k = n ? n + h : h;
2666
2666
  if (!this._events[k]) return !1;
2667
2667
  var p = this._events[k], S = arguments.length, A, E;
@@ -2706,11 +2706,11 @@ function mi() {
2706
2706
  }
2707
2707
  }
2708
2708
  return !0;
2709
- }, d.prototype.on = function(h, f, v) {
2710
- return r(this, h, f, v, !1);
2711
- }, d.prototype.once = function(h, f, v) {
2712
- return r(this, h, f, v, !0);
2713
- }, d.prototype.removeListener = function(h, f, v, _) {
2709
+ }, l.prototype.on = function(h, f, v) {
2710
+ return a(this, h, f, v, !1);
2711
+ }, l.prototype.once = function(h, f, v) {
2712
+ return a(this, h, f, v, !0);
2713
+ }, l.prototype.removeListener = function(h, f, v, _) {
2714
2714
  var w = n ? n + h : h;
2715
2715
  if (!this._events[w]) return this;
2716
2716
  if (!f)
@@ -2724,20 +2724,20 @@ function mi() {
2724
2724
  p.length ? this._events[w] = p.length === 1 ? p[0] : p : o(this, w);
2725
2725
  }
2726
2726
  return this;
2727
- }, d.prototype.removeAllListeners = function(h) {
2727
+ }, l.prototype.removeAllListeners = function(h) {
2728
2728
  var f;
2729
2729
  return h ? (f = n ? n + h : h, this._events[f] && o(this, f)) : (this._events = new i(), this._eventsCount = 0), this;
2730
- }, d.prototype.off = d.prototype.removeListener, d.prototype.addListener = d.prototype.on, d.prefixed = n, d.EventEmitter = d, t.exports = d;
2730
+ }, l.prototype.off = l.prototype.removeListener, l.prototype.addListener = l.prototype.on, l.prefixed = n, l.EventEmitter = l, t.exports = l;
2731
2731
  })(Xe)), Xe.exports;
2732
2732
  }
2733
- var yi = mi();
2734
- const gt = /* @__PURE__ */ un(yi), $e = new gt();
2735
- var Pe = { exports: {} }, bi = Pe.exports, Dt;
2736
- function _i() {
2737
- return Dt || (Dt = 1, (function(t) {
2733
+ var mi = vi();
2734
+ const ft = /* @__PURE__ */ dn(mi), Fe = new ft();
2735
+ var Pe = { exports: {} }, yi = Pe.exports, Pt;
2736
+ function bi() {
2737
+ return Pt || (Pt = 1, (function(t) {
2738
2738
  (function(e, n) {
2739
2739
  t.exports ? t.exports = n() : e.log = n();
2740
- })(bi, function() {
2740
+ })(yi, function() {
2741
2741
  var e = function() {
2742
2742
  }, n = "undefined", i = typeof window !== n && typeof window.navigator !== n && /Trident\/|MSIE /.test(window.navigator.userAgent), s = [
2743
2743
  "trace",
@@ -2745,8 +2745,8 @@ function _i() {
2745
2745
  "info",
2746
2746
  "warn",
2747
2747
  "error"
2748
- ], r = {}, o = null;
2749
- function d(k, p) {
2748
+ ], a = {}, o = null;
2749
+ function l(k, p) {
2750
2750
  var S = k[p];
2751
2751
  if (typeof S.bind == "function")
2752
2752
  return S.bind(k);
@@ -2758,11 +2758,11 @@ function _i() {
2758
2758
  };
2759
2759
  }
2760
2760
  }
2761
- function l() {
2761
+ function d() {
2762
2762
  console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
2763
2763
  }
2764
2764
  function h(k) {
2765
- return k === "debug" && (k = "log"), typeof console === n ? !1 : k === "trace" && i ? l : console[k] !== void 0 ? d(console, k) : console.log !== void 0 ? d(console, "log") : e;
2765
+ return k === "debug" && (k = "log"), typeof console === n ? !1 : k === "trace" && i ? d : console[k] !== void 0 ? l(console, k) : console.log !== void 0 ? l(console, "log") : e;
2766
2766
  }
2767
2767
  function f() {
2768
2768
  for (var k = this.getLevel(), p = 0; p < s.length; p++) {
@@ -2827,7 +2827,7 @@ function _i() {
2827
2827
  }
2828
2828
  }
2829
2829
  }
2830
- function a(u) {
2830
+ function r(u) {
2831
2831
  var g = u;
2832
2832
  if (typeof g == "string" && S.levels[g.toUpperCase()] !== void 0 && (g = S.levels[g.toUpperCase()]), typeof g == "number" && g >= 0 && g <= S.levels.SILENT)
2833
2833
  return g;
@@ -2843,9 +2843,9 @@ function _i() {
2843
2843
  }, S.methodFactory = p || _, S.getLevel = function() {
2844
2844
  return P ?? E ?? A;
2845
2845
  }, S.setLevel = function(u, g) {
2846
- return P = a(u), g !== !1 && q(P), f.call(S);
2846
+ return P = r(u), g !== !1 && q(P), f.call(S);
2847
2847
  }, S.setDefaultLevel = function(u) {
2848
- E = a(u), B() || S.setLevel(u, !1);
2848
+ E = r(u), B() || S.setLevel(u, !1);
2849
2849
  }, S.resetLevel = function() {
2850
2850
  P = null, x(), f.call(S);
2851
2851
  }, S.enableAll = function(u) {
@@ -2853,20 +2853,20 @@ function _i() {
2853
2853
  }, S.disableAll = function(u) {
2854
2854
  S.setLevel(S.levels.SILENT, u);
2855
2855
  }, S.rebuild = function() {
2856
- if (o !== S && (A = a(o.getLevel())), f.call(S), o === S)
2857
- for (var u in r)
2858
- r[u].rebuild();
2859
- }, A = a(
2856
+ if (o !== S && (A = r(o.getLevel())), f.call(S), o === S)
2857
+ for (var u in a)
2858
+ a[u].rebuild();
2859
+ }, A = r(
2860
2860
  o ? o.getLevel() : "WARN"
2861
2861
  );
2862
2862
  var c = B();
2863
- c != null && (P = a(c)), f.call(S);
2863
+ c != null && (P = r(c)), f.call(S);
2864
2864
  }
2865
2865
  o = new w(), o.getLogger = function(p) {
2866
2866
  if (typeof p != "symbol" && typeof p != "string" || p === "")
2867
2867
  throw new TypeError("You must supply a name when creating a logger.");
2868
- var S = r[p];
2869
- return S || (S = r[p] = new w(
2868
+ var S = a[p];
2869
+ return S || (S = a[p] = new w(
2870
2870
  p,
2871
2871
  o.methodFactory
2872
2872
  )), S;
@@ -2875,29 +2875,29 @@ function _i() {
2875
2875
  return o.noConflict = function() {
2876
2876
  return typeof window !== n && window.log === o && (window.log = C), o;
2877
2877
  }, o.getLoggers = function() {
2878
- return r;
2878
+ return a;
2879
2879
  }, o.default = o, o;
2880
2880
  });
2881
2881
  })(Pe)), Pe.exports;
2882
2882
  }
2883
- var Si = _i();
2884
- const wi = /* @__PURE__ */ un(Si), Ci = () => (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), z = wi.getLogger("telnyx-ai-agent"), ki = z.methodFactory;
2883
+ var _i = bi();
2884
+ const Si = /* @__PURE__ */ dn(_i), wi = () => (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), z = Si.getLogger("telnyx-ai-agent"), Ci = z.methodFactory;
2885
2885
  z.methodFactory = (t, e, n) => {
2886
- const i = ki(t, e, n);
2886
+ const i = Ci(t, e, n);
2887
2887
  return function(...s) {
2888
- i(Ci(), "-", ...s);
2888
+ i(wi(), "-", ...s);
2889
2889
  };
2890
2890
  };
2891
2891
  z.setLevel("info");
2892
- function Ii(t, e) {
2892
+ function ki(t, e) {
2893
2893
  let n = 0;
2894
2894
  return (...i) => {
2895
2895
  const s = Date.now();
2896
2896
  s - n >= e && (n = s, t(...i));
2897
2897
  };
2898
2898
  }
2899
- const Ze = 10, Ei = 1e3, Nt = 20;
2900
- class Ti {
2899
+ const Ii = 10, Ei = 500, Ti = 100, Dt = 20;
2900
+ class Ai {
2901
2901
  remoteIntervalId = null;
2902
2902
  localIntervalId = null;
2903
2903
  remoteStream = null;
@@ -2913,10 +2913,21 @@ class Ti {
2913
2913
  // Local stream (user) state tracking
2914
2914
  userIsSpeaking = !1;
2915
2915
  lastUserAudioTime = null;
2916
- constructor() {
2916
+ userSpeechStartTime = null;
2917
+ // Latency measurement tracking
2918
+ userSilenceStartTime = null;
2919
+ isFirstAgentSpeech = !0;
2920
+ monitorStartTime = null;
2921
+ // Configurable VAD options
2922
+ volumeThreshold;
2923
+ silenceDurationMs;
2924
+ minSpeechDurationMs;
2925
+ maxLatencyMs;
2926
+ constructor(e) {
2927
+ this.volumeThreshold = e?.volumeThreshold ?? Ii, this.silenceDurationMs = e?.silenceDurationMs ?? Ei, this.minSpeechDurationMs = e?.minSpeechDurationMs ?? Ti, this.maxLatencyMs = e?.maxLatencyMs;
2917
2928
  }
2918
- updateAgentState = Ii((e) => {
2919
- z.debug("AudioStreamMonitor updateAgentState", e), z.debug("Previous state:", this.lastState), e.state !== this.lastState && (this.lastState = e.state, $e.emit("conversation.agent.state", e));
2929
+ updateAgentState = ki((e) => {
2930
+ z.debug("AudioStreamMonitor updateAgentState", e), z.debug("Previous state:", this.lastState), e.state !== this.lastState && (this.lastState = e.state, Fe.emit("conversation.agent.state", e));
2920
2931
  }, 100);
2921
2932
  /**
2922
2933
  * Set the remote audio stream (agent's voice) to monitor for speech detection
@@ -2952,7 +2963,7 @@ class Ti {
2952
2963
  z.debug("Remote monitor: no stream, skipping");
2953
2964
  return;
2954
2965
  }
2955
- this.remoteAudioContext = new AudioContext(), z.debug("Remote AudioContext state:", this.remoteAudioContext.state), this.remoteAudioContext.state === "suspended" && (z.debug("Resuming suspended AudioContext..."), this.remoteAudioContext.resume().then(() => {
2966
+ this.monitorStartTime = performance.now(), this.remoteAudioContext = new AudioContext(), z.debug("Remote AudioContext state:", this.remoteAudioContext.state), this.remoteAudioContext.state === "suspended" && (z.debug("Resuming suspended AudioContext..."), this.remoteAudioContext.resume().then(() => {
2956
2967
  z.debug("AudioContext resumed, state:", this.remoteAudioContext?.state);
2957
2968
  })), this.remoteSource = this.remoteAudioContext.createMediaStreamSource(
2958
2969
  this.remoteStream
@@ -2963,18 +2974,23 @@ class Ti {
2963
2974
  let i = !1;
2964
2975
  const s = () => {
2965
2976
  this.remoteAnalyser?.getByteFrequencyData(n);
2966
- const r = n.reduce((d, l) => d + l, 0) / n.length, o = r >= Ze;
2967
- if (Math.random() < 0.01 && z.debug("Remote audio volume:", r, "threshold:", Ze, "above:", o), o)
2968
- if (!i && this.thinkingStartTime !== null) {
2969
- const d = performance.now() - this.thinkingStartTime;
2970
- this.thinkingStartTime = null, this.updateAgentState({ state: "speaking", latencyMs: d });
2977
+ const a = n.reduce((l, d) => l + d, 0) / n.length, o = a >= this.volumeThreshold;
2978
+ if (Math.random() < 0.01 && z.debug("Remote audio volume:", a, "threshold:", this.volumeThreshold, "above:", o), o)
2979
+ if (i)
2980
+ this.updateAgentState({ state: "speaking" });
2981
+ else if (this.isFirstAgentSpeech && this.monitorStartTime !== null) {
2982
+ const l = Math.round(performance.now() - this.monitorStartTime);
2983
+ this.isFirstAgentSpeech = !1, this.thinkingStartTime = null, this.userSilenceStartTime = null, this.userSpeechStartTime = null, this.updateAgentState({ state: "speaking", greetingLatencyMs: l });
2984
+ } else if (this.userSilenceStartTime !== null) {
2985
+ const l = Math.round(performance.now() - this.userSilenceStartTime);
2986
+ this.thinkingStartTime = null, this.userSilenceStartTime = null, this.maxLatencyMs === void 0 || l < this.maxLatencyMs ? this.updateAgentState({ state: "speaking", userPerceivedLatencyMs: l }) : this.updateAgentState({ state: "speaking" });
2971
2987
  } else
2972
2988
  this.updateAgentState({ state: "speaking" });
2973
2989
  else
2974
2990
  this.thinkingStartTime === null && this.updateAgentState({ state: "listening" });
2975
2991
  i = o;
2976
2992
  };
2977
- this.remoteIntervalId = window.setInterval(s, Nt);
2993
+ this.remoteIntervalId = window.setInterval(s, Dt);
2978
2994
  }
2979
2995
  /**
2980
2996
  * Monitor local stream (user's microphone) for VAD
@@ -2990,53 +3006,49 @@ class Ti {
2990
3006
  ), this.localAnalyser = this.localAudioContext.createAnalyser(), this.localSource.connect(this.localAnalyser), this.localAnalyser.fftSize = 512;
2991
3007
  const e = new Uint8Array(this.localAnalyser.frequencyBinCount), n = () => {
2992
3008
  this.localAnalyser?.getByteFrequencyData(e);
2993
- const i = e.reduce((r, o) => r + o, 0) / e.length;
2994
- Math.random() < 0.02 && z.debug("Local audio volume:", i);
2995
- const s = i >= Ze;
2996
- if (s && !this.userIsSpeaking)
2997
- this.userIsSpeaking = !0, this.lastUserAudioTime = performance.now();
2998
- else if (s && this.userIsSpeaking)
2999
- this.lastUserAudioTime = performance.now();
3000
- else if (!s && this.userIsSpeaking && this.lastUserAudioTime !== null && performance.now() - this.lastUserAudioTime > Ei) {
3001
- this.userIsSpeaking = !1, this.thinkingStartTime = performance.now();
3002
- const o = (/* @__PURE__ */ new Date()).toISOString();
3003
- this.updateAgentState({ state: "thinking", thinkingStartedAt: o });
3009
+ const i = e.reduce((a, o) => a + o, 0) / e.length;
3010
+ if (Math.random() < 0.02 && z.debug("Local audio volume:", i), i >= this.volumeThreshold)
3011
+ this.userIsSpeaking || (this.userIsSpeaking = !0, this.userSpeechStartTime = performance.now(), this.userSilenceStartTime = null), this.lastUserAudioTime = performance.now();
3012
+ else if (this.userIsSpeaking && this.lastUserAudioTime !== null && (this.lastUserAudioTime - (this.userSpeechStartTime || this.lastUserAudioTime) >= this.minSpeechDurationMs && this.userSilenceStartTime === null && (this.userSilenceStartTime = this.lastUserAudioTime), performance.now() - this.lastUserAudioTime > this.silenceDurationMs)) {
3013
+ this.userIsSpeaking = !1, this.userSpeechStartTime = null, this.thinkingStartTime = performance.now();
3014
+ const l = (/* @__PURE__ */ new Date()).toISOString();
3015
+ this.updateAgentState({ state: "thinking", thinkingStartedAt: l });
3004
3016
  }
3005
3017
  };
3006
- this.localIntervalId = window.setInterval(n, Nt);
3018
+ this.localIntervalId = window.setInterval(n, Dt);
3007
3019
  }
3008
3020
  destroy() {
3009
3021
  this.stopAudioStreamMonitor();
3010
3022
  }
3011
3023
  }
3012
- function Ai(t) {
3024
+ function Ri(t) {
3013
3025
  if (!t || typeof t != "object")
3014
3026
  return !1;
3015
3027
  const e = t;
3016
3028
  return e.method === "ai_conversation" && typeof e.params == "object";
3017
3029
  }
3018
- function Ri(t) {
3030
+ function xi(t) {
3019
3031
  if (!t || typeof t != "object")
3020
3032
  return !1;
3021
3033
  const e = t;
3022
3034
  return e.params.type !== "response.text.delta" ? !1 : !!e.params.delta;
3023
3035
  }
3024
- function xi(t) {
3036
+ function Li(t) {
3025
3037
  if (!t || typeof t != "object")
3026
3038
  return !1;
3027
3039
  const e = t;
3028
3040
  return e.params.type !== "conversation.item.created" ? !1 : !!e.params.item.content;
3029
3041
  }
3030
3042
  function Oi(t) {
3031
- return Ri(t) ? {
3043
+ return xi(t) ? {
3032
3044
  id: `${t.params.item_id}-${Date.now()}`,
3033
3045
  role: "assistant",
3034
3046
  content: t.params.delta,
3035
3047
  timestamp: /* @__PURE__ */ new Date()
3036
3048
  } : null;
3037
3049
  }
3038
- function Li(t) {
3039
- if (!xi(t) || t.params.item.role !== "user" || t.params.item.status !== "completed")
3050
+ function Mi(t) {
3051
+ if (!Li(t) || t.params.item.role !== "user" || t.params.item.status !== "completed")
3040
3052
  return null;
3041
3053
  let e = "", n = [];
3042
3054
  return Array.isArray(t.params.item.content) ? (e = t.params.item.content.reduce((i, s) => (s.type === "text" && (i += s.text), i), ""), n = t.params.item.content.reduce((i, s) => (s.type === "image_url" && s.image_url.url && i.push({ type: "image", url: s.image_url.url }), i), [])) : e = t.params.item.content, {
@@ -3047,29 +3059,29 @@ function Li(t) {
3047
3059
  attachments: n
3048
3060
  };
3049
3061
  }
3050
- class Mi extends gt {
3062
+ class Pi extends ft {
3051
3063
  telnyxRTC;
3052
3064
  transcript = [];
3053
3065
  constructor(e) {
3054
- super(), this.telnyxRTC = e, this.telnyxRTC.on(O.SocketMessage, this.onSocketMessage);
3066
+ super(), this.telnyxRTC = e, this.telnyxRTC.on(L.SocketMessage, this.onSocketMessage);
3055
3067
  }
3056
3068
  onSocketMessage = (e) => {
3057
- if (Ai(e))
3069
+ if (Ri(e))
3058
3070
  switch (e.params.type) {
3059
3071
  case "response.text.delta": {
3060
3072
  const n = Oi(e);
3061
- n && (this.transcript.push(n), this.emit("transcript.item", n), $e.emit("conversation.agent.state", { state: "listening" }));
3073
+ n && (this.transcript.push(n), this.emit("transcript.item", n), Fe.emit("conversation.agent.state", { state: "listening" }));
3062
3074
  return;
3063
3075
  }
3064
3076
  case "conversation.item.created": {
3065
- const n = Li(e);
3077
+ const n = Mi(e);
3066
3078
  n && (this.transcript.push(n), this.emit("transcript.item", n));
3067
3079
  return;
3068
3080
  }
3069
3081
  }
3070
3082
  };
3071
3083
  }
3072
- class jt extends gt {
3084
+ class Nt extends ft {
3073
3085
  telnyxRTC;
3074
3086
  transcription;
3075
3087
  agentId;
@@ -3078,7 +3090,7 @@ class jt extends gt {
3078
3090
  audioStreamMonitor;
3079
3091
  activeCall;
3080
3092
  constructor(e) {
3081
- super(), this.agentId = e.agentId, this.versionId = e.versionId || "main", this.debug = e.debug || !1, this.activeCall = null, z.setLevel(this.debug ? "debug" : "info"), this.telnyxRTC = new vi({
3093
+ super(), this.agentId = e.agentId, this.versionId = e.versionId || "main", this.debug = e.debug || !1, this.activeCall = null, z.setLevel(this.debug ? "debug" : "info"), this.telnyxRTC = new gi({
3082
3094
  // @ts-expect-error hidden argument
3083
3095
  environment: e.environment || "production",
3084
3096
  anonymous_login: {
@@ -3088,10 +3100,10 @@ class jt extends gt {
3088
3100
  },
3089
3101
  debug: e.debug || !1,
3090
3102
  trickleIce: e.trickleIce
3091
- }), this.telnyxRTC.on(O.Ready, this.onClientReady), this.telnyxRTC.on(O.Error, this.onClientOrSocketError), this.telnyxRTC.on(O.SocketError, this.onClientOrSocketError), this.telnyxRTC.on(O.Notification, this.onNotification), this.transcription = new Mi(this.telnyxRTC), this.transcription.addListener("transcript.item", this.onTranscriptItem), $e.addListener(
3103
+ }), this.telnyxRTC.on(L.Ready, this.onClientReady), this.telnyxRTC.on(L.Error, this.onClientOrSocketError), this.telnyxRTC.on(L.SocketError, this.onClientOrSocketError), this.telnyxRTC.on(L.Notification, this.onNotification), this.transcription = new Pi(this.telnyxRTC), this.transcription.addListener("transcript.item", this.onTranscriptItem), Fe.addListener(
3092
3104
  "conversation.agent.state",
3093
3105
  this.onAgentStateChange
3094
- ), this.audioStreamMonitor = new Ti();
3106
+ ), this.audioStreamMonitor = new Ai(e.vad);
3095
3107
  }
3096
3108
  /**
3097
3109
  * Connects to the Telnyx WebRTC service and establishes a session with the AI agent.
@@ -3106,7 +3118,7 @@ class jt extends gt {
3106
3118
  * Emits an 'agent.disconnected' event before completing cleanup.
3107
3119
  */
3108
3120
  async disconnect() {
3109
- this.audioStreamMonitor.destroy(), this.telnyxRTC.disconnect(), this.telnyxRTC.off(O.Ready, this.onClientReady), this.telnyxRTC.off(O.Error, this.onClientOrSocketError), this.telnyxRTC.off(O.SocketError, this.onClientOrSocketError), this.telnyxRTC.off(O.Notification, this.onNotification), this.emit("agent.disconnected"), this.transcription.removeAllListeners(), $e.removeAllListeners(), this.removeAllListeners();
3121
+ this.audioStreamMonitor.destroy(), this.telnyxRTC.disconnect(), this.telnyxRTC.off(L.Ready, this.onClientReady), this.telnyxRTC.off(L.Error, this.onClientOrSocketError), this.telnyxRTC.off(L.SocketError, this.onClientOrSocketError), this.telnyxRTC.off(L.Notification, this.onNotification), this.emit("agent.disconnected"), this.transcription.removeAllListeners(), Fe.removeAllListeners(), this.removeAllListeners();
3110
3122
  }
3111
3123
  /**
3112
3124
  * Sends a text message to the AI agent during an active conversation.
@@ -3170,21 +3182,21 @@ class jt extends gt {
3170
3182
  (h) => h.mimeType.toLowerCase().includes("opus")
3171
3183
  ), {
3172
3184
  customHeaders: s,
3173
- audio: r,
3185
+ audio: a,
3174
3186
  ...o
3175
- } = e || {}, d = s ? [...s] : [];
3176
- this.versionId && d.push({
3187
+ } = e || {}, l = s ? [...s] : [];
3188
+ this.versionId && l.push({
3177
3189
  name: "X-AI-Assistant-Version-ID",
3178
3190
  value: this.versionId
3179
3191
  });
3180
- const l = this.telnyxRTC.newCall({
3192
+ const d = this.telnyxRTC.newCall({
3181
3193
  destinationNumber: "xxx",
3182
3194
  ...o,
3183
- audio: r ?? !0,
3195
+ audio: a ?? !0,
3184
3196
  preferred_codecs: [i],
3185
- customHeaders: d.length > 0 ? d : void 0
3197
+ customHeaders: l.length > 0 ? l : void 0
3186
3198
  });
3187
- this.emit("conversation.update", { call: l, type: "callUpdate" });
3199
+ this.emit("conversation.update", { call: d, type: "callUpdate" });
3188
3200
  }
3189
3201
  /**
3190
3202
  * Ends the current active conversation with the AI agent.
@@ -3222,31 +3234,31 @@ class jt extends gt {
3222
3234
  }
3223
3235
  var Me = { exports: {} }, _e = {};
3224
3236
  var Ut;
3225
- function Pi() {
3237
+ function Di() {
3226
3238
  if (Ut) return _e;
3227
3239
  Ut = 1;
3228
3240
  var t = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
3229
- function n(i, s, r) {
3241
+ function n(i, s, a) {
3230
3242
  var o = null;
3231
- if (r !== void 0 && (o = "" + r), s.key !== void 0 && (o = "" + s.key), "key" in s) {
3232
- r = {};
3233
- for (var d in s)
3234
- d !== "key" && (r[d] = s[d]);
3235
- } else r = s;
3236
- return s = r.ref, {
3243
+ if (a !== void 0 && (o = "" + a), s.key !== void 0 && (o = "" + s.key), "key" in s) {
3244
+ a = {};
3245
+ for (var l in s)
3246
+ l !== "key" && (a[l] = s[l]);
3247
+ } else a = s;
3248
+ return s = a.ref, {
3237
3249
  $$typeof: t,
3238
3250
  type: i,
3239
3251
  key: o,
3240
3252
  ref: s !== void 0 ? s : null,
3241
- props: r
3253
+ props: a
3242
3254
  };
3243
3255
  }
3244
3256
  return _e.Fragment = e, _e.jsx = n, _e.jsxs = n, _e;
3245
3257
  }
3246
3258
  var Se = {};
3247
- var $t;
3248
- function Di() {
3249
- return $t || ($t = 1, process.env.NODE_ENV !== "production" && (function() {
3259
+ var jt;
3260
+ function Ni() {
3261
+ return jt || (jt = 1, process.env.NODE_ENV !== "production" && (function() {
3250
3262
  function t(m) {
3251
3263
  if (m == null) return null;
3252
3264
  if (typeof m == "function")
@@ -3281,7 +3293,7 @@ function Di() {
3281
3293
  return m = m.displayName, m || (m = M.displayName || M.name || "", m = m !== "" ? "ForwardRef(" + m + ")" : "ForwardRef"), m;
3282
3294
  case x:
3283
3295
  return M = m.displayName || null, M !== null ? M : t(m.type) || "Memo";
3284
- case a:
3296
+ case r:
3285
3297
  M = m._payload, m = m._init;
3286
3298
  try {
3287
3299
  return t(m(M));
@@ -3302,8 +3314,8 @@ function Di() {
3302
3314
  }
3303
3315
  if (M) {
3304
3316
  M = console;
3305
- var j = M.error, V = typeof Symbol == "function" && Symbol.toStringTag && m[Symbol.toStringTag] || m.constructor.name || "Object";
3306
- return j.call(
3317
+ var U = M.error, V = typeof Symbol == "function" && Symbol.toStringTag && m[Symbol.toStringTag] || m.constructor.name || "Object";
3318
+ return U.call(
3307
3319
  M,
3308
3320
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
3309
3321
  V
@@ -3312,7 +3324,7 @@ function Di() {
3312
3324
  }
3313
3325
  function i(m) {
3314
3326
  if (m === p) return "<>";
3315
- if (typeof m == "object" && m !== null && m.$$typeof === a)
3327
+ if (typeof m == "object" && m !== null && m.$$typeof === r)
3316
3328
  return "<...>";
3317
3329
  try {
3318
3330
  var M = t(m);
@@ -3325,7 +3337,7 @@ function Di() {
3325
3337
  var m = g.A;
3326
3338
  return m === null ? null : m.getOwner();
3327
3339
  }
3328
- function r() {
3340
+ function a() {
3329
3341
  return Error("react-stack-top-frame");
3330
3342
  }
3331
3343
  function o(m) {
@@ -3335,35 +3347,35 @@ function Di() {
3335
3347
  }
3336
3348
  return m.key !== void 0;
3337
3349
  }
3338
- function d(m, M) {
3339
- function j() {
3350
+ function l(m, M) {
3351
+ function U() {
3340
3352
  R || (R = !0, console.error(
3341
3353
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
3342
3354
  M
3343
3355
  ));
3344
3356
  }
3345
- j.isReactWarning = !0, Object.defineProperty(m, "key", {
3346
- get: j,
3357
+ U.isReactWarning = !0, Object.defineProperty(m, "key", {
3358
+ get: U,
3347
3359
  configurable: !0
3348
3360
  });
3349
3361
  }
3350
- function l() {
3362
+ function d() {
3351
3363
  var m = t(this.type);
3352
- return U[m] || (U[m] = !0, console.error(
3364
+ return j[m] || (j[m] = !0, console.error(
3353
3365
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
3354
3366
  )), m = this.props.ref, m !== void 0 ? m : null;
3355
3367
  }
3356
- function h(m, M, j, V, Y, Q) {
3357
- var W = j.ref;
3368
+ function h(m, M, U, V, Y, Q) {
3369
+ var W = U.ref;
3358
3370
  return m = {
3359
3371
  $$typeof: C,
3360
3372
  type: m,
3361
3373
  key: M,
3362
- props: j,
3374
+ props: U,
3363
3375
  _owner: V
3364
3376
  }, (W !== void 0 ? W : null) !== null ? Object.defineProperty(m, "ref", {
3365
3377
  enumerable: !1,
3366
- get: l
3378
+ get: d
3367
3379
  }) : Object.defineProperty(m, "ref", { enumerable: !1, value: null }), m._store = {}, Object.defineProperty(m._store, "validated", {
3368
3380
  configurable: !1,
3369
3381
  enumerable: !1,
@@ -3386,7 +3398,7 @@ function Di() {
3386
3398
  value: Q
3387
3399
  }), Object.freeze && (Object.freeze(m.props), Object.freeze(m)), m;
3388
3400
  }
3389
- function f(m, M, j, V, Y, Q) {
3401
+ function f(m, M, U, V, Y, Q) {
3390
3402
  var W = M.children;
3391
3403
  if (W !== void 0)
3392
3404
  if (V)
@@ -3401,8 +3413,8 @@ function Di() {
3401
3413
  else v(W);
3402
3414
  if (b.call(M, "key")) {
3403
3415
  W = t(m);
3404
- var re = Object.keys(M).filter(function(En) {
3405
- return En !== "key";
3416
+ var re = Object.keys(M).filter(function(In) {
3417
+ return In !== "key";
3406
3418
  });
3407
3419
  V = 0 < re.length ? "{key: someKey, " + re.join(": ..., ") + ": ...}" : "{key: someKey}", G[W + V] || (re = 0 < re.length ? "{" + re.join(": ..., ") + ": ...}" : "{}", console.error(
3408
3420
  `A props object containing a "key" prop is being spread into JSX:
@@ -3417,30 +3429,30 @@ React keys must be passed directly to JSX without using spread:
3417
3429
  W
3418
3430
  ), G[W + V] = !0);
3419
3431
  }
3420
- if (W = null, j !== void 0 && (n(j), W = "" + j), o(M) && (n(M.key), W = "" + M.key), "key" in M) {
3421
- j = {};
3432
+ if (W = null, U !== void 0 && (n(U), W = "" + U), o(M) && (n(M.key), W = "" + M.key), "key" in M) {
3433
+ U = {};
3422
3434
  for (var ze in M)
3423
- ze !== "key" && (j[ze] = M[ze]);
3424
- } else j = M;
3425
- return W && d(
3426
- j,
3435
+ ze !== "key" && (U[ze] = M[ze]);
3436
+ } else U = M;
3437
+ return W && l(
3438
+ U,
3427
3439
  typeof m == "function" ? m.displayName || m.name || "Unknown" : m
3428
3440
  ), h(
3429
3441
  m,
3430
3442
  W,
3431
- j,
3443
+ U,
3432
3444
  s(),
3433
3445
  Y,
3434
3446
  Q
3435
3447
  );
3436
3448
  }
3437
3449
  function v(m) {
3438
- _(m) ? m._store && (m._store.validated = 1) : typeof m == "object" && m !== null && m.$$typeof === a && (m._payload.status === "fulfilled" ? _(m._payload.value) && m._payload.value._store && (m._payload.value._store.validated = 1) : m._store && (m._store.validated = 1));
3450
+ _(m) ? m._store && (m._store.validated = 1) : typeof m == "object" && m !== null && m.$$typeof === r && (m._payload.status === "fulfilled" ? _(m._payload.value) && m._payload.value._store && (m._payload.value._store.validated = 1) : m._store && (m._store.validated = 1));
3439
3451
  }
3440
3452
  function _(m) {
3441
3453
  return typeof m == "object" && m !== null && m.$$typeof === C;
3442
3454
  }
3443
- var w = ht, C = Symbol.for("react.transitional.element"), k = Symbol.for("react.portal"), p = Symbol.for("react.fragment"), S = Symbol.for("react.strict_mode"), A = Symbol.for("react.profiler"), E = Symbol.for("react.consumer"), P = Symbol.for("react.context"), D = Symbol.for("react.forward_ref"), q = Symbol.for("react.suspense"), B = Symbol.for("react.suspense_list"), x = Symbol.for("react.memo"), a = Symbol.for("react.lazy"), c = Symbol.for("react.activity"), u = Symbol.for("react.client.reference"), g = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, b = Object.prototype.hasOwnProperty, T = Array.isArray, I = console.createTask ? console.createTask : function() {
3455
+ var w = ut, C = Symbol.for("react.transitional.element"), k = Symbol.for("react.portal"), p = Symbol.for("react.fragment"), S = Symbol.for("react.strict_mode"), A = Symbol.for("react.profiler"), E = Symbol.for("react.consumer"), P = Symbol.for("react.context"), D = Symbol.for("react.forward_ref"), q = Symbol.for("react.suspense"), B = Symbol.for("react.suspense_list"), x = Symbol.for("react.memo"), r = Symbol.for("react.lazy"), c = Symbol.for("react.activity"), u = Symbol.for("react.client.reference"), g = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, b = Object.prototype.hasOwnProperty, T = Array.isArray, I = console.createTask ? console.createTask : function() {
3444
3456
  return null;
3445
3457
  };
3446
3458
  w = {
@@ -3448,26 +3460,26 @@ React keys must be passed directly to JSX without using spread:
3448
3460
  return m();
3449
3461
  }
3450
3462
  };
3451
- var R, U = {}, ee = w.react_stack_bottom_frame.bind(
3463
+ var R, j = {}, ee = w.react_stack_bottom_frame.bind(
3452
3464
  w,
3453
- r
3454
- )(), ne = I(i(r)), G = {};
3455
- Se.Fragment = p, Se.jsx = function(m, M, j) {
3465
+ a
3466
+ )(), ne = I(i(a)), G = {};
3467
+ Se.Fragment = p, Se.jsx = function(m, M, U) {
3456
3468
  var V = 1e4 > g.recentlyCreatedOwnerStacks++;
3457
3469
  return f(
3458
3470
  m,
3459
3471
  M,
3460
- j,
3472
+ U,
3461
3473
  !1,
3462
3474
  V ? Error("react-stack-top-frame") : ee,
3463
3475
  V ? I(i(m)) : ne
3464
3476
  );
3465
- }, Se.jsxs = function(m, M, j) {
3477
+ }, Se.jsxs = function(m, M, U) {
3466
3478
  var V = 1e4 > g.recentlyCreatedOwnerStacks++;
3467
3479
  return f(
3468
3480
  m,
3469
3481
  M,
3470
- j,
3482
+ U,
3471
3483
  !0,
3472
3484
  V ? Error("react-stack-top-frame") : ee,
3473
3485
  V ? I(i(m)) : ne
@@ -3476,21 +3488,21 @@ React keys must be passed directly to JSX without using spread:
3476
3488
  })()), Se;
3477
3489
  }
3478
3490
  var Ft;
3479
- function Ni() {
3480
- return Ft || (Ft = 1, process.env.NODE_ENV === "production" ? Me.exports = Pi() : Me.exports = Di()), Me.exports;
3491
+ function Ui() {
3492
+ return Ft || (Ft = 1, process.env.NODE_ENV === "production" ? Me.exports = Di() : Me.exports = Ni()), Me.exports;
3481
3493
  }
3482
- var we = Ni();
3494
+ var we = Ui();
3483
3495
  const ce = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
3484
- function hn(t) {
3496
+ function un(t) {
3485
3497
  return "init" in t;
3486
3498
  }
3487
- function at(t) {
3499
+ function rt(t) {
3488
3500
  return !!t.write;
3489
3501
  }
3490
- function Bt(t) {
3502
+ function $t(t) {
3491
3503
  return "v" in t || "e" in t;
3492
3504
  }
3493
- function Fe(t) {
3505
+ function $e(t) {
3494
3506
  if ("e" in t)
3495
3507
  throw t.e;
3496
3508
  if ((ce ? "production" : void 0) !== "production" && !("v" in t))
@@ -3498,7 +3510,7 @@ function Fe(t) {
3498
3510
  return t.v;
3499
3511
  }
3500
3512
  const Be = /* @__PURE__ */ new WeakMap();
3501
- function pn(t) {
3513
+ function hn(t) {
3502
3514
  var e;
3503
3515
  return Ve(t) && !!((e = Be.get(t)) != null && e[0]);
3504
3516
  }
@@ -3506,7 +3518,7 @@ function ji(t) {
3506
3518
  const e = Be.get(t);
3507
3519
  e?.[0] && (e[0] = !1, e[1].forEach((n) => n()));
3508
3520
  }
3509
- function ct(t, e) {
3521
+ function at(t, e) {
3510
3522
  let n = Be.get(t);
3511
3523
  if (!n) {
3512
3524
  n = [!0, /* @__PURE__ */ new Set()], Be.set(t, n);
@@ -3520,45 +3532,45 @@ function ct(t, e) {
3520
3532
  function Ve(t) {
3521
3533
  return typeof t?.then == "function";
3522
3534
  }
3523
- function fn(t, e, n) {
3535
+ function pn(t, e, n) {
3524
3536
  if (!n.p.has(t)) {
3525
3537
  n.p.add(t);
3526
3538
  const i = () => n.p.delete(t);
3527
3539
  e.then(i, i);
3528
3540
  }
3529
3541
  }
3530
- function gn(t, e, n) {
3542
+ function fn(t, e, n) {
3531
3543
  var i;
3532
3544
  const s = /* @__PURE__ */ new Set();
3533
- for (const r of ((i = n.get(t)) == null ? void 0 : i.t) || [])
3534
- s.add(r);
3535
- for (const r of e.p)
3536
- s.add(r);
3545
+ for (const a of ((i = n.get(t)) == null ? void 0 : i.t) || [])
3546
+ s.add(a);
3547
+ for (const a of e.p)
3548
+ s.add(a);
3537
3549
  return s;
3538
3550
  }
3539
- const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi = (t, e) => {
3551
+ const Fi = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Bi = (t, e) => {
3540
3552
  if (e.INTERNAL_onInit)
3541
3553
  return e.INTERNAL_onInit(t);
3542
3554
  if (e.unstable_onInit)
3543
3555
  return console.warn(
3544
3556
  "[DEPRECATED] atom.unstable_onInit is renamed to atom.INTERNAL_onInit."
3545
3557
  ), e.unstable_onInit(t);
3546
- }, Bi = (t, e, n) => {
3558
+ }, Vi = (t, e, n) => {
3547
3559
  var i;
3548
3560
  return (i = e.onMount) == null ? void 0 : i.call(e, n);
3549
- }, Vi = (t, e) => {
3561
+ }, Gi = (t, e) => {
3550
3562
  var n;
3551
- const i = X(t), s = i[0], r = i[6], o = i[9];
3563
+ const i = X(t), s = i[0], a = i[6], o = i[9];
3552
3564
  if ((ce ? "production" : void 0) !== "production" && !e)
3553
3565
  throw new Error("Atom is undefined or null");
3554
- let d = s.get(e);
3555
- return d || (d = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, s.set(e, d), (n = r.i) == null || n.call(r, e), o?.(t, e)), d;
3556
- }, Gi = (t) => {
3557
- const e = X(t), n = e[1], i = e[3], s = e[4], r = e[5], o = e[6], d = e[13], l = [], h = (f) => {
3566
+ let l = s.get(e);
3567
+ return l || (l = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, s.set(e, l), (n = a.i) == null || n.call(a, e), o?.(t, e)), l;
3568
+ }, Wi = (t) => {
3569
+ const e = X(t), n = e[1], i = e[3], s = e[4], a = e[5], o = e[6], l = e[13], d = [], h = (f) => {
3558
3570
  try {
3559
3571
  f();
3560
3572
  } catch (v) {
3561
- l.push(v);
3573
+ d.push(v);
3562
3574
  }
3563
3575
  };
3564
3576
  do {
@@ -3567,49 +3579,49 @@ const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi
3567
3579
  i.forEach((_) => {
3568
3580
  var w;
3569
3581
  return (w = n.get(_)) == null ? void 0 : w.l.forEach(v);
3570
- }), i.clear(), r.forEach(v), r.clear(), s.forEach(v), s.clear(), f.forEach(h), i.size && d(t);
3571
- } while (i.size || r.size || s.size);
3572
- if (l.length)
3573
- throw new AggregateError(l);
3574
- }, Wi = (t) => {
3575
- const e = X(t), n = e[1], i = e[2], s = e[3], r = e[11], o = e[14], d = e[17], l = [], h = /* @__PURE__ */ new WeakSet(), f = /* @__PURE__ */ new WeakSet(), v = Array.from(s);
3582
+ }), i.clear(), a.forEach(v), a.clear(), s.forEach(v), s.clear(), f.forEach(h), i.size && l(t);
3583
+ } while (i.size || a.size || s.size);
3584
+ if (d.length)
3585
+ throw new AggregateError(d);
3586
+ }, Hi = (t) => {
3587
+ const e = X(t), n = e[1], i = e[2], s = e[3], a = e[11], o = e[14], l = e[17], d = [], h = /* @__PURE__ */ new WeakSet(), f = /* @__PURE__ */ new WeakSet(), v = Array.from(s);
3576
3588
  for (; v.length; ) {
3577
- const _ = v[v.length - 1], w = r(t, _);
3589
+ const _ = v[v.length - 1], w = a(t, _);
3578
3590
  if (f.has(_)) {
3579
3591
  v.pop();
3580
3592
  continue;
3581
3593
  }
3582
3594
  if (h.has(_)) {
3583
3595
  if (i.get(_) === w.n)
3584
- l.push([_, w]);
3596
+ d.push([_, w]);
3585
3597
  else if ((ce ? "production" : void 0) !== "production" && i.has(_))
3586
3598
  throw new Error("[Bug] invalidated atom exists");
3587
3599
  f.add(_), v.pop();
3588
3600
  continue;
3589
3601
  }
3590
3602
  h.add(_);
3591
- for (const C of gn(_, w, n))
3603
+ for (const C of fn(_, w, n))
3592
3604
  h.has(C) || v.push(C);
3593
3605
  }
3594
- for (let _ = l.length - 1; _ >= 0; --_) {
3595
- const [w, C] = l[_];
3606
+ for (let _ = d.length - 1; _ >= 0; --_) {
3607
+ const [w, C] = d[_];
3596
3608
  let k = !1;
3597
3609
  for (const p of C.d.keys())
3598
3610
  if (p !== w && s.has(p)) {
3599
3611
  k = !0;
3600
3612
  break;
3601
3613
  }
3602
- k && (o(t, w), d(t, w)), i.delete(w);
3614
+ k && (o(t, w), l(t, w)), i.delete(w);
3603
3615
  }
3604
- }, dt = /* @__PURE__ */ new WeakSet(), Hi = (t, e) => {
3616
+ }, ct = /* @__PURE__ */ new WeakSet(), qi = (t, e) => {
3605
3617
  var n, i;
3606
- const s = X(t), r = s[1], o = s[2], d = s[3], l = s[6], h = s[7], f = s[11], v = s[12], _ = s[13], w = s[14], C = s[16], k = s[17], p = f(t, e);
3607
- if (Bt(p)) {
3608
- if (r.has(e) && o.get(e) !== p.n)
3618
+ const s = X(t), a = s[1], o = s[2], l = s[3], d = s[6], h = s[7], f = s[11], v = s[12], _ = s[13], w = s[14], C = s[16], k = s[17], p = f(t, e);
3619
+ if ($t(p)) {
3620
+ if (a.has(e) && o.get(e) !== p.n)
3609
3621
  return p;
3610
3622
  let x = !1;
3611
- for (const [a, c] of p.d)
3612
- if (w(t, a).n !== c) {
3623
+ for (const [r, c] of p.d)
3624
+ if (w(t, r).n !== c) {
3613
3625
  x = !0;
3614
3626
  break;
3615
3627
  }
@@ -3619,24 +3631,24 @@ const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi
3619
3631
  p.d.clear();
3620
3632
  let S = !0;
3621
3633
  function A() {
3622
- r.has(e) && (k(t, e), _(t), v(t));
3634
+ a.has(e) && (k(t, e), _(t), v(t));
3623
3635
  }
3624
3636
  function E(x) {
3625
- var a;
3637
+ var r;
3626
3638
  if (x === e) {
3627
3639
  const u = f(t, x);
3628
- if (!Bt(u))
3629
- if (hn(x))
3640
+ if (!$t(u))
3641
+ if (un(x))
3630
3642
  Ge(t, x, x.init);
3631
3643
  else
3632
3644
  throw new Error("no atom init");
3633
- return Fe(u);
3645
+ return $e(u);
3634
3646
  }
3635
3647
  const c = w(t, x);
3636
3648
  try {
3637
- return Fe(c);
3649
+ return $e(c);
3638
3650
  } finally {
3639
- p.d.set(x, c.n), pn(p.v) && fn(e, p.v, c), r.has(e) && ((a = r.get(x)) == null || a.t.add(e)), S || A();
3651
+ p.d.set(x, c.n), hn(p.v) && pn(e, p.v, c), a.has(e) && ((r = a.get(x)) == null || r.t.add(e)), S || A();
3640
3652
  }
3641
3653
  }
3642
3654
  let P, D;
@@ -3645,7 +3657,7 @@ const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi
3645
3657
  return P || (P = new AbortController()), P.signal;
3646
3658
  },
3647
3659
  get setSelf() {
3648
- return (ce ? "production" : void 0) !== "production" && !at(e) && console.warn("setSelf function cannot be used with read-only atom"), !D && at(e) && (D = (...x) => {
3660
+ return (ce ? "production" : void 0) !== "production" && !rt(e) && console.warn("setSelf function cannot be used with read-only atom"), !D && rt(e) && (D = (...x) => {
3649
3661
  if ((ce ? "production" : void 0) !== "production" && S && console.warn("setSelf function cannot be called in sync"), !S)
3650
3662
  try {
3651
3663
  return C(t, e, ...x);
@@ -3656,43 +3668,43 @@ const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi
3656
3668
  }
3657
3669
  }, B = p.n;
3658
3670
  try {
3659
- (ce ? "production" : void 0) !== "production" && dt.delete(t);
3671
+ (ce ? "production" : void 0) !== "production" && ct.delete(t);
3660
3672
  const x = h(t, e, E, q);
3661
- return (ce ? "production" : void 0) !== "production" && dt.has(t) && console.warn(
3673
+ return (ce ? "production" : void 0) !== "production" && ct.has(t) && console.warn(
3662
3674
  "Detected store mutation during atom read. This is not supported."
3663
- ), Ge(t, e, x), Ve(x) && (ct(x, () => P?.abort()), x.then(A, A)), (n = l.r) == null || n.call(l, e), p;
3675
+ ), Ge(t, e, x), Ve(x) && (at(x, () => P?.abort()), x.then(A, A)), (n = d.r) == null || n.call(d, e), p;
3664
3676
  } catch (x) {
3665
3677
  return delete p.v, p.e = x, ++p.n, p;
3666
3678
  } finally {
3667
- S = !1, B !== p.n && o.get(e) === B && (o.set(e, p.n), d.add(e), (i = l.c) == null || i.call(l, e));
3679
+ S = !1, B !== p.n && o.get(e) === B && (o.set(e, p.n), l.add(e), (i = d.c) == null || i.call(d, e));
3668
3680
  }
3669
- }, qi = (t, e) => {
3670
- const n = X(t), i = n[1], s = n[2], r = n[11], o = [e];
3681
+ }, Ji = (t, e) => {
3682
+ const n = X(t), i = n[1], s = n[2], a = n[11], o = [e];
3671
3683
  for (; o.length; ) {
3672
- const d = o.pop(), l = r(t, d);
3673
- for (const h of gn(d, l, i)) {
3674
- const f = r(t, h);
3684
+ const l = o.pop(), d = a(t, l);
3685
+ for (const h of fn(l, d, i)) {
3686
+ const f = a(t, h);
3675
3687
  s.set(h, f.n), o.push(h);
3676
3688
  }
3677
3689
  }
3678
- }, vn = (t, e, ...n) => {
3679
- const i = X(t), s = i[3], r = i[6], o = i[8], d = i[11], l = i[12], h = i[13], f = i[14], v = i[15], _ = i[17];
3690
+ }, gn = (t, e, ...n) => {
3691
+ const i = X(t), s = i[3], a = i[6], o = i[8], l = i[11], d = i[12], h = i[13], f = i[14], v = i[15], _ = i[17];
3680
3692
  let w = !0;
3681
- const C = (p) => Fe(f(t, p)), k = (p, ...S) => {
3693
+ const C = (p) => $e(f(t, p)), k = (p, ...S) => {
3682
3694
  var A;
3683
- const E = d(t, p);
3695
+ const E = l(t, p);
3684
3696
  try {
3685
3697
  if (p === e) {
3686
- if (!hn(p))
3698
+ if (!un(p))
3687
3699
  throw new Error("atom not writable");
3688
- (ce ? "production" : void 0) !== "production" && dt.add(t);
3700
+ (ce ? "production" : void 0) !== "production" && ct.add(t);
3689
3701
  const P = E.n, D = S[0];
3690
- Ge(t, p, D), _(t, p), P !== E.n && (s.add(p), v(t, p), (A = r.c) == null || A.call(r, p));
3702
+ Ge(t, p, D), _(t, p), P !== E.n && (s.add(p), v(t, p), (A = a.c) == null || A.call(a, p));
3691
3703
  return;
3692
3704
  } else
3693
- return vn(t, p, ...S);
3705
+ return gn(t, p, ...S);
3694
3706
  } finally {
3695
- w || (h(t), l(t));
3707
+ w || (h(t), d(t));
3696
3708
  }
3697
3709
  };
3698
3710
  try {
@@ -3700,14 +3712,14 @@ const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi
3700
3712
  } finally {
3701
3713
  w = !1;
3702
3714
  }
3703
- }, Ji = (t, e) => {
3715
+ }, Yi = (t, e) => {
3704
3716
  var n;
3705
- const i = X(t), s = i[1], r = i[3], o = i[6], d = i[11], l = i[15], h = i[18], f = i[19], v = d(t, e), _ = s.get(e);
3706
- if (_ && !pn(v.v)) {
3717
+ const i = X(t), s = i[1], a = i[3], o = i[6], l = i[11], d = i[15], h = i[18], f = i[19], v = l(t, e), _ = s.get(e);
3718
+ if (_ && !hn(v.v)) {
3707
3719
  for (const [w, C] of v.d)
3708
3720
  if (!_.d.has(w)) {
3709
- const k = d(t, w);
3710
- h(t, w).t.add(e), _.d.add(w), C !== k.n && (r.add(w), l(t, w), (n = o.c) == null || n.call(o, w));
3721
+ const k = l(t, w);
3722
+ h(t, w).t.add(e), _.d.add(w), C !== k.n && (a.add(w), d(t, w), (n = o.c) == null || n.call(o, w));
3711
3723
  }
3712
3724
  for (const w of _.d)
3713
3725
  if (!v.d.has(w)) {
@@ -3716,19 +3728,19 @@ const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi
3716
3728
  C?.t.delete(e);
3717
3729
  }
3718
3730
  }
3719
- }, mn = (t, e) => {
3731
+ }, vn = (t, e) => {
3720
3732
  var n;
3721
- const i = X(t), s = i[1], r = i[4], o = i[6], d = i[10], l = i[11], h = i[12], f = i[13], v = i[14], _ = i[16], w = l(t, e);
3733
+ const i = X(t), s = i[1], a = i[4], o = i[6], l = i[10], d = i[11], h = i[12], f = i[13], v = i[14], _ = i[16], w = d(t, e);
3722
3734
  let C = s.get(e);
3723
3735
  if (!C) {
3724
3736
  v(t, e);
3725
3737
  for (const k of w.d.keys())
3726
- mn(t, k).t.add(e);
3738
+ vn(t, k).t.add(e);
3727
3739
  if (C = {
3728
3740
  l: /* @__PURE__ */ new Set(),
3729
3741
  d: new Set(w.d.keys()),
3730
3742
  t: /* @__PURE__ */ new Set()
3731
- }, s.set(e, C), at(e)) {
3743
+ }, s.set(e, C), rt(e)) {
3732
3744
  const k = () => {
3733
3745
  let p = !0;
3734
3746
  const S = (...A) => {
@@ -3739,7 +3751,7 @@ const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi
3739
3751
  }
3740
3752
  };
3741
3753
  try {
3742
- const A = d(t, e, S);
3754
+ const A = l(t, e, S);
3743
3755
  A && (C.u = () => {
3744
3756
  p = !0;
3745
3757
  try {
@@ -3752,79 +3764,79 @@ const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi
3752
3764
  p = !1;
3753
3765
  }
3754
3766
  };
3755
- r.add(k);
3767
+ a.add(k);
3756
3768
  }
3757
3769
  (n = o.m) == null || n.call(o, e);
3758
3770
  }
3759
3771
  return C;
3760
- }, Yi = (t, e) => {
3772
+ }, zi = (t, e) => {
3761
3773
  var n, i;
3762
- const s = X(t), r = s[1], o = s[5], d = s[6], l = s[11], h = s[19], f = l(t, e);
3763
- let v = r.get(e);
3774
+ const s = X(t), a = s[1], o = s[5], l = s[6], d = s[11], h = s[19], f = d(t, e);
3775
+ let v = a.get(e);
3764
3776
  if (!v || v.l.size)
3765
3777
  return v;
3766
3778
  let _ = !1;
3767
3779
  for (const w of v.t)
3768
- if ((n = r.get(w)) != null && n.d.has(e)) {
3780
+ if ((n = a.get(w)) != null && n.d.has(e)) {
3769
3781
  _ = !0;
3770
3782
  break;
3771
3783
  }
3772
3784
  if (!_) {
3773
- v.u && o.add(v.u), v = void 0, r.delete(e);
3785
+ v.u && o.add(v.u), v = void 0, a.delete(e);
3774
3786
  for (const w of f.d.keys()) {
3775
3787
  const C = h(t, w);
3776
3788
  C?.t.delete(e);
3777
3789
  }
3778
- (i = d.u) == null || i.call(d, e);
3790
+ (i = l.u) == null || i.call(l, e);
3779
3791
  return;
3780
3792
  }
3781
3793
  return v;
3782
3794
  }, Ge = (t, e, n) => {
3783
- const i = X(t)[11], s = i(t, e), r = "v" in s, o = s.v;
3795
+ const i = X(t)[11], s = i(t, e), a = "v" in s, o = s.v;
3784
3796
  if (Ve(n))
3785
- for (const d of s.d.keys())
3786
- fn(
3797
+ for (const l of s.d.keys())
3798
+ pn(
3787
3799
  e,
3788
3800
  n,
3789
- i(t, d)
3801
+ i(t, l)
3790
3802
  );
3791
- s.v = n, delete s.e, (!r || !Object.is(o, s.v)) && (++s.n, Ve(o) && ji(o));
3792
- }, zi = (t, e) => {
3803
+ s.v = n, delete s.e, (!a || !Object.is(o, s.v)) && (++s.n, Ve(o) && ji(o));
3804
+ }, Ki = (t, e) => {
3793
3805
  const n = X(t)[14];
3794
- return Fe(n(t, e));
3795
- }, Ki = (t, e, ...n) => {
3796
- const i = X(t), s = i[12], r = i[13], o = i[16];
3806
+ return $e(n(t, e));
3807
+ }, Qi = (t, e, ...n) => {
3808
+ const i = X(t), s = i[12], a = i[13], o = i[16];
3797
3809
  try {
3798
3810
  return o(t, e, ...n);
3799
3811
  } finally {
3800
- r(t), s(t);
3812
+ a(t), s(t);
3801
3813
  }
3802
- }, Qi = (t, e, n) => {
3803
- const i = X(t), s = i[12], r = i[18], o = i[19], l = r(t, e).l;
3804
- return l.add(n), s(t), () => {
3805
- l.delete(n), o(t, e), s(t);
3814
+ }, Xi = (t, e, n) => {
3815
+ const i = X(t), s = i[12], a = i[18], o = i[19], d = a(t, e).l;
3816
+ return d.add(n), s(t), () => {
3817
+ d.delete(n), o(t, e), s(t);
3806
3818
  };
3807
- }, yn = /* @__PURE__ */ new WeakMap(), X = (t) => {
3808
- const e = yn.get(t);
3819
+ }, mn = /* @__PURE__ */ new WeakMap(), X = (t) => {
3820
+ const e = mn.get(t);
3809
3821
  if ((ce ? "production" : void 0) !== "production" && !e)
3810
3822
  throw new Error(
3811
3823
  "Store must be created by buildStore to read its building blocks"
3812
3824
  );
3813
3825
  return e;
3814
3826
  };
3815
- function Xi(...t) {
3827
+ function Zi(...t) {
3816
3828
  const e = {
3817
3829
  get(i) {
3818
3830
  const s = X(e)[21];
3819
3831
  return s(e, i);
3820
3832
  },
3821
3833
  set(i, ...s) {
3822
- const r = X(e)[22];
3823
- return r(e, i, ...s);
3834
+ const a = X(e)[22];
3835
+ return a(e, i, ...s);
3824
3836
  },
3825
3837
  sub(i, s) {
3826
- const r = X(e)[23];
3827
- return r(e, i, s);
3838
+ const a = X(e)[23];
3839
+ return a(e, i, s);
3828
3840
  }
3829
3841
  }, n = [
3830
3842
  // store state
@@ -3843,63 +3855,63 @@ function Xi(...t) {
3843
3855
  {},
3844
3856
  // storeHooks
3845
3857
  // atom interceptors
3846
- Ui,
3847
- $i,
3848
3858
  Fi,
3859
+ $i,
3849
3860
  Bi,
3850
- // building-block functions
3851
3861
  Vi,
3862
+ // building-block functions
3852
3863
  Gi,
3853
3864
  Wi,
3854
3865
  Hi,
3855
3866
  qi,
3856
- vn,
3857
3867
  Ji,
3858
- mn,
3868
+ gn,
3859
3869
  Yi,
3860
- Ge,
3870
+ vn,
3861
3871
  zi,
3872
+ Ge,
3862
3873
  Ki,
3863
3874
  Qi,
3875
+ Xi,
3864
3876
  void 0
3865
3877
  ].map((i, s) => t[s] || i);
3866
- return yn.set(e, Object.freeze(n)), e;
3878
+ return mn.set(e, Object.freeze(n)), e;
3867
3879
  }
3868
- const bn = {};
3869
- let Zi = 0;
3880
+ const yn = {};
3881
+ let es = 0;
3870
3882
  function He(t, e) {
3871
- const n = `atom${++Zi}`, i = {
3883
+ const n = `atom${++es}`, i = {
3872
3884
  toString() {
3873
- return (bn ? "production" : void 0) !== "production" && this.debugLabel ? n + ":" + this.debugLabel : n;
3885
+ return (yn ? "production" : void 0) !== "production" && this.debugLabel ? n + ":" + this.debugLabel : n;
3874
3886
  }
3875
3887
  };
3876
- return typeof t == "function" ? i.read = t : (i.init = t, i.read = es, i.write = ts), i;
3888
+ return typeof t == "function" ? i.read = t : (i.init = t, i.read = ts, i.write = ns), i;
3877
3889
  }
3878
- function es(t) {
3890
+ function ts(t) {
3879
3891
  return t(this);
3880
3892
  }
3881
- function ts(t, e, n) {
3893
+ function ns(t, e, n) {
3882
3894
  return e(
3883
3895
  this,
3884
3896
  typeof n == "function" ? n(t(this)) : n
3885
3897
  );
3886
3898
  }
3887
- function ns() {
3888
- return Xi();
3899
+ function is() {
3900
+ return Zi();
3889
3901
  }
3890
3902
  let Ce;
3891
- function is() {
3892
- return Ce || (Ce = ns(), (bn ? "production" : void 0) !== "production" && (globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = Ce), globalThis.__JOTAI_DEFAULT_STORE__ !== Ce && console.warn(
3903
+ function ss() {
3904
+ return Ce || (Ce = is(), (yn ? "production" : void 0) !== "production" && (globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = Ce), globalThis.__JOTAI_DEFAULT_STORE__ !== Ce && console.warn(
3893
3905
  "Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
3894
3906
  ))), Ce;
3895
3907
  }
3896
- const ss = {}, os = Wt(
3908
+ const os = {}, rs = Gt(
3897
3909
  void 0
3898
3910
  );
3899
- function _n(t) {
3900
- return Gt(os) || is();
3911
+ function bn(t) {
3912
+ return Vt(rs) || ss();
3901
3913
  }
3902
- const lt = (t) => typeof t?.then == "function", ut = (t) => {
3914
+ const lt = (t) => typeof t?.then == "function", dt = (t) => {
3903
3915
  t.status || (t.status = "pending", t.then(
3904
3916
  (e) => {
3905
3917
  t.status = "fulfilled", t.value = e;
@@ -3908,34 +3920,34 @@ const lt = (t) => typeof t?.then == "function", ut = (t) => {
3908
3920
  t.status = "rejected", t.reason = e;
3909
3921
  }
3910
3922
  ));
3911
- }, rs = ht.use || // A shim for older React versions
3923
+ }, as = ut.use || // A shim for older React versions
3912
3924
  ((t) => {
3913
3925
  if (t.status === "pending")
3914
3926
  throw t;
3915
3927
  if (t.status === "fulfilled")
3916
3928
  return t.value;
3917
- throw t.status === "rejected" ? t.reason : (ut(t), t);
3918
- }), et = /* @__PURE__ */ new WeakMap(), Vt = (t, e) => {
3919
- let n = et.get(t);
3929
+ throw t.status === "rejected" ? t.reason : (dt(t), t);
3930
+ }), Ze = /* @__PURE__ */ new WeakMap(), Bt = (t, e) => {
3931
+ let n = Ze.get(t);
3920
3932
  return n || (n = new Promise((i, s) => {
3921
- let r = t;
3933
+ let a = t;
3922
3934
  const o = (h) => (f) => {
3923
- r === h && i(f);
3924
- }, d = (h) => (f) => {
3925
- r === h && s(f);
3926
- }, l = () => {
3935
+ a === h && i(f);
3936
+ }, l = (h) => (f) => {
3937
+ a === h && s(f);
3938
+ }, d = () => {
3927
3939
  try {
3928
3940
  const h = e();
3929
- lt(h) ? (et.set(h, n), r = h, h.then(o(h), d(h)), ct(h, l)) : i(h);
3941
+ lt(h) ? (Ze.set(h, n), a = h, h.then(o(h), l(h)), at(h, d)) : i(h);
3930
3942
  } catch (h) {
3931
3943
  s(h);
3932
3944
  }
3933
3945
  };
3934
- t.then(o(t), d(t)), ct(t, l);
3935
- }), et.set(t, n)), n;
3946
+ t.then(o(t), l(t)), at(t, d);
3947
+ }), Ze.set(t, n)), n;
3936
3948
  };
3937
3949
  function qe(t, e) {
3938
- const { delay: n, unstable_promiseStatus: i = !ht.use } = {}, s = _n(), [[r, o, d], l] = Tn(
3950
+ const { delay: n, unstable_promiseStatus: i = !ut.use } = {}, s = bn(), [[a, o, l], d] = En(
3939
3951
  (f) => {
3940
3952
  const v = s.get(t);
3941
3953
  return Object.is(f[0], v) && f[1] === s && f[2] === t ? f : [v, s, t];
@@ -3943,56 +3955,56 @@ function qe(t, e) {
3943
3955
  void 0,
3944
3956
  () => [s.get(t), s, t]
3945
3957
  );
3946
- let h = r;
3947
- if ((o !== s || d !== t) && (l(), h = s.get(t)), pe(() => {
3958
+ let h = a;
3959
+ if ((o !== s || l !== t) && (d(), h = s.get(t)), pe(() => {
3948
3960
  const f = s.sub(t, () => {
3949
3961
  if (i)
3950
3962
  try {
3951
3963
  const v = s.get(t);
3952
- lt(v) && ut(
3953
- Vt(v, () => s.get(t))
3964
+ lt(v) && dt(
3965
+ Bt(v, () => s.get(t))
3954
3966
  );
3955
3967
  } catch {
3956
3968
  }
3957
3969
  if (typeof n == "number") {
3958
- setTimeout(l, n);
3970
+ setTimeout(d, n);
3959
3971
  return;
3960
3972
  }
3961
- l();
3973
+ d();
3962
3974
  });
3963
- return l(), f;
3964
- }, [s, t, n, i]), An(h), lt(h)) {
3965
- const f = Vt(h, () => s.get(t));
3966
- return i && ut(f), rs(f);
3975
+ return d(), f;
3976
+ }, [s, t, n, i]), Tn(h), lt(h)) {
3977
+ const f = Bt(h, () => s.get(t));
3978
+ return i && dt(f), as(f);
3967
3979
  }
3968
3980
  return h;
3969
3981
  }
3970
3982
  function Je(t, e) {
3971
- const n = _n();
3972
- return Rn(
3983
+ const n = bn();
3984
+ return An(
3973
3985
  (...s) => {
3974
- if ((ss ? "production" : void 0) !== "production" && !("write" in t))
3986
+ if ((os ? "production" : void 0) !== "production" && !("write" in t))
3975
3987
  throw new Error("not writable atom");
3976
3988
  return n.set(t, ...s);
3977
3989
  },
3978
3990
  [n, t]
3979
3991
  );
3980
3992
  }
3981
- const Sn = He([]);
3982
- function vs() {
3983
- return qe(Sn);
3993
+ const _n = He([]);
3994
+ function ms() {
3995
+ return qe(_n);
3984
3996
  }
3985
- function as() {
3986
- return Je(Sn);
3997
+ function cs() {
3998
+ return Je(_n);
3987
3999
  }
3988
4000
  const Ye = () => {
3989
- const t = Gt(In);
4001
+ const t = Vt(kn);
3990
4002
  if (!t)
3991
4003
  throw new Error("useClient must be used within a TelnyxAIAgentProvider");
3992
4004
  return t;
3993
4005
  };
3994
- function cs() {
3995
- const t = Ye(), e = as();
4006
+ function ls() {
4007
+ const t = Ye(), e = cs();
3996
4008
  return pe(() => {
3997
4009
  const n = (i) => e((s) => [...s, i]);
3998
4010
  return t.addListener("transcript.item", n), () => {
@@ -4000,14 +4012,14 @@ function cs() {
4000
4012
  };
4001
4013
  }, [t, e]), null;
4002
4014
  }
4003
- const wn = He("connecting");
4004
- function ms() {
4005
- return qe(wn);
4015
+ const Sn = He("connecting");
4016
+ function ys() {
4017
+ return qe(Sn);
4006
4018
  }
4007
4019
  function ds() {
4008
- return Je(wn);
4020
+ return Je(Sn);
4009
4021
  }
4010
- function ls() {
4022
+ function us() {
4011
4023
  const t = Ye(), e = ds();
4012
4024
  return pe(() => {
4013
4025
  const n = () => e("connected"), i = () => e("disconnected"), s = () => e("error");
@@ -4016,15 +4028,15 @@ function ls() {
4016
4028
  };
4017
4029
  }, [t, e]), null;
4018
4030
  }
4019
- const Cn = He(null);
4020
- function ys() {
4021
- return qe(Cn);
4031
+ const wn = He(null);
4032
+ function bs() {
4033
+ return qe(wn);
4022
4034
  }
4023
- function us() {
4024
- return Je(Cn);
4035
+ function hs() {
4036
+ return Je(wn);
4025
4037
  }
4026
- const hs = () => {
4027
- const t = Ye(), e = us();
4038
+ const ps = () => {
4039
+ const t = Ye(), e = hs();
4028
4040
  return pe(() => {
4029
4041
  const n = (i) => {
4030
4042
  e(i);
@@ -4033,15 +4045,15 @@ const hs = () => {
4033
4045
  t.removeListener("conversation.update", n);
4034
4046
  };
4035
4047
  }, [t, e]), null;
4036
- }, kn = He({ state: "listening" });
4037
- function bs() {
4038
- return qe(kn);
4039
- }
4040
- function ps() {
4041
- return Je(kn);
4048
+ }, Cn = He({ state: "listening" });
4049
+ function _s() {
4050
+ return qe(Cn);
4042
4051
  }
4043
4052
  function fs() {
4044
- const t = Ye(), e = ps();
4053
+ return Je(Cn);
4054
+ }
4055
+ function gs() {
4056
+ const t = Ye(), e = fs();
4045
4057
  return pe(() => {
4046
4058
  const n = (i) => {
4047
4059
  e(i);
@@ -4051,43 +4063,44 @@ function fs() {
4051
4063
  };
4052
4064
  }, [t, e]), null;
4053
4065
  }
4054
- const In = Wt(null), _s = ({
4066
+ const kn = Gt(null), Ss = ({
4055
4067
  children: t,
4056
4068
  agentId: e,
4057
4069
  environment: n,
4058
4070
  versionId: i,
4059
- debug: s
4071
+ debug: s,
4072
+ vad: a
4060
4073
  }) => {
4061
- const [r, o] = xn(() => new jt({ agentId: e, environment: n, versionId: i, debug: s }));
4074
+ const [o, l] = Rn(() => new Nt({ agentId: e, environment: n, versionId: i, debug: s, vad: a }));
4062
4075
  return pe(() => {
4063
- if (!r) {
4064
- const d = new jt({ agentId: e, environment: n, versionId: i });
4065
- return o(d), () => {
4076
+ if (!o) {
4077
+ const d = new Nt({ agentId: e, environment: n, versionId: i, vad: a });
4078
+ return l(d), () => {
4066
4079
  d.disconnect();
4067
4080
  };
4068
4081
  }
4069
- }, [e, r, n, i]), pe(() => {
4070
- r?.connect();
4071
- }, [r]), /* @__PURE__ */ we.jsxs(In.Provider, { value: r, children: [
4072
- /* @__PURE__ */ we.jsx(cs, {}),
4082
+ }, [e, o, n, i, a]), pe(() => {
4083
+ o?.connect();
4084
+ }, [o]), /* @__PURE__ */ we.jsxs(kn.Provider, { value: o, children: [
4073
4085
  /* @__PURE__ */ we.jsx(ls, {}),
4074
- /* @__PURE__ */ we.jsx(hs, {}),
4075
- /* @__PURE__ */ we.jsx(fs, {}),
4086
+ /* @__PURE__ */ we.jsx(us, {}),
4087
+ /* @__PURE__ */ we.jsx(ps, {}),
4088
+ /* @__PURE__ */ we.jsx(gs, {}),
4076
4089
  t
4077
4090
  ] });
4078
4091
  };
4079
4092
  export {
4080
- In as ClientContext,
4081
- O as SwEvent,
4082
- jt as TelnyxAIAgent,
4083
- _s as TelnyxAIAgentProvider,
4084
- bs as useAgentState,
4093
+ kn as ClientContext,
4094
+ L as SwEvent,
4095
+ Nt as TelnyxAIAgent,
4096
+ Ss as TelnyxAIAgentProvider,
4097
+ _s as useAgentState,
4085
4098
  Ye as useClient,
4086
- ms as useConnectionState,
4087
- ys as useConversation,
4088
- ps as useSetAgentState,
4099
+ ys as useConnectionState,
4100
+ bs as useConversation,
4101
+ fs as useSetAgentState,
4089
4102
  ds as useSetConnectionState,
4090
- us as useSetConversation,
4091
- as as useSetTranscript,
4092
- vs as useTranscript
4103
+ hs as useSetConversation,
4104
+ cs as useSetTranscript,
4105
+ ms as useTranscript
4093
4106
  };