@telnyx/ai-agent-lib 0.1.0
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/README.md +3 -0
- package/dist/agent-state.d.ts +3 -0
- package/dist/audio-stream-monitor.d.ts +11 -0
- package/dist/client.d.ts +27 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4795 -0
- package/dist/message.d.ts +45 -0
- package/dist/react/agent-state-auto-update.d.ts +1 -0
- package/dist/react/client-context.d.ts +5 -0
- package/dist/react/connection-state-auto-update.d.ts +1 -0
- package/dist/react/conversation-auto-update.d.ts +1 -0
- package/dist/react/transcript-auto-update.d.ts +1 -0
- package/dist/react/use-agent-state.d.ts +3 -0
- package/dist/react/use-client-connection-state.d.ts +3 -0
- package/dist/react/use-client.d.ts +1 -0
- package/dist/react/use-conversation.d.ts +3 -0
- package/dist/react/use-transcript.d.ts +3 -0
- package/dist/transcript.d.ts +9 -0
- package/dist/types.d.ts +19 -0
- package/dist/util.d.ts +1 -0
- package/package.json +38 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,4795 @@
|
|
|
1
|
+
function Et(t, e) {
|
|
2
|
+
var n = {};
|
|
3
|
+
for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
|
|
4
|
+
if (t != null && typeof Object.getOwnPropertySymbols == "function") {
|
|
5
|
+
var i = 0;
|
|
6
|
+
for (r = Object.getOwnPropertySymbols(t); i < r.length; i++) e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[i]) && (n[r[i]] = t[r[i]]);
|
|
7
|
+
}
|
|
8
|
+
return n;
|
|
9
|
+
}
|
|
10
|
+
function q(t, e, n, r) {
|
|
11
|
+
return new (n || (n = Promise))(function(i, u) {
|
|
12
|
+
function l(p) {
|
|
13
|
+
try {
|
|
14
|
+
g(r.next(p));
|
|
15
|
+
} catch (y) {
|
|
16
|
+
u(y);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function h(p) {
|
|
20
|
+
try {
|
|
21
|
+
g(r.throw(p));
|
|
22
|
+
} catch (y) {
|
|
23
|
+
u(y);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function g(p) {
|
|
27
|
+
var y;
|
|
28
|
+
p.done ? i(p.value) : (y = p.value, y instanceof n ? y : new n(function(S) {
|
|
29
|
+
S(y);
|
|
30
|
+
})).then(l, h);
|
|
31
|
+
}
|
|
32
|
+
g((r = r.apply(t, [])).next());
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
var zt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), sr = new Uint8Array(16);
|
|
36
|
+
function ar() {
|
|
37
|
+
if (!zt) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
38
|
+
return zt(sr);
|
|
39
|
+
}
|
|
40
|
+
for (var kn = [], Je = 0; Je < 256; ++Je) kn[Je] = (Je + 256).toString(16).substr(1);
|
|
41
|
+
function Ie(t, e, n) {
|
|
42
|
+
var r = e && n || 0;
|
|
43
|
+
typeof t == "string" && (e = t === "binary" ? new Array(16) : null, t = null);
|
|
44
|
+
var i = (t = t || {}).random || (t.rng || ar)();
|
|
45
|
+
if (i[6] = 15 & i[6] | 64, i[8] = 63 & i[8] | 128, e) for (var u = 0; u < 16; ++u) e[r + u] = i[u];
|
|
46
|
+
return e || function(l, h) {
|
|
47
|
+
var g = 0, p = kn;
|
|
48
|
+
return [p[l[g++]], p[l[g++]], p[l[g++]], p[l[g++]], "-", p[l[g++]], p[l[g++]], "-", p[l[g++]], p[l[g++]], "-", p[l[g++]], p[l[g++]], "-", p[l[g++]], p[l[g++]], p[l[g++]], p[l[g++]], p[l[g++]], p[l[g++]]].join("");
|
|
49
|
+
}(i);
|
|
50
|
+
}
|
|
51
|
+
const An = "Time to call invite", Kt = "wss://rtc.telnyx.com", cr = { urls: "stun:stun.l.google.com:19302" }, ur = { urls: "stun:stun.telnyx.com:3478" }, On = { urls: "turn:turn.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" };
|
|
52
|
+
var V;
|
|
53
|
+
(function(t) {
|
|
54
|
+
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";
|
|
55
|
+
})(V || (V = {}));
|
|
56
|
+
var lr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
57
|
+
function xn(t, e) {
|
|
58
|
+
return t(e = { exports: {} }, e.exports), e.exports;
|
|
59
|
+
}
|
|
60
|
+
var dr = xn(function(t) {
|
|
61
|
+
var e, n;
|
|
62
|
+
e = lr, n = function() {
|
|
63
|
+
var r = function() {
|
|
64
|
+
}, i = "undefined", u = typeof window !== i && typeof window.navigator !== i && /Trident\/|MSIE /.test(window.navigator.userAgent), l = ["trace", "debug", "info", "warn", "error"];
|
|
65
|
+
function h(b, j) {
|
|
66
|
+
var $ = b[j];
|
|
67
|
+
if (typeof $.bind == "function") return $.bind(b);
|
|
68
|
+
try {
|
|
69
|
+
return Function.prototype.bind.call($, b);
|
|
70
|
+
} catch {
|
|
71
|
+
return function() {
|
|
72
|
+
return Function.prototype.apply.apply($, [b, arguments]);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function g() {
|
|
77
|
+
console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
|
|
78
|
+
}
|
|
79
|
+
function p(b, j) {
|
|
80
|
+
for (var $ = 0; $ < l.length; $++) {
|
|
81
|
+
var M = l[$];
|
|
82
|
+
this[M] = $ < b ? r : this.methodFactory(M, b, j);
|
|
83
|
+
}
|
|
84
|
+
this.log = this.debug;
|
|
85
|
+
}
|
|
86
|
+
function y(b, j, $) {
|
|
87
|
+
return function() {
|
|
88
|
+
typeof console !== i && (p.call(this, j, $), this[b].apply(this, arguments));
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function S(b, j, $) {
|
|
92
|
+
return function(M) {
|
|
93
|
+
return M === "debug" && (M = "log"), typeof console !== i && (M === "trace" && u ? g : console[M] !== void 0 ? h(console, M) : console.log !== void 0 ? h(console, "log") : r);
|
|
94
|
+
}(b) || y.apply(this, arguments);
|
|
95
|
+
}
|
|
96
|
+
function I(b, j, $) {
|
|
97
|
+
var M, K = this;
|
|
98
|
+
j = j ?? "WARN";
|
|
99
|
+
var G = "loglevel";
|
|
100
|
+
function ce() {
|
|
101
|
+
var x;
|
|
102
|
+
if (typeof window !== i && G) {
|
|
103
|
+
try {
|
|
104
|
+
x = window.localStorage[G];
|
|
105
|
+
} catch {
|
|
106
|
+
}
|
|
107
|
+
if (typeof x === i) try {
|
|
108
|
+
var s = window.document.cookie, c = s.indexOf(encodeURIComponent(G) + "=");
|
|
109
|
+
c !== -1 && (x = /^([^;]+)/.exec(s.slice(c))[1]);
|
|
110
|
+
} catch {
|
|
111
|
+
}
|
|
112
|
+
return K.levels[x] === void 0 && (x = void 0), x;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
typeof b == "string" ? G += ":" + b : typeof b == "symbol" && (G = void 0), K.name = b, K.levels = { TRACE: 0, DEBUG: 1, INFO: 2, WARN: 3, ERROR: 4, SILENT: 5 }, K.methodFactory = $ || S, K.getLevel = function() {
|
|
116
|
+
return M;
|
|
117
|
+
}, K.setLevel = function(x, s) {
|
|
118
|
+
if (typeof x == "string" && K.levels[x.toUpperCase()] !== void 0 && (x = K.levels[x.toUpperCase()]), !(typeof x == "number" && x >= 0 && x <= K.levels.SILENT)) throw "log.setLevel() called with invalid level: " + x;
|
|
119
|
+
if (M = x, s !== !1 && function(c) {
|
|
120
|
+
var d = (l[c] || "silent").toUpperCase();
|
|
121
|
+
if (typeof window !== i && G) {
|
|
122
|
+
try {
|
|
123
|
+
return void (window.localStorage[G] = d);
|
|
124
|
+
} catch {
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
window.document.cookie = encodeURIComponent(G) + "=" + d + ";";
|
|
128
|
+
} catch {
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}(x), p.call(K, x, b), typeof console === i && x < K.levels.SILENT) return "No console available for logging";
|
|
132
|
+
}, K.setDefaultLevel = function(x) {
|
|
133
|
+
j = x, ce() || K.setLevel(x, !1);
|
|
134
|
+
}, K.resetLevel = function() {
|
|
135
|
+
K.setLevel(j, !1), function() {
|
|
136
|
+
if (typeof window !== i && G) {
|
|
137
|
+
try {
|
|
138
|
+
return void window.localStorage.removeItem(G);
|
|
139
|
+
} catch {
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
window.document.cookie = encodeURIComponent(G) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
|
|
143
|
+
} catch {
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}();
|
|
147
|
+
}, K.enableAll = function(x) {
|
|
148
|
+
K.setLevel(K.levels.TRACE, x);
|
|
149
|
+
}, K.disableAll = function(x) {
|
|
150
|
+
K.setLevel(K.levels.SILENT, x);
|
|
151
|
+
};
|
|
152
|
+
var R = ce();
|
|
153
|
+
R == null && (R = j), K.setLevel(R, !1);
|
|
154
|
+
}
|
|
155
|
+
var T = new I(), C = {};
|
|
156
|
+
T.getLogger = function(b) {
|
|
157
|
+
if (typeof b != "symbol" && typeof b != "string" || b === "") throw new TypeError("You must supply a name when creating a logger.");
|
|
158
|
+
var j = C[b];
|
|
159
|
+
return j || (j = C[b] = new I(b, T.getLevel(), T.methodFactory)), j;
|
|
160
|
+
};
|
|
161
|
+
var D = typeof window !== i ? window.log : void 0;
|
|
162
|
+
return T.noConflict = function() {
|
|
163
|
+
return typeof window !== i && window.log === T && (window.log = D), T;
|
|
164
|
+
}, T.getLoggers = function() {
|
|
165
|
+
return C;
|
|
166
|
+
}, T.default = T, T;
|
|
167
|
+
}, t.exports ? t.exports = n() : e.log = n();
|
|
168
|
+
});
|
|
169
|
+
const B = dr.getLogger("telnyx"), hr = B.methodFactory;
|
|
170
|
+
B.methodFactory = (t, e, n) => {
|
|
171
|
+
const r = hr(t, e, n);
|
|
172
|
+
return function() {
|
|
173
|
+
const i = [(/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), "-"];
|
|
174
|
+
for (let u = 0; u < arguments.length; u++) i.push(arguments[u]);
|
|
175
|
+
r.apply(void 0, i);
|
|
176
|
+
};
|
|
177
|
+
}, B.setLevel(B.getLevel());
|
|
178
|
+
const Jt = (t) => Object.keys(t).length === 0, Qe = (t) => {
|
|
179
|
+
const [e, n, r, i, u, l] = t;
|
|
180
|
+
let h = {};
|
|
181
|
+
try {
|
|
182
|
+
h = JSON.parse(u.replace(/ID"/g, 'Id"'));
|
|
183
|
+
} catch {
|
|
184
|
+
B.warn("Verto LA invalid media JSON string:", u);
|
|
185
|
+
}
|
|
186
|
+
return { participantId: Number(e), participantNumber: n, participantName: r, codec: i, media: h, participantData: l };
|
|
187
|
+
}, Ln = (t) => {
|
|
188
|
+
if (typeof t != "string") return t;
|
|
189
|
+
try {
|
|
190
|
+
return JSON.parse(t);
|
|
191
|
+
} catch {
|
|
192
|
+
return t;
|
|
193
|
+
}
|
|
194
|
+
}, ke = (t) => t instanceof Function || typeof t == "function", $e = (t) => typeof document == "object" && "getElementById" in document ? typeof t == "string" ? document.getElementById(t) || null : typeof t == "function" ? t() : t instanceof HTMLMediaElement ? t : null : null, fr = /^(ws|wss):\/\//, Nn = (t, e = null) => {
|
|
195
|
+
const { result: n = {}, error: r } = t;
|
|
196
|
+
if (r) return { error: r };
|
|
197
|
+
const { result: i = null } = n;
|
|
198
|
+
if (i === null) return e !== null && (n.node_id = e), { result: n };
|
|
199
|
+
const { code: u = null, node_id: l = null, result: h = null } = i;
|
|
200
|
+
return u && u !== "200" ? { error: i } : h ? Nn(h, l) : { result: i };
|
|
201
|
+
}, Mn = (t, e) => Math.floor(Math.random() * (e - t + 1) + t), Ct = ({ login: t, passwd: e, password: n, login_token: r }) => !!(t && (e || n) || r), nt = ({ anonymous_login: t }) => !!t && !!t.target_id && !!t.target_type, Ot = (t) => {
|
|
202
|
+
var e, n, r, i, u, l;
|
|
203
|
+
let h = "", g = "";
|
|
204
|
+
return !((n = (e = t?.result) === null || e === void 0 ? void 0 : e.params) === null || n === void 0) && n.state && (h = (i = (r = t?.result) === null || r === void 0 ? void 0 : r.params) === null || i === void 0 ? void 0 : i.state), !((u = t?.params) === null || u === void 0) && u.state && (g = (l = t?.params) === null || l === void 0 ? void 0 : l.state), h || g;
|
|
205
|
+
};
|
|
206
|
+
function Qt({ debounceTime: t }) {
|
|
207
|
+
let e, n;
|
|
208
|
+
return { promise: new Promise((r, i) => {
|
|
209
|
+
e = t ? pr(r, t) : r, n = i;
|
|
210
|
+
}), resolve: e, reject: n };
|
|
211
|
+
}
|
|
212
|
+
const pr = (t, e) => {
|
|
213
|
+
let n;
|
|
214
|
+
return (...r) => {
|
|
215
|
+
clearTimeout(n), n = window.setTimeout(() => {
|
|
216
|
+
t(...r);
|
|
217
|
+
}, e);
|
|
218
|
+
};
|
|
219
|
+
}, xt = "telnyx-voice-sdk-id";
|
|
220
|
+
function Rt() {
|
|
221
|
+
return sessionStorage.getItem(xt);
|
|
222
|
+
}
|
|
223
|
+
var ge, we, ne;
|
|
224
|
+
typeof window < "u" && window.addEventListener("beforeunload", () => {
|
|
225
|
+
sessionStorage.removeItem(xt);
|
|
226
|
+
}), function(t) {
|
|
227
|
+
t.Offer = "offer", t.Answer = "answer";
|
|
228
|
+
}(ge || (ge = {})), function(t) {
|
|
229
|
+
t.Inbound = "inbound", t.Outbound = "outbound";
|
|
230
|
+
}(we || (we = {})), function(t) {
|
|
231
|
+
t.Invite = "telnyx_rtc.invite", t.Attach = "telnyx_rtc.attach", t.Answer = "telnyx_rtc.answer", t.Info = "telnyx_rtc.info", 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";
|
|
232
|
+
}(ne || (ne = {}));
|
|
233
|
+
const ye = { generic: "event", [ne.Display]: "participantData", [ne.Attach]: "participantData", conferenceUpdate: "conferenceUpdate", callUpdate: "callUpdate", vertoClientReady: "vertoClientReady", userMediaError: "userMediaError" }, gr = { destinationNumber: "", remoteCallerName: "Outbound Call", remoteCallerNumber: "", callerName: "", callerNumber: "", audio: !0, video: !1, useStereo: !1, debug: !1, debugOutput: "socket", attach: !1, screenShare: !1, userVariables: {}, mediaSettings: { useSdpASBandwidthKbps: !1, sdpASBandwidthKbps: 0 } };
|
|
234
|
+
var Q, Ue, de, _e, le;
|
|
235
|
+
(function(t) {
|
|
236
|
+
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";
|
|
237
|
+
})(Q || (Q = {})), function(t) {
|
|
238
|
+
t.Participant = "participant", t.Moderator = "moderator";
|
|
239
|
+
}(Ue || (Ue = {})), function(t) {
|
|
240
|
+
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";
|
|
241
|
+
}(de || (de = {})), function(t) {
|
|
242
|
+
t.Video = "videoinput", t.AudioIn = "audioinput", t.AudioOut = "audiooutput";
|
|
243
|
+
}(_e || (_e = {})), function(t) {
|
|
244
|
+
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";
|
|
245
|
+
}(le || (le = {}));
|
|
246
|
+
const Ae = "GLOBAL", he = {}, Fe = (t, e) => `${t}|${e}`, Pn = (t, e = Ae) => Fe(t, e) in he, Ce = (t, e, n = Ae) => {
|
|
247
|
+
const r = Fe(t, n);
|
|
248
|
+
r in he || (he[r] = []), he[r].push(e);
|
|
249
|
+
}, Dn = (t, e, n = Ae) => {
|
|
250
|
+
const r = function(i) {
|
|
251
|
+
Re(t, r, n), e(i);
|
|
252
|
+
};
|
|
253
|
+
return r.prototype.targetRef = e, Ce(t, r, n);
|
|
254
|
+
}, Re = (t, e, n = Ae) => {
|
|
255
|
+
if (!Pn(t, n)) return !1;
|
|
256
|
+
const r = Fe(t, n);
|
|
257
|
+
if (ke(e))
|
|
258
|
+
for (let i = he[r].length - 1; i >= 0; i--) {
|
|
259
|
+
const u = he[r][i];
|
|
260
|
+
(e === u || u.prototype && e === u.prototype.targetRef) && he[r].splice(i, 1);
|
|
261
|
+
}
|
|
262
|
+
else he[r] = [];
|
|
263
|
+
return he[r].length === 0 && delete he[r], !0;
|
|
264
|
+
}, X = (t, e, n = Ae, r = !0) => {
|
|
265
|
+
const i = r && n !== Ae;
|
|
266
|
+
if (!Pn(t, n)) return i && X(t, e), !1;
|
|
267
|
+
const u = Fe(t, n), l = he[u].length;
|
|
268
|
+
if (!l) return i && X(t, e), !1;
|
|
269
|
+
for (let h = l - 1; h >= 0; h--) he[u][h](e);
|
|
270
|
+
return i && X(t, e), !0;
|
|
271
|
+
}, vt = (t) => {
|
|
272
|
+
const e = Fe(t, "");
|
|
273
|
+
Object.keys(he).filter((n) => n.indexOf(e) === 0).forEach((n) => delete he[n]);
|
|
274
|
+
};
|
|
275
|
+
let vr = typeof WebSocket < "u" ? WebSocket : null;
|
|
276
|
+
const mr = 0, yr = 1, _r = 2, br = 3;
|
|
277
|
+
class Xt {
|
|
278
|
+
constructor(e) {
|
|
279
|
+
this.session = e, this.previousGatewayState = "", this._wsClient = null, this._host = Kt, this._timers = {}, this.upDur = null, this.downDur = null;
|
|
280
|
+
const { host: n, env: r, region: i } = e.options;
|
|
281
|
+
r && (this._host = r === "development" ? "wss://rtcdev.telnyx.com" : Kt), n && (this._host = ((u) => `${fr.test(u) ? "" : "wss://"}${u}`)(n)), i && (this._host = this._host.replace(/rtc(dev)?/, `${i}.rtc$1`));
|
|
282
|
+
}
|
|
283
|
+
get connected() {
|
|
284
|
+
return this._wsClient && this._wsClient.readyState === yr;
|
|
285
|
+
}
|
|
286
|
+
get connecting() {
|
|
287
|
+
return this._wsClient && this._wsClient.readyState === mr;
|
|
288
|
+
}
|
|
289
|
+
get closing() {
|
|
290
|
+
return this._wsClient && this._wsClient.readyState === _r;
|
|
291
|
+
}
|
|
292
|
+
get closed() {
|
|
293
|
+
return this._wsClient && this._wsClient.readyState === br;
|
|
294
|
+
}
|
|
295
|
+
get isAlive() {
|
|
296
|
+
return this.connecting || this.connected;
|
|
297
|
+
}
|
|
298
|
+
get isDead() {
|
|
299
|
+
return this.closing || this.closed;
|
|
300
|
+
}
|
|
301
|
+
connect() {
|
|
302
|
+
const e = new URL(this._host), n = Rt();
|
|
303
|
+
n && e.searchParams.set("voice_sdk_id", n), this._wsClient = new vr(e.toString()), this._wsClient.onopen = (r) => X(V.SocketOpen, r, this.session.uuid), this._wsClient.onclose = (r) => X(V.SocketClose, r, this.session.uuid), this._wsClient.onerror = (r) => X(V.SocketError, { error: r, sessionId: this.session.sessionid }, this.session.uuid), this._wsClient.onmessage = (r) => {
|
|
304
|
+
var i, u;
|
|
305
|
+
const l = Ln(r.data);
|
|
306
|
+
var h;
|
|
307
|
+
if (typeof l != "string") {
|
|
308
|
+
if (l.voice_sdk_id && (h = l.voice_sdk_id, sessionStorage.setItem(xt, h)), this._unsetTimer(l.id), B.debug(`RECV:
|
|
309
|
+
`, JSON.stringify(l, null, 2), `
|
|
310
|
+
`), le[`${(u = (i = l?.result) === null || i === void 0 ? void 0 : i.params) === null || u === void 0 ? void 0 : u.state}`] || !X(l.id, l)) {
|
|
311
|
+
const g = Ot(l);
|
|
312
|
+
X(V.SocketMessage, l, this.session.uuid), g && (this.previousGatewayState = g);
|
|
313
|
+
}
|
|
314
|
+
} else this._handleStringResponse(l);
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
sendRawText(e) {
|
|
318
|
+
this._wsClient.send(e);
|
|
319
|
+
}
|
|
320
|
+
send(e) {
|
|
321
|
+
const { request: n } = e, r = new Promise((i, u) => {
|
|
322
|
+
if (n.hasOwnProperty("result")) return i();
|
|
323
|
+
Dn(n.id, (l) => {
|
|
324
|
+
const { result: h, error: g } = Nn(l);
|
|
325
|
+
return g ? u(g) : i(h);
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
return B.debug(`SEND:
|
|
329
|
+
`, JSON.stringify(n, null, 2), `
|
|
330
|
+
`), this._wsClient.send(JSON.stringify(n)), r;
|
|
331
|
+
}
|
|
332
|
+
close() {
|
|
333
|
+
this._wsClient && (ke(this._wsClient._beginClose) ? this._wsClient._beginClose() : this._wsClient.close()), this._wsClient = null;
|
|
334
|
+
}
|
|
335
|
+
_unsetTimer(e) {
|
|
336
|
+
clearTimeout(this._timers[e]), delete this._timers[e];
|
|
337
|
+
}
|
|
338
|
+
_handleStringResponse(e) {
|
|
339
|
+
if (/^#SP/.test(e)) switch (e[3]) {
|
|
340
|
+
case "U":
|
|
341
|
+
this.upDur = parseInt(e.substring(4));
|
|
342
|
+
break;
|
|
343
|
+
case "D":
|
|
344
|
+
this.downDur = parseInt(e.substring(4)), X(V.SpeedTest, { upDur: this.upDur, downDur: this.downDur }, this.session.uuid);
|
|
345
|
+
}
|
|
346
|
+
else B.warn("Unknown message from socket", e);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
class We {
|
|
350
|
+
buildRequest(e) {
|
|
351
|
+
this.request = Object.assign({ jsonrpc: "2.0", id: Ie() }, e);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
const Zt = { 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" };
|
|
355
|
+
class fe extends We {
|
|
356
|
+
constructor(e = {}) {
|
|
357
|
+
if (super(), e.hasOwnProperty("dialogParams")) {
|
|
358
|
+
const n = Et(e.dialogParams, ["remoteSdp", "localStream", "remoteStream", "onNotification", "camId", "micId", "speakerId"]);
|
|
359
|
+
for (const r in Zt) r && n.hasOwnProperty(r) && (n[Zt[r]] = n[r], delete n[r]);
|
|
360
|
+
e.dialogParams = n;
|
|
361
|
+
}
|
|
362
|
+
this.buildRequest({ method: this.toString(), params: e });
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
class jn extends fe {
|
|
366
|
+
constructor() {
|
|
367
|
+
super(), this.method = ne.GatewayState, this.buildRequest({ method: this.method, params: {} });
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
class wr {
|
|
371
|
+
constructor(e) {
|
|
372
|
+
this.pendingRequestId = null, this.onSocketMessage = (n) => q(this, void 0, void 0, function* () {
|
|
373
|
+
n.id === this.pendingRequestId && this.gatewayStateTask.resolve(Ot(n));
|
|
374
|
+
}), this.getIsRegistered = () => q(this, void 0, void 0, function* () {
|
|
375
|
+
const n = new jn();
|
|
376
|
+
this.pendingRequestId = n.request.id, this.gatewayStateTask = Qt({}), this.session.execute(n);
|
|
377
|
+
const r = yield this.gatewayStateTask.promise;
|
|
378
|
+
return !!r && [le.REGISTER, le.REGED].includes(r);
|
|
379
|
+
}), this.session = e, this.gatewayStateTask = Qt({}), this.session.on("telnyx.socket.message", this.onSocketMessage);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
class Sr {
|
|
383
|
+
constructor(e) {
|
|
384
|
+
if (this.options = e, this.uuid = Ie(), this.sessionid = "", this.subscriptions = {}, this.signature = null, this.relayProtocol = null, this.contexts = [], this.timeoutErrorCode = -32e3, this.connection = null, this._jwtAuth = !1, this._doKeepAlive = !1, this._autoReconnect = !0, this._idle = !1, this._executeQueue = [], !this.validateOptions()) throw new Error("Invalid init options");
|
|
385
|
+
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 Xt(this), this.registerAgent = new wr(this);
|
|
386
|
+
}
|
|
387
|
+
get __logger() {
|
|
388
|
+
return B;
|
|
389
|
+
}
|
|
390
|
+
get connected() {
|
|
391
|
+
return this.connection && this.connection.connected;
|
|
392
|
+
}
|
|
393
|
+
get reconnectDelay() {
|
|
394
|
+
return 1e3 * Mn(2, 6);
|
|
395
|
+
}
|
|
396
|
+
execute(e) {
|
|
397
|
+
return this._idle ? new Promise((n) => this._executeQueue.push({ resolve: n, msg: e })) : this.connected ? this.connection.send(e) : new Promise((n) => {
|
|
398
|
+
this._executeQueue.push({ resolve: n, msg: e }), this.connect();
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
executeRaw(e) {
|
|
402
|
+
this._idle ? this._executeQueue.push({ msg: e }) : this.connection.sendRawText(e);
|
|
403
|
+
}
|
|
404
|
+
validateOptions() {
|
|
405
|
+
return Ct(this.options) || nt(this.options);
|
|
406
|
+
}
|
|
407
|
+
broadcast(e) {
|
|
408
|
+
}
|
|
409
|
+
disconnect() {
|
|
410
|
+
return q(this, void 0, void 0, function* () {
|
|
411
|
+
clearTimeout(this._reconnectTimeout), this.subscriptions = {}, this._autoReconnect = !1, this.relayProtocol = null, this._closeConnection(), yield sessionStorage.removeItem(this.signature), this._executeQueue = [], this._detachListeners();
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
on(e, n) {
|
|
415
|
+
return Ce(e, n, this.uuid), this;
|
|
416
|
+
}
|
|
417
|
+
off(e, n) {
|
|
418
|
+
return Re(e, n, this.uuid), this;
|
|
419
|
+
}
|
|
420
|
+
connect() {
|
|
421
|
+
return q(this, void 0, void 0, function* () {
|
|
422
|
+
this.connection || (this.connection = new Xt(this)), this._attachListeners(), this.connection.isAlive || this.connection.connect();
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
_handleLoginError(e) {
|
|
426
|
+
X(V.Error, { error: e, sessionId: this.sessionid }, this.uuid);
|
|
427
|
+
}
|
|
428
|
+
_onSocketOpen() {
|
|
429
|
+
return q(this, void 0, void 0, function* () {
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
onNetworkClose() {
|
|
433
|
+
this.relayProtocol && vt(this.relayProtocol);
|
|
434
|
+
for (const e in this.subscriptions) vt(e);
|
|
435
|
+
this.subscriptions = {}, this.contexts = [], this._autoReconnect && (this._reconnectTimeout = setTimeout(() => this.connect(), this.reconnectDelay));
|
|
436
|
+
}
|
|
437
|
+
_onSocketMessage(e) {
|
|
438
|
+
}
|
|
439
|
+
_removeSubscription(e, n) {
|
|
440
|
+
this._existsSubscription(e, n) && (n ? (delete this.subscriptions[e][n], Re(e, null, n)) : (delete this.subscriptions[e], vt(e)));
|
|
441
|
+
}
|
|
442
|
+
_addSubscription(e, n = null, r) {
|
|
443
|
+
this._existsSubscription(e, r) || (this._existsSubscription(e) || (this.subscriptions[e] = {}), this.subscriptions[e][r] = {}, ke(n) && Ce(e, n, r));
|
|
444
|
+
}
|
|
445
|
+
_existsSubscription(e, n) {
|
|
446
|
+
return !(!this.subscriptions.hasOwnProperty(e) || !(!n || n && this.subscriptions[e].hasOwnProperty(n)));
|
|
447
|
+
}
|
|
448
|
+
_attachListeners() {
|
|
449
|
+
this._detachListeners(), this.on(V.SocketOpen, this._onSocketOpen), this.on(V.SocketClose, this.onNetworkClose), this.on(V.SocketError, this.onNetworkClose), this.on(V.SocketMessage, this._onSocketMessage);
|
|
450
|
+
}
|
|
451
|
+
_detachListeners() {
|
|
452
|
+
this.off(V.SocketOpen, this._onSocketOpen), this.off(V.SocketClose, this.onNetworkClose), this.off(V.SocketError, this.onNetworkClose), this.off(V.SocketMessage, this._onSocketMessage);
|
|
453
|
+
}
|
|
454
|
+
_emptyExecuteQueues() {
|
|
455
|
+
this._executeQueue.forEach(({ resolve: e, msg: n }) => {
|
|
456
|
+
typeof n == "string" ? this.executeRaw(n) : e(this.execute(n));
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
_closeConnection() {
|
|
460
|
+
this._idle = !0, clearTimeout(this._keepAliveTimeout), this.connection && this.connection.close();
|
|
461
|
+
}
|
|
462
|
+
_keepAlive() {
|
|
463
|
+
this._doKeepAlive === !0 && (this._pong = !1, this._keepAliveTimeout = setTimeout(() => this._keepAlive(), 3e4));
|
|
464
|
+
}
|
|
465
|
+
static on(e, n) {
|
|
466
|
+
Ce(e, n);
|
|
467
|
+
}
|
|
468
|
+
static off(e) {
|
|
469
|
+
Re(e);
|
|
470
|
+
}
|
|
471
|
+
static uuid() {
|
|
472
|
+
return Ie();
|
|
473
|
+
}
|
|
474
|
+
clearConnection() {
|
|
475
|
+
this.connection = null;
|
|
476
|
+
}
|
|
477
|
+
hasAutoReconnect() {
|
|
478
|
+
return this._autoReconnect;
|
|
479
|
+
}
|
|
480
|
+
getIsRegistered() {
|
|
481
|
+
return this.registerAgent.getIsRegistered();
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
const Tt = (t) => navigator.mediaDevices.getUserMedia(t), ot = (t) => t && t instanceof MediaStream, it = (t, e) => {
|
|
485
|
+
const n = $e(t);
|
|
486
|
+
n !== null && (n.getAttribute("autoplay") || n.setAttribute("autoplay", "autoplay"), n.getAttribute("playsinline") || n.setAttribute("playsinline", "playsinline"), n.srcObject = e);
|
|
487
|
+
}, Un = (t, e) => q(void 0, void 0, void 0, function* () {
|
|
488
|
+
const n = $e(t);
|
|
489
|
+
if (n === null) return B.info("No HTMLMediaElement to attach the speakerId"), !1;
|
|
490
|
+
if (typeof e != "string") return B.info(`Invalid speaker deviceId: '${e}'`), !1;
|
|
491
|
+
try {
|
|
492
|
+
return yield n.setSinkId(e), !0;
|
|
493
|
+
} catch {
|
|
494
|
+
return !1;
|
|
495
|
+
}
|
|
496
|
+
}), Er = (t) => {
|
|
497
|
+
t && t.readyState === "live" && t.stop();
|
|
498
|
+
}, Ve = (t) => {
|
|
499
|
+
ot(t) && t.getTracks().forEach(Er), t = null;
|
|
500
|
+
}, st = (t) => q(void 0, void 0, void 0, function* () {
|
|
501
|
+
B.info("RTCService.getUserMedia", t);
|
|
502
|
+
const { audio: e, video: n } = t;
|
|
503
|
+
if (!e && !n) return null;
|
|
504
|
+
try {
|
|
505
|
+
return yield Tt(t);
|
|
506
|
+
} catch (r) {
|
|
507
|
+
throw B.error("getUserMedia error: ", r), r;
|
|
508
|
+
}
|
|
509
|
+
}), Pe = (t = null, e = !1) => q(void 0, void 0, void 0, function* () {
|
|
510
|
+
let n = [];
|
|
511
|
+
const r = yield navigator.mediaDevices.getUserMedia(((i = null) => ({ audio: !i || i === _e.AudioIn || i === _e.AudioOut, video: !i || i === _e.Video }))(t)).catch((i) => (console.error(i), null));
|
|
512
|
+
if (r) {
|
|
513
|
+
if (Ve(r), n = yield navigator.mediaDevices.enumerateDevices(), t && (n = n.filter((u) => u.kind === t)), e === !0) return n;
|
|
514
|
+
const i = [];
|
|
515
|
+
n = n.filter((u) => {
|
|
516
|
+
if (!u.groupId) return !0;
|
|
517
|
+
const l = `${u.kind}-${u.groupId}`;
|
|
518
|
+
return !i.includes(l) && (i.push(l), !0);
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
return n;
|
|
522
|
+
}), en = [[320, 240], [640, 360], [640, 480], [1280, 720], [1920, 1080]], at = (t, e, n) => q(void 0, void 0, void 0, function* () {
|
|
523
|
+
const r = yield Pe(n, !0);
|
|
524
|
+
for (let i = 0; i < r.length; i++) {
|
|
525
|
+
const { deviceId: u, label: l } = r[i];
|
|
526
|
+
if (t === u || e === l) return u;
|
|
527
|
+
}
|
|
528
|
+
return null;
|
|
529
|
+
}), tn = (t) => {
|
|
530
|
+
const e = navigator.mediaDevices.getSupportedConstraints();
|
|
531
|
+
Object.keys(t).map((n) => {
|
|
532
|
+
e.hasOwnProperty(n) && t[n] !== null && t[n] !== void 0 || delete t[n];
|
|
533
|
+
});
|
|
534
|
+
}, nn = (t, e, n, r) => q(void 0, void 0, void 0, function* () {
|
|
535
|
+
const { deviceId: i } = r;
|
|
536
|
+
if (i === void 0 && (t || e)) {
|
|
537
|
+
const u = yield at(t, e, n).catch((l) => null);
|
|
538
|
+
u && (r.deviceId = { exact: u });
|
|
539
|
+
}
|
|
540
|
+
return r;
|
|
541
|
+
}), rt = (t, e) => {
|
|
542
|
+
if (!t) return !1;
|
|
543
|
+
const { subscribed: n, alreadySubscribed: r } = It(t);
|
|
544
|
+
return n.includes(e) || r.includes(e);
|
|
545
|
+
}, It = (t) => {
|
|
546
|
+
const e = { subscribed: [], alreadySubscribed: [], unauthorized: [], unsubscribed: [], notSubscribed: [] };
|
|
547
|
+
return Object.keys(e).forEach((n) => {
|
|
548
|
+
e[n] = t[`${n}Channels`] || [];
|
|
549
|
+
}), e;
|
|
550
|
+
}, Te = (t, e = null, n = null) => {
|
|
551
|
+
if (!ot(t)) return null;
|
|
552
|
+
let r = [];
|
|
553
|
+
switch (e) {
|
|
554
|
+
case "audio":
|
|
555
|
+
r = t.getAudioTracks();
|
|
556
|
+
break;
|
|
557
|
+
case "video":
|
|
558
|
+
r = t.getVideoTracks();
|
|
559
|
+
break;
|
|
560
|
+
default:
|
|
561
|
+
r = t.getTracks();
|
|
562
|
+
}
|
|
563
|
+
r.forEach((i) => {
|
|
564
|
+
switch (n) {
|
|
565
|
+
case "on":
|
|
566
|
+
case !0:
|
|
567
|
+
i.enabled = !0;
|
|
568
|
+
break;
|
|
569
|
+
case "off":
|
|
570
|
+
case !1:
|
|
571
|
+
i.enabled = !1;
|
|
572
|
+
break;
|
|
573
|
+
default:
|
|
574
|
+
i.enabled = !i.enabled;
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
}, rn = (t) => {
|
|
578
|
+
Te(t, "audio", !0);
|
|
579
|
+
}, on = (t) => {
|
|
580
|
+
Te(t, "audio", !1);
|
|
581
|
+
}, sn = (t) => {
|
|
582
|
+
Te(t, "audio", null);
|
|
583
|
+
};
|
|
584
|
+
function Cr() {
|
|
585
|
+
try {
|
|
586
|
+
const { browserInfo: t, name: e, version: n, supportAudio: r, supportVideo: i } = function() {
|
|
587
|
+
if (!window || !window.navigator || !window.navigator.userAgent) throw new Error("You should use @telnyx/webrtc in a web browser such as Chrome|Firefox|Safari");
|
|
588
|
+
if (navigator.userAgent.match(/chrom(e|ium)/gim) && !navigator.userAgent.match(/OPR\/[0-9]{2}/gi) && !navigator.userAgent.match(/edg/gim)) {
|
|
589
|
+
const y = navigator.userAgent.match(/chrom(e|ium)\/[0-9]+\./gim)[0].split("/"), S = y[0], I = parseInt(y[1], 10);
|
|
590
|
+
return { browserInfo: navigator.userAgent, name: S, version: I, supportAudio: !0, supportVideo: !0 };
|
|
591
|
+
}
|
|
592
|
+
if (navigator.userAgent.match(/firefox/gim) && !navigator.userAgent.match(/OPR\/[0-9]{2}/gi) && !navigator.userAgent.match(/edg/gim)) {
|
|
593
|
+
const y = navigator.userAgent.match(/firefox\/[0-9]+\./gim)[0].split("/"), S = y[0], I = parseInt(y[1], 10);
|
|
594
|
+
return { browserInfo: navigator.userAgent, name: S, version: I, supportAudio: !0, supportVideo: !1 };
|
|
595
|
+
}
|
|
596
|
+
if (navigator.userAgent.match(/safari/gim) && !navigator.userAgent.match(/OPR\/[0-9]{2}/gi) && !navigator.userAgent.match(/edg/gim)) {
|
|
597
|
+
const y = navigator.userAgent.match(/safari/gim)[0], S = navigator.userAgent.match(/version\/[0-9]+\./gim)[0].split("/"), I = parseInt(S[1], 10);
|
|
598
|
+
return { browserInfo: navigator.userAgent, name: y, version: I, supportAudio: !0, supportVideo: !0 };
|
|
599
|
+
}
|
|
600
|
+
if (navigator.userAgent.match(/edg/gim) && !navigator.userAgent.match(/OPR\/[0-9]{2}/gi)) {
|
|
601
|
+
const y = navigator.userAgent.match(/edg\/[0-9]+\./gim)[0].split("/"), S = y[0], I = parseInt(y[1], 10);
|
|
602
|
+
return { browserInfo: navigator.userAgent, name: S, version: I, supportAudio: !0, supportVideo: !0 };
|
|
603
|
+
}
|
|
604
|
+
throw new Error("This browser does not support @telnyx/webrtc. To see browser support list: `TelnyxRTC.webRTCSupportedBrowserList()`");
|
|
605
|
+
}(), u = window.RTCPeerConnection, l = window.RTCSessionDescription, h = window.RTCIceCandidate, g = window.navigator && window.navigator.mediaDevices, p = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia || navigator.mozGetUserMedia;
|
|
606
|
+
return { browserInfo: t, browserName: e, browserVersion: n, supportWebRTC: !!(u && l && h && g && p), supportWebRTCAudio: r, supportWebRTCVideo: i, supportRTCPeerConnection: !!u, supportSessionDescription: !!l, supportIceCandidate: !!h, supportMediaDevices: !!g, supportGetUserMedia: !!st };
|
|
607
|
+
} catch (t) {
|
|
608
|
+
return t.message;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
var se;
|
|
612
|
+
function an(t, e) {
|
|
613
|
+
const n = document.getElementById(e);
|
|
614
|
+
if (n) return n;
|
|
615
|
+
if (t && e) {
|
|
616
|
+
const r = document.createElement("audio");
|
|
617
|
+
return r.id = e, r.loop = !0, r.src = t, r.preload = "auto", r.load(), document.body.appendChild(r), r;
|
|
618
|
+
}
|
|
619
|
+
return null;
|
|
620
|
+
}
|
|
621
|
+
function cn(t) {
|
|
622
|
+
t && (t._playFulfilled = !1, t._promise = t.play(), t._promise.then(() => {
|
|
623
|
+
t._playFulfilled = !0;
|
|
624
|
+
}).catch((e) => {
|
|
625
|
+
console.error("playAudio", e), t._playFulfilled = !0;
|
|
626
|
+
}));
|
|
627
|
+
}
|
|
628
|
+
function un(t) {
|
|
629
|
+
t && (t._playFulfilled ? (t.pause(), t.currentTime = 0) : t._promise && t._promise.then ? t._promise.then(() => {
|
|
630
|
+
t.pause(), t.currentTime = 0;
|
|
631
|
+
}) : setTimeout(() => {
|
|
632
|
+
t.pause(), t.currentTime = 0;
|
|
633
|
+
}, 1e3));
|
|
634
|
+
}
|
|
635
|
+
(function(t) {
|
|
636
|
+
t.not_supported = "not supported", t.full = "full", t.partial = "partial";
|
|
637
|
+
})(se || (se = {}));
|
|
638
|
+
var $n = "2.22.15", Lt = $n;
|
|
639
|
+
class Rr extends fe {
|
|
640
|
+
constructor(e, n, r, i, u = {}, l) {
|
|
641
|
+
super(), this.method = "login";
|
|
642
|
+
const h = { login: e, passwd: n, login_token: r, userVariables: u, reconnection: l, loginParams: {}, "User-Agent": { sdkVersion: Lt, data: navigator.userAgent } };
|
|
643
|
+
i && (h.sessid = i), this.buildRequest({ method: this.method, params: h });
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
class Tr extends fe {
|
|
647
|
+
constructor(e, n) {
|
|
648
|
+
super(), this.buildRequest({ id: e, result: { method: n } });
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
class Ir extends fe {
|
|
652
|
+
toString() {
|
|
653
|
+
return ne.Invite;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
class kr extends fe {
|
|
657
|
+
toString() {
|
|
658
|
+
return ne.Answer;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
class Ar extends fe {
|
|
662
|
+
toString() {
|
|
663
|
+
return ne.Attach;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
class Or extends fe {
|
|
667
|
+
toString() {
|
|
668
|
+
return ne.Bye;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
class mt extends fe {
|
|
672
|
+
toString() {
|
|
673
|
+
return ne.Modify;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
class ln extends fe {
|
|
677
|
+
toString() {
|
|
678
|
+
return ne.Info;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
class xr extends fe {
|
|
682
|
+
toString() {
|
|
683
|
+
return ne.Broadcast;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
class Lr extends fe {
|
|
687
|
+
toString() {
|
|
688
|
+
return ne.Subscribe;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
class Nr extends fe {
|
|
692
|
+
toString() {
|
|
693
|
+
return ne.Unsubscribe;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
class Mr extends We {
|
|
697
|
+
constructor(e) {
|
|
698
|
+
super(), this.method = "ai_conversation", this.buildRequest({ method: this.method, params: { type: "conversation.item.create", previous_item_id: null, item: { id: Ie(), type: "message", role: "user", content: [{ type: "input_text", text: e }] } } });
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
const Vn = (t, e) => {
|
|
702
|
+
const { contentType: n, canvasType: r, callID: i, canvasInfo: u = null, currentLayerIdx: l = -1 } = e;
|
|
703
|
+
u && r !== "mcu-personal-canvas" && delete u.memberID;
|
|
704
|
+
const h = { type: ye.conferenceUpdate, call: t.calls[i], canvasInfo: Pr(u), currentLayerIdx: l };
|
|
705
|
+
switch (n) {
|
|
706
|
+
case "layer-info": {
|
|
707
|
+
const g = Object.assign({ action: de.LayerInfo }, h);
|
|
708
|
+
X(V.Notification, g, t.uuid);
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
case "layout-info": {
|
|
712
|
+
const g = Object.assign({ action: de.LayoutInfo }, h);
|
|
713
|
+
X(V.Notification, g, t.uuid);
|
|
714
|
+
break;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
}, Pr = (t) => {
|
|
718
|
+
const e = JSON.stringify(t).replace(/memberID/g, "participantId").replace(/ID"/g, 'Id"').replace(/POS"/g, 'Pos"');
|
|
719
|
+
return Ln(e);
|
|
720
|
+
};
|
|
721
|
+
var Xe, Gn = xn(function(t, e) {
|
|
722
|
+
var n;
|
|
723
|
+
function r() {
|
|
724
|
+
}
|
|
725
|
+
function i() {
|
|
726
|
+
i.init.call(this);
|
|
727
|
+
}
|
|
728
|
+
function u(s) {
|
|
729
|
+
return s._maxListeners === void 0 ? i.defaultMaxListeners : s._maxListeners;
|
|
730
|
+
}
|
|
731
|
+
function l(s, c, d, f) {
|
|
732
|
+
var _, E, w;
|
|
733
|
+
if (typeof d != "function") throw new TypeError('"listener" argument must be a function');
|
|
734
|
+
if ((E = s._events) ? (E.newListener && (s.emit("newListener", c, d.listener ? d.listener : d), E = s._events), w = E[c]) : (E = s._events = new r(), s._eventsCount = 0), w) {
|
|
735
|
+
if (typeof w == "function" ? w = E[c] = f ? [d, w] : [w, d] : f ? w.unshift(d) : w.push(d), !w.warned && (_ = u(s)) && 0 < _ && w.length > _) {
|
|
736
|
+
w.warned = !0;
|
|
737
|
+
var L = new Error("Possible EventEmitter memory leak detected. " + w.length + " " + c + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
738
|
+
L.name = "MaxListenersExceededWarning", L.emitter = s, L.type = c, L.count = w.length, function(P) {
|
|
739
|
+
typeof console.warn == "function" ? console.warn(P) : console.log(P);
|
|
740
|
+
}(L);
|
|
741
|
+
}
|
|
742
|
+
} else w = E[c] = d, ++s._eventsCount;
|
|
743
|
+
return s;
|
|
744
|
+
}
|
|
745
|
+
function h(s, c, d) {
|
|
746
|
+
function f() {
|
|
747
|
+
s.removeListener(c, f), _ || (_ = !0, d.apply(s, arguments));
|
|
748
|
+
}
|
|
749
|
+
var _ = !1;
|
|
750
|
+
return f.listener = d, f;
|
|
751
|
+
}
|
|
752
|
+
function g(s) {
|
|
753
|
+
var c = this._events;
|
|
754
|
+
if (c) {
|
|
755
|
+
var d = c[s];
|
|
756
|
+
if (typeof d == "function") return 1;
|
|
757
|
+
if (d) return d.length;
|
|
758
|
+
}
|
|
759
|
+
return 0;
|
|
760
|
+
}
|
|
761
|
+
function p(s, c) {
|
|
762
|
+
for (var d = Array(c); c--; ) d[c] = s[c];
|
|
763
|
+
return d;
|
|
764
|
+
}
|
|
765
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), r.prototype = /* @__PURE__ */ Object.create(null), i.EventEmitter = i, i.usingDomains = !1, i.prototype.domain = void 0, i.prototype._events = void 0, i.prototype._maxListeners = void 0, i.defaultMaxListeners = 10, i.init = function() {
|
|
766
|
+
this.domain = null, i.usingDomains && n.active && !(this instanceof n.Domain) && (this.domain = n.active), this._events && this._events !== Object.getPrototypeOf(this)._events || (this._events = new r(), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
767
|
+
}, i.prototype.setMaxListeners = function(s) {
|
|
768
|
+
if (typeof s != "number" || 0 > s || isNaN(s)) throw new TypeError('"n" argument must be a positive number');
|
|
769
|
+
return this._maxListeners = s, this;
|
|
770
|
+
}, i.prototype.getMaxListeners = function() {
|
|
771
|
+
return u(this);
|
|
772
|
+
}, i.prototype.emit = function(s) {
|
|
773
|
+
var c, d, f, _, E, w, L, P = s === "error";
|
|
774
|
+
if (w = this._events) P = P && w.error == null;
|
|
775
|
+
else if (!P) return !1;
|
|
776
|
+
if (L = this.domain, P) {
|
|
777
|
+
if (c = arguments[1], !L) {
|
|
778
|
+
if (c instanceof Error) throw c;
|
|
779
|
+
var oe = new Error('Uncaught, unspecified "error" event. (' + c + ")");
|
|
780
|
+
throw oe.context = c, oe;
|
|
781
|
+
}
|
|
782
|
+
return c || (c = new Error('Uncaught, unspecified "error" event')), c.domainEmitter = this, c.domain = L, c.domainThrown = !1, L.emit("error", c), !1;
|
|
783
|
+
}
|
|
784
|
+
if (!(d = w[s])) return !1;
|
|
785
|
+
var ie = typeof d == "function";
|
|
786
|
+
switch (f = arguments.length) {
|
|
787
|
+
case 1:
|
|
788
|
+
(function(a, m, k) {
|
|
789
|
+
if (m) a.call(k);
|
|
790
|
+
else for (var A = a.length, U = p(a, A), Y = 0; Y < A; ++Y) U[Y].call(k);
|
|
791
|
+
})(d, ie, this);
|
|
792
|
+
break;
|
|
793
|
+
case 2:
|
|
794
|
+
(function(a, m, k, A) {
|
|
795
|
+
if (m) a.call(k, A);
|
|
796
|
+
else for (var U = a.length, Y = p(a, U), F = 0; F < U; ++F) Y[F].call(k, A);
|
|
797
|
+
})(d, ie, this, arguments[1]);
|
|
798
|
+
break;
|
|
799
|
+
case 3:
|
|
800
|
+
(function(a, m, k, A, U) {
|
|
801
|
+
if (m) a.call(k, A, U);
|
|
802
|
+
else for (var Y = a.length, F = p(a, Y), ae = 0; ae < Y; ++ae) F[ae].call(k, A, U);
|
|
803
|
+
})(d, ie, this, arguments[1], arguments[2]);
|
|
804
|
+
break;
|
|
805
|
+
case 4:
|
|
806
|
+
(function(a, m, k, A, U, Y) {
|
|
807
|
+
if (m) a.call(k, A, U, Y);
|
|
808
|
+
else for (var F = a.length, ae = p(a, F), H = 0; H < F; ++H) ae[H].call(k, A, U, Y);
|
|
809
|
+
})(d, ie, this, arguments[1], arguments[2], arguments[3]);
|
|
810
|
+
break;
|
|
811
|
+
default:
|
|
812
|
+
for (_ = Array(f - 1), E = 1; E < f; E++) _[E - 1] = arguments[E];
|
|
813
|
+
(function(a, m, k, A) {
|
|
814
|
+
if (m) a.apply(k, A);
|
|
815
|
+
else for (var U = a.length, Y = p(a, U), F = 0; F < U; ++F) Y[F].apply(k, A);
|
|
816
|
+
})(d, ie, this, _);
|
|
817
|
+
}
|
|
818
|
+
return !0;
|
|
819
|
+
}, i.prototype.addListener = function(s, c) {
|
|
820
|
+
return l(this, s, c, !1);
|
|
821
|
+
}, i.prototype.on = i.prototype.addListener, i.prototype.prependListener = function(s, c) {
|
|
822
|
+
return l(this, s, c, !0);
|
|
823
|
+
}, i.prototype.once = function(s, c) {
|
|
824
|
+
if (typeof c != "function") throw new TypeError('"listener" argument must be a function');
|
|
825
|
+
return this.on(s, h(this, s, c)), this;
|
|
826
|
+
}, i.prototype.prependOnceListener = function(s, c) {
|
|
827
|
+
if (typeof c != "function") throw new TypeError('"listener" argument must be a function');
|
|
828
|
+
return this.prependListener(s, h(this, s, c)), this;
|
|
829
|
+
}, i.prototype.removeListener = function(s, c) {
|
|
830
|
+
var d, f, _, E, w;
|
|
831
|
+
if (typeof c != "function") throw new TypeError('"listener" argument must be a function');
|
|
832
|
+
if (!(f = this._events)) return this;
|
|
833
|
+
if (!(d = f[s])) return this;
|
|
834
|
+
if (d === c || d.listener && d.listener === c) --this._eventsCount == 0 ? this._events = new r() : (delete f[s], f.removeListener && this.emit("removeListener", s, d.listener || c));
|
|
835
|
+
else if (typeof d != "function") {
|
|
836
|
+
for (_ = -1, E = d.length; 0 < E--; ) if (d[E] === c || d[E].listener && d[E].listener === c) {
|
|
837
|
+
w = d[E].listener, _ = E;
|
|
838
|
+
break;
|
|
839
|
+
}
|
|
840
|
+
if (0 > _) return this;
|
|
841
|
+
if (d.length === 1) {
|
|
842
|
+
if (d[0] = void 0, --this._eventsCount == 0) return this._events = new r(), this;
|
|
843
|
+
delete f[s];
|
|
844
|
+
} else (function(L, P) {
|
|
845
|
+
for (var oe = P, ie = oe + 1, a = L.length; ie < a; oe += 1, ie += 1) L[oe] = L[ie];
|
|
846
|
+
L.pop();
|
|
847
|
+
})(d, _);
|
|
848
|
+
f.removeListener && this.emit("removeListener", s, w || c);
|
|
849
|
+
}
|
|
850
|
+
return this;
|
|
851
|
+
}, i.prototype.removeAllListeners = function(s) {
|
|
852
|
+
var c, d;
|
|
853
|
+
if (!(d = this._events)) return this;
|
|
854
|
+
if (!d.removeListener) return arguments.length === 0 ? (this._events = new r(), this._eventsCount = 0) : d[s] && (--this._eventsCount == 0 ? this._events = new r() : delete d[s]), this;
|
|
855
|
+
if (arguments.length === 0) {
|
|
856
|
+
for (var f, _ = Object.keys(d), E = 0; E < _.length; ++E) (f = _[E]) !== "removeListener" && this.removeAllListeners(f);
|
|
857
|
+
return this.removeAllListeners("removeListener"), this._events = new r(), this._eventsCount = 0, this;
|
|
858
|
+
}
|
|
859
|
+
if (typeof (c = d[s]) == "function") this.removeListener(s, c);
|
|
860
|
+
else if (c) do
|
|
861
|
+
this.removeListener(s, c[c.length - 1]);
|
|
862
|
+
while (c[0]);
|
|
863
|
+
return this;
|
|
864
|
+
}, i.prototype.listeners = function(s) {
|
|
865
|
+
var c, d, f = this._events;
|
|
866
|
+
return f ? d = (c = f[s]) ? typeof c == "function" ? [c.listener || c] : function(_) {
|
|
867
|
+
for (var E = Array(_.length), w = 0; w < E.length; ++w) E[w] = _[w].listener || _[w];
|
|
868
|
+
return E;
|
|
869
|
+
}(c) : [] : d = [], d;
|
|
870
|
+
}, i.listenerCount = function(s, c) {
|
|
871
|
+
return typeof s.listenerCount == "function" ? s.listenerCount(c) : g.call(s, c);
|
|
872
|
+
}, i.prototype.listenerCount = g, i.prototype.eventNames = function() {
|
|
873
|
+
return 0 < this._eventsCount ? Reflect.ownKeys(this._events) : [];
|
|
874
|
+
};
|
|
875
|
+
var y, S = new Uint8Array(16);
|
|
876
|
+
function I() {
|
|
877
|
+
if (!y && !(y = 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");
|
|
878
|
+
return y(S);
|
|
879
|
+
}
|
|
880
|
+
for (var T = /^(?:[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 = [], D = 0; 256 > D; ++D) C.push((D + 256).toString(16).substr(1));
|
|
881
|
+
function b(s) {
|
|
882
|
+
var c = 1 < arguments.length && arguments[1] !== void 0 ? arguments[1] : 0, d = (C[s[c + 0]] + C[s[c + 1]] + C[s[c + 2]] + C[s[c + 3]] + "-" + C[s[c + 4]] + C[s[c + 5]] + "-" + C[s[c + 6]] + C[s[c + 7]] + "-" + C[s[c + 8]] + C[s[c + 9]] + "-" + C[s[c + 10]] + C[s[c + 11]] + C[s[c + 12]] + C[s[c + 13]] + C[s[c + 14]] + C[s[c + 15]]).toLowerCase();
|
|
883
|
+
if (!function(f) {
|
|
884
|
+
return typeof f == "string" && T.test(f);
|
|
885
|
+
}(d)) throw TypeError("Stringified UUID is invalid");
|
|
886
|
+
return d;
|
|
887
|
+
}
|
|
888
|
+
function j(s, c, d) {
|
|
889
|
+
var f = (s = s || {}).random || (s.rng || I)();
|
|
890
|
+
return f[6] = 64 | 15 & f[6], f[8] = 128 | 63 & f[8], b(f);
|
|
891
|
+
}
|
|
892
|
+
function $(s, c) {
|
|
893
|
+
if (!s || !c) return {};
|
|
894
|
+
const d = { ...s };
|
|
895
|
+
if (d.localCandidateId) {
|
|
896
|
+
const f = c.get(d.localCandidateId);
|
|
897
|
+
d.local = { ...f };
|
|
898
|
+
}
|
|
899
|
+
if (d.remoteCandidateId) {
|
|
900
|
+
const f = c.get(d.remoteCandidateId);
|
|
901
|
+
d.remote = { ...f };
|
|
902
|
+
}
|
|
903
|
+
return d;
|
|
904
|
+
}
|
|
905
|
+
function M(s, c, d) {
|
|
906
|
+
return 8 * function(f, _, E) {
|
|
907
|
+
const w = f[E], L = _ ? _[E] : null;
|
|
908
|
+
return w === null || L === null ? null : (w - L) / (f.timestamp - _.timestamp) * 1e3;
|
|
909
|
+
}(s, c, d);
|
|
910
|
+
}
|
|
911
|
+
function K(s) {
|
|
912
|
+
if (!s.entries) return s;
|
|
913
|
+
const c = {};
|
|
914
|
+
return s.forEach(function(d, f) {
|
|
915
|
+
c[f] = d;
|
|
916
|
+
}), c;
|
|
917
|
+
}
|
|
918
|
+
function G(s, c, d = {}) {
|
|
919
|
+
if (!s) return null;
|
|
920
|
+
let f = { audio: { inbound: [], outbound: [] }, video: { inbound: [], outbound: [] }, connection: { inbound: [], outbound: [] } };
|
|
921
|
+
d.remote && (f.remote = { audio: { inbound: [], outbound: [] }, video: { inbound: [], outbound: [] } });
|
|
922
|
+
for (const _ of s.values()) switch (_.type) {
|
|
923
|
+
case "outbound-rtp": {
|
|
924
|
+
const E = _.mediaType || _.kind, w = {};
|
|
925
|
+
let L = {};
|
|
926
|
+
if (!["audio", "video"].includes(E)) continue;
|
|
927
|
+
if (_.codecId) {
|
|
928
|
+
const P = s.get(_.codecId);
|
|
929
|
+
P && (w.clockRate = P.clockRate, w.mimeType = P.mimeType, w.payloadType = P.payloadType);
|
|
930
|
+
}
|
|
931
|
+
L = s.get(_.mediaSourceId) || s.get(_.trackId) || {}, f[E].outbound.push({ ..._, ...w, track: { ...L } });
|
|
932
|
+
break;
|
|
933
|
+
}
|
|
934
|
+
case "inbound-rtp": {
|
|
935
|
+
let E = _.mediaType || _.kind, w = {};
|
|
936
|
+
const L = {};
|
|
937
|
+
if (!["audio", "video"].includes(E)) if (_.id.includes("Video")) E = "video";
|
|
938
|
+
else {
|
|
939
|
+
if (!_.id.includes("Audio")) continue;
|
|
940
|
+
E = "audio";
|
|
941
|
+
}
|
|
942
|
+
if (_.codecId) {
|
|
943
|
+
const P = s.get(_.codecId);
|
|
944
|
+
P && (L.clockRate = P.clockRate, L.mimeType = P.mimeType, L.payloadType = P.payloadType);
|
|
945
|
+
}
|
|
946
|
+
if (!f.connection.id && _.transportId) {
|
|
947
|
+
const P = s.get(_.transportId);
|
|
948
|
+
if (P && P.selectedCandidatePairId) {
|
|
949
|
+
const oe = s.get(P.selectedCandidatePairId);
|
|
950
|
+
f.connection = $(oe, s);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
w = s.get(_.mediaSourceId) || s.get(_.trackId) || {}, f[E].inbound.push({ ..._, ...L, track: { ...w } });
|
|
954
|
+
break;
|
|
955
|
+
}
|
|
956
|
+
case "peer-connection":
|
|
957
|
+
f.connection.dataChannelsClosed = _.dataChannelsClosed, f.connection.dataChannelsOpened = _.dataChannelsOpened;
|
|
958
|
+
break;
|
|
959
|
+
case "remote-inbound-rtp": {
|
|
960
|
+
if (!d.remote) break;
|
|
961
|
+
let E = _.mediaType || _.kind;
|
|
962
|
+
const w = {};
|
|
963
|
+
if (!["audio", "video"].includes(E)) if (_.id.includes("Video")) E = "video";
|
|
964
|
+
else {
|
|
965
|
+
if (!_.id.includes("Audio")) continue;
|
|
966
|
+
E = "audio";
|
|
967
|
+
}
|
|
968
|
+
if (_.codecId) {
|
|
969
|
+
const L = s.get(_.codecId);
|
|
970
|
+
L && (w.clockRate = L.clockRate, w.mimeType = L.mimeType, w.payloadType = L.payloadType);
|
|
971
|
+
}
|
|
972
|
+
if (!f.connection.id && _.transportId) {
|
|
973
|
+
const L = s.get(_.transportId);
|
|
974
|
+
if (L && L.selectedCandidatePairId) {
|
|
975
|
+
const P = s.get(L.selectedCandidatePairId);
|
|
976
|
+
f.connection = $(P, s);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
f.remote[E].inbound.push({ ..._, ...w });
|
|
980
|
+
break;
|
|
981
|
+
}
|
|
982
|
+
case "remote-outbound-rtp": {
|
|
983
|
+
if (!d.remote) break;
|
|
984
|
+
const E = _.mediaType || _.kind, w = {};
|
|
985
|
+
if (!["audio", "video"].includes(E)) continue;
|
|
986
|
+
if (_.codecId) {
|
|
987
|
+
const L = s.get(_.codecId);
|
|
988
|
+
L && (w.clockRate = L.clockRate, w.mimeType = L.mimeType, w.payloadType = L.payloadType);
|
|
989
|
+
}
|
|
990
|
+
f.remote[E].outbound.push({ ..._, ...w });
|
|
991
|
+
break;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
if (!f.connection.id) for (const _ of s.values()) _.type === "candidate-pair" && _.nominated && _.state === "succeeded" && (f.connection = $(_, s));
|
|
995
|
+
return f = function(_, E) {
|
|
996
|
+
return E && (_.audio.inbound.map((w) => {
|
|
997
|
+
let L = E.audio.inbound.find((P) => P.id === w.id);
|
|
998
|
+
w.bitrate = M(w, L, "bytesReceived"), w.packetRate = M(w, L, "packetsReceived");
|
|
999
|
+
}), _.audio.outbound.map((w) => {
|
|
1000
|
+
let L = E.audio.outbound.find((P) => P.id === w.id);
|
|
1001
|
+
w.bitrate = M(w, L, "bytesSent"), w.packetRate = M(w, L, "packetsSent");
|
|
1002
|
+
}), _.video.inbound.map((w) => {
|
|
1003
|
+
let L = E.video.inbound.find((P) => P.id === w.id);
|
|
1004
|
+
w.bitrate = M(w, L, "bytesReceived"), w.packetRate = M(w, L, "packetsReceived");
|
|
1005
|
+
}), _.video.outbound.map((w) => {
|
|
1006
|
+
let L = E.video.outbound.find((P) => P.id === w.id);
|
|
1007
|
+
w.bitrate = M(w, L, "bytesSent"), w.packetRate = M(w, L, "packetsSent");
|
|
1008
|
+
})), _;
|
|
1009
|
+
}(f, c), f;
|
|
1010
|
+
}
|
|
1011
|
+
let ce, R = {}, x = [];
|
|
1012
|
+
e.WebRTCStats = class extends i {
|
|
1013
|
+
constructor(s) {
|
|
1014
|
+
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");
|
|
1015
|
+
const c = { ...s };
|
|
1016
|
+
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();
|
|
1017
|
+
}
|
|
1018
|
+
async addPeer(s, c) {
|
|
1019
|
+
return console.warn("The addPeer() method has been deprecated, please use addConnection()"), this.addConnection({ peerId: s, pc: c });
|
|
1020
|
+
}
|
|
1021
|
+
async addConnection(s) {
|
|
1022
|
+
const { pc: c, peerId: d } = s;
|
|
1023
|
+
let { connectionId: f, remote: _ } = s;
|
|
1024
|
+
if (_ = typeof _ == "boolean" ? _ : this.remote, !(c && c instanceof RTCPeerConnection)) throw new Error("Missing argument 'pc' or is not of instance RTCPeerConnection");
|
|
1025
|
+
if (!d) throw new Error("Missing argument peerId");
|
|
1026
|
+
if (this.isEdge) throw new Error("Can't monitor peers in Edge at this time.");
|
|
1027
|
+
if (this.peersToMonitor[d]) {
|
|
1028
|
+
if (f && f in this.peersToMonitor[d]) throw new Error(`We are already monitoring connection with id ${f}.`);
|
|
1029
|
+
for (let w in this.peersToMonitor[d]) {
|
|
1030
|
+
const L = this.peersToMonitor[d][w];
|
|
1031
|
+
if (L.pc === c) throw new Error(`We are already monitoring peer with id ${d}.`);
|
|
1032
|
+
L.pc.connectionState === "closed" && this.removeConnection({ pc: L.pc });
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
const E = c.getConfiguration();
|
|
1036
|
+
return E.iceServers && E.iceServers.forEach(function(w) {
|
|
1037
|
+
delete w.credential;
|
|
1038
|
+
}), f || (f = j()), this.emitEvent({ event: "addConnection", tag: "peer", peerId: d, connectionId: f, data: { options: s, peerConfiguration: E } }), this.monitorPeer({ peerId: d, connectionId: f, pc: c, remote: _ }), { connectionId: f };
|
|
1039
|
+
}
|
|
1040
|
+
getTimeline(s) {
|
|
1041
|
+
return this.timeline = this.timeline.sort((c, d) => c.timestamp.getTime() - d.timestamp.getTime()), s ? this.timeline.filter((c) => c.tag === s) : this.timeline;
|
|
1042
|
+
}
|
|
1043
|
+
get logger() {
|
|
1044
|
+
const s = (c) => {
|
|
1045
|
+
const d = ["none", "error", "warn", "info", "debug"];
|
|
1046
|
+
return d.slice(0, d.indexOf(this.logLevel) + 1).indexOf(c) > -1;
|
|
1047
|
+
};
|
|
1048
|
+
return { error(...c) {
|
|
1049
|
+
this.debug && s("error") && console.error("[webrtc-stats][error] ", ...c);
|
|
1050
|
+
}, warn(...c) {
|
|
1051
|
+
this.debug && s("warn") && console.warn("[webrtc-stats][warn] ", ...c);
|
|
1052
|
+
}, info(...c) {
|
|
1053
|
+
this.debug && s("info") && console.log("[webrtc-stats][info] ", ...c);
|
|
1054
|
+
}, debug(...c) {
|
|
1055
|
+
this.debug && s("debug") && console.debug("[webrtc-stats][debug] ", ...c);
|
|
1056
|
+
} };
|
|
1057
|
+
}
|
|
1058
|
+
removeConnection(s) {
|
|
1059
|
+
let c, { connectionId: d, pc: f } = s;
|
|
1060
|
+
if (!f && !d) throw new Error("Missing arguments. You need to either send pc or a connectionId.");
|
|
1061
|
+
if (d) {
|
|
1062
|
+
if (typeof d != "string") throw new Error("connectionId must be a string.");
|
|
1063
|
+
for (let _ in this.peersToMonitor) d in this.peersToMonitor[_] && (f = this.peersToMonitor[_][d].pc, c = _);
|
|
1064
|
+
} else if (f) {
|
|
1065
|
+
if (!(f instanceof RTCPeerConnection)) throw new Error("pc must be an instance of RTCPeerConnection.");
|
|
1066
|
+
for (let _ in this.peersToMonitor) for (let E in this.peersToMonitor[_]) this.peersToMonitor[_][E].pc === f && (d = E, c = _);
|
|
1067
|
+
}
|
|
1068
|
+
if (!f || !d) throw new Error("Could not find the desired connection.");
|
|
1069
|
+
return this.removePeerConnectionEventListeners(d, f), delete this.peersToMonitor[c][d], Object.values(this.peersToMonitor[c]).length === 0 && delete this.peersToMonitor[c], { connectionId: d };
|
|
1070
|
+
}
|
|
1071
|
+
removeAllPeers() {
|
|
1072
|
+
for (let s in this.peersToMonitor) this.removePeer(s);
|
|
1073
|
+
}
|
|
1074
|
+
removePeer(s) {
|
|
1075
|
+
if (this.logger.info(`Removing PeerConnection with id ${s}.`), this.peersToMonitor[s]) {
|
|
1076
|
+
for (let c in this.peersToMonitor[s]) {
|
|
1077
|
+
let d = this.peersToMonitor[s][c].pc;
|
|
1078
|
+
this.removePeerConnectionEventListeners(c, d);
|
|
1079
|
+
}
|
|
1080
|
+
delete this.peersToMonitor[s];
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
destroy() {
|
|
1084
|
+
this.removeAllPeers(), x.forEach((s) => {
|
|
1085
|
+
this.removeTrackEventListeners(s);
|
|
1086
|
+
}), x = [], this.shouldWrapGetUserMedia && ce && (navigator.mediaDevices.getUserMedia = ce);
|
|
1087
|
+
}
|
|
1088
|
+
monitorPeer(s) {
|
|
1089
|
+
let { peerId: c, connectionId: d, pc: f, remote: _ } = s;
|
|
1090
|
+
if (!f) return void this.logger.warn("Did not receive pc argument when calling monitorPeer()");
|
|
1091
|
+
const E = { pc: f, connectionId: d, stream: null, stats: { parsed: null, raw: null }, options: { remote: _ } };
|
|
1092
|
+
if (this.peersToMonitor[c]) {
|
|
1093
|
+
if (d in this.peersToMonitor[c]) return void this.logger.warn(`Already watching connection with ID ${d}`);
|
|
1094
|
+
this.peersToMonitor[c][d] = E;
|
|
1095
|
+
} else this.peersToMonitor[c] = { [d]: E };
|
|
1096
|
+
this.addPeerConnectionEventListeners(c, d, f), this.numberOfMonitoredPeers === 1 && (this.startStatsMonitoring(), this.startConnectionStateMonitoring());
|
|
1097
|
+
}
|
|
1098
|
+
startStatsMonitoring() {
|
|
1099
|
+
this.monitoringSetInterval || (this.monitoringSetInterval = window.setInterval(() => {
|
|
1100
|
+
this.numberOfMonitoredPeers || this.stopStatsMonitoring(), this.getStats().then((s) => {
|
|
1101
|
+
s.forEach((c) => {
|
|
1102
|
+
this.emitEvent(c);
|
|
1103
|
+
});
|
|
1104
|
+
});
|
|
1105
|
+
}, this._getStatsInterval));
|
|
1106
|
+
}
|
|
1107
|
+
stopStatsMonitoring() {
|
|
1108
|
+
this.monitoringSetInterval && (window.clearInterval(this.monitoringSetInterval), this.monitoringSetInterval = 0);
|
|
1109
|
+
}
|
|
1110
|
+
async getStats(s = null) {
|
|
1111
|
+
this.logger.info(s ? `Getting stats from peer ${s}` : "Getting stats from all peers");
|
|
1112
|
+
let c = {};
|
|
1113
|
+
if (s) {
|
|
1114
|
+
if (!this.peersToMonitor[s]) throw new Error(`Cannot get stats. Peer with id ${s} does not exist`);
|
|
1115
|
+
c[s] = this.peersToMonitor[s];
|
|
1116
|
+
} else c = this.peersToMonitor;
|
|
1117
|
+
let d = [];
|
|
1118
|
+
for (const f in c) for (const _ in c[f]) {
|
|
1119
|
+
const E = c[f][_], w = E.pc;
|
|
1120
|
+
if (w && !this.checkIfConnectionIsClosed(f, _, w)) try {
|
|
1121
|
+
const L = this.getTimestamp(), P = w.getStats(null);
|
|
1122
|
+
if (P) {
|
|
1123
|
+
const oe = await P, ie = this.getTimestamp(), a = K(oe), m = { remote: E.options.remote }, k = G(oe, E.stats.parsed, m), A = { event: "stats", tag: "stats", peerId: f, connectionId: _, timeTaken: ie - L, data: k };
|
|
1124
|
+
this.rawStats === !0 && (A.rawStats = oe), this.statsObject === !0 && (A.statsObject = a), this.filteredStats === !0 && (A.filteredStats = this.filteroutStats(a)), d.push(A), E.stats.parsed = k;
|
|
1125
|
+
} else this.logger.error(`PeerConnection from peer ${f} did not return any stats data`);
|
|
1126
|
+
} catch (L) {
|
|
1127
|
+
this.logger.error(L);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
return d;
|
|
1131
|
+
}
|
|
1132
|
+
startConnectionStateMonitoring() {
|
|
1133
|
+
this.connectionMonitoringSetInterval = window.setInterval(() => {
|
|
1134
|
+
this.numberOfMonitoredPeers || this.stopConnectionStateMonitoring();
|
|
1135
|
+
for (const s in this.peersToMonitor) for (const c in this.peersToMonitor[s]) {
|
|
1136
|
+
const d = this.peersToMonitor[s][c].pc;
|
|
1137
|
+
this.checkIfConnectionIsClosed(s, c, d);
|
|
1138
|
+
}
|
|
1139
|
+
}, this.connectionMonitoringInterval);
|
|
1140
|
+
}
|
|
1141
|
+
checkIfConnectionIsClosed(s, c, d) {
|
|
1142
|
+
const f = this.isConnectionClosed(d);
|
|
1143
|
+
if (f) {
|
|
1144
|
+
this.removeConnection({ pc: d });
|
|
1145
|
+
let _ = d.connectionState === "closed" ? "onconnectionstatechange" : "oniceconnectionstatechange";
|
|
1146
|
+
this.emitEvent({ event: _, peerId: s, connectionId: c, tag: "connection", data: "closed" });
|
|
1147
|
+
}
|
|
1148
|
+
return f;
|
|
1149
|
+
}
|
|
1150
|
+
isConnectionClosed(s) {
|
|
1151
|
+
return s.connectionState === "closed" || s.iceConnectionState === "closed";
|
|
1152
|
+
}
|
|
1153
|
+
stopConnectionStateMonitoring() {
|
|
1154
|
+
this.connectionMonitoringSetInterval && (window.clearInterval(this.connectionMonitoringSetInterval), this.connectionMonitoringSetInterval = 0);
|
|
1155
|
+
}
|
|
1156
|
+
wrapGetUserMedia() {
|
|
1157
|
+
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) return void this.logger.warn("'navigator.mediaDevices.getUserMedia' is not available in browser. Will not wrap getUserMedia.");
|
|
1158
|
+
this.logger.info("Wrapping getUsermedia functions."), ce = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
|
|
1159
|
+
const s = this.parseGetUserMedia.bind(this);
|
|
1160
|
+
navigator.mediaDevices.getUserMedia = (function() {
|
|
1161
|
+
return s({ constraints: arguments[0] }), ce.apply(navigator.mediaDevices, arguments).then((c) => (s({ stream: c }), c), (c) => (s({ error: c }), Promise.reject(c)));
|
|
1162
|
+
}).bind(navigator.mediaDevices);
|
|
1163
|
+
}
|
|
1164
|
+
filteroutStats(s = {}) {
|
|
1165
|
+
const c = { ...s };
|
|
1166
|
+
for (const f in c) {
|
|
1167
|
+
var d = c[f];
|
|
1168
|
+
this.statsToMonitor.includes(d.type) || delete c[f];
|
|
1169
|
+
}
|
|
1170
|
+
return c;
|
|
1171
|
+
}
|
|
1172
|
+
get peerConnectionListeners() {
|
|
1173
|
+
return { icecandidate: (s, c, d, f) => {
|
|
1174
|
+
this.logger.debug("[pc-event] icecandidate | peerId: ${peerId}", f), this.emitEvent({ event: "onicecandidate", tag: "connection", peerId: s, connectionId: c, data: f.candidate });
|
|
1175
|
+
}, track: (s, c, d, f) => {
|
|
1176
|
+
this.logger.debug(`[pc-event] track | peerId: ${s}`, f);
|
|
1177
|
+
const _ = f.track, E = f.streams[0];
|
|
1178
|
+
s in this.peersToMonitor && c in this.peersToMonitor[s] && (this.peersToMonitor[s][c].stream = E), this.addTrackEventListeners(_, c), this.emitEvent({ event: "ontrack", tag: "track", peerId: s, connectionId: c, data: { stream: E ? this.getStreamDetails(E) : null, track: _ ? this.getMediaTrackDetails(_) : null, title: f.track.kind + ":" + f.track.id + " " + f.streams.map(function(w) {
|
|
1179
|
+
return "stream:" + w.id;
|
|
1180
|
+
}) } });
|
|
1181
|
+
}, signalingstatechange: (s, c, d) => {
|
|
1182
|
+
this.logger.debug(`[pc-event] signalingstatechange | peerId: ${s}`), this.emitEvent({ event: "onsignalingstatechange", tag: "connection", peerId: s, connectionId: c, data: { signalingState: d.signalingState, localDescription: d.localDescription, remoteDescription: d.remoteDescription } });
|
|
1183
|
+
}, iceconnectionstatechange: (s, c, d) => {
|
|
1184
|
+
this.logger.debug(`[pc-event] iceconnectionstatechange | peerId: ${s}`), this.emitEvent({ event: "oniceconnectionstatechange", tag: "connection", peerId: s, connectionId: c, data: d.iceConnectionState });
|
|
1185
|
+
}, icegatheringstatechange: (s, c, d) => {
|
|
1186
|
+
this.logger.debug(`[pc-event] icegatheringstatechange | peerId: ${s}`), this.emitEvent({ event: "onicegatheringstatechange", tag: "connection", peerId: s, connectionId: c, data: d.iceGatheringState });
|
|
1187
|
+
}, icecandidateerror: (s, c, d, f) => {
|
|
1188
|
+
this.logger.debug(`[pc-event] icecandidateerror | peerId: ${s}`), this.emitEvent({ event: "onicecandidateerror", tag: "connection", peerId: s, connectionId: c, error: { errorCode: f.errorCode } });
|
|
1189
|
+
}, connectionstatechange: (s, c, d) => {
|
|
1190
|
+
this.logger.debug(`[pc-event] connectionstatechange | peerId: ${s}`), this.emitEvent({ event: "onconnectionstatechange", tag: "connection", peerId: s, connectionId: c, data: d.connectionState });
|
|
1191
|
+
}, negotiationneeded: (s, c, d) => {
|
|
1192
|
+
this.logger.debug(`[pc-event] negotiationneeded | peerId: ${s}`), this.emitEvent({ event: "onnegotiationneeded", tag: "connection", peerId: s, connectionId: c });
|
|
1193
|
+
}, datachannel: (s, c, d, f) => {
|
|
1194
|
+
this.logger.debug(`[pc-event] datachannel | peerId: ${s}`, f), this.emitEvent({ event: "ondatachannel", tag: "datachannel", peerId: s, connectionId: c, data: f.channel });
|
|
1195
|
+
} };
|
|
1196
|
+
}
|
|
1197
|
+
addPeerConnectionEventListeners(s, c, d) {
|
|
1198
|
+
this.logger.debug(`Adding event listeners for peer ${s} and connection ${c}.`), R[c] = {}, Object.keys(this.peerConnectionListeners).forEach((f) => {
|
|
1199
|
+
R[c][f] = this.peerConnectionListeners[f].bind(this, s, c, d), d.addEventListener(f, R[c][f], !1);
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
parseGetUserMedia(s) {
|
|
1203
|
+
try {
|
|
1204
|
+
const c = { event: "getUserMedia", tag: "getUserMedia", data: { ...s } };
|
|
1205
|
+
s.stream && (c.data.details = this.parseStream(s.stream), s.stream.getTracks().map((d) => {
|
|
1206
|
+
this.addTrackEventListeners(d), x.push(d);
|
|
1207
|
+
})), this.emitEvent(c);
|
|
1208
|
+
} catch {
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
parseStream(s) {
|
|
1212
|
+
const c = { audio: [], video: [] };
|
|
1213
|
+
return s.getTracks().forEach((d) => {
|
|
1214
|
+
c[d.kind].push(this.getMediaTrackDetails(d));
|
|
1215
|
+
}), c;
|
|
1216
|
+
}
|
|
1217
|
+
getMediaTrackDetails(s) {
|
|
1218
|
+
return { enabled: s.enabled, id: s.id, contentHint: s.contentHint, kind: s.kind, label: s.label, muted: s.muted, readyState: s.readyState, constructorName: s.constructor.name, capabilities: s.getCapabilities ? s.getCapabilities() : {}, constraints: s.getConstraints ? s.getConstraints() : {}, settings: s.getSettings ? s.getSettings() : {}, _track: s };
|
|
1219
|
+
}
|
|
1220
|
+
getStreamDetails(s) {
|
|
1221
|
+
return { active: s.active, id: s.id, _stream: s };
|
|
1222
|
+
}
|
|
1223
|
+
getTrackEventObject(s) {
|
|
1224
|
+
return { mute: (c) => {
|
|
1225
|
+
this.emitEvent({ event: "mute", tag: "track", connectionId: s, data: { event: c } });
|
|
1226
|
+
}, unmute: (c) => {
|
|
1227
|
+
this.emitEvent({ event: "unmute", tag: "track", connectionId: s, data: { event: c } });
|
|
1228
|
+
}, overconstrained: (c) => {
|
|
1229
|
+
this.emitEvent({ event: "overconstrained", tag: "track", connectionId: s, data: { event: c } });
|
|
1230
|
+
}, ended: (c) => {
|
|
1231
|
+
this.emitEvent({ event: "ended", tag: "track", connectionId: s, data: { event: c } }), this.removeTrackEventListeners(c.target);
|
|
1232
|
+
} };
|
|
1233
|
+
}
|
|
1234
|
+
addTrackEventListeners(s, c) {
|
|
1235
|
+
R[s.id] = {};
|
|
1236
|
+
const d = this.getTrackEventObject(c);
|
|
1237
|
+
Object.keys(d).forEach((f) => {
|
|
1238
|
+
R[s.id][f] = d[f].bind(this), s.addEventListener(f, R[s.id][f]);
|
|
1239
|
+
}), R[s.id].readyState = setInterval(() => {
|
|
1240
|
+
if (s.readyState === "ended") {
|
|
1241
|
+
let f = new CustomEvent("ended", { detail: { check: "readyState" } });
|
|
1242
|
+
s.dispatchEvent(f);
|
|
1243
|
+
}
|
|
1244
|
+
}, 1e3);
|
|
1245
|
+
}
|
|
1246
|
+
removeTrackEventListeners(s) {
|
|
1247
|
+
if (s.id in R) {
|
|
1248
|
+
const c = this.getTrackEventObject();
|
|
1249
|
+
Object.keys(c).forEach((d) => {
|
|
1250
|
+
s.removeEventListener(d, R[s.id][d]);
|
|
1251
|
+
}), clearInterval(R[s.id].readyState), delete R[s.id];
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
addToTimeline(s) {
|
|
1255
|
+
this.timeline.push(s), this.emit("timeline", s);
|
|
1256
|
+
}
|
|
1257
|
+
emitEvent(s) {
|
|
1258
|
+
const c = { ...s, timestamp: /* @__PURE__ */ new Date() };
|
|
1259
|
+
this.addToTimeline(c), c.tag && this.emit(c.tag, c);
|
|
1260
|
+
}
|
|
1261
|
+
set getStatsInterval(s) {
|
|
1262
|
+
if (!Number.isInteger(s)) throw new Error(`getStatsInterval should be an integer, got: ${s}`);
|
|
1263
|
+
this._getStatsInterval = s, this.monitoringSetInterval && (this.stopStatsMonitoring(), this.startStatsMonitoring());
|
|
1264
|
+
}
|
|
1265
|
+
get numberOfMonitoredPeers() {
|
|
1266
|
+
return Object.keys(this.peersToMonitor).length;
|
|
1267
|
+
}
|
|
1268
|
+
removePeerConnectionEventListeners(s, c) {
|
|
1269
|
+
s in R && (Object.keys(this.peerConnectionListeners).forEach((d) => {
|
|
1270
|
+
c.removeEventListener(d, R[s][d], !1);
|
|
1271
|
+
}), delete R[s]), c.getSenders().forEach((d) => {
|
|
1272
|
+
d.track && this.removeTrackEventListeners(d.track);
|
|
1273
|
+
}), c.getReceivers().forEach((d) => {
|
|
1274
|
+
d.track && this.removeTrackEventListeners(d.track);
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
getTimestamp() {
|
|
1278
|
+
return Date.now();
|
|
1279
|
+
}
|
|
1280
|
+
wrapGetDisplayMedia() {
|
|
1281
|
+
const s = this;
|
|
1282
|
+
if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
|
|
1283
|
+
const c = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices), d = function() {
|
|
1284
|
+
return s.debug("navigator.mediaDevices.getDisplayMedia", null, arguments[0]), c.apply(navigator.mediaDevices, arguments).then(function(f) {
|
|
1285
|
+
return f;
|
|
1286
|
+
}, function(f) {
|
|
1287
|
+
return s.debug("navigator.mediaDevices.getDisplayMediaOnFailure", null, f.name), Promise.reject(f);
|
|
1288
|
+
});
|
|
1289
|
+
};
|
|
1290
|
+
navigator.mediaDevices.getDisplayMedia = d.bind(navigator.mediaDevices);
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
};
|
|
1294
|
+
});
|
|
1295
|
+
(Xe = Gn) && Xe.__esModule && Object.prototype.hasOwnProperty.call(Xe, "default") && Xe.default;
|
|
1296
|
+
var Dr = Gn.WebRTCStats;
|
|
1297
|
+
function jr(t) {
|
|
1298
|
+
const { packetsLost: e, packetsReceived: n, jitter: r, rtt: i } = t, u = function(p) {
|
|
1299
|
+
const { jitter: y, rtt: S } = p, I = y + S / 2;
|
|
1300
|
+
return 0.024 * I + 0.11 * (I - 177.3) * (I > 177.3 ? 1 : 0);
|
|
1301
|
+
}({ rtt: i, jitter: r }), l = function(p) {
|
|
1302
|
+
const { packetsLost: y, packetsReceived: S } = p, I = y / (S + y) * 100;
|
|
1303
|
+
return 20 * Math.log(1 + I);
|
|
1304
|
+
}({ packetsLost: e, packetsReceived: n }), h = 93.2 - u - l + 0, g = 1 + 0.035 * h + 7e-6 * h * (h - 60) * (100 - h);
|
|
1305
|
+
return Math.min(Math.max(g, 1), 5);
|
|
1306
|
+
}
|
|
1307
|
+
function Ur(t) {
|
|
1308
|
+
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";
|
|
1309
|
+
}
|
|
1310
|
+
class $r extends We {
|
|
1311
|
+
constructor(e) {
|
|
1312
|
+
super(), this.buildRequest({ type: "debug_report_start", debug_report_id: e, debug_report_version: 1 });
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
class Vr extends We {
|
|
1316
|
+
constructor(e) {
|
|
1317
|
+
super(), this.buildRequest({ type: "debug_report_stop", debug_report_id: e, debug_report_version: 1 });
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
class Gr extends We {
|
|
1321
|
+
constructor(e, n) {
|
|
1322
|
+
super(), this.buildRequest({ type: "debug_report_data", debug_report_id: e, debug_report_version: 1, debug_report_data: n });
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
function Fr(t) {
|
|
1326
|
+
const e = Ie(), n = new Dr({ getStatsInterval: 1e3, rawStats: !1, statsObject: !0, filteredStats: !1, remote: !0, debug: !1, logLevel: "warn" }), r = (i) => q(this, void 0, void 0, function* () {
|
|
1327
|
+
i.event === "stats" && X(V.StatsFrame, function({ data: u }) {
|
|
1328
|
+
var l, h, g, p, y, S, I, T;
|
|
1329
|
+
const { audio: C, remote: D } = u, { audio: b } = D, j = (h = (l = b.inbound[0]) === null || l === void 0 ? void 0 : l.jitter) !== null && h !== void 0 ? h : 1 / 0, $ = (p = (g = b.inbound[0]) === null || g === void 0 ? void 0 : g.roundTripTime) !== null && p !== void 0 ? p : 1 / 0, M = (S = (y = C.inbound[0]) === null || y === void 0 ? void 0 : y.packetsReceived) !== null && S !== void 0 ? S : -1, K = (T = (I = C.inbound[0]) === null || I === void 0 ? void 0 : I.packetsLost) !== null && T !== void 0 ? T : -1, G = jr({ jitter: 1e3 * j, rtt: 1e3 * $, packetsLost: K, packetsReceived: M });
|
|
1330
|
+
return { jitter: j, rtt: $, mos: G, quality: Ur(G), inboundAudio: C.inbound[0], outboundAudio: C.outbound[0], remoteInboundAudio: b.inbound[0], remoteOutboundAudio: b.outbound[0] };
|
|
1331
|
+
}(i), t.uuid), yield t.execute(new Gr(e, i));
|
|
1332
|
+
});
|
|
1333
|
+
return { start: (i, u, l) => q(this, void 0, void 0, function* () {
|
|
1334
|
+
yield t.execute(new $r(e)), n.on("timeline", r), yield new Promise((h) => setTimeout(h, 500)), n.addConnection({ pc: i, peerId: u, connectionId: l });
|
|
1335
|
+
}), stop: (i) => q(this, void 0, void 0, function* () {
|
|
1336
|
+
const u = n.getTimeline();
|
|
1337
|
+
X(V.StatsReport, u, t.uuid), i === "file" && function(l, h) {
|
|
1338
|
+
const g = new Blob([JSON.stringify(l)], { type: "application/json" }), p = URL.createObjectURL(g), y = document.createElement("a");
|
|
1339
|
+
y.href = p, y.download = `${h}.json`, y.click(), URL.revokeObjectURL(p);
|
|
1340
|
+
}(u, `webrtc-stats-${e}-${Date.now()}`), yield t.execute(new Vr(e)), n.removeAllPeers(), n.destroy();
|
|
1341
|
+
}) };
|
|
1342
|
+
}
|
|
1343
|
+
class dn {
|
|
1344
|
+
constructor(e, n, r) {
|
|
1345
|
+
this.type = e, this.options = n, this.onSdpReadyTwice = null, this.statsReporter = null, this._negotiating = !1, this.handleConnectionStateChange = (i) => q(this, void 0, void 0, function* () {
|
|
1346
|
+
const { connectionState: u } = this.instance;
|
|
1347
|
+
if (console.log(`[${(/* @__PURE__ */ new Date()).toISOString()}] Connection State`, u), u === "failed" || u === "disconnected") {
|
|
1348
|
+
const l = () => {
|
|
1349
|
+
this.instance.restartIce(), this._session._closeConnection(), this._session.connect(), window.removeEventListener("online", l);
|
|
1350
|
+
};
|
|
1351
|
+
if (navigator.onLine) return l();
|
|
1352
|
+
window.addEventListener("online", l);
|
|
1353
|
+
}
|
|
1354
|
+
}), this._handleIceConnectionStateChange = (i) => {
|
|
1355
|
+
console.log(`[${(/* @__PURE__ */ new Date()).toISOString()}] ICE Connection State`, this.instance.iceConnectionState);
|
|
1356
|
+
}, this._handleIceGatheringStateChange = (i) => {
|
|
1357
|
+
console.log(`[${(/* @__PURE__ */ new Date()).toISOString()}] ICE Gathering State`, this.instance.iceGatheringState);
|
|
1358
|
+
}, this._setAudioCodec = (i) => {
|
|
1359
|
+
if (this.options.preferred_codecs && this.options.preferred_codecs.length !== 0) return i.setCodecPreferences ? i.setCodecPreferences(this.options.preferred_codecs) : void 0;
|
|
1360
|
+
}, B.info("New Peer with type:", this.type, "Options:", this.options), this._constraints = { offerToReceiveAudio: !0, offerToReceiveVideo: !0 }, 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 = r, this._init(), this.isDebugEnabled && (this.statsReporter = Fr(r));
|
|
1361
|
+
}
|
|
1362
|
+
get isOffer() {
|
|
1363
|
+
return this.type === ge.Offer;
|
|
1364
|
+
}
|
|
1365
|
+
get isAnswer() {
|
|
1366
|
+
return this.type === ge.Answer;
|
|
1367
|
+
}
|
|
1368
|
+
get isDebugEnabled() {
|
|
1369
|
+
return this.options.debug || this._session.options.debug;
|
|
1370
|
+
}
|
|
1371
|
+
get debugOutput() {
|
|
1372
|
+
return this.options.debugOutput || this._session.options.debugOutput;
|
|
1373
|
+
}
|
|
1374
|
+
startNegotiation() {
|
|
1375
|
+
this._negotiating = !0, this._isOffer() ? this._createOffer() : this._createAnswer();
|
|
1376
|
+
}
|
|
1377
|
+
_logTransceivers() {
|
|
1378
|
+
B.info("Number of transceivers:", this.instance.getTransceivers().length), this.instance.getTransceivers().forEach((e, n) => {
|
|
1379
|
+
B.info(`>> Transceiver [${n}]:`, e.mid, e.direction, e.stopped), B.info(`>> Sender Params [${n}]:`, JSON.stringify(e.sender.getParameters(), null, 2));
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
handleSignalingStateChangeEvent(e) {
|
|
1383
|
+
switch (B.info("signalingState:", this.instance.signalingState), this.instance.signalingState) {
|
|
1384
|
+
case "stable":
|
|
1385
|
+
this._negotiating = !1;
|
|
1386
|
+
break;
|
|
1387
|
+
case "closed":
|
|
1388
|
+
this.instance = null;
|
|
1389
|
+
break;
|
|
1390
|
+
default:
|
|
1391
|
+
this._negotiating = !0;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
handleNegotiationNeededEvent() {
|
|
1395
|
+
B.info("Negotiation needed event"), this.instance.signalingState === "stable" && this.startNegotiation();
|
|
1396
|
+
}
|
|
1397
|
+
handleTrackEvent(e) {
|
|
1398
|
+
const { streams: [n] } = e, { remoteElement: r, screenShare: i } = this.options;
|
|
1399
|
+
let { remoteStream: u } = this.options;
|
|
1400
|
+
u = n, i === !1 && it(r, u);
|
|
1401
|
+
}
|
|
1402
|
+
createPeerConnection() {
|
|
1403
|
+
return q(this, void 0, void 0, function* () {
|
|
1404
|
+
var e;
|
|
1405
|
+
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) => {
|
|
1406
|
+
this.options.remoteStream = n.stream;
|
|
1407
|
+
}), this.options.localStream = yield this._retrieveLocalStream().catch((n) => (X(V.MediaError, n, this.options.id), null));
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
_init() {
|
|
1411
|
+
var e;
|
|
1412
|
+
return q(this, void 0, void 0, function* () {
|
|
1413
|
+
yield this.createPeerConnection(), yield (e = this.statsReporter) === null || e === void 0 ? void 0 : e.start(this.instance, this._session.sessionid, this._session.sessionid);
|
|
1414
|
+
const { localElement: n, localStream: r = null, screenShare: i = !1 } = this.options;
|
|
1415
|
+
if (ot(r)) {
|
|
1416
|
+
const u = r.getAudioTracks();
|
|
1417
|
+
B.info("Local audio tracks: ", u);
|
|
1418
|
+
const l = r.getVideoTracks();
|
|
1419
|
+
if (B.info("Local video tracks: ", l), this.isOffer && typeof this.instance.addTransceiver == "function") {
|
|
1420
|
+
const h = { direction: "sendrecv", streams: [r] };
|
|
1421
|
+
u.forEach((g) => {
|
|
1422
|
+
this.options.userVariables.microphoneLabel = g.label;
|
|
1423
|
+
const p = this.instance.addTransceiver(g, h);
|
|
1424
|
+
this._setAudioCodec(p);
|
|
1425
|
+
}), console.debug("Applying video transceiverParams", h), l.forEach((g) => {
|
|
1426
|
+
this.options.userVariables.cameraLabel = g.label, this.instance.addTransceiver(g, h);
|
|
1427
|
+
});
|
|
1428
|
+
} else typeof this.instance.addTrack == "function" ? (u.forEach((h) => {
|
|
1429
|
+
this.options.userVariables.microphoneLabel = h.label, this.instance.addTrack(h, r);
|
|
1430
|
+
}), this.instance.getTransceivers().forEach((h) => this._setAudioCodec(h)), l.forEach((h) => {
|
|
1431
|
+
this.options.userVariables.cameraLabel = h.label, this.instance.addTrack(h, r);
|
|
1432
|
+
})) : this.instance.addStream(r);
|
|
1433
|
+
i === !1 && (((h) => {
|
|
1434
|
+
const g = $e(h);
|
|
1435
|
+
g && (g.muted = !0);
|
|
1436
|
+
})(n), it(n, r));
|
|
1437
|
+
}
|
|
1438
|
+
this.isOffer ? (this.options.negotiateAudio && this._checkMediaToNegotiate("audio"), this.options.negotiateVideo && this._checkMediaToNegotiate("video")) : this.startNegotiation(), this._logTransceivers();
|
|
1439
|
+
});
|
|
1440
|
+
}
|
|
1441
|
+
_getSenderByKind(e) {
|
|
1442
|
+
return this.instance.getSenders().find(({ track: n }) => n && n.kind === e);
|
|
1443
|
+
}
|
|
1444
|
+
_checkMediaToNegotiate(e) {
|
|
1445
|
+
if (!this._getSenderByKind(e)) {
|
|
1446
|
+
const n = this.instance.addTransceiver(e);
|
|
1447
|
+
B.info("Add transceiver", e, n);
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
_createOffer() {
|
|
1451
|
+
return q(this, void 0, void 0, function* () {
|
|
1452
|
+
this._isOffer() && (this._constraints.offerToReceiveAudio = !!this.options.audio, this._constraints.offerToReceiveVideo = !!this.options.video, B.info("_createOffer - this._constraints", this._constraints), yield this.instance.createOffer(this._constraints).then(this._setLocalDescription.bind(this)).then(this._sdpReady).catch((e) => B.error("Peer _createOffer error:", e)));
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
_setRemoteDescription(e) {
|
|
1456
|
+
return q(this, void 0, void 0, function* () {
|
|
1457
|
+
yield this.instance.setRemoteDescription(e);
|
|
1458
|
+
});
|
|
1459
|
+
}
|
|
1460
|
+
_createAnswer() {
|
|
1461
|
+
return q(this, void 0, void 0, function* () {
|
|
1462
|
+
if (!this._isAnswer()) return;
|
|
1463
|
+
if (this.instance.signalingState !== "stable") return console.log(" - 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: ge.Offer })]));
|
|
1464
|
+
yield this._setRemoteDescription({ sdp: this.options.remoteSdp, type: ge.Offer }), this._logTransceivers();
|
|
1465
|
+
const e = yield this.instance.createAnswer();
|
|
1466
|
+
yield this._setLocalDescription(e);
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
_setLocalDescription(e) {
|
|
1470
|
+
return q(this, void 0, void 0, function* () {
|
|
1471
|
+
const { useStereo: n, googleMaxBitrate: r, googleMinBitrate: i, googleStartBitrate: u, mediaSettings: l } = this.options;
|
|
1472
|
+
n && (e.sdp = ((h) => {
|
|
1473
|
+
const p = h.split(`\r
|
|
1474
|
+
`), y = p.findIndex((C) => /^a=rtpmap/.test(C) && /opus\/48000/.test(C));
|
|
1475
|
+
if (y < 0) return h;
|
|
1476
|
+
const S = ((C) => {
|
|
1477
|
+
const D = new RegExp("a=rtpmap:(\\d+) \\w+\\/\\d+"), b = C.match(D);
|
|
1478
|
+
return b && b.length == 2 ? b[1] : null;
|
|
1479
|
+
})(p[y]), I = new RegExp(`a=fmtp:${S}`), T = p.findIndex((C) => I.test(C));
|
|
1480
|
+
return T >= 0 ? /stereo=1;/.test(p[T]) || (p[T] += "; stereo=1; sprop-stereo=1") : p[y] += `\r
|
|
1481
|
+
a=fmtp:${S} stereo=1; sprop-stereo=1`, p.join(`\r
|
|
1482
|
+
`);
|
|
1483
|
+
})(e.sdp)), r && i && u && (e.sdp = ((h, g, p, y) => {
|
|
1484
|
+
const S = h.split(`\r
|
|
1485
|
+
`);
|
|
1486
|
+
return S.forEach((I, T) => {
|
|
1487
|
+
/^a=fmtp:\d*/.test(I) ? S[T] += `;x-google-max-bitrate=${g};x-google-min-bitrate=${p};x-google-start-bitrate=${y}` : /^a=mid:(1|video)/.test(I) && (S[T] += `\r
|
|
1488
|
+
b=AS:${g}`);
|
|
1489
|
+
}), S.join(`\r
|
|
1490
|
+
`);
|
|
1491
|
+
})(e.sdp, r, i, u)), l && l.useSdpASBandwidthKbps && l.sdpASBandwidthKbps !== null && (e.sdp = ((h, g) => {
|
|
1492
|
+
let p = "AS", y = g;
|
|
1493
|
+
return !navigator.userAgent.match(/firefox/gim) || navigator.userAgent.match(/OPR\/[0-9]{2}/gi) || navigator.userAgent.match(/edg/gim) || (p = "TIAS", y = 1e3 * (g >>> 0)), h.indexOf("b=" + p + ":") === -1 ? h.replace(/c=IN (.*)\r\n/, `c=IN $1\r
|
|
1494
|
+
b=` + p + ":" + y + `\r
|
|
1495
|
+
`) : h.replace(new RegExp("b=" + p + `:.*\r
|
|
1496
|
+
`), "b=" + p + ":" + y + `\r
|
|
1497
|
+
`);
|
|
1498
|
+
})(e.sdp, l.sdpASBandwidthKbps)), yield this.instance.setLocalDescription(e);
|
|
1499
|
+
});
|
|
1500
|
+
}
|
|
1501
|
+
_sdpReady() {
|
|
1502
|
+
ke(this.onSdpReadyTwice) && this.onSdpReadyTwice(this.instance.localDescription);
|
|
1503
|
+
}
|
|
1504
|
+
_retrieveLocalStream() {
|
|
1505
|
+
return q(this, void 0, void 0, function* () {
|
|
1506
|
+
if (ot(this.options.localStream)) return this.options.localStream;
|
|
1507
|
+
const e = yield (n = this.options, q(void 0, void 0, void 0, function* () {
|
|
1508
|
+
let { audio: r = !0, micId: i } = n;
|
|
1509
|
+
const { micLabel: u = "" } = n;
|
|
1510
|
+
i && (i = yield at(i, u, _e.AudioIn).catch((p) => null), i && (typeof r == "boolean" && (r = {}), r.deviceId = { exact: i }));
|
|
1511
|
+
let { camId: l } = n, h = n.video;
|
|
1512
|
+
const { camLabel: g = "" } = n;
|
|
1513
|
+
return l && (l = yield at(l, g, _e.Video).catch((p) => null), l && (typeof h == "boolean" && (h = {}), h.deviceId = { exact: l })), { audio: r, video: h };
|
|
1514
|
+
}));
|
|
1515
|
+
var n;
|
|
1516
|
+
return st(e);
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
_isOffer() {
|
|
1520
|
+
return this.type === ge.Offer;
|
|
1521
|
+
}
|
|
1522
|
+
_isAnswer() {
|
|
1523
|
+
return this.type === ge.Answer;
|
|
1524
|
+
}
|
|
1525
|
+
_config() {
|
|
1526
|
+
const { prefetchIceCandidates: e, forceRelayCandidate: n } = this.options, r = { bundlePolicy: "max-compat", iceCandidatePoolSize: e ? 10 : 0, iceServers: [cr, On], iceTransportPolicy: n ? "relay" : "all" };
|
|
1527
|
+
return B.info("RTC config", r), r;
|
|
1528
|
+
}
|
|
1529
|
+
close() {
|
|
1530
|
+
var e;
|
|
1531
|
+
return q(this, void 0, void 0, function* () {
|
|
1532
|
+
yield (e = this.statsReporter) === null || e === void 0 ? void 0 : e.stop(this.debugOutput), this.instance && (this.instance.close(), this.instance = null);
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
const Wr = Lt;
|
|
1537
|
+
class Fn {
|
|
1538
|
+
constructor(e, n) {
|
|
1539
|
+
this.session = e, this.id = "", this.state = Q[Q.New], this.prevState = "", this.channels = [], this.role = Ue.Participant, this.extension = null, this._state = Q.New, this._prevState = Q.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._checkConferenceSerno = (b) => {
|
|
1540
|
+
const j = b < 0 || !this._lastSerno || this._lastSerno && b === this._lastSerno + 1;
|
|
1541
|
+
return j && b >= 0 && (this._lastSerno = b), j;
|
|
1542
|
+
}, this._doStats = () => {
|
|
1543
|
+
this.peer && this.peer.instance && this._statsBindings.length !== 0 && this.peer.instance.getStats().then((b) => {
|
|
1544
|
+
b.forEach((j) => {
|
|
1545
|
+
this._statsBindings.forEach(($) => {
|
|
1546
|
+
if ($.callback) {
|
|
1547
|
+
if ($.constraints) {
|
|
1548
|
+
for (var M in $.constraints) if ($.constraints.hasOwnProperty(M) && $.constraints[M] !== j[M]) return;
|
|
1549
|
+
}
|
|
1550
|
+
$.callback(j);
|
|
1551
|
+
}
|
|
1552
|
+
});
|
|
1553
|
+
});
|
|
1554
|
+
});
|
|
1555
|
+
};
|
|
1556
|
+
const { iceServers: r, speaker: i, micId: u, micLabel: l, camId: h, camLabel: g, localElement: p, remoteElement: y, options: S, mediaConstraints: { audio: I, video: T }, ringtoneFile: C, ringbackFile: D } = e;
|
|
1557
|
+
this.options = Object.assign({}, gr, { audio: I, video: T, iceServers: r, localElement: p, remoteElement: y, micId: u, micLabel: l, camId: h, camLabel: g, speakerId: i, ringtoneFile: C, ringbackFile: D, debug: S.debug, debugOutput: S.debugOutput }, n), this._onMediaError = this._onMediaError.bind(this), this._init(), this.options && (this._ringtone = an(this.options.ringtoneFile, "_ringtone"), this._ringback = an(this.options.ringbackFile, "_ringback"));
|
|
1558
|
+
}
|
|
1559
|
+
get nodeId() {
|
|
1560
|
+
return this._targetNodeId;
|
|
1561
|
+
}
|
|
1562
|
+
set nodeId(e) {
|
|
1563
|
+
this._targetNodeId = e;
|
|
1564
|
+
}
|
|
1565
|
+
get telnyxIDs() {
|
|
1566
|
+
return { telnyxCallControlId: this.options.telnyxCallControlId, telnyxSessionId: this.options.telnyxSessionId, telnyxLegId: this.options.telnyxLegId };
|
|
1567
|
+
}
|
|
1568
|
+
get localStream() {
|
|
1569
|
+
return this.options.localStream;
|
|
1570
|
+
}
|
|
1571
|
+
get remoteStream() {
|
|
1572
|
+
return this.options.remoteStream;
|
|
1573
|
+
}
|
|
1574
|
+
get memberChannel() {
|
|
1575
|
+
return `conference-member.${this.id}`;
|
|
1576
|
+
}
|
|
1577
|
+
invite() {
|
|
1578
|
+
this.direction = we.Outbound, this.peer = new dn(ge.Offer, this.options, this.session), this._registerPeerEvents();
|
|
1579
|
+
}
|
|
1580
|
+
answer(e = {}) {
|
|
1581
|
+
var n, r, i, u;
|
|
1582
|
+
this.stopRingtone(), this.options.video = (r = (n = e.video) !== null && n !== void 0 ? n : this.options.video) !== null && r !== void 0 && r, this.direction = we.Inbound, ((i = e?.customHeaders) === null || i === void 0 ? void 0 : i.length) > 0 && (this.options = Object.assign(Object.assign({}, this.options), { customHeaders: e.customHeaders })), ((u = e.preferred_codecs) === null || u === void 0 ? void 0 : u.length) > 0 && (this.options.preferred_codecs = e.preferred_codecs), this.peer = new dn(ge.Answer, this.options, this.session), this._registerPeerEvents();
|
|
1583
|
+
}
|
|
1584
|
+
playRingtone() {
|
|
1585
|
+
cn(this._ringtone);
|
|
1586
|
+
}
|
|
1587
|
+
stopRingtone() {
|
|
1588
|
+
un(this._ringtone);
|
|
1589
|
+
}
|
|
1590
|
+
playRingback() {
|
|
1591
|
+
cn(this._ringback);
|
|
1592
|
+
}
|
|
1593
|
+
stopRingback() {
|
|
1594
|
+
un(this._ringback);
|
|
1595
|
+
}
|
|
1596
|
+
hangup(e, n) {
|
|
1597
|
+
var r, i, u;
|
|
1598
|
+
let l = e || {}, h = n !== !1;
|
|
1599
|
+
this.cause = l.cause || "NORMAL_CLEARING", this.causeCode = l.causeCode || 16, this.sipCode = l.sipCode || null, this.sipReason = l.sipReason || null, this.sipCallId = l.sip_call_id || null, this.options.customHeaders = [...(r = this.options.customHeaders) !== null && r !== void 0 ? r : [], ...(u = (i = l?.dialogParams) === null || i === void 0 ? void 0 : i.customHeaders) !== null && u !== void 0 ? u : []], this.setState(Q.Hangup);
|
|
1600
|
+
const g = () => {
|
|
1601
|
+
var p;
|
|
1602
|
+
return (p = this.peer) === null || p === void 0 || p.close(), this.setState(Q.Destroy);
|
|
1603
|
+
};
|
|
1604
|
+
if (this.stopRingtone(), this.stopRingback(), h) {
|
|
1605
|
+
const p = new Or({ sessid: this.session.sessionid, dialogParams: this.options, cause: "USER_BUSY", causeCode: 17 });
|
|
1606
|
+
this._execute(p).catch((y) => {
|
|
1607
|
+
B.error("telnyx_rtc.bye failed!", y), X(V.Error, { error: y, sessionId: this.session.sessionid }, this.session.uuid);
|
|
1608
|
+
}).then(g.bind(this));
|
|
1609
|
+
} else g();
|
|
1610
|
+
}
|
|
1611
|
+
hold() {
|
|
1612
|
+
const e = new mt({ sessid: this.session.sessionid, action: "hold", dialogParams: this.options });
|
|
1613
|
+
return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this));
|
|
1614
|
+
}
|
|
1615
|
+
unhold() {
|
|
1616
|
+
const e = new mt({ sessid: this.session.sessionid, action: "unhold", dialogParams: this.options });
|
|
1617
|
+
return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this));
|
|
1618
|
+
}
|
|
1619
|
+
toggleHold() {
|
|
1620
|
+
const e = new mt({ sessid: this.session.sessionid, action: "toggleHold", dialogParams: this.options });
|
|
1621
|
+
return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this));
|
|
1622
|
+
}
|
|
1623
|
+
dtmf(e) {
|
|
1624
|
+
const n = new ln({ sessid: this.session.sessionid, dtmf: e, dialogParams: this.options });
|
|
1625
|
+
this._execute(n);
|
|
1626
|
+
}
|
|
1627
|
+
message(e, n) {
|
|
1628
|
+
const r = { from: this.session.options.login, to: e, body: n }, i = new ln({ sessid: this.session.sessionid, msg: r, dialogParams: this.options });
|
|
1629
|
+
this._execute(i);
|
|
1630
|
+
}
|
|
1631
|
+
muteAudio() {
|
|
1632
|
+
on(this.options.localStream);
|
|
1633
|
+
}
|
|
1634
|
+
unmuteAudio() {
|
|
1635
|
+
rn(this.options.localStream);
|
|
1636
|
+
}
|
|
1637
|
+
toggleAudioMute() {
|
|
1638
|
+
sn(this.options.localStream);
|
|
1639
|
+
}
|
|
1640
|
+
setAudioInDevice(e) {
|
|
1641
|
+
return q(this, void 0, void 0, function* () {
|
|
1642
|
+
const { instance: n } = this.peer, r = n.getSenders().find(({ track: { kind: i } }) => i === "audio");
|
|
1643
|
+
if (r) {
|
|
1644
|
+
const i = yield Tt({ audio: { deviceId: { exact: e } } }), u = i.getAudioTracks()[0];
|
|
1645
|
+
r.replaceTrack(u), this.options.micId = e;
|
|
1646
|
+
const { localStream: l } = this.options;
|
|
1647
|
+
l.getAudioTracks().forEach((h) => h.stop()), l.getVideoTracks().forEach((h) => i.addTrack(h)), this.options.localStream = i;
|
|
1648
|
+
}
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
muteVideo() {
|
|
1652
|
+
var e;
|
|
1653
|
+
e = this.options.localStream, Te(e, "video", !1);
|
|
1654
|
+
}
|
|
1655
|
+
unmuteVideo() {
|
|
1656
|
+
var e;
|
|
1657
|
+
e = this.options.localStream, Te(e, "video", !0);
|
|
1658
|
+
}
|
|
1659
|
+
toggleVideoMute() {
|
|
1660
|
+
var e;
|
|
1661
|
+
e = this.options.localStream, Te(e, "video", null);
|
|
1662
|
+
}
|
|
1663
|
+
setVideoDevice(e) {
|
|
1664
|
+
return q(this, void 0, void 0, function* () {
|
|
1665
|
+
const { instance: n } = this.peer, r = n.getSenders().find(({ track: { kind: i } }) => i === "video");
|
|
1666
|
+
if (r) {
|
|
1667
|
+
const i = yield Tt({ video: { deviceId: { exact: e } } }), u = i.getVideoTracks()[0];
|
|
1668
|
+
r.replaceTrack(u);
|
|
1669
|
+
const { localElement: l, localStream: h } = this.options;
|
|
1670
|
+
it(l, i), this.options.camId = e, h.getAudioTracks().forEach((g) => i.addTrack(g)), h.getVideoTracks().forEach((g) => g.stop()), this.options.localStream = i;
|
|
1671
|
+
}
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
deaf() {
|
|
1675
|
+
on(this.options.remoteStream);
|
|
1676
|
+
}
|
|
1677
|
+
undeaf() {
|
|
1678
|
+
rn(this.options.remoteStream);
|
|
1679
|
+
}
|
|
1680
|
+
toggleDeaf() {
|
|
1681
|
+
sn(this.options.remoteStream);
|
|
1682
|
+
}
|
|
1683
|
+
setBandwidthEncodingsMaxBps(e, n) {
|
|
1684
|
+
return q(this, void 0, void 0, function* () {
|
|
1685
|
+
if (!this || !this.peer) return void B.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?)");
|
|
1686
|
+
const { instance: r } = this.peer, i = r.getSenders();
|
|
1687
|
+
if (!i) return void B.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?)");
|
|
1688
|
+
const u = i.find(({ track: { kind: l } }) => l === n);
|
|
1689
|
+
if (u) {
|
|
1690
|
+
const l = u.getParameters();
|
|
1691
|
+
l.encodings || (l.encodings = [{ rid: "h" }]), B.info("Parameters: ", l), B.info("Setting max ", n === "audio" ? "audio" : "video", " bandwidth to: ", e, " [bps]"), l.encodings[0].maxBitrate = e, yield u.setParameters(l).then(() => {
|
|
1692
|
+
B.info(n === "audio" ? "New audio" : "New video", " bandwidth settings in use: ", u.getParameters());
|
|
1693
|
+
}).catch((h) => console.error(h));
|
|
1694
|
+
} else B.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?)");
|
|
1695
|
+
});
|
|
1696
|
+
}
|
|
1697
|
+
setAudioBandwidthEncodingsMaxBps(e) {
|
|
1698
|
+
this.setBandwidthEncodingsMaxBps(e, "audio");
|
|
1699
|
+
}
|
|
1700
|
+
setVideoBandwidthEncodingsMaxBps(e) {
|
|
1701
|
+
this.setBandwidthEncodingsMaxBps(e, "video");
|
|
1702
|
+
}
|
|
1703
|
+
getStats(e, n) {
|
|
1704
|
+
if (!e) return;
|
|
1705
|
+
const r = { callback: e, constraints: n };
|
|
1706
|
+
this._statsBindings.push(r), !this._statsIntervalId && this._startStats(2e3);
|
|
1707
|
+
}
|
|
1708
|
+
setState(e) {
|
|
1709
|
+
switch (this._prevState = this._state, this._state = e, this.state = Q[this._state].toLowerCase(), this.prevState = Q[this._prevState].toLowerCase(), B.info(`Call ${this.id} state change from ${this.prevState} to ${this.state}`), this._dispatchNotification({ type: ye.callUpdate, call: this }), e) {
|
|
1710
|
+
case Q.Purge:
|
|
1711
|
+
this.hangup({ cause: "PURGE", causeCode: "01" }, !1);
|
|
1712
|
+
break;
|
|
1713
|
+
case Q.Active:
|
|
1714
|
+
setTimeout(() => {
|
|
1715
|
+
const { remoteElement: n, speakerId: r } = this.options;
|
|
1716
|
+
n && r && Un(n, r);
|
|
1717
|
+
}, 0);
|
|
1718
|
+
break;
|
|
1719
|
+
case Q.Destroy:
|
|
1720
|
+
this._finalize();
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
handleMessage(e) {
|
|
1724
|
+
const { method: n, params: r } = e;
|
|
1725
|
+
switch (n) {
|
|
1726
|
+
case ne.Answer:
|
|
1727
|
+
if (this.gotAnswer = !0, this._state >= Q.Active) return;
|
|
1728
|
+
this._state >= Q.Early && this.setState(Q.Active), this.gotEarly || this._onRemoteSdp(r.sdp), this.stopRingback(), this.stopRingtone();
|
|
1729
|
+
break;
|
|
1730
|
+
case ne.Media:
|
|
1731
|
+
if (this._state >= Q.Early) return;
|
|
1732
|
+
this.gotEarly = !0, this._onRemoteSdp(r.sdp);
|
|
1733
|
+
break;
|
|
1734
|
+
case ne.Display:
|
|
1735
|
+
case ne.Attach: {
|
|
1736
|
+
const { display_name: u, display_number: l, display_direction: h } = r;
|
|
1737
|
+
this.extension = l;
|
|
1738
|
+
const g = h === we.Inbound ? we.Outbound : we.Inbound, p = { type: ye[n], call: this, displayName: u, displayNumber: l, displayDirection: g };
|
|
1739
|
+
X(V.Notification, p, this.id) || X(V.Notification, p, this.session.uuid);
|
|
1740
|
+
break;
|
|
1741
|
+
}
|
|
1742
|
+
case ne.Info:
|
|
1743
|
+
case ne.Event: {
|
|
1744
|
+
const u = Object.assign(Object.assign({}, r), { type: ye.generic, call: this });
|
|
1745
|
+
X(V.Notification, u, this.id) || X(V.Notification, u, this.session.uuid);
|
|
1746
|
+
break;
|
|
1747
|
+
}
|
|
1748
|
+
case ne.Ringing:
|
|
1749
|
+
this.playRingback(), r.telnyx_call_control_id && (this.options.telnyxCallControlId = r.telnyx_call_control_id), r.telnyx_session_id && (this.options.telnyxSessionId = r.telnyx_session_id), r.telnyx_leg_id && (this.options.telnyxLegId = r.telnyx_leg_id);
|
|
1750
|
+
break;
|
|
1751
|
+
case ne.Bye:
|
|
1752
|
+
const i = r.client_state || r.clientState;
|
|
1753
|
+
i && (this.options.clientState = i), this.stopRingback(), this.stopRingtone(), this.hangup(r, !1);
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
handleConferenceUpdate(e, n) {
|
|
1757
|
+
return q(this, void 0, void 0, function* () {
|
|
1758
|
+
if (!this._checkConferenceSerno(e.wireSerno) && e.name !== n.laName) return B.error("ConferenceUpdate invalid wireSerno or packet name:", e), "INVALID_PACKET";
|
|
1759
|
+
const { action: r, data: i, hashKey: u = String(this._lastSerno), arrIndex: l } = e;
|
|
1760
|
+
switch (r) {
|
|
1761
|
+
case "bootObj": {
|
|
1762
|
+
this._lastSerno = 0;
|
|
1763
|
+
const { chatChannel: h, infoChannel: g, modChannel: p, laName: y, conferenceMemberID: S, role: I } = n;
|
|
1764
|
+
this._dispatchConferenceUpdate({ action: de.Join, conferenceName: y, participantId: Number(S), role: I }), h && (yield this._subscribeConferenceChat(h)), g && (yield this._subscribeConferenceInfo(g)), p && I === Ue.Moderator && (yield this._subscribeConferenceModerator(p));
|
|
1765
|
+
const T = [];
|
|
1766
|
+
for (const C in i) T.push(Object.assign({ callId: i[C][0], index: Number(C) }, Qe(i[C][1])));
|
|
1767
|
+
this._dispatchConferenceUpdate({ action: de.Bootstrap, participants: T });
|
|
1768
|
+
break;
|
|
1769
|
+
}
|
|
1770
|
+
case "add":
|
|
1771
|
+
this._dispatchConferenceUpdate(Object.assign({ action: de.Add, callId: u, index: l }, Qe(i)));
|
|
1772
|
+
break;
|
|
1773
|
+
case "modify":
|
|
1774
|
+
this._dispatchConferenceUpdate(Object.assign({ action: de.Modify, callId: u, index: l }, Qe(i)));
|
|
1775
|
+
break;
|
|
1776
|
+
case "del":
|
|
1777
|
+
this._dispatchConferenceUpdate(Object.assign({ action: de.Delete, callId: u, index: l }, Qe(i)));
|
|
1778
|
+
break;
|
|
1779
|
+
case "clear":
|
|
1780
|
+
this._dispatchConferenceUpdate({ action: de.Clear });
|
|
1781
|
+
break;
|
|
1782
|
+
default:
|
|
1783
|
+
this._dispatchConferenceUpdate({ action: r, data: i, callId: u, index: l });
|
|
1784
|
+
}
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
_addChannel(e) {
|
|
1788
|
+
this.channels.includes(e) || this.channels.push(e);
|
|
1789
|
+
const n = this.session.relayProtocol;
|
|
1790
|
+
this.session._existsSubscription(n, e) && (this.session.subscriptions[n][e] = Object.assign(Object.assign({}, this.session.subscriptions[n][e]), { callId: this.id }));
|
|
1791
|
+
}
|
|
1792
|
+
_subscribeConferenceChat(e) {
|
|
1793
|
+
return q(this, void 0, void 0, function* () {
|
|
1794
|
+
const n = { nodeId: this.nodeId, channels: [e], handler: (i) => {
|
|
1795
|
+
const { direction: u, from: l, fromDisplay: h, message: g, type: p } = i.data;
|
|
1796
|
+
this._dispatchConferenceUpdate({ action: de.ChatMessage, direction: u, participantNumber: l, participantName: h, messageText: g, messageType: p, messageId: i.eventSerno });
|
|
1797
|
+
} }, r = yield this.session.vertoSubscribe(n).catch((i) => {
|
|
1798
|
+
B.error("ConfChat subscription error:", i);
|
|
1799
|
+
});
|
|
1800
|
+
rt(r, e) && (this._addChannel(e), Object.defineProperties(this, { sendChatMessage: { configurable: !0, value: (i, u) => {
|
|
1801
|
+
this.session.vertoBroadcast({ nodeId: this.nodeId, channel: e, data: { action: "send", message: i, type: u } });
|
|
1802
|
+
} } }));
|
|
1803
|
+
});
|
|
1804
|
+
}
|
|
1805
|
+
_subscribeConferenceInfo(e) {
|
|
1806
|
+
return q(this, void 0, void 0, function* () {
|
|
1807
|
+
const n = { nodeId: this.nodeId, channels: [e], handler: (i) => {
|
|
1808
|
+
const { eventData: u } = i;
|
|
1809
|
+
u.contentType === "layout-info" ? (u.callID = this.id, Vn(this.session, u)) : B.error("Conference-Info unknown contentType", i);
|
|
1810
|
+
} }, r = yield this.session.vertoSubscribe(n).catch((i) => {
|
|
1811
|
+
B.error("ConfInfo subscription error:", i);
|
|
1812
|
+
});
|
|
1813
|
+
rt(r, e) && this._addChannel(e);
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
_confControl(e, n = {}) {
|
|
1817
|
+
const r = Object.assign({ application: "conf-control", callID: this.id, value: null }, n);
|
|
1818
|
+
this.session.vertoBroadcast({ nodeId: this.nodeId, channel: e, data: r });
|
|
1819
|
+
}
|
|
1820
|
+
_subscribeConferenceModerator(e) {
|
|
1821
|
+
return q(this, void 0, void 0, function* () {
|
|
1822
|
+
const n = (l, h = null, g = null) => {
|
|
1823
|
+
const p = parseInt(h) || null;
|
|
1824
|
+
this._confControl(e, { command: l, id: p, value: g });
|
|
1825
|
+
}, r = () => {
|
|
1826
|
+
const { video: l } = this.options;
|
|
1827
|
+
if (typeof l == "boolean" && !l || typeof l == "object" && Jt(l)) throw `Conference ${this.id} has no video!`;
|
|
1828
|
+
}, i = { nodeId: this.nodeId, channels: [e], handler: (l) => {
|
|
1829
|
+
const { data: h } = l;
|
|
1830
|
+
if (h["conf-command"] === "list-videoLayouts") {
|
|
1831
|
+
if (h.responseData) {
|
|
1832
|
+
const g = JSON.stringify(h.responseData).replace(/IDS"/g, 'Ids"');
|
|
1833
|
+
this._dispatchConferenceUpdate({ action: de.LayoutList, layouts: JSON.parse(g) });
|
|
1834
|
+
}
|
|
1835
|
+
} else this._dispatchConferenceUpdate({ action: de.ModCmdResponse, command: h["conf-command"], response: h.response });
|
|
1836
|
+
} }, u = yield this.session.vertoSubscribe(i).catch((l) => {
|
|
1837
|
+
B.error("ConfMod subscription error:", l);
|
|
1838
|
+
});
|
|
1839
|
+
rt(u, e) && (this.role = Ue.Moderator, this._addChannel(e), Object.defineProperties(this, { listVideoLayouts: { configurable: !0, value: () => {
|
|
1840
|
+
n("list-videoLayouts");
|
|
1841
|
+
} }, playMedia: { configurable: !0, value: (l) => {
|
|
1842
|
+
n("play", null, l);
|
|
1843
|
+
} }, stopMedia: { configurable: !0, value: () => {
|
|
1844
|
+
n("stop", null, "all");
|
|
1845
|
+
} }, deaf: { configurable: !0, value: (l) => {
|
|
1846
|
+
n("deaf", l);
|
|
1847
|
+
} }, undeaf: { configurable: !0, value: (l) => {
|
|
1848
|
+
n("undeaf", l);
|
|
1849
|
+
} }, startRecord: { configurable: !0, value: (l) => {
|
|
1850
|
+
n("recording", null, ["start", l]);
|
|
1851
|
+
} }, stopRecord: { configurable: !0, value: () => {
|
|
1852
|
+
n("recording", null, ["stop", "all"]);
|
|
1853
|
+
} }, snapshot: { configurable: !0, value: (l) => {
|
|
1854
|
+
r(), n("vid-write-png", null, l);
|
|
1855
|
+
} }, setVideoLayout: { configurable: !0, value: (l, h) => {
|
|
1856
|
+
r(), n("vid-layout", null, h ? [l, h] : l);
|
|
1857
|
+
} }, kick: { configurable: !0, value: (l) => {
|
|
1858
|
+
n("kick", l);
|
|
1859
|
+
} }, muteMic: { configurable: !0, value: (l) => {
|
|
1860
|
+
n("tmute", l);
|
|
1861
|
+
} }, muteVideo: { configurable: !0, value: (l) => {
|
|
1862
|
+
r(), n("tvmute", l);
|
|
1863
|
+
} }, presenter: { configurable: !0, value: (l) => {
|
|
1864
|
+
r(), n("vid-res-id", l, "presenter");
|
|
1865
|
+
} }, videoFloor: { configurable: !0, value: (l) => {
|
|
1866
|
+
r(), n("vid-floor", l, "force");
|
|
1867
|
+
} }, banner: { configurable: !0, value: (l, h) => {
|
|
1868
|
+
r(), n("vid-banner", l, encodeURI(h));
|
|
1869
|
+
} }, volumeDown: { configurable: !0, value: (l) => {
|
|
1870
|
+
n("volume_out", l, "down");
|
|
1871
|
+
} }, volumeUp: { configurable: !0, value: (l) => {
|
|
1872
|
+
n("volume_out", l, "up");
|
|
1873
|
+
} }, gainDown: { configurable: !0, value: (l) => {
|
|
1874
|
+
n("volume_in", l, "down");
|
|
1875
|
+
} }, gainUp: { configurable: !0, value: (l) => {
|
|
1876
|
+
n("volume_in", l, "up");
|
|
1877
|
+
} }, transfer: { configurable: !0, value: (l, h) => {
|
|
1878
|
+
n("transfer", l, h);
|
|
1879
|
+
} } }));
|
|
1880
|
+
});
|
|
1881
|
+
}
|
|
1882
|
+
_handleChangeHoldStateSuccess(e) {
|
|
1883
|
+
return e.holdState === "active" ? this.setState(Q.Active) : this.setState(Q.Held), !0;
|
|
1884
|
+
}
|
|
1885
|
+
_handleChangeHoldStateError(e) {
|
|
1886
|
+
return B.error(`Failed to ${e.action} on call ${this.id}`), !1;
|
|
1887
|
+
}
|
|
1888
|
+
_onRemoteSdp(e) {
|
|
1889
|
+
return q(this, void 0, void 0, function* () {
|
|
1890
|
+
const n = new RTCSessionDescription({ sdp: e, type: "answer" });
|
|
1891
|
+
yield this.peer.instance.setRemoteDescription(n).then(() => {
|
|
1892
|
+
this.gotEarly && this.setState(Q.Early), this.gotAnswer && this.setState(Q.Active);
|
|
1893
|
+
}).catch((r) => {
|
|
1894
|
+
B.error("Call setRemoteDescription Error: ", r), this.hangup();
|
|
1895
|
+
});
|
|
1896
|
+
});
|
|
1897
|
+
}
|
|
1898
|
+
_requestAnotherLocalDescription() {
|
|
1899
|
+
ke(this.peer.onSdpReadyTwice) ? X(V.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());
|
|
1900
|
+
}
|
|
1901
|
+
_onIceSdp(e) {
|
|
1902
|
+
var n, r;
|
|
1903
|
+
this._iceTimeout && clearTimeout(this._iceTimeout), this._iceTimeout = null, this._iceDone = !0;
|
|
1904
|
+
const { sdp: i, type: u } = e;
|
|
1905
|
+
if (i.indexOf("candidate") === -1) return B.info(`No candidate - retry
|
|
1906
|
+
`), void this._requestAnotherLocalDescription();
|
|
1907
|
+
(r = (n = this.peer) === null || n === void 0 ? void 0 : n.instance) === null || r === void 0 || r.removeEventListener("icecandidate", this._onIce);
|
|
1908
|
+
let l = null;
|
|
1909
|
+
const h = { sessid: this.session.sessionid, sdp: i, dialogParams: this.options, "User-Agent": `Web-${Wr}` };
|
|
1910
|
+
switch (u) {
|
|
1911
|
+
case ge.Offer:
|
|
1912
|
+
this.setState(Q.Requesting), l = new Ir(h);
|
|
1913
|
+
break;
|
|
1914
|
+
case ge.Answer:
|
|
1915
|
+
this.setState(Q.Answering), l = this.options.attach === !0 ? new Ar(h) : new kr(h);
|
|
1916
|
+
break;
|
|
1917
|
+
default:
|
|
1918
|
+
return B.error(`${this.id} - Unknown local SDP type:`, e), this.hangup({}, !1);
|
|
1919
|
+
}
|
|
1920
|
+
this._execute(l).then((g) => {
|
|
1921
|
+
const { node_id: p = null } = g;
|
|
1922
|
+
this._targetNodeId = p, u === ge.Offer ? this.setState(Q.Trying) : this.setState(Q.Active);
|
|
1923
|
+
}).catch((g) => {
|
|
1924
|
+
B.error(`${this.id} - Sending ${u} error:`, g), this.hangup();
|
|
1925
|
+
}), console.timeEnd(An);
|
|
1926
|
+
}
|
|
1927
|
+
_onIce(e) {
|
|
1928
|
+
const { instance: n } = this.peer;
|
|
1929
|
+
this._iceTimeout === null && (this._iceTimeout = setTimeout(() => this._onIceSdp(n.localDescription), 1e3)), e.candidate ? B.debug("RTCPeer Candidate:", e.candidate) : this._onIceSdp(n.localDescription);
|
|
1930
|
+
}
|
|
1931
|
+
_registerPeerEvents() {
|
|
1932
|
+
const { instance: e } = this.peer;
|
|
1933
|
+
this._iceDone = !1, e.onicecandidate = (n) => {
|
|
1934
|
+
this._iceDone || this._onIce(n);
|
|
1935
|
+
}, e.addEventListener("addstream", (n) => {
|
|
1936
|
+
this.options.remoteStream = n.stream;
|
|
1937
|
+
}), e.addEventListener("track", (n) => {
|
|
1938
|
+
this.options.remoteStream = n.streams[0];
|
|
1939
|
+
const { remoteElement: r, remoteStream: i, screenShare: u } = this.options;
|
|
1940
|
+
u === !1 && it(r, i);
|
|
1941
|
+
});
|
|
1942
|
+
}
|
|
1943
|
+
_onMediaError(e) {
|
|
1944
|
+
this._dispatchNotification({ type: ye.userMediaError, error: e }), this.hangup({}, !1);
|
|
1945
|
+
}
|
|
1946
|
+
_dispatchConferenceUpdate(e) {
|
|
1947
|
+
this._dispatchNotification(Object.assign({ type: ye.conferenceUpdate, call: this }, e));
|
|
1948
|
+
}
|
|
1949
|
+
_dispatchNotification(e) {
|
|
1950
|
+
this.options.screenShare !== !0 && (X(V.Notification, e, this.id, !1) || X(V.Notification, e, this.session.uuid));
|
|
1951
|
+
}
|
|
1952
|
+
_execute(e) {
|
|
1953
|
+
return this.nodeId && (e.targetNodeId = this.nodeId), this.session.execute(e);
|
|
1954
|
+
}
|
|
1955
|
+
_init() {
|
|
1956
|
+
const { id: e, userVariables: n, remoteCallerNumber: r, onNotification: i } = this.options;
|
|
1957
|
+
e || (this.options.id = Ie()), this.id = this.options.id, n && !Jt(n) || (this.options.userVariables = this.session.options.userVariables || {}), r || (this.options.remoteCallerNumber = this.options.destinationNumber), this.session.calls[this.id] = this, Ce(V.MediaError, this._onMediaError, this.id), ke(i) && Ce(V.Notification, i.bind(this), this.id), this.setState(Q.New), B.info("New Call with Options:", this.options);
|
|
1958
|
+
}
|
|
1959
|
+
_finalize() {
|
|
1960
|
+
this._stopStats(), this.peer && this.peer.instance && (this.peer.instance.close(), this.peer = null);
|
|
1961
|
+
const { remoteStream: e, localStream: n } = this.options;
|
|
1962
|
+
Ve(e), Ve(n), Re(V.MediaError, null, this.id), this.session.calls[this.id] = null, delete this.session.calls[this.id];
|
|
1963
|
+
}
|
|
1964
|
+
_startStats(e) {
|
|
1965
|
+
this._statsIntervalId = setInterval(this._doStats, e), B.info("Stats started");
|
|
1966
|
+
}
|
|
1967
|
+
_stopStats() {
|
|
1968
|
+
this._statsIntervalId && (clearInterval(this._statsIntervalId), this._statsIntervalId = null), B.info("Stats stopped");
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
Fn.setStateTelnyx = (t) => {
|
|
1972
|
+
if (t) {
|
|
1973
|
+
switch (t._state) {
|
|
1974
|
+
case Q.Requesting:
|
|
1975
|
+
case Q.Recovering:
|
|
1976
|
+
case Q.Trying:
|
|
1977
|
+
case Q.Early:
|
|
1978
|
+
t.state = "connecting";
|
|
1979
|
+
break;
|
|
1980
|
+
case Q.Active:
|
|
1981
|
+
t.state = "active";
|
|
1982
|
+
break;
|
|
1983
|
+
case Q.Held:
|
|
1984
|
+
t.state = "held";
|
|
1985
|
+
break;
|
|
1986
|
+
case Q.Hangup:
|
|
1987
|
+
case Q.Destroy:
|
|
1988
|
+
t.state = "done";
|
|
1989
|
+
break;
|
|
1990
|
+
case Q.Answering:
|
|
1991
|
+
t.state = "ringing";
|
|
1992
|
+
break;
|
|
1993
|
+
case Q.New:
|
|
1994
|
+
t.state = "new";
|
|
1995
|
+
}
|
|
1996
|
+
return t;
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
class Se extends Fn {
|
|
2000
|
+
constructor() {
|
|
2001
|
+
super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e) => this.session.execute(new Mr(e));
|
|
2002
|
+
}
|
|
2003
|
+
hangup(e = {}, n = !0) {
|
|
2004
|
+
this.screenShare instanceof Se && this.screenShare.hangup(e, n), super.hangup(e, n);
|
|
2005
|
+
}
|
|
2006
|
+
startScreenShare(e) {
|
|
2007
|
+
return q(this, void 0, void 0, function* () {
|
|
2008
|
+
const n = yield (r = { video: !0 }, navigator.mediaDevices.getDisplayMedia(r));
|
|
2009
|
+
var r;
|
|
2010
|
+
n.getTracks().forEach((p) => {
|
|
2011
|
+
p.addEventListener("ended", () => {
|
|
2012
|
+
this.screenShare && this.screenShare.hangup();
|
|
2013
|
+
});
|
|
2014
|
+
});
|
|
2015
|
+
const { remoteCallerName: i, remoteCallerNumber: u, callerName: l, callerNumber: h } = this.options, g = Object.assign({ screenShare: !0, localStream: n, destinationNumber: `${this.extension}-screen`, remoteCallerName: i, remoteCallerNumber: `${u}-screen`, callerName: `${l} (Screen)`, callerNumber: `${h} (Screen)` }, e);
|
|
2016
|
+
return this.screenShare = new Se(this.session, g), this.screenShare.invite(), this.screenShare;
|
|
2017
|
+
});
|
|
2018
|
+
}
|
|
2019
|
+
stopScreenShare() {
|
|
2020
|
+
this.screenShare instanceof Se && this.screenShare.hangup();
|
|
2021
|
+
}
|
|
2022
|
+
setAudioOutDevice(e) {
|
|
2023
|
+
return q(this, void 0, void 0, function* () {
|
|
2024
|
+
this.options.speakerId = e;
|
|
2025
|
+
const { remoteElement: n, speakerId: r } = this.options;
|
|
2026
|
+
return !(!n || !r) && Un(n, r);
|
|
2027
|
+
});
|
|
2028
|
+
}
|
|
2029
|
+
_finalize() {
|
|
2030
|
+
this._stats(!1), super._finalize();
|
|
2031
|
+
}
|
|
2032
|
+
_stats(e = !0) {
|
|
2033
|
+
if (e === !1) return clearInterval(this._statsInterval);
|
|
2034
|
+
B.setLevel(2), this._statsInterval = window.setInterval(() => q(this, void 0, void 0, function* () {
|
|
2035
|
+
const n = yield this.peer.instance.getStats(null);
|
|
2036
|
+
let r = "";
|
|
2037
|
+
const i = ["certificate", "codec", "peer-connection", "stream", "local-candidate", "remote-candidate"], u = ["id", "type", "timestamp"];
|
|
2038
|
+
n.forEach((l) => {
|
|
2039
|
+
i.includes(l.type) || (r += `
|
|
2040
|
+
${l.type}
|
|
2041
|
+
`, Object.keys(l).forEach((h) => {
|
|
2042
|
+
u.includes(h) || (r += ` ${h}: ${l[h]}
|
|
2043
|
+
`);
|
|
2044
|
+
}));
|
|
2045
|
+
}), B.info(r);
|
|
2046
|
+
}), 2e3);
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
class Br extends Sr {
|
|
2050
|
+
constructor(e) {
|
|
2051
|
+
super(e), this.calls = {}, this.autoRecoverCalls = !0, this._iceServers = [], this._localElement = null, this._remoteElement = null, this._jwtAuth = !0, this._audioConstraints = !0, this._videoConstraints = !1, this._speaker = null, this.iceServers = e.iceServers, this.ringtoneFile = e.ringtoneFile, this.ringbackFile = e.ringbackFile;
|
|
2052
|
+
}
|
|
2053
|
+
get reconnectDelay() {
|
|
2054
|
+
return 1e3;
|
|
2055
|
+
}
|
|
2056
|
+
connect() {
|
|
2057
|
+
const e = Object.create(null, { connect: { get: () => super.connect } });
|
|
2058
|
+
return q(this, void 0, void 0, function* () {
|
|
2059
|
+
e.connect.call(this);
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
checkPermissions(e = !0, n = !0) {
|
|
2063
|
+
return q(this, void 0, void 0, function* () {
|
|
2064
|
+
try {
|
|
2065
|
+
const r = yield st({ audio: e, video: n });
|
|
2066
|
+
return Ve(r), !0;
|
|
2067
|
+
} catch {
|
|
2068
|
+
return !1;
|
|
2069
|
+
}
|
|
2070
|
+
});
|
|
2071
|
+
}
|
|
2072
|
+
logout() {
|
|
2073
|
+
this.disconnect();
|
|
2074
|
+
}
|
|
2075
|
+
disconnect() {
|
|
2076
|
+
const e = Object.create(null, { disconnect: { get: () => super.disconnect } });
|
|
2077
|
+
return q(this, void 0, void 0, function* () {
|
|
2078
|
+
Object.keys(this.calls).forEach((n) => this.calls[n].setState(Q.Purge)), this.calls = {}, yield e.disconnect.call(this);
|
|
2079
|
+
});
|
|
2080
|
+
}
|
|
2081
|
+
speedTest(e) {
|
|
2082
|
+
return new Promise((n, r) => {
|
|
2083
|
+
if (Dn(V.SpeedTest, (l) => {
|
|
2084
|
+
const { upDur: h, downDur: g } = l, p = g ? 8 * e / (g / 1e3) / 1024 : 0;
|
|
2085
|
+
n({ upDur: h, downDur: g, upKps: (h ? 8 * e / (h / 1e3) / 1024 : 0).toFixed(0), downKps: p.toFixed(0) });
|
|
2086
|
+
}, this.uuid), !(e = Number(e))) return r(`Invalid parameter 'bytes': ${e}`);
|
|
2087
|
+
this.executeRaw(`#SPU ${e}`);
|
|
2088
|
+
let i = e / 1024;
|
|
2089
|
+
e % 1024 && i++;
|
|
2090
|
+
const u = ".".repeat(1024);
|
|
2091
|
+
for (let l = 0; l < i; l++) this.executeRaw(`#SPB ${u}`);
|
|
2092
|
+
this.executeRaw("#SPE");
|
|
2093
|
+
});
|
|
2094
|
+
}
|
|
2095
|
+
getDevices() {
|
|
2096
|
+
return Pe().catch((e) => (X(V.MediaError, e, this.uuid), []));
|
|
2097
|
+
}
|
|
2098
|
+
getVideoDevices() {
|
|
2099
|
+
return Pe(_e.Video).catch((e) => (X(V.MediaError, e, this.uuid), []));
|
|
2100
|
+
}
|
|
2101
|
+
getAudioInDevices() {
|
|
2102
|
+
return Pe(_e.AudioIn).catch((e) => (X(V.MediaError, e, this.uuid), []));
|
|
2103
|
+
}
|
|
2104
|
+
getAudioOutDevices() {
|
|
2105
|
+
return Pe(_e.AudioOut).catch((e) => (console.error("getAudioOutDevices", e), X(V.MediaError, e, this.uuid), []));
|
|
2106
|
+
}
|
|
2107
|
+
validateDeviceId(e, n, r) {
|
|
2108
|
+
return at(e, n, r);
|
|
2109
|
+
}
|
|
2110
|
+
getDeviceResolutions(e) {
|
|
2111
|
+
return q(this, void 0, void 0, function* () {
|
|
2112
|
+
try {
|
|
2113
|
+
return yield ((n) => q(void 0, void 0, void 0, function* () {
|
|
2114
|
+
const r = [], i = yield st({ video: { deviceId: { exact: n } } }), u = i.getVideoTracks()[0];
|
|
2115
|
+
for (let l = 0; l < en.length; l++) {
|
|
2116
|
+
const [h, g] = en[l];
|
|
2117
|
+
(yield u.applyConstraints({ width: { exact: h }, height: { exact: g } }).then(() => !0).catch(() => !1)) && r.push({ resolution: `${h}x${g}`, width: h, height: g });
|
|
2118
|
+
}
|
|
2119
|
+
return Ve(i), r;
|
|
2120
|
+
}))(e);
|
|
2121
|
+
} catch (n) {
|
|
2122
|
+
throw n;
|
|
2123
|
+
}
|
|
2124
|
+
});
|
|
2125
|
+
}
|
|
2126
|
+
get mediaConstraints() {
|
|
2127
|
+
return { audio: this._audioConstraints, video: this._videoConstraints };
|
|
2128
|
+
}
|
|
2129
|
+
setAudioSettings(e) {
|
|
2130
|
+
return q(this, void 0, void 0, function* () {
|
|
2131
|
+
if (!e) throw new Error("You need to provide the settings object");
|
|
2132
|
+
const { micId: n, micLabel: r } = e, i = Et(e, ["micId", "micLabel"]);
|
|
2133
|
+
return tn(i), this._audioConstraints = yield nn(n, r, "audioinput", i), this.micId = n, this.micLabel = r, this._audioConstraints;
|
|
2134
|
+
});
|
|
2135
|
+
}
|
|
2136
|
+
disableMicrophone() {
|
|
2137
|
+
this._audioConstraints = !1;
|
|
2138
|
+
}
|
|
2139
|
+
enableMicrophone() {
|
|
2140
|
+
this._audioConstraints = !0;
|
|
2141
|
+
}
|
|
2142
|
+
setVideoSettings(e) {
|
|
2143
|
+
return q(this, void 0, void 0, function* () {
|
|
2144
|
+
if (!e) throw new Error("You need to provide the settings object");
|
|
2145
|
+
const { camId: n, camLabel: r } = e, i = Et(e, ["camId", "camLabel"]);
|
|
2146
|
+
return tn(i), this._videoConstraints = yield nn(n, r, "videoinput", i), this.camId = n, this.camLabel = r, this._videoConstraints;
|
|
2147
|
+
});
|
|
2148
|
+
}
|
|
2149
|
+
disableWebcam() {
|
|
2150
|
+
this._videoConstraints = !1;
|
|
2151
|
+
}
|
|
2152
|
+
enableWebcam() {
|
|
2153
|
+
this._videoConstraints = !0;
|
|
2154
|
+
}
|
|
2155
|
+
set iceServers(e) {
|
|
2156
|
+
const n = { urls: ["stun:stun.l.google.com:19302"] };
|
|
2157
|
+
this._iceServers = typeof e == "boolean" ? e ? [n] : [] : e || [On, ur, n];
|
|
2158
|
+
}
|
|
2159
|
+
get iceServers() {
|
|
2160
|
+
return this._iceServers;
|
|
2161
|
+
}
|
|
2162
|
+
set speaker(e) {
|
|
2163
|
+
this._speaker = e;
|
|
2164
|
+
}
|
|
2165
|
+
get speaker() {
|
|
2166
|
+
return this._speaker;
|
|
2167
|
+
}
|
|
2168
|
+
set localElement(e) {
|
|
2169
|
+
this._localElement = $e(e);
|
|
2170
|
+
}
|
|
2171
|
+
get localElement() {
|
|
2172
|
+
return this._localElement;
|
|
2173
|
+
}
|
|
2174
|
+
set remoteElement(e) {
|
|
2175
|
+
this._remoteElement = $e(e);
|
|
2176
|
+
}
|
|
2177
|
+
get remoteElement() {
|
|
2178
|
+
return this._remoteElement;
|
|
2179
|
+
}
|
|
2180
|
+
vertoBroadcast({ nodeId: e, channel: n = "", data: r }) {
|
|
2181
|
+
if (!n) throw new Error(`Invalid channel for broadcast: ${n}`);
|
|
2182
|
+
const i = new xr({ sessid: this.sessionid, eventChannel: n, data: r });
|
|
2183
|
+
e && (i.targetNodeId = e), this.execute(i).catch((u) => u);
|
|
2184
|
+
}
|
|
2185
|
+
vertoSubscribe({ nodeId: e, channels: n = [], handler: r }) {
|
|
2186
|
+
return q(this, void 0, void 0, function* () {
|
|
2187
|
+
if (!(n = n.filter((g) => g && !this._existsSubscription(this.relayProtocol, g))).length) return {};
|
|
2188
|
+
const i = new Lr({ sessid: this.sessionid, eventChannel: n });
|
|
2189
|
+
e && (i.targetNodeId = e);
|
|
2190
|
+
const u = yield this.execute(i), { unauthorized: l = [], subscribed: h = [] } = It(u);
|
|
2191
|
+
return l.length && l.forEach((g) => this._removeSubscription(this.relayProtocol, g)), h.forEach((g) => this._addSubscription(this.relayProtocol, r, g)), u;
|
|
2192
|
+
});
|
|
2193
|
+
}
|
|
2194
|
+
vertoUnsubscribe({ nodeId: e, channels: n = [] }) {
|
|
2195
|
+
return q(this, void 0, void 0, function* () {
|
|
2196
|
+
if (!(n = n.filter((h) => h && this._existsSubscription(this.relayProtocol, h))).length) return {};
|
|
2197
|
+
const r = new Nr({ sessid: this.sessionid, eventChannel: n });
|
|
2198
|
+
e && (r.targetNodeId = e);
|
|
2199
|
+
const i = yield this.execute(r), { unsubscribed: u = [], notSubscribed: l = [] } = It(i);
|
|
2200
|
+
return u.forEach((h) => this._removeSubscription(this.relayProtocol, h)), l.forEach((h) => this._removeSubscription(this.relayProtocol, h)), i;
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
2203
|
+
static telnyxStateCall(e) {
|
|
2204
|
+
return Se.setStateTelnyx(e);
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
class hn {
|
|
2208
|
+
constructor(e, n) {
|
|
2209
|
+
this.code = n, this.message = e;
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
class Yr extends fe {
|
|
2213
|
+
constructor() {
|
|
2214
|
+
super(), this.method = ne.Ping, this.buildRequest({ method: this.method, params: {} });
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
class me {
|
|
2218
|
+
constructor(e) {
|
|
2219
|
+
this.session = e;
|
|
2220
|
+
}
|
|
2221
|
+
_ack(e, n) {
|
|
2222
|
+
const r = new Tr(e, n);
|
|
2223
|
+
this.nodeId && (r.targetNodeId = this.nodeId), this.session.execute(r);
|
|
2224
|
+
}
|
|
2225
|
+
reconnectDelay() {
|
|
2226
|
+
return 1e3 * Mn(2, 6);
|
|
2227
|
+
}
|
|
2228
|
+
handleMessage(e) {
|
|
2229
|
+
const { session: n } = this, { id: r, method: i, params: u = {} } = e, l = u?.callID, h = u?.eventChannel, g = u?.eventType, p = i === ne.Attach;
|
|
2230
|
+
if (g === "channelPvtData") return this._handlePvtEvent(u.pvtData);
|
|
2231
|
+
if (l && n.calls.hasOwnProperty(l)) {
|
|
2232
|
+
if (!p) return n.calls[l].handleMessage(e), void this._ack(r, i);
|
|
2233
|
+
n.calls[l].hangup({}, !1);
|
|
2234
|
+
}
|
|
2235
|
+
const y = () => {
|
|
2236
|
+
var T, C, D, b;
|
|
2237
|
+
const j = { id: l, remoteSdp: u.sdp, destinationNumber: u.callee_id_number, remoteCallerName: u.caller_id_name, remoteCallerNumber: u.caller_id_number, callerName: u.callee_id_name, callerNumber: u.callee_id_number, attach: p, mediaSettings: u.mediaSettings, debug: (T = n.options.debug) !== null && T !== void 0 && T, debugOutput: (C = n.options.debugOutput) !== null && C !== void 0 ? C : "socket", prefetchIceCandidates: (D = n.options.prefetchIceCandidates) !== null && D !== void 0 && D, forceRelayCandidate: (b = n.options.forceRelayCandidate) !== null && b !== void 0 && b };
|
|
2238
|
+
u.telnyx_call_control_id && (j.telnyxCallControlId = u.telnyx_call_control_id), u.telnyx_session_id && (j.telnyxSessionId = u.telnyx_session_id), u.telnyx_leg_id && (j.telnyxLegId = u.telnyx_leg_id), u.client_state && (j.clientState = u.client_state), u.dialogParams && u.dialogParams.custom_headers && u.dialogParams.custom_headers.length && (j.customHeaders = u.dialogParams.custom_headers);
|
|
2239
|
+
const $ = new Se(n, j);
|
|
2240
|
+
return $.nodeId = this.nodeId, $;
|
|
2241
|
+
}, S = new jn(), I = new Yr();
|
|
2242
|
+
switch (i) {
|
|
2243
|
+
case ne.Ping:
|
|
2244
|
+
this.session.execute(I);
|
|
2245
|
+
break;
|
|
2246
|
+
case ne.Punt:
|
|
2247
|
+
n.disconnect();
|
|
2248
|
+
break;
|
|
2249
|
+
case ne.Invite: {
|
|
2250
|
+
const D = y();
|
|
2251
|
+
D.playRingtone(), D.setState(Q.Ringing), D.direction = we.Inbound, this._ack(r, i);
|
|
2252
|
+
break;
|
|
2253
|
+
}
|
|
2254
|
+
case ne.Attach: {
|
|
2255
|
+
const D = y();
|
|
2256
|
+
this.session.autoRecoverCalls ? D.answer() : D.setState(Q.Recovering), D.handleMessage(e);
|
|
2257
|
+
break;
|
|
2258
|
+
}
|
|
2259
|
+
case ne.Event:
|
|
2260
|
+
case "webrtc.event":
|
|
2261
|
+
if (!h) return void B.error("Verto received an unknown event:", u);
|
|
2262
|
+
const T = n.relayProtocol, C = h.split(".")[0];
|
|
2263
|
+
n._existsSubscription(T, h) ? X(T, u, h) : h === n.sessionid ? this._handleSessionEvent(u.eventData) : n._existsSubscription(T, C) ? X(T, u, C) : n.calls.hasOwnProperty(h) ? n.calls[h].handleMessage(e) : X(V.Notification, u, n.uuid);
|
|
2264
|
+
break;
|
|
2265
|
+
case ne.Info:
|
|
2266
|
+
u.type = ye.generic, X(V.Notification, u, n.uuid);
|
|
2267
|
+
break;
|
|
2268
|
+
case ne.ClientReady:
|
|
2269
|
+
this.session.execute(S);
|
|
2270
|
+
break;
|
|
2271
|
+
default: {
|
|
2272
|
+
const D = Ot(e);
|
|
2273
|
+
if (D) {
|
|
2274
|
+
switch (D) {
|
|
2275
|
+
case le.REGISTER:
|
|
2276
|
+
case le.REGED:
|
|
2277
|
+
n.connection.previousGatewayState !== le.REGED && n.connection.previousGatewayState !== le.REGISTER && (me.retriedRegister = 0, u.type = ye.vertoClientReady, X(V.Ready, u, n.uuid));
|
|
2278
|
+
break;
|
|
2279
|
+
case le.UNREGED:
|
|
2280
|
+
case le.NOREG:
|
|
2281
|
+
if (me.retriedRegister += 1, me.retriedRegister === 5) {
|
|
2282
|
+
me.retriedRegister = 0, X(V.Error, { error: new hn("Fail to register the user, the server tried 5 times", "UNREGED|NOREG"), sessionId: n.sessionid }, n.uuid);
|
|
2283
|
+
break;
|
|
2284
|
+
}
|
|
2285
|
+
setTimeout(() => {
|
|
2286
|
+
this.session.execute(S);
|
|
2287
|
+
}, this.reconnectDelay());
|
|
2288
|
+
break;
|
|
2289
|
+
case le.FAILED:
|
|
2290
|
+
case le.FAIL_WAIT:
|
|
2291
|
+
if (n.connection.previousGatewayState !== le.FAILED && n.connection.previousGatewayState !== le.FAIL_WAIT) {
|
|
2292
|
+
if (!this.session.hasAutoReconnect()) {
|
|
2293
|
+
me.retriedConnect = 0, X(V.Error, { error: new hn("Fail to connect the server, the server tried 5 times", "FAILED|FAIL_WAIT"), sessionId: n.sessionid }, n.uuid);
|
|
2294
|
+
break;
|
|
2295
|
+
}
|
|
2296
|
+
if (me.retriedConnect += 1, me.retriedConnect === 5) {
|
|
2297
|
+
me.retriedConnect = 0, X(V.Error, { error: new Error("Connection Retry Failed"), sessionId: n.sessionid }, n.uuid);
|
|
2298
|
+
break;
|
|
2299
|
+
}
|
|
2300
|
+
setTimeout(() => {
|
|
2301
|
+
this.session.disconnect().then(() => {
|
|
2302
|
+
this.session.clearConnection(), this.session.connect();
|
|
2303
|
+
});
|
|
2304
|
+
}, this.reconnectDelay());
|
|
2305
|
+
}
|
|
2306
|
+
break;
|
|
2307
|
+
default:
|
|
2308
|
+
B.warn("GatewayState message unknown method:", e);
|
|
2309
|
+
}
|
|
2310
|
+
break;
|
|
2311
|
+
}
|
|
2312
|
+
B.debug("Verto message unknown method:", e);
|
|
2313
|
+
break;
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
_retrieveCallId(e, n) {
|
|
2318
|
+
const r = Object.keys(this.session.calls);
|
|
2319
|
+
if (e.action !== "bootObj") return r.find((i) => this.session.calls[i].channels.includes(n));
|
|
2320
|
+
{
|
|
2321
|
+
const i = e.data.find((u) => r.includes(u[0]));
|
|
2322
|
+
if (i instanceof Array) return i[0];
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
_handlePvtEvent(e) {
|
|
2326
|
+
return q(this, void 0, void 0, function* () {
|
|
2327
|
+
const { session: n } = this, r = n.relayProtocol, { action: i, laChannel: u, laName: l, chatChannel: h, infoChannel: g, modChannel: p, conferenceMemberID: y, role: S, callID: I } = e;
|
|
2328
|
+
switch (i) {
|
|
2329
|
+
case "conference-liveArray-join": {
|
|
2330
|
+
const T = () => {
|
|
2331
|
+
n.vertoBroadcast({ nodeId: this.nodeId, channel: u, data: { liveArray: { command: "bootstrap", context: u, name: l } } });
|
|
2332
|
+
}, C = { nodeId: this.nodeId, channels: [u], handler: ({ data: b }) => {
|
|
2333
|
+
const j = I || this._retrieveCallId(b, u);
|
|
2334
|
+
if (j && n.calls.hasOwnProperty(j)) {
|
|
2335
|
+
const $ = n.calls[j];
|
|
2336
|
+
$._addChannel(u), $.extension = l, $.handleConferenceUpdate(b, e).then((M) => {
|
|
2337
|
+
M === "INVALID_PACKET" && T();
|
|
2338
|
+
});
|
|
2339
|
+
}
|
|
2340
|
+
} }, D = yield n.vertoSubscribe(C).catch((b) => {
|
|
2341
|
+
B.error("liveArray subscription error:", b);
|
|
2342
|
+
});
|
|
2343
|
+
rt(D, u) && T();
|
|
2344
|
+
break;
|
|
2345
|
+
}
|
|
2346
|
+
case "conference-liveArray-part": {
|
|
2347
|
+
let T = null;
|
|
2348
|
+
if (u && n._existsSubscription(r, u)) {
|
|
2349
|
+
const { callId: D = null } = n.subscriptions[r][u];
|
|
2350
|
+
if (T = n.calls[D] || null, D !== null) {
|
|
2351
|
+
const b = { type: ye.conferenceUpdate, action: de.Leave, conferenceName: l, participantId: Number(y), role: S };
|
|
2352
|
+
X(V.Notification, b, D, !1) || X(V.Notification, b, n.uuid), T === null && Re(V.Notification, null, D);
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
const C = [u, h, g, p];
|
|
2356
|
+
n.vertoUnsubscribe({ nodeId: this.nodeId, channels: C }).then(({ unsubscribedChannels: D = [] }) => {
|
|
2357
|
+
T && (T.channels = T.channels.filter((b) => !D.includes(b)));
|
|
2358
|
+
}).catch((D) => {
|
|
2359
|
+
B.error("liveArray unsubscribe error:", D);
|
|
2360
|
+
});
|
|
2361
|
+
break;
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
_handleSessionEvent(e) {
|
|
2367
|
+
switch (e.contentType) {
|
|
2368
|
+
case "layout-info":
|
|
2369
|
+
case "layer-info":
|
|
2370
|
+
Vn(this.session, e);
|
|
2371
|
+
break;
|
|
2372
|
+
case "logo-info": {
|
|
2373
|
+
const n = { type: ye.conferenceUpdate, action: de.LogoInfo, logo: e.logoURL };
|
|
2374
|
+
X(V.Notification, n, this.session.uuid);
|
|
2375
|
+
break;
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
me.retriedConnect = 0, me.retriedRegister = 0;
|
|
2381
|
+
class qr extends fe {
|
|
2382
|
+
constructor(e) {
|
|
2383
|
+
super(), this.method = "anonymous_login";
|
|
2384
|
+
const { target_type: n, target_id: r, target_version_id: i, userVariables: u, sessionId: l, reconnection: h } = e, g = { target_type: n, target_id: r, userVariables: u, reconnection: h, "User-Agent": { sdkVersion: Lt, data: navigator.userAgent } };
|
|
2385
|
+
l && (g.sessid = l), i && (g.target_version_id = i), this.buildRequest({ method: this.method, params: g });
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
class Hr extends Br {
|
|
2389
|
+
constructor(e) {
|
|
2390
|
+
super(e), this.relayProtocol = "verto-protocol", this.timeoutErrorCode = -329990, this.handleLoginOnSocketOpen = () => q(this, void 0, void 0, function* () {
|
|
2391
|
+
this._idle = !1;
|
|
2392
|
+
const { login: n, password: r, passwd: i, login_token: u, userVariables: l, autoReconnect: h = !0 } = this.options, g = new Rr(n, r || i, u, this.sessionid, l, !!Rt()), p = yield this.execute(g).catch(this._handleLoginError);
|
|
2393
|
+
p && (this._autoReconnect = h, this.sessionid = p.sessid);
|
|
2394
|
+
}), this.handleAnonymousLoginOnSocketOpen = () => q(this, void 0, void 0, function* () {
|
|
2395
|
+
this._idle = !1;
|
|
2396
|
+
const { anonymous_login: n } = this.options, r = new qr({ 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: !!Rt() }), i = yield this.execute(r).catch(this._handleLoginError);
|
|
2397
|
+
i && (this.sessionid = i.sessid);
|
|
2398
|
+
}), window.addEventListener("beforeunload", (n) => {
|
|
2399
|
+
this.calls && Object.keys(this.calls).forEach((r) => {
|
|
2400
|
+
this.calls[r] && this.calls[r].hangup({}, !0);
|
|
2401
|
+
});
|
|
2402
|
+
});
|
|
2403
|
+
}
|
|
2404
|
+
validateOptions() {
|
|
2405
|
+
return Ct(this.options) || nt(this.options);
|
|
2406
|
+
}
|
|
2407
|
+
newCall(e) {
|
|
2408
|
+
if (!this.validateCallOptions(e)) throw new Error("Verto.newCall() error: destinationNumber is required.");
|
|
2409
|
+
console.time(An);
|
|
2410
|
+
const n = new Se(this, e);
|
|
2411
|
+
return n.invite(), n;
|
|
2412
|
+
}
|
|
2413
|
+
broadcast(e) {
|
|
2414
|
+
return this.vertoBroadcast(e);
|
|
2415
|
+
}
|
|
2416
|
+
subscribe(e) {
|
|
2417
|
+
return this.vertoSubscribe(e);
|
|
2418
|
+
}
|
|
2419
|
+
unsubscribe(e) {
|
|
2420
|
+
return this.vertoUnsubscribe(e);
|
|
2421
|
+
}
|
|
2422
|
+
validateCallOptions(e) {
|
|
2423
|
+
return !!nt(this.options) || !!e.destinationNumber;
|
|
2424
|
+
}
|
|
2425
|
+
_onSocketOpen() {
|
|
2426
|
+
return q(this, void 0, void 0, function* () {
|
|
2427
|
+
return Ct(this.options) ? this.handleLoginOnSocketOpen() : nt(this.options) ? this.handleAnonymousLoginOnSocketOpen() : void 0;
|
|
2428
|
+
});
|
|
2429
|
+
}
|
|
2430
|
+
_onSocketMessage(e) {
|
|
2431
|
+
new me(this).handleMessage(e);
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
class zr extends Hr {
|
|
2435
|
+
constructor(e) {
|
|
2436
|
+
super(e), console.log(`SDK version: ${$n}`);
|
|
2437
|
+
}
|
|
2438
|
+
newCall(e) {
|
|
2439
|
+
return super.newCall(e);
|
|
2440
|
+
}
|
|
2441
|
+
static webRTCInfo() {
|
|
2442
|
+
return Cr();
|
|
2443
|
+
}
|
|
2444
|
+
static webRTCSupportedBrowserList() {
|
|
2445
|
+
return [{ operationSystem: "Android", supported: [{ browserName: "Chrome", features: ["audio"], supported: se.full }, { browserName: "Firefox", features: ["audio"], supported: se.partial }, { browserName: "Safari", supported: se.not_supported }, { browserName: "Edge", supported: se.not_supported }] }, { operationSystem: "iOS", supported: [{ browserName: "Chrome", supported: se.not_supported }, { browserName: "Firefox", supported: se.not_supported }, { browserName: "Safari", features: ["video", "audio"], supported: se.full }, { browserName: "Edge", supported: se.not_supported }] }, { operationSystem: "Linux", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: se.full }, { browserName: "Firefox", features: ["audio"], supported: se.partial }, { browserName: "Safari", supported: se.not_supported }, { browserName: "Edge", supported: se.not_supported }] }, { operationSystem: "MacOS", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: se.full }, { browserName: "Firefox", features: ["audio"], supported: se.partial }, { browserName: "Safari", features: ["video", "audio"], supported: se.full }, { browserName: "Edge", features: ["audio"], supported: se.partial }] }, { operationSystem: "Windows", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: se.full }, { browserName: "Firefox", features: ["audio"], supported: se.partial }, { browserName: "Safari", supported: se.not_supported }, { browserName: "Edge", features: ["audio"], supported: se.partial }] }];
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
function Wn(t) {
|
|
2449
|
+
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
2450
|
+
}
|
|
2451
|
+
var yt = { exports: {} }, fn;
|
|
2452
|
+
function Kr() {
|
|
2453
|
+
return fn || (fn = 1, function(t) {
|
|
2454
|
+
var e = Object.prototype.hasOwnProperty, n = "~";
|
|
2455
|
+
function r() {
|
|
2456
|
+
}
|
|
2457
|
+
Object.create && (r.prototype = /* @__PURE__ */ Object.create(null), new r().__proto__ || (n = !1));
|
|
2458
|
+
function i(g, p, y) {
|
|
2459
|
+
this.fn = g, this.context = p, this.once = y || !1;
|
|
2460
|
+
}
|
|
2461
|
+
function u(g, p, y, S, I) {
|
|
2462
|
+
if (typeof y != "function")
|
|
2463
|
+
throw new TypeError("The listener must be a function");
|
|
2464
|
+
var T = new i(y, S || g, I), C = n ? n + p : p;
|
|
2465
|
+
return g._events[C] ? g._events[C].fn ? g._events[C] = [g._events[C], T] : g._events[C].push(T) : (g._events[C] = T, g._eventsCount++), g;
|
|
2466
|
+
}
|
|
2467
|
+
function l(g, p) {
|
|
2468
|
+
--g._eventsCount === 0 ? g._events = new r() : delete g._events[p];
|
|
2469
|
+
}
|
|
2470
|
+
function h() {
|
|
2471
|
+
this._events = new r(), this._eventsCount = 0;
|
|
2472
|
+
}
|
|
2473
|
+
h.prototype.eventNames = function() {
|
|
2474
|
+
var p = [], y, S;
|
|
2475
|
+
if (this._eventsCount === 0) return p;
|
|
2476
|
+
for (S in y = this._events)
|
|
2477
|
+
e.call(y, S) && p.push(n ? S.slice(1) : S);
|
|
2478
|
+
return Object.getOwnPropertySymbols ? p.concat(Object.getOwnPropertySymbols(y)) : p;
|
|
2479
|
+
}, h.prototype.listeners = function(p) {
|
|
2480
|
+
var y = n ? n + p : p, S = this._events[y];
|
|
2481
|
+
if (!S) return [];
|
|
2482
|
+
if (S.fn) return [S.fn];
|
|
2483
|
+
for (var I = 0, T = S.length, C = new Array(T); I < T; I++)
|
|
2484
|
+
C[I] = S[I].fn;
|
|
2485
|
+
return C;
|
|
2486
|
+
}, h.prototype.listenerCount = function(p) {
|
|
2487
|
+
var y = n ? n + p : p, S = this._events[y];
|
|
2488
|
+
return S ? S.fn ? 1 : S.length : 0;
|
|
2489
|
+
}, h.prototype.emit = function(p, y, S, I, T, C) {
|
|
2490
|
+
var D = n ? n + p : p;
|
|
2491
|
+
if (!this._events[D]) return !1;
|
|
2492
|
+
var b = this._events[D], j = arguments.length, $, M;
|
|
2493
|
+
if (b.fn) {
|
|
2494
|
+
switch (b.once && this.removeListener(p, b.fn, void 0, !0), j) {
|
|
2495
|
+
case 1:
|
|
2496
|
+
return b.fn.call(b.context), !0;
|
|
2497
|
+
case 2:
|
|
2498
|
+
return b.fn.call(b.context, y), !0;
|
|
2499
|
+
case 3:
|
|
2500
|
+
return b.fn.call(b.context, y, S), !0;
|
|
2501
|
+
case 4:
|
|
2502
|
+
return b.fn.call(b.context, y, S, I), !0;
|
|
2503
|
+
case 5:
|
|
2504
|
+
return b.fn.call(b.context, y, S, I, T), !0;
|
|
2505
|
+
case 6:
|
|
2506
|
+
return b.fn.call(b.context, y, S, I, T, C), !0;
|
|
2507
|
+
}
|
|
2508
|
+
for (M = 1, $ = new Array(j - 1); M < j; M++)
|
|
2509
|
+
$[M - 1] = arguments[M];
|
|
2510
|
+
b.fn.apply(b.context, $);
|
|
2511
|
+
} else {
|
|
2512
|
+
var K = b.length, G;
|
|
2513
|
+
for (M = 0; M < K; M++)
|
|
2514
|
+
switch (b[M].once && this.removeListener(p, b[M].fn, void 0, !0), j) {
|
|
2515
|
+
case 1:
|
|
2516
|
+
b[M].fn.call(b[M].context);
|
|
2517
|
+
break;
|
|
2518
|
+
case 2:
|
|
2519
|
+
b[M].fn.call(b[M].context, y);
|
|
2520
|
+
break;
|
|
2521
|
+
case 3:
|
|
2522
|
+
b[M].fn.call(b[M].context, y, S);
|
|
2523
|
+
break;
|
|
2524
|
+
case 4:
|
|
2525
|
+
b[M].fn.call(b[M].context, y, S, I);
|
|
2526
|
+
break;
|
|
2527
|
+
default:
|
|
2528
|
+
if (!$) for (G = 1, $ = new Array(j - 1); G < j; G++)
|
|
2529
|
+
$[G - 1] = arguments[G];
|
|
2530
|
+
b[M].fn.apply(b[M].context, $);
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
return !0;
|
|
2534
|
+
}, h.prototype.on = function(p, y, S) {
|
|
2535
|
+
return u(this, p, y, S, !1);
|
|
2536
|
+
}, h.prototype.once = function(p, y, S) {
|
|
2537
|
+
return u(this, p, y, S, !0);
|
|
2538
|
+
}, h.prototype.removeListener = function(p, y, S, I) {
|
|
2539
|
+
var T = n ? n + p : p;
|
|
2540
|
+
if (!this._events[T]) return this;
|
|
2541
|
+
if (!y)
|
|
2542
|
+
return l(this, T), this;
|
|
2543
|
+
var C = this._events[T];
|
|
2544
|
+
if (C.fn)
|
|
2545
|
+
C.fn === y && (!I || C.once) && (!S || C.context === S) && l(this, T);
|
|
2546
|
+
else {
|
|
2547
|
+
for (var D = 0, b = [], j = C.length; D < j; D++)
|
|
2548
|
+
(C[D].fn !== y || I && !C[D].once || S && C[D].context !== S) && b.push(C[D]);
|
|
2549
|
+
b.length ? this._events[T] = b.length === 1 ? b[0] : b : l(this, T);
|
|
2550
|
+
}
|
|
2551
|
+
return this;
|
|
2552
|
+
}, h.prototype.removeAllListeners = function(p) {
|
|
2553
|
+
var y;
|
|
2554
|
+
return p ? (y = n ? n + p : p, this._events[y] && l(this, y)) : (this._events = new r(), this._eventsCount = 0), this;
|
|
2555
|
+
}, h.prototype.off = h.prototype.removeListener, h.prototype.addListener = h.prototype.on, h.prefixed = n, h.EventEmitter = h, t.exports = h;
|
|
2556
|
+
}(yt)), yt.exports;
|
|
2557
|
+
}
|
|
2558
|
+
var Jr = Kr();
|
|
2559
|
+
const Nt = /* @__PURE__ */ Wn(Jr), Ge = new Nt();
|
|
2560
|
+
function Qr(t) {
|
|
2561
|
+
if (!t || typeof t != "object")
|
|
2562
|
+
return !1;
|
|
2563
|
+
const e = t;
|
|
2564
|
+
return e.method === "ai_conversation" && typeof e.params == "object";
|
|
2565
|
+
}
|
|
2566
|
+
function Xr(t) {
|
|
2567
|
+
if (!t || typeof t != "object")
|
|
2568
|
+
return !1;
|
|
2569
|
+
const e = t;
|
|
2570
|
+
return e.params.type !== "response.text.delta" ? !1 : !!e.params.delta;
|
|
2571
|
+
}
|
|
2572
|
+
function Zr(t) {
|
|
2573
|
+
if (!t || typeof t != "object")
|
|
2574
|
+
return !1;
|
|
2575
|
+
const e = t;
|
|
2576
|
+
return e.params.type !== "conversation.item.created" ? !1 : !!e.params.item.content;
|
|
2577
|
+
}
|
|
2578
|
+
function eo(t) {
|
|
2579
|
+
return Xr(t) ? {
|
|
2580
|
+
id: `${t.params.item_id}-${Date.now()}`,
|
|
2581
|
+
role: "assistant",
|
|
2582
|
+
content: t.params.delta,
|
|
2583
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
2584
|
+
} : null;
|
|
2585
|
+
}
|
|
2586
|
+
function to(t) {
|
|
2587
|
+
return !Zr(t) || t.params.item.role !== "user" || t.params.item.status !== "completed" ? null : {
|
|
2588
|
+
id: `${t.params.item.id}-${Date.now()}`,
|
|
2589
|
+
role: t.params.item.role,
|
|
2590
|
+
content: t.params.item.content.map((e) => e.transcript).join(" "),
|
|
2591
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
2592
|
+
};
|
|
2593
|
+
}
|
|
2594
|
+
class no extends Nt {
|
|
2595
|
+
telnyxRTC;
|
|
2596
|
+
transcript = [];
|
|
2597
|
+
constructor(e) {
|
|
2598
|
+
super(), this.telnyxRTC = e, this.telnyxRTC.on(V.SocketMessage, this.onSocketMessage);
|
|
2599
|
+
}
|
|
2600
|
+
onSocketMessage = (e) => {
|
|
2601
|
+
if (Qr(e))
|
|
2602
|
+
switch (e.params.type) {
|
|
2603
|
+
case "response.text.delta": {
|
|
2604
|
+
const n = eo(e);
|
|
2605
|
+
n && (this.transcript.push(n), this.emit("transcript.item", n)), Ge.emit("conversation.agent.state", "listening");
|
|
2606
|
+
return;
|
|
2607
|
+
}
|
|
2608
|
+
case "conversation.item.created": {
|
|
2609
|
+
const n = to(e);
|
|
2610
|
+
n && (this.transcript.push(n), this.emit("transcript.item", n), Ge.emit("conversation.agent.state", "thinking"));
|
|
2611
|
+
return;
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
};
|
|
2615
|
+
}
|
|
2616
|
+
const ro = 5;
|
|
2617
|
+
class oo {
|
|
2618
|
+
animationFrameId = null;
|
|
2619
|
+
stream = null;
|
|
2620
|
+
audioContext = null;
|
|
2621
|
+
source = null;
|
|
2622
|
+
analyser = null;
|
|
2623
|
+
updateAgentState = (e) => {
|
|
2624
|
+
Ge.emit("conversation.agent.state", e);
|
|
2625
|
+
};
|
|
2626
|
+
setMonitoredAudioStream(e) {
|
|
2627
|
+
this.stream && this.stopAudioStreamMonitor(), this.stream = e, this.startAudioStreamMonitor();
|
|
2628
|
+
}
|
|
2629
|
+
stopAudioStreamMonitor() {
|
|
2630
|
+
this.animationFrameId && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null), this.source?.disconnect();
|
|
2631
|
+
}
|
|
2632
|
+
startAudioStreamMonitor() {
|
|
2633
|
+
if (!this.stream) return;
|
|
2634
|
+
this.audioContext = new AudioContext(), this.source = this.audioContext.createMediaStreamSource(this.stream), this.analyser = this.audioContext.createAnalyser(), this.source.connect(this.analyser), this.analyser.fftSize = 512;
|
|
2635
|
+
const e = new Uint8Array(this.analyser.frequencyBinCount), n = () => {
|
|
2636
|
+
const r = e.reduce((i, u) => i + u, 0) / e.length;
|
|
2637
|
+
this.analyser?.getByteFrequencyData(e), r > ro ? this.updateAgentState("speaking") : this.updateAgentState("listening"), this.animationFrameId = requestAnimationFrame(n);
|
|
2638
|
+
};
|
|
2639
|
+
this.animationFrameId = requestAnimationFrame(n);
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
class pn extends Nt {
|
|
2643
|
+
telnyxRTC;
|
|
2644
|
+
transcription;
|
|
2645
|
+
agentId;
|
|
2646
|
+
versionId;
|
|
2647
|
+
audioStreamMonitor;
|
|
2648
|
+
activeCall;
|
|
2649
|
+
constructor(e) {
|
|
2650
|
+
super(), this.agentId = e.agentId, this.versionId = e.versionId || "main", this.activeCall = null, this.telnyxRTC = new zr({
|
|
2651
|
+
// @ts-expect-error hidden argument
|
|
2652
|
+
environment: e.environment || "production",
|
|
2653
|
+
anonymous_login: {
|
|
2654
|
+
target_id: e.agentId,
|
|
2655
|
+
target_type: "ai_assistant",
|
|
2656
|
+
target_version_id: e.versionId
|
|
2657
|
+
}
|
|
2658
|
+
}), this.telnyxRTC.on(V.Ready, this.onClientReady), this.telnyxRTC.on(V.Error, this.onClientOrSocketError), this.telnyxRTC.on(V.SocketError, this.onClientOrSocketError), this.telnyxRTC.on(V.Notification, this.onNotification), this.transcription = new no(this.telnyxRTC), this.transcription.addListener("transcript.item", this.onTranscriptItem), Ge.addListener(
|
|
2659
|
+
"conversation.agent.state",
|
|
2660
|
+
this.onAgentStateChange
|
|
2661
|
+
), this.audioStreamMonitor = new oo();
|
|
2662
|
+
}
|
|
2663
|
+
async connect() {
|
|
2664
|
+
return this.telnyxRTC.connect();
|
|
2665
|
+
}
|
|
2666
|
+
async disconnect() {
|
|
2667
|
+
this.audioStreamMonitor.stopAudioStreamMonitor(), this.telnyxRTC.disconnect(), this.telnyxRTC.off(V.Ready, this.onClientReady), this.telnyxRTC.off(V.Error, this.onClientOrSocketError), this.telnyxRTC.off(V.SocketError, this.onClientOrSocketError), this.telnyxRTC.off(V.Notification, this.onNotification), this.emit("agent.disconnected"), this.transcription.removeAllListeners(), Ge.removeAllListeners(), this.removeAllListeners();
|
|
2668
|
+
}
|
|
2669
|
+
get transcript() {
|
|
2670
|
+
return this.transcription.transcript;
|
|
2671
|
+
}
|
|
2672
|
+
async startConversation() {
|
|
2673
|
+
if (!this.telnyxRTC) {
|
|
2674
|
+
console.error("Client is not initialized.");
|
|
2675
|
+
return;
|
|
2676
|
+
}
|
|
2677
|
+
const n = RTCRtpReceiver.getCapabilities("audio")?.codecs?.find(
|
|
2678
|
+
(u) => u.mimeType.toLowerCase().includes("opus")
|
|
2679
|
+
), r = this.versionId ? [{ name: "X-AI-Assistant-Version-ID", value: this.versionId }] : void 0, i = this.telnyxRTC.newCall({
|
|
2680
|
+
destinationNumber: "xxx",
|
|
2681
|
+
preferred_codecs: [n],
|
|
2682
|
+
customHeaders: r
|
|
2683
|
+
});
|
|
2684
|
+
this.emit("conversation.update", { call: i, type: "callUpdate" });
|
|
2685
|
+
}
|
|
2686
|
+
endConversation() {
|
|
2687
|
+
return this.activeCall?.hangup();
|
|
2688
|
+
}
|
|
2689
|
+
onClientReady = () => {
|
|
2690
|
+
this.emit("agent.connected");
|
|
2691
|
+
};
|
|
2692
|
+
onClientOrSocketError = (e) => {
|
|
2693
|
+
this.emit("agent.error", e);
|
|
2694
|
+
};
|
|
2695
|
+
onNotification = (e) => {
|
|
2696
|
+
e.type !== "callUpdate" || !e.call || (this.emit("conversation.update", e), e.call.state === "active" ? (this.activeCall = e.call, this.audioStreamMonitor.setMonitoredAudioStream(
|
|
2697
|
+
e.call.remoteStream
|
|
2698
|
+
)) : (this.activeCall = null, this.audioStreamMonitor.stopAudioStreamMonitor()));
|
|
2699
|
+
};
|
|
2700
|
+
onTranscriptItem = (e) => {
|
|
2701
|
+
this.emit("transcript.item", e);
|
|
2702
|
+
};
|
|
2703
|
+
onAgentStateChange = (e) => {
|
|
2704
|
+
this.emit("conversation.agent.state", e);
|
|
2705
|
+
};
|
|
2706
|
+
}
|
|
2707
|
+
var Ze = { exports: {} }, xe = {};
|
|
2708
|
+
/**
|
|
2709
|
+
* @license React
|
|
2710
|
+
* react-jsx-runtime.production.js
|
|
2711
|
+
*
|
|
2712
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2713
|
+
*
|
|
2714
|
+
* This source code is licensed under the MIT license found in the
|
|
2715
|
+
* LICENSE file in the root directory of this source tree.
|
|
2716
|
+
*/
|
|
2717
|
+
var gn;
|
|
2718
|
+
function io() {
|
|
2719
|
+
if (gn) return xe;
|
|
2720
|
+
gn = 1;
|
|
2721
|
+
var t = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
2722
|
+
function n(r, i, u) {
|
|
2723
|
+
var l = null;
|
|
2724
|
+
if (u !== void 0 && (l = "" + u), i.key !== void 0 && (l = "" + i.key), "key" in i) {
|
|
2725
|
+
u = {};
|
|
2726
|
+
for (var h in i)
|
|
2727
|
+
h !== "key" && (u[h] = i[h]);
|
|
2728
|
+
} else u = i;
|
|
2729
|
+
return i = u.ref, {
|
|
2730
|
+
$$typeof: t,
|
|
2731
|
+
type: r,
|
|
2732
|
+
key: l,
|
|
2733
|
+
ref: i !== void 0 ? i : null,
|
|
2734
|
+
props: u
|
|
2735
|
+
};
|
|
2736
|
+
}
|
|
2737
|
+
return xe.Fragment = e, xe.jsx = n, xe.jsxs = n, xe;
|
|
2738
|
+
}
|
|
2739
|
+
var Le = {}, et = { exports: {} }, z = {};
|
|
2740
|
+
/**
|
|
2741
|
+
* @license React
|
|
2742
|
+
* react.production.js
|
|
2743
|
+
*
|
|
2744
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2745
|
+
*
|
|
2746
|
+
* This source code is licensed under the MIT license found in the
|
|
2747
|
+
* LICENSE file in the root directory of this source tree.
|
|
2748
|
+
*/
|
|
2749
|
+
var vn;
|
|
2750
|
+
function so() {
|
|
2751
|
+
if (vn) return z;
|
|
2752
|
+
vn = 1;
|
|
2753
|
+
var t = Symbol.for("react.transitional.element"), e = Symbol.for("react.portal"), n = Symbol.for("react.fragment"), r = Symbol.for("react.strict_mode"), i = Symbol.for("react.profiler"), u = Symbol.for("react.consumer"), l = Symbol.for("react.context"), h = Symbol.for("react.forward_ref"), g = Symbol.for("react.suspense"), p = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), S = Symbol.iterator;
|
|
2754
|
+
function I(a) {
|
|
2755
|
+
return a === null || typeof a != "object" ? null : (a = S && a[S] || a["@@iterator"], typeof a == "function" ? a : null);
|
|
2756
|
+
}
|
|
2757
|
+
var T = {
|
|
2758
|
+
isMounted: function() {
|
|
2759
|
+
return !1;
|
|
2760
|
+
},
|
|
2761
|
+
enqueueForceUpdate: function() {
|
|
2762
|
+
},
|
|
2763
|
+
enqueueReplaceState: function() {
|
|
2764
|
+
},
|
|
2765
|
+
enqueueSetState: function() {
|
|
2766
|
+
}
|
|
2767
|
+
}, C = Object.assign, D = {};
|
|
2768
|
+
function b(a, m, k) {
|
|
2769
|
+
this.props = a, this.context = m, this.refs = D, this.updater = k || T;
|
|
2770
|
+
}
|
|
2771
|
+
b.prototype.isReactComponent = {}, b.prototype.setState = function(a, m) {
|
|
2772
|
+
if (typeof a != "object" && typeof a != "function" && a != null)
|
|
2773
|
+
throw Error(
|
|
2774
|
+
"takes an object of state variables to update or a function which returns an object of state variables."
|
|
2775
|
+
);
|
|
2776
|
+
this.updater.enqueueSetState(this, a, m, "setState");
|
|
2777
|
+
}, b.prototype.forceUpdate = function(a) {
|
|
2778
|
+
this.updater.enqueueForceUpdate(this, a, "forceUpdate");
|
|
2779
|
+
};
|
|
2780
|
+
function j() {
|
|
2781
|
+
}
|
|
2782
|
+
j.prototype = b.prototype;
|
|
2783
|
+
function $(a, m, k) {
|
|
2784
|
+
this.props = a, this.context = m, this.refs = D, this.updater = k || T;
|
|
2785
|
+
}
|
|
2786
|
+
var M = $.prototype = new j();
|
|
2787
|
+
M.constructor = $, C(M, b.prototype), M.isPureReactComponent = !0;
|
|
2788
|
+
var K = Array.isArray, G = { H: null, A: null, T: null, S: null, V: null }, ce = Object.prototype.hasOwnProperty;
|
|
2789
|
+
function R(a, m, k, A, U, Y) {
|
|
2790
|
+
return k = Y.ref, {
|
|
2791
|
+
$$typeof: t,
|
|
2792
|
+
type: a,
|
|
2793
|
+
key: m,
|
|
2794
|
+
ref: k !== void 0 ? k : null,
|
|
2795
|
+
props: Y
|
|
2796
|
+
};
|
|
2797
|
+
}
|
|
2798
|
+
function x(a, m) {
|
|
2799
|
+
return R(
|
|
2800
|
+
a.type,
|
|
2801
|
+
m,
|
|
2802
|
+
void 0,
|
|
2803
|
+
void 0,
|
|
2804
|
+
void 0,
|
|
2805
|
+
a.props
|
|
2806
|
+
);
|
|
2807
|
+
}
|
|
2808
|
+
function s(a) {
|
|
2809
|
+
return typeof a == "object" && a !== null && a.$$typeof === t;
|
|
2810
|
+
}
|
|
2811
|
+
function c(a) {
|
|
2812
|
+
var m = { "=": "=0", ":": "=2" };
|
|
2813
|
+
return "$" + a.replace(/[=:]/g, function(k) {
|
|
2814
|
+
return m[k];
|
|
2815
|
+
});
|
|
2816
|
+
}
|
|
2817
|
+
var d = /\/+/g;
|
|
2818
|
+
function f(a, m) {
|
|
2819
|
+
return typeof a == "object" && a !== null && a.key != null ? c("" + a.key) : m.toString(36);
|
|
2820
|
+
}
|
|
2821
|
+
function _() {
|
|
2822
|
+
}
|
|
2823
|
+
function E(a) {
|
|
2824
|
+
switch (a.status) {
|
|
2825
|
+
case "fulfilled":
|
|
2826
|
+
return a.value;
|
|
2827
|
+
case "rejected":
|
|
2828
|
+
throw a.reason;
|
|
2829
|
+
default:
|
|
2830
|
+
switch (typeof a.status == "string" ? a.then(_, _) : (a.status = "pending", a.then(
|
|
2831
|
+
function(m) {
|
|
2832
|
+
a.status === "pending" && (a.status = "fulfilled", a.value = m);
|
|
2833
|
+
},
|
|
2834
|
+
function(m) {
|
|
2835
|
+
a.status === "pending" && (a.status = "rejected", a.reason = m);
|
|
2836
|
+
}
|
|
2837
|
+
)), a.status) {
|
|
2838
|
+
case "fulfilled":
|
|
2839
|
+
return a.value;
|
|
2840
|
+
case "rejected":
|
|
2841
|
+
throw a.reason;
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
throw a;
|
|
2845
|
+
}
|
|
2846
|
+
function w(a, m, k, A, U) {
|
|
2847
|
+
var Y = typeof a;
|
|
2848
|
+
(Y === "undefined" || Y === "boolean") && (a = null);
|
|
2849
|
+
var F = !1;
|
|
2850
|
+
if (a === null) F = !0;
|
|
2851
|
+
else
|
|
2852
|
+
switch (Y) {
|
|
2853
|
+
case "bigint":
|
|
2854
|
+
case "string":
|
|
2855
|
+
case "number":
|
|
2856
|
+
F = !0;
|
|
2857
|
+
break;
|
|
2858
|
+
case "object":
|
|
2859
|
+
switch (a.$$typeof) {
|
|
2860
|
+
case t:
|
|
2861
|
+
case e:
|
|
2862
|
+
F = !0;
|
|
2863
|
+
break;
|
|
2864
|
+
case y:
|
|
2865
|
+
return F = a._init, w(
|
|
2866
|
+
F(a._payload),
|
|
2867
|
+
m,
|
|
2868
|
+
k,
|
|
2869
|
+
A,
|
|
2870
|
+
U
|
|
2871
|
+
);
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
if (F)
|
|
2875
|
+
return U = U(a), F = A === "" ? "." + f(a, 0) : A, K(U) ? (k = "", F != null && (k = F.replace(d, "$&/") + "/"), w(U, m, k, "", function(pe) {
|
|
2876
|
+
return pe;
|
|
2877
|
+
})) : U != null && (s(U) && (U = x(
|
|
2878
|
+
U,
|
|
2879
|
+
k + (U.key == null || a && a.key === U.key ? "" : ("" + U.key).replace(
|
|
2880
|
+
d,
|
|
2881
|
+
"$&/"
|
|
2882
|
+
) + "/") + F
|
|
2883
|
+
)), m.push(U)), 1;
|
|
2884
|
+
F = 0;
|
|
2885
|
+
var ae = A === "" ? "." : A + ":";
|
|
2886
|
+
if (K(a))
|
|
2887
|
+
for (var H = 0; H < a.length; H++)
|
|
2888
|
+
A = a[H], Y = ae + f(A, H), F += w(
|
|
2889
|
+
A,
|
|
2890
|
+
m,
|
|
2891
|
+
k,
|
|
2892
|
+
Y,
|
|
2893
|
+
U
|
|
2894
|
+
);
|
|
2895
|
+
else if (H = I(a), typeof H == "function")
|
|
2896
|
+
for (a = H.call(a), H = 0; !(A = a.next()).done; )
|
|
2897
|
+
A = A.value, Y = ae + f(A, H++), F += w(
|
|
2898
|
+
A,
|
|
2899
|
+
m,
|
|
2900
|
+
k,
|
|
2901
|
+
Y,
|
|
2902
|
+
U
|
|
2903
|
+
);
|
|
2904
|
+
else if (Y === "object") {
|
|
2905
|
+
if (typeof a.then == "function")
|
|
2906
|
+
return w(
|
|
2907
|
+
E(a),
|
|
2908
|
+
m,
|
|
2909
|
+
k,
|
|
2910
|
+
A,
|
|
2911
|
+
U
|
|
2912
|
+
);
|
|
2913
|
+
throw m = String(a), Error(
|
|
2914
|
+
"Objects are not valid as a React child (found: " + (m === "[object Object]" ? "object with keys {" + Object.keys(a).join(", ") + "}" : m) + "). If you meant to render a collection of children, use an array instead."
|
|
2915
|
+
);
|
|
2916
|
+
}
|
|
2917
|
+
return F;
|
|
2918
|
+
}
|
|
2919
|
+
function L(a, m, k) {
|
|
2920
|
+
if (a == null) return a;
|
|
2921
|
+
var A = [], U = 0;
|
|
2922
|
+
return w(a, A, "", "", function(Y) {
|
|
2923
|
+
return m.call(k, Y, U++);
|
|
2924
|
+
}), A;
|
|
2925
|
+
}
|
|
2926
|
+
function P(a) {
|
|
2927
|
+
if (a._status === -1) {
|
|
2928
|
+
var m = a._result;
|
|
2929
|
+
m = m(), m.then(
|
|
2930
|
+
function(k) {
|
|
2931
|
+
(a._status === 0 || a._status === -1) && (a._status = 1, a._result = k);
|
|
2932
|
+
},
|
|
2933
|
+
function(k) {
|
|
2934
|
+
(a._status === 0 || a._status === -1) && (a._status = 2, a._result = k);
|
|
2935
|
+
}
|
|
2936
|
+
), a._status === -1 && (a._status = 0, a._result = m);
|
|
2937
|
+
}
|
|
2938
|
+
if (a._status === 1) return a._result.default;
|
|
2939
|
+
throw a._result;
|
|
2940
|
+
}
|
|
2941
|
+
var oe = typeof reportError == "function" ? reportError : function(a) {
|
|
2942
|
+
if (typeof window == "object" && typeof window.ErrorEvent == "function") {
|
|
2943
|
+
var m = new window.ErrorEvent("error", {
|
|
2944
|
+
bubbles: !0,
|
|
2945
|
+
cancelable: !0,
|
|
2946
|
+
message: typeof a == "object" && a !== null && typeof a.message == "string" ? String(a.message) : String(a),
|
|
2947
|
+
error: a
|
|
2948
|
+
});
|
|
2949
|
+
if (!window.dispatchEvent(m)) return;
|
|
2950
|
+
} else if (typeof process == "object" && typeof process.emit == "function") {
|
|
2951
|
+
process.emit("uncaughtException", a);
|
|
2952
|
+
return;
|
|
2953
|
+
}
|
|
2954
|
+
console.error(a);
|
|
2955
|
+
};
|
|
2956
|
+
function ie() {
|
|
2957
|
+
}
|
|
2958
|
+
return z.Children = {
|
|
2959
|
+
map: L,
|
|
2960
|
+
forEach: function(a, m, k) {
|
|
2961
|
+
L(
|
|
2962
|
+
a,
|
|
2963
|
+
function() {
|
|
2964
|
+
m.apply(this, arguments);
|
|
2965
|
+
},
|
|
2966
|
+
k
|
|
2967
|
+
);
|
|
2968
|
+
},
|
|
2969
|
+
count: function(a) {
|
|
2970
|
+
var m = 0;
|
|
2971
|
+
return L(a, function() {
|
|
2972
|
+
m++;
|
|
2973
|
+
}), m;
|
|
2974
|
+
},
|
|
2975
|
+
toArray: function(a) {
|
|
2976
|
+
return L(a, function(m) {
|
|
2977
|
+
return m;
|
|
2978
|
+
}) || [];
|
|
2979
|
+
},
|
|
2980
|
+
only: function(a) {
|
|
2981
|
+
if (!s(a))
|
|
2982
|
+
throw Error(
|
|
2983
|
+
"React.Children.only expected to receive a single React element child."
|
|
2984
|
+
);
|
|
2985
|
+
return a;
|
|
2986
|
+
}
|
|
2987
|
+
}, z.Component = b, z.Fragment = n, z.Profiler = i, z.PureComponent = $, z.StrictMode = r, z.Suspense = g, z.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = G, z.__COMPILER_RUNTIME = {
|
|
2988
|
+
__proto__: null,
|
|
2989
|
+
c: function(a) {
|
|
2990
|
+
return G.H.useMemoCache(a);
|
|
2991
|
+
}
|
|
2992
|
+
}, z.cache = function(a) {
|
|
2993
|
+
return function() {
|
|
2994
|
+
return a.apply(null, arguments);
|
|
2995
|
+
};
|
|
2996
|
+
}, z.cloneElement = function(a, m, k) {
|
|
2997
|
+
if (a == null)
|
|
2998
|
+
throw Error(
|
|
2999
|
+
"The argument must be a React element, but you passed " + a + "."
|
|
3000
|
+
);
|
|
3001
|
+
var A = C({}, a.props), U = a.key, Y = void 0;
|
|
3002
|
+
if (m != null)
|
|
3003
|
+
for (F in m.ref !== void 0 && (Y = void 0), m.key !== void 0 && (U = "" + m.key), m)
|
|
3004
|
+
!ce.call(m, F) || F === "key" || F === "__self" || F === "__source" || F === "ref" && m.ref === void 0 || (A[F] = m[F]);
|
|
3005
|
+
var F = arguments.length - 2;
|
|
3006
|
+
if (F === 1) A.children = k;
|
|
3007
|
+
else if (1 < F) {
|
|
3008
|
+
for (var ae = Array(F), H = 0; H < F; H++)
|
|
3009
|
+
ae[H] = arguments[H + 2];
|
|
3010
|
+
A.children = ae;
|
|
3011
|
+
}
|
|
3012
|
+
return R(a.type, U, void 0, void 0, Y, A);
|
|
3013
|
+
}, z.createContext = function(a) {
|
|
3014
|
+
return a = {
|
|
3015
|
+
$$typeof: l,
|
|
3016
|
+
_currentValue: a,
|
|
3017
|
+
_currentValue2: a,
|
|
3018
|
+
_threadCount: 0,
|
|
3019
|
+
Provider: null,
|
|
3020
|
+
Consumer: null
|
|
3021
|
+
}, a.Provider = a, a.Consumer = {
|
|
3022
|
+
$$typeof: u,
|
|
3023
|
+
_context: a
|
|
3024
|
+
}, a;
|
|
3025
|
+
}, z.createElement = function(a, m, k) {
|
|
3026
|
+
var A, U = {}, Y = null;
|
|
3027
|
+
if (m != null)
|
|
3028
|
+
for (A in m.key !== void 0 && (Y = "" + m.key), m)
|
|
3029
|
+
ce.call(m, A) && A !== "key" && A !== "__self" && A !== "__source" && (U[A] = m[A]);
|
|
3030
|
+
var F = arguments.length - 2;
|
|
3031
|
+
if (F === 1) U.children = k;
|
|
3032
|
+
else if (1 < F) {
|
|
3033
|
+
for (var ae = Array(F), H = 0; H < F; H++)
|
|
3034
|
+
ae[H] = arguments[H + 2];
|
|
3035
|
+
U.children = ae;
|
|
3036
|
+
}
|
|
3037
|
+
if (a && a.defaultProps)
|
|
3038
|
+
for (A in F = a.defaultProps, F)
|
|
3039
|
+
U[A] === void 0 && (U[A] = F[A]);
|
|
3040
|
+
return R(a, Y, void 0, void 0, null, U);
|
|
3041
|
+
}, z.createRef = function() {
|
|
3042
|
+
return { current: null };
|
|
3043
|
+
}, z.forwardRef = function(a) {
|
|
3044
|
+
return { $$typeof: h, render: a };
|
|
3045
|
+
}, z.isValidElement = s, z.lazy = function(a) {
|
|
3046
|
+
return {
|
|
3047
|
+
$$typeof: y,
|
|
3048
|
+
_payload: { _status: -1, _result: a },
|
|
3049
|
+
_init: P
|
|
3050
|
+
};
|
|
3051
|
+
}, z.memo = function(a, m) {
|
|
3052
|
+
return {
|
|
3053
|
+
$$typeof: p,
|
|
3054
|
+
type: a,
|
|
3055
|
+
compare: m === void 0 ? null : m
|
|
3056
|
+
};
|
|
3057
|
+
}, z.startTransition = function(a) {
|
|
3058
|
+
var m = G.T, k = {};
|
|
3059
|
+
G.T = k;
|
|
3060
|
+
try {
|
|
3061
|
+
var A = a(), U = G.S;
|
|
3062
|
+
U !== null && U(k, A), typeof A == "object" && A !== null && typeof A.then == "function" && A.then(ie, oe);
|
|
3063
|
+
} catch (Y) {
|
|
3064
|
+
oe(Y);
|
|
3065
|
+
} finally {
|
|
3066
|
+
G.T = m;
|
|
3067
|
+
}
|
|
3068
|
+
}, z.unstable_useCacheRefresh = function() {
|
|
3069
|
+
return G.H.useCacheRefresh();
|
|
3070
|
+
}, z.use = function(a) {
|
|
3071
|
+
return G.H.use(a);
|
|
3072
|
+
}, z.useActionState = function(a, m, k) {
|
|
3073
|
+
return G.H.useActionState(a, m, k);
|
|
3074
|
+
}, z.useCallback = function(a, m) {
|
|
3075
|
+
return G.H.useCallback(a, m);
|
|
3076
|
+
}, z.useContext = function(a) {
|
|
3077
|
+
return G.H.useContext(a);
|
|
3078
|
+
}, z.useDebugValue = function() {
|
|
3079
|
+
}, z.useDeferredValue = function(a, m) {
|
|
3080
|
+
return G.H.useDeferredValue(a, m);
|
|
3081
|
+
}, z.useEffect = function(a, m, k) {
|
|
3082
|
+
var A = G.H;
|
|
3083
|
+
if (typeof k == "function")
|
|
3084
|
+
throw Error(
|
|
3085
|
+
"useEffect CRUD overload is not enabled in this build of React."
|
|
3086
|
+
);
|
|
3087
|
+
return A.useEffect(a, m);
|
|
3088
|
+
}, z.useId = function() {
|
|
3089
|
+
return G.H.useId();
|
|
3090
|
+
}, z.useImperativeHandle = function(a, m, k) {
|
|
3091
|
+
return G.H.useImperativeHandle(a, m, k);
|
|
3092
|
+
}, z.useInsertionEffect = function(a, m) {
|
|
3093
|
+
return G.H.useInsertionEffect(a, m);
|
|
3094
|
+
}, z.useLayoutEffect = function(a, m) {
|
|
3095
|
+
return G.H.useLayoutEffect(a, m);
|
|
3096
|
+
}, z.useMemo = function(a, m) {
|
|
3097
|
+
return G.H.useMemo(a, m);
|
|
3098
|
+
}, z.useOptimistic = function(a, m) {
|
|
3099
|
+
return G.H.useOptimistic(a, m);
|
|
3100
|
+
}, z.useReducer = function(a, m, k) {
|
|
3101
|
+
return G.H.useReducer(a, m, k);
|
|
3102
|
+
}, z.useRef = function(a) {
|
|
3103
|
+
return G.H.useRef(a);
|
|
3104
|
+
}, z.useState = function(a) {
|
|
3105
|
+
return G.H.useState(a);
|
|
3106
|
+
}, z.useSyncExternalStore = function(a, m, k) {
|
|
3107
|
+
return G.H.useSyncExternalStore(
|
|
3108
|
+
a,
|
|
3109
|
+
m,
|
|
3110
|
+
k
|
|
3111
|
+
);
|
|
3112
|
+
}, z.useTransition = function() {
|
|
3113
|
+
return G.H.useTransition();
|
|
3114
|
+
}, z.version = "19.1.1", z;
|
|
3115
|
+
}
|
|
3116
|
+
var De = { exports: {} };
|
|
3117
|
+
/**
|
|
3118
|
+
* @license React
|
|
3119
|
+
* react.development.js
|
|
3120
|
+
*
|
|
3121
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3122
|
+
*
|
|
3123
|
+
* This source code is licensed under the MIT license found in the
|
|
3124
|
+
* LICENSE file in the root directory of this source tree.
|
|
3125
|
+
*/
|
|
3126
|
+
De.exports;
|
|
3127
|
+
var mn;
|
|
3128
|
+
function ao() {
|
|
3129
|
+
return mn || (mn = 1, function(t, e) {
|
|
3130
|
+
process.env.NODE_ENV !== "production" && function() {
|
|
3131
|
+
function n(o, v) {
|
|
3132
|
+
Object.defineProperty(u.prototype, o, {
|
|
3133
|
+
get: function() {
|
|
3134
|
+
console.warn(
|
|
3135
|
+
"%s(...) is deprecated in plain JavaScript React classes. %s",
|
|
3136
|
+
v[0],
|
|
3137
|
+
v[1]
|
|
3138
|
+
);
|
|
3139
|
+
}
|
|
3140
|
+
});
|
|
3141
|
+
}
|
|
3142
|
+
function r(o) {
|
|
3143
|
+
return o === null || typeof o != "object" ? null : (o = Be && o[Be] || o["@@iterator"], typeof o == "function" ? o : null);
|
|
3144
|
+
}
|
|
3145
|
+
function i(o, v) {
|
|
3146
|
+
o = (o = o.constructor) && (o.displayName || o.name) || "ReactClass";
|
|
3147
|
+
var O = o + "." + v;
|
|
3148
|
+
Pt[O] || (console.error(
|
|
3149
|
+
"Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",
|
|
3150
|
+
v,
|
|
3151
|
+
o
|
|
3152
|
+
), Pt[O] = !0);
|
|
3153
|
+
}
|
|
3154
|
+
function u(o, v, O) {
|
|
3155
|
+
this.props = o, this.context = v, this.refs = pt, this.updater = O || Dt;
|
|
3156
|
+
}
|
|
3157
|
+
function l() {
|
|
3158
|
+
}
|
|
3159
|
+
function h(o, v, O) {
|
|
3160
|
+
this.props = o, this.context = v, this.refs = pt, this.updater = O || Dt;
|
|
3161
|
+
}
|
|
3162
|
+
function g(o) {
|
|
3163
|
+
return "" + o;
|
|
3164
|
+
}
|
|
3165
|
+
function p(o) {
|
|
3166
|
+
try {
|
|
3167
|
+
g(o);
|
|
3168
|
+
var v = !1;
|
|
3169
|
+
} catch {
|
|
3170
|
+
v = !0;
|
|
3171
|
+
}
|
|
3172
|
+
if (v) {
|
|
3173
|
+
v = console;
|
|
3174
|
+
var O = v.error, N = typeof Symbol == "function" && Symbol.toStringTag && o[Symbol.toStringTag] || o.constructor.name || "Object";
|
|
3175
|
+
return O.call(
|
|
3176
|
+
v,
|
|
3177
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
3178
|
+
N
|
|
3179
|
+
), g(o);
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
function y(o) {
|
|
3183
|
+
if (o == null) return null;
|
|
3184
|
+
if (typeof o == "function")
|
|
3185
|
+
return o.$$typeof === tr ? null : o.displayName || o.name || null;
|
|
3186
|
+
if (typeof o == "string") return o;
|
|
3187
|
+
switch (o) {
|
|
3188
|
+
case a:
|
|
3189
|
+
return "Fragment";
|
|
3190
|
+
case k:
|
|
3191
|
+
return "Profiler";
|
|
3192
|
+
case m:
|
|
3193
|
+
return "StrictMode";
|
|
3194
|
+
case F:
|
|
3195
|
+
return "Suspense";
|
|
3196
|
+
case ae:
|
|
3197
|
+
return "SuspenseList";
|
|
3198
|
+
case Oe:
|
|
3199
|
+
return "Activity";
|
|
3200
|
+
}
|
|
3201
|
+
if (typeof o == "object")
|
|
3202
|
+
switch (typeof o.tag == "number" && console.error(
|
|
3203
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
3204
|
+
), o.$$typeof) {
|
|
3205
|
+
case ie:
|
|
3206
|
+
return "Portal";
|
|
3207
|
+
case U:
|
|
3208
|
+
return (o.displayName || "Context") + ".Provider";
|
|
3209
|
+
case A:
|
|
3210
|
+
return (o._context.displayName || "Context") + ".Consumer";
|
|
3211
|
+
case Y:
|
|
3212
|
+
var v = o.render;
|
|
3213
|
+
return o = o.displayName, o || (o = v.displayName || v.name || "", o = o !== "" ? "ForwardRef(" + o + ")" : "ForwardRef"), o;
|
|
3214
|
+
case H:
|
|
3215
|
+
return v = o.displayName || null, v !== null ? v : y(o.type) || "Memo";
|
|
3216
|
+
case pe:
|
|
3217
|
+
v = o._payload, o = o._init;
|
|
3218
|
+
try {
|
|
3219
|
+
return y(o(v));
|
|
3220
|
+
} catch {
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
return null;
|
|
3224
|
+
}
|
|
3225
|
+
function S(o) {
|
|
3226
|
+
if (o === a) return "<>";
|
|
3227
|
+
if (typeof o == "object" && o !== null && o.$$typeof === pe)
|
|
3228
|
+
return "<...>";
|
|
3229
|
+
try {
|
|
3230
|
+
var v = y(o);
|
|
3231
|
+
return v ? "<" + v + ">" : "<...>";
|
|
3232
|
+
} catch {
|
|
3233
|
+
return "<...>";
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
function I() {
|
|
3237
|
+
var o = ee.A;
|
|
3238
|
+
return o === null ? null : o.getOwner();
|
|
3239
|
+
}
|
|
3240
|
+
function T() {
|
|
3241
|
+
return Error("react-stack-top-frame");
|
|
3242
|
+
}
|
|
3243
|
+
function C(o) {
|
|
3244
|
+
if (qe.call(o, "key")) {
|
|
3245
|
+
var v = Object.getOwnPropertyDescriptor(o, "key").get;
|
|
3246
|
+
if (v && v.isReactWarning) return !1;
|
|
3247
|
+
}
|
|
3248
|
+
return o.key !== void 0;
|
|
3249
|
+
}
|
|
3250
|
+
function D(o, v) {
|
|
3251
|
+
function O() {
|
|
3252
|
+
Vt || (Vt = !0, console.error(
|
|
3253
|
+
"%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)",
|
|
3254
|
+
v
|
|
3255
|
+
));
|
|
3256
|
+
}
|
|
3257
|
+
O.isReactWarning = !0, Object.defineProperty(o, "key", {
|
|
3258
|
+
get: O,
|
|
3259
|
+
configurable: !0
|
|
3260
|
+
});
|
|
3261
|
+
}
|
|
3262
|
+
function b() {
|
|
3263
|
+
var o = y(this.type);
|
|
3264
|
+
return Ft[o] || (Ft[o] = !0, console.error(
|
|
3265
|
+
"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."
|
|
3266
|
+
)), o = this.props.ref, o !== void 0 ? o : null;
|
|
3267
|
+
}
|
|
3268
|
+
function j(o, v, O, N, W, te, J, re) {
|
|
3269
|
+
return O = te.ref, o = {
|
|
3270
|
+
$$typeof: oe,
|
|
3271
|
+
type: o,
|
|
3272
|
+
key: v,
|
|
3273
|
+
props: te,
|
|
3274
|
+
_owner: W
|
|
3275
|
+
}, (O !== void 0 ? O : null) !== null ? Object.defineProperty(o, "ref", {
|
|
3276
|
+
enumerable: !1,
|
|
3277
|
+
get: b
|
|
3278
|
+
}) : Object.defineProperty(o, "ref", { enumerable: !1, value: null }), o._store = {}, Object.defineProperty(o._store, "validated", {
|
|
3279
|
+
configurable: !1,
|
|
3280
|
+
enumerable: !1,
|
|
3281
|
+
writable: !0,
|
|
3282
|
+
value: 0
|
|
3283
|
+
}), Object.defineProperty(o, "_debugInfo", {
|
|
3284
|
+
configurable: !1,
|
|
3285
|
+
enumerable: !1,
|
|
3286
|
+
writable: !0,
|
|
3287
|
+
value: null
|
|
3288
|
+
}), Object.defineProperty(o, "_debugStack", {
|
|
3289
|
+
configurable: !1,
|
|
3290
|
+
enumerable: !1,
|
|
3291
|
+
writable: !0,
|
|
3292
|
+
value: J
|
|
3293
|
+
}), Object.defineProperty(o, "_debugTask", {
|
|
3294
|
+
configurable: !1,
|
|
3295
|
+
enumerable: !1,
|
|
3296
|
+
writable: !0,
|
|
3297
|
+
value: re
|
|
3298
|
+
}), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
|
|
3299
|
+
}
|
|
3300
|
+
function $(o, v) {
|
|
3301
|
+
return v = j(
|
|
3302
|
+
o.type,
|
|
3303
|
+
v,
|
|
3304
|
+
void 0,
|
|
3305
|
+
void 0,
|
|
3306
|
+
o._owner,
|
|
3307
|
+
o.props,
|
|
3308
|
+
o._debugStack,
|
|
3309
|
+
o._debugTask
|
|
3310
|
+
), o._store && (v._store.validated = o._store.validated), v;
|
|
3311
|
+
}
|
|
3312
|
+
function M(o) {
|
|
3313
|
+
return typeof o == "object" && o !== null && o.$$typeof === oe;
|
|
3314
|
+
}
|
|
3315
|
+
function K(o) {
|
|
3316
|
+
var v = { "=": "=0", ":": "=2" };
|
|
3317
|
+
return "$" + o.replace(/[=:]/g, function(O) {
|
|
3318
|
+
return v[O];
|
|
3319
|
+
});
|
|
3320
|
+
}
|
|
3321
|
+
function G(o, v) {
|
|
3322
|
+
return typeof o == "object" && o !== null && o.key != null ? (p(o.key), K("" + o.key)) : v.toString(36);
|
|
3323
|
+
}
|
|
3324
|
+
function ce() {
|
|
3325
|
+
}
|
|
3326
|
+
function R(o) {
|
|
3327
|
+
switch (o.status) {
|
|
3328
|
+
case "fulfilled":
|
|
3329
|
+
return o.value;
|
|
3330
|
+
case "rejected":
|
|
3331
|
+
throw o.reason;
|
|
3332
|
+
default:
|
|
3333
|
+
switch (typeof o.status == "string" ? o.then(ce, ce) : (o.status = "pending", o.then(
|
|
3334
|
+
function(v) {
|
|
3335
|
+
o.status === "pending" && (o.status = "fulfilled", o.value = v);
|
|
3336
|
+
},
|
|
3337
|
+
function(v) {
|
|
3338
|
+
o.status === "pending" && (o.status = "rejected", o.reason = v);
|
|
3339
|
+
}
|
|
3340
|
+
)), o.status) {
|
|
3341
|
+
case "fulfilled":
|
|
3342
|
+
return o.value;
|
|
3343
|
+
case "rejected":
|
|
3344
|
+
throw o.reason;
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
throw o;
|
|
3348
|
+
}
|
|
3349
|
+
function x(o, v, O, N, W) {
|
|
3350
|
+
var te = typeof o;
|
|
3351
|
+
(te === "undefined" || te === "boolean") && (o = null);
|
|
3352
|
+
var J = !1;
|
|
3353
|
+
if (o === null) J = !0;
|
|
3354
|
+
else
|
|
3355
|
+
switch (te) {
|
|
3356
|
+
case "bigint":
|
|
3357
|
+
case "string":
|
|
3358
|
+
case "number":
|
|
3359
|
+
J = !0;
|
|
3360
|
+
break;
|
|
3361
|
+
case "object":
|
|
3362
|
+
switch (o.$$typeof) {
|
|
3363
|
+
case oe:
|
|
3364
|
+
case ie:
|
|
3365
|
+
J = !0;
|
|
3366
|
+
break;
|
|
3367
|
+
case pe:
|
|
3368
|
+
return J = o._init, x(
|
|
3369
|
+
J(o._payload),
|
|
3370
|
+
v,
|
|
3371
|
+
O,
|
|
3372
|
+
N,
|
|
3373
|
+
W
|
|
3374
|
+
);
|
|
3375
|
+
}
|
|
3376
|
+
}
|
|
3377
|
+
if (J) {
|
|
3378
|
+
J = o, W = W(J);
|
|
3379
|
+
var re = N === "" ? "." + G(J, 0) : N;
|
|
3380
|
+
return Ut(W) ? (O = "", re != null && (O = re.replace(Bt, "$&/") + "/"), x(W, v, O, "", function(be) {
|
|
3381
|
+
return be;
|
|
3382
|
+
})) : W != null && (M(W) && (W.key != null && (J && J.key === W.key || p(W.key)), O = $(
|
|
3383
|
+
W,
|
|
3384
|
+
O + (W.key == null || J && J.key === W.key ? "" : ("" + W.key).replace(
|
|
3385
|
+
Bt,
|
|
3386
|
+
"$&/"
|
|
3387
|
+
) + "/") + re
|
|
3388
|
+
), N !== "" && J != null && M(J) && J.key == null && J._store && !J._store.validated && (O._store.validated = 2), W = O), v.push(W)), 1;
|
|
3389
|
+
}
|
|
3390
|
+
if (J = 0, re = N === "" ? "." : N + ":", Ut(o))
|
|
3391
|
+
for (var Z = 0; Z < o.length; Z++)
|
|
3392
|
+
N = o[Z], te = re + G(N, Z), J += x(
|
|
3393
|
+
N,
|
|
3394
|
+
v,
|
|
3395
|
+
O,
|
|
3396
|
+
te,
|
|
3397
|
+
W
|
|
3398
|
+
);
|
|
3399
|
+
else if (Z = r(o), typeof Z == "function")
|
|
3400
|
+
for (Z === o.entries && (Wt || console.warn(
|
|
3401
|
+
"Using Maps as children is not supported. Use an array of keyed ReactElements instead."
|
|
3402
|
+
), Wt = !0), o = Z.call(o), Z = 0; !(N = o.next()).done; )
|
|
3403
|
+
N = N.value, te = re + G(N, Z++), J += x(
|
|
3404
|
+
N,
|
|
3405
|
+
v,
|
|
3406
|
+
O,
|
|
3407
|
+
te,
|
|
3408
|
+
W
|
|
3409
|
+
);
|
|
3410
|
+
else if (te === "object") {
|
|
3411
|
+
if (typeof o.then == "function")
|
|
3412
|
+
return x(
|
|
3413
|
+
R(o),
|
|
3414
|
+
v,
|
|
3415
|
+
O,
|
|
3416
|
+
N,
|
|
3417
|
+
W
|
|
3418
|
+
);
|
|
3419
|
+
throw v = String(o), Error(
|
|
3420
|
+
"Objects are not valid as a React child (found: " + (v === "[object Object]" ? "object with keys {" + Object.keys(o).join(", ") + "}" : v) + "). If you meant to render a collection of children, use an array instead."
|
|
3421
|
+
);
|
|
3422
|
+
}
|
|
3423
|
+
return J;
|
|
3424
|
+
}
|
|
3425
|
+
function s(o, v, O) {
|
|
3426
|
+
if (o == null) return o;
|
|
3427
|
+
var N = [], W = 0;
|
|
3428
|
+
return x(o, N, "", "", function(te) {
|
|
3429
|
+
return v.call(O, te, W++);
|
|
3430
|
+
}), N;
|
|
3431
|
+
}
|
|
3432
|
+
function c(o) {
|
|
3433
|
+
if (o._status === -1) {
|
|
3434
|
+
var v = o._result;
|
|
3435
|
+
v = v(), v.then(
|
|
3436
|
+
function(O) {
|
|
3437
|
+
(o._status === 0 || o._status === -1) && (o._status = 1, o._result = O);
|
|
3438
|
+
},
|
|
3439
|
+
function(O) {
|
|
3440
|
+
(o._status === 0 || o._status === -1) && (o._status = 2, o._result = O);
|
|
3441
|
+
}
|
|
3442
|
+
), o._status === -1 && (o._status = 0, o._result = v);
|
|
3443
|
+
}
|
|
3444
|
+
if (o._status === 1)
|
|
3445
|
+
return v = o._result, v === void 0 && console.error(
|
|
3446
|
+
`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
3447
|
+
|
|
3448
|
+
Your code should look like:
|
|
3449
|
+
const MyComponent = lazy(() => import('./MyComponent'))
|
|
3450
|
+
|
|
3451
|
+
Did you accidentally put curly braces around the import?`,
|
|
3452
|
+
v
|
|
3453
|
+
), "default" in v || console.error(
|
|
3454
|
+
`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
3455
|
+
|
|
3456
|
+
Your code should look like:
|
|
3457
|
+
const MyComponent = lazy(() => import('./MyComponent'))`,
|
|
3458
|
+
v
|
|
3459
|
+
), v.default;
|
|
3460
|
+
throw o._result;
|
|
3461
|
+
}
|
|
3462
|
+
function d() {
|
|
3463
|
+
var o = ee.H;
|
|
3464
|
+
return o === null && console.error(
|
|
3465
|
+
`Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
|
|
3466
|
+
1. You might have mismatching versions of React and the renderer (such as React DOM)
|
|
3467
|
+
2. You might be breaking the Rules of Hooks
|
|
3468
|
+
3. You might have more than one copy of React in the same app
|
|
3469
|
+
See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`
|
|
3470
|
+
), o;
|
|
3471
|
+
}
|
|
3472
|
+
function f() {
|
|
3473
|
+
}
|
|
3474
|
+
function _(o) {
|
|
3475
|
+
if (He === null)
|
|
3476
|
+
try {
|
|
3477
|
+
var v = ("require" + Math.random()).slice(0, 7);
|
|
3478
|
+
He = (t && t[v]).call(
|
|
3479
|
+
t,
|
|
3480
|
+
"timers"
|
|
3481
|
+
).setImmediate;
|
|
3482
|
+
} catch {
|
|
3483
|
+
He = function(N) {
|
|
3484
|
+
qt === !1 && (qt = !0, typeof MessageChannel > "u" && console.error(
|
|
3485
|
+
"This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."
|
|
3486
|
+
));
|
|
3487
|
+
var W = new MessageChannel();
|
|
3488
|
+
W.port1.onmessage = N, W.port2.postMessage(void 0);
|
|
3489
|
+
};
|
|
3490
|
+
}
|
|
3491
|
+
return He(o);
|
|
3492
|
+
}
|
|
3493
|
+
function E(o) {
|
|
3494
|
+
return 1 < o.length && typeof AggregateError == "function" ? new AggregateError(o) : o[0];
|
|
3495
|
+
}
|
|
3496
|
+
function w(o, v) {
|
|
3497
|
+
v !== ze - 1 && console.error(
|
|
3498
|
+
"You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
|
|
3499
|
+
), ze = v;
|
|
3500
|
+
}
|
|
3501
|
+
function L(o, v, O) {
|
|
3502
|
+
var N = ee.actQueue;
|
|
3503
|
+
if (N !== null)
|
|
3504
|
+
if (N.length !== 0)
|
|
3505
|
+
try {
|
|
3506
|
+
P(N), _(function() {
|
|
3507
|
+
return L(o, v, O);
|
|
3508
|
+
});
|
|
3509
|
+
return;
|
|
3510
|
+
} catch (W) {
|
|
3511
|
+
ee.thrownErrors.push(W);
|
|
3512
|
+
}
|
|
3513
|
+
else ee.actQueue = null;
|
|
3514
|
+
0 < ee.thrownErrors.length ? (N = E(ee.thrownErrors), ee.thrownErrors.length = 0, O(N)) : v(o);
|
|
3515
|
+
}
|
|
3516
|
+
function P(o) {
|
|
3517
|
+
if (!gt) {
|
|
3518
|
+
gt = !0;
|
|
3519
|
+
var v = 0;
|
|
3520
|
+
try {
|
|
3521
|
+
for (; v < o.length; v++) {
|
|
3522
|
+
var O = o[v];
|
|
3523
|
+
do {
|
|
3524
|
+
ee.didUsePromise = !1;
|
|
3525
|
+
var N = O(!1);
|
|
3526
|
+
if (N !== null) {
|
|
3527
|
+
if (ee.didUsePromise) {
|
|
3528
|
+
o[v] = O, o.splice(0, v);
|
|
3529
|
+
return;
|
|
3530
|
+
}
|
|
3531
|
+
O = N;
|
|
3532
|
+
} else break;
|
|
3533
|
+
} while (!0);
|
|
3534
|
+
}
|
|
3535
|
+
o.length = 0;
|
|
3536
|
+
} catch (W) {
|
|
3537
|
+
o.splice(0, v + 1), ee.thrownErrors.push(W);
|
|
3538
|
+
} finally {
|
|
3539
|
+
gt = !1;
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
}
|
|
3543
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
3544
|
+
var oe = Symbol.for("react.transitional.element"), ie = Symbol.for("react.portal"), a = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), k = Symbol.for("react.profiler"), A = Symbol.for("react.consumer"), U = Symbol.for("react.context"), Y = Symbol.for("react.forward_ref"), F = Symbol.for("react.suspense"), ae = Symbol.for("react.suspense_list"), H = Symbol.for("react.memo"), pe = Symbol.for("react.lazy"), Oe = Symbol.for("react.activity"), Be = Symbol.iterator, Pt = {}, Dt = {
|
|
3545
|
+
isMounted: function() {
|
|
3546
|
+
return !1;
|
|
3547
|
+
},
|
|
3548
|
+
enqueueForceUpdate: function(o) {
|
|
3549
|
+
i(o, "forceUpdate");
|
|
3550
|
+
},
|
|
3551
|
+
enqueueReplaceState: function(o) {
|
|
3552
|
+
i(o, "replaceState");
|
|
3553
|
+
},
|
|
3554
|
+
enqueueSetState: function(o) {
|
|
3555
|
+
i(o, "setState");
|
|
3556
|
+
}
|
|
3557
|
+
}, jt = Object.assign, pt = {};
|
|
3558
|
+
Object.freeze(pt), u.prototype.isReactComponent = {}, u.prototype.setState = function(o, v) {
|
|
3559
|
+
if (typeof o != "object" && typeof o != "function" && o != null)
|
|
3560
|
+
throw Error(
|
|
3561
|
+
"takes an object of state variables to update or a function which returns an object of state variables."
|
|
3562
|
+
);
|
|
3563
|
+
this.updater.enqueueSetState(this, o, v, "setState");
|
|
3564
|
+
}, u.prototype.forceUpdate = function(o) {
|
|
3565
|
+
this.updater.enqueueForceUpdate(this, o, "forceUpdate");
|
|
3566
|
+
};
|
|
3567
|
+
var ve = {
|
|
3568
|
+
isMounted: [
|
|
3569
|
+
"isMounted",
|
|
3570
|
+
"Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
|
|
3571
|
+
],
|
|
3572
|
+
replaceState: [
|
|
3573
|
+
"replaceState",
|
|
3574
|
+
"Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
|
|
3575
|
+
]
|
|
3576
|
+
}, Ye;
|
|
3577
|
+
for (Ye in ve)
|
|
3578
|
+
ve.hasOwnProperty(Ye) && n(Ye, ve[Ye]);
|
|
3579
|
+
l.prototype = u.prototype, ve = h.prototype = new l(), ve.constructor = h, jt(ve, u.prototype), ve.isPureReactComponent = !0;
|
|
3580
|
+
var Ut = Array.isArray, tr = Symbol.for("react.client.reference"), ee = {
|
|
3581
|
+
H: null,
|
|
3582
|
+
A: null,
|
|
3583
|
+
T: null,
|
|
3584
|
+
S: null,
|
|
3585
|
+
V: null,
|
|
3586
|
+
actQueue: null,
|
|
3587
|
+
isBatchingLegacy: !1,
|
|
3588
|
+
didScheduleLegacyUpdate: !1,
|
|
3589
|
+
didUsePromise: !1,
|
|
3590
|
+
thrownErrors: [],
|
|
3591
|
+
getCurrentStack: null,
|
|
3592
|
+
recentlyCreatedOwnerStacks: 0
|
|
3593
|
+
}, qe = Object.prototype.hasOwnProperty, $t = console.createTask ? console.createTask : function() {
|
|
3594
|
+
return null;
|
|
3595
|
+
};
|
|
3596
|
+
ve = {
|
|
3597
|
+
react_stack_bottom_frame: function(o) {
|
|
3598
|
+
return o();
|
|
3599
|
+
}
|
|
3600
|
+
};
|
|
3601
|
+
var Vt, Gt, Ft = {}, nr = ve.react_stack_bottom_frame.bind(
|
|
3602
|
+
ve,
|
|
3603
|
+
T
|
|
3604
|
+
)(), rr = $t(S(T)), Wt = !1, Bt = /\/+/g, Yt = typeof reportError == "function" ? reportError : function(o) {
|
|
3605
|
+
if (typeof window == "object" && typeof window.ErrorEvent == "function") {
|
|
3606
|
+
var v = new window.ErrorEvent("error", {
|
|
3607
|
+
bubbles: !0,
|
|
3608
|
+
cancelable: !0,
|
|
3609
|
+
message: typeof o == "object" && o !== null && typeof o.message == "string" ? String(o.message) : String(o),
|
|
3610
|
+
error: o
|
|
3611
|
+
});
|
|
3612
|
+
if (!window.dispatchEvent(v)) return;
|
|
3613
|
+
} else if (typeof process == "object" && typeof process.emit == "function") {
|
|
3614
|
+
process.emit("uncaughtException", o);
|
|
3615
|
+
return;
|
|
3616
|
+
}
|
|
3617
|
+
console.error(o);
|
|
3618
|
+
}, qt = !1, He = null, ze = 0, Ke = !1, gt = !1, Ht = typeof queueMicrotask == "function" ? function(o) {
|
|
3619
|
+
queueMicrotask(function() {
|
|
3620
|
+
return queueMicrotask(o);
|
|
3621
|
+
});
|
|
3622
|
+
} : _;
|
|
3623
|
+
ve = Object.freeze({
|
|
3624
|
+
__proto__: null,
|
|
3625
|
+
c: function(o) {
|
|
3626
|
+
return d().useMemoCache(o);
|
|
3627
|
+
}
|
|
3628
|
+
}), e.Children = {
|
|
3629
|
+
map: s,
|
|
3630
|
+
forEach: function(o, v, O) {
|
|
3631
|
+
s(
|
|
3632
|
+
o,
|
|
3633
|
+
function() {
|
|
3634
|
+
v.apply(this, arguments);
|
|
3635
|
+
},
|
|
3636
|
+
O
|
|
3637
|
+
);
|
|
3638
|
+
},
|
|
3639
|
+
count: function(o) {
|
|
3640
|
+
var v = 0;
|
|
3641
|
+
return s(o, function() {
|
|
3642
|
+
v++;
|
|
3643
|
+
}), v;
|
|
3644
|
+
},
|
|
3645
|
+
toArray: function(o) {
|
|
3646
|
+
return s(o, function(v) {
|
|
3647
|
+
return v;
|
|
3648
|
+
}) || [];
|
|
3649
|
+
},
|
|
3650
|
+
only: function(o) {
|
|
3651
|
+
if (!M(o))
|
|
3652
|
+
throw Error(
|
|
3653
|
+
"React.Children.only expected to receive a single React element child."
|
|
3654
|
+
);
|
|
3655
|
+
return o;
|
|
3656
|
+
}
|
|
3657
|
+
}, e.Component = u, e.Fragment = a, e.Profiler = k, e.PureComponent = h, e.StrictMode = m, e.Suspense = F, e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ee, e.__COMPILER_RUNTIME = ve, e.act = function(o) {
|
|
3658
|
+
var v = ee.actQueue, O = ze;
|
|
3659
|
+
ze++;
|
|
3660
|
+
var N = ee.actQueue = v !== null ? v : [], W = !1;
|
|
3661
|
+
try {
|
|
3662
|
+
var te = o();
|
|
3663
|
+
} catch (Z) {
|
|
3664
|
+
ee.thrownErrors.push(Z);
|
|
3665
|
+
}
|
|
3666
|
+
if (0 < ee.thrownErrors.length)
|
|
3667
|
+
throw w(v, O), o = E(ee.thrownErrors), ee.thrownErrors.length = 0, o;
|
|
3668
|
+
if (te !== null && typeof te == "object" && typeof te.then == "function") {
|
|
3669
|
+
var J = te;
|
|
3670
|
+
return Ht(function() {
|
|
3671
|
+
W || Ke || (Ke = !0, console.error(
|
|
3672
|
+
"You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"
|
|
3673
|
+
));
|
|
3674
|
+
}), {
|
|
3675
|
+
then: function(Z, be) {
|
|
3676
|
+
W = !0, J.then(
|
|
3677
|
+
function(Ee) {
|
|
3678
|
+
if (w(v, O), O === 0) {
|
|
3679
|
+
try {
|
|
3680
|
+
P(N), _(function() {
|
|
3681
|
+
return L(
|
|
3682
|
+
Ee,
|
|
3683
|
+
Z,
|
|
3684
|
+
be
|
|
3685
|
+
);
|
|
3686
|
+
});
|
|
3687
|
+
} catch (ir) {
|
|
3688
|
+
ee.thrownErrors.push(ir);
|
|
3689
|
+
}
|
|
3690
|
+
if (0 < ee.thrownErrors.length) {
|
|
3691
|
+
var or = E(
|
|
3692
|
+
ee.thrownErrors
|
|
3693
|
+
);
|
|
3694
|
+
ee.thrownErrors.length = 0, be(or);
|
|
3695
|
+
}
|
|
3696
|
+
} else Z(Ee);
|
|
3697
|
+
},
|
|
3698
|
+
function(Ee) {
|
|
3699
|
+
w(v, O), 0 < ee.thrownErrors.length && (Ee = E(
|
|
3700
|
+
ee.thrownErrors
|
|
3701
|
+
), ee.thrownErrors.length = 0), be(Ee);
|
|
3702
|
+
}
|
|
3703
|
+
);
|
|
3704
|
+
}
|
|
3705
|
+
};
|
|
3706
|
+
}
|
|
3707
|
+
var re = te;
|
|
3708
|
+
if (w(v, O), O === 0 && (P(N), N.length !== 0 && Ht(function() {
|
|
3709
|
+
W || Ke || (Ke = !0, console.error(
|
|
3710
|
+
"A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"
|
|
3711
|
+
));
|
|
3712
|
+
}), ee.actQueue = null), 0 < ee.thrownErrors.length)
|
|
3713
|
+
throw o = E(ee.thrownErrors), ee.thrownErrors.length = 0, o;
|
|
3714
|
+
return {
|
|
3715
|
+
then: function(Z, be) {
|
|
3716
|
+
W = !0, O === 0 ? (ee.actQueue = N, _(function() {
|
|
3717
|
+
return L(
|
|
3718
|
+
re,
|
|
3719
|
+
Z,
|
|
3720
|
+
be
|
|
3721
|
+
);
|
|
3722
|
+
})) : Z(re);
|
|
3723
|
+
}
|
|
3724
|
+
};
|
|
3725
|
+
}, e.cache = function(o) {
|
|
3726
|
+
return function() {
|
|
3727
|
+
return o.apply(null, arguments);
|
|
3728
|
+
};
|
|
3729
|
+
}, e.captureOwnerStack = function() {
|
|
3730
|
+
var o = ee.getCurrentStack;
|
|
3731
|
+
return o === null ? null : o();
|
|
3732
|
+
}, e.cloneElement = function(o, v, O) {
|
|
3733
|
+
if (o == null)
|
|
3734
|
+
throw Error(
|
|
3735
|
+
"The argument must be a React element, but you passed " + o + "."
|
|
3736
|
+
);
|
|
3737
|
+
var N = jt({}, o.props), W = o.key, te = o._owner;
|
|
3738
|
+
if (v != null) {
|
|
3739
|
+
var J;
|
|
3740
|
+
e: {
|
|
3741
|
+
if (qe.call(v, "ref") && (J = Object.getOwnPropertyDescriptor(
|
|
3742
|
+
v,
|
|
3743
|
+
"ref"
|
|
3744
|
+
).get) && J.isReactWarning) {
|
|
3745
|
+
J = !1;
|
|
3746
|
+
break e;
|
|
3747
|
+
}
|
|
3748
|
+
J = v.ref !== void 0;
|
|
3749
|
+
}
|
|
3750
|
+
J && (te = I()), C(v) && (p(v.key), W = "" + v.key);
|
|
3751
|
+
for (re in v)
|
|
3752
|
+
!qe.call(v, re) || re === "key" || re === "__self" || re === "__source" || re === "ref" && v.ref === void 0 || (N[re] = v[re]);
|
|
3753
|
+
}
|
|
3754
|
+
var re = arguments.length - 2;
|
|
3755
|
+
if (re === 1) N.children = O;
|
|
3756
|
+
else if (1 < re) {
|
|
3757
|
+
J = Array(re);
|
|
3758
|
+
for (var Z = 0; Z < re; Z++)
|
|
3759
|
+
J[Z] = arguments[Z + 2];
|
|
3760
|
+
N.children = J;
|
|
3761
|
+
}
|
|
3762
|
+
for (N = j(
|
|
3763
|
+
o.type,
|
|
3764
|
+
W,
|
|
3765
|
+
void 0,
|
|
3766
|
+
void 0,
|
|
3767
|
+
te,
|
|
3768
|
+
N,
|
|
3769
|
+
o._debugStack,
|
|
3770
|
+
o._debugTask
|
|
3771
|
+
), W = 2; W < arguments.length; W++)
|
|
3772
|
+
te = arguments[W], M(te) && te._store && (te._store.validated = 1);
|
|
3773
|
+
return N;
|
|
3774
|
+
}, e.createContext = function(o) {
|
|
3775
|
+
return o = {
|
|
3776
|
+
$$typeof: U,
|
|
3777
|
+
_currentValue: o,
|
|
3778
|
+
_currentValue2: o,
|
|
3779
|
+
_threadCount: 0,
|
|
3780
|
+
Provider: null,
|
|
3781
|
+
Consumer: null
|
|
3782
|
+
}, o.Provider = o, o.Consumer = {
|
|
3783
|
+
$$typeof: A,
|
|
3784
|
+
_context: o
|
|
3785
|
+
}, o._currentRenderer = null, o._currentRenderer2 = null, o;
|
|
3786
|
+
}, e.createElement = function(o, v, O) {
|
|
3787
|
+
for (var N = 2; N < arguments.length; N++) {
|
|
3788
|
+
var W = arguments[N];
|
|
3789
|
+
M(W) && W._store && (W._store.validated = 1);
|
|
3790
|
+
}
|
|
3791
|
+
if (N = {}, W = null, v != null)
|
|
3792
|
+
for (Z in Gt || !("__self" in v) || "key" in v || (Gt = !0, console.warn(
|
|
3793
|
+
"Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform"
|
|
3794
|
+
)), C(v) && (p(v.key), W = "" + v.key), v)
|
|
3795
|
+
qe.call(v, Z) && Z !== "key" && Z !== "__self" && Z !== "__source" && (N[Z] = v[Z]);
|
|
3796
|
+
var te = arguments.length - 2;
|
|
3797
|
+
if (te === 1) N.children = O;
|
|
3798
|
+
else if (1 < te) {
|
|
3799
|
+
for (var J = Array(te), re = 0; re < te; re++)
|
|
3800
|
+
J[re] = arguments[re + 2];
|
|
3801
|
+
Object.freeze && Object.freeze(J), N.children = J;
|
|
3802
|
+
}
|
|
3803
|
+
if (o && o.defaultProps)
|
|
3804
|
+
for (Z in te = o.defaultProps, te)
|
|
3805
|
+
N[Z] === void 0 && (N[Z] = te[Z]);
|
|
3806
|
+
W && D(
|
|
3807
|
+
N,
|
|
3808
|
+
typeof o == "function" ? o.displayName || o.name || "Unknown" : o
|
|
3809
|
+
);
|
|
3810
|
+
var Z = 1e4 > ee.recentlyCreatedOwnerStacks++;
|
|
3811
|
+
return j(
|
|
3812
|
+
o,
|
|
3813
|
+
W,
|
|
3814
|
+
void 0,
|
|
3815
|
+
void 0,
|
|
3816
|
+
I(),
|
|
3817
|
+
N,
|
|
3818
|
+
Z ? Error("react-stack-top-frame") : nr,
|
|
3819
|
+
Z ? $t(S(o)) : rr
|
|
3820
|
+
);
|
|
3821
|
+
}, e.createRef = function() {
|
|
3822
|
+
var o = { current: null };
|
|
3823
|
+
return Object.seal(o), o;
|
|
3824
|
+
}, e.forwardRef = function(o) {
|
|
3825
|
+
o != null && o.$$typeof === H ? console.error(
|
|
3826
|
+
"forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."
|
|
3827
|
+
) : typeof o != "function" ? console.error(
|
|
3828
|
+
"forwardRef requires a render function but was given %s.",
|
|
3829
|
+
o === null ? "null" : typeof o
|
|
3830
|
+
) : o.length !== 0 && o.length !== 2 && console.error(
|
|
3831
|
+
"forwardRef render functions accept exactly two parameters: props and ref. %s",
|
|
3832
|
+
o.length === 1 ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined."
|
|
3833
|
+
), o != null && o.defaultProps != null && console.error(
|
|
3834
|
+
"forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?"
|
|
3835
|
+
);
|
|
3836
|
+
var v = { $$typeof: Y, render: o }, O;
|
|
3837
|
+
return Object.defineProperty(v, "displayName", {
|
|
3838
|
+
enumerable: !1,
|
|
3839
|
+
configurable: !0,
|
|
3840
|
+
get: function() {
|
|
3841
|
+
return O;
|
|
3842
|
+
},
|
|
3843
|
+
set: function(N) {
|
|
3844
|
+
O = N, o.name || o.displayName || (Object.defineProperty(o, "name", { value: N }), o.displayName = N);
|
|
3845
|
+
}
|
|
3846
|
+
}), v;
|
|
3847
|
+
}, e.isValidElement = M, e.lazy = function(o) {
|
|
3848
|
+
return {
|
|
3849
|
+
$$typeof: pe,
|
|
3850
|
+
_payload: { _status: -1, _result: o },
|
|
3851
|
+
_init: c
|
|
3852
|
+
};
|
|
3853
|
+
}, e.memo = function(o, v) {
|
|
3854
|
+
o == null && console.error(
|
|
3855
|
+
"memo: The first argument must be a component. Instead received: %s",
|
|
3856
|
+
o === null ? "null" : typeof o
|
|
3857
|
+
), v = {
|
|
3858
|
+
$$typeof: H,
|
|
3859
|
+
type: o,
|
|
3860
|
+
compare: v === void 0 ? null : v
|
|
3861
|
+
};
|
|
3862
|
+
var O;
|
|
3863
|
+
return Object.defineProperty(v, "displayName", {
|
|
3864
|
+
enumerable: !1,
|
|
3865
|
+
configurable: !0,
|
|
3866
|
+
get: function() {
|
|
3867
|
+
return O;
|
|
3868
|
+
},
|
|
3869
|
+
set: function(N) {
|
|
3870
|
+
O = N, o.name || o.displayName || (Object.defineProperty(o, "name", { value: N }), o.displayName = N);
|
|
3871
|
+
}
|
|
3872
|
+
}), v;
|
|
3873
|
+
}, e.startTransition = function(o) {
|
|
3874
|
+
var v = ee.T, O = {};
|
|
3875
|
+
ee.T = O, O._updatedFibers = /* @__PURE__ */ new Set();
|
|
3876
|
+
try {
|
|
3877
|
+
var N = o(), W = ee.S;
|
|
3878
|
+
W !== null && W(O, N), typeof N == "object" && N !== null && typeof N.then == "function" && N.then(f, Yt);
|
|
3879
|
+
} catch (te) {
|
|
3880
|
+
Yt(te);
|
|
3881
|
+
} finally {
|
|
3882
|
+
v === null && O._updatedFibers && (o = O._updatedFibers.size, O._updatedFibers.clear(), 10 < o && console.warn(
|
|
3883
|
+
"Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."
|
|
3884
|
+
)), ee.T = v;
|
|
3885
|
+
}
|
|
3886
|
+
}, e.unstable_useCacheRefresh = function() {
|
|
3887
|
+
return d().useCacheRefresh();
|
|
3888
|
+
}, e.use = function(o) {
|
|
3889
|
+
return d().use(o);
|
|
3890
|
+
}, e.useActionState = function(o, v, O) {
|
|
3891
|
+
return d().useActionState(
|
|
3892
|
+
o,
|
|
3893
|
+
v,
|
|
3894
|
+
O
|
|
3895
|
+
);
|
|
3896
|
+
}, e.useCallback = function(o, v) {
|
|
3897
|
+
return d().useCallback(o, v);
|
|
3898
|
+
}, e.useContext = function(o) {
|
|
3899
|
+
var v = d();
|
|
3900
|
+
return o.$$typeof === A && console.error(
|
|
3901
|
+
"Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"
|
|
3902
|
+
), v.useContext(o);
|
|
3903
|
+
}, e.useDebugValue = function(o, v) {
|
|
3904
|
+
return d().useDebugValue(o, v);
|
|
3905
|
+
}, e.useDeferredValue = function(o, v) {
|
|
3906
|
+
return d().useDeferredValue(o, v);
|
|
3907
|
+
}, e.useEffect = function(o, v, O) {
|
|
3908
|
+
o == null && console.warn(
|
|
3909
|
+
"React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
3910
|
+
);
|
|
3911
|
+
var N = d();
|
|
3912
|
+
if (typeof O == "function")
|
|
3913
|
+
throw Error(
|
|
3914
|
+
"useEffect CRUD overload is not enabled in this build of React."
|
|
3915
|
+
);
|
|
3916
|
+
return N.useEffect(o, v);
|
|
3917
|
+
}, e.useId = function() {
|
|
3918
|
+
return d().useId();
|
|
3919
|
+
}, e.useImperativeHandle = function(o, v, O) {
|
|
3920
|
+
return d().useImperativeHandle(o, v, O);
|
|
3921
|
+
}, e.useInsertionEffect = function(o, v) {
|
|
3922
|
+
return o == null && console.warn(
|
|
3923
|
+
"React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
3924
|
+
), d().useInsertionEffect(o, v);
|
|
3925
|
+
}, e.useLayoutEffect = function(o, v) {
|
|
3926
|
+
return o == null && console.warn(
|
|
3927
|
+
"React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
3928
|
+
), d().useLayoutEffect(o, v);
|
|
3929
|
+
}, e.useMemo = function(o, v) {
|
|
3930
|
+
return d().useMemo(o, v);
|
|
3931
|
+
}, e.useOptimistic = function(o, v) {
|
|
3932
|
+
return d().useOptimistic(o, v);
|
|
3933
|
+
}, e.useReducer = function(o, v, O) {
|
|
3934
|
+
return d().useReducer(o, v, O);
|
|
3935
|
+
}, e.useRef = function(o) {
|
|
3936
|
+
return d().useRef(o);
|
|
3937
|
+
}, e.useState = function(o) {
|
|
3938
|
+
return d().useState(o);
|
|
3939
|
+
}, e.useSyncExternalStore = function(o, v, O) {
|
|
3940
|
+
return d().useSyncExternalStore(
|
|
3941
|
+
o,
|
|
3942
|
+
v,
|
|
3943
|
+
O
|
|
3944
|
+
);
|
|
3945
|
+
}, e.useTransition = function() {
|
|
3946
|
+
return d().useTransition();
|
|
3947
|
+
}, e.version = "19.1.1", typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
3948
|
+
}();
|
|
3949
|
+
}(De, De.exports)), De.exports;
|
|
3950
|
+
}
|
|
3951
|
+
var yn;
|
|
3952
|
+
function Bn() {
|
|
3953
|
+
return yn || (yn = 1, process.env.NODE_ENV === "production" ? et.exports = so() : et.exports = ao()), et.exports;
|
|
3954
|
+
}
|
|
3955
|
+
/**
|
|
3956
|
+
* @license React
|
|
3957
|
+
* react-jsx-runtime.development.js
|
|
3958
|
+
*
|
|
3959
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3960
|
+
*
|
|
3961
|
+
* This source code is licensed under the MIT license found in the
|
|
3962
|
+
* LICENSE file in the root directory of this source tree.
|
|
3963
|
+
*/
|
|
3964
|
+
var _n;
|
|
3965
|
+
function co() {
|
|
3966
|
+
return _n || (_n = 1, process.env.NODE_ENV !== "production" && function() {
|
|
3967
|
+
function t(a) {
|
|
3968
|
+
if (a == null) return null;
|
|
3969
|
+
if (typeof a == "function")
|
|
3970
|
+
return a.$$typeof === c ? null : a.displayName || a.name || null;
|
|
3971
|
+
if (typeof a == "string") return a;
|
|
3972
|
+
switch (a) {
|
|
3973
|
+
case D:
|
|
3974
|
+
return "Fragment";
|
|
3975
|
+
case j:
|
|
3976
|
+
return "Profiler";
|
|
3977
|
+
case b:
|
|
3978
|
+
return "StrictMode";
|
|
3979
|
+
case G:
|
|
3980
|
+
return "Suspense";
|
|
3981
|
+
case ce:
|
|
3982
|
+
return "SuspenseList";
|
|
3983
|
+
case s:
|
|
3984
|
+
return "Activity";
|
|
3985
|
+
}
|
|
3986
|
+
if (typeof a == "object")
|
|
3987
|
+
switch (typeof a.tag == "number" && console.error(
|
|
3988
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
3989
|
+
), a.$$typeof) {
|
|
3990
|
+
case C:
|
|
3991
|
+
return "Portal";
|
|
3992
|
+
case M:
|
|
3993
|
+
return (a.displayName || "Context") + ".Provider";
|
|
3994
|
+
case $:
|
|
3995
|
+
return (a._context.displayName || "Context") + ".Consumer";
|
|
3996
|
+
case K:
|
|
3997
|
+
var m = a.render;
|
|
3998
|
+
return a = a.displayName, a || (a = m.displayName || m.name || "", a = a !== "" ? "ForwardRef(" + a + ")" : "ForwardRef"), a;
|
|
3999
|
+
case R:
|
|
4000
|
+
return m = a.displayName || null, m !== null ? m : t(a.type) || "Memo";
|
|
4001
|
+
case x:
|
|
4002
|
+
m = a._payload, a = a._init;
|
|
4003
|
+
try {
|
|
4004
|
+
return t(a(m));
|
|
4005
|
+
} catch {
|
|
4006
|
+
}
|
|
4007
|
+
}
|
|
4008
|
+
return null;
|
|
4009
|
+
}
|
|
4010
|
+
function e(a) {
|
|
4011
|
+
return "" + a;
|
|
4012
|
+
}
|
|
4013
|
+
function n(a) {
|
|
4014
|
+
try {
|
|
4015
|
+
e(a);
|
|
4016
|
+
var m = !1;
|
|
4017
|
+
} catch {
|
|
4018
|
+
m = !0;
|
|
4019
|
+
}
|
|
4020
|
+
if (m) {
|
|
4021
|
+
m = console;
|
|
4022
|
+
var k = m.error, A = typeof Symbol == "function" && Symbol.toStringTag && a[Symbol.toStringTag] || a.constructor.name || "Object";
|
|
4023
|
+
return k.call(
|
|
4024
|
+
m,
|
|
4025
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
4026
|
+
A
|
|
4027
|
+
), e(a);
|
|
4028
|
+
}
|
|
4029
|
+
}
|
|
4030
|
+
function r(a) {
|
|
4031
|
+
if (a === D) return "<>";
|
|
4032
|
+
if (typeof a == "object" && a !== null && a.$$typeof === x)
|
|
4033
|
+
return "<...>";
|
|
4034
|
+
try {
|
|
4035
|
+
var m = t(a);
|
|
4036
|
+
return m ? "<" + m + ">" : "<...>";
|
|
4037
|
+
} catch {
|
|
4038
|
+
return "<...>";
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
function i() {
|
|
4042
|
+
var a = d.A;
|
|
4043
|
+
return a === null ? null : a.getOwner();
|
|
4044
|
+
}
|
|
4045
|
+
function u() {
|
|
4046
|
+
return Error("react-stack-top-frame");
|
|
4047
|
+
}
|
|
4048
|
+
function l(a) {
|
|
4049
|
+
if (f.call(a, "key")) {
|
|
4050
|
+
var m = Object.getOwnPropertyDescriptor(a, "key").get;
|
|
4051
|
+
if (m && m.isReactWarning) return !1;
|
|
4052
|
+
}
|
|
4053
|
+
return a.key !== void 0;
|
|
4054
|
+
}
|
|
4055
|
+
function h(a, m) {
|
|
4056
|
+
function k() {
|
|
4057
|
+
w || (w = !0, console.error(
|
|
4058
|
+
"%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)",
|
|
4059
|
+
m
|
|
4060
|
+
));
|
|
4061
|
+
}
|
|
4062
|
+
k.isReactWarning = !0, Object.defineProperty(a, "key", {
|
|
4063
|
+
get: k,
|
|
4064
|
+
configurable: !0
|
|
4065
|
+
});
|
|
4066
|
+
}
|
|
4067
|
+
function g() {
|
|
4068
|
+
var a = t(this.type);
|
|
4069
|
+
return L[a] || (L[a] = !0, console.error(
|
|
4070
|
+
"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."
|
|
4071
|
+
)), a = this.props.ref, a !== void 0 ? a : null;
|
|
4072
|
+
}
|
|
4073
|
+
function p(a, m, k, A, U, Y, F, ae) {
|
|
4074
|
+
return k = Y.ref, a = {
|
|
4075
|
+
$$typeof: T,
|
|
4076
|
+
type: a,
|
|
4077
|
+
key: m,
|
|
4078
|
+
props: Y,
|
|
4079
|
+
_owner: U
|
|
4080
|
+
}, (k !== void 0 ? k : null) !== null ? Object.defineProperty(a, "ref", {
|
|
4081
|
+
enumerable: !1,
|
|
4082
|
+
get: g
|
|
4083
|
+
}) : Object.defineProperty(a, "ref", { enumerable: !1, value: null }), a._store = {}, Object.defineProperty(a._store, "validated", {
|
|
4084
|
+
configurable: !1,
|
|
4085
|
+
enumerable: !1,
|
|
4086
|
+
writable: !0,
|
|
4087
|
+
value: 0
|
|
4088
|
+
}), Object.defineProperty(a, "_debugInfo", {
|
|
4089
|
+
configurable: !1,
|
|
4090
|
+
enumerable: !1,
|
|
4091
|
+
writable: !0,
|
|
4092
|
+
value: null
|
|
4093
|
+
}), Object.defineProperty(a, "_debugStack", {
|
|
4094
|
+
configurable: !1,
|
|
4095
|
+
enumerable: !1,
|
|
4096
|
+
writable: !0,
|
|
4097
|
+
value: F
|
|
4098
|
+
}), Object.defineProperty(a, "_debugTask", {
|
|
4099
|
+
configurable: !1,
|
|
4100
|
+
enumerable: !1,
|
|
4101
|
+
writable: !0,
|
|
4102
|
+
value: ae
|
|
4103
|
+
}), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
|
|
4104
|
+
}
|
|
4105
|
+
function y(a, m, k, A, U, Y, F, ae) {
|
|
4106
|
+
var H = m.children;
|
|
4107
|
+
if (H !== void 0)
|
|
4108
|
+
if (A)
|
|
4109
|
+
if (_(H)) {
|
|
4110
|
+
for (A = 0; A < H.length; A++)
|
|
4111
|
+
S(H[A]);
|
|
4112
|
+
Object.freeze && Object.freeze(H);
|
|
4113
|
+
} else
|
|
4114
|
+
console.error(
|
|
4115
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
4116
|
+
);
|
|
4117
|
+
else S(H);
|
|
4118
|
+
if (f.call(m, "key")) {
|
|
4119
|
+
H = t(a);
|
|
4120
|
+
var pe = Object.keys(m).filter(function(Be) {
|
|
4121
|
+
return Be !== "key";
|
|
4122
|
+
});
|
|
4123
|
+
A = 0 < pe.length ? "{key: someKey, " + pe.join(": ..., ") + ": ...}" : "{key: someKey}", ie[H + A] || (pe = 0 < pe.length ? "{" + pe.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
4124
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
4125
|
+
let props = %s;
|
|
4126
|
+
<%s {...props} />
|
|
4127
|
+
React keys must be passed directly to JSX without using spread:
|
|
4128
|
+
let props = %s;
|
|
4129
|
+
<%s key={someKey} {...props} />`,
|
|
4130
|
+
A,
|
|
4131
|
+
H,
|
|
4132
|
+
pe,
|
|
4133
|
+
H
|
|
4134
|
+
), ie[H + A] = !0);
|
|
4135
|
+
}
|
|
4136
|
+
if (H = null, k !== void 0 && (n(k), H = "" + k), l(m) && (n(m.key), H = "" + m.key), "key" in m) {
|
|
4137
|
+
k = {};
|
|
4138
|
+
for (var Oe in m)
|
|
4139
|
+
Oe !== "key" && (k[Oe] = m[Oe]);
|
|
4140
|
+
} else k = m;
|
|
4141
|
+
return H && h(
|
|
4142
|
+
k,
|
|
4143
|
+
typeof a == "function" ? a.displayName || a.name || "Unknown" : a
|
|
4144
|
+
), p(
|
|
4145
|
+
a,
|
|
4146
|
+
H,
|
|
4147
|
+
Y,
|
|
4148
|
+
U,
|
|
4149
|
+
i(),
|
|
4150
|
+
k,
|
|
4151
|
+
F,
|
|
4152
|
+
ae
|
|
4153
|
+
);
|
|
4154
|
+
}
|
|
4155
|
+
function S(a) {
|
|
4156
|
+
typeof a == "object" && a !== null && a.$$typeof === T && a._store && (a._store.validated = 1);
|
|
4157
|
+
}
|
|
4158
|
+
var I = Bn(), T = Symbol.for("react.transitional.element"), C = Symbol.for("react.portal"), D = Symbol.for("react.fragment"), b = Symbol.for("react.strict_mode"), j = Symbol.for("react.profiler"), $ = Symbol.for("react.consumer"), M = Symbol.for("react.context"), K = Symbol.for("react.forward_ref"), G = Symbol.for("react.suspense"), ce = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), x = Symbol.for("react.lazy"), s = Symbol.for("react.activity"), c = Symbol.for("react.client.reference"), d = I.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, f = Object.prototype.hasOwnProperty, _ = Array.isArray, E = console.createTask ? console.createTask : function() {
|
|
4159
|
+
return null;
|
|
4160
|
+
};
|
|
4161
|
+
I = {
|
|
4162
|
+
react_stack_bottom_frame: function(a) {
|
|
4163
|
+
return a();
|
|
4164
|
+
}
|
|
4165
|
+
};
|
|
4166
|
+
var w, L = {}, P = I.react_stack_bottom_frame.bind(
|
|
4167
|
+
I,
|
|
4168
|
+
u
|
|
4169
|
+
)(), oe = E(r(u)), ie = {};
|
|
4170
|
+
Le.Fragment = D, Le.jsx = function(a, m, k, A, U) {
|
|
4171
|
+
var Y = 1e4 > d.recentlyCreatedOwnerStacks++;
|
|
4172
|
+
return y(
|
|
4173
|
+
a,
|
|
4174
|
+
m,
|
|
4175
|
+
k,
|
|
4176
|
+
!1,
|
|
4177
|
+
A,
|
|
4178
|
+
U,
|
|
4179
|
+
Y ? Error("react-stack-top-frame") : P,
|
|
4180
|
+
Y ? E(r(a)) : oe
|
|
4181
|
+
);
|
|
4182
|
+
}, Le.jsxs = function(a, m, k, A, U) {
|
|
4183
|
+
var Y = 1e4 > d.recentlyCreatedOwnerStacks++;
|
|
4184
|
+
return y(
|
|
4185
|
+
a,
|
|
4186
|
+
m,
|
|
4187
|
+
k,
|
|
4188
|
+
!0,
|
|
4189
|
+
A,
|
|
4190
|
+
U,
|
|
4191
|
+
Y ? Error("react-stack-top-frame") : P,
|
|
4192
|
+
Y ? E(r(a)) : oe
|
|
4193
|
+
);
|
|
4194
|
+
};
|
|
4195
|
+
}()), Le;
|
|
4196
|
+
}
|
|
4197
|
+
var bn;
|
|
4198
|
+
function uo() {
|
|
4199
|
+
return bn || (bn = 1, process.env.NODE_ENV === "production" ? Ze.exports = io() : Ze.exports = co()), Ze.exports;
|
|
4200
|
+
}
|
|
4201
|
+
var Ne = uo(), ue = Bn();
|
|
4202
|
+
const Yn = /* @__PURE__ */ Wn(ue), je = {}, wn = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Sn = (t) => "init" in t, _t = (t) => !!t.write, En = (t) => "v" in t || "e" in t, tt = (t) => {
|
|
4203
|
+
if ("e" in t)
|
|
4204
|
+
throw t.e;
|
|
4205
|
+
if ((je ? "production" : void 0) !== "production" && !("v" in t))
|
|
4206
|
+
throw new Error("[Bug] atom state is not initialized");
|
|
4207
|
+
return t.v;
|
|
4208
|
+
}, ct = /* @__PURE__ */ new WeakMap(), Cn = (t) => {
|
|
4209
|
+
var e;
|
|
4210
|
+
return ut(t) && !!((e = ct.get(t)) != null && e[0]);
|
|
4211
|
+
}, lo = (t) => {
|
|
4212
|
+
const e = ct.get(t);
|
|
4213
|
+
e?.[0] && (e[0] = !1, e[1].forEach((n) => n()));
|
|
4214
|
+
}, qn = (t, e) => {
|
|
4215
|
+
let n = ct.get(t);
|
|
4216
|
+
if (!n) {
|
|
4217
|
+
n = [!0, /* @__PURE__ */ new Set()], ct.set(t, n);
|
|
4218
|
+
const r = () => {
|
|
4219
|
+
n[0] = !1;
|
|
4220
|
+
};
|
|
4221
|
+
t.then(r, r);
|
|
4222
|
+
}
|
|
4223
|
+
n[1].add(e);
|
|
4224
|
+
}, ut = (t) => typeof t?.then == "function", Hn = (t, e, n) => {
|
|
4225
|
+
n.p.has(t) || (n.p.add(t), e.then(
|
|
4226
|
+
() => {
|
|
4227
|
+
n.p.delete(t);
|
|
4228
|
+
},
|
|
4229
|
+
() => {
|
|
4230
|
+
n.p.delete(t);
|
|
4231
|
+
}
|
|
4232
|
+
));
|
|
4233
|
+
}, bt = (t, e, n) => {
|
|
4234
|
+
const r = n(t), i = "v" in r, u = r.v;
|
|
4235
|
+
if (ut(e))
|
|
4236
|
+
for (const l of r.d.keys())
|
|
4237
|
+
Hn(t, e, n(l));
|
|
4238
|
+
r.v = e, delete r.e, (!i || !Object.is(u, r.v)) && (++r.n, ut(u) && lo(u));
|
|
4239
|
+
}, Rn = (t, e, n) => {
|
|
4240
|
+
var r;
|
|
4241
|
+
const i = /* @__PURE__ */ new Set();
|
|
4242
|
+
for (const u of ((r = n.get(t)) == null ? void 0 : r.t) || [])
|
|
4243
|
+
n.has(u) && i.add(u);
|
|
4244
|
+
for (const u of e.p)
|
|
4245
|
+
i.add(u);
|
|
4246
|
+
return i;
|
|
4247
|
+
}, ho = () => {
|
|
4248
|
+
const t = /* @__PURE__ */ new Set(), e = () => {
|
|
4249
|
+
t.forEach((n) => n());
|
|
4250
|
+
};
|
|
4251
|
+
return e.add = (n) => (t.add(n), () => {
|
|
4252
|
+
t.delete(n);
|
|
4253
|
+
}), e;
|
|
4254
|
+
}, wt = () => {
|
|
4255
|
+
const t = {}, e = /* @__PURE__ */ new WeakMap(), n = (r) => {
|
|
4256
|
+
var i, u;
|
|
4257
|
+
(i = e.get(t)) == null || i.forEach((l) => l(r)), (u = e.get(r)) == null || u.forEach((l) => l());
|
|
4258
|
+
};
|
|
4259
|
+
return n.add = (r, i) => {
|
|
4260
|
+
const u = r || t, l = (e.has(u) ? e : e.set(u, /* @__PURE__ */ new Set())).get(u);
|
|
4261
|
+
return l.add(i), () => {
|
|
4262
|
+
l?.delete(i), l.size || e.delete(u);
|
|
4263
|
+
};
|
|
4264
|
+
}, n;
|
|
4265
|
+
}, fo = (t) => (t.c || (t.c = wt()), t.m || (t.m = wt()), t.u || (t.u = wt()), t.f || (t.f = ho()), t), po = Symbol(), go = (t = /* @__PURE__ */ new WeakMap(), e = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), l = {}, h = (I, ...T) => I.read(...T), g = (I, ...T) => I.write(...T), p = (I, T) => {
|
|
4266
|
+
var C;
|
|
4267
|
+
return (C = I.unstable_onInit) == null ? void 0 : C.call(I, T);
|
|
4268
|
+
}, y = (I, T) => {
|
|
4269
|
+
var C;
|
|
4270
|
+
return (C = I.onMount) == null ? void 0 : C.call(I, T);
|
|
4271
|
+
}, ...S) => {
|
|
4272
|
+
const I = S[0] || ((R) => {
|
|
4273
|
+
if ((je ? "production" : void 0) !== "production" && !R)
|
|
4274
|
+
throw new Error("Atom is undefined or null");
|
|
4275
|
+
let x = t.get(R);
|
|
4276
|
+
return x || (x = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, t.set(R, x), p?.(R, ce)), x;
|
|
4277
|
+
}), T = S[1] || (() => {
|
|
4278
|
+
const R = [], x = (s) => {
|
|
4279
|
+
try {
|
|
4280
|
+
s();
|
|
4281
|
+
} catch (c) {
|
|
4282
|
+
R.push(c);
|
|
4283
|
+
}
|
|
4284
|
+
};
|
|
4285
|
+
do {
|
|
4286
|
+
l.f && x(l.f);
|
|
4287
|
+
const s = /* @__PURE__ */ new Set(), c = s.add.bind(s);
|
|
4288
|
+
r.forEach((d) => {
|
|
4289
|
+
var f;
|
|
4290
|
+
return (f = e.get(d)) == null ? void 0 : f.l.forEach(c);
|
|
4291
|
+
}), r.clear(), u.forEach(c), u.clear(), i.forEach(c), i.clear(), s.forEach(x), r.size && C();
|
|
4292
|
+
} while (r.size || u.size || i.size);
|
|
4293
|
+
if (R.length)
|
|
4294
|
+
throw new AggregateError(R);
|
|
4295
|
+
}), C = S[2] || (() => {
|
|
4296
|
+
const R = [], x = /* @__PURE__ */ new WeakSet(), s = /* @__PURE__ */ new WeakSet(), c = Array.from(r);
|
|
4297
|
+
for (; c.length; ) {
|
|
4298
|
+
const d = c[c.length - 1], f = I(d);
|
|
4299
|
+
if (s.has(d)) {
|
|
4300
|
+
c.pop();
|
|
4301
|
+
continue;
|
|
4302
|
+
}
|
|
4303
|
+
if (x.has(d)) {
|
|
4304
|
+
if (n.get(d) === f.n)
|
|
4305
|
+
R.push([d, f]);
|
|
4306
|
+
else if ((je ? "production" : void 0) !== "production" && n.has(d))
|
|
4307
|
+
throw new Error("[Bug] invalidated atom exists");
|
|
4308
|
+
s.add(d), c.pop();
|
|
4309
|
+
continue;
|
|
4310
|
+
}
|
|
4311
|
+
x.add(d);
|
|
4312
|
+
for (const _ of Rn(d, f, e))
|
|
4313
|
+
x.has(_) || c.push(_);
|
|
4314
|
+
}
|
|
4315
|
+
for (let d = R.length - 1; d >= 0; --d) {
|
|
4316
|
+
const [f, _] = R[d];
|
|
4317
|
+
let E = !1;
|
|
4318
|
+
for (const w of _.d.keys())
|
|
4319
|
+
if (w !== f && r.has(w)) {
|
|
4320
|
+
E = !0;
|
|
4321
|
+
break;
|
|
4322
|
+
}
|
|
4323
|
+
E && (D(f), $(f)), n.delete(f);
|
|
4324
|
+
}
|
|
4325
|
+
}), D = S[3] || ((R) => {
|
|
4326
|
+
var x;
|
|
4327
|
+
const s = I(R);
|
|
4328
|
+
if (En(s) && (e.has(R) && n.get(R) !== s.n || Array.from(s.d).every(
|
|
4329
|
+
([P, oe]) => (
|
|
4330
|
+
// Recursively, read the atom state of the dependency, and
|
|
4331
|
+
// check if the atom epoch number is unchanged
|
|
4332
|
+
D(P).n === oe
|
|
4333
|
+
)
|
|
4334
|
+
)))
|
|
4335
|
+
return s;
|
|
4336
|
+
s.d.clear();
|
|
4337
|
+
let c = !0;
|
|
4338
|
+
const d = () => {
|
|
4339
|
+
e.has(R) && ($(R), C(), T());
|
|
4340
|
+
}, f = (P) => {
|
|
4341
|
+
var oe;
|
|
4342
|
+
if (wn(R, P)) {
|
|
4343
|
+
const a = I(P);
|
|
4344
|
+
if (!En(a))
|
|
4345
|
+
if (Sn(P))
|
|
4346
|
+
bt(P, P.init, I);
|
|
4347
|
+
else
|
|
4348
|
+
throw new Error("no atom init");
|
|
4349
|
+
return tt(a);
|
|
4350
|
+
}
|
|
4351
|
+
const ie = D(P);
|
|
4352
|
+
try {
|
|
4353
|
+
return tt(ie);
|
|
4354
|
+
} finally {
|
|
4355
|
+
s.d.set(P, ie.n), Cn(s.v) && Hn(R, s.v, ie), (oe = e.get(P)) == null || oe.t.add(R), c || d();
|
|
4356
|
+
}
|
|
4357
|
+
};
|
|
4358
|
+
let _, E;
|
|
4359
|
+
const w = {
|
|
4360
|
+
get signal() {
|
|
4361
|
+
return _ || (_ = new AbortController()), _.signal;
|
|
4362
|
+
},
|
|
4363
|
+
get setSelf() {
|
|
4364
|
+
return (je ? "production" : void 0) !== "production" && !_t(R) && console.warn("setSelf function cannot be used with read-only atom"), !E && _t(R) && (E = (...P) => {
|
|
4365
|
+
if ((je ? "production" : void 0) !== "production" && c && console.warn("setSelf function cannot be called in sync"), !c)
|
|
4366
|
+
try {
|
|
4367
|
+
return j(R, ...P);
|
|
4368
|
+
} finally {
|
|
4369
|
+
C(), T();
|
|
4370
|
+
}
|
|
4371
|
+
}), E;
|
|
4372
|
+
}
|
|
4373
|
+
}, L = s.n;
|
|
4374
|
+
try {
|
|
4375
|
+
const P = h(R, f, w);
|
|
4376
|
+
return bt(R, P, I), ut(P) && (qn(P, () => _?.abort()), P.then(
|
|
4377
|
+
d,
|
|
4378
|
+
d
|
|
4379
|
+
)), s;
|
|
4380
|
+
} catch (P) {
|
|
4381
|
+
return delete s.v, s.e = P, ++s.n, s;
|
|
4382
|
+
} finally {
|
|
4383
|
+
c = !1, L !== s.n && n.get(R) === L && (n.set(R, s.n), r.add(R), (x = l.c) == null || x.call(l, R));
|
|
4384
|
+
}
|
|
4385
|
+
}), b = S[4] || ((R) => {
|
|
4386
|
+
const x = [R];
|
|
4387
|
+
for (; x.length; ) {
|
|
4388
|
+
const s = x.pop(), c = I(s);
|
|
4389
|
+
for (const d of Rn(s, c, e)) {
|
|
4390
|
+
const f = I(d);
|
|
4391
|
+
n.set(d, f.n), x.push(d);
|
|
4392
|
+
}
|
|
4393
|
+
}
|
|
4394
|
+
}), j = S[5] || ((R, ...x) => {
|
|
4395
|
+
let s = !0;
|
|
4396
|
+
const c = (f) => tt(D(f)), d = (f, ..._) => {
|
|
4397
|
+
var E;
|
|
4398
|
+
const w = I(f);
|
|
4399
|
+
try {
|
|
4400
|
+
if (wn(R, f)) {
|
|
4401
|
+
if (!Sn(f))
|
|
4402
|
+
throw new Error("atom not writable");
|
|
4403
|
+
const L = w.n, P = _[0];
|
|
4404
|
+
bt(f, P, I), $(f), L !== w.n && (r.add(f), (E = l.c) == null || E.call(l, f), b(f));
|
|
4405
|
+
return;
|
|
4406
|
+
} else
|
|
4407
|
+
return j(f, ..._);
|
|
4408
|
+
} finally {
|
|
4409
|
+
s || (C(), T());
|
|
4410
|
+
}
|
|
4411
|
+
};
|
|
4412
|
+
try {
|
|
4413
|
+
return g(R, c, d, ...x);
|
|
4414
|
+
} finally {
|
|
4415
|
+
s = !1;
|
|
4416
|
+
}
|
|
4417
|
+
}), $ = S[6] || ((R) => {
|
|
4418
|
+
var x;
|
|
4419
|
+
const s = I(R), c = e.get(R);
|
|
4420
|
+
if (c && !Cn(s.v)) {
|
|
4421
|
+
for (const [d, f] of s.d)
|
|
4422
|
+
if (!c.d.has(d)) {
|
|
4423
|
+
const _ = I(d);
|
|
4424
|
+
M(d).t.add(R), c.d.add(d), f !== _.n && (r.add(d), (x = l.c) == null || x.call(l, d), b(d));
|
|
4425
|
+
}
|
|
4426
|
+
for (const d of c.d || [])
|
|
4427
|
+
if (!s.d.has(d)) {
|
|
4428
|
+
c.d.delete(d);
|
|
4429
|
+
const f = K(d);
|
|
4430
|
+
f?.t.delete(R);
|
|
4431
|
+
}
|
|
4432
|
+
}
|
|
4433
|
+
}), M = S[7] || ((R) => {
|
|
4434
|
+
var x;
|
|
4435
|
+
const s = I(R);
|
|
4436
|
+
let c = e.get(R);
|
|
4437
|
+
if (!c) {
|
|
4438
|
+
D(R);
|
|
4439
|
+
for (const d of s.d.keys())
|
|
4440
|
+
M(d).t.add(R);
|
|
4441
|
+
if (c = {
|
|
4442
|
+
l: /* @__PURE__ */ new Set(),
|
|
4443
|
+
d: new Set(s.d.keys()),
|
|
4444
|
+
t: /* @__PURE__ */ new Set()
|
|
4445
|
+
}, e.set(R, c), (x = l.m) == null || x.call(l, R), _t(R)) {
|
|
4446
|
+
const d = () => {
|
|
4447
|
+
let f = !0;
|
|
4448
|
+
const _ = (...E) => {
|
|
4449
|
+
try {
|
|
4450
|
+
return j(R, ...E);
|
|
4451
|
+
} finally {
|
|
4452
|
+
f || (C(), T());
|
|
4453
|
+
}
|
|
4454
|
+
};
|
|
4455
|
+
try {
|
|
4456
|
+
const E = y(R, _);
|
|
4457
|
+
E && (c.u = () => {
|
|
4458
|
+
f = !0;
|
|
4459
|
+
try {
|
|
4460
|
+
E();
|
|
4461
|
+
} finally {
|
|
4462
|
+
f = !1;
|
|
4463
|
+
}
|
|
4464
|
+
});
|
|
4465
|
+
} finally {
|
|
4466
|
+
f = !1;
|
|
4467
|
+
}
|
|
4468
|
+
};
|
|
4469
|
+
i.add(d);
|
|
4470
|
+
}
|
|
4471
|
+
}
|
|
4472
|
+
return c;
|
|
4473
|
+
}), K = S[8] || ((R) => {
|
|
4474
|
+
var x;
|
|
4475
|
+
const s = I(R);
|
|
4476
|
+
let c = e.get(R);
|
|
4477
|
+
if (c && !c.l.size && !Array.from(c.t).some((d) => {
|
|
4478
|
+
var f;
|
|
4479
|
+
return (f = e.get(d)) == null ? void 0 : f.d.has(R);
|
|
4480
|
+
})) {
|
|
4481
|
+
c.u && u.add(c.u), c = void 0, e.delete(R), (x = l.u) == null || x.call(l, R);
|
|
4482
|
+
for (const d of s.d.keys()) {
|
|
4483
|
+
const f = K(d);
|
|
4484
|
+
f?.t.delete(R);
|
|
4485
|
+
}
|
|
4486
|
+
return;
|
|
4487
|
+
}
|
|
4488
|
+
return c;
|
|
4489
|
+
}), G = [
|
|
4490
|
+
// store state
|
|
4491
|
+
t,
|
|
4492
|
+
e,
|
|
4493
|
+
n,
|
|
4494
|
+
r,
|
|
4495
|
+
i,
|
|
4496
|
+
u,
|
|
4497
|
+
l,
|
|
4498
|
+
// atom interceptors
|
|
4499
|
+
h,
|
|
4500
|
+
g,
|
|
4501
|
+
p,
|
|
4502
|
+
y,
|
|
4503
|
+
// building-block functions
|
|
4504
|
+
I,
|
|
4505
|
+
T,
|
|
4506
|
+
C,
|
|
4507
|
+
D,
|
|
4508
|
+
b,
|
|
4509
|
+
j,
|
|
4510
|
+
$,
|
|
4511
|
+
M,
|
|
4512
|
+
K
|
|
4513
|
+
], ce = {
|
|
4514
|
+
get: (R) => tt(D(R)),
|
|
4515
|
+
set: (R, ...x) => {
|
|
4516
|
+
try {
|
|
4517
|
+
return j(R, ...x);
|
|
4518
|
+
} finally {
|
|
4519
|
+
C(), T();
|
|
4520
|
+
}
|
|
4521
|
+
},
|
|
4522
|
+
sub: (R, x) => {
|
|
4523
|
+
const c = M(R).l;
|
|
4524
|
+
return c.add(x), T(), () => {
|
|
4525
|
+
c.delete(x), K(R), T();
|
|
4526
|
+
};
|
|
4527
|
+
}
|
|
4528
|
+
};
|
|
4529
|
+
return Object.defineProperty(ce, po, { value: G }), ce;
|
|
4530
|
+
}, zn = go, vo = fo, Tn = qn, Mt = {};
|
|
4531
|
+
let mo = 0;
|
|
4532
|
+
function lt(t, e) {
|
|
4533
|
+
const n = `atom${++mo}`, r = {
|
|
4534
|
+
toString() {
|
|
4535
|
+
return (Mt ? "production" : void 0) !== "production" && this.debugLabel ? n + ":" + this.debugLabel : n;
|
|
4536
|
+
}
|
|
4537
|
+
};
|
|
4538
|
+
return typeof t == "function" ? r.read = t : (r.init = t, r.read = yo, r.write = _o), r;
|
|
4539
|
+
}
|
|
4540
|
+
function yo(t) {
|
|
4541
|
+
return t(this);
|
|
4542
|
+
}
|
|
4543
|
+
function _o(t, e, n) {
|
|
4544
|
+
return e(
|
|
4545
|
+
this,
|
|
4546
|
+
typeof n == "function" ? n(t(this)) : n
|
|
4547
|
+
);
|
|
4548
|
+
}
|
|
4549
|
+
const bo = () => {
|
|
4550
|
+
let t = 0;
|
|
4551
|
+
const e = vo({}), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), i = zn(
|
|
4552
|
+
n,
|
|
4553
|
+
r,
|
|
4554
|
+
void 0,
|
|
4555
|
+
void 0,
|
|
4556
|
+
void 0,
|
|
4557
|
+
void 0,
|
|
4558
|
+
e,
|
|
4559
|
+
void 0,
|
|
4560
|
+
(h, g, p, ...y) => t ? p(h, ...y) : h.write(g, p, ...y)
|
|
4561
|
+
), u = /* @__PURE__ */ new Set();
|
|
4562
|
+
return e.m.add(void 0, (h) => {
|
|
4563
|
+
u.add(h);
|
|
4564
|
+
const g = n.get(h);
|
|
4565
|
+
g.m = r.get(h);
|
|
4566
|
+
}), e.u.add(void 0, (h) => {
|
|
4567
|
+
u.delete(h);
|
|
4568
|
+
const g = n.get(h);
|
|
4569
|
+
delete g.m;
|
|
4570
|
+
}), Object.assign(i, {
|
|
4571
|
+
// store dev methods (these are tentative and subject to change without notice)
|
|
4572
|
+
dev4_get_internal_weak_map: () => (console.log("Deprecated: Use devstore from the devtools library"), n),
|
|
4573
|
+
dev4_get_mounted_atoms: () => u,
|
|
4574
|
+
dev4_restore_atoms: (h) => {
|
|
4575
|
+
const g = {
|
|
4576
|
+
read: () => null,
|
|
4577
|
+
write: (p, y) => {
|
|
4578
|
+
++t;
|
|
4579
|
+
try {
|
|
4580
|
+
for (const [S, I] of h)
|
|
4581
|
+
"init" in S && y(S, I);
|
|
4582
|
+
} finally {
|
|
4583
|
+
--t;
|
|
4584
|
+
}
|
|
4585
|
+
}
|
|
4586
|
+
};
|
|
4587
|
+
i.set(g);
|
|
4588
|
+
}
|
|
4589
|
+
});
|
|
4590
|
+
};
|
|
4591
|
+
function wo() {
|
|
4592
|
+
return (Mt ? "production" : void 0) !== "production" ? bo() : zn();
|
|
4593
|
+
}
|
|
4594
|
+
let Me;
|
|
4595
|
+
function So() {
|
|
4596
|
+
return Me || (Me = wo(), (Mt ? "production" : void 0) !== "production" && (globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = Me), globalThis.__JOTAI_DEFAULT_STORE__ !== Me && console.warn(
|
|
4597
|
+
"Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
|
|
4598
|
+
))), Me;
|
|
4599
|
+
}
|
|
4600
|
+
const Eo = {}, Co = ue.createContext(
|
|
4601
|
+
void 0
|
|
4602
|
+
);
|
|
4603
|
+
function Kn(t) {
|
|
4604
|
+
return ue.useContext(Co) || So();
|
|
4605
|
+
}
|
|
4606
|
+
const kt = (t) => typeof t?.then == "function", At = (t) => {
|
|
4607
|
+
t.status || (t.status = "pending", t.then(
|
|
4608
|
+
(e) => {
|
|
4609
|
+
t.status = "fulfilled", t.value = e;
|
|
4610
|
+
},
|
|
4611
|
+
(e) => {
|
|
4612
|
+
t.status = "rejected", t.reason = e;
|
|
4613
|
+
}
|
|
4614
|
+
));
|
|
4615
|
+
}, Ro = Yn.use || // A shim for older React versions
|
|
4616
|
+
((t) => {
|
|
4617
|
+
if (t.status === "pending")
|
|
4618
|
+
throw t;
|
|
4619
|
+
if (t.status === "fulfilled")
|
|
4620
|
+
return t.value;
|
|
4621
|
+
throw t.status === "rejected" ? t.reason : (At(t), t);
|
|
4622
|
+
}), St = /* @__PURE__ */ new WeakMap(), In = (t, e) => {
|
|
4623
|
+
let n = St.get(t);
|
|
4624
|
+
return n || (n = new Promise((r, i) => {
|
|
4625
|
+
let u = t;
|
|
4626
|
+
const l = (p) => (y) => {
|
|
4627
|
+
u === p && r(y);
|
|
4628
|
+
}, h = (p) => (y) => {
|
|
4629
|
+
u === p && i(y);
|
|
4630
|
+
}, g = () => {
|
|
4631
|
+
try {
|
|
4632
|
+
const p = e();
|
|
4633
|
+
kt(p) ? (St.set(p, n), u = p, p.then(l(p), h(p)), Tn(p, g)) : r(p);
|
|
4634
|
+
} catch (p) {
|
|
4635
|
+
i(p);
|
|
4636
|
+
}
|
|
4637
|
+
};
|
|
4638
|
+
t.then(l(t), h(t)), Tn(t, g);
|
|
4639
|
+
}), St.set(t, n)), n;
|
|
4640
|
+
};
|
|
4641
|
+
function dt(t, e) {
|
|
4642
|
+
const { delay: n, unstable_promiseStatus: r = !Yn.use } = {}, i = Kn(), [[u, l, h], g] = ue.useReducer(
|
|
4643
|
+
(y) => {
|
|
4644
|
+
const S = i.get(t);
|
|
4645
|
+
return Object.is(y[0], S) && y[1] === i && y[2] === t ? y : [S, i, t];
|
|
4646
|
+
},
|
|
4647
|
+
void 0,
|
|
4648
|
+
() => [i.get(t), i, t]
|
|
4649
|
+
);
|
|
4650
|
+
let p = u;
|
|
4651
|
+
if ((l !== i || h !== t) && (g(), p = i.get(t)), ue.useEffect(() => {
|
|
4652
|
+
const y = i.sub(t, () => {
|
|
4653
|
+
if (r)
|
|
4654
|
+
try {
|
|
4655
|
+
const S = i.get(t);
|
|
4656
|
+
kt(S) && At(
|
|
4657
|
+
In(S, () => i.get(t))
|
|
4658
|
+
);
|
|
4659
|
+
} catch {
|
|
4660
|
+
}
|
|
4661
|
+
if (typeof n == "number") {
|
|
4662
|
+
setTimeout(g, n);
|
|
4663
|
+
return;
|
|
4664
|
+
}
|
|
4665
|
+
g();
|
|
4666
|
+
});
|
|
4667
|
+
return g(), y;
|
|
4668
|
+
}, [i, t, n, r]), ue.useDebugValue(p), kt(p)) {
|
|
4669
|
+
const y = In(p, () => i.get(t));
|
|
4670
|
+
return r && At(y), Ro(y);
|
|
4671
|
+
}
|
|
4672
|
+
return p;
|
|
4673
|
+
}
|
|
4674
|
+
function ht(t, e) {
|
|
4675
|
+
const n = Kn();
|
|
4676
|
+
return ue.useCallback(
|
|
4677
|
+
(...i) => {
|
|
4678
|
+
if ((Eo ? "production" : void 0) !== "production" && !("write" in t))
|
|
4679
|
+
throw new Error("not writable atom");
|
|
4680
|
+
return n.set(t, ...i);
|
|
4681
|
+
},
|
|
4682
|
+
[n, t]
|
|
4683
|
+
);
|
|
4684
|
+
}
|
|
4685
|
+
const Jn = lt([]);
|
|
4686
|
+
function Mo() {
|
|
4687
|
+
return dt(Jn);
|
|
4688
|
+
}
|
|
4689
|
+
function To() {
|
|
4690
|
+
return ht(Jn);
|
|
4691
|
+
}
|
|
4692
|
+
const ft = () => {
|
|
4693
|
+
const t = ue.useContext(er);
|
|
4694
|
+
if (!t)
|
|
4695
|
+
throw new Error("useClient must be used within a TelnyxAIAgentProvider");
|
|
4696
|
+
return t;
|
|
4697
|
+
};
|
|
4698
|
+
function Io() {
|
|
4699
|
+
const t = ft(), e = To();
|
|
4700
|
+
return ue.useEffect(() => {
|
|
4701
|
+
const n = (r) => e((i) => [...i, r]);
|
|
4702
|
+
return t.addListener("transcript.item", n), () => {
|
|
4703
|
+
t.removeListener("transcript.item", n);
|
|
4704
|
+
};
|
|
4705
|
+
}, [t, e]), null;
|
|
4706
|
+
}
|
|
4707
|
+
const Qn = lt("connecting");
|
|
4708
|
+
function Po() {
|
|
4709
|
+
return dt(Qn);
|
|
4710
|
+
}
|
|
4711
|
+
function ko() {
|
|
4712
|
+
return ht(Qn);
|
|
4713
|
+
}
|
|
4714
|
+
function Ao() {
|
|
4715
|
+
const t = ft(), e = ko();
|
|
4716
|
+
return ue.useEffect(() => {
|
|
4717
|
+
const n = () => e("connected"), r = () => e("disconnected"), i = () => e("error");
|
|
4718
|
+
return t.addListener("agent.connected", n), t.addListener("agent.disconnected", r), t.addListener("agent.error", i), () => {
|
|
4719
|
+
t.removeListener("agent.connected", n), t.removeListener("agent.disconnected", r), t.removeListener("agent.error", i);
|
|
4720
|
+
};
|
|
4721
|
+
}, [t, e]), null;
|
|
4722
|
+
}
|
|
4723
|
+
const Xn = lt(null);
|
|
4724
|
+
function Do() {
|
|
4725
|
+
return dt(Xn);
|
|
4726
|
+
}
|
|
4727
|
+
function Oo() {
|
|
4728
|
+
return ht(Xn);
|
|
4729
|
+
}
|
|
4730
|
+
const xo = () => {
|
|
4731
|
+
const t = ft(), e = Oo();
|
|
4732
|
+
return ue.useEffect(() => {
|
|
4733
|
+
const n = (r) => {
|
|
4734
|
+
e(r);
|
|
4735
|
+
};
|
|
4736
|
+
return t.addListener("conversation.update", n), () => {
|
|
4737
|
+
t.removeListener("conversation.update", n);
|
|
4738
|
+
};
|
|
4739
|
+
}, [t, e]), null;
|
|
4740
|
+
}, Zn = lt("listening");
|
|
4741
|
+
function jo() {
|
|
4742
|
+
return dt(Zn);
|
|
4743
|
+
}
|
|
4744
|
+
function Lo() {
|
|
4745
|
+
return ht(Zn);
|
|
4746
|
+
}
|
|
4747
|
+
function No() {
|
|
4748
|
+
const t = ft(), e = Lo();
|
|
4749
|
+
return ue.useEffect(() => {
|
|
4750
|
+
const n = (r) => {
|
|
4751
|
+
e(r);
|
|
4752
|
+
};
|
|
4753
|
+
return t.addListener("conversation.agent.state", n), () => {
|
|
4754
|
+
t.removeListener("conversation.agent.state", n);
|
|
4755
|
+
};
|
|
4756
|
+
}, [t, e]), null;
|
|
4757
|
+
}
|
|
4758
|
+
const er = ue.createContext(null), Uo = ({
|
|
4759
|
+
children: t,
|
|
4760
|
+
agentId: e,
|
|
4761
|
+
environment: n,
|
|
4762
|
+
versionId: r
|
|
4763
|
+
}) => {
|
|
4764
|
+
const [i, u] = ue.useState(() => new pn({ agentId: e, environment: n, versionId: r }));
|
|
4765
|
+
return ue.useEffect(() => {
|
|
4766
|
+
if (!i) {
|
|
4767
|
+
const l = new pn({ agentId: e, environment: n, versionId: r });
|
|
4768
|
+
return u(l), () => {
|
|
4769
|
+
l.disconnect();
|
|
4770
|
+
};
|
|
4771
|
+
}
|
|
4772
|
+
}, [e, i, n, r]), ue.useEffect(() => {
|
|
4773
|
+
i?.connect();
|
|
4774
|
+
}, [i]), /* @__PURE__ */ Ne.jsxs(er.Provider, { value: i, children: [
|
|
4775
|
+
/* @__PURE__ */ Ne.jsx(Io, {}),
|
|
4776
|
+
/* @__PURE__ */ Ne.jsx(Ao, {}),
|
|
4777
|
+
/* @__PURE__ */ Ne.jsx(xo, {}),
|
|
4778
|
+
/* @__PURE__ */ Ne.jsx(No, {}),
|
|
4779
|
+
t
|
|
4780
|
+
] });
|
|
4781
|
+
};
|
|
4782
|
+
export {
|
|
4783
|
+
er as ClientContext,
|
|
4784
|
+
pn as TelnyxAIAgent,
|
|
4785
|
+
Uo as TelnyxAIAgentProvider,
|
|
4786
|
+
jo as useAgentState,
|
|
4787
|
+
ft as useClient,
|
|
4788
|
+
Po as useConnectionState,
|
|
4789
|
+
Do as useConversation,
|
|
4790
|
+
Lo as useSetAgentState,
|
|
4791
|
+
ko as useSetConnectionState,
|
|
4792
|
+
Oo as useSetConversation,
|
|
4793
|
+
To as useSetTranscript,
|
|
4794
|
+
Mo as useTranscript
|
|
4795
|
+
};
|