@telnyx/ai-agent-lib 0.2.3 → 0.2.5

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,20 +8,20 @@ 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
15
  d(i.next(h));
16
16
  } catch (f) {
17
- r(f);
17
+ a(f);
18
18
  }
19
19
  }
20
20
  function l(h) {
21
21
  try {
22
22
  d(i.throw(h));
23
23
  } catch (f) {
24
- r(f);
24
+ a(f);
25
25
  }
26
26
  }
27
27
  function d(h) {
@@ -33,38 +33,38 @@ function L(t, e, n, i) {
33
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];
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
47
  return e || (function(o, l) {
48
- var d = 0, h = qt;
48
+ var d = 0, h = Ht;
49
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 l(p, S) {
67
- var A = 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, _) {
67
+ var A = p[_];
68
68
  if (typeof A.bind == "function") return A.bind(p);
69
69
  try {
70
70
  return Function.prototype.bind.call(A, p);
@@ -77,26 +77,26 @@ var Nn = Yt((function(t) {
77
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
- function h(p, S) {
80
+ function h(p, _) {
81
81
  for (var A = 0; A < o.length; A++) {
82
82
  var E = o[A];
83
- this[E] = A < p ? i : this.methodFactory(E, p, S);
83
+ this[E] = A < p ? i : this.methodFactory(E, p, _);
84
84
  }
85
85
  this.log = this.debug;
86
86
  }
87
- function f(p, S, A) {
87
+ function f(p, _, A) {
88
88
  return function() {
89
- typeof console !== s && (h.call(this, S, A), this[p].apply(this, arguments));
89
+ typeof console !== s && (h.call(this, _, A), this[p].apply(this, arguments));
90
90
  };
91
91
  }
92
- function v(p, S, A) {
92
+ function v(p, _, A) {
93
93
  return (function(E) {
94
- return E === "debug" && (E = "log"), typeof console !== s && (E === "trace" && r ? d : console[E] !== void 0 ? l(console, E) : console.log !== void 0 ? l(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
- function _(p, S, A) {
97
+ function S(p, _, A) {
98
98
  var E, P = this;
99
- S = S ?? "WARN";
99
+ _ = _ ?? "WARN";
100
100
  var D = "loglevel";
101
101
  function q() {
102
102
  var x;
@@ -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 {
@@ -131,9 +131,9 @@ var Nn = Yt((function(t) {
131
131
  }
132
132
  })(x), h.call(P, x, p), typeof console === s && x < P.levels.SILENT) return "No console available for logging";
133
133
  }, P.setDefaultLevel = function(x) {
134
- S = x, q() || P.setLevel(x, !1);
134
+ _ = x, q() || P.setLevel(x, !1);
135
135
  }, P.resetLevel = function() {
136
- P.setLevel(S, !1), (function() {
136
+ P.setLevel(_, !1), (function() {
137
137
  if (typeof window !== s && D) {
138
138
  try {
139
139
  return void window.localStorage.removeItem(D);
@@ -151,13 +151,13 @@ var Nn = Yt((function(t) {
151
151
  P.setLevel(P.levels.SILENT, x);
152
152
  };
153
153
  var B = q();
154
- B == null && (B = S), P.setLevel(B, !1);
154
+ B == null && (B = _), P.setLevel(B, !1);
155
155
  }
156
- var w = new _(), C = {};
156
+ var w = new S(), C = {};
157
157
  w.getLogger = function(p) {
158
158
  if (typeof p != "symbol" && typeof p != "string" || p === "") throw new TypeError("You must supply a name when creating a logger.");
159
- var S = C[p];
160
- return S || (S = C[p] = new _(p, w.getLevel(), w.methodFactory)), S;
159
+ var _ = C[p];
160
+ return _ || (_ = C[p] = new S(p, w.getLevel(), w.methodFactory)), _;
161
161
  };
162
162
  var k = typeof window !== s ? window.log : void 0;
163
163
  return w.noConflict = function() {
@@ -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;
179
+ const Le = (t) => {
180
+ const [e, n, i, s, a, o] = t;
181
181
  let l = {};
182
182
  try {
183
- l = 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
187
  return { participantId: Number(e), participantNumber: n, participantName: i, codec: s, media: l, participantData: o };
188
- }, zt = (t) => {
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: l = null } = s;
201
- return r && r !== "200" ? { error: s } : l ? Kt(l, 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;
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
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), !((r = t?.params) === null || r === void 0) && r.state && (d = (o = t?.params) === null || o === void 0 ? void 0 : o.state), 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, le, 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
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, de = (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
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 l = o - 1; l >= 0; l--) ie[r][l](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 = ((l) => `${Un.test(l) ? "" : "wss://"}${l}`)(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);
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
308
  var l;
309
309
  if (typeof o != "string") {
310
- if (o.voice_sdk_id && (l = o.voice_sdk_id, sessionStorage.setItem(ft, l)), 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 d = pt(o);
314
- $(O.SocketMessage, o, this.session.uuid), d && (this.previousGatewayState = d);
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: l, error: d } = Kt(o);
327
- return d ? r(d) : s(l);
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
- 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 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,7 +419,7 @@ 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
  }
@@ -430,15 +430,15 @@ class Jn {
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() {
@@ -458,10 +458,10 @@ class Jn {
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);
@@ -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
+ })), St = [[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
+ }, _t = (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,35 +603,35 @@ 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");
610
610
  if (navigator.userAgent.match(/chrom(e|ium)/gim) && !navigator.userAgent.match(/OPR\/[0-9]{2}/gi) && !navigator.userAgent.match(/edg/gim)) {
611
- const f = navigator.userAgent.match(/chrom(e|ium)\/[0-9]+\./gim)[0].split("/"), v = f[0], _ = parseInt(f[1], 10);
612
- return { browserInfo: navigator.userAgent, name: v, version: _, supportAudio: !0, supportVideo: !0 };
611
+ const f = navigator.userAgent.match(/chrom(e|ium)\/[0-9]+\./gim)[0].split("/"), v = f[0], S = parseInt(f[1], 10);
612
+ return { browserInfo: navigator.userAgent, name: v, version: S, supportAudio: !0, supportVideo: !0 };
613
613
  }
614
614
  if (navigator.userAgent.match(/firefox/gim) && !navigator.userAgent.match(/OPR\/[0-9]{2}/gi) && !navigator.userAgent.match(/edg/gim)) {
615
- const f = navigator.userAgent.match(/firefox\/[0-9]+\./gim)[0].split("/"), v = f[0], _ = parseInt(f[1], 10);
616
- return { browserInfo: navigator.userAgent, name: v, version: _, supportAudio: !0, supportVideo: !1 };
615
+ const f = navigator.userAgent.match(/firefox\/[0-9]+\./gim)[0].split("/"), v = f[0], S = parseInt(f[1], 10);
616
+ return { browserInfo: navigator.userAgent, name: v, version: S, supportAudio: !0, supportVideo: !1 };
617
617
  }
618
618
  if (navigator.userAgent.match(/safari/gim) && !navigator.userAgent.match(/OPR\/[0-9]{2}/gi) && !navigator.userAgent.match(/edg/gim)) {
619
- const f = navigator.userAgent.match(/safari/gim)[0], v = navigator.userAgent.match(/version\/[0-9]+\./gim)[0].split("/"), _ = parseInt(v[1], 10);
620
- return { browserInfo: navigator.userAgent, name: f, version: _, supportAudio: !0, supportVideo: !0 };
619
+ const f = navigator.userAgent.match(/safari/gim)[0], v = navigator.userAgent.match(/version\/[0-9]+\./gim)[0].split("/"), S = parseInt(v[1], 10);
620
+ return { browserInfo: navigator.userAgent, name: f, version: S, supportAudio: !0, supportVideo: !0 };
621
621
  }
622
622
  if (navigator.userAgent.match(/edg/gim) && !navigator.userAgent.match(/OPR\/[0-9]{2}/gi)) {
623
- const f = navigator.userAgent.match(/edg\/[0-9]+\./gim)[0].split("/"), v = f[0], _ = parseInt(f[1], 10);
624
- return { browserInfo: navigator.userAgent, name: v, version: _, supportAudio: !0, supportVideo: !0 };
623
+ const f = navigator.userAgent.match(/edg\/[0-9]+\./gim)[0].split("/"), v = f[0], S = parseInt(f[1], 10);
624
+ return { browserInfo: navigator.userAgent, name: v, version: S, 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, 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: !!(r && o && l && d && h), supportWebRTCAudio: i, supportWebRTCVideo: s, supportRTCPeerConnection: !!r, supportSessionDescription: !!o, supportIceCandidate: !!l, supportMediaDevices: !!d, 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.14", 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 l = { login: e, passwd: n, login_token: i, userVariables: r, reconnection: o, loginParams: {}, "User-Agent": { sdkVersion: We, data: navigator.userAgent } };
664
+ const l = { login: e, passwd: n, login_token: i, userVariables: a, reconnection: o, loginParams: {}, "User-Agent": { sdkVersion: We, data: navigator.userAgent } };
665
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 l(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 d(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, l(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, l(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,58 +852,58 @@ 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) : d.call(a, c);
882
+ }, s.listenerCount = function(r, c) {
883
+ return typeof r.listenerCount == "function" ? r.listenerCount(c) : d.call(r, c);
884
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);
888
- function _() {
888
+ function S() {
889
889
  if (!f && !(f = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto))) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
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 _(r, c, u) {
901
+ var g = (r = r || {}).random || (r.rng || S)();
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 = _()), 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,115 +1304,115 @@ 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) {
1311
- const { jitter: f, rtt: v } = h, _ = f + v / 2;
1312
- return 0.024 * _ + 0.11 * (_ - 177.3) * (_ > 177.3 ? 1 : 0);
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
+ const { jitter: f, rtt: v } = h, S = f + v / 2;
1312
+ return 0.024 * S + 0.11 * (S - 177.3) * (S > 177.3 ? 1 : 0);
1313
1313
  })({ rtt: s, jitter: i }), o = (function(h) {
1314
- const { packetsLost: f, packetsReceived: v } = h, _ = f / (v + f) * 100;
1315
- return 20 * Math.log(1 + _);
1316
- })({ packetsLost: e, packetsReceived: n }), l = 93.2 - r - o + 0, d = 1 + 0.035 * l + 7e-6 * l * (l - 60) * (100 - l);
1314
+ const { packetsLost: f, packetsReceived: v } = h, S = f / (v + f) * 100;
1315
+ return 20 * Math.log(1 + S);
1316
+ })({ packetsLost: e, packetsReceived: n }), l = 93.2 - a - o + 0, d = 1 + 0.035 * l + 7e-6 * l * (l - 60) * (100 - l);
1317
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 li 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
  }
1331
1331
  }
1332
- class di extends Re {
1332
+ class li extends Re {
1333
1333
  constructor(e, n) {
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 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 = 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 di(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, S, w, C;
1345
+ const { audio: k, remote: p } = o, { audio: _ } = p, A = (d = (l = _.inbound[0]) === null || l === void 0 ? void 0 : l.jitter) !== null && d !== void 0 ? d : 1 / 0, E = (f = (h = _.inbound[0]) === null || h === void 0 ? void 0 : h.roundTripTime) !== null && f !== void 0 ? f : 1 / 0, P = (S = (v = k.inbound[0]) === null || v === void 0 ? void 0 : v.packetsReceived) !== null && S !== void 0 ? S : -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: _.inbound[0], remoteOutboundAudio: _.outbound[0] };
1347
+ })(a), t.uuid), yield t.execute(new li(n, a));
1348
1348
  }));
1349
- return { start: (r, o, l) => L(this, void 0, void 0, (function* () {
1350
- yield t.execute(new ci(n, e)), i.on("timeline", s), yield new Promise(((d) => setTimeout(d, 500))), i.addConnection({ pc: r, peerId: o, connectionId: l });
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(l, d) {
1353
+ F(L.StatsReport, o, t.uuid), a === "file" && (function(l, d) {
1354
1354
  const h = new Blob([JSON.stringify(l)], { type: "application/json" }), f = URL.createObjectURL(h), v = document.createElement("a");
1355
1355
  v.href = f, v.download = `${d}.json`, v.click(), URL.revokeObjectURL(f);
1356
- })(o, `webrtc-stats-${n}-${Date.now()}`), yield t.execute(new li(n, e)), i.removeAllPeers(), i.destroy();
1357
- })), reportConnectionStateChange: (r) => {
1358
- const o = { event: "connectionstatechange-detailed", tag: "connection", timestamp: (/* @__PURE__ */ new Date()).toISOString(), data: r };
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 l = { 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
1371
  const d = Object.assign({ action: se.LayerInfo }, l);
1372
- $(O.Notification, d, t.uuid);
1372
+ F(L.Notification, d, t.uuid);
1373
1373
  break;
1374
1374
  }
1375
1375
  case "layout-info": {
1376
1376
  const d = Object.assign({ action: se.LayoutInfo }, l);
1377
- $(O.Notification, d, t.uuid);
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* () {
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
1388
  const { connectionState: l } = this.instance;
1389
1389
  if (y.info(`[${(/* @__PURE__ */ new Date()).toISOString()}] Connection State changed: ${this._prevConnectionState} -> ${l}`), l === "failed" || l === "disconnected") {
1390
- const d = () => L(this, void 0, void 0, (function* () {
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* () {
1394
- const _ = { connectionState: f.connectionState, previousConnectionState: v, iceConnectionState: f.iceConnectionState, iceGatheringState: f.iceGatheringState, signalingState: f.signalingState }, w = f.getTransceivers();
1393
+ return O(this, void 0, void 0, (function* () {
1394
+ const S = { 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;
1397
- k && (_.dtlsState = k.state);
1397
+ k && (S.dtlsState = k.state);
1398
1398
  }
1399
- f.sctp && (_.sctpState = f.sctp.state);
1399
+ f.sctp && (S.sctpState = f.sctp.state);
1400
1400
  try {
1401
1401
  const C = yield f.getStats();
1402
1402
  C.forEach(((k) => {
1403
- k.type === "candidate-pair" && k.state === "succeeded" && (_.candidatePairState = k.state, C.forEach(((p) => {
1404
- p.type === "local-candidate" && p.id === k.localCandidateId && (_.localCandidateType = p.candidateType, _.selectedCandidatePair = _.selectedCandidatePair || { local: {}, remote: {} }, _.selectedCandidatePair.local = { address: p.address, port: p.port, protocol: p.protocol, candidateType: p.candidateType }), p.type === "remote-candidate" && p.id === k.remoteCandidateId && (_.remoteCandidateType = p.candidateType, _.selectedCandidatePair = _.selectedCandidatePair || { local: {}, remote: {} }, _.selectedCandidatePair.remote = { address: p.address, port: p.port, protocol: p.protocol, candidateType: p.candidateType });
1405
- }))), k.type === "transport" && (_.dtlsCipher = k.dtlsCipher, _.srtpCipher = k.srtpCipher, _.tlsVersion = k.tlsVersion, k.dtlsState && (_.dtlsState = k.dtlsState));
1403
+ k.type === "candidate-pair" && k.state === "succeeded" && (S.candidatePairState = k.state, C.forEach(((p) => {
1404
+ p.type === "local-candidate" && p.id === k.localCandidateId && (S.localCandidateType = p.candidateType, S.selectedCandidatePair = S.selectedCandidatePair || { local: {}, remote: {} }, S.selectedCandidatePair.local = { address: p.address, port: p.port, protocol: p.protocol, candidateType: p.candidateType }), p.type === "remote-candidate" && p.id === k.remoteCandidateId && (S.remoteCandidateType = p.candidateType, S.selectedCandidatePair = S.selectedCandidatePair || { local: {}, remote: {} }, S.selectedCandidatePair.remote = { address: p.address, port: p.port, protocol: p.protocol, candidateType: p.candidateType });
1405
+ }))), k.type === "transport" && (S.dtlsCipher = k.dtlsCipher, S.srtpCipher = k.srtpCipher, S.tlsVersion = k.tlsVersion, k.dtlsState && (S.dtlsState = k.dtlsState));
1406
1406
  }));
1407
1407
  } catch (C) {
1408
1408
  y.error("Error gathering connection state details:", C);
1409
1409
  }
1410
- return _;
1410
+ return S;
1411
1411
  }));
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: ${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);
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
1417
  navigator.onLine ? d() : window.addEventListener("online", d);
1418
1418
  }
@@ -1423,7 +1423,7 @@ class Ot {
1423
1423
  y.debug(`[${(/* @__PURE__ */ new Date()).toISOString()}] ICE Gathering State`, this.instance.iceGatheringState);
1424
1424
  }, this._setCodecs = (o, l) => {
1425
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 = r;
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"), 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(r.duration) }, "SDP Send": { duration: l(s.duration) }, "Total Duration": { duration: l(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,38 +1475,38 @@ 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
1505
  const { audioCodecs: l, videoCodecs: d } = ((h) => {
1506
1506
  const f = [], v = [];
1507
- return h && h.length !== 0 ? (h.forEach(((_) => {
1508
- const w = _.mimeType.toLocaleLowerCase();
1509
- w.startsWith("audio/") ? f.push(_) : w.startsWith("video/") && v.push(_);
1507
+ return h && h.length !== 0 ? (h.forEach(((S) => {
1508
+ const w = S.mimeType.toLocaleLowerCase();
1509
+ w.startsWith("audio/") ? f.push(S) : w.startsWith("video/") && v.push(S);
1510
1510
  })), { audioCodecs: f, videoCodecs: v }) : { audioCodecs: f, videoCodecs: v };
1511
1511
  })(this.options.preferred_codecs);
1512
1512
  if (this.isOffer && typeof this.instance.addTransceiver == "function") {
@@ -1536,7 +1536,7 @@ 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
1541
  this._constraints.offerToReceiveAudio = this.options.audio !== !1, this._constraints.offerToReceiveVideo = !!this.options.video, y.info("_createOffer - this._constraints", this._constraints);
1542
1542
  try {
@@ -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;
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
1583
  const { micLabel: l = "", camLabel: d = "" } = n;
1584
- return s && (s = yield Ue(s, l, ae.AudioIn).catch(((h) => null)), s && (typeof i == "boolean" && (i = {}), i.deviceId = { exact: s })), o && (o = yield Ue(o, d, ae.Video).catch(((h) => null)), o && (typeof r == "boolean" && (r = {}), r.deviceId = { exact: o })), { audio: i, video: r };
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,37 +1627,37 @@ 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 ln {
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) => {
1639
- const S = p < 0 || !this._lastSerno || this._lastSerno && p === this._lastSerno + 1;
1640
- return S && p >= 0 && (this._lastSerno = p), S;
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
+ const _ = p < 0 || !this._lastSerno || this._lastSerno && p === this._lastSerno + 1;
1640
+ return _ && p >= 0 && (this._lastSerno = p), _;
1641
1641
  }, this._doStats = () => {
1642
1642
  this.peer && this.peer.instance && this._statsBindings.length !== 0 && this.peer.instance.getStats().then(((p) => {
1643
- p.forEach(((S) => {
1643
+ p.forEach(((_) => {
1644
1644
  this._statsBindings.forEach(((A) => {
1645
1645
  if (A.callback) {
1646
1646
  if (A.constraints) {
1647
- for (var E in A.constraints) if (A.constraints.hasOwnProperty(E) && A.constraints[E] !== S[E]) return;
1647
+ for (var E in A.constraints) if (A.constraints.hasOwnProperty(E) && A.constraints[E] !== _[E]) return;
1648
1648
  }
1649
- A.callback(S);
1649
+ A.callback(_);
1650
1650
  }
1651
1651
  }));
1652
1652
  }));
1653
1653
  }));
1654
1654
  };
1655
- const { iceServers: i, speaker: s, micId: r, 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: r, 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 = 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: S, video: w }, ringtoneFile: C, ringbackFile: k } = e;
1656
+ this.options = Object.assign({}, Fn, { audio: S, 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,43 +1681,43 @@ class ln {
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 = le.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 = 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 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;
1710
+ var i, s, a;
1711
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 : [], ...(r = (s = o?.dialogParams) === null || s === void 0 ? void 0 : s.customHeaders) !== null && r !== void 0 ? r : []], this.setState(N.Hangup);
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
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
1717
  if (this.stopRingtone(), this.stopRingback(), l) {
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 });
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);
1720
+ y.error("telnyx_rtc.bye failed!", f), F(L.Error, { error: f, sessionId: this.session.sessionid }, this.session.uuid);
1721
1721
  })).then(d.bind(this));
1722
1722
  } else d();
1723
1723
  }
@@ -1734,30 +1734,30 @@ class ln {
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
+ _t(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
1759
  const { localStream: l } = this.options;
1760
- l.getAudioTracks().forEach(((d) => d.stop())), l.getVideoTracks().forEach(((d) => r.addTrack(d))), this.options.localStream = r;
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,35 +1774,35 @@ class ln {
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);
1780
+ const s = yield tt({ video: { deviceId: { exact: e } } }), a = s.getVideoTracks()[0];
1781
+ i.replaceTrack(a);
1782
1782
  const { localElement: o, localStream: l } = this.options;
1783
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
+ _t(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());
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
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
  }));
@@ -1826,7 +1826,7 @@ class ln {
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 ln {
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: l } = 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 d = l === le.Inbound ? le.Outbound : le.Inbound, h = { type: oe[n], call: this, displayName: r, displayNumber: o, displayDirection: d };
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: 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));
1879
+ const { chatChannel: l, infoChannel: d, modChannel: h, laName: f, conferenceMemberID: v, role: S } = n;
1880
+ this._dispatchConferenceUpdate({ action: se.Join, conferenceName: f, participantId: Number(v), role: S }), 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 ln {
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: l, message: d, type: h } = s.data;
1912
- this._dispatchConferenceUpdate({ action: se.ChatMessage, direction: r, participantNumber: o, participantName: l, messageText: d, 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 ln {
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 ln {
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
1963
  const l = { sessid: this.session.sessionid, sdp: s, dialogParams: this.options, "User-Agent": `Web-${Lt}` };
1964
- switch (r) {
1964
+ switch (a) {
1965
1965
  case K.Offer:
1966
- this.setState(N.Requesting), o = new Tt(l);
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(l) : new At(l);
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
1974
  performance.mark("sdp-send-start"), this._execute(o).then(((d) => {
1975
1975
  const { node_id: h = null } = d;
1976
- this._targetNodeId = h, r === K.Offer ? this.setState(N.Trying) : this.setState(N.Active);
1976
+ this._targetNodeId = h, a === K.Offer ? this.setState(N.Trying) : this.setState(N.Active);
1977
1977
  })).catch(((d) => {
1978
- y.error(`${this.id} - Sending ${r} error:`, d), this.hangup();
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,13 +1984,13 @@ class ln {
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);
@@ -2012,7 +2012,7 @@ class ln {
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 ln {
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 ln {
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 ln {
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,21 +2087,21 @@ class ln {
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, de(O.MediaError, this._onMediaError, this.id), de(O.PeerConnectionFailureError, this._onPeerConnectionFailureError, this.id), ye(s) && de(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");
@@ -2110,7 +2110,7 @@ class ln {
2110
2110
  this._statsIntervalId && (clearInterval(this._statsIntervalId), this._statsIntervalId = null), y.debug("Stats stopped");
2111
2111
  }
2112
2112
  }
2113
- ln.setStateTelnyx = (t) => {
2113
+ cn.setStateTelnyx = (t) => {
2114
2114
  if (t) {
2115
2115
  switch (t._state) {
2116
2116
  case N.Requesting:
@@ -2138,15 +2138,15 @@ ln.setStateTelnyx = (t) => {
2138
2138
  return t;
2139
2139
  }
2140
2140
  };
2141
- class he extends ln {
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,7 +2154,7 @@ class he extends ln {
2154
2154
  this.screenShare && this.screenShare.hangup();
2155
2155
  }));
2156
2156
  }));
2157
- const { remoteCallerName: s, remoteCallerNumber: r, callerName: o, callerNumber: l } = this.options, d = Object.assign({ screenShare: !0, localStream: n, destinationNumber: `${this.extension}-screen`, remoteCallerName: s, remoteCallerNumber: `${r}-screen`, callerName: `${o} (Screen)`, callerNumber: `${l} (Screen)` }, e);
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
2158
  return this.screenShare = new he(this.session, d), this.screenShare.invite(), this.screenShare;
2159
2159
  }));
2160
2160
  }
@@ -2162,10 +2162,10 @@ class he extends ln {
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,22 +2173,22 @@ class he extends ln {
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
2183
  `, Object.keys(o).forEach(((l) => {
2184
- r.includes(l) || (i += ` ${l}: ${o[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
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
  }
@@ -2197,20 +2197,20 @@ class pi extends Jn {
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) => {
2237
+ if (Xt(L.SpeedTest, ((o) => {
2238
2238
  const { upDur: l, downDur: d } = o, h = d ? 8 * e / (d / 1e3) / 1024 : 0;
2239
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];
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
2269
  for (let o = 0; o < St.length; o++) {
2270
2270
  const [l, d] = St[o];
2271
- (yield r.applyConstraints({ width: { exact: l }, height: { exact: d } }).then((() => !0)).catch((() => !1))) && i.push({ resolution: `${l}x${d}`, width: l, height: d });
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,13 +2281,13 @@ 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, l, d) => L(void 0, void 0, void 0, (function* () {
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
2288
  const { deviceId: h } = d;
2289
- if (h === void 0 && (r || o)) {
2290
- const f = yield Ue(r, o, l).catch(((v) => null));
2289
+ if (h === void 0 && (a || o)) {
2290
+ const f = yield je(a, o, l).catch(((v) => null));
2291
2291
  f && (d.deviceId = { exact: f });
2292
2292
  }
2293
2293
  return d;
@@ -2304,7 +2304,7 @@ class pi extends Jn {
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* () {
2337
+ return O(this, void 0, void 0, (function* () {
2338
2338
  if (!(n = n.filter(((d) => d && !this._existsSubscription(this.relayProtocol, d)))).length) return {};
2339
- const s = new ni({ sessid: this.sessionid, eventChannel: n });
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: l = [] } = st(r);
2342
- return o.length && o.forEach(((d) => this._removeSubscription(this.relayProtocol, d))), l.forEach(((d) => this._addSubscription(this.relayProtocol, i, d))), 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* () {
2346
+ return O(this, void 0, void 0, (function* () {
2347
2347
  if (!(n = n.filter(((l) => l && this._existsSubscription(this.relayProtocol, l)))).length) return {};
2348
- const i = new ii({ sessid: this.sessionid, eventChannel: n });
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(((l) => this._removeSubscription(this.relayProtocol, l))), o.forEach(((l) => this._removeSubscription(this.relayProtocol, l))), 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,102 +2365,102 @@ 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
  }
2372
2372
  }
2373
- class dn extends Z {
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: l } = e, d = { target_type: n, target_id: i, userVariables: r, reconnection: l, "User-Agent": { sdkVersion: We, data: navigator.userAgent } };
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
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, l = new on(n, i || s, r, this.session.sessionid, o, !!fe()), d = yield this.session.execute(l).catch(this.session.handleLoginError);
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
2385
  d && (this.session.sessionid = d.sessid);
2386
- })), this.handleAnonymousLogin = () => L(this, void 0, void 0, (function* () {
2387
- const { anonymous_login: n } = this.session.options, i = new dn({ 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);
2386
+ })), this.handleAnonymousLogin = () => O(this, void 0, void 0, (function* () {
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: l } = e, d = 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, S = a === $.Punt;
2401
2401
  let w = !1;
2402
2402
  if (f === "channelPvtData") return this._handlePvtEvent(o.pvtData);
2403
2403
  if (d && i.calls.hasOwnProperty(d)) {
2404
- if (!v) return i.calls[d].handleMessage(e), void this._ack(s, r);
2404
+ if (!v) return i.calls[d].handleMessage(e), void this._ack(s, a);
2405
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()}][${d}] keeping call alive due to PUNT and keepConnectionAliveOnSocketClose. Disconnecting base session...`), this.session.socketDisconnect(), void this._ack(s, r);
2407
+ if (S && 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
- var S, A, E, P, D, 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 };
2409
+ var _, A, E, P, D, 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: (_ = i.options.debug) !== null && _ !== void 0 && _, 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(l), p = new tn(l);
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 = le.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[d].peer.instance.localDescription.sdp, dialogParams: this.session.calls[d].options, "User-Agent": `Web-${fi}` }));
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
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
- 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);
2441
+ const _ = i.relayProtocol, A = h.split(".")[0];
2442
+ i._existsSubscription(_, h) ? F(_, o, h) : h === i.sessionid ? this._handleSessionEvent(o.eventData) : i._existsSubscription(_, A) ? F(_, 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: l, infoChannel: d, 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: S } = 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);
2516
- if (S && n.calls.hasOwnProperty(S)) {
2517
- const A = n.calls[S];
2518
- A._addChannel(r), A.extension = o, A.handleConferenceUpdate(p, e).then(((E) => {
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
+ if (_ && n.calls.hasOwnProperty(_)) {
2517
+ const A = n.calls[_];
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, l, d, 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,26 +2549,26 @@ 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: l = !0 } = this.options, d = new on(n, i || s, r, this.sessionid, o, !!fe()), h = yield this.execute(d).catch(this._handleLoginError);
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
2568
  h && (this._autoReconnect = l, this.sessionid = h.sessid);
2569
- })), this.handleAnonymousLoginOnSocketOpen = () => L(this, void 0, void 0, (function* () {
2569
+ })), this.handleAnonymousLoginOnSocketOpen = () => O(this, void 0, void 0, (function* () {
2570
2570
  this._idle = !1;
2571
- const { anonymous_login: n } = this.options, i = new dn({ 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);
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);
2573
2573
  })), window.addEventListener("beforeunload", ((n) => {
2574
2574
  this.calls && Object.keys(this.calls).forEach(((i) => {
@@ -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,26 +2606,26 @@ 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
  }
@@ -2633,10 +2633,10 @@ function mi() {
2633
2633
  function s(d, h, f) {
2634
2634
  this.fn = d, this.context = h, this.once = f || !1;
2635
2635
  }
2636
- function r(d, h, f, v, _) {
2636
+ function a(d, h, f, v, S) {
2637
2637
  if (typeof f != "function")
2638
2638
  throw new TypeError("The listener must be a function");
2639
- var w = new s(f, v || d, _), C = n ? n + h : h;
2639
+ var w = new s(f, v || d, S), C = n ? n + h : h;
2640
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
2642
  function o(d, h) {
@@ -2655,18 +2655,18 @@ function mi() {
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
- for (var _ = 0, w = v.length, C = new Array(w); _ < w; _++)
2659
- C[_] = v[_].fn;
2658
+ for (var S = 0, w = v.length, C = new Array(w); S < w; S++)
2659
+ C[S] = v[S].fn;
2660
2660
  return C;
2661
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
- }, l.prototype.emit = function(h, f, v, _, w, C) {
2664
+ }, l.prototype.emit = function(h, f, v, S, w, C) {
2665
2665
  var k = n ? n + h : h;
2666
2666
  if (!this._events[k]) return !1;
2667
- var p = this._events[k], S = arguments.length, A, E;
2667
+ var p = this._events[k], _ = arguments.length, A, E;
2668
2668
  if (p.fn) {
2669
- switch (p.once && this.removeListener(h, p.fn, void 0, !0), S) {
2669
+ switch (p.once && this.removeListener(h, p.fn, void 0, !0), _) {
2670
2670
  case 1:
2671
2671
  return p.fn.call(p.context), !0;
2672
2672
  case 2:
@@ -2674,19 +2674,19 @@ function mi() {
2674
2674
  case 3:
2675
2675
  return p.fn.call(p.context, f, v), !0;
2676
2676
  case 4:
2677
- return p.fn.call(p.context, f, v, _), !0;
2677
+ return p.fn.call(p.context, f, v, S), !0;
2678
2678
  case 5:
2679
- return p.fn.call(p.context, f, v, _, w), !0;
2679
+ return p.fn.call(p.context, f, v, S, w), !0;
2680
2680
  case 6:
2681
- return p.fn.call(p.context, f, v, _, w, C), !0;
2681
+ return p.fn.call(p.context, f, v, S, w, C), !0;
2682
2682
  }
2683
- for (E = 1, A = new Array(S - 1); E < S; E++)
2683
+ for (E = 1, A = new Array(_ - 1); E < _; E++)
2684
2684
  A[E - 1] = arguments[E];
2685
2685
  p.fn.apply(p.context, A);
2686
2686
  } else {
2687
2687
  var P = p.length, D;
2688
2688
  for (E = 0; E < P; E++)
2689
- switch (p[E].once && this.removeListener(h, p[E].fn, void 0, !0), S) {
2689
+ switch (p[E].once && this.removeListener(h, p[E].fn, void 0, !0), _) {
2690
2690
  case 1:
2691
2691
  p[E].fn.call(p[E].context);
2692
2692
  break;
@@ -2697,30 +2697,30 @@ function mi() {
2697
2697
  p[E].fn.call(p[E].context, f, v);
2698
2698
  break;
2699
2699
  case 4:
2700
- p[E].fn.call(p[E].context, f, v, _);
2700
+ p[E].fn.call(p[E].context, f, v, S);
2701
2701
  break;
2702
2702
  default:
2703
- if (!A) for (D = 1, A = new Array(S - 1); D < S; D++)
2703
+ if (!A) for (D = 1, A = new Array(_ - 1); D < _; D++)
2704
2704
  A[D - 1] = arguments[D];
2705
2705
  p[E].fn.apply(p[E].context, A);
2706
2706
  }
2707
2707
  }
2708
2708
  return !0;
2709
2709
  }, l.prototype.on = function(h, f, v) {
2710
- return r(this, h, f, v, !1);
2710
+ return a(this, h, f, v, !1);
2711
2711
  }, l.prototype.once = function(h, f, v) {
2712
- return r(this, h, f, v, !0);
2713
- }, l.prototype.removeListener = function(h, f, v, _) {
2712
+ return a(this, h, f, v, !0);
2713
+ }, l.prototype.removeListener = function(h, f, v, S) {
2714
2714
  var w = n ? n + h : h;
2715
2715
  if (!this._events[w]) return this;
2716
2716
  if (!f)
2717
2717
  return o(this, w), this;
2718
2718
  var C = this._events[w];
2719
2719
  if (C.fn)
2720
- C.fn === f && (!_ || C.once) && (!v || C.context === v) && o(this, w);
2720
+ C.fn === f && (!S || C.once) && (!v || C.context === v) && o(this, w);
2721
2721
  else {
2722
- for (var k = 0, p = [], S = C.length; k < S; k++)
2723
- (C[k].fn !== f || _ && !C[k].once || v && C[k].context !== v) && p.push(C[k]);
2722
+ for (var k = 0, p = [], _ = C.length; k < _; k++)
2723
+ (C[k].fn !== f || S && !C[k].once || v && C[k].context !== v) && p.push(C[k]);
2724
2724
  p.length ? this._events[w] = p.length === 1 ? p[0] : p : o(this, w);
2725
2725
  }
2726
2726
  return this;
@@ -2730,14 +2730,14 @@ function mi() {
2730
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,16 +2745,16 @@ function _i() {
2745
2745
  "info",
2746
2746
  "warn",
2747
2747
  "error"
2748
- ], r = {}, o = null;
2748
+ ], a = {}, o = null;
2749
2749
  function l(k, p) {
2750
- var S = k[p];
2751
- if (typeof S.bind == "function")
2752
- return S.bind(k);
2750
+ var _ = k[p];
2751
+ if (typeof _.bind == "function")
2752
+ return _.bind(k);
2753
2753
  try {
2754
- return Function.prototype.bind.call(S, k);
2754
+ return Function.prototype.bind.call(_, k);
2755
2755
  } catch {
2756
2756
  return function() {
2757
- return Function.prototype.apply.apply(S, [k, arguments]);
2757
+ return Function.prototype.apply.apply(_, [k, arguments]);
2758
2758
  };
2759
2759
  }
2760
2760
  }
@@ -2766,8 +2766,8 @@ function _i() {
2766
2766
  }
2767
2767
  function f() {
2768
2768
  for (var k = this.getLevel(), p = 0; p < s.length; p++) {
2769
- var S = s[p];
2770
- this[S] = p < k ? e : this.methodFactory(S, k, this.name);
2769
+ var _ = s[p];
2770
+ this[_] = p < k ? e : this.methodFactory(_, k, this.name);
2771
2771
  }
2772
2772
  if (this.log = this.debug, typeof console === n && k < this.levels.SILENT)
2773
2773
  return "No console available for logging";
@@ -2777,11 +2777,11 @@ function _i() {
2777
2777
  typeof console !== n && (f.call(this), this[k].apply(this, arguments));
2778
2778
  };
2779
2779
  }
2780
- function _(k, p, S) {
2780
+ function S(k, p, _) {
2781
2781
  return h(k) || v.apply(this, arguments);
2782
2782
  }
2783
2783
  function w(k, p) {
2784
- var S = this, A, E, P, D = "loglevel";
2784
+ var _ = this, A, E, P, D = "loglevel";
2785
2785
  typeof k == "string" ? D += ":" + k : typeof k == "symbol" && (D = void 0);
2786
2786
  function q(u) {
2787
2787
  var g = (s[u] || "silent").toUpperCase();
@@ -2812,7 +2812,7 @@ function _i() {
2812
2812
  )[1]);
2813
2813
  } catch {
2814
2814
  }
2815
- return S.levels[u] === void 0 && (u = void 0), u;
2815
+ return _.levels[u] === void 0 && (u = void 0), u;
2816
2816
  }
2817
2817
  }
2818
2818
  function x() {
@@ -2827,77 +2827,77 @@ function _i() {
2827
2827
  }
2828
2828
  }
2829
2829
  }
2830
- function a(u) {
2830
+ function r(u) {
2831
2831
  var g = u;
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)
2832
+ if (typeof g == "string" && _.levels[g.toUpperCase()] !== void 0 && (g = _.levels[g.toUpperCase()]), typeof g == "number" && g >= 0 && g <= _.levels.SILENT)
2833
2833
  return g;
2834
2834
  throw new TypeError("log.setLevel() called with invalid level: " + u);
2835
2835
  }
2836
- S.name = k, S.levels = {
2836
+ _.name = k, _.levels = {
2837
2837
  TRACE: 0,
2838
2838
  DEBUG: 1,
2839
2839
  INFO: 2,
2840
2840
  WARN: 3,
2841
2841
  ERROR: 4,
2842
2842
  SILENT: 5
2843
- }, S.methodFactory = p || _, S.getLevel = function() {
2843
+ }, _.methodFactory = p || S, _.getLevel = function() {
2844
2844
  return P ?? E ?? A;
2845
- }, S.setLevel = function(u, g) {
2846
- return P = a(u), g !== !1 && q(P), f.call(S);
2847
- }, S.setDefaultLevel = function(u) {
2848
- E = a(u), B() || S.setLevel(u, !1);
2849
- }, S.resetLevel = function() {
2850
- P = null, x(), f.call(S);
2851
- }, S.enableAll = function(u) {
2852
- S.setLevel(S.levels.TRACE, u);
2853
- }, S.disableAll = function(u) {
2854
- S.setLevel(S.levels.SILENT, u);
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(
2845
+ }, _.setLevel = function(u, g) {
2846
+ return P = r(u), g !== !1 && q(P), f.call(_);
2847
+ }, _.setDefaultLevel = function(u) {
2848
+ E = r(u), B() || _.setLevel(u, !1);
2849
+ }, _.resetLevel = function() {
2850
+ P = null, x(), f.call(_);
2851
+ }, _.enableAll = function(u) {
2852
+ _.setLevel(_.levels.TRACE, u);
2853
+ }, _.disableAll = function(u) {
2854
+ _.setLevel(_.levels.SILENT, u);
2855
+ }, _.rebuild = function() {
2856
+ if (o !== _ && (A = r(o.getLevel())), f.call(_), o === _)
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(_);
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 _ = a[p];
2869
+ return _ || (_ = a[p] = new w(
2870
2870
  p,
2871
2871
  o.methodFactory
2872
- )), S;
2872
+ )), _;
2873
2873
  };
2874
2874
  var C = typeof window !== n ? window.log : void 0;
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 Si = bi();
2884
+ const _i = /* @__PURE__ */ dn(Si), wi = () => (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), z = _i.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,14 +2913,21 @@ class Ti {
2913
2913
  // Local stream (user) state tracking
2914
2914
  userIsSpeaking = !1;
2915
2915
  lastUserAudioTime = null;
2916
+ userSpeechStartTime = null;
2916
2917
  // Latency measurement tracking
2917
2918
  userSilenceStartTime = null;
2918
2919
  isFirstAgentSpeech = !0;
2919
2920
  monitorStartTime = null;
2920
- constructor() {
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;
2921
2928
  }
2922
- updateAgentState = Ii((e) => {
2923
- 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));
2924
2931
  }, 100);
2925
2932
  /**
2926
2933
  * Set the remote audio stream (agent's voice) to monitor for speech detection
@@ -2944,8 +2951,15 @@ class Ti {
2944
2951
  stopLocalMonitor() {
2945
2952
  this.localIntervalId && (clearInterval(this.localIntervalId), this.localIntervalId = null), this.localSource?.disconnect(), this.localAudioContext?.close(), this.localAudioContext = null, this.localSource = null, this.localAnalyser = null;
2946
2953
  }
2954
+ /**
2955
+ * Reset all latency tracking state for a fresh call.
2956
+ * Should be called when a call ends to prevent stale data affecting the next call.
2957
+ */
2958
+ resetLatencyState() {
2959
+ this.thinkingStartTime = null, this.lastState = null, this.userIsSpeaking = !1, this.lastUserAudioTime = null, this.userSpeechStartTime = null, this.userSilenceStartTime = null, this.isFirstAgentSpeech = !0, this.monitorStartTime = null;
2960
+ }
2947
2961
  stopAudioStreamMonitor() {
2948
- this.stopRemoteMonitor(), this.stopLocalMonitor();
2962
+ this.stopRemoteMonitor(), this.stopLocalMonitor(), this.resetLatencyState();
2949
2963
  }
2950
2964
  /**
2951
2965
  * Monitor remote stream (agent's audio) for speech detection
@@ -2967,23 +2981,23 @@ class Ti {
2967
2981
  let i = !1;
2968
2982
  const s = () => {
2969
2983
  this.remoteAnalyser?.getByteFrequencyData(n);
2970
- const r = n.reduce((l, d) => l + d, 0) / n.length, o = r >= Ze;
2971
- if (Math.random() < 0.01 && z.debug("Remote audio volume:", r, "threshold:", Ze, "above:", o), o)
2984
+ const a = n.reduce((l, d) => l + d, 0) / n.length, o = a >= this.volumeThreshold;
2985
+ if (Math.random() < 0.01 && z.debug("Remote audio volume:", a, "threshold:", this.volumeThreshold, "above:", o), o)
2972
2986
  if (i)
2973
2987
  this.updateAgentState({ state: "speaking" });
2974
2988
  else if (this.isFirstAgentSpeech && this.monitorStartTime !== null) {
2975
- const l = performance.now() - this.monitorStartTime;
2976
- this.isFirstAgentSpeech = !1, this.thinkingStartTime = null, this.userSilenceStartTime = null, this.updateAgentState({ state: "speaking", greetingLatencyMs: l });
2989
+ const l = Math.round(performance.now() - this.monitorStartTime);
2990
+ this.isFirstAgentSpeech = !1, this.thinkingStartTime = null, this.userSilenceStartTime = null, this.userSpeechStartTime = null, this.updateAgentState({ state: "speaking", greetingLatencyMs: l });
2977
2991
  } else if (this.userSilenceStartTime !== null) {
2978
- const l = performance.now() - this.userSilenceStartTime;
2979
- this.thinkingStartTime = null, this.userSilenceStartTime = null, this.updateAgentState({ state: "speaking", userPerceivedLatencyMs: l });
2992
+ const l = Math.round(performance.now() - this.userSilenceStartTime);
2993
+ this.thinkingStartTime = null, this.userSilenceStartTime = null, this.maxLatencyMs === void 0 || l < this.maxLatencyMs ? this.updateAgentState({ state: "speaking", userPerceivedLatencyMs: l }) : this.updateAgentState({ state: "speaking" });
2980
2994
  } else
2981
2995
  this.updateAgentState({ state: "speaking" });
2982
2996
  else
2983
2997
  this.thinkingStartTime === null && this.updateAgentState({ state: "listening" });
2984
2998
  i = o;
2985
2999
  };
2986
- this.remoteIntervalId = window.setInterval(s, Nt);
3000
+ this.remoteIntervalId = window.setInterval(s, Dt);
2987
3001
  }
2988
3002
  /**
2989
3003
  * Monitor local stream (user's microphone) for VAD
@@ -2999,53 +3013,49 @@ class Ti {
2999
3013
  ), this.localAnalyser = this.localAudioContext.createAnalyser(), this.localSource.connect(this.localAnalyser), this.localAnalyser.fftSize = 512;
3000
3014
  const e = new Uint8Array(this.localAnalyser.frequencyBinCount), n = () => {
3001
3015
  this.localAnalyser?.getByteFrequencyData(e);
3002
- const i = e.reduce((r, o) => r + o, 0) / e.length;
3003
- Math.random() < 0.02 && z.debug("Local audio volume:", i);
3004
- const s = i >= Ze;
3005
- if (s && !this.userIsSpeaking)
3006
- this.userIsSpeaking = !0, this.lastUserAudioTime = performance.now();
3007
- else if (s && this.userIsSpeaking)
3008
- this.lastUserAudioTime = performance.now();
3009
- else if (!s && this.userIsSpeaking && this.lastUserAudioTime !== null && performance.now() - this.lastUserAudioTime > Ei) {
3010
- this.userIsSpeaking = !1, this.userSilenceStartTime = this.lastUserAudioTime, this.thinkingStartTime = performance.now();
3011
- const o = (/* @__PURE__ */ new Date()).toISOString();
3012
- this.updateAgentState({ state: "thinking", thinkingStartedAt: o });
3016
+ const i = e.reduce((a, o) => a + o, 0) / e.length;
3017
+ if (Math.random() < 0.02 && z.debug("Local audio volume:", i), i >= this.volumeThreshold)
3018
+ this.userIsSpeaking || (this.userIsSpeaking = !0, this.userSpeechStartTime = performance.now(), this.userSilenceStartTime = null), this.lastUserAudioTime = performance.now();
3019
+ 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)) {
3020
+ this.userIsSpeaking = !1, this.userSpeechStartTime = null, this.thinkingStartTime = performance.now();
3021
+ const l = (/* @__PURE__ */ new Date()).toISOString();
3022
+ this.updateAgentState({ state: "thinking", thinkingStartedAt: l });
3013
3023
  }
3014
3024
  };
3015
- this.localIntervalId = window.setInterval(n, Nt);
3025
+ this.localIntervalId = window.setInterval(n, Dt);
3016
3026
  }
3017
3027
  destroy() {
3018
3028
  this.stopAudioStreamMonitor();
3019
3029
  }
3020
3030
  }
3021
- function Ai(t) {
3031
+ function Ri(t) {
3022
3032
  if (!t || typeof t != "object")
3023
3033
  return !1;
3024
3034
  const e = t;
3025
3035
  return e.method === "ai_conversation" && typeof e.params == "object";
3026
3036
  }
3027
- function Ri(t) {
3037
+ function xi(t) {
3028
3038
  if (!t || typeof t != "object")
3029
3039
  return !1;
3030
3040
  const e = t;
3031
3041
  return e.params.type !== "response.text.delta" ? !1 : !!e.params.delta;
3032
3042
  }
3033
- function xi(t) {
3043
+ function Li(t) {
3034
3044
  if (!t || typeof t != "object")
3035
3045
  return !1;
3036
3046
  const e = t;
3037
3047
  return e.params.type !== "conversation.item.created" ? !1 : !!e.params.item.content;
3038
3048
  }
3039
3049
  function Oi(t) {
3040
- return Ri(t) ? {
3050
+ return xi(t) ? {
3041
3051
  id: `${t.params.item_id}-${Date.now()}`,
3042
3052
  role: "assistant",
3043
3053
  content: t.params.delta,
3044
3054
  timestamp: /* @__PURE__ */ new Date()
3045
3055
  } : null;
3046
3056
  }
3047
- function Li(t) {
3048
- if (!xi(t) || t.params.item.role !== "user" || t.params.item.status !== "completed")
3057
+ function Mi(t) {
3058
+ if (!Li(t) || t.params.item.role !== "user" || t.params.item.status !== "completed")
3049
3059
  return null;
3050
3060
  let e = "", n = [];
3051
3061
  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, {
@@ -3056,29 +3066,29 @@ function Li(t) {
3056
3066
  attachments: n
3057
3067
  };
3058
3068
  }
3059
- class Mi extends gt {
3069
+ class Pi extends ft {
3060
3070
  telnyxRTC;
3061
3071
  transcript = [];
3062
3072
  constructor(e) {
3063
- super(), this.telnyxRTC = e, this.telnyxRTC.on(O.SocketMessage, this.onSocketMessage);
3073
+ super(), this.telnyxRTC = e, this.telnyxRTC.on(L.SocketMessage, this.onSocketMessage);
3064
3074
  }
3065
3075
  onSocketMessage = (e) => {
3066
- if (Ai(e))
3076
+ if (Ri(e))
3067
3077
  switch (e.params.type) {
3068
3078
  case "response.text.delta": {
3069
3079
  const n = Oi(e);
3070
- n && (this.transcript.push(n), this.emit("transcript.item", n), $e.emit("conversation.agent.state", { state: "listening" }));
3080
+ n && (this.transcript.push(n), this.emit("transcript.item", n), Fe.emit("conversation.agent.state", { state: "listening" }));
3071
3081
  return;
3072
3082
  }
3073
3083
  case "conversation.item.created": {
3074
- const n = Li(e);
3084
+ const n = Mi(e);
3075
3085
  n && (this.transcript.push(n), this.emit("transcript.item", n));
3076
3086
  return;
3077
3087
  }
3078
3088
  }
3079
3089
  };
3080
3090
  }
3081
- class jt extends gt {
3091
+ class Nt extends ft {
3082
3092
  telnyxRTC;
3083
3093
  transcription;
3084
3094
  agentId;
@@ -3087,7 +3097,7 @@ class jt extends gt {
3087
3097
  audioStreamMonitor;
3088
3098
  activeCall;
3089
3099
  constructor(e) {
3090
- 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({
3100
+ 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({
3091
3101
  // @ts-expect-error hidden argument
3092
3102
  environment: e.environment || "production",
3093
3103
  anonymous_login: {
@@ -3097,10 +3107,10 @@ class jt extends gt {
3097
3107
  },
3098
3108
  debug: e.debug || !1,
3099
3109
  trickleIce: e.trickleIce
3100
- }), 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(
3110
+ }), 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(
3101
3111
  "conversation.agent.state",
3102
3112
  this.onAgentStateChange
3103
- ), this.audioStreamMonitor = new Ti();
3113
+ ), this.audioStreamMonitor = new Ai(e.vad);
3104
3114
  }
3105
3115
  /**
3106
3116
  * Connects to the Telnyx WebRTC service and establishes a session with the AI agent.
@@ -3115,7 +3125,7 @@ class jt extends gt {
3115
3125
  * Emits an 'agent.disconnected' event before completing cleanup.
3116
3126
  */
3117
3127
  async disconnect() {
3118
- 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();
3128
+ 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();
3119
3129
  }
3120
3130
  /**
3121
3131
  * Sends a text message to the AI agent during an active conversation.
@@ -3179,7 +3189,7 @@ class jt extends gt {
3179
3189
  (h) => h.mimeType.toLowerCase().includes("opus")
3180
3190
  ), {
3181
3191
  customHeaders: s,
3182
- audio: r,
3192
+ audio: a,
3183
3193
  ...o
3184
3194
  } = e || {}, l = s ? [...s] : [];
3185
3195
  this.versionId && l.push({
@@ -3189,7 +3199,7 @@ class jt extends gt {
3189
3199
  const d = this.telnyxRTC.newCall({
3190
3200
  destinationNumber: "xxx",
3191
3201
  ...o,
3192
- audio: r ?? !0,
3202
+ audio: a ?? !0,
3193
3203
  preferred_codecs: [i],
3194
3204
  customHeaders: l.length > 0 ? l : void 0
3195
3205
  });
@@ -3229,33 +3239,33 @@ class jt extends gt {
3229
3239
  this.emit("conversation.agent.state", e);
3230
3240
  };
3231
3241
  }
3232
- var Me = { exports: {} }, _e = {};
3242
+ var Me = { exports: {} }, Se = {};
3233
3243
  var Ut;
3234
- function Pi() {
3235
- if (Ut) return _e;
3244
+ function Di() {
3245
+ if (Ut) return Se;
3236
3246
  Ut = 1;
3237
3247
  var t = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
3238
- function n(i, s, r) {
3248
+ function n(i, s, a) {
3239
3249
  var o = null;
3240
- if (r !== void 0 && (o = "" + r), s.key !== void 0 && (o = "" + s.key), "key" in s) {
3241
- r = {};
3250
+ if (a !== void 0 && (o = "" + a), s.key !== void 0 && (o = "" + s.key), "key" in s) {
3251
+ a = {};
3242
3252
  for (var l in s)
3243
- l !== "key" && (r[l] = s[l]);
3244
- } else r = s;
3245
- return s = r.ref, {
3253
+ l !== "key" && (a[l] = s[l]);
3254
+ } else a = s;
3255
+ return s = a.ref, {
3246
3256
  $$typeof: t,
3247
3257
  type: i,
3248
3258
  key: o,
3249
3259
  ref: s !== void 0 ? s : null,
3250
- props: r
3260
+ props: a
3251
3261
  };
3252
3262
  }
3253
- return _e.Fragment = e, _e.jsx = n, _e.jsxs = n, _e;
3263
+ return Se.Fragment = e, Se.jsx = n, Se.jsxs = n, Se;
3254
3264
  }
3255
- var Se = {};
3256
- var $t;
3257
- function Di() {
3258
- return $t || ($t = 1, process.env.NODE_ENV !== "production" && (function() {
3265
+ var _e = {};
3266
+ var jt;
3267
+ function Ni() {
3268
+ return jt || (jt = 1, process.env.NODE_ENV !== "production" && (function() {
3259
3269
  function t(m) {
3260
3270
  if (m == null) return null;
3261
3271
  if (typeof m == "function")
@@ -3266,7 +3276,7 @@ function Di() {
3266
3276
  return "Fragment";
3267
3277
  case A:
3268
3278
  return "Profiler";
3269
- case S:
3279
+ case _:
3270
3280
  return "StrictMode";
3271
3281
  case q:
3272
3282
  return "Suspense";
@@ -3290,7 +3300,7 @@ function Di() {
3290
3300
  return m = m.displayName, m || (m = M.displayName || M.name || "", m = m !== "" ? "ForwardRef(" + m + ")" : "ForwardRef"), m;
3291
3301
  case x:
3292
3302
  return M = m.displayName || null, M !== null ? M : t(m.type) || "Memo";
3293
- case a:
3303
+ case r:
3294
3304
  M = m._payload, m = m._init;
3295
3305
  try {
3296
3306
  return t(m(M));
@@ -3311,8 +3321,8 @@ function Di() {
3311
3321
  }
3312
3322
  if (M) {
3313
3323
  M = console;
3314
- var j = M.error, V = typeof Symbol == "function" && Symbol.toStringTag && m[Symbol.toStringTag] || m.constructor.name || "Object";
3315
- return j.call(
3324
+ var U = M.error, V = typeof Symbol == "function" && Symbol.toStringTag && m[Symbol.toStringTag] || m.constructor.name || "Object";
3325
+ return U.call(
3316
3326
  M,
3317
3327
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
3318
3328
  V
@@ -3321,7 +3331,7 @@ function Di() {
3321
3331
  }
3322
3332
  function i(m) {
3323
3333
  if (m === p) return "<>";
3324
- if (typeof m == "object" && m !== null && m.$$typeof === a)
3334
+ if (typeof m == "object" && m !== null && m.$$typeof === r)
3325
3335
  return "<...>";
3326
3336
  try {
3327
3337
  var M = t(m);
@@ -3334,7 +3344,7 @@ function Di() {
3334
3344
  var m = g.A;
3335
3345
  return m === null ? null : m.getOwner();
3336
3346
  }
3337
- function r() {
3347
+ function a() {
3338
3348
  return Error("react-stack-top-frame");
3339
3349
  }
3340
3350
  function o(m) {
@@ -3345,30 +3355,30 @@ function Di() {
3345
3355
  return m.key !== void 0;
3346
3356
  }
3347
3357
  function l(m, M) {
3348
- function j() {
3358
+ function U() {
3349
3359
  R || (R = !0, console.error(
3350
3360
  "%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)",
3351
3361
  M
3352
3362
  ));
3353
3363
  }
3354
- j.isReactWarning = !0, Object.defineProperty(m, "key", {
3355
- get: j,
3364
+ U.isReactWarning = !0, Object.defineProperty(m, "key", {
3365
+ get: U,
3356
3366
  configurable: !0
3357
3367
  });
3358
3368
  }
3359
3369
  function d() {
3360
3370
  var m = t(this.type);
3361
- return U[m] || (U[m] = !0, console.error(
3371
+ return j[m] || (j[m] = !0, console.error(
3362
3372
  "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."
3363
3373
  )), m = this.props.ref, m !== void 0 ? m : null;
3364
3374
  }
3365
- function h(m, M, j, V, Y, Q) {
3366
- var W = j.ref;
3375
+ function h(m, M, U, V, Y, Q) {
3376
+ var W = U.ref;
3367
3377
  return m = {
3368
3378
  $$typeof: C,
3369
3379
  type: m,
3370
3380
  key: M,
3371
- props: j,
3381
+ props: U,
3372
3382
  _owner: V
3373
3383
  }, (W !== void 0 ? W : null) !== null ? Object.defineProperty(m, "ref", {
3374
3384
  enumerable: !1,
@@ -3395,7 +3405,7 @@ function Di() {
3395
3405
  value: Q
3396
3406
  }), Object.freeze && (Object.freeze(m.props), Object.freeze(m)), m;
3397
3407
  }
3398
- function f(m, M, j, V, Y, Q) {
3408
+ function f(m, M, U, V, Y, Q) {
3399
3409
  var W = M.children;
3400
3410
  if (W !== void 0)
3401
3411
  if (V)
@@ -3410,8 +3420,8 @@ function Di() {
3410
3420
  else v(W);
3411
3421
  if (b.call(M, "key")) {
3412
3422
  W = t(m);
3413
- var re = Object.keys(M).filter(function(En) {
3414
- return En !== "key";
3423
+ var re = Object.keys(M).filter(function(In) {
3424
+ return In !== "key";
3415
3425
  });
3416
3426
  V = 0 < re.length ? "{key: someKey, " + re.join(": ..., ") + ": ...}" : "{key: someKey}", G[W + V] || (re = 0 < re.length ? "{" + re.join(": ..., ") + ": ...}" : "{}", console.error(
3417
3427
  `A props object containing a "key" prop is being spread into JSX:
@@ -3426,30 +3436,30 @@ React keys must be passed directly to JSX without using spread:
3426
3436
  W
3427
3437
  ), G[W + V] = !0);
3428
3438
  }
3429
- if (W = null, j !== void 0 && (n(j), W = "" + j), o(M) && (n(M.key), W = "" + M.key), "key" in M) {
3430
- j = {};
3439
+ if (W = null, U !== void 0 && (n(U), W = "" + U), o(M) && (n(M.key), W = "" + M.key), "key" in M) {
3440
+ U = {};
3431
3441
  for (var ze in M)
3432
- ze !== "key" && (j[ze] = M[ze]);
3433
- } else j = M;
3442
+ ze !== "key" && (U[ze] = M[ze]);
3443
+ } else U = M;
3434
3444
  return W && l(
3435
- j,
3445
+ U,
3436
3446
  typeof m == "function" ? m.displayName || m.name || "Unknown" : m
3437
3447
  ), h(
3438
3448
  m,
3439
3449
  W,
3440
- j,
3450
+ U,
3441
3451
  s(),
3442
3452
  Y,
3443
3453
  Q
3444
3454
  );
3445
3455
  }
3446
3456
  function v(m) {
3447
- _(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));
3457
+ S(m) ? m._store && (m._store.validated = 1) : typeof m == "object" && m !== null && m.$$typeof === r && (m._payload.status === "fulfilled" ? S(m._payload.value) && m._payload.value._store && (m._payload.value._store.validated = 1) : m._store && (m._store.validated = 1));
3448
3458
  }
3449
- function _(m) {
3459
+ function S(m) {
3450
3460
  return typeof m == "object" && m !== null && m.$$typeof === C;
3451
3461
  }
3452
- 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() {
3462
+ var w = ut, C = Symbol.for("react.transitional.element"), k = Symbol.for("react.portal"), p = Symbol.for("react.fragment"), _ = 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() {
3453
3463
  return null;
3454
3464
  };
3455
3465
  w = {
@@ -3457,49 +3467,49 @@ React keys must be passed directly to JSX without using spread:
3457
3467
  return m();
3458
3468
  }
3459
3469
  };
3460
- var R, U = {}, ee = w.react_stack_bottom_frame.bind(
3470
+ var R, j = {}, ee = w.react_stack_bottom_frame.bind(
3461
3471
  w,
3462
- r
3463
- )(), ne = I(i(r)), G = {};
3464
- Se.Fragment = p, Se.jsx = function(m, M, j) {
3472
+ a
3473
+ )(), ne = I(i(a)), G = {};
3474
+ _e.Fragment = p, _e.jsx = function(m, M, U) {
3465
3475
  var V = 1e4 > g.recentlyCreatedOwnerStacks++;
3466
3476
  return f(
3467
3477
  m,
3468
3478
  M,
3469
- j,
3479
+ U,
3470
3480
  !1,
3471
3481
  V ? Error("react-stack-top-frame") : ee,
3472
3482
  V ? I(i(m)) : ne
3473
3483
  );
3474
- }, Se.jsxs = function(m, M, j) {
3484
+ }, _e.jsxs = function(m, M, U) {
3475
3485
  var V = 1e4 > g.recentlyCreatedOwnerStacks++;
3476
3486
  return f(
3477
3487
  m,
3478
3488
  M,
3479
- j,
3489
+ U,
3480
3490
  !0,
3481
3491
  V ? Error("react-stack-top-frame") : ee,
3482
3492
  V ? I(i(m)) : ne
3483
3493
  );
3484
3494
  };
3485
- })()), Se;
3495
+ })()), _e;
3486
3496
  }
3487
3497
  var Ft;
3488
- function Ni() {
3489
- return Ft || (Ft = 1, process.env.NODE_ENV === "production" ? Me.exports = Pi() : Me.exports = Di()), Me.exports;
3498
+ function Ui() {
3499
+ return Ft || (Ft = 1, process.env.NODE_ENV === "production" ? Me.exports = Di() : Me.exports = Ni()), Me.exports;
3490
3500
  }
3491
- var we = Ni();
3501
+ var we = Ui();
3492
3502
  const ce = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
3493
- function hn(t) {
3503
+ function un(t) {
3494
3504
  return "init" in t;
3495
3505
  }
3496
- function at(t) {
3506
+ function rt(t) {
3497
3507
  return !!t.write;
3498
3508
  }
3499
- function Bt(t) {
3509
+ function $t(t) {
3500
3510
  return "v" in t || "e" in t;
3501
3511
  }
3502
- function Fe(t) {
3512
+ function $e(t) {
3503
3513
  if ("e" in t)
3504
3514
  throw t.e;
3505
3515
  if ((ce ? "production" : void 0) !== "production" && !("v" in t))
@@ -3507,7 +3517,7 @@ function Fe(t) {
3507
3517
  return t.v;
3508
3518
  }
3509
3519
  const Be = /* @__PURE__ */ new WeakMap();
3510
- function pn(t) {
3520
+ function hn(t) {
3511
3521
  var e;
3512
3522
  return Ve(t) && !!((e = Be.get(t)) != null && e[0]);
3513
3523
  }
@@ -3515,7 +3525,7 @@ function ji(t) {
3515
3525
  const e = Be.get(t);
3516
3526
  e?.[0] && (e[0] = !1, e[1].forEach((n) => n()));
3517
3527
  }
3518
- function ct(t, e) {
3528
+ function at(t, e) {
3519
3529
  let n = Be.get(t);
3520
3530
  if (!n) {
3521
3531
  n = [!0, /* @__PURE__ */ new Set()], Be.set(t, n);
@@ -3529,41 +3539,41 @@ function ct(t, e) {
3529
3539
  function Ve(t) {
3530
3540
  return typeof t?.then == "function";
3531
3541
  }
3532
- function fn(t, e, n) {
3542
+ function pn(t, e, n) {
3533
3543
  if (!n.p.has(t)) {
3534
3544
  n.p.add(t);
3535
3545
  const i = () => n.p.delete(t);
3536
3546
  e.then(i, i);
3537
3547
  }
3538
3548
  }
3539
- function gn(t, e, n) {
3549
+ function fn(t, e, n) {
3540
3550
  var i;
3541
3551
  const s = /* @__PURE__ */ new Set();
3542
- for (const r of ((i = n.get(t)) == null ? void 0 : i.t) || [])
3543
- s.add(r);
3544
- for (const r of e.p)
3545
- s.add(r);
3552
+ for (const a of ((i = n.get(t)) == null ? void 0 : i.t) || [])
3553
+ s.add(a);
3554
+ for (const a of e.p)
3555
+ s.add(a);
3546
3556
  return s;
3547
3557
  }
3548
- const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi = (t, e) => {
3558
+ const Fi = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Bi = (t, e) => {
3549
3559
  if (e.INTERNAL_onInit)
3550
3560
  return e.INTERNAL_onInit(t);
3551
3561
  if (e.unstable_onInit)
3552
3562
  return console.warn(
3553
3563
  "[DEPRECATED] atom.unstable_onInit is renamed to atom.INTERNAL_onInit."
3554
3564
  ), e.unstable_onInit(t);
3555
- }, Bi = (t, e, n) => {
3565
+ }, Vi = (t, e, n) => {
3556
3566
  var i;
3557
3567
  return (i = e.onMount) == null ? void 0 : i.call(e, n);
3558
- }, Vi = (t, e) => {
3568
+ }, Gi = (t, e) => {
3559
3569
  var n;
3560
- const i = X(t), s = i[0], r = i[6], o = i[9];
3570
+ const i = X(t), s = i[0], a = i[6], o = i[9];
3561
3571
  if ((ce ? "production" : void 0) !== "production" && !e)
3562
3572
  throw new Error("Atom is undefined or null");
3563
3573
  let l = s.get(e);
3564
- return l || (l = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, s.set(e, l), (n = r.i) == null || n.call(r, e), o?.(t, e)), l;
3565
- }, Gi = (t) => {
3566
- const e = X(t), n = e[1], i = e[3], s = e[4], r = e[5], o = e[6], l = e[13], d = [], h = (f) => {
3574
+ 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;
3575
+ }, Wi = (t) => {
3576
+ 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) => {
3567
3577
  try {
3568
3578
  f();
3569
3579
  } catch (v) {
@@ -3573,35 +3583,35 @@ const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi
3573
3583
  do {
3574
3584
  o.f && h(o.f);
3575
3585
  const f = /* @__PURE__ */ new Set(), v = f.add.bind(f);
3576
- i.forEach((_) => {
3586
+ i.forEach((S) => {
3577
3587
  var w;
3578
- return (w = n.get(_)) == null ? void 0 : w.l.forEach(v);
3579
- }), i.clear(), r.forEach(v), r.clear(), s.forEach(v), s.clear(), f.forEach(h), i.size && l(t);
3580
- } while (i.size || r.size || s.size);
3588
+ return (w = n.get(S)) == null ? void 0 : w.l.forEach(v);
3589
+ }), i.clear(), a.forEach(v), a.clear(), s.forEach(v), s.clear(), f.forEach(h), i.size && l(t);
3590
+ } while (i.size || a.size || s.size);
3581
3591
  if (d.length)
3582
3592
  throw new AggregateError(d);
3583
- }, Wi = (t) => {
3584
- const e = X(t), n = e[1], i = e[2], s = e[3], r = e[11], o = e[14], l = e[17], d = [], h = /* @__PURE__ */ new WeakSet(), f = /* @__PURE__ */ new WeakSet(), v = Array.from(s);
3593
+ }, Hi = (t) => {
3594
+ 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);
3585
3595
  for (; v.length; ) {
3586
- const _ = v[v.length - 1], w = r(t, _);
3587
- if (f.has(_)) {
3596
+ const S = v[v.length - 1], w = a(t, S);
3597
+ if (f.has(S)) {
3588
3598
  v.pop();
3589
3599
  continue;
3590
3600
  }
3591
- if (h.has(_)) {
3592
- if (i.get(_) === w.n)
3593
- d.push([_, w]);
3594
- else if ((ce ? "production" : void 0) !== "production" && i.has(_))
3601
+ if (h.has(S)) {
3602
+ if (i.get(S) === w.n)
3603
+ d.push([S, w]);
3604
+ else if ((ce ? "production" : void 0) !== "production" && i.has(S))
3595
3605
  throw new Error("[Bug] invalidated atom exists");
3596
- f.add(_), v.pop();
3606
+ f.add(S), v.pop();
3597
3607
  continue;
3598
3608
  }
3599
- h.add(_);
3600
- for (const C of gn(_, w, n))
3609
+ h.add(S);
3610
+ for (const C of fn(S, w, n))
3601
3611
  h.has(C) || v.push(C);
3602
3612
  }
3603
- for (let _ = d.length - 1; _ >= 0; --_) {
3604
- const [w, C] = d[_];
3613
+ for (let S = d.length - 1; S >= 0; --S) {
3614
+ const [w, C] = d[S];
3605
3615
  let k = !1;
3606
3616
  for (const p of C.d.keys())
3607
3617
  if (p !== w && s.has(p)) {
@@ -3610,15 +3620,15 @@ const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi
3610
3620
  }
3611
3621
  k && (o(t, w), l(t, w)), i.delete(w);
3612
3622
  }
3613
- }, lt = /* @__PURE__ */ new WeakSet(), Hi = (t, e) => {
3623
+ }, ct = /* @__PURE__ */ new WeakSet(), qi = (t, e) => {
3614
3624
  var n, i;
3615
- const s = X(t), r = 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);
3616
- if (Bt(p)) {
3617
- if (r.has(e) && o.get(e) !== p.n)
3625
+ 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 = s[13], w = s[14], C = s[16], k = s[17], p = f(t, e);
3626
+ if ($t(p)) {
3627
+ if (a.has(e) && o.get(e) !== p.n)
3618
3628
  return p;
3619
3629
  let x = !1;
3620
- for (const [a, c] of p.d)
3621
- if (w(t, a).n !== c) {
3630
+ for (const [r, c] of p.d)
3631
+ if (w(t, r).n !== c) {
3622
3632
  x = !0;
3623
3633
  break;
3624
3634
  }
@@ -3626,26 +3636,26 @@ const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi
3626
3636
  return p;
3627
3637
  }
3628
3638
  p.d.clear();
3629
- let S = !0;
3639
+ let _ = !0;
3630
3640
  function A() {
3631
- r.has(e) && (k(t, e), _(t), v(t));
3641
+ a.has(e) && (k(t, e), S(t), v(t));
3632
3642
  }
3633
3643
  function E(x) {
3634
- var a;
3644
+ var r;
3635
3645
  if (x === e) {
3636
3646
  const u = f(t, x);
3637
- if (!Bt(u))
3638
- if (hn(x))
3647
+ if (!$t(u))
3648
+ if (un(x))
3639
3649
  Ge(t, x, x.init);
3640
3650
  else
3641
3651
  throw new Error("no atom init");
3642
- return Fe(u);
3652
+ return $e(u);
3643
3653
  }
3644
3654
  const c = w(t, x);
3645
3655
  try {
3646
- return Fe(c);
3656
+ return $e(c);
3647
3657
  } finally {
3648
- 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();
3658
+ 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)), _ || A();
3649
3659
  }
3650
3660
  }
3651
3661
  let P, D;
@@ -3654,52 +3664,52 @@ const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi
3654
3664
  return P || (P = new AbortController()), P.signal;
3655
3665
  },
3656
3666
  get setSelf() {
3657
- return (ce ? "production" : void 0) !== "production" && !at(e) && console.warn("setSelf function cannot be used with read-only atom"), !D && at(e) && (D = (...x) => {
3658
- if ((ce ? "production" : void 0) !== "production" && S && console.warn("setSelf function cannot be called in sync"), !S)
3667
+ return (ce ? "production" : void 0) !== "production" && !rt(e) && console.warn("setSelf function cannot be used with read-only atom"), !D && rt(e) && (D = (...x) => {
3668
+ if ((ce ? "production" : void 0) !== "production" && _ && console.warn("setSelf function cannot be called in sync"), !_)
3659
3669
  try {
3660
3670
  return C(t, e, ...x);
3661
3671
  } finally {
3662
- _(t), v(t);
3672
+ S(t), v(t);
3663
3673
  }
3664
3674
  }), D;
3665
3675
  }
3666
3676
  }, B = p.n;
3667
3677
  try {
3668
- (ce ? "production" : void 0) !== "production" && lt.delete(t);
3678
+ (ce ? "production" : void 0) !== "production" && ct.delete(t);
3669
3679
  const x = h(t, e, E, q);
3670
- return (ce ? "production" : void 0) !== "production" && lt.has(t) && console.warn(
3680
+ return (ce ? "production" : void 0) !== "production" && ct.has(t) && console.warn(
3671
3681
  "Detected store mutation during atom read. This is not supported."
3672
- ), Ge(t, e, x), Ve(x) && (ct(x, () => P?.abort()), x.then(A, A)), (n = d.r) == null || n.call(d, e), p;
3682
+ ), Ge(t, e, x), Ve(x) && (at(x, () => P?.abort()), x.then(A, A)), (n = d.r) == null || n.call(d, e), p;
3673
3683
  } catch (x) {
3674
3684
  return delete p.v, p.e = x, ++p.n, p;
3675
3685
  } finally {
3676
- 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));
3686
+ _ = !1, B !== p.n && o.get(e) === B && (o.set(e, p.n), l.add(e), (i = d.c) == null || i.call(d, e));
3677
3687
  }
3678
- }, qi = (t, e) => {
3679
- const n = X(t), i = n[1], s = n[2], r = n[11], o = [e];
3688
+ }, Ji = (t, e) => {
3689
+ const n = X(t), i = n[1], s = n[2], a = n[11], o = [e];
3680
3690
  for (; o.length; ) {
3681
- const l = o.pop(), d = r(t, l);
3682
- for (const h of gn(l, d, i)) {
3683
- const f = r(t, h);
3691
+ const l = o.pop(), d = a(t, l);
3692
+ for (const h of fn(l, d, i)) {
3693
+ const f = a(t, h);
3684
3694
  s.set(h, f.n), o.push(h);
3685
3695
  }
3686
3696
  }
3687
- }, vn = (t, e, ...n) => {
3688
- const i = X(t), s = i[3], r = i[6], o = i[8], l = i[11], d = i[12], h = i[13], f = i[14], v = i[15], _ = i[17];
3697
+ }, gn = (t, e, ...n) => {
3698
+ 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], S = i[17];
3689
3699
  let w = !0;
3690
- const C = (p) => Fe(f(t, p)), k = (p, ...S) => {
3700
+ const C = (p) => $e(f(t, p)), k = (p, ..._) => {
3691
3701
  var A;
3692
3702
  const E = l(t, p);
3693
3703
  try {
3694
3704
  if (p === e) {
3695
- if (!hn(p))
3705
+ if (!un(p))
3696
3706
  throw new Error("atom not writable");
3697
- (ce ? "production" : void 0) !== "production" && lt.add(t);
3698
- const P = E.n, D = S[0];
3699
- Ge(t, p, D), _(t, p), P !== E.n && (s.add(p), v(t, p), (A = r.c) == null || A.call(r, p));
3707
+ (ce ? "production" : void 0) !== "production" && ct.add(t);
3708
+ const P = E.n, D = _[0];
3709
+ Ge(t, p, D), S(t, p), P !== E.n && (s.add(p), v(t, p), (A = a.c) == null || A.call(a, p));
3700
3710
  return;
3701
3711
  } else
3702
- return vn(t, p, ...S);
3712
+ return gn(t, p, ..._);
3703
3713
  } finally {
3704
3714
  w || (h(t), d(t));
3705
3715
  }
@@ -3709,46 +3719,46 @@ const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi
3709
3719
  } finally {
3710
3720
  w = !1;
3711
3721
  }
3712
- }, Ji = (t, e) => {
3722
+ }, Yi = (t, e) => {
3713
3723
  var n;
3714
- const i = X(t), s = i[1], r = i[3], o = i[6], l = i[11], d = i[15], h = i[18], f = i[19], v = l(t, e), _ = s.get(e);
3715
- if (_ && !pn(v.v)) {
3724
+ 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 = s.get(e);
3725
+ if (S && !hn(v.v)) {
3716
3726
  for (const [w, C] of v.d)
3717
- if (!_.d.has(w)) {
3727
+ if (!S.d.has(w)) {
3718
3728
  const k = l(t, w);
3719
- h(t, w).t.add(e), _.d.add(w), C !== k.n && (r.add(w), d(t, w), (n = o.c) == null || n.call(o, w));
3729
+ h(t, w).t.add(e), S.d.add(w), C !== k.n && (a.add(w), d(t, w), (n = o.c) == null || n.call(o, w));
3720
3730
  }
3721
- for (const w of _.d)
3731
+ for (const w of S.d)
3722
3732
  if (!v.d.has(w)) {
3723
- _.d.delete(w);
3733
+ S.d.delete(w);
3724
3734
  const C = f(t, w);
3725
3735
  C?.t.delete(e);
3726
3736
  }
3727
3737
  }
3728
- }, mn = (t, e) => {
3738
+ }, vn = (t, e) => {
3729
3739
  var n;
3730
- const i = X(t), s = i[1], r = 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);
3740
+ 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], S = i[16], w = d(t, e);
3731
3741
  let C = s.get(e);
3732
3742
  if (!C) {
3733
3743
  v(t, e);
3734
3744
  for (const k of w.d.keys())
3735
- mn(t, k).t.add(e);
3745
+ vn(t, k).t.add(e);
3736
3746
  if (C = {
3737
3747
  l: /* @__PURE__ */ new Set(),
3738
3748
  d: new Set(w.d.keys()),
3739
3749
  t: /* @__PURE__ */ new Set()
3740
- }, s.set(e, C), at(e)) {
3750
+ }, s.set(e, C), rt(e)) {
3741
3751
  const k = () => {
3742
3752
  let p = !0;
3743
- const S = (...A) => {
3753
+ const _ = (...A) => {
3744
3754
  try {
3745
- return _(t, e, ...A);
3755
+ return S(t, e, ...A);
3746
3756
  } finally {
3747
3757
  p || (f(t), h(t));
3748
3758
  }
3749
3759
  };
3750
3760
  try {
3751
- const A = l(t, e, S);
3761
+ const A = l(t, e, _);
3752
3762
  A && (C.u = () => {
3753
3763
  p = !0;
3754
3764
  try {
@@ -3761,25 +3771,25 @@ const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi
3761
3771
  p = !1;
3762
3772
  }
3763
3773
  };
3764
- r.add(k);
3774
+ a.add(k);
3765
3775
  }
3766
3776
  (n = o.m) == null || n.call(o, e);
3767
3777
  }
3768
3778
  return C;
3769
- }, Yi = (t, e) => {
3779
+ }, zi = (t, e) => {
3770
3780
  var n, i;
3771
- const s = X(t), r = s[1], o = s[5], l = s[6], d = s[11], h = s[19], f = d(t, e);
3772
- let v = r.get(e);
3781
+ const s = X(t), a = s[1], o = s[5], l = s[6], d = s[11], h = s[19], f = d(t, e);
3782
+ let v = a.get(e);
3773
3783
  if (!v || v.l.size)
3774
3784
  return v;
3775
- let _ = !1;
3785
+ let S = !1;
3776
3786
  for (const w of v.t)
3777
- if ((n = r.get(w)) != null && n.d.has(e)) {
3778
- _ = !0;
3787
+ if ((n = a.get(w)) != null && n.d.has(e)) {
3788
+ S = !0;
3779
3789
  break;
3780
3790
  }
3781
- if (!_) {
3782
- v.u && o.add(v.u), v = void 0, r.delete(e);
3791
+ if (!S) {
3792
+ v.u && o.add(v.u), v = void 0, a.delete(e);
3783
3793
  for (const w of f.d.keys()) {
3784
3794
  const C = h(t, w);
3785
3795
  C?.t.delete(e);
@@ -3789,51 +3799,51 @@ const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi
3789
3799
  }
3790
3800
  return v;
3791
3801
  }, Ge = (t, e, n) => {
3792
- const i = X(t)[11], s = i(t, e), r = "v" in s, o = s.v;
3802
+ const i = X(t)[11], s = i(t, e), a = "v" in s, o = s.v;
3793
3803
  if (Ve(n))
3794
3804
  for (const l of s.d.keys())
3795
- fn(
3805
+ pn(
3796
3806
  e,
3797
3807
  n,
3798
3808
  i(t, l)
3799
3809
  );
3800
- s.v = n, delete s.e, (!r || !Object.is(o, s.v)) && (++s.n, Ve(o) && ji(o));
3801
- }, zi = (t, e) => {
3810
+ s.v = n, delete s.e, (!a || !Object.is(o, s.v)) && (++s.n, Ve(o) && ji(o));
3811
+ }, Ki = (t, e) => {
3802
3812
  const n = X(t)[14];
3803
- return Fe(n(t, e));
3804
- }, Ki = (t, e, ...n) => {
3805
- const i = X(t), s = i[12], r = i[13], o = i[16];
3813
+ return $e(n(t, e));
3814
+ }, Qi = (t, e, ...n) => {
3815
+ const i = X(t), s = i[12], a = i[13], o = i[16];
3806
3816
  try {
3807
3817
  return o(t, e, ...n);
3808
3818
  } finally {
3809
- r(t), s(t);
3819
+ a(t), s(t);
3810
3820
  }
3811
- }, Qi = (t, e, n) => {
3812
- const i = X(t), s = i[12], r = i[18], o = i[19], d = r(t, e).l;
3821
+ }, Xi = (t, e, n) => {
3822
+ const i = X(t), s = i[12], a = i[18], o = i[19], d = a(t, e).l;
3813
3823
  return d.add(n), s(t), () => {
3814
3824
  d.delete(n), o(t, e), s(t);
3815
3825
  };
3816
- }, yn = /* @__PURE__ */ new WeakMap(), X = (t) => {
3817
- const e = yn.get(t);
3826
+ }, mn = /* @__PURE__ */ new WeakMap(), X = (t) => {
3827
+ const e = mn.get(t);
3818
3828
  if ((ce ? "production" : void 0) !== "production" && !e)
3819
3829
  throw new Error(
3820
3830
  "Store must be created by buildStore to read its building blocks"
3821
3831
  );
3822
3832
  return e;
3823
3833
  };
3824
- function Xi(...t) {
3834
+ function Zi(...t) {
3825
3835
  const e = {
3826
3836
  get(i) {
3827
3837
  const s = X(e)[21];
3828
3838
  return s(e, i);
3829
3839
  },
3830
3840
  set(i, ...s) {
3831
- const r = X(e)[22];
3832
- return r(e, i, ...s);
3841
+ const a = X(e)[22];
3842
+ return a(e, i, ...s);
3833
3843
  },
3834
3844
  sub(i, s) {
3835
- const r = X(e)[23];
3836
- return r(e, i, s);
3845
+ const a = X(e)[23];
3846
+ return a(e, i, s);
3837
3847
  }
3838
3848
  }, n = [
3839
3849
  // store state
@@ -3852,63 +3862,63 @@ function Xi(...t) {
3852
3862
  {},
3853
3863
  // storeHooks
3854
3864
  // atom interceptors
3855
- Ui,
3856
- $i,
3857
3865
  Fi,
3866
+ $i,
3858
3867
  Bi,
3859
- // building-block functions
3860
3868
  Vi,
3869
+ // building-block functions
3861
3870
  Gi,
3862
3871
  Wi,
3863
3872
  Hi,
3864
3873
  qi,
3865
- vn,
3866
3874
  Ji,
3867
- mn,
3875
+ gn,
3868
3876
  Yi,
3869
- Ge,
3877
+ vn,
3870
3878
  zi,
3879
+ Ge,
3871
3880
  Ki,
3872
3881
  Qi,
3882
+ Xi,
3873
3883
  void 0
3874
3884
  ].map((i, s) => t[s] || i);
3875
- return yn.set(e, Object.freeze(n)), e;
3885
+ return mn.set(e, Object.freeze(n)), e;
3876
3886
  }
3877
- const bn = {};
3878
- let Zi = 0;
3887
+ const yn = {};
3888
+ let es = 0;
3879
3889
  function He(t, e) {
3880
- const n = `atom${++Zi}`, i = {
3890
+ const n = `atom${++es}`, i = {
3881
3891
  toString() {
3882
- return (bn ? "production" : void 0) !== "production" && this.debugLabel ? n + ":" + this.debugLabel : n;
3892
+ return (yn ? "production" : void 0) !== "production" && this.debugLabel ? n + ":" + this.debugLabel : n;
3883
3893
  }
3884
3894
  };
3885
- return typeof t == "function" ? i.read = t : (i.init = t, i.read = es, i.write = ts), i;
3895
+ return typeof t == "function" ? i.read = t : (i.init = t, i.read = ts, i.write = ns), i;
3886
3896
  }
3887
- function es(t) {
3897
+ function ts(t) {
3888
3898
  return t(this);
3889
3899
  }
3890
- function ts(t, e, n) {
3900
+ function ns(t, e, n) {
3891
3901
  return e(
3892
3902
  this,
3893
3903
  typeof n == "function" ? n(t(this)) : n
3894
3904
  );
3895
3905
  }
3896
- function ns() {
3897
- return Xi();
3906
+ function is() {
3907
+ return Zi();
3898
3908
  }
3899
3909
  let Ce;
3900
- function is() {
3901
- 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(
3910
+ function ss() {
3911
+ 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(
3902
3912
  "Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
3903
3913
  ))), Ce;
3904
3914
  }
3905
- const ss = {}, os = Wt(
3915
+ const os = {}, rs = Gt(
3906
3916
  void 0
3907
3917
  );
3908
- function _n(t) {
3909
- return Gt(os) || is();
3918
+ function bn(t) {
3919
+ return Vt(rs) || ss();
3910
3920
  }
3911
- const dt = (t) => typeof t?.then == "function", ut = (t) => {
3921
+ const lt = (t) => typeof t?.then == "function", dt = (t) => {
3912
3922
  t.status || (t.status = "pending", t.then(
3913
3923
  (e) => {
3914
3924
  t.status = "fulfilled", t.value = e;
@@ -3917,34 +3927,34 @@ const dt = (t) => typeof t?.then == "function", ut = (t) => {
3917
3927
  t.status = "rejected", t.reason = e;
3918
3928
  }
3919
3929
  ));
3920
- }, rs = ht.use || // A shim for older React versions
3930
+ }, as = ut.use || // A shim for older React versions
3921
3931
  ((t) => {
3922
3932
  if (t.status === "pending")
3923
3933
  throw t;
3924
3934
  if (t.status === "fulfilled")
3925
3935
  return t.value;
3926
- throw t.status === "rejected" ? t.reason : (ut(t), t);
3927
- }), et = /* @__PURE__ */ new WeakMap(), Vt = (t, e) => {
3928
- let n = et.get(t);
3936
+ throw t.status === "rejected" ? t.reason : (dt(t), t);
3937
+ }), Ze = /* @__PURE__ */ new WeakMap(), Bt = (t, e) => {
3938
+ let n = Ze.get(t);
3929
3939
  return n || (n = new Promise((i, s) => {
3930
- let r = t;
3940
+ let a = t;
3931
3941
  const o = (h) => (f) => {
3932
- r === h && i(f);
3942
+ a === h && i(f);
3933
3943
  }, l = (h) => (f) => {
3934
- r === h && s(f);
3944
+ a === h && s(f);
3935
3945
  }, d = () => {
3936
3946
  try {
3937
3947
  const h = e();
3938
- dt(h) ? (et.set(h, n), r = h, h.then(o(h), l(h)), ct(h, d)) : i(h);
3948
+ lt(h) ? (Ze.set(h, n), a = h, h.then(o(h), l(h)), at(h, d)) : i(h);
3939
3949
  } catch (h) {
3940
3950
  s(h);
3941
3951
  }
3942
3952
  };
3943
- t.then(o(t), l(t)), ct(t, d);
3944
- }), et.set(t, n)), n;
3953
+ t.then(o(t), l(t)), at(t, d);
3954
+ }), Ze.set(t, n)), n;
3945
3955
  };
3946
3956
  function qe(t, e) {
3947
- const { delay: n, unstable_promiseStatus: i = !ht.use } = {}, s = _n(), [[r, o, l], d] = Tn(
3957
+ const { delay: n, unstable_promiseStatus: i = !ut.use } = {}, s = bn(), [[a, o, l], d] = En(
3948
3958
  (f) => {
3949
3959
  const v = s.get(t);
3950
3960
  return Object.is(f[0], v) && f[1] === s && f[2] === t ? f : [v, s, t];
@@ -3952,14 +3962,14 @@ function qe(t, e) {
3952
3962
  void 0,
3953
3963
  () => [s.get(t), s, t]
3954
3964
  );
3955
- let h = r;
3965
+ let h = a;
3956
3966
  if ((o !== s || l !== t) && (d(), h = s.get(t)), pe(() => {
3957
3967
  const f = s.sub(t, () => {
3958
3968
  if (i)
3959
3969
  try {
3960
3970
  const v = s.get(t);
3961
- dt(v) && ut(
3962
- Vt(v, () => s.get(t))
3971
+ lt(v) && dt(
3972
+ Bt(v, () => s.get(t))
3963
3973
  );
3964
3974
  } catch {
3965
3975
  }
@@ -3970,17 +3980,17 @@ function qe(t, e) {
3970
3980
  d();
3971
3981
  });
3972
3982
  return d(), f;
3973
- }, [s, t, n, i]), An(h), dt(h)) {
3974
- const f = Vt(h, () => s.get(t));
3975
- return i && ut(f), rs(f);
3983
+ }, [s, t, n, i]), Tn(h), lt(h)) {
3984
+ const f = Bt(h, () => s.get(t));
3985
+ return i && dt(f), as(f);
3976
3986
  }
3977
3987
  return h;
3978
3988
  }
3979
3989
  function Je(t, e) {
3980
- const n = _n();
3981
- return Rn(
3990
+ const n = bn();
3991
+ return An(
3982
3992
  (...s) => {
3983
- if ((ss ? "production" : void 0) !== "production" && !("write" in t))
3993
+ if ((os ? "production" : void 0) !== "production" && !("write" in t))
3984
3994
  throw new Error("not writable atom");
3985
3995
  return n.set(t, ...s);
3986
3996
  },
@@ -3988,20 +3998,20 @@ function Je(t, e) {
3988
3998
  );
3989
3999
  }
3990
4000
  const Sn = He([]);
3991
- function vs() {
4001
+ function ms() {
3992
4002
  return qe(Sn);
3993
4003
  }
3994
- function as() {
4004
+ function cs() {
3995
4005
  return Je(Sn);
3996
4006
  }
3997
4007
  const Ye = () => {
3998
- const t = Gt(In);
4008
+ const t = Vt(kn);
3999
4009
  if (!t)
4000
4010
  throw new Error("useClient must be used within a TelnyxAIAgentProvider");
4001
4011
  return t;
4002
4012
  };
4003
- function cs() {
4004
- const t = Ye(), e = as();
4013
+ function ls() {
4014
+ const t = Ye(), e = cs();
4005
4015
  return pe(() => {
4006
4016
  const n = (i) => e((s) => [...s, i]);
4007
4017
  return t.addListener("transcript.item", n), () => {
@@ -4009,15 +4019,15 @@ function cs() {
4009
4019
  };
4010
4020
  }, [t, e]), null;
4011
4021
  }
4012
- const wn = He("connecting");
4013
- function ms() {
4014
- return qe(wn);
4015
- }
4016
- function ls() {
4017
- return Je(wn);
4022
+ const _n = He("connecting");
4023
+ function ys() {
4024
+ return qe(_n);
4018
4025
  }
4019
4026
  function ds() {
4020
- const t = Ye(), e = ls();
4027
+ return Je(_n);
4028
+ }
4029
+ function us() {
4030
+ const t = Ye(), e = ds();
4021
4031
  return pe(() => {
4022
4032
  const n = () => e("connected"), i = () => e("disconnected"), s = () => e("error");
4023
4033
  return t.addListener("agent.connected", n), t.addListener("agent.disconnected", i), t.addListener("agent.error", s), () => {
@@ -4025,15 +4035,15 @@ function ds() {
4025
4035
  };
4026
4036
  }, [t, e]), null;
4027
4037
  }
4028
- const Cn = He(null);
4029
- function ys() {
4030
- return qe(Cn);
4038
+ const wn = He(null);
4039
+ function bs() {
4040
+ return qe(wn);
4031
4041
  }
4032
- function us() {
4033
- return Je(Cn);
4042
+ function hs() {
4043
+ return Je(wn);
4034
4044
  }
4035
- const hs = () => {
4036
- const t = Ye(), e = us();
4045
+ const ps = () => {
4046
+ const t = Ye(), e = hs();
4037
4047
  return pe(() => {
4038
4048
  const n = (i) => {
4039
4049
  e(i);
@@ -4042,15 +4052,15 @@ const hs = () => {
4042
4052
  t.removeListener("conversation.update", n);
4043
4053
  };
4044
4054
  }, [t, e]), null;
4045
- }, kn = He({ state: "listening" });
4046
- function bs() {
4047
- return qe(kn);
4048
- }
4049
- function ps() {
4050
- return Je(kn);
4055
+ }, Cn = He({ state: "listening" });
4056
+ function Ss() {
4057
+ return qe(Cn);
4051
4058
  }
4052
4059
  function fs() {
4053
- const t = Ye(), e = ps();
4060
+ return Je(Cn);
4061
+ }
4062
+ function gs() {
4063
+ const t = Ye(), e = fs();
4054
4064
  return pe(() => {
4055
4065
  const n = (i) => {
4056
4066
  e(i);
@@ -4060,43 +4070,44 @@ function fs() {
4060
4070
  };
4061
4071
  }, [t, e]), null;
4062
4072
  }
4063
- const In = Wt(null), _s = ({
4073
+ const kn = Gt(null), _s = ({
4064
4074
  children: t,
4065
4075
  agentId: e,
4066
4076
  environment: n,
4067
4077
  versionId: i,
4068
- debug: s
4078
+ debug: s,
4079
+ vad: a
4069
4080
  }) => {
4070
- const [r, o] = xn(() => new jt({ agentId: e, environment: n, versionId: i, debug: s }));
4081
+ const [o, l] = Rn(() => new Nt({ agentId: e, environment: n, versionId: i, debug: s, vad: a }));
4071
4082
  return pe(() => {
4072
- if (!r) {
4073
- const l = new jt({ agentId: e, environment: n, versionId: i });
4074
- return o(l), () => {
4075
- l.disconnect();
4083
+ if (!o) {
4084
+ const d = new Nt({ agentId: e, environment: n, versionId: i, vad: a });
4085
+ return l(d), () => {
4086
+ d.disconnect();
4076
4087
  };
4077
4088
  }
4078
- }, [e, r, n, i]), pe(() => {
4079
- r?.connect();
4080
- }, [r]), /* @__PURE__ */ we.jsxs(In.Provider, { value: r, children: [
4081
- /* @__PURE__ */ we.jsx(cs, {}),
4082
- /* @__PURE__ */ we.jsx(ds, {}),
4083
- /* @__PURE__ */ we.jsx(hs, {}),
4084
- /* @__PURE__ */ we.jsx(fs, {}),
4089
+ }, [e, o, n, i, a]), pe(() => {
4090
+ o?.connect();
4091
+ }, [o]), /* @__PURE__ */ we.jsxs(kn.Provider, { value: o, children: [
4092
+ /* @__PURE__ */ we.jsx(ls, {}),
4093
+ /* @__PURE__ */ we.jsx(us, {}),
4094
+ /* @__PURE__ */ we.jsx(ps, {}),
4095
+ /* @__PURE__ */ we.jsx(gs, {}),
4085
4096
  t
4086
4097
  ] });
4087
4098
  };
4088
4099
  export {
4089
- In as ClientContext,
4090
- O as SwEvent,
4091
- jt as TelnyxAIAgent,
4100
+ kn as ClientContext,
4101
+ L as SwEvent,
4102
+ Nt as TelnyxAIAgent,
4092
4103
  _s as TelnyxAIAgentProvider,
4093
- bs as useAgentState,
4104
+ Ss as useAgentState,
4094
4105
  Ye as useClient,
4095
- ms as useConnectionState,
4096
- ys as useConversation,
4097
- ps as useSetAgentState,
4098
- ls as useSetConnectionState,
4099
- us as useSetConversation,
4100
- as as useSetTranscript,
4101
- vs as useTranscript
4106
+ ys as useConnectionState,
4107
+ bs as useConversation,
4108
+ fs as useSetAgentState,
4109
+ ds as useSetConnectionState,
4110
+ hs as useSetConversation,
4111
+ cs as useSetTranscript,
4112
+ ms as useTranscript
4102
4113
  };