vue-peer
Version:
With this package, you can have video calls along with two or multi-person chat communication. You can easily bind and display your streams in any video element you want.
1,271 lines • 204 kB
JavaScript
var rn = Object.defineProperty;
var sn = (r, e, t) => e in r ? rn(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
var T = (r, e, t) => (sn(r, typeof e != "symbol" ? e + "" : e, t), t);
var F = (r, e, t) => {
if (e.has(r))
throw TypeError("Cannot add the same private member more than once");
e instanceof WeakSet ? e.add(r) : e.set(r, t);
};
function on(r, e) {
for (var t = 0; t < e.length; t++) {
const n = e[t];
if (typeof n != "string" && !Array.isArray(n)) {
for (const s in n)
if (s !== "default" && !(s in r)) {
const i = Object.getOwnPropertyDescriptor(n, s);
i && Object.defineProperty(r, s, i.get ? i : {
enumerable: !0,
get: () => n[s]
});
}
}
}
return Object.freeze(Object.defineProperty(r, Symbol.toStringTag, { value: "Module" }));
}
function an(r, e) {
return r.then(function(t) {
return [null, t];
}).catch(function(t) {
return e && Object.assign(t, e), [t, void 0];
});
}
class cn {
constructor() {
this.encoder = new TextEncoder(), this._pieces = [], this._parts = [];
}
append_buffer(e) {
this.flush(), this._parts.push(e);
}
append(e) {
this._pieces.push(e);
}
flush() {
if (this._pieces.length > 0) {
const e = new Uint8Array(this._pieces);
this._parts.push(e), this._pieces = [];
}
}
toArrayBuffer() {
const e = [];
for (const t of this._parts)
e.push(t);
return hn(e).buffer;
}
}
function hn(r) {
let e = 0;
for (const s of r)
e += s.byteLength;
const t = new Uint8Array(e);
let n = 0;
for (const s of r) {
const i = new Uint8Array(s.buffer, s.byteOffset, s.byteLength);
t.set(i, n), n += s.byteLength;
}
return t;
}
function rt(r) {
return new fn(r).unpack();
}
function st(r) {
const e = new ln(), t = e.pack(r);
return t instanceof Promise ? t.then(() => e.getBuffer()) : e.getBuffer();
}
class fn {
constructor(e) {
this.index = 0, this.dataBuffer = e, this.dataView = new Uint8Array(this.dataBuffer), this.length = this.dataBuffer.byteLength;
}
unpack() {
const e = this.unpack_uint8();
if (e < 128)
return e;
if ((e ^ 224) < 32)
return (e ^ 224) - 32;
let t;
if ((t = e ^ 160) <= 15)
return this.unpack_raw(t);
if ((t = e ^ 176) <= 15)
return this.unpack_string(t);
if ((t = e ^ 144) <= 15)
return this.unpack_array(t);
if ((t = e ^ 128) <= 15)
return this.unpack_map(t);
switch (e) {
case 192:
return null;
case 193:
return;
case 194:
return !1;
case 195:
return !0;
case 202:
return this.unpack_float();
case 203:
return this.unpack_double();
case 204:
return this.unpack_uint8();
case 205:
return this.unpack_uint16();
case 206:
return this.unpack_uint32();
case 207:
return this.unpack_uint64();
case 208:
return this.unpack_int8();
case 209:
return this.unpack_int16();
case 210:
return this.unpack_int32();
case 211:
return this.unpack_int64();
case 212:
return;
case 213:
return;
case 214:
return;
case 215:
return;
case 216:
return t = this.unpack_uint16(), this.unpack_string(t);
case 217:
return t = this.unpack_uint32(), this.unpack_string(t);
case 218:
return t = this.unpack_uint16(), this.unpack_raw(t);
case 219:
return t = this.unpack_uint32(), this.unpack_raw(t);
case 220:
return t = this.unpack_uint16(), this.unpack_array(t);
case 221:
return t = this.unpack_uint32(), this.unpack_array(t);
case 222:
return t = this.unpack_uint16(), this.unpack_map(t);
case 223:
return t = this.unpack_uint32(), this.unpack_map(t);
}
}
unpack_uint8() {
const e = this.dataView[this.index] & 255;
return this.index++, e;
}
unpack_uint16() {
const e = this.read(2), t = (e[0] & 255) * 256 + (e[1] & 255);
return this.index += 2, t;
}
unpack_uint32() {
const e = this.read(4), t = ((e[0] * 256 + e[1]) * 256 + e[2]) * 256 + e[3];
return this.index += 4, t;
}
unpack_uint64() {
const e = this.read(8), t = ((((((e[0] * 256 + e[1]) * 256 + e[2]) * 256 + e[3]) * 256 + e[4]) * 256 + e[5]) * 256 + e[6]) * 256 + e[7];
return this.index += 8, t;
}
unpack_int8() {
const e = this.unpack_uint8();
return e < 128 ? e : e - 256;
}
unpack_int16() {
const e = this.unpack_uint16();
return e < 32768 ? e : e - 65536;
}
unpack_int32() {
const e = this.unpack_uint32();
return e < 2 ** 31 ? e : e - 2 ** 32;
}
unpack_int64() {
const e = this.unpack_uint64();
return e < 2 ** 63 ? e : e - 2 ** 64;
}
unpack_raw(e) {
if (this.length < this.index + e)
throw new Error(`BinaryPackFailure: index is out of range ${this.index} ${e} ${this.length}`);
const t = this.dataBuffer.slice(this.index, this.index + e);
return this.index += e, t;
}
unpack_string(e) {
const t = this.read(e);
let n = 0, s = "", i, o;
for (; n < e; )
i = t[n], i < 160 ? (o = i, n++) : (i ^ 192) < 32 ? (o = (i & 31) << 6 | t[n + 1] & 63, n += 2) : (i ^ 224) < 16 ? (o = (i & 15) << 12 | (t[n + 1] & 63) << 6 | t[n + 2] & 63, n += 3) : (o = (i & 7) << 18 | (t[n + 1] & 63) << 12 | (t[n + 2] & 63) << 6 | t[n + 3] & 63, n += 4), s += String.fromCodePoint(o);
return this.index += e, s;
}
unpack_array(e) {
const t = new Array(e);
for (let n = 0; n < e; n++)
t[n] = this.unpack();
return t;
}
unpack_map(e) {
const t = {};
for (let n = 0; n < e; n++) {
const s = this.unpack();
t[s] = this.unpack();
}
return t;
}
unpack_float() {
const e = this.unpack_uint32(), t = e >> 31, n = (e >> 23 & 255) - 127, s = e & 8388607 | 8388608;
return (t === 0 ? 1 : -1) * s * 2 ** (n - 23);
}
unpack_double() {
const e = this.unpack_uint32(), t = this.unpack_uint32(), n = e >> 31, s = (e >> 20 & 2047) - 1023, o = (e & 1048575 | 1048576) * 2 ** (s - 20) + t * 2 ** (s - 52);
return (n === 0 ? 1 : -1) * o;
}
read(e) {
const t = this.index;
if (t + e <= this.length)
return this.dataView.subarray(t, t + e);
throw new Error("BinaryPackFailure: read index out of range");
}
}
class ln {
getBuffer() {
return this._bufferBuilder.toArrayBuffer();
}
pack(e) {
if (typeof e == "string")
this.pack_string(e);
else if (typeof e == "number")
Math.floor(e) === e ? this.pack_integer(e) : this.pack_double(e);
else if (typeof e == "boolean")
e === !0 ? this._bufferBuilder.append(195) : e === !1 && this._bufferBuilder.append(194);
else if (e === void 0)
this._bufferBuilder.append(192);
else if (typeof e == "object")
if (e === null)
this._bufferBuilder.append(192);
else {
const t = e.constructor;
if (e instanceof Array) {
const n = this.pack_array(e);
if (n instanceof Promise)
return n.then(() => this._bufferBuilder.flush());
} else if (e instanceof ArrayBuffer)
this.pack_bin(new Uint8Array(e));
else if ("BYTES_PER_ELEMENT" in e) {
const n = e;
this.pack_bin(new Uint8Array(n.buffer, n.byteOffset, n.byteLength));
} else if (e instanceof Date)
this.pack_string(e.toString());
else {
if (e instanceof Blob)
return e.arrayBuffer().then((n) => {
this.pack_bin(new Uint8Array(n)), this._bufferBuilder.flush();
});
if (t == Object || t.toString().startsWith("class")) {
const n = this.pack_object(e);
if (n instanceof Promise)
return n.then(() => this._bufferBuilder.flush());
} else
throw new Error(`Type "${t.toString()}" not yet supported`);
}
}
else
throw new Error(`Type "${typeof e}" not yet supported`);
this._bufferBuilder.flush();
}
pack_bin(e) {
const t = e.length;
if (t <= 15)
this.pack_uint8(160 + t);
else if (t <= 65535)
this._bufferBuilder.append(218), this.pack_uint16(t);
else if (t <= 4294967295)
this._bufferBuilder.append(219), this.pack_uint32(t);
else
throw new Error("Invalid length");
this._bufferBuilder.append_buffer(e);
}
pack_string(e) {
const t = this._textEncoder.encode(e), n = t.length;
if (n <= 15)
this.pack_uint8(176 + n);
else if (n <= 65535)
this._bufferBuilder.append(216), this.pack_uint16(n);
else if (n <= 4294967295)
this._bufferBuilder.append(217), this.pack_uint32(n);
else
throw new Error("Invalid length");
this._bufferBuilder.append_buffer(t);
}
pack_array(e) {
const t = e.length;
if (t <= 15)
this.pack_uint8(144 + t);
else if (t <= 65535)
this._bufferBuilder.append(220), this.pack_uint16(t);
else if (t <= 4294967295)
this._bufferBuilder.append(221), this.pack_uint32(t);
else
throw new Error("Invalid length");
const n = (s) => {
if (s < t) {
const i = this.pack(e[s]);
return i instanceof Promise ? i.then(() => n(s + 1)) : n(s + 1);
}
};
return n(0);
}
pack_integer(e) {
if (e >= -32 && e <= 127)
this._bufferBuilder.append(e & 255);
else if (e >= 0 && e <= 255)
this._bufferBuilder.append(204), this.pack_uint8(e);
else if (e >= -128 && e <= 127)
this._bufferBuilder.append(208), this.pack_int8(e);
else if (e >= 0 && e <= 65535)
this._bufferBuilder.append(205), this.pack_uint16(e);
else if (e >= -32768 && e <= 32767)
this._bufferBuilder.append(209), this.pack_int16(e);
else if (e >= 0 && e <= 4294967295)
this._bufferBuilder.append(206), this.pack_uint32(e);
else if (e >= -2147483648 && e <= 2147483647)
this._bufferBuilder.append(210), this.pack_int32(e);
else if (e >= -9223372036854776e3 && e <= 9223372036854776e3)
this._bufferBuilder.append(211), this.pack_int64(e);
else if (e >= 0 && e <= 18446744073709552e3)
this._bufferBuilder.append(207), this.pack_uint64(e);
else
throw new Error("Invalid integer");
}
pack_double(e) {
let t = 0;
e < 0 && (t = 1, e = -e);
const n = Math.floor(Math.log(e) / Math.LN2), s = e / 2 ** n - 1, i = Math.floor(s * 2 ** 52), o = 2 ** 32, a = t << 31 | n + 1023 << 20 | i / o & 1048575, c = i % o;
this._bufferBuilder.append(203), this.pack_int32(a), this.pack_int32(c);
}
pack_object(e) {
const t = Object.keys(e), n = t.length;
if (n <= 15)
this.pack_uint8(128 + n);
else if (n <= 65535)
this._bufferBuilder.append(222), this.pack_uint16(n);
else if (n <= 4294967295)
this._bufferBuilder.append(223), this.pack_uint32(n);
else
throw new Error("Invalid length");
const s = (i) => {
if (i < t.length) {
const o = t[i];
if (e.hasOwnProperty(o)) {
this.pack(o);
const a = this.pack(e[o]);
if (a instanceof Promise)
return a.then(() => s(i + 1));
}
return s(i + 1);
}
};
return s(0);
}
pack_uint8(e) {
this._bufferBuilder.append(e);
}
pack_uint16(e) {
this._bufferBuilder.append(e >> 8), this._bufferBuilder.append(e & 255);
}
pack_uint32(e) {
const t = e & 4294967295;
this._bufferBuilder.append((t & 4278190080) >>> 24), this._bufferBuilder.append((t & 16711680) >>> 16), this._bufferBuilder.append((t & 65280) >>> 8), this._bufferBuilder.append(t & 255);
}
pack_uint64(e) {
const t = e / 4294967296, n = e % 2 ** 32;
this._bufferBuilder.append((t & 4278190080) >>> 24), this._bufferBuilder.append((t & 16711680) >>> 16), this._bufferBuilder.append((t & 65280) >>> 8), this._bufferBuilder.append(t & 255), this._bufferBuilder.append((n & 4278190080) >>> 24), this._bufferBuilder.append((n & 16711680) >>> 16), this._bufferBuilder.append((n & 65280) >>> 8), this._bufferBuilder.append(n & 255);
}
pack_int8(e) {
this._bufferBuilder.append(e & 255);
}
pack_int16(e) {
this._bufferBuilder.append((e & 65280) >> 8), this._bufferBuilder.append(e & 255);
}
pack_int32(e) {
this._bufferBuilder.append(e >>> 24 & 255), this._bufferBuilder.append((e & 16711680) >>> 16), this._bufferBuilder.append((e & 65280) >>> 8), this._bufferBuilder.append(e & 255);
}
pack_int64(e) {
const t = Math.floor(e / 4294967296), n = e % 2 ** 32;
this._bufferBuilder.append((t & 4278190080) >>> 24), this._bufferBuilder.append((t & 16711680) >>> 16), this._bufferBuilder.append((t & 65280) >>> 8), this._bufferBuilder.append(t & 255), this._bufferBuilder.append((n & 4278190080) >>> 24), this._bufferBuilder.append((n & 16711680) >>> 16), this._bufferBuilder.append((n & 65280) >>> 8), this._bufferBuilder.append(n & 255);
}
constructor() {
this._bufferBuilder = new cn(), this._textEncoder = new TextEncoder();
}
}
let it = !0, ot = !0;
function X(r, e, t) {
const n = r.match(e);
return n && n.length >= t && parseInt(n[t], 10);
}
function M(r, e, t) {
if (!r.RTCPeerConnection)
return;
const n = r.RTCPeerConnection.prototype, s = n.addEventListener;
n.addEventListener = function(o, a) {
if (o !== e)
return s.apply(this, arguments);
const c = (f) => {
const h = t(f);
h && (a.handleEvent ? a.handleEvent(h) : a(h));
};
return this._eventMap = this._eventMap || {}, this._eventMap[e] || (this._eventMap[e] = /* @__PURE__ */ new Map()), this._eventMap[e].set(a, c), s.apply(this, [
o,
c
]);
};
const i = n.removeEventListener;
n.removeEventListener = function(o, a) {
if (o !== e || !this._eventMap || !this._eventMap[e])
return i.apply(this, arguments);
if (!this._eventMap[e].has(a))
return i.apply(this, arguments);
const c = this._eventMap[e].get(a);
return this._eventMap[e].delete(a), this._eventMap[e].size === 0 && delete this._eventMap[e], Object.keys(this._eventMap).length === 0 && delete this._eventMap, i.apply(this, [
o,
c
]);
}, Object.defineProperty(n, "on" + e, {
get() {
return this["_on" + e];
},
set(o) {
this["_on" + e] && (this.removeEventListener(
e,
this["_on" + e]
), delete this["_on" + e]), o && this.addEventListener(
e,
this["_on" + e] = o
);
},
enumerable: !0,
configurable: !0
});
}
function pn(r) {
return typeof r != "boolean" ? new Error("Argument type: " + typeof r + ". Please use a boolean.") : (it = r, r ? "adapter.js logging disabled" : "adapter.js logging enabled");
}
function un(r) {
return typeof r != "boolean" ? new Error("Argument type: " + typeof r + ". Please use a boolean.") : (ot = !r, "adapter.js deprecation warnings " + (r ? "disabled" : "enabled"));
}
function at() {
if (typeof window == "object") {
if (it)
return;
typeof console < "u" && typeof console.log == "function" && console.log.apply(console, arguments);
}
}
function Me(r, e) {
ot && console.warn(r + " is deprecated, please use " + e + " instead.");
}
function dn(r) {
const e = { browser: null, version: null };
if (typeof r > "u" || !r.navigator || !r.navigator.userAgent)
return e.browser = "Not a browser.", e;
const { navigator: t } = r;
if (t.userAgentData && t.userAgentData.brands) {
const n = t.userAgentData.brands.find((s) => s.brand === "Chromium");
if (n)
return { browser: "chrome", version: parseInt(n.version, 10) };
}
if (t.mozGetUserMedia)
e.browser = "firefox", e.version = X(
t.userAgent,
/Firefox\/(\d+)\./,
1
);
else if (t.webkitGetUserMedia || r.isSecureContext === !1 && r.webkitRTCPeerConnection)
e.browser = "chrome", e.version = X(
t.userAgent,
/Chrom(e|ium)\/(\d+)\./,
2
);
else if (r.RTCPeerConnection && t.userAgent.match(/AppleWebKit\/(\d+)\./))
e.browser = "safari", e.version = X(
t.userAgent,
/AppleWebKit\/(\d+)\./,
1
), e.supportsUnifiedPlan = r.RTCRtpTransceiver && "currentDirection" in r.RTCRtpTransceiver.prototype;
else
return e.browser = "Not a supported browser.", e;
return e;
}
function Ve(r) {
return Object.prototype.toString.call(r) === "[object Object]";
}
function ct(r) {
return Ve(r) ? Object.keys(r).reduce(function(e, t) {
const n = Ve(r[t]), s = n ? ct(r[t]) : r[t], i = n && !Object.keys(s).length;
return s === void 0 || i ? e : Object.assign(e, { [t]: s });
}, {}) : r;
}
function ye(r, e, t) {
!e || t.has(e.id) || (t.set(e.id, e), Object.keys(e).forEach((n) => {
n.endsWith("Id") ? ye(r, r.get(e[n]), t) : n.endsWith("Ids") && e[n].forEach((s) => {
ye(r, r.get(s), t);
});
}));
}
function qe(r, e, t) {
const n = t ? "outbound-rtp" : "inbound-rtp", s = /* @__PURE__ */ new Map();
if (e === null)
return s;
const i = [];
return r.forEach((o) => {
o.type === "track" && o.trackIdentifier === e.id && i.push(o);
}), i.forEach((o) => {
r.forEach((a) => {
a.type === n && a.trackId === o.id && ye(r, a, s);
});
}), s;
}
const Je = at;
function ht(r, e) {
const t = r && r.navigator;
if (!t.mediaDevices)
return;
const n = function(a) {
if (typeof a != "object" || a.mandatory || a.optional)
return a;
const c = {};
return Object.keys(a).forEach((f) => {
if (f === "require" || f === "advanced" || f === "mediaSource")
return;
const h = typeof a[f] == "object" ? a[f] : { ideal: a[f] };
h.exact !== void 0 && typeof h.exact == "number" && (h.min = h.max = h.exact);
const l = function(p, d) {
return p ? p + d.charAt(0).toUpperCase() + d.slice(1) : d === "deviceId" ? "sourceId" : d;
};
if (h.ideal !== void 0) {
c.optional = c.optional || [];
let p = {};
typeof h.ideal == "number" ? (p[l("min", f)] = h.ideal, c.optional.push(p), p = {}, p[l("max", f)] = h.ideal, c.optional.push(p)) : (p[l("", f)] = h.ideal, c.optional.push(p));
}
h.exact !== void 0 && typeof h.exact != "number" ? (c.mandatory = c.mandatory || {}, c.mandatory[l("", f)] = h.exact) : ["min", "max"].forEach((p) => {
h[p] !== void 0 && (c.mandatory = c.mandatory || {}, c.mandatory[l(p, f)] = h[p]);
});
}), a.advanced && (c.optional = (c.optional || []).concat(a.advanced)), c;
}, s = function(a, c) {
if (e.version >= 61)
return c(a);
if (a = JSON.parse(JSON.stringify(a)), a && typeof a.audio == "object") {
const f = function(h, l, p) {
l in h && !(p in h) && (h[p] = h[l], delete h[l]);
};
a = JSON.parse(JSON.stringify(a)), f(a.audio, "autoGainControl", "googAutoGainControl"), f(a.audio, "noiseSuppression", "googNoiseSuppression"), a.audio = n(a.audio);
}
if (a && typeof a.video == "object") {
let f = a.video.facingMode;
f = f && (typeof f == "object" ? f : { ideal: f });
const h = e.version < 66;
if (f && (f.exact === "user" || f.exact === "environment" || f.ideal === "user" || f.ideal === "environment") && !(t.mediaDevices.getSupportedConstraints && t.mediaDevices.getSupportedConstraints().facingMode && !h)) {
delete a.video.facingMode;
let l;
if (f.exact === "environment" || f.ideal === "environment" ? l = ["back", "rear"] : (f.exact === "user" || f.ideal === "user") && (l = ["front"]), l)
return t.mediaDevices.enumerateDevices().then((p) => {
p = p.filter((_) => _.kind === "videoinput");
let d = p.find((_) => l.some((v) => _.label.toLowerCase().includes(v)));
return !d && p.length && l.includes("back") && (d = p[p.length - 1]), d && (a.video.deviceId = f.exact ? { exact: d.deviceId } : { ideal: d.deviceId }), a.video = n(a.video), Je("chrome: " + JSON.stringify(a)), c(a);
});
}
a.video = n(a.video);
}
return Je("chrome: " + JSON.stringify(a)), c(a);
}, i = function(a) {
return e.version >= 64 ? a : {
name: {
PermissionDeniedError: "NotAllowedError",
PermissionDismissedError: "NotAllowedError",
InvalidStateError: "NotAllowedError",
DevicesNotFoundError: "NotFoundError",
ConstraintNotSatisfiedError: "OverconstrainedError",
TrackStartError: "NotReadableError",
MediaDeviceFailedDueToShutdown: "NotAllowedError",
MediaDeviceKillSwitchOn: "NotAllowedError",
TabCaptureError: "AbortError",
ScreenCaptureError: "AbortError",
DeviceCaptureError: "AbortError"
}[a.name] || a.name,
message: a.message,
constraint: a.constraint || a.constraintName,
toString() {
return this.name + (this.message && ": ") + this.message;
}
};
}, o = function(a, c, f) {
s(a, (h) => {
t.webkitGetUserMedia(h, c, (l) => {
f && f(i(l));
});
});
};
if (t.getUserMedia = o.bind(t), t.mediaDevices.getUserMedia) {
const a = t.mediaDevices.getUserMedia.bind(t.mediaDevices);
t.mediaDevices.getUserMedia = function(c) {
return s(c, (f) => a(f).then((h) => {
if (f.audio && !h.getAudioTracks().length || f.video && !h.getVideoTracks().length)
throw h.getTracks().forEach((l) => {
l.stop();
}), new DOMException("", "NotFoundError");
return h;
}, (h) => Promise.reject(i(h))));
};
}
}
function ft(r) {
r.MediaStream = r.MediaStream || r.webkitMediaStream;
}
function lt(r) {
if (typeof r == "object" && r.RTCPeerConnection && !("ontrack" in r.RTCPeerConnection.prototype)) {
Object.defineProperty(r.RTCPeerConnection.prototype, "ontrack", {
get() {
return this._ontrack;
},
set(t) {
this._ontrack && this.removeEventListener("track", this._ontrack), this.addEventListener("track", this._ontrack = t);
},
enumerable: !0,
configurable: !0
});
const e = r.RTCPeerConnection.prototype.setRemoteDescription;
r.RTCPeerConnection.prototype.setRemoteDescription = function() {
return this._ontrackpoly || (this._ontrackpoly = (n) => {
n.stream.addEventListener("addtrack", (s) => {
let i;
r.RTCPeerConnection.prototype.getReceivers ? i = this.getReceivers().find((a) => a.track && a.track.id === s.track.id) : i = { track: s.track };
const o = new Event("track");
o.track = s.track, o.receiver = i, o.transceiver = { receiver: i }, o.streams = [n.stream], this.dispatchEvent(o);
}), n.stream.getTracks().forEach((s) => {
let i;
r.RTCPeerConnection.prototype.getReceivers ? i = this.getReceivers().find((a) => a.track && a.track.id === s.id) : i = { track: s };
const o = new Event("track");
o.track = s, o.receiver = i, o.transceiver = { receiver: i }, o.streams = [n.stream], this.dispatchEvent(o);
});
}, this.addEventListener("addstream", this._ontrackpoly)), e.apply(this, arguments);
};
} else
M(r, "track", (e) => (e.transceiver || Object.defineProperty(
e,
"transceiver",
{ value: { receiver: e.receiver } }
), e));
}
function pt(r) {
if (typeof r == "object" && r.RTCPeerConnection && !("getSenders" in r.RTCPeerConnection.prototype) && "createDTMFSender" in r.RTCPeerConnection.prototype) {
const e = function(s, i) {
return {
track: i,
get dtmf() {
return this._dtmf === void 0 && (i.kind === "audio" ? this._dtmf = s.createDTMFSender(i) : this._dtmf = null), this._dtmf;
},
_pc: s
};
};
if (!r.RTCPeerConnection.prototype.getSenders) {
r.RTCPeerConnection.prototype.getSenders = function() {
return this._senders = this._senders || [], this._senders.slice();
};
const s = r.RTCPeerConnection.prototype.addTrack;
r.RTCPeerConnection.prototype.addTrack = function(a, c) {
let f = s.apply(this, arguments);
return f || (f = e(this, a), this._senders.push(f)), f;
};
const i = r.RTCPeerConnection.prototype.removeTrack;
r.RTCPeerConnection.prototype.removeTrack = function(a) {
i.apply(this, arguments);
const c = this._senders.indexOf(a);
c !== -1 && this._senders.splice(c, 1);
};
}
const t = r.RTCPeerConnection.prototype.addStream;
r.RTCPeerConnection.prototype.addStream = function(i) {
this._senders = this._senders || [], t.apply(this, [i]), i.getTracks().forEach((o) => {
this._senders.push(e(this, o));
});
};
const n = r.RTCPeerConnection.prototype.removeStream;
r.RTCPeerConnection.prototype.removeStream = function(i) {
this._senders = this._senders || [], n.apply(this, [i]), i.getTracks().forEach((o) => {
const a = this._senders.find((c) => c.track === o);
a && this._senders.splice(this._senders.indexOf(a), 1);
});
};
} else if (typeof r == "object" && r.RTCPeerConnection && "getSenders" in r.RTCPeerConnection.prototype && "createDTMFSender" in r.RTCPeerConnection.prototype && r.RTCRtpSender && !("dtmf" in r.RTCRtpSender.prototype)) {
const e = r.RTCPeerConnection.prototype.getSenders;
r.RTCPeerConnection.prototype.getSenders = function() {
const n = e.apply(this, []);
return n.forEach((s) => s._pc = this), n;
}, Object.defineProperty(r.RTCRtpSender.prototype, "dtmf", {
get() {
return this._dtmf === void 0 && (this.track.kind === "audio" ? this._dtmf = this._pc.createDTMFSender(this.track) : this._dtmf = null), this._dtmf;
}
});
}
}
function ut(r) {
if (!(typeof r == "object" && r.RTCPeerConnection && r.RTCRtpSender && r.RTCRtpReceiver))
return;
if (!("getStats" in r.RTCRtpSender.prototype)) {
const t = r.RTCPeerConnection.prototype.getSenders;
t && (r.RTCPeerConnection.prototype.getSenders = function() {
const i = t.apply(this, []);
return i.forEach((o) => o._pc = this), i;
});
const n = r.RTCPeerConnection.prototype.addTrack;
n && (r.RTCPeerConnection.prototype.addTrack = function() {
const i = n.apply(this, arguments);
return i._pc = this, i;
}), r.RTCRtpSender.prototype.getStats = function() {
const i = this;
return this._pc.getStats().then((o) => (
/* Note: this will include stats of all senders that
* send a track with the same id as sender.track as
* it is not possible to identify the RTCRtpSender.
*/
qe(o, i.track, !0)
));
};
}
if (!("getStats" in r.RTCRtpReceiver.prototype)) {
const t = r.RTCPeerConnection.prototype.getReceivers;
t && (r.RTCPeerConnection.prototype.getReceivers = function() {
const s = t.apply(this, []);
return s.forEach((i) => i._pc = this), s;
}), M(r, "track", (n) => (n.receiver._pc = n.srcElement, n)), r.RTCRtpReceiver.prototype.getStats = function() {
const s = this;
return this._pc.getStats().then((i) => qe(i, s.track, !1));
};
}
if (!("getStats" in r.RTCRtpSender.prototype && "getStats" in r.RTCRtpReceiver.prototype))
return;
const e = r.RTCPeerConnection.prototype.getStats;
r.RTCPeerConnection.prototype.getStats = function() {
if (arguments.length > 0 && arguments[0] instanceof r.MediaStreamTrack) {
const n = arguments[0];
let s, i, o;
return this.getSenders().forEach((a) => {
a.track === n && (s ? o = !0 : s = a);
}), this.getReceivers().forEach((a) => (a.track === n && (i ? o = !0 : i = a), a.track === n)), o || s && i ? Promise.reject(new DOMException(
"There are more than one sender or receiver for the track.",
"InvalidAccessError"
)) : s ? s.getStats() : i ? i.getStats() : Promise.reject(new DOMException(
"There is no sender or receiver for the track.",
"InvalidAccessError"
));
}
return e.apply(this, arguments);
};
}
function dt(r) {
r.RTCPeerConnection.prototype.getLocalStreams = function() {
return this._shimmedLocalStreams = this._shimmedLocalStreams || {}, Object.keys(this._shimmedLocalStreams).map((o) => this._shimmedLocalStreams[o][0]);
};
const e = r.RTCPeerConnection.prototype.addTrack;
r.RTCPeerConnection.prototype.addTrack = function(o, a) {
if (!a)
return e.apply(this, arguments);
this._shimmedLocalStreams = this._shimmedLocalStreams || {};
const c = e.apply(this, arguments);
return this._shimmedLocalStreams[a.id] ? this._shimmedLocalStreams[a.id].indexOf(c) === -1 && this._shimmedLocalStreams[a.id].push(c) : this._shimmedLocalStreams[a.id] = [a, c], c;
};
const t = r.RTCPeerConnection.prototype.addStream;
r.RTCPeerConnection.prototype.addStream = function(o) {
this._shimmedLocalStreams = this._shimmedLocalStreams || {}, o.getTracks().forEach((f) => {
if (this.getSenders().find((l) => l.track === f))
throw new DOMException(
"Track already exists.",
"InvalidAccessError"
);
});
const a = this.getSenders();
t.apply(this, arguments);
const c = this.getSenders().filter((f) => a.indexOf(f) === -1);
this._shimmedLocalStreams[o.id] = [o].concat(c);
};
const n = r.RTCPeerConnection.prototype.removeStream;
r.RTCPeerConnection.prototype.removeStream = function(o) {
return this._shimmedLocalStreams = this._shimmedLocalStreams || {}, delete this._shimmedLocalStreams[o.id], n.apply(this, arguments);
};
const s = r.RTCPeerConnection.prototype.removeTrack;
r.RTCPeerConnection.prototype.removeTrack = function(o) {
return this._shimmedLocalStreams = this._shimmedLocalStreams || {}, o && Object.keys(this._shimmedLocalStreams).forEach((a) => {
const c = this._shimmedLocalStreams[a].indexOf(o);
c !== -1 && this._shimmedLocalStreams[a].splice(c, 1), this._shimmedLocalStreams[a].length === 1 && delete this._shimmedLocalStreams[a];
}), s.apply(this, arguments);
};
}
function mt(r, e) {
if (!r.RTCPeerConnection)
return;
if (r.RTCPeerConnection.prototype.addTrack && e.version >= 65)
return dt(r);
const t = r.RTCPeerConnection.prototype.getLocalStreams;
r.RTCPeerConnection.prototype.getLocalStreams = function() {
const h = t.apply(this);
return this._reverseStreams = this._reverseStreams || {}, h.map((l) => this._reverseStreams[l.id]);
};
const n = r.RTCPeerConnection.prototype.addStream;
r.RTCPeerConnection.prototype.addStream = function(h) {
if (this._streams = this._streams || {}, this._reverseStreams = this._reverseStreams || {}, h.getTracks().forEach((l) => {
if (this.getSenders().find((d) => d.track === l))
throw new DOMException(
"Track already exists.",
"InvalidAccessError"
);
}), !this._reverseStreams[h.id]) {
const l = new r.MediaStream(h.getTracks());
this._streams[h.id] = l, this._reverseStreams[l.id] = h, h = l;
}
n.apply(this, [h]);
};
const s = r.RTCPeerConnection.prototype.removeStream;
r.RTCPeerConnection.prototype.removeStream = function(h) {
this._streams = this._streams || {}, this._reverseStreams = this._reverseStreams || {}, s.apply(this, [this._streams[h.id] || h]), delete this._reverseStreams[this._streams[h.id] ? this._streams[h.id].id : h.id], delete this._streams[h.id];
}, r.RTCPeerConnection.prototype.addTrack = function(h, l) {
if (this.signalingState === "closed")
throw new DOMException(
"The RTCPeerConnection's signalingState is 'closed'.",
"InvalidStateError"
);
const p = [].slice.call(arguments, 1);
if (p.length !== 1 || !p[0].getTracks().find((v) => v === h))
throw new DOMException(
"The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.",
"NotSupportedError"
);
if (this.getSenders().find((v) => v.track === h))
throw new DOMException(
"Track already exists.",
"InvalidAccessError"
);
this._streams = this._streams || {}, this._reverseStreams = this._reverseStreams || {};
const _ = this._streams[l.id];
if (_)
_.addTrack(h), Promise.resolve().then(() => {
this.dispatchEvent(new Event("negotiationneeded"));
});
else {
const v = new r.MediaStream([h]);
this._streams[l.id] = v, this._reverseStreams[v.id] = l, this.addStream(v);
}
return this.getSenders().find((v) => v.track === h);
};
function i(f, h) {
let l = h.sdp;
return Object.keys(f._reverseStreams || []).forEach((p) => {
const d = f._reverseStreams[p], _ = f._streams[d.id];
l = l.replace(
new RegExp(_.id, "g"),
d.id
);
}), new RTCSessionDescription({
type: h.type,
sdp: l
});
}
function o(f, h) {
let l = h.sdp;
return Object.keys(f._reverseStreams || []).forEach((p) => {
const d = f._reverseStreams[p], _ = f._streams[d.id];
l = l.replace(
new RegExp(d.id, "g"),
_.id
);
}), new RTCSessionDescription({
type: h.type,
sdp: l
});
}
["createOffer", "createAnswer"].forEach(function(f) {
const h = r.RTCPeerConnection.prototype[f], l = { [f]() {
const p = arguments;
return arguments.length && typeof arguments[0] == "function" ? h.apply(this, [
(_) => {
const v = i(this, _);
p[0].apply(null, [v]);
},
(_) => {
p[1] && p[1].apply(null, _);
},
arguments[2]
]) : h.apply(this, arguments).then((_) => i(this, _));
} };
r.RTCPeerConnection.prototype[f] = l[f];
});
const a = r.RTCPeerConnection.prototype.setLocalDescription;
r.RTCPeerConnection.prototype.setLocalDescription = function() {
return !arguments.length || !arguments[0].type ? a.apply(this, arguments) : (arguments[0] = o(this, arguments[0]), a.apply(this, arguments));
};
const c = Object.getOwnPropertyDescriptor(
r.RTCPeerConnection.prototype,
"localDescription"
);
Object.defineProperty(
r.RTCPeerConnection.prototype,
"localDescription",
{
get() {
const f = c.get.apply(this);
return f.type === "" ? f : i(this, f);
}
}
), r.RTCPeerConnection.prototype.removeTrack = function(h) {
if (this.signalingState === "closed")
throw new DOMException(
"The RTCPeerConnection's signalingState is 'closed'.",
"InvalidStateError"
);
if (!h._pc)
throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.", "TypeError");
if (!(h._pc === this))
throw new DOMException(
"Sender was not created by this connection.",
"InvalidAccessError"
);
this._streams = this._streams || {};
let p;
Object.keys(this._streams).forEach((d) => {
this._streams[d].getTracks().find((v) => h.track === v) && (p = this._streams[d]);
}), p && (p.getTracks().length === 1 ? this.removeStream(this._reverseStreams[p.id]) : p.removeTrack(h.track), this.dispatchEvent(new Event("negotiationneeded")));
};
}
function _e(r, e) {
!r.RTCPeerConnection && r.webkitRTCPeerConnection && (r.RTCPeerConnection = r.webkitRTCPeerConnection), r.RTCPeerConnection && e.version < 53 && ["setLocalDescription", "setRemoteDescription", "addIceCandidate"].forEach(function(t) {
const n = r.RTCPeerConnection.prototype[t], s = { [t]() {
return arguments[0] = new (t === "addIceCandidate" ? r.RTCIceCandidate : r.RTCSessionDescription)(arguments[0]), n.apply(this, arguments);
} };
r.RTCPeerConnection.prototype[t] = s[t];
});
}
function gt(r, e) {
M(r, "negotiationneeded", (t) => {
const n = t.target;
if (!((e.version < 72 || n.getConfiguration && n.getConfiguration().sdpSemantics === "plan-b") && n.signalingState !== "stable"))
return t;
});
}
const Ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
fixNegotiationNeeded: gt,
shimAddTrackRemoveTrack: mt,
shimAddTrackRemoveTrackWithNative: dt,
shimGetSendersWithDtmf: pt,
shimGetUserMedia: ht,
shimMediaStream: ft,
shimOnTrack: lt,
shimPeerConnection: _e,
shimSenderReceiverGetStats: ut
}, Symbol.toStringTag, { value: "Module" }));
function yt(r, e) {
const t = r && r.navigator, n = r && r.MediaStreamTrack;
if (t.getUserMedia = function(s, i, o) {
Me(
"navigator.getUserMedia",
"navigator.mediaDevices.getUserMedia"
), t.mediaDevices.getUserMedia(s).then(i, o);
}, !(e.version > 55 && "autoGainControl" in t.mediaDevices.getSupportedConstraints())) {
const s = function(o, a, c) {
a in o && !(c in o) && (o[c] = o[a], delete o[a]);
}, i = t.mediaDevices.getUserMedia.bind(t.mediaDevices);
if (t.mediaDevices.getUserMedia = function(o) {
return typeof o == "object" && typeof o.audio == "object" && (o = JSON.parse(JSON.stringify(o)), s(o.audio, "autoGainControl", "mozAutoGainControl"), s(o.audio, "noiseSuppression", "mozNoiseSuppression")), i(o);
}, n && n.prototype.getSettings) {
const o = n.prototype.getSettings;
n.prototype.getSettings = function() {
const a = o.apply(this, arguments);
return s(a, "mozAutoGainControl", "autoGainControl"), s(a, "mozNoiseSuppression", "noiseSuppression"), a;
};
}
if (n && n.prototype.applyConstraints) {
const o = n.prototype.applyConstraints;
n.prototype.applyConstraints = function(a) {
return this.kind === "audio" && typeof a == "object" && (a = JSON.parse(JSON.stringify(a)), s(a, "autoGainControl", "mozAutoGainControl"), s(a, "noiseSuppression", "mozNoiseSuppression")), o.apply(this, [a]);
};
}
}
}
function mn(r, e) {
r.navigator.mediaDevices && "getDisplayMedia" in r.navigator.mediaDevices || r.navigator.mediaDevices && (r.navigator.mediaDevices.getDisplayMedia = function(n) {
if (!(n && n.video)) {
const s = new DOMException("getDisplayMedia without video constraints is undefined");
return s.name = "NotFoundError", s.code = 8, Promise.reject(s);
}
return n.video === !0 ? n.video = { mediaSource: e } : n.video.mediaSource = e, r.navigator.mediaDevices.getUserMedia(n);
});
}
function _t(r) {
typeof r == "object" && r.RTCTrackEvent && "receiver" in r.RTCTrackEvent.prototype && !("transceiver" in r.RTCTrackEvent.prototype) && Object.defineProperty(r.RTCTrackEvent.prototype, "transceiver", {
get() {
return { receiver: this.receiver };
}
});
}
function be(r, e) {
if (typeof r != "object" || !(r.RTCPeerConnection || r.mozRTCPeerConnection))
return;
!r.RTCPeerConnection && r.mozRTCPeerConnection && (r.RTCPeerConnection = r.mozRTCPeerConnection), e.version < 53 && ["setLocalDescription", "setRemoteDescription", "addIceCandidate"].forEach(function(s) {
const i = r.RTCPeerConnection.prototype[s], o = { [s]() {
return arguments[0] = new (s === "addIceCandidate" ? r.RTCIceCandidate : r.RTCSessionDescription)(arguments[0]), i.apply(this, arguments);
} };
r.RTCPeerConnection.prototype[s] = o[s];
});
const t = {
inboundrtp: "inbound-rtp",
outboundrtp: "outbound-rtp",
candidatepair: "candidate-pair",
localcandidate: "local-candidate",
remotecandidate: "remote-candidate"
}, n = r.RTCPeerConnection.prototype.getStats;
r.RTCPeerConnection.prototype.getStats = function() {
const [i, o, a] = arguments;
return n.apply(this, [i || null]).then((c) => {
if (e.version < 53 && !o)
try {
c.forEach((f) => {
f.type = t[f.type] || f.type;
});
} catch (f) {
if (f.name !== "TypeError")
throw f;
c.forEach((h, l) => {
c.set(l, Object.assign({}, h, {
type: t[h.type] || h.type
}));
});
}
return c;
}).then(o, a);
};
}
function bt(r) {
if (!(typeof r == "object" && r.RTCPeerConnection && r.RTCRtpSender) || r.RTCRtpSender && "getStats" in r.RTCRtpSender.prototype)
return;
const e = r.RTCPeerConnection.prototype.getSenders;
e && (r.RTCPeerConnection.prototype.getSenders = function() {
const s = e.apply(this, []);
return s.forEach((i) => i._pc = this), s;
});
const t = r.RTCPeerConnection.prototype.addTrack;
t && (r.RTCPeerConnection.prototype.addTrack = function() {
const s = t.apply(this, arguments);
return s._pc = this, s;
}), r.RTCRtpSender.prototype.getStats = function() {
return this.track ? this._pc.getStats(this.track) : Promise.resolve(/* @__PURE__ */ new Map());
};
}
function Ct(r) {
if (!(typeof r == "object" && r.RTCPeerConnection && r.RTCRtpSender) || r.RTCRtpSender && "getStats" in r.RTCRtpReceiver.prototype)
return;
const e = r.RTCPeerConnection.prototype.getReceivers;
e && (r.RTCPeerConnection.prototype.getReceivers = function() {
const n = e.apply(this, []);
return n.forEach((s) => s._pc = this), n;
}), M(r, "track", (t) => (t.receiver._pc = t.srcElement, t)), r.RTCRtpReceiver.prototype.getStats = function() {
return this._pc.getStats(this.track);
};
}
function vt(r) {
!r.RTCPeerConnection || "removeStream" in r.RTCPeerConnection.prototype || (r.RTCPeerConnection.prototype.removeStream = function(t) {
Me("removeStream", "removeTrack"), this.getSenders().forEach((n) => {
n.track && t.getTracks().includes(n.track) && this.removeTrack(n);
});
});
}
function kt(r) {
r.DataChannel && !r.RTCDataChannel && (r.RTCDataChannel = r.DataChannel);
}
function St(r) {
if (!(typeof r == "object" && r.RTCPeerConnection))
return;
const e = r.RTCPeerConnection.prototype.addTransceiver;
e && (r.RTCPeerConnection.prototype.addTransceiver = function() {
this.setParametersPromises = [];
let n = arguments[1] && arguments[1].sendEncodings;
n === void 0 && (n = []), n = [...n];
const s = n.length > 0;
s && n.forEach((o) => {
if ("rid" in o && !/^[a-z0-9]{0,16}$/i.test(o.rid))
throw new TypeError("Invalid RID value provided.");
if ("scaleResolutionDownBy" in o && !(parseFloat(o.scaleResolutionDownBy) >= 1))
throw new RangeError("scale_resolution_down_by must be >= 1.0");
if ("maxFramerate" in o && !(parseFloat(o.maxFramerate) >= 0))
throw new RangeError("max_framerate must be >= 0.0");
});
const i = e.apply(this, arguments);
if (s) {
const { sender: o } = i, a = o.getParameters();
(!("encodings" in a) || // Avoid being fooled by patched getParameters() below.
a.encodings.length === 1 && Object.keys(a.encodings[0]).length === 0) && (a.encodings = n, o.sendEncodings = n, this.setParametersPromises.push(
o.setParameters(a).then(() => {
delete o.sendEncodings;
}).catch(() => {
delete o.sendEncodings;
})
));
}
return i;
});
}
function Tt(r) {
if (!(typeof r == "object" && r.RTCRtpSender))
return;
const e = r.RTCRtpSender.prototype.getParameters;
e && (r.RTCRtpSender.prototype.getParameters = function() {
const n = e.apply(this, arguments);
return "encodings" in n || (n.encodings = [].concat(this.sendEncodings || [{}])), n;
});
}
function Rt(r) {
if (!(typeof r == "object" && r.RTCPeerConnection))
return;
const e = r.RTCPeerConnection.prototype.createOffer;
r.RTCPeerConnection.prototype.createOffer = function() {
return this.setParametersPromises && this.setParametersPromises.length ? Promise.all(this.setParametersPromises).then(() => e.apply(this, arguments)).finally(() => {
this.setParametersPromises = [];
}) : e.apply(this, arguments);
};
}
function Et(r) {
if (!(typeof r == "object" && r.RTCPeerConnection))
return;
const e = r.RTCPeerConnection.prototype.createAnswer;
r.RTCPeerConnection.prototype.createAnswer = function() {
return this.setParametersPromises && this.setParametersPromises.length ? Promise.all(this.setParametersPromises).then(() => e.apply(this, arguments)).finally(() => {
this.setParametersPromises = [];
}) : e.apply(this, arguments);
};
}
const He = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
shimAddTransceiver: St,
shimCreateAnswer: Et,
shimCreateOffer: Rt,
shimGetDisplayMedia: mn,
shimGetParameters: Tt,
shimGetUserMedia: yt,
shimOnTrack: _t,
shimPeerConnection: be,
shimRTCDataChannel: kt,
shimReceiverGetStats: Ct,
shimRemoveStream: vt,
shimSenderGetStats: bt
}, Symbol.toStringTag, { value: "Module" }));
function xt(r) {
if (!(typeof r != "object" || !r.RTCPeerConnection)) {
if ("getLocalStreams" in r.RTCPeerConnection.prototype || (r.RTCPeerConnection.prototype.getLocalStreams = function() {
return this._localStreams || (this._localStreams = []), this._localStreams;
}), !("addStream" in r.RTCPeerConnection.prototype)) {
const e = r.RTCPeerConnection.prototype.addTrack;
r.RTCPeerConnection.prototype.addStream = function(n) {
this._localStreams || (this._localStreams = []), this._localStreams.includes(n) || this._localStreams.push(n), n.getAudioTracks().forEach((s) => e.call(
this,
s,
n
)), n.getVideoTracks().forEach((s) => e.call(
this,
s,
n
));
}, r.RTCPeerConnection.prototype.addTrack = function(n, ...s) {
return s && s.forEach((i) => {
this._localStreams ? this._localStreams.includes(i) || this._localStreams.push(i) : this._localStreams = [i];
}), e.apply(this, arguments);
};
}
"removeStream" in r.RTCPeerConnection.prototype || (r.RTCPeerConnection.prototype.removeStream = function(t) {
this._localStreams || (this._localStreams = []);
const n = this._localStreams.indexOf(t);
if (n === -1)
return;
this._localStreams.splice(n, 1);
const s = t.getTracks();
this.getSenders().forEach((i) => {
s.includes(i.track) && this.removeTrack(i);
});
});
}
}
function Pt(r) {
if (!(typeof r != "object" || !r.RTCPeerConnection) && ("getRemoteStreams" in r.RTCPeerConnection.prototype || (r.RTCPeerConnection.prototype.getRemoteStreams = function() {
return this._remoteStreams ? this._remoteStreams : [];
}), !("onaddstream" in r.RTCPeerConnection.prototype))) {
Object.defineProperty(r.RTCPeerConnection.prototype, "onaddstream", {
get() {
return this._onaddstream;
},
set(t) {
this._onaddstream && (this.removeEventListener("addstream", this._onaddstream), this.removeEventListener("track", this._onaddstreampoly)), this.addEventListener("addstream", this._onaddstream = t), this.addEventListener("track", this._onaddstreampoly = (n) => {
n.streams.forEach((s) => {
if (this._remoteStreams || (this._remoteStreams = []), this._remoteStreams.includes(s))
return;
this._remoteStreams.push(s);
const i = new Event("addstream");
i.stream = s, this.dispatchEvent(i);
});
});
}
});
const e = r.RTCPeerConnection.prototype.setRemoteDescription;
r.RTCPeerConnection.prototype.setRemoteDescription = function() {
const n = this;
return this._onaddstreampoly || this.addEventListener("track", this._onaddstreampoly = function(s) {
s.streams.forEach((i) => {
if (n._remoteStreams || (n._remoteStreams = []), n._remoteStreams.indexOf(i) >= 0)
return;
n._remoteStreams.push(i);
const o = new Event("addstream");
o.stream = i, n.dispatchEvent(o);
});
}), e.apply(n, arguments);
};
}
}
function Ot(r) {
if (typeof r != "object" || !r.RTCPeerConnection)
return;
const e = r.RTCPeerConnection.prototype, t = e.createOffer, n = e.createAnswer, s = e.setLocalDescription, i = e.setRemoteDescription, o = e.addIceCandidate;
e.createOffer = function(f, h) {
const l = arguments.length >= 2 ? arguments[2] : arguments[0], p = t.apply(this, [l]);
return h ? (p.then(f, h), Promise.resolve()) : p;
}, e.createAnswer = function(f, h) {
const l = arguments.length >= 2 ? arguments[2] : arguments[0], p = n.apply(this, [l]);
return h ? (p.then(f, h), Promise.resolve()) : p;
};
let a = function(c, f, h) {
const l = s.apply(this, [c]);
return h ? (l.then(f, h), Promise.resolve()) : l;
};
e.setLocalDescription = a, a = function(c, f, h) {
const l = i.apply(this, [c]);
return h ? (l.then(f, h), Promise.resolve()) : l;
}, e.setRemoteDescription = a, a = function(c, f, h) {
const l = o.apply(this, [c]);
return h ? (l.then(f, h), Promise.resolve()) : l;
}, e.addIceCandidate = a;
}
function Dt(r) {
const e = r && r.navigator;
if (e.mediaDevices && e.mediaDevices.getUserMedia) {
const t = e.mediaDevices, n = t.getUserMedia.bind(t);
e.mediaDevices.getUserMedia = (s) => n(At(s));
}
!e.getUserMedia && e.mediaDevices && e.mediaDevices.getUserMedia && (e.getUserMedia = (function(n, s, i) {
e.mediaDevices.getUserMedia(n).then(s, i);
}).bind(e));
}
function At(r) {
return r && r.video !== void 0 ? Object.assign(
{},
r,
{ video: ct(r.video) }
) : r;
}
function It(r) {
if (!r.RTCPeerConnection)
return;
const e = r.RTCPeerConnection;
r.RTCPeerConnection = function(n, s) {
if (n && n.iceServers) {
const i = [];
for (let o = 0; o < n.iceServers.length; o++) {
let a = n.iceServers[o];
a.urls === void 0 && a.url ? (Me("RTCIceServer.url", "RTCIceServer.urls"), a = JSON.parse(JSON.stringify(a)), a.urls = a.url, delete a.url, i.push(a)) : i.push(n.iceServers[o]);
}
n.i