@nainudhin/video-meeting-sdk 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/meet-sdk.mjs CHANGED
@@ -1,8 +1,8 @@
1
- var tn = (r) => {
1
+ var nn = (r) => {
2
2
  throw TypeError(r);
3
3
  };
4
- var U = (r, e, t) => e.has(r) ? tn("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t);
5
- function nn(r, e) {
4
+ var U = (r, e, t) => e.has(r) ? nn("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t);
5
+ function rn(r, e) {
6
6
  for (var t = 0; t < e.length; t++) {
7
7
  const n = e[t];
8
8
  if (typeof n != "string" && !Array.isArray(n)) {
@@ -18,7 +18,7 @@ function nn(r, e) {
18
18
  }
19
19
  return Object.freeze(Object.defineProperty(r, Symbol.toStringTag, { value: "Module" }));
20
20
  }
21
- class rn {
21
+ class sn {
22
22
  constructor() {
23
23
  this.encoder = new TextEncoder(), this._pieces = [], this._parts = [];
24
24
  }
@@ -37,10 +37,10 @@ class rn {
37
37
  toArrayBuffer() {
38
38
  const e = [];
39
39
  for (const t of this._parts) e.push(t);
40
- return sn(e).buffer;
40
+ return on(e).buffer;
41
41
  }
42
42
  }
43
- function sn(r) {
43
+ function on(r) {
44
44
  let e = 0;
45
45
  for (const s of r) e += s.byteLength;
46
46
  const t = new Uint8Array(e);
@@ -51,14 +51,14 @@ function sn(r) {
51
51
  }
52
52
  return t;
53
53
  }
54
- function et(r) {
55
- return new on(r).unpack();
56
- }
57
54
  function tt(r) {
58
- const e = new an(), t = e.pack(r);
55
+ return new an(r).unpack();
56
+ }
57
+ function nt(r) {
58
+ const e = new cn(), t = e.pack(r);
59
59
  return t instanceof Promise ? t.then(() => e.getBuffer()) : e.getBuffer();
60
60
  }
61
- class on {
61
+ class an {
62
62
  constructor(e) {
63
63
  this.index = 0, this.dataBuffer = e, this.dataView = new Uint8Array(this.dataBuffer), this.length = this.dataBuffer.byteLength;
64
64
  }
@@ -197,7 +197,7 @@ class on {
197
197
  throw new Error("BinaryPackFailure: read index out of range");
198
198
  }
199
199
  }
200
- class an {
200
+ class cn {
201
201
  getBuffer() {
202
202
  return this._bufferBuilder.toArrayBuffer();
203
203
  }
@@ -344,11 +344,11 @@ class an {
344
344
  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);
345
345
  }
346
346
  constructor() {
347
- this._bufferBuilder = new rn(), this._textEncoder = new TextEncoder();
347
+ this._bufferBuilder = new sn(), this._textEncoder = new TextEncoder();
348
348
  }
349
349
  }
350
- let nt = !0, rt = !0;
351
- function F(r, e, t) {
350
+ let rt = !0, st = !0;
351
+ function j(r, e, t) {
352
352
  const n = r.match(e);
353
353
  return n && n.length >= t && parseFloat(n[t], 10);
354
354
  }
@@ -359,7 +359,7 @@ function D(r, e, t) {
359
359
  EventTarget.prototype,
360
360
  "addEventListener"
361
361
  ).writable) {
362
- Me("Unable to polyfill events");
362
+ Ae("Unable to polyfill events");
363
363
  return;
364
364
  }
365
365
  const s = r.RTCPeerConnection.prototype, i = s.addEventListener;
@@ -403,23 +403,23 @@ function D(r, e, t) {
403
403
  configurable: !0
404
404
  });
405
405
  }
406
- function cn(r) {
407
- return typeof r != "boolean" ? new Error("Argument type: " + typeof r + ". Please use a boolean.") : (nt = r, r ? "adapter.js logging disabled" : "adapter.js logging enabled");
408
- }
409
406
  function hn(r) {
410
- return typeof r != "boolean" ? new Error("Argument type: " + typeof r + ". Please use a boolean.") : (rt = !r, "adapter.js deprecation warnings " + (r ? "disabled" : "enabled"));
407
+ return typeof r != "boolean" ? new Error("Argument type: " + typeof r + ". Please use a boolean.") : (rt = r, r ? "adapter.js logging disabled" : "adapter.js logging enabled");
411
408
  }
412
- function Me() {
409
+ function fn(r) {
410
+ return typeof r != "boolean" ? new Error("Argument type: " + typeof r + ". Please use a boolean.") : (st = !r, "adapter.js deprecation warnings " + (r ? "disabled" : "enabled"));
411
+ }
412
+ function Ae() {
413
413
  if (typeof window == "object") {
414
- if (nt)
414
+ if (rt)
415
415
  return;
416
416
  typeof console < "u" && typeof console.log == "function" && console.log.apply(console, arguments);
417
417
  }
418
418
  }
419
419
  function De(r, e) {
420
- rt && console.warn(r + " is deprecated, please use " + e + " instead.");
420
+ st && console.warn(r + " is deprecated, please use " + e + " instead.");
421
421
  }
422
- function fn(r) {
422
+ function ln(r) {
423
423
  const e = { browser: null, version: null };
424
424
  if (typeof r > "u" || !r.navigator || !r.navigator.userAgent)
425
425
  return e.browser = "Not a browser.", e;
@@ -433,23 +433,23 @@ function fn(r) {
433
433
  }
434
434
  }
435
435
  if (t.mozGetUserMedia)
436
- e.browser = "firefox", e.version = parseInt(F(
436
+ e.browser = "firefox", e.version = parseInt(j(
437
437
  t.userAgent,
438
438
  /Firefox\/(\d+)\./,
439
439
  1
440
440
  ));
441
441
  else if (t.webkitGetUserMedia || r.isSecureContext === !1 && r.webkitRTCPeerConnection)
442
- e.browser = "chrome", e.version = parseInt(F(
442
+ e.browser = "chrome", e.version = parseInt(j(
443
443
  t.userAgent,
444
444
  /Chrom(e|ium)\/(\d+)\./,
445
445
  2
446
446
  )) || null;
447
447
  else if (r.RTCPeerConnection && t.userAgent.match(/AppleWebKit\/(\d+)\./))
448
- e.browser = "safari", e.version = parseInt(F(
448
+ e.browser = "safari", e.version = parseInt(j(
449
449
  t.userAgent,
450
450
  /AppleWebKit\/(\d+)\./,
451
451
  1
452
- )), e.supportsUnifiedPlan = r.RTCRtpTransceiver && "currentDirection" in r.RTCRtpTransceiver.prototype, e._safariVersion = F(
452
+ )), e.supportsUnifiedPlan = r.RTCRtpTransceiver && "currentDirection" in r.RTCRtpTransceiver.prototype, e._safariVersion = j(
453
453
  t.userAgent,
454
454
  /Version\/(\d+(\.?\d+))/,
455
455
  1
@@ -458,23 +458,23 @@ function fn(r) {
458
458
  return e.browser = "Not a supported browser.", e;
459
459
  return e;
460
460
  }
461
- function we(r) {
461
+ function ze(r) {
462
462
  return Object.prototype.toString.call(r) === "[object Object]";
463
463
  }
464
- function st(r) {
465
- return we(r) ? Object.keys(r).reduce(function(e, t) {
466
- const n = we(r[t]), s = n ? st(r[t]) : r[t], i = n && !Object.keys(s).length;
464
+ function it(r) {
465
+ return ze(r) ? Object.keys(r).reduce(function(e, t) {
466
+ const n = ze(r[t]), s = n ? it(r[t]) : r[t], i = n && !Object.keys(s).length;
467
467
  return s === void 0 || i ? e : Object.assign(e, { [t]: s });
468
468
  }, {}) : r;
469
469
  }
470
- function pe(r, e, t) {
470
+ function de(r, e, t) {
471
471
  !e || t.has(e.id) || (t.set(e.id, e), Object.keys(e).forEach((n) => {
472
- n.endsWith("Id") ? pe(r, r.get(e[n]), t) : n.endsWith("Ids") && e[n].forEach((s) => {
473
- pe(r, r.get(s), t);
472
+ n.endsWith("Id") ? de(r, r.get(e[n]), t) : n.endsWith("Ids") && e[n].forEach((s) => {
473
+ de(r, r.get(s), t);
474
474
  });
475
475
  }));
476
476
  }
477
- function ze(r, e, t) {
477
+ function Ve(r, e, t) {
478
478
  const n = t ? "outbound-rtp" : "inbound-rtp", s = /* @__PURE__ */ new Map();
479
479
  if (e === null)
480
480
  return s;
@@ -483,12 +483,12 @@ function ze(r, e, t) {
483
483
  o.type === "track" && o.trackIdentifier === e.id && i.push(o);
484
484
  }), i.forEach((o) => {
485
485
  r.forEach((a) => {
486
- a.type === n && a.trackId === o.id && pe(r, a, s);
486
+ a.type === n && a.trackId === o.id && de(r, a, s);
487
487
  });
488
488
  }), s;
489
489
  }
490
- const Ve = Me;
491
- function it(r, e) {
490
+ const qe = Ae;
491
+ function ot(r, e) {
492
492
  if (e.version >= 64)
493
493
  return;
494
494
  const t = r && r.navigator;
@@ -503,8 +503,8 @@ function it(r, e) {
503
503
  return;
504
504
  const f = typeof a[h] == "object" ? a[h] : { ideal: a[h] };
505
505
  f.exact !== void 0 && typeof f.exact == "number" && (f.min = f.max = f.exact);
506
- const l = function(u, d) {
507
- return u ? u + d.charAt(0).toUpperCase() + d.slice(1) : d === "deviceId" ? "sourceId" : d;
506
+ const l = function(u, p) {
507
+ return u ? u + p.charAt(0).toUpperCase() + p.slice(1) : p === "deviceId" ? "sourceId" : p;
508
508
  };
509
509
  if (f.ideal !== void 0) {
510
510
  c.optional = c.optional || [];
@@ -534,13 +534,13 @@ function it(r, e) {
534
534
  if (h.exact === "environment" || h.ideal === "environment" ? l = ["back", "rear"] : (h.exact === "user" || h.ideal === "user") && (l = ["front"]), l)
535
535
  return t.mediaDevices.enumerateDevices().then((u) => {
536
536
  u = u.filter((_) => _.kind === "videoinput");
537
- let d = u.find((_) => l.some((v) => _.label.toLowerCase().includes(v)));
538
- return !d && u.length && l.includes("back") && (d = u[u.length - 1]), d && (a.video.deviceId = h.exact ? { exact: d.deviceId } : { ideal: d.deviceId }), a.video = n(a.video), Ve("chrome: " + JSON.stringify(a)), c(a);
537
+ let p = u.find((_) => l.some((v) => _.label.toLowerCase().includes(v)));
538
+ return !p && u.length && l.includes("back") && (p = u[u.length - 1]), p && (a.video.deviceId = h.exact ? { exact: p.deviceId } : { ideal: p.deviceId }), a.video = n(a.video), qe("chrome: " + JSON.stringify(a)), c(a);
539
539
  });
540
540
  }
541
541
  a.video = n(a.video);
542
542
  }
543
- return Ve("chrome: " + JSON.stringify(a)), c(a);
543
+ return qe("chrome: " + JSON.stringify(a)), c(a);
544
544
  }, i = function(a) {
545
545
  return e.version >= 64 ? a : {
546
546
  name: {
@@ -582,10 +582,10 @@ function it(r, e) {
582
582
  };
583
583
  }
584
584
  }
585
- function ot(r) {
585
+ function at(r) {
586
586
  r.MediaStream = r.MediaStream || r.webkitMediaStream;
587
587
  }
588
- function at(r, e) {
588
+ function ct(r, e) {
589
589
  if (!(e.version > 102))
590
590
  if (typeof r == "object" && r.RTCPeerConnection && !("ontrack" in r.RTCPeerConnection.prototype)) {
591
591
  Object.defineProperty(r.RTCPeerConnection.prototype, "ontrack", {
@@ -621,7 +621,7 @@ function at(r, e) {
621
621
  { value: { receiver: t.receiver } }
622
622
  ), t));
623
623
  }
624
- function ct(r) {
624
+ function ht(r) {
625
625
  if (typeof r == "object" && r.RTCPeerConnection && !("getSenders" in r.RTCPeerConnection.prototype) && "createDTMFSender" in r.RTCPeerConnection.prototype) {
626
626
  const e = function(s, i) {
627
627
  return {
@@ -673,7 +673,7 @@ function ct(r) {
673
673
  });
674
674
  }
675
675
  }
676
- function ht(r, e) {
676
+ function ft(r, e) {
677
677
  if (e.version >= 67 || !(typeof r == "object" && r.RTCPeerConnection && r.RTCRtpSender && r.RTCRtpReceiver))
678
678
  return;
679
679
  if (!("getStats" in r.RTCRtpSender.prototype)) {
@@ -693,7 +693,7 @@ function ht(r, e) {
693
693
  * send a track with the same id as sender.track as
694
694
  * it is not possible to identify the RTCRtpSender.
695
695
  */
696
- ze(a, o.track, !0)
696
+ Ve(a, o.track, !0)
697
697
  ));
698
698
  };
699
699
  }
@@ -704,7 +704,7 @@ function ht(r, e) {
704
704
  return i.forEach((o) => o._pc = this), i;
705
705
  }), D(r, "track", (s) => (s.receiver._pc = s.srcElement, s)), r.RTCRtpReceiver.prototype.getStats = function() {
706
706
  const i = this;
707
- return this._pc.getStats().then((o) => ze(o, i.track, !1));
707
+ return this._pc.getStats().then((o) => Ve(o, i.track, !1));
708
708
  };
709
709
  }
710
710
  if (!("getStats" in r.RTCRtpSender.prototype && "getStats" in r.RTCRtpReceiver.prototype))
@@ -727,7 +727,7 @@ function ht(r, e) {
727
727
  return t.apply(this, arguments);
728
728
  };
729
729
  }
730
- function ft(r) {
730
+ function lt(r) {
731
731
  r.RTCPeerConnection.prototype.getLocalStreams = function() {
732
732
  return this._shimmedLocalStreams = this._shimmedLocalStreams || {}, Object.keys(this._shimmedLocalStreams).map((o) => this._shimmedLocalStreams[o][0]);
733
733
  };
@@ -765,11 +765,11 @@ function ft(r) {
765
765
  }), s.apply(this, arguments);
766
766
  };
767
767
  }
768
- function lt(r, e) {
768
+ function ut(r, e) {
769
769
  if (!r.RTCPeerConnection)
770
770
  return;
771
771
  if (r.RTCPeerConnection.prototype.addTrack && e.version >= 65)
772
- return ft(r);
772
+ return lt(r);
773
773
  const t = r.RTCPeerConnection.prototype.getLocalStreams;
774
774
  r.RTCPeerConnection.prototype.getLocalStreams = function() {
775
775
  const f = t.apply(this);
@@ -778,7 +778,7 @@ function lt(r, e) {
778
778
  const n = r.RTCPeerConnection.prototype.addStream;
779
779
  r.RTCPeerConnection.prototype.addStream = function(f) {
780
780
  if (this._streams = this._streams || {}, this._reverseStreams = this._reverseStreams || {}, f.getTracks().forEach((l) => {
781
- if (this.getSenders().find((d) => d.track === l))
781
+ if (this.getSenders().find((p) => p.track === l))
782
782
  throw new DOMException(
783
783
  "Track already exists.",
784
784
  "InvalidAccessError"
@@ -824,10 +824,10 @@ function lt(r, e) {
824
824
  function i(h, f) {
825
825
  let l = f.sdp;
826
826
  return Object.keys(h._reverseStreams || []).forEach((u) => {
827
- const d = h._reverseStreams[u], _ = h._streams[d.id];
827
+ const p = h._reverseStreams[u], _ = h._streams[p.id];
828
828
  l = l.replace(
829
829
  new RegExp(_.id, "g"),
830
- d.id
830
+ p.id
831
831
  );
832
832
  }), new RTCSessionDescription({
833
833
  type: f.type,
@@ -837,9 +837,9 @@ function lt(r, e) {
837
837
  function o(h, f) {
838
838
  let l = f.sdp;
839
839
  return Object.keys(h._reverseStreams || []).forEach((u) => {
840
- const d = h._reverseStreams[u], _ = h._streams[d.id];
840
+ const p = h._reverseStreams[u], _ = h._streams[p.id];
841
841
  l = l.replace(
842
- new RegExp(d.id, "g"),
842
+ new RegExp(p.id, "g"),
843
843
  _.id
844
844
  );
845
845
  }), new RTCSessionDescription({
@@ -895,12 +895,12 @@ function lt(r, e) {
895
895
  );
896
896
  this._streams = this._streams || {};
897
897
  let u;
898
- Object.keys(this._streams).forEach((d) => {
899
- this._streams[d].getTracks().find((v) => f.track === v) && (u = this._streams[d]);
898
+ Object.keys(this._streams).forEach((p) => {
899
+ this._streams[p].getTracks().find((v) => f.track === v) && (u = this._streams[p]);
900
900
  }), u && (u.getTracks().length === 1 ? this.removeStream(this._reverseStreams[u.id]) : u.removeTrack(f.track), this.dispatchEvent(new Event("negotiationneeded")));
901
901
  };
902
902
  }
903
- function de(r, e) {
903
+ function pe(r, e) {
904
904
  !r.RTCPeerConnection && r.webkitRTCPeerConnection && (r.RTCPeerConnection = r.webkitRTCPeerConnection), r.RTCPeerConnection && e.version < 53 && ["setLocalDescription", "setRemoteDescription", "addIceCandidate"].forEach(function(t) {
905
905
  const n = r.RTCPeerConnection.prototype[t], s = { [t]() {
906
906
  return arguments[0] = new (t === "addIceCandidate" ? r.RTCIceCandidate : r.RTCSessionDescription)(arguments[0]), n.apply(this, arguments);
@@ -908,24 +908,24 @@ function de(r, e) {
908
908
  r.RTCPeerConnection.prototype[t] = s[t];
909
909
  });
910
910
  }
911
- function ut(r, e) {
911
+ function dt(r, e) {
912
912
  e.version > 102 || D(r, "negotiationneeded", (t) => {
913
913
  const n = t.target;
914
914
  if (!((e.version < 72 || n.getConfiguration && n.getConfiguration().sdpSemantics === "plan-b") && n.signalingState !== "stable"))
915
915
  return t;
916
916
  });
917
917
  }
918
- const qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
918
+ const He = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
919
919
  __proto__: null,
920
- fixNegotiationNeeded: ut,
921
- shimAddTrackRemoveTrack: lt,
922
- shimAddTrackRemoveTrackWithNative: ft,
923
- shimGetSendersWithDtmf: ct,
924
- shimGetUserMedia: it,
925
- shimMediaStream: ot,
926
- shimOnTrack: at,
927
- shimPeerConnection: de,
928
- shimSenderReceiverGetStats: ht
920
+ fixNegotiationNeeded: dt,
921
+ shimAddTrackRemoveTrack: ut,
922
+ shimAddTrackRemoveTrackWithNative: lt,
923
+ shimGetSendersWithDtmf: ht,
924
+ shimGetUserMedia: ot,
925
+ shimMediaStream: at,
926
+ shimOnTrack: ct,
927
+ shimPeerConnection: pe,
928
+ shimSenderReceiverGetStats: ft
929
929
  }, Symbol.toStringTag, { value: "Module" }));
930
930
  function pt(r, e) {
931
931
  const t = r && r.navigator;
@@ -958,7 +958,7 @@ function pt(r, e) {
958
958
  }
959
959
  }
960
960
  }
961
- function ln(r, e) {
961
+ function un(r, e) {
962
962
  r.navigator.mediaDevices && (r.navigator.mediaDevices && "getDisplayMedia" in r.navigator.mediaDevices || (r.navigator.mediaDevices.getDisplayMedia = function(n) {
963
963
  if (!(n && n.video)) {
964
964
  const s = new DOMException("getDisplayMedia without video constraints is undefined");
@@ -967,7 +967,7 @@ function ln(r, e) {
967
967
  return n.video === !0 ? n.video = { mediaSource: e } : n.video.mediaSource = e, r.navigator.mediaDevices.getUserMedia(n);
968
968
  }));
969
969
  }
970
- function dt(r) {
970
+ function mt(r) {
971
971
  typeof r == "object" && r.RTCTrackEvent && "receiver" in r.RTCTrackEvent.prototype && !("transceiver" in r.RTCTrackEvent.prototype) && Object.defineProperty(r.RTCTrackEvent.prototype, "transceiver", {
972
972
  get() {
973
973
  return { receiver: this.receiver };
@@ -982,7 +982,7 @@ function me(r, e) {
982
982
  r.RTCPeerConnection.prototype[t] = s[t];
983
983
  }));
984
984
  }
985
- function mt(r, e) {
985
+ function gt(r, e) {
986
986
  if (typeof r != "object" || !(r.RTCPeerConnection || r.mozRTCPeerConnection) || e.version >= 151)
987
987
  return;
988
988
  const t = {
@@ -1013,7 +1013,7 @@ function mt(r, e) {
1013
1013
  }).then(o, a);
1014
1014
  };
1015
1015
  }
1016
- function gt(r) {
1016
+ function yt(r) {
1017
1017
  if (!(typeof r == "object" && r.RTCPeerConnection && r.RTCRtpSender) || r.RTCRtpSender && "getStats" in r.RTCRtpSender.prototype)
1018
1018
  return;
1019
1019
  const e = r.RTCPeerConnection.prototype.getSenders;
@@ -1029,7 +1029,7 @@ function gt(r) {
1029
1029
  return this.track ? this._pc.getStats(this.track) : Promise.resolve(/* @__PURE__ */ new Map());
1030
1030
  };
1031
1031
  }
1032
- function yt(r) {
1032
+ function _t(r) {
1033
1033
  if (!(typeof r == "object" && r.RTCPeerConnection && r.RTCRtpSender) || r.RTCRtpSender && "getStats" in r.RTCRtpReceiver.prototype)
1034
1034
  return;
1035
1035
  const e = r.RTCPeerConnection.prototype.getReceivers;
@@ -1040,17 +1040,17 @@ function yt(r) {
1040
1040
  return this._pc.getStats(this.track);
1041
1041
  };
1042
1042
  }
1043
- function _t(r) {
1043
+ function bt(r) {
1044
1044
  !r.RTCPeerConnection || "removeStream" in r.RTCPeerConnection.prototype || (r.RTCPeerConnection.prototype.removeStream = function(t) {
1045
1045
  De("removeStream", "removeTrack"), this.getSenders().forEach((n) => {
1046
1046
  n.track && t.getTracks().includes(n.track) && this.removeTrack(n);
1047
1047
  });
1048
1048
  });
1049
1049
  }
1050
- function bt(r) {
1050
+ function Ct(r) {
1051
1051
  r.DataChannel && !r.RTCDataChannel && (r.RTCDataChannel = r.DataChannel);
1052
1052
  }
1053
- function Ct(r, e) {
1053
+ function vt(r, e) {
1054
1054
  if (!(typeof r == "object" && r.RTCPeerConnection) || e.version >= 110)
1055
1055
  return;
1056
1056
  const t = r.RTCPeerConnection.prototype.addTransceiver;
@@ -1082,7 +1082,7 @@ function Ct(r, e) {
1082
1082
  return o;
1083
1083
  });
1084
1084
  }
1085
- function vt(r, e) {
1085
+ function St(r, e) {
1086
1086
  if (!(typeof r == "object" && r.RTCRtpSender) || e.version >= 110)
1087
1087
  return;
1088
1088
  const t = r.RTCRtpSender.prototype.getParameters;
@@ -1091,7 +1091,7 @@ function vt(r, e) {
1091
1091
  return "encodings" in s || (s.encodings = [].concat(this.sendEncodings || [{}])), s;
1092
1092
  });
1093
1093
  }
1094
- function St(r, e) {
1094
+ function kt(r, e) {
1095
1095
  if (!(typeof r == "object" && r.RTCPeerConnection) || e.version >= 110)
1096
1096
  return;
1097
1097
  const t = r.RTCPeerConnection.prototype.createOffer;
@@ -1101,7 +1101,7 @@ function St(r, e) {
1101
1101
  }) : t.apply(this, arguments);
1102
1102
  };
1103
1103
  }
1104
- function kt(r, e) {
1104
+ function Tt(r, e) {
1105
1105
  if (!(typeof r == "object" && r.RTCPeerConnection) || e.version >= 110)
1106
1106
  return;
1107
1107
  const t = r.RTCPeerConnection.prototype.createAnswer;
@@ -1111,23 +1111,23 @@ function kt(r, e) {
1111
1111
  }) : t.apply(this, arguments);
1112
1112
  };
1113
1113
  }
1114
- const He = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1114
+ const Ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1115
1115
  __proto__: null,
1116
- shimAddTransceiver: Ct,
1117
- shimCreateAnswer: kt,
1118
- shimCreateOffer: St,
1119
- shimGetDisplayMedia: ln,
1120
- shimGetParameters: vt,
1121
- shimGetStats: mt,
1116
+ shimAddTransceiver: vt,
1117
+ shimCreateAnswer: Tt,
1118
+ shimCreateOffer: kt,
1119
+ shimGetDisplayMedia: un,
1120
+ shimGetParameters: St,
1121
+ shimGetStats: gt,
1122
1122
  shimGetUserMedia: pt,
1123
- shimOnTrack: dt,
1123
+ shimOnTrack: mt,
1124
1124
  shimPeerConnection: me,
1125
- shimRTCDataChannel: bt,
1126
- shimReceiverGetStats: yt,
1127
- shimRemoveStream: _t,
1128
- shimSenderGetStats: gt
1125
+ shimRTCDataChannel: Ct,
1126
+ shimReceiverGetStats: _t,
1127
+ shimRemoveStream: bt,
1128
+ shimSenderGetStats: yt
1129
1129
  }, Symbol.toStringTag, { value: "Module" }));
1130
- function Tt(r) {
1130
+ function Rt(r) {
1131
1131
  if (!(typeof r != "object" || !r.RTCPeerConnection)) {
1132
1132
  if ("getLocalStreams" in r.RTCPeerConnection.prototype || (r.RTCPeerConnection.prototype.getLocalStreams = function() {
1133
1133
  return this._localStreams || (this._localStreams = []), this._localStreams;
@@ -1197,7 +1197,7 @@ function xt(r) {
1197
1197
  };
1198
1198
  }
1199
1199
  }
1200
- function Rt(r) {
1200
+ function Et(r) {
1201
1201
  if (typeof r != "object" || !r.RTCPeerConnection)
1202
1202
  return;
1203
1203
  const e = r.RTCPeerConnection.prototype, t = e.createOffer, n = e.createAnswer, s = e.setLocalDescription, i = e.setRemoteDescription, o = e.addIceCandidate;
@@ -1220,24 +1220,24 @@ function Rt(r) {
1220
1220
  return f ? (l.then(h, f), Promise.resolve()) : l;
1221
1221
  }, e.addIceCandidate = a;
1222
1222
  }
1223
- function Et(r) {
1223
+ function Pt(r) {
1224
1224
  const e = r && r.navigator;
1225
1225
  if (e.mediaDevices && e.mediaDevices.getUserMedia) {
1226
1226
  const t = e.mediaDevices, n = t.getUserMedia.bind(t);
1227
- e.mediaDevices.getUserMedia = (s) => n(Pt(s));
1227
+ e.mediaDevices.getUserMedia = (s) => n(Ot(s));
1228
1228
  }
1229
1229
  !e.getUserMedia && e.mediaDevices && e.mediaDevices.getUserMedia && (e.getUserMedia = (function(n, s, i) {
1230
1230
  e.mediaDevices.getUserMedia(n).then(s, i);
1231
1231
  }).bind(e));
1232
1232
  }
1233
- function Pt(r) {
1233
+ function Ot(r) {
1234
1234
  return r && r.video !== void 0 ? Object.assign(
1235
1235
  {},
1236
1236
  r,
1237
- { video: st(r.video) }
1237
+ { video: it(r.video) }
1238
1238
  ) : r;
1239
1239
  }
1240
- function Ot(r) {
1240
+ function Mt(r) {
1241
1241
  if (!r.RTCPeerConnection)
1242
1242
  return;
1243
1243
  const e = r.RTCPeerConnection;
@@ -1264,7 +1264,7 @@ function At(r) {
1264
1264
  }
1265
1265
  });
1266
1266
  }
1267
- function Mt(r) {
1267
+ function Dt(r) {
1268
1268
  const e = r.RTCPeerConnection.prototype.createOffer;
1269
1269
  r.RTCPeerConnection.prototype.createOffer = function(n) {
1270
1270
  if (n) {
@@ -1277,25 +1277,25 @@ function Mt(r) {
1277
1277
  return e.apply(this, arguments);
1278
1278
  };
1279
1279
  }
1280
- function Dt(r) {
1280
+ function Lt(r) {
1281
1281
  typeof r != "object" || r.AudioContext || (r.AudioContext = r.webkitAudioContext);
1282
1282
  }
1283
- const Ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1283
+ const Je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1284
1284
  __proto__: null,
1285
- shimAudioContext: Dt,
1286
- shimCallbacksAPI: Rt,
1287
- shimConstraints: Pt,
1288
- shimCreateOfferLegacy: Mt,
1289
- shimGetUserMedia: Et,
1290
- shimLocalStreamsAPI: Tt,
1291
- shimRTCIceServerUrls: Ot,
1285
+ shimAudioContext: Lt,
1286
+ shimCallbacksAPI: Et,
1287
+ shimConstraints: Ot,
1288
+ shimCreateOfferLegacy: Dt,
1289
+ shimGetUserMedia: Pt,
1290
+ shimLocalStreamsAPI: Rt,
1291
+ shimRTCIceServerUrls: Mt,
1292
1292
  shimRemoteStreamsAPI: xt,
1293
1293
  shimTrackEventTransceiver: At
1294
1294
  }, Symbol.toStringTag, { value: "Module" }));
1295
- function un(r) {
1295
+ function dn(r) {
1296
1296
  return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
1297
1297
  }
1298
- var Lt = { exports: {} };
1298
+ var It = { exports: {} };
1299
1299
  (function(r) {
1300
1300
  const e = {};
1301
1301
  e.generateIdentifier = function() {
@@ -1555,14 +1555,14 @@ a=ice-pwd:` + t.password + `\r
1555
1555
  const f = e.matchPrefix(t, "a=ssrc-group:FID").map((u) => u.substring(17).split(" ").map((_) => parseInt(_, 10)));
1556
1556
  f.length > 0 && f[0].length > 1 && f[0][0] === c && (h = f[0][1]), s.codecs.forEach((u) => {
1557
1557
  if (u.name.toUpperCase() === "RTX" && u.parameters.apt) {
1558
- let d = {
1558
+ let p = {
1559
1559
  ssrc: c,
1560
1560
  codecPayloadType: parseInt(u.parameters.apt, 10)
1561
1561
  };
1562
- c && h && (d.rtx = { ssrc: h }), n.push(d), i && (d = JSON.parse(JSON.stringify(d)), d.fec = {
1562
+ c && h && (p.rtx = { ssrc: h }), n.push(p), i && (p = JSON.parse(JSON.stringify(p)), p.fec = {
1563
1563
  ssrc: c,
1564
1564
  mechanism: o ? "red+ulpfec" : "red"
1565
- }, n.push(d));
1565
+ }, n.push(p));
1566
1566
  }
1567
1567
  }), n.length === 0 && c && n.push({
1568
1568
  ssrc: c
@@ -1682,12 +1682,12 @@ t=0 0\r
1682
1682
  return !1;
1683
1683
  return !0;
1684
1684
  }, r.exports = e;
1685
- })(Lt);
1686
- var It = Lt.exports;
1687
- const B = /* @__PURE__ */ un(It), pn = /* @__PURE__ */ nn({
1685
+ })(It);
1686
+ var Bt = It.exports;
1687
+ const B = /* @__PURE__ */ dn(Bt), pn = /* @__PURE__ */ rn({
1688
1688
  __proto__: null,
1689
1689
  default: B
1690
- }, [It]);
1690
+ }, [Bt]);
1691
1691
  function J(r) {
1692
1692
  if (!r.RTCIceCandidate || r.RTCIceCandidate && "foundation" in r.RTCIceCandidate.prototype)
1693
1693
  return;
@@ -1900,7 +1900,7 @@ function X(r, e) {
1900
1900
  return s.sdp || s.type !== "offer" && s.type !== "answer" ? t.apply(this, [s]) : (s.type === "offer" ? this.createOffer : this.createAnswer).apply(this).then((o) => t.apply(this, [o]));
1901
1901
  });
1902
1902
  }
1903
- const dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1903
+ const mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1904
1904
  __proto__: null,
1905
1905
  removeExtmapAllowMixed: _e,
1906
1906
  shimAddIceCandidateNullOrEmpty: W,
@@ -1911,37 +1911,37 @@ const dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1911
1911
  shimRTCIceCandidateRelayProtocol: ge,
1912
1912
  shimSendThrowTypeError: Y
1913
1913
  }, Symbol.toStringTag, { value: "Module" }));
1914
- function mn({ window: r } = {}, e = {
1914
+ function gn({ window: r } = {}, e = {
1915
1915
  shimChrome: !0,
1916
1916
  shimFirefox: !0,
1917
1917
  shimSafari: !0
1918
1918
  }) {
1919
- const t = Me, n = fn(r), s = {
1919
+ const t = Ae, n = ln(r), s = {
1920
1920
  browserDetails: n,
1921
- commonShim: dn,
1922
- extractVersion: F,
1923
- disableLog: cn,
1924
- disableWarnings: hn,
1921
+ commonShim: mn,
1922
+ extractVersion: j,
1923
+ disableLog: hn,
1924
+ disableWarnings: fn,
1925
1925
  // Expose sdp as a convenience. For production apps include directly.
1926
1926
  sdp: pn
1927
1927
  };
1928
1928
  switch (n.browser) {
1929
1929
  case "chrome":
1930
- if (!qe || !de || !e.shimChrome)
1930
+ if (!He || !pe || !e.shimChrome)
1931
1931
  return t("Chrome shim is not included in this adapter release."), s;
1932
1932
  if (n.version === null)
1933
1933
  return t("Chrome shim can not determine version, not shimming."), s;
1934
- t("adapter.js shimming chrome."), s.browserShim = qe, W(r, n), X(r), it(r, n), ot(r), de(r, n), at(r, n), lt(r, n), ct(r), ht(r, n), ut(r, n), J(r), ge(r), ye(r), G(r, n), Y(r, n), _e(r, n);
1934
+ t("adapter.js shimming chrome."), s.browserShim = He, W(r, n), X(r), ot(r, n), at(r), pe(r, n), ct(r, n), ut(r, n), ht(r), ft(r, n), dt(r, n), J(r), ge(r), ye(r), G(r, n), Y(r, n), _e(r, n);
1935
1935
  break;
1936
1936
  case "firefox":
1937
- if (!He || !me || !e.shimFirefox)
1937
+ if (!Ke || !me || !e.shimFirefox)
1938
1938
  return t("Firefox shim is not included in this adapter release."), s;
1939
- t("adapter.js shimming firefox."), s.browserShim = He, W(r, n), X(r), pt(r, n), me(r, n), mt(r, n), dt(r), _t(r), gt(r), yt(r), bt(r), Ct(r, n), vt(r, n), St(r, n), kt(r, n), J(r), ye(r), G(r, n), Y(r, n);
1939
+ t("adapter.js shimming firefox."), s.browserShim = Ke, W(r, n), X(r), pt(r, n), me(r, n), gt(r, n), mt(r), bt(r), yt(r), _t(r), Ct(r), vt(r, n), St(r, n), kt(r, n), Tt(r, n), J(r), ye(r), G(r, n), Y(r, n);
1940
1940
  break;
1941
1941
  case "safari":
1942
- if (!Ke || !e.shimSafari)
1942
+ if (!Je || !e.shimSafari)
1943
1943
  return t("Safari shim is not included in this adapter release."), s;
1944
- t("adapter.js shimming safari."), s.browserShim = Ke, W(r, n), X(r), Ot(r), Mt(r), Rt(r), Tt(r), xt(r), At(r), Et(r), Dt(r), J(r), ge(r), G(r, n), Y(r, n), _e(r, n);
1944
+ t("adapter.js shimming safari."), s.browserShim = Je, W(r, n), X(r), Mt(r), Dt(r), Et(r), Rt(r), xt(r), At(r), Pt(r), Lt(r), J(r), ge(r), G(r, n), Y(r, n), _e(r, n);
1945
1945
  break;
1946
1946
  default:
1947
1947
  t("Unsupported browser!");
@@ -1949,11 +1949,11 @@ function mn({ window: r } = {}, e = {
1949
1949
  }
1950
1950
  return s;
1951
1951
  }
1952
- const Je = mn({ window: typeof window > "u" ? void 0 : window });
1952
+ const Ge = gn({ window: typeof window > "u" ? void 0 : window });
1953
1953
  function L(r, e, t, n) {
1954
1954
  Object.defineProperty(r, e, { get: t, set: n, enumerable: !0, configurable: !0 });
1955
1955
  }
1956
- class Bt {
1956
+ class $t {
1957
1957
  constructor() {
1958
1958
  this.chunkedMTU = 16300, this._dataCount = 1, this.chunk = (e) => {
1959
1959
  const t = [], n = e.byteLength, s = Math.ceil(n / this.chunkedMTU);
@@ -1971,7 +1971,7 @@ class Bt {
1971
1971
  };
1972
1972
  }
1973
1973
  }
1974
- function gn(r) {
1974
+ function yn(r) {
1975
1975
  let e = 0;
1976
1976
  for (const s of r) e += s.byteLength;
1977
1977
  const t = new Uint8Array(e);
@@ -1982,8 +1982,8 @@ function gn(r) {
1982
1982
  }
1983
1983
  const ce = (
1984
1984
  //@ts-ignore
1985
- Je.default || Je
1986
- ), N = new class {
1985
+ Ge.default || Ge
1986
+ ), w = new class {
1987
1987
  isWebRTCSupported() {
1988
1988
  return typeof RTCPeerConnection < "u";
1989
1989
  }
@@ -2031,7 +2031,7 @@ const ce = (
2031
2031
  "safari"
2032
2032
  ], this.minFirefoxVersion = 59, this.minChromeVersion = 72, this.minSafariVersion = 605;
2033
2033
  }
2034
- }(), yn = (r) => !r || /^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.test(r), $t = () => Math.random().toString(36).slice(2), Ge = {
2034
+ }(), _n = (r) => !r || /^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.test(r), Ut = () => Math.random().toString(36).slice(2), Ye = {
2035
2035
  iceServers: [
2036
2036
  {
2037
2037
  urls: "stun:stun.l.google.com:19302"
@@ -2047,7 +2047,7 @@ const ce = (
2047
2047
  ],
2048
2048
  sdpSemantics: "unified-plan"
2049
2049
  };
2050
- class _n extends Bt {
2050
+ class bn extends $t {
2051
2051
  noop() {
2052
2052
  }
2053
2053
  blobToArrayBuffer(e, t) {
@@ -2070,7 +2070,7 @@ class _n extends Bt {
2070
2070
  Chrome: 1,
2071
2071
  chrome: 1
2072
2072
  }, // Returns browser-agnostic default config
2073
- this.defaultConfig = Ge, this.browser = N.getBrowser(), this.browserVersion = N.getVersion(), this.pack = tt, this.unpack = et, /**
2073
+ this.defaultConfig = Ye, this.browser = w.getBrowser(), this.browserVersion = w.getVersion(), this.pack = nt, this.unpack = tt, /**
2074
2074
  * A hash of WebRTC features mapped to booleans that correspond to whether the feature is supported by the current browser.
2075
2075
  *
2076
2076
  * :::caution
@@ -2079,8 +2079,8 @@ class _n extends Bt {
2079
2079
  */
2080
2080
  this.supports = function() {
2081
2081
  const t = {
2082
- browser: N.isBrowserSupported(),
2083
- webRTC: N.isWebRTCSupported(),
2082
+ browser: w.isBrowserSupported(),
2083
+ webRTC: w.isWebRTCSupported(),
2084
2084
  audioVideo: !1,
2085
2085
  data: !1,
2086
2086
  binaryBlob: !1,
@@ -2089,14 +2089,14 @@ class _n extends Bt {
2089
2089
  if (!t.webRTC) return t;
2090
2090
  let n;
2091
2091
  try {
2092
- n = new RTCPeerConnection(Ge), t.audioVideo = !0;
2092
+ n = new RTCPeerConnection(Ye), t.audioVideo = !0;
2093
2093
  let s;
2094
2094
  try {
2095
2095
  s = n.createDataChannel("_PEERJSTEST", {
2096
2096
  ordered: !0
2097
2097
  }), t.data = !0, t.reliable = !!s.ordered;
2098
2098
  try {
2099
- s.binaryType = "blob", t.binaryBlob = !N.isIOS;
2099
+ s.binaryType = "blob", t.binaryBlob = !w.isIOS;
2100
2100
  } catch {
2101
2101
  }
2102
2102
  } catch {
@@ -2109,11 +2109,11 @@ class _n extends Bt {
2109
2109
  }
2110
2110
  return t;
2111
2111
  }(), // Ensure alphanumeric ids
2112
- this.validateId = yn, this.randomToken = $t;
2112
+ this.validateId = _n, this.randomToken = Ut;
2113
2113
  }
2114
2114
  }
2115
- const k = new _n(), bn = "PeerJS: ";
2116
- class Cn {
2115
+ const k = new bn(), Cn = "PeerJS: ";
2116
+ class vn {
2117
2117
  get logLevel() {
2118
2118
  return this._logLevel;
2119
2119
  }
@@ -2134,7 +2134,7 @@ class Cn {
2134
2134
  }
2135
2135
  _print(e, ...t) {
2136
2136
  const n = [
2137
- bn,
2137
+ Cn,
2138
2138
  ...t
2139
2139
  ];
2140
2140
  for (const s in n) n[s] instanceof Error && (n[s] = "(" + n[s].name + ") " + n[s].message);
@@ -2144,16 +2144,16 @@ class Cn {
2144
2144
  this._logLevel = 0;
2145
2145
  }
2146
2146
  }
2147
- var p = new Cn(), Le = {}, vn = Object.prototype.hasOwnProperty, S = "~";
2147
+ var d = new vn(), Le = {}, Sn = Object.prototype.hasOwnProperty, S = "~";
2148
2148
  function q() {
2149
2149
  }
2150
2150
  Object.create && (q.prototype = /* @__PURE__ */ Object.create(null), new q().__proto__ || (S = !1));
2151
- function Sn(r, e, t) {
2151
+ function kn(r, e, t) {
2152
2152
  this.fn = r, this.context = e, this.once = t || !1;
2153
2153
  }
2154
- function Ut(r, e, t, n, s) {
2154
+ function wt(r, e, t, n, s) {
2155
2155
  if (typeof t != "function") throw new TypeError("The listener must be a function");
2156
- var i = new Sn(t, n || r, s), o = S ? S + e : e;
2156
+ var i = new kn(t, n || r, s), o = S ? S + e : e;
2157
2157
  return r._events[o] ? r._events[o].fn ? r._events[o] = [
2158
2158
  r._events[o],
2159
2159
  i
@@ -2168,7 +2168,7 @@ function C() {
2168
2168
  C.prototype.eventNames = function() {
2169
2169
  var e = [], t, n;
2170
2170
  if (this._eventsCount === 0) return e;
2171
- for (n in t = this._events) vn.call(t, n) && e.push(S ? n.slice(1) : n);
2171
+ for (n in t = this._events) Sn.call(t, n) && e.push(S ? n.slice(1) : n);
2172
2172
  return Object.getOwnPropertySymbols ? e.concat(Object.getOwnPropertySymbols(t)) : e;
2173
2173
  };
2174
2174
  C.prototype.listeners = function(e) {
@@ -2206,7 +2206,7 @@ C.prototype.emit = function(e, t, n, s, i, o) {
2206
2206
  for (l = 1, f = new Array(h - 1); l < h; l++) f[l - 1] = arguments[l];
2207
2207
  c.fn.apply(c.context, f);
2208
2208
  } else {
2209
- var u = c.length, d;
2209
+ var u = c.length, p;
2210
2210
  for (l = 0; l < u; l++)
2211
2211
  switch (c[l].once && this.removeListener(e, c[l].fn, void 0, !0), h) {
2212
2212
  case 1:
@@ -2222,17 +2222,17 @@ C.prototype.emit = function(e, t, n, s, i, o) {
2222
2222
  c[l].fn.call(c[l].context, t, n, s);
2223
2223
  break;
2224
2224
  default:
2225
- if (!f) for (d = 1, f = new Array(h - 1); d < h; d++) f[d - 1] = arguments[d];
2225
+ if (!f) for (p = 1, f = new Array(h - 1); p < h; p++) f[p - 1] = arguments[p];
2226
2226
  c[l].fn.apply(c[l].context, f);
2227
2227
  }
2228
2228
  }
2229
2229
  return !0;
2230
2230
  };
2231
2231
  C.prototype.on = function(e, t, n) {
2232
- return Ut(this, e, t, n, !1);
2232
+ return wt(this, e, t, n, !1);
2233
2233
  };
2234
2234
  C.prototype.once = function(e, t, n) {
2235
- return Ut(this, e, t, n, !0);
2235
+ return wt(this, e, t, n, !0);
2236
2236
  };
2237
2237
  C.prototype.removeListener = function(e, t, n, s) {
2238
2238
  var i = S ? S + e : e;
@@ -2281,7 +2281,7 @@ var O = /* @__PURE__ */ function(r) {
2281
2281
  return r.Heartbeat = "HEARTBEAT", r.Candidate = "CANDIDATE", r.Offer = "OFFER", r.Answer = "ANSWER", r.Open = "OPEN", r.Error = "ERROR", r.IdTaken = "ID-TAKEN", r.InvalidKey = "INVALID-KEY", r.Leave = "LEAVE", r.Expire = "EXPIRE", r;
2282
2282
  }({});
2283
2283
  const Nt = "1.5.5";
2284
- class kn extends Le.EventEmitter {
2284
+ class Tn extends Le.EventEmitter {
2285
2285
  constructor(e, t, n, s, i, o = 5e3) {
2286
2286
  super(), this.pingInterval = o, this._disconnected = !0, this._messagesQueue = [];
2287
2287
  const a = e ? "wss://" : "ws://";
@@ -2293,16 +2293,16 @@ class kn extends Le.EventEmitter {
2293
2293
  this._socket || !this._disconnected || (this._socket = new WebSocket(n + "&version=" + Nt), this._disconnected = !1, this._socket.onmessage = (s) => {
2294
2294
  let i;
2295
2295
  try {
2296
- i = JSON.parse(s.data), p.log("Server message received:", i);
2296
+ i = JSON.parse(s.data), d.log("Server message received:", i);
2297
2297
  } catch {
2298
- p.log("Invalid server message", s.data);
2298
+ d.log("Invalid server message", s.data);
2299
2299
  return;
2300
2300
  }
2301
2301
  this.emit(P.Message, i);
2302
2302
  }, this._socket.onclose = (s) => {
2303
- this._disconnected || (p.log("Socket closed.", s), this._cleanup(), this._disconnected = !0, this.emit(P.Disconnected));
2303
+ this._disconnected || (d.log("Socket closed.", s), this._cleanup(), this._disconnected = !0, this.emit(P.Disconnected));
2304
2304
  }, this._socket.onopen = () => {
2305
- this._disconnected || (this._sendQueuedMessages(), p.log("Socket open"), this._scheduleHeartbeat());
2305
+ this._disconnected || (this._sendQueuedMessages(), d.log("Socket open"), this._scheduleHeartbeat());
2306
2306
  });
2307
2307
  }
2308
2308
  _scheduleHeartbeat() {
@@ -2312,7 +2312,7 @@ class kn extends Le.EventEmitter {
2312
2312
  }
2313
2313
  _sendHeartbeat() {
2314
2314
  if (!this._wsOpen()) {
2315
- p.log("Cannot send heartbeat, because socket closed");
2315
+ d.log("Cannot send heartbeat, because socket closed");
2316
2316
  return;
2317
2317
  }
2318
2318
  const e = JSON.stringify({
@@ -2370,15 +2370,15 @@ class jt {
2370
2370
  }
2371
2371
  /** Start a PC. */
2372
2372
  _startPeerConnection() {
2373
- p.log("Creating RTCPeerConnection.");
2373
+ d.log("Creating RTCPeerConnection.");
2374
2374
  const e = new RTCPeerConnection(this.connection.provider.options.config);
2375
2375
  return this._setupListeners(e), e;
2376
2376
  }
2377
2377
  /** Set up various WebRTC listeners. */
2378
2378
  _setupListeners(e) {
2379
2379
  const t = this.connection.peer, n = this.connection.connectionId, s = this.connection.type, i = this.connection.provider;
2380
- p.log("Listening for ICE candidates."), e.onicecandidate = (o) => {
2381
- !o.candidate || !o.candidate.candidate || (p.log(`Received ICE candidates for ${t}:`, o.candidate), i.socket.send({
2380
+ d.log("Listening for ICE candidates."), e.onicecandidate = (o) => {
2381
+ !o.candidate || !o.candidate.candidate || (d.log(`Received ICE candidates for ${t}:`, o.candidate), i.socket.send({
2382
2382
  type: b.Candidate,
2383
2383
  payload: {
2384
2384
  candidate: o.candidate,
@@ -2390,13 +2390,13 @@ class jt {
2390
2390
  }, e.oniceconnectionstatechange = () => {
2391
2391
  switch (e.iceConnectionState) {
2392
2392
  case "failed":
2393
- p.log("iceConnectionState is failed, closing connections to " + t), this.connection.emitError(be.NegotiationFailed, "Negotiation of connection to " + t + " failed."), this.connection.close();
2393
+ d.log("iceConnectionState is failed, closing connections to " + t), this.connection.emitError(be.NegotiationFailed, "Negotiation of connection to " + t + " failed."), this.connection.close();
2394
2394
  break;
2395
2395
  case "closed":
2396
- p.log("iceConnectionState is closed, closing connections to " + t), this.connection.emitError(be.ConnectionClosed, "Connection to " + t + " closed."), this.connection.close();
2396
+ d.log("iceConnectionState is closed, closing connections to " + t), this.connection.emitError(be.ConnectionClosed, "Connection to " + t + " closed."), this.connection.close();
2397
2397
  break;
2398
2398
  case "disconnected":
2399
- p.log("iceConnectionState changed to disconnected on the connection with " + t);
2399
+ d.log("iceConnectionState changed to disconnected on the connection with " + t);
2400
2400
  break;
2401
2401
  case "completed":
2402
2402
  e.onicecandidate = () => {
@@ -2404,12 +2404,12 @@ class jt {
2404
2404
  break;
2405
2405
  }
2406
2406
  this.connection.emit("iceStateChanged", e.iceConnectionState);
2407
- }, p.log("Listening for data channel"), e.ondatachannel = (o) => {
2408
- p.log("Received data channel");
2407
+ }, d.log("Listening for data channel"), e.ondatachannel = (o) => {
2408
+ d.log("Received data channel");
2409
2409
  const a = o.channel;
2410
2410
  i.getConnection(t, n)._initializeDataChannel(a);
2411
- }, p.log("Listening for remote stream"), e.ontrack = (o) => {
2412
- p.log("Received remote stream");
2411
+ }, d.log("Listening for remote stream"), e.ontrack = (o) => {
2412
+ d.log("Received remote stream");
2413
2413
  const a = o.streams[0], c = i.getConnection(t, n);
2414
2414
  if (c.type === O.Media) {
2415
2415
  const h = c;
@@ -2418,7 +2418,7 @@ class jt {
2418
2418
  };
2419
2419
  }
2420
2420
  cleanup() {
2421
- p.log("Cleaning up PeerConnection to " + this.connection.peer);
2421
+ d.log("Cleaning up PeerConnection to " + this.connection.peer);
2422
2422
  const e = this.connection.peerConnection;
2423
2423
  if (!e) return;
2424
2424
  this.connection.peerConnection = null, e.onicecandidate = e.oniceconnectionstatechange = e.ondatachannel = e.ontrack = () => {
@@ -2432,9 +2432,9 @@ class jt {
2432
2432
  const e = this.connection.peerConnection, t = this.connection.provider;
2433
2433
  try {
2434
2434
  const n = await e.createOffer(this.connection.options.constraints);
2435
- p.log("Created offer."), this.connection.options.sdpTransform && typeof this.connection.options.sdpTransform == "function" && (n.sdp = this.connection.options.sdpTransform(n.sdp) || n.sdp);
2435
+ d.log("Created offer."), this.connection.options.sdpTransform && typeof this.connection.options.sdpTransform == "function" && (n.sdp = this.connection.options.sdpTransform(n.sdp) || n.sdp);
2436
2436
  try {
2437
- await e.setLocalDescription(n), p.log("Set localDescription:", n, `for:${this.connection.peer}`);
2437
+ await e.setLocalDescription(n), d.log("Set localDescription:", n, `for:${this.connection.peer}`);
2438
2438
  let s = {
2439
2439
  sdp: n,
2440
2440
  type: this.connection.type,
@@ -2456,19 +2456,19 @@ class jt {
2456
2456
  dst: this.connection.peer
2457
2457
  });
2458
2458
  } catch (s) {
2459
- s != "OperationError: Failed to set local offer sdp: Called in wrong state: kHaveRemoteOffer" && (t.emitError(g.WebRTC, s), p.log("Failed to setLocalDescription, ", s));
2459
+ s != "OperationError: Failed to set local offer sdp: Called in wrong state: kHaveRemoteOffer" && (t.emitError(g.WebRTC, s), d.log("Failed to setLocalDescription, ", s));
2460
2460
  }
2461
2461
  } catch (n) {
2462
- t.emitError(g.WebRTC, n), p.log("Failed to createOffer, ", n);
2462
+ t.emitError(g.WebRTC, n), d.log("Failed to createOffer, ", n);
2463
2463
  }
2464
2464
  }
2465
2465
  async _makeAnswer() {
2466
2466
  const e = this.connection.peerConnection, t = this.connection.provider;
2467
2467
  try {
2468
2468
  const n = await e.createAnswer();
2469
- p.log("Created answer."), this.connection.options.sdpTransform && typeof this.connection.options.sdpTransform == "function" && (n.sdp = this.connection.options.sdpTransform(n.sdp) || n.sdp);
2469
+ d.log("Created answer."), this.connection.options.sdpTransform && typeof this.connection.options.sdpTransform == "function" && (n.sdp = this.connection.options.sdpTransform(n.sdp) || n.sdp);
2470
2470
  try {
2471
- await e.setLocalDescription(n), p.log("Set localDescription:", n, `for:${this.connection.peer}`), t.socket.send({
2471
+ await e.setLocalDescription(n), d.log("Set localDescription:", n, `for:${this.connection.peer}`), t.socket.send({
2472
2472
  type: b.Answer,
2473
2473
  payload: {
2474
2474
  sdp: n,
@@ -2478,41 +2478,41 @@ class jt {
2478
2478
  dst: this.connection.peer
2479
2479
  });
2480
2480
  } catch (s) {
2481
- t.emitError(g.WebRTC, s), p.log("Failed to setLocalDescription, ", s);
2481
+ t.emitError(g.WebRTC, s), d.log("Failed to setLocalDescription, ", s);
2482
2482
  }
2483
2483
  } catch (n) {
2484
- t.emitError(g.WebRTC, n), p.log("Failed to create answer, ", n);
2484
+ t.emitError(g.WebRTC, n), d.log("Failed to create answer, ", n);
2485
2485
  }
2486
2486
  }
2487
2487
  /** Handle an SDP. */
2488
2488
  async handleSDP(e, t) {
2489
2489
  t = new RTCSessionDescription(t);
2490
2490
  const n = this.connection.peerConnection, s = this.connection.provider;
2491
- p.log("Setting remote description", t);
2491
+ d.log("Setting remote description", t);
2492
2492
  const i = this;
2493
2493
  try {
2494
- await n.setRemoteDescription(t), p.log(`Set remoteDescription:${e} for:${this.connection.peer}`), e === "OFFER" && await i._makeAnswer();
2494
+ await n.setRemoteDescription(t), d.log(`Set remoteDescription:${e} for:${this.connection.peer}`), e === "OFFER" && await i._makeAnswer();
2495
2495
  } catch (o) {
2496
- s.emitError(g.WebRTC, o), p.log("Failed to setRemoteDescription, ", o);
2496
+ s.emitError(g.WebRTC, o), d.log("Failed to setRemoteDescription, ", o);
2497
2497
  }
2498
2498
  }
2499
2499
  /** Handle a candidate. */
2500
2500
  async handleCandidate(e) {
2501
- p.log("handleCandidate:", e);
2501
+ d.log("handleCandidate:", e);
2502
2502
  try {
2503
- await this.connection.peerConnection.addIceCandidate(e), p.log(`Added ICE candidate for:${this.connection.peer}`);
2503
+ await this.connection.peerConnection.addIceCandidate(e), d.log(`Added ICE candidate for:${this.connection.peer}`);
2504
2504
  } catch (t) {
2505
- this.connection.provider.emitError(g.WebRTC, t), p.log("Failed to handleCandidate, ", t);
2505
+ this.connection.provider.emitError(g.WebRTC, t), d.log("Failed to handleCandidate, ", t);
2506
2506
  }
2507
2507
  }
2508
2508
  _addTracksToConnection(e, t) {
2509
- if (p.log(`add tracks from stream ${e.id} to peer connection`), !t.addTrack) return p.error("Your browser does't support RTCPeerConnection#addTrack. Ignored.");
2509
+ if (d.log(`add tracks from stream ${e.id} to peer connection`), !t.addTrack) return d.error("Your browser does't support RTCPeerConnection#addTrack. Ignored.");
2510
2510
  e.getTracks().forEach((n) => {
2511
2511
  t.addTrack(n, e);
2512
2512
  });
2513
2513
  }
2514
2514
  _addStreamToMediaConnection(e, t) {
2515
- p.log(`add stream ${e.id} to media connection ${t.connectionId}`), t.addStream(e);
2515
+ d.log(`add stream ${e.id} to media connection ${t.connectionId}`), t.addStream(e);
2516
2516
  }
2517
2517
  }
2518
2518
  class Ft extends Le.EventEmitter {
@@ -2522,10 +2522,10 @@ class Ft extends Le.EventEmitter {
2522
2522
  * @internal
2523
2523
  */
2524
2524
  emitError(e, t) {
2525
- p.error("Error:", t), this.emit("error", new Tn(`${e}`, t));
2525
+ d.error("Error:", t), this.emit("error", new Rn(`${e}`, t));
2526
2526
  }
2527
2527
  }
2528
- class Tn extends Error {
2528
+ class Rn extends Error {
2529
2529
  /**
2530
2530
  * @internal
2531
2531
  */
@@ -2533,7 +2533,7 @@ class Tn extends Error {
2533
2533
  typeof t == "string" ? super(t) : (super(), Object.assign(this, t)), this.type = e;
2534
2534
  }
2535
2535
  }
2536
- class wt extends Ft {
2536
+ class zt extends Ft {
2537
2537
  /**
2538
2538
  * Whether the media connection is active (e.g. your call has been answered).
2539
2539
  * You can check this if you want to set a maximum wait time for a one-sided call.
@@ -2546,7 +2546,7 @@ class wt extends Ft {
2546
2546
  }
2547
2547
  }
2548
2548
  var Ee;
2549
- const z = class z extends wt {
2549
+ const z = class z extends zt {
2550
2550
  /**
2551
2551
  * For media connections, this is always 'media'.
2552
2552
  */
@@ -2568,13 +2568,13 @@ const z = class z extends wt {
2568
2568
  /** Called by the Negotiator when the DataChannel is ready. */
2569
2569
  _initializeDataChannel(e) {
2570
2570
  this.dataChannel = e, this.dataChannel.onopen = () => {
2571
- p.log(`DC#${this.connectionId} dc connection success`), this.emit("willCloseOnRemote");
2571
+ d.log(`DC#${this.connectionId} dc connection success`), this.emit("willCloseOnRemote");
2572
2572
  }, this.dataChannel.onclose = () => {
2573
- p.log(`DC#${this.connectionId} dc closed for:`, this.peer), this.close();
2573
+ d.log(`DC#${this.connectionId} dc closed for:`, this.peer), this.close();
2574
2574
  };
2575
2575
  }
2576
2576
  addStream(e) {
2577
- p.log("Receiving stream", e), this._remoteStream = e, super.emit("stream", e);
2577
+ d.log("Receiving stream", e), this._remoteStream = e, super.emit("stream", e);
2578
2578
  }
2579
2579
  /**
2580
2580
  * @internal
@@ -2589,7 +2589,7 @@ const z = class z extends wt {
2589
2589
  this._negotiator.handleCandidate(n.candidate);
2590
2590
  break;
2591
2591
  default:
2592
- p.warn(`Unrecognized message type:${t} from peer:${this.peer}`);
2592
+ d.warn(`Unrecognized message type:${t} from peer:${this.peer}`);
2593
2593
  break;
2594
2594
  }
2595
2595
  }
@@ -2605,7 +2605,7 @@ const z = class z extends wt {
2605
2605
  */
2606
2606
  answer(e, t = {}) {
2607
2607
  if (this._localStream) {
2608
- p.warn("Local stream already exists on this MediaConnection. Are you answering a call twice?");
2608
+ d.warn("Local stream already exists on this MediaConnection. Are you answering a call twice?");
2609
2609
  return;
2610
2610
  }
2611
2611
  this._localStream = e, t && t.sdpTransform && (this.options.sdpTransform = t.sdpTransform), this._negotiator.startConnection({
@@ -2645,7 +2645,7 @@ class xn {
2645
2645
  if (e.status !== 200) throw new Error(`Error. Status:${e.status}`);
2646
2646
  return e.text();
2647
2647
  } catch (e) {
2648
- p.error("Error retrieving ID", e);
2648
+ d.error("Error retrieving ID", e);
2649
2649
  let t = "";
2650
2650
  throw this._options.path === "/" && this._options.host !== k.CLOUD_HOST && (t = " If you passed in a `path` to your self-hosted PeerServer, you'll also need to pass in that same path when creating a new Peer."), new Error("Could not get an ID from the server." + t);
2651
2651
  }
@@ -2663,17 +2663,17 @@ class xn {
2663
2663
  }
2664
2664
  return e.json();
2665
2665
  } catch (e) {
2666
- throw p.error("Error retrieving list peers", e), new Error("Could not get list peers from the server." + e);
2666
+ throw d.error("Error retrieving list peers", e), new Error("Could not get list peers from the server." + e);
2667
2667
  }
2668
2668
  }
2669
2669
  }
2670
2670
  var Pe, Oe;
2671
- const M = class M extends wt {
2671
+ const A = class A extends zt {
2672
2672
  get type() {
2673
2673
  return O.Data;
2674
2674
  }
2675
2675
  constructor(e, t, n) {
2676
- super(e, t, n), this.connectionId = this.options.connectionId || M.ID_PREFIX + $t(), this.label = this.options.label || this.connectionId, this.reliable = !!this.options.reliable, this._negotiator = new jt(this), this._negotiator.startConnection(this.options._payload || {
2676
+ super(e, t, n), this.connectionId = this.options.connectionId || A.ID_PREFIX + Ut(), this.label = this.options.label || this.connectionId, this.reliable = !!this.options.reliable, this._negotiator = new jt(this), this._negotiator.startConnection(this.options._payload || {
2677
2677
  originator: !0,
2678
2678
  reliable: this.reliable
2679
2679
  });
@@ -2681,11 +2681,11 @@ const M = class M extends wt {
2681
2681
  /** Called by the Negotiator when the DataChannel is ready. */
2682
2682
  _initializeDataChannel(e) {
2683
2683
  this.dataChannel = e, this.dataChannel.onopen = () => {
2684
- p.log(`DC#${this.connectionId} dc connection success`), this._open = !0, this.emit("open");
2684
+ d.log(`DC#${this.connectionId} dc connection success`), this._open = !0, this.emit("open");
2685
2685
  }, this.dataChannel.onmessage = (t) => {
2686
- p.log(`DC#${this.connectionId} dc onmessage:`, t.data);
2686
+ d.log(`DC#${this.connectionId} dc onmessage:`, t.data);
2687
2687
  }, this.dataChannel.onclose = () => {
2688
- p.log(`DC#${this.connectionId} dc closed for:`, this.peer), this.close();
2688
+ d.log(`DC#${this.connectionId} dc closed for:`, this.peer), this.close();
2689
2689
  };
2690
2690
  }
2691
2691
  /**
@@ -2721,13 +2721,13 @@ const M = class M extends wt {
2721
2721
  await this._negotiator.handleCandidate(t.candidate);
2722
2722
  break;
2723
2723
  default:
2724
- p.warn("Unrecognized message type:", e.type, "from peer:", this.peer);
2724
+ d.warn("Unrecognized message type:", e.type, "from peer:", this.peer);
2725
2725
  break;
2726
2726
  }
2727
2727
  }
2728
2728
  };
2729
- Pe = new WeakMap(), Oe = new WeakMap(), U(M, Pe, M.ID_PREFIX = "dc_"), U(M, Oe, M.MAX_BUFFERED_AMOUNT = 8388608);
2730
- let se = M;
2729
+ Pe = new WeakMap(), Oe = new WeakMap(), U(A, Pe, A.ID_PREFIX = "dc_"), U(A, Oe, A.MAX_BUFFERED_AMOUNT = 8388608);
2730
+ let se = A;
2731
2731
  class Be extends se {
2732
2732
  get bufferSize() {
2733
2733
  return this._bufferSize;
@@ -2748,7 +2748,7 @@ class Be extends se {
2748
2748
  try {
2749
2749
  this.dataChannel.send(e);
2750
2750
  } catch (t) {
2751
- return p.error(`DC#:${this.connectionId} Error when sending:`, t), this._buffering = !0, this.close(), !1;
2751
+ return d.error(`DC#:${this.connectionId} Error when sending:`, t), this._buffering = !0, this.close(), !1;
2752
2752
  }
2753
2753
  return !0;
2754
2754
  }
@@ -2778,11 +2778,11 @@ class he extends Be {
2778
2778
  super.close(e), this._chunkedData = {};
2779
2779
  }
2780
2780
  constructor(e, t, n) {
2781
- super(e, t, n), this.chunker = new Bt(), this.serialization = ie.Binary, this._chunkedData = {};
2781
+ super(e, t, n), this.chunker = new $t(), this.serialization = ie.Binary, this._chunkedData = {};
2782
2782
  }
2783
2783
  // Handles a DataChannel message.
2784
2784
  _handleDataMessage({ data: e }) {
2785
- const t = et(e), n = t.__peerData;
2785
+ const t = tt(e), n = t.__peerData;
2786
2786
  if (n) {
2787
2787
  if (n.type === "close") {
2788
2788
  this.close();
@@ -2801,14 +2801,14 @@ class he extends Be {
2801
2801
  };
2802
2802
  if (n.data[e.n] = new Uint8Array(e.data), n.count++, this._chunkedData[t] = n, n.total === n.count) {
2803
2803
  delete this._chunkedData[t];
2804
- const s = gn(n.data);
2804
+ const s = yn(n.data);
2805
2805
  this._handleDataMessage({
2806
2806
  data: s
2807
2807
  });
2808
2808
  }
2809
2809
  }
2810
2810
  _send(e, t) {
2811
- const n = tt(e);
2811
+ const n = nt(e);
2812
2812
  if (n instanceof Promise) return this._send_blob(n);
2813
2813
  if (!t && n.byteLength > this.chunker.chunkedMTU) {
2814
2814
  this._sendChunks(n);
@@ -2826,11 +2826,11 @@ class he extends Be {
2826
2826
  }
2827
2827
  _sendChunks(e) {
2828
2828
  const t = this.chunker.chunk(e);
2829
- p.log(`DC#${this.connectionId} Try to send ${t.length} chunks...`);
2829
+ d.log(`DC#${this.connectionId} Try to send ${t.length} chunks...`);
2830
2830
  for (const n of t) this.send(n, !0);
2831
2831
  }
2832
2832
  }
2833
- class Rn extends Be {
2833
+ class En extends Be {
2834
2834
  _handleDataMessage({ data: e }) {
2835
2835
  super.emit("data", e);
2836
2836
  }
@@ -2841,7 +2841,7 @@ class Rn extends Be {
2841
2841
  super(...e), this.serialization = ie.None;
2842
2842
  }
2843
2843
  }
2844
- class En extends Be {
2844
+ class Pn extends Be {
2845
2845
  // Handles a DataChannel message.
2846
2846
  _handleDataMessage({ data: e }) {
2847
2847
  const t = this.parse(this.decoder.decode(e)), n = t.__peerData;
@@ -2863,7 +2863,7 @@ class En extends Be {
2863
2863
  super(...e), this.serialization = ie.JSON, this.encoder = new TextEncoder(), this.decoder = new TextDecoder(), this.stringify = JSON.stringify, this.parse = JSON.parse;
2864
2864
  }
2865
2865
  }
2866
- var Ae;
2866
+ var Me;
2867
2867
  const V = class V extends Ft {
2868
2868
  /**
2869
2869
  * The brokering ID of this peer
@@ -2910,8 +2910,8 @@ const V = class V extends Ft {
2910
2910
  }
2911
2911
  constructor(e, t) {
2912
2912
  super(), this._serializers = {
2913
- raw: Rn,
2914
- json: En,
2913
+ raw: En,
2914
+ json: Pn,
2915
2915
  binary: he,
2916
2916
  "binary-utf8": he,
2917
2917
  default: he
@@ -2932,7 +2932,7 @@ const V = class V extends Ft {
2932
2932
  }, this._options = t, this._serializers = {
2933
2933
  ...this._serializers,
2934
2934
  ...this.options.serializers
2935
- }, this._options.host === "/" && (this._options.host = window.location.hostname), this._options.path && (this._options.path[0] !== "/" && (this._options.path = "/" + this._options.path), this._options.path[this._options.path.length - 1] !== "/" && (this._options.path += "/")), this._options.secure === void 0 && this._options.host !== k.CLOUD_HOST ? this._options.secure = k.isSecure() : this._options.host == k.CLOUD_HOST && (this._options.secure = !0), this._options.logFunction && p.setLogFunction(this._options.logFunction), p.logLevel = this._options.debug || 0, this._api = new xn(t), this._socket = this._createServerConnection(), !k.supports.audioVideo && !k.supports.data) {
2935
+ }, this._options.host === "/" && (this._options.host = window.location.hostname), this._options.path && (this._options.path[0] !== "/" && (this._options.path = "/" + this._options.path), this._options.path[this._options.path.length - 1] !== "/" && (this._options.path += "/")), this._options.secure === void 0 && this._options.host !== k.CLOUD_HOST ? this._options.secure = k.isSecure() : this._options.host == k.CLOUD_HOST && (this._options.secure = !0), this._options.logFunction && d.setLogFunction(this._options.logFunction), d.logLevel = this._options.debug || 0, this._api = new xn(t), this._socket = this._createServerConnection(), !k.supports.audioVideo && !k.supports.data) {
2936
2936
  this._delayedAbort(g.BrowserIncompatible, "The current browser does not support WebRTC");
2937
2937
  return;
2938
2938
  }
@@ -2943,7 +2943,7 @@ const V = class V extends Ft {
2943
2943
  n ? this._initialize(n) : this._api.retrieveId().then((s) => this._initialize(s)).catch((s) => this._abort(g.ServerError, s));
2944
2944
  }
2945
2945
  _createServerConnection() {
2946
- const e = new kn(this._options.secure, this._options.host, this._options.port, this._options.path, this._options.key, this._options.pingInterval);
2946
+ const e = new Tn(this._options.secure, this._options.host, this._options.port, this._options.path, this._options.key, this._options.pingInterval);
2947
2947
  return e.on(P.Message, (t) => {
2948
2948
  this._handleMessage(t);
2949
2949
  }), e.on(P.Error, (t) => {
@@ -2975,7 +2975,7 @@ const V = class V extends Ft {
2975
2975
  this._abort(g.InvalidKey, `API KEY "${this._options.key}" is invalid`);
2976
2976
  break;
2977
2977
  case b.Leave:
2978
- p.log(`Received leave message from ${s}`), this._cleanupPeer(s), this._connections.delete(s);
2978
+ d.log(`Received leave message from ${s}`), this._cleanupPeer(s), this._connections.delete(s);
2979
2979
  break;
2980
2980
  case b.Expire:
2981
2981
  this.emitError(g.PeerUnavailable, `Could not connect to peer ${s}`);
@@ -2983,7 +2983,7 @@ const V = class V extends Ft {
2983
2983
  case b.Offer: {
2984
2984
  const i = n.connectionId;
2985
2985
  let o = this.getConnection(s, i);
2986
- if (o && (o.close(), p.warn(`Offer received for existing Connection ID:${i}`)), n.type === O.Media) {
2986
+ if (o && (o.close(), d.warn(`Offer received for existing Connection ID:${i}`)), n.type === O.Media) {
2987
2987
  const c = new re(s, this, {
2988
2988
  connectionId: i,
2989
2989
  _payload: n,
@@ -3001,7 +3001,7 @@ const V = class V extends Ft {
3001
3001
  });
3002
3002
  o = c, this._addConnection(s, o), this.emit("connection", c);
3003
3003
  } else {
3004
- p.warn(`Received malformed connection type:${n.type}`);
3004
+ d.warn(`Received malformed connection type:${n.type}`);
3005
3005
  return;
3006
3006
  }
3007
3007
  const a = this._getMessages(i);
@@ -3010,11 +3010,11 @@ const V = class V extends Ft {
3010
3010
  }
3011
3011
  default: {
3012
3012
  if (!n) {
3013
- p.warn(`You received a malformed message from ${s} of type ${t}`);
3013
+ d.warn(`You received a malformed message from ${s} of type ${t}`);
3014
3014
  return;
3015
3015
  }
3016
3016
  const i = n.connectionId, o = this.getConnection(s, i);
3017
- o && o.peerConnection ? o.handleMessage(e) : i ? this._storeMessage(i, e) : p.warn("You received an unrecognized message:", e);
3017
+ o && o.peerConnection ? o.handleMessage(e) : i ? this._storeMessage(i, e) : d.warn("You received an unrecognized message:", e);
3018
3018
  break;
3019
3019
  }
3020
3020
  }
@@ -3042,7 +3042,7 @@ const V = class V extends Ft {
3042
3042
  serialization: "default",
3043
3043
  ...t
3044
3044
  }, this.disconnected) {
3045
- p.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect, or call reconnect on this peer if you believe its ID to still be available."), this.emitError(g.Disconnected, "Cannot connect to new Peer after disconnecting from server.");
3045
+ d.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect, or call reconnect on this peer if you believe its ID to still be available."), this.emitError(g.Disconnected, "Cannot connect to new Peer after disconnecting from server.");
3046
3046
  return;
3047
3047
  }
3048
3048
  const n = new this._serializers[t.serialization](e, this, t);
@@ -3056,11 +3056,11 @@ const V = class V extends Ft {
3056
3056
  */
3057
3057
  call(e, t, n = {}) {
3058
3058
  if (this.disconnected) {
3059
- p.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect."), this.emitError(g.Disconnected, "Cannot connect to new Peer after disconnecting from server.");
3059
+ d.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect."), this.emitError(g.Disconnected, "Cannot connect to new Peer after disconnecting from server.");
3060
3060
  return;
3061
3061
  }
3062
3062
  if (!t) {
3063
- p.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");
3063
+ d.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");
3064
3064
  return;
3065
3065
  }
3066
3066
  const s = new re(e, this, {
@@ -3071,7 +3071,7 @@ const V = class V extends Ft {
3071
3071
  }
3072
3072
  /** Add a data/media connection to this peer. */
3073
3073
  _addConnection(e, t) {
3074
- p.log(`add connection ${t.type}:${t.connectionId} to peerId:${e}`), this._connections.has(e) || this._connections.set(e, []), this._connections.get(e).push(t);
3074
+ d.log(`add connection ${t.type}:${t.connectionId} to peerId:${e}`), this._connections.has(e) || this._connections.set(e, []), this._connections.get(e).push(t);
3075
3075
  }
3076
3076
  //TODO should be private
3077
3077
  _removeConnection(e) {
@@ -3101,7 +3101,7 @@ const V = class V extends Ft {
3101
3101
  * it retains its disconnected state and its existing connections.
3102
3102
  */
3103
3103
  _abort(e, t) {
3104
- p.error("Aborting!"), this.emitError(e, t), this._lastServerId ? this.disconnect() : this.destroy();
3104
+ d.error("Aborting!"), this.emitError(e, t), this._lastServerId ? this.disconnect() : this.destroy();
3105
3105
  }
3106
3106
  /**
3107
3107
  * Destroys the Peer: closes all active connections as well as the connection
@@ -3114,7 +3114,7 @@ const V = class V extends Ft {
3114
3114
  * :::
3115
3115
  */
3116
3116
  destroy() {
3117
- this.destroyed || (p.log(`Destroy peer with ID:${this.id}`), this.disconnect(), this._cleanup(), this._destroyed = !0, this.emit("close"));
3117
+ this.destroyed || (d.log(`Destroy peer with ID:${this.id}`), this.disconnect(), this._cleanup(), this._destroyed = !0, this.emit("close"));
3118
3118
  }
3119
3119
  /** Disconnects every connection on this peer. */
3120
3120
  _cleanup() {
@@ -3137,7 +3137,7 @@ const V = class V extends Ft {
3137
3137
  disconnect() {
3138
3138
  if (this.disconnected) return;
3139
3139
  const e = this.id;
3140
- p.log(`Disconnect peer with ID:${e}`), this._disconnected = !0, this._open = !1, this.socket.close(), this._lastServerId = e, this._id = null, this.emit("disconnected", e);
3140
+ d.log(`Disconnect peer with ID:${e}`), this._disconnected = !0, this._open = !1, this.socket.close(), this._lastServerId = e, this._id = null, this.emit("disconnected", e);
3141
3141
  }
3142
3142
  /** Attempts to reconnect with the same ID.
3143
3143
  *
@@ -3148,11 +3148,11 @@ const V = class V extends Ft {
3148
3148
  */
3149
3149
  reconnect() {
3150
3150
  if (this.disconnected && !this.destroyed)
3151
- p.log(`Attempting reconnection to server with ID ${this._lastServerId}`), this._disconnected = !1, this._initialize(this._lastServerId);
3151
+ d.log(`Attempting reconnection to server with ID ${this._lastServerId}`), this._disconnected = !1, this._initialize(this._lastServerId);
3152
3152
  else {
3153
3153
  if (this.destroyed) throw new Error("This peer cannot reconnect to the server. It has already been destroyed.");
3154
3154
  if (!this.disconnected && !this.open)
3155
- p.error("In a hurry? We're still trying to make the initial connection!");
3155
+ d.error("In a hurry? We're still trying to make the initial connection!");
3156
3156
  else throw new Error(`Peer ${this.id} cannot reconnect because it is not disconnected from the server!`);
3157
3157
  }
3158
3158
  }
@@ -3167,10 +3167,10 @@ const V = class V extends Ft {
3167
3167
  this._api.listAllPeers().then((t) => e(t)).catch((t) => this._abort(g.ServerError, t));
3168
3168
  }
3169
3169
  };
3170
- Ae = new WeakMap(), U(V, Ae, V.DEFAULT_KEY = "peerjs");
3170
+ Me = new WeakMap(), U(V, Me, V.DEFAULT_KEY = "peerjs");
3171
3171
  let Ce = V;
3172
- var Pn = Ce;
3173
- class On {
3172
+ var On = Ce;
3173
+ class Mn {
3174
3174
  constructor(e) {
3175
3175
  this.config = e, this.peer = null, this.localStream = null, this.connections = {}, this.callbacks = {
3176
3176
  onStream: null,
@@ -3180,7 +3180,7 @@ class On {
3180
3180
  }
3181
3181
  async initialize(e) {
3182
3182
  return new Promise((t, n) => {
3183
- this.peer = new Pn(e, {
3183
+ this.peer = new On(e, {
3184
3184
  host: this.config.peerServer.host,
3185
3185
  port: this.config.peerServer.port,
3186
3186
  path: this.config.peerServer.path || "/peerjs",
@@ -3271,59 +3271,59 @@ const Z = /* @__PURE__ */ Object.create(null);
3271
3271
  Object.keys(E).forEach((r) => {
3272
3272
  Z[E[r]] = r;
3273
3273
  });
3274
- const ve = { type: "error", data: "parser error" }, zt = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Vt = typeof ArrayBuffer == "function", qt = (r) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(r) : r && r.buffer instanceof ArrayBuffer, $e = ({ type: r, data: e }, t, n) => zt && e instanceof Blob ? t ? n(e) : Ye(e, n) : Vt && (e instanceof ArrayBuffer || qt(e)) ? t ? n(e) : Ye(new Blob([e]), n) : n(E[r] + (e || "")), Ye = (r, e) => {
3274
+ const ve = { type: "error", data: "parser error" }, Vt = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", qt = typeof ArrayBuffer == "function", Ht = (r) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(r) : r && r.buffer instanceof ArrayBuffer, $e = ({ type: r, data: e }, t, n) => Vt && e instanceof Blob ? t ? n(e) : We(e, n) : qt && (e instanceof ArrayBuffer || Ht(e)) ? t ? n(e) : We(new Blob([e]), n) : n(E[r] + (e || "")), We = (r, e) => {
3275
3275
  const t = new FileReader();
3276
3276
  return t.onload = function() {
3277
3277
  const n = t.result.split(",")[1];
3278
3278
  e("b" + (n || ""));
3279
3279
  }, t.readAsDataURL(r);
3280
3280
  };
3281
- function We(r) {
3281
+ function Xe(r) {
3282
3282
  return r instanceof Uint8Array ? r : r instanceof ArrayBuffer ? new Uint8Array(r) : new Uint8Array(r.buffer, r.byteOffset, r.byteLength);
3283
3283
  }
3284
3284
  let fe;
3285
3285
  function An(r, e) {
3286
- if (zt && r.data instanceof Blob)
3287
- return r.data.arrayBuffer().then(We).then(e);
3288
- if (Vt && (r.data instanceof ArrayBuffer || qt(r.data)))
3289
- return e(We(r.data));
3286
+ if (Vt && r.data instanceof Blob)
3287
+ return r.data.arrayBuffer().then(Xe).then(e);
3288
+ if (qt && (r.data instanceof ArrayBuffer || Ht(r.data)))
3289
+ return e(Xe(r.data));
3290
3290
  $e(r, !1, (t) => {
3291
3291
  fe || (fe = new TextEncoder()), e(fe.encode(t));
3292
3292
  });
3293
3293
  }
3294
- const Xe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", w = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
3295
- for (let r = 0; r < Xe.length; r++)
3296
- w[Xe.charCodeAt(r)] = r;
3297
- const Mn = (r) => {
3294
+ const Qe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", F = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
3295
+ for (let r = 0; r < Qe.length; r++)
3296
+ F[Qe.charCodeAt(r)] = r;
3297
+ const Dn = (r) => {
3298
3298
  let e = r.length * 0.75, t = r.length, n, s = 0, i, o, a, c;
3299
3299
  r[r.length - 1] === "=" && (e--, r[r.length - 2] === "=" && e--);
3300
3300
  const h = new ArrayBuffer(e), f = new Uint8Array(h);
3301
3301
  for (n = 0; n < t; n += 4)
3302
- i = w[r.charCodeAt(n)], o = w[r.charCodeAt(n + 1)], a = w[r.charCodeAt(n + 2)], c = w[r.charCodeAt(n + 3)], f[s++] = i << 2 | o >> 4, f[s++] = (o & 15) << 4 | a >> 2, f[s++] = (a & 3) << 6 | c & 63;
3302
+ i = F[r.charCodeAt(n)], o = F[r.charCodeAt(n + 1)], a = F[r.charCodeAt(n + 2)], c = F[r.charCodeAt(n + 3)], f[s++] = i << 2 | o >> 4, f[s++] = (o & 15) << 4 | a >> 2, f[s++] = (a & 3) << 6 | c & 63;
3303
3303
  return h;
3304
- }, Dn = typeof ArrayBuffer == "function", Ue = (r, e) => {
3304
+ }, Ln = typeof ArrayBuffer == "function", Ue = (r, e) => {
3305
3305
  if (typeof r != "string")
3306
3306
  return {
3307
3307
  type: "message",
3308
- data: Ht(r, e)
3308
+ data: Kt(r, e)
3309
3309
  };
3310
3310
  const t = r.charAt(0);
3311
3311
  return t === "b" ? {
3312
3312
  type: "message",
3313
- data: Ln(r.substring(1), e)
3313
+ data: In(r.substring(1), e)
3314
3314
  } : Z[t] ? r.length > 1 ? {
3315
3315
  type: Z[t],
3316
3316
  data: r.substring(1)
3317
3317
  } : {
3318
3318
  type: Z[t]
3319
3319
  } : ve;
3320
- }, Ln = (r, e) => {
3321
- if (Dn) {
3322
- const t = Mn(r);
3323
- return Ht(t, e);
3320
+ }, In = (r, e) => {
3321
+ if (Ln) {
3322
+ const t = Dn(r);
3323
+ return Kt(t, e);
3324
3324
  } else
3325
3325
  return { base64: !0, data: r };
3326
- }, Ht = (r, e) => {
3326
+ }, Kt = (r, e) => {
3327
3327
  switch (e) {
3328
3328
  case "blob":
3329
3329
  return r instanceof Blob ? r : new Blob([r]);
@@ -3331,16 +3331,16 @@ const Mn = (r) => {
3331
3331
  default:
3332
3332
  return r instanceof ArrayBuffer ? r : r.buffer;
3333
3333
  }
3334
- }, Kt = "", In = (r, e) => {
3334
+ }, Jt = "", Bn = (r, e) => {
3335
3335
  const t = r.length, n = new Array(t);
3336
3336
  let s = 0;
3337
3337
  r.forEach((i, o) => {
3338
3338
  $e(i, !1, (a) => {
3339
- n[o] = a, ++s === t && e(n.join(Kt));
3339
+ n[o] = a, ++s === t && e(n.join(Jt));
3340
3340
  });
3341
3341
  });
3342
- }, Bn = (r, e) => {
3343
- const t = r.split(Kt), n = [];
3342
+ }, $n = (r, e) => {
3343
+ const t = r.split(Jt), n = [];
3344
3344
  for (let s = 0; s < t.length; s++) {
3345
3345
  const i = Ue(t[s], e);
3346
3346
  if (n.push(i), i.type === "error")
@@ -3348,7 +3348,7 @@ const Mn = (r) => {
3348
3348
  }
3349
3349
  return n;
3350
3350
  };
3351
- function $n() {
3351
+ function Un() {
3352
3352
  return new TransformStream({
3353
3353
  transform(r, e) {
3354
3354
  An(r, (t) => {
@@ -3383,7 +3383,7 @@ function K(r, e) {
3383
3383
  t[s] = r[0][n++], n === r[0].length && (r.shift(), n = 0);
3384
3384
  return r.length && n < r[0].length && (r[0] = r[0].slice(n)), t;
3385
3385
  }
3386
- function Un(r, e) {
3386
+ function wn(r, e) {
3387
3387
  le || (le = new TextDecoder());
3388
3388
  const t = [];
3389
3389
  let n = 0, s = -1, i = !1;
@@ -3423,7 +3423,7 @@ function Un(r, e) {
3423
3423
  }
3424
3424
  });
3425
3425
  }
3426
- const Jt = 4;
3426
+ const Gt = 4;
3427
3427
  function y(r) {
3428
3428
  if (r) return Nn(r);
3429
3429
  }
@@ -3474,33 +3474,33 @@ y.prototype.hasListeners = function(r) {
3474
3474
  return !!this.listeners(r).length;
3475
3475
  };
3476
3476
  const oe = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), T = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), jn = "arraybuffer";
3477
- function Gt(r, ...e) {
3477
+ function Yt(r, ...e) {
3478
3478
  return e.reduce((t, n) => (r.hasOwnProperty(n) && (t[n] = r[n]), t), {});
3479
3479
  }
3480
- const Fn = T.setTimeout, wn = T.clearTimeout;
3480
+ const Fn = T.setTimeout, zn = T.clearTimeout;
3481
3481
  function ae(r, e) {
3482
- e.useNativeTimers ? (r.setTimeoutFn = Fn.bind(T), r.clearTimeoutFn = wn.bind(T)) : (r.setTimeoutFn = T.setTimeout.bind(T), r.clearTimeoutFn = T.clearTimeout.bind(T));
3483
- }
3484
- const zn = 1.33;
3485
- function Vn(r) {
3486
- return typeof r == "string" ? qn(r) : Math.ceil((r.byteLength || r.size) * zn);
3482
+ e.useNativeTimers ? (r.setTimeoutFn = Fn.bind(T), r.clearTimeoutFn = zn.bind(T)) : (r.setTimeoutFn = T.setTimeout.bind(T), r.clearTimeoutFn = T.clearTimeout.bind(T));
3487
3483
  }
3484
+ const Vn = 1.33;
3488
3485
  function qn(r) {
3486
+ return typeof r == "string" ? Hn(r) : Math.ceil((r.byteLength || r.size) * Vn);
3487
+ }
3488
+ function Hn(r) {
3489
3489
  let e = 0, t = 0;
3490
3490
  for (let n = 0, s = r.length; n < s; n++)
3491
3491
  e = r.charCodeAt(n), e < 128 ? t += 1 : e < 2048 ? t += 2 : e < 55296 || e >= 57344 ? t += 3 : (n++, t += 4);
3492
3492
  return t;
3493
3493
  }
3494
- function Yt() {
3494
+ function Wt() {
3495
3495
  return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
3496
3496
  }
3497
- function Hn(r) {
3497
+ function Kn(r) {
3498
3498
  let e = "";
3499
3499
  for (let t in r)
3500
3500
  r.hasOwnProperty(t) && (e.length && (e += "&"), e += encodeURIComponent(t) + "=" + encodeURIComponent(r[t]));
3501
3501
  return e;
3502
3502
  }
3503
- function Kn(r) {
3503
+ function Jn(r) {
3504
3504
  let e = {}, t = r.split("&");
3505
3505
  for (let n = 0, s = t.length; n < s; n++) {
3506
3506
  let i = t[n].split("=");
@@ -3508,12 +3508,12 @@ function Kn(r) {
3508
3508
  }
3509
3509
  return e;
3510
3510
  }
3511
- class Jn extends Error {
3511
+ class Gn extends Error {
3512
3512
  constructor(e, t, n) {
3513
3513
  super(e), this.description = t, this.context = n, this.type = "TransportError";
3514
3514
  }
3515
3515
  }
3516
- class Ne extends y {
3516
+ class we extends y {
3517
3517
  /**
3518
3518
  * Transport abstract constructor.
3519
3519
  *
@@ -3533,7 +3533,7 @@ class Ne extends y {
3533
3533
  * @protected
3534
3534
  */
3535
3535
  onError(e, t, n) {
3536
- return super.emitReserved("error", new Jn(e, t, n)), this;
3536
+ return super.emitReserved("error", new Gn(e, t, n)), this;
3537
3537
  }
3538
3538
  /**
3539
3539
  * Opens the transport.
@@ -3607,11 +3607,11 @@ class Ne extends y {
3607
3607
  return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
3608
3608
  }
3609
3609
  _query(e) {
3610
- const t = Hn(e);
3610
+ const t = Kn(e);
3611
3611
  return t.length ? "?" + t : "";
3612
3612
  }
3613
3613
  }
3614
- class Gn extends Ne {
3614
+ class Yn extends we {
3615
3615
  constructor() {
3616
3616
  super(...arguments), this._polling = !1;
3617
3617
  }
@@ -3667,7 +3667,7 @@ class Gn extends Ne {
3667
3667
  return this.onClose({ description: "transport closed by the server" }), !1;
3668
3668
  this.onPacket(n);
3669
3669
  };
3670
- Bn(e, this.socket.binaryType).forEach(t), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
3670
+ $n(e, this.socket.binaryType).forEach(t), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
3671
3671
  }
3672
3672
  /**
3673
3673
  * For polling, send a close packet.
@@ -3687,7 +3687,7 @@ class Gn extends Ne {
3687
3687
  * @protected
3688
3688
  */
3689
3689
  write(e) {
3690
- this.writable = !1, In(e, (t) => {
3690
+ this.writable = !1, Bn(e, (t) => {
3691
3691
  this.doWrite(t, () => {
3692
3692
  this.writable = !0, this.emitReserved("drain");
3693
3693
  });
@@ -3700,18 +3700,18 @@ class Gn extends Ne {
3700
3700
  */
3701
3701
  uri() {
3702
3702
  const e = this.opts.secure ? "https" : "http", t = this.query || {};
3703
- return this.opts.timestampRequests !== !1 && (t[this.opts.timestampParam] = Yt()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
3703
+ return this.opts.timestampRequests !== !1 && (t[this.opts.timestampParam] = Wt()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
3704
3704
  }
3705
3705
  }
3706
- let Wt = !1;
3706
+ let Xt = !1;
3707
3707
  try {
3708
- Wt = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
3708
+ Xt = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
3709
3709
  } catch {
3710
3710
  }
3711
- const Yn = Wt;
3712
- function Wn() {
3711
+ const Wn = Xt;
3712
+ function Xn() {
3713
3713
  }
3714
- class Xn extends Gn {
3714
+ class Qn extends Yn {
3715
3715
  /**
3716
3716
  * XHR Polling constructor.
3717
3717
  *
@@ -3753,7 +3753,7 @@ class Xn extends Gn {
3753
3753
  }), this.pollXhr = e;
3754
3754
  }
3755
3755
  }
3756
- class R extends y {
3756
+ class x extends y {
3757
3757
  /**
3758
3758
  * Request constructor
3759
3759
  *
@@ -3770,7 +3770,7 @@ class R extends y {
3770
3770
  */
3771
3771
  _create() {
3772
3772
  var e;
3773
- const t = Gt(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
3773
+ const t = Yt(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
3774
3774
  t.xdomain = !!this._opts.xd;
3775
3775
  const n = this._xhr = this.createRequest(t);
3776
3776
  try {
@@ -3807,7 +3807,7 @@ class R extends y {
3807
3807
  }, 0);
3808
3808
  return;
3809
3809
  }
3810
- typeof document < "u" && (this._index = R.requestsCount++, R.requests[this._index] = this);
3810
+ typeof document < "u" && (this._index = x.requestsCount++, x.requests[this._index] = this);
3811
3811
  }
3812
3812
  /**
3813
3813
  * Called upon error.
@@ -3824,12 +3824,12 @@ class R extends y {
3824
3824
  */
3825
3825
  _cleanup(e) {
3826
3826
  if (!(typeof this._xhr > "u" || this._xhr === null)) {
3827
- if (this._xhr.onreadystatechange = Wn, e)
3827
+ if (this._xhr.onreadystatechange = Xn, e)
3828
3828
  try {
3829
3829
  this._xhr.abort();
3830
3830
  } catch {
3831
3831
  }
3832
- typeof document < "u" && delete R.requests[this._index], this._xhr = null;
3832
+ typeof document < "u" && delete x.requests[this._index], this._xhr = null;
3833
3833
  }
3834
3834
  }
3835
3835
  /**
@@ -3850,40 +3850,40 @@ class R extends y {
3850
3850
  this._cleanup();
3851
3851
  }
3852
3852
  }
3853
- R.requestsCount = 0;
3854
- R.requests = {};
3853
+ x.requestsCount = 0;
3854
+ x.requests = {};
3855
3855
  if (typeof document < "u") {
3856
3856
  if (typeof attachEvent == "function")
3857
- attachEvent("onunload", Qe);
3857
+ attachEvent("onunload", Ze);
3858
3858
  else if (typeof addEventListener == "function") {
3859
3859
  const r = "onpagehide" in T ? "pagehide" : "unload";
3860
- addEventListener(r, Qe, !1);
3860
+ addEventListener(r, Ze, !1);
3861
3861
  }
3862
3862
  }
3863
- function Qe() {
3864
- for (let r in R.requests)
3865
- R.requests.hasOwnProperty(r) && R.requests[r].abort();
3863
+ function Ze() {
3864
+ for (let r in x.requests)
3865
+ x.requests.hasOwnProperty(r) && x.requests[r].abort();
3866
3866
  }
3867
- const Qn = function() {
3868
- const r = Xt({
3867
+ const Zn = function() {
3868
+ const r = Qt({
3869
3869
  xdomain: !1
3870
3870
  });
3871
3871
  return r && r.responseType !== null;
3872
3872
  }();
3873
- class Zn extends Xn {
3873
+ class er extends Qn {
3874
3874
  constructor(e) {
3875
3875
  super(e);
3876
3876
  const t = e && e.forceBase64;
3877
- this.supportsBinary = Qn && !t;
3877
+ this.supportsBinary = Zn && !t;
3878
3878
  }
3879
3879
  request(e = {}) {
3880
- return Object.assign(e, { xd: this.xd }, this.opts), new R(Xt, this.uri(), e);
3880
+ return Object.assign(e, { xd: this.xd }, this.opts), new x(Qt, this.uri(), e);
3881
3881
  }
3882
3882
  }
3883
- function Xt(r) {
3883
+ function Qt(r) {
3884
3884
  const e = r.xdomain;
3885
3885
  try {
3886
- if (typeof XMLHttpRequest < "u" && (!e || Yn))
3886
+ if (typeof XMLHttpRequest < "u" && (!e || Wn))
3887
3887
  return new XMLHttpRequest();
3888
3888
  } catch {
3889
3889
  }
@@ -3893,13 +3893,13 @@ function Xt(r) {
3893
3893
  } catch {
3894
3894
  }
3895
3895
  }
3896
- const Qt = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
3897
- class er extends Ne {
3896
+ const Zt = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
3897
+ class tr extends we {
3898
3898
  get name() {
3899
3899
  return "websocket";
3900
3900
  }
3901
3901
  doOpen() {
3902
- const e = this.uri(), t = this.opts.protocols, n = Qt ? {} : Gt(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
3902
+ const e = this.uri(), t = this.opts.protocols, n = Zt ? {} : Yt(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
3903
3903
  this.opts.extraHeaders && (n.headers = this.opts.extraHeaders);
3904
3904
  try {
3905
3905
  this.ws = this.createSocket(e, t, n);
@@ -3947,19 +3947,19 @@ class er extends Ne {
3947
3947
  */
3948
3948
  uri() {
3949
3949
  const e = this.opts.secure ? "wss" : "ws", t = this.query || {};
3950
- return this.opts.timestampRequests && (t[this.opts.timestampParam] = Yt()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
3950
+ return this.opts.timestampRequests && (t[this.opts.timestampParam] = Wt()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
3951
3951
  }
3952
3952
  }
3953
3953
  const ue = T.WebSocket || T.MozWebSocket;
3954
- class tr extends er {
3954
+ class nr extends tr {
3955
3955
  createSocket(e, t, n) {
3956
- return Qt ? new ue(e, t, n) : t ? new ue(e, t) : new ue(e);
3956
+ return Zt ? new ue(e, t, n) : t ? new ue(e, t) : new ue(e);
3957
3957
  }
3958
3958
  doWrite(e, t) {
3959
3959
  this.ws.send(t);
3960
3960
  }
3961
3961
  }
3962
- class nr extends Ne {
3962
+ class rr extends we {
3963
3963
  get name() {
3964
3964
  return "webtransport";
3965
3965
  }
@@ -3975,7 +3975,7 @@ class nr extends Ne {
3975
3975
  this.onError("webtransport error", e);
3976
3976
  }), this._transport.ready.then(() => {
3977
3977
  this._transport.createBidirectionalStream().then((e) => {
3978
- const t = Un(Number.MAX_SAFE_INTEGER, this.socket.binaryType), n = e.readable.pipeThrough(t).getReader(), s = $n();
3978
+ const t = wn(Number.MAX_SAFE_INTEGER, this.socket.binaryType), n = e.readable.pipeThrough(t).getReader(), s = Un();
3979
3979
  s.readable.pipeTo(e.writable), this._writer = s.writable.getWriter();
3980
3980
  const i = () => {
3981
3981
  n.read().then(({ done: a, value: c }) => {
@@ -4005,11 +4005,11 @@ class nr extends Ne {
4005
4005
  (e = this._transport) === null || e === void 0 || e.close();
4006
4006
  }
4007
4007
  }
4008
- const rr = {
4009
- websocket: tr,
4010
- webtransport: nr,
4011
- polling: Zn
4012
- }, sr = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, ir = [
4008
+ const sr = {
4009
+ websocket: nr,
4010
+ webtransport: rr,
4011
+ polling: er
4012
+ }, ir = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, or = [
4013
4013
  "source",
4014
4014
  "protocol",
4015
4015
  "authority",
@@ -4030,16 +4030,16 @@ function Se(r) {
4030
4030
  throw "URI too long";
4031
4031
  const e = r, t = r.indexOf("["), n = r.indexOf("]");
4032
4032
  t != -1 && n != -1 && (r = r.substring(0, t) + r.substring(t, n).replace(/:/g, ";") + r.substring(n, r.length));
4033
- let s = sr.exec(r || ""), i = {}, o = 14;
4033
+ let s = ir.exec(r || ""), i = {}, o = 14;
4034
4034
  for (; o--; )
4035
- i[ir[o]] = s[o] || "";
4036
- return t != -1 && n != -1 && (i.source = e, i.host = i.host.substring(1, i.host.length - 1).replace(/;/g, ":"), i.authority = i.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), i.ipv6uri = !0), i.pathNames = or(i, i.path), i.queryKey = ar(i, i.query), i;
4035
+ i[or[o]] = s[o] || "";
4036
+ return t != -1 && n != -1 && (i.source = e, i.host = i.host.substring(1, i.host.length - 1).replace(/;/g, ":"), i.authority = i.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), i.ipv6uri = !0), i.pathNames = ar(i, i.path), i.queryKey = cr(i, i.query), i;
4037
4037
  }
4038
- function or(r, e) {
4038
+ function ar(r, e) {
4039
4039
  const t = /\/{2,9}/g, n = e.replace(t, "/").split("/");
4040
4040
  return (e.slice(0, 1) == "/" || e.length === 0) && n.splice(0, 1), e.slice(-1) == "/" && n.splice(n.length - 1, 1), n;
4041
4041
  }
4042
- function ar(r, e) {
4042
+ function cr(r, e) {
4043
4043
  const t = {};
4044
4044
  return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(n, s, i) {
4045
4045
  s && (t[s] = i);
@@ -4049,7 +4049,7 @@ const ke = typeof addEventListener == "function" && typeof removeEventListener =
4049
4049
  ke && addEventListener("offline", () => {
4050
4050
  ee.forEach((r) => r());
4051
4051
  }, !1);
4052
- class A extends y {
4052
+ class M extends y {
4053
4053
  /**
4054
4054
  * Socket constructor.
4055
4055
  *
@@ -4078,7 +4078,7 @@ class A extends y {
4078
4078
  },
4079
4079
  transportOptions: {},
4080
4080
  closeOnBeforeunload: !1
4081
- }, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = Kn(this.opts.query)), ke && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
4081
+ }, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = Jn(this.opts.query)), ke && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
4082
4082
  this.transport && (this.transport.removeAllListeners(), this.transport.close());
4083
4083
  }, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
4084
4084
  this._onClose("transport close", {
@@ -4095,7 +4095,7 @@ class A extends y {
4095
4095
  */
4096
4096
  createTransport(e) {
4097
4097
  const t = Object.assign({}, this.opts.query);
4098
- t.EIO = Jt, t.transport = e, this.id && (t.sid = this.id);
4098
+ t.EIO = Gt, t.transport = e, this.id && (t.sid = this.id);
4099
4099
  const n = Object.assign({}, this.opts, {
4100
4100
  query: t,
4101
4101
  socket: this,
@@ -4117,7 +4117,7 @@ class A extends y {
4117
4117
  }, 0);
4118
4118
  return;
4119
4119
  }
4120
- const e = this.opts.rememberUpgrade && A.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
4120
+ const e = this.opts.rememberUpgrade && M.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
4121
4121
  this.readyState = "opening";
4122
4122
  const t = this.createTransport(e);
4123
4123
  t.open(), this.setTransport(t);
@@ -4136,7 +4136,7 @@ class A extends y {
4136
4136
  * @private
4137
4137
  */
4138
4138
  onOpen() {
4139
- this.readyState = "open", A.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
4139
+ this.readyState = "open", M.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
4140
4140
  }
4141
4141
  /**
4142
4142
  * Handles a packet.
@@ -4213,7 +4213,7 @@ class A extends y {
4213
4213
  let t = 1;
4214
4214
  for (let n = 0; n < this.writeBuffer.length; n++) {
4215
4215
  const s = this.writeBuffer[n].data;
4216
- if (s && (t += Vn(s)), n > 0 && t > this._maxPayload)
4216
+ if (s && (t += qn(s)), n > 0 && t > this._maxPayload)
4217
4217
  return this.writeBuffer.slice(0, n);
4218
4218
  t += 2;
4219
4219
  }
@@ -4300,7 +4300,7 @@ class A extends y {
4300
4300
  * @private
4301
4301
  */
4302
4302
  _onError(e) {
4303
- if (A.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
4303
+ if (M.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
4304
4304
  return this.transports.shift(), this._open();
4305
4305
  this.emitReserved("error", e), this._onClose("transport error", e);
4306
4306
  }
@@ -4319,8 +4319,8 @@ class A extends y {
4319
4319
  }
4320
4320
  }
4321
4321
  }
4322
- A.protocol = Jt;
4323
- class cr extends A {
4322
+ M.protocol = Gt;
4323
+ class hr extends M {
4324
4324
  constructor() {
4325
4325
  super(...arguments), this._upgrades = [];
4326
4326
  }
@@ -4337,14 +4337,14 @@ class cr extends A {
4337
4337
  */
4338
4338
  _probe(e) {
4339
4339
  let t = this.createTransport(e), n = !1;
4340
- A.priorWebsocketSuccess = !1;
4340
+ M.priorWebsocketSuccess = !1;
4341
4341
  const s = () => {
4342
4342
  n || (t.send([{ type: "ping", data: "probe" }]), t.once("packet", (l) => {
4343
4343
  if (!n)
4344
4344
  if (l.type === "pong" && l.data === "probe") {
4345
4345
  if (this.upgrading = !0, this.emitReserved("upgrading", t), !t)
4346
4346
  return;
4347
- A.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
4347
+ M.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
4348
4348
  n || this.readyState !== "closed" && (f(), this.setTransport(t), t.send([{ type: "upgrade" }]), this.emitReserved("upgrade", t), t = null, this.upgrading = !1, this.flush());
4349
4349
  });
4350
4350
  } else {
@@ -4392,21 +4392,21 @@ class cr extends A {
4392
4392
  return t;
4393
4393
  }
4394
4394
  }
4395
- let hr = class extends cr {
4395
+ let fr = class extends hr {
4396
4396
  constructor(e, t = {}) {
4397
4397
  const n = typeof e == "object", s = n ? { ...e } : { ...t };
4398
- (!s.transports || s.transports && typeof s.transports[0] == "string") && (s.transports = (s.transports || ["polling", "websocket", "webtransport"]).map((i) => rr[i]).filter((i) => !!i)), super(n ? s : e, s);
4398
+ (!s.transports || s.transports && typeof s.transports[0] == "string") && (s.transports = (s.transports || ["polling", "websocket", "webtransport"]).map((i) => sr[i]).filter((i) => !!i)), super(n ? s : e, s);
4399
4399
  }
4400
4400
  };
4401
- function fr(r, e = "", t) {
4401
+ function lr(r, e = "", t) {
4402
4402
  let n = r;
4403
4403
  t = t || typeof location < "u" && location, r == null && (r = t.protocol + "//" + t.host), typeof r == "string" && (r.charAt(0) === "/" && (r.charAt(1) === "/" ? r = t.protocol + r : r = t.host + r), /^(https?|wss?):\/\//.test(r) || (typeof t < "u" ? r = t.protocol + "//" + r : r = "https://" + r), n = Se(r)), n.port || (/^(http|ws)$/.test(n.protocol) ? n.port = "80" : /^(http|ws)s$/.test(n.protocol) && (n.port = "443")), n.path = n.path || "/";
4404
4404
  const i = n.host.indexOf(":") !== -1 ? "[" + n.host + "]" : n.host;
4405
4405
  return n.id = n.protocol + "://" + i + ":" + n.port + e, n.href = n.protocol + "://" + i + (t && t.port === n.port ? "" : ":" + n.port), n;
4406
4406
  }
4407
- const lr = typeof ArrayBuffer == "function", ur = (r) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(r) : r.buffer instanceof ArrayBuffer, Zt = Object.prototype.toString, pr = typeof Blob == "function" || typeof Blob < "u" && Zt.call(Blob) === "[object BlobConstructor]", dr = typeof File == "function" || typeof File < "u" && Zt.call(File) === "[object FileConstructor]";
4408
- function je(r) {
4409
- return lr && (r instanceof ArrayBuffer || ur(r)) || pr && r instanceof Blob || dr && r instanceof File;
4407
+ const ur = typeof ArrayBuffer == "function", dr = (r) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(r) : r.buffer instanceof ArrayBuffer, en = Object.prototype.toString, pr = typeof Blob == "function" || typeof Blob < "u" && en.call(Blob) === "[object BlobConstructor]", mr = typeof File == "function" || typeof File < "u" && en.call(File) === "[object FileConstructor]";
4408
+ function Ne(r) {
4409
+ return ur && (r instanceof ArrayBuffer || dr(r)) || pr && r instanceof Blob || mr && r instanceof File;
4410
4410
  }
4411
4411
  function te(r, e) {
4412
4412
  if (!r || typeof r != "object")
@@ -4417,7 +4417,7 @@ function te(r, e) {
4417
4417
  return !0;
4418
4418
  return !1;
4419
4419
  }
4420
- if (je(r))
4420
+ if (Ne(r))
4421
4421
  return !0;
4422
4422
  if (r.toJSON && typeof r.toJSON == "function" && arguments.length === 1)
4423
4423
  return te(r.toJSON(), !0);
@@ -4426,14 +4426,14 @@ function te(r, e) {
4426
4426
  return !0;
4427
4427
  return !1;
4428
4428
  }
4429
- function mr(r) {
4429
+ function gr(r) {
4430
4430
  const e = [], t = r.data, n = r;
4431
4431
  return n.data = Te(t, e), n.attachments = e.length, { packet: n, buffers: e };
4432
4432
  }
4433
4433
  function Te(r, e) {
4434
4434
  if (!r)
4435
4435
  return r;
4436
- if (je(r)) {
4436
+ if (Ne(r)) {
4437
4437
  const t = { _placeholder: !0, num: e.length };
4438
4438
  return e.push(r), t;
4439
4439
  } else if (Array.isArray(r)) {
@@ -4449,10 +4449,10 @@ function Te(r, e) {
4449
4449
  }
4450
4450
  return r;
4451
4451
  }
4452
- function gr(r, e) {
4453
- return r.data = xe(r.data, e), delete r.attachments, r;
4452
+ function yr(r, e) {
4453
+ return r.data = Re(r.data, e), delete r.attachments, r;
4454
4454
  }
4455
- function xe(r, e) {
4455
+ function Re(r, e) {
4456
4456
  if (!r)
4457
4457
  return r;
4458
4458
  if (r && r._placeholder === !0) {
@@ -4461,13 +4461,13 @@ function xe(r, e) {
4461
4461
  throw new Error("illegal attachments");
4462
4462
  } else if (Array.isArray(r))
4463
4463
  for (let t = 0; t < r.length; t++)
4464
- r[t] = xe(r[t], e);
4464
+ r[t] = Re(r[t], e);
4465
4465
  else if (typeof r == "object")
4466
4466
  for (const t in r)
4467
- Object.prototype.hasOwnProperty.call(r, t) && (r[t] = xe(r[t], e));
4467
+ Object.prototype.hasOwnProperty.call(r, t) && (r[t] = Re(r[t], e));
4468
4468
  return r;
4469
4469
  }
4470
- const yr = [
4470
+ const _r = [
4471
4471
  "connect",
4472
4472
  // used on the client side
4473
4473
  "connect_error",
@@ -4485,7 +4485,7 @@ var m;
4485
4485
  (function(r) {
4486
4486
  r[r.CONNECT = 0] = "CONNECT", r[r.DISCONNECT = 1] = "DISCONNECT", r[r.EVENT = 2] = "EVENT", r[r.ACK = 3] = "ACK", r[r.CONNECT_ERROR = 4] = "CONNECT_ERROR", r[r.BINARY_EVENT = 5] = "BINARY_EVENT", r[r.BINARY_ACK = 6] = "BINARY_ACK";
4487
4487
  })(m || (m = {}));
4488
- class _r {
4488
+ class br {
4489
4489
  /**
4490
4490
  * Encoder constructor
4491
4491
  *
@@ -4521,11 +4521,11 @@ class _r {
4521
4521
  * a list of buffers.
4522
4522
  */
4523
4523
  encodeAsBinary(e) {
4524
- const t = mr(e), n = this.encodeAsString(t.packet), s = t.buffers;
4524
+ const t = gr(e), n = this.encodeAsString(t.packet), s = t.buffers;
4525
4525
  return s.unshift(n), s;
4526
4526
  }
4527
4527
  }
4528
- class Fe extends y {
4528
+ class je extends y {
4529
4529
  /**
4530
4530
  * Decoder constructor
4531
4531
  */
@@ -4547,8 +4547,8 @@ class Fe extends y {
4547
4547
  throw new Error("got plaintext data when reconstructing a packet");
4548
4548
  t = this.decodeString(e);
4549
4549
  const n = t.type === m.BINARY_EVENT;
4550
- n || t.type === m.BINARY_ACK ? (t.type = n ? m.EVENT : m.ACK, this.reconstructor = new br(t), t.attachments === 0 && super.emitReserved("decoded", t)) : super.emitReserved("decoded", t);
4551
- } else if (je(e) || e.base64)
4550
+ n || t.type === m.BINARY_ACK ? (t.type = n ? m.EVENT : m.ACK, this.reconstructor = new Cr(t), t.attachments === 0 && super.emitReserved("decoded", t)) : super.emitReserved("decoded", t);
4551
+ } else if (Ne(e) || e.base64)
4552
4552
  if (this.reconstructor)
4553
4553
  t = this.reconstructor.takeBinaryData(e), t && (this.reconstructor = null, super.emitReserved("decoded", t));
4554
4554
  else
@@ -4577,7 +4577,7 @@ class Fe extends y {
4577
4577
  if (o != Number(o) || e.charAt(t) !== "-")
4578
4578
  throw new Error("Illegal attachments");
4579
4579
  const a = Number(o);
4580
- if (!Cr(a) || a < 0)
4580
+ if (!vr(a) || a < 0)
4581
4581
  throw new Error("Illegal attachments");
4582
4582
  if (a > this.opts.maxAttachments)
4583
4583
  throw new Error("too many attachments");
@@ -4606,7 +4606,7 @@ class Fe extends y {
4606
4606
  }
4607
4607
  if (e.charAt(++t)) {
4608
4608
  const i = this.tryParse(e.substr(t));
4609
- if (Fe.isPayloadValid(n.type, i))
4609
+ if (je.isPayloadValid(n.type, i))
4610
4610
  n.data = i;
4611
4611
  else
4612
4612
  throw new Error("invalid payload");
@@ -4623,14 +4623,14 @@ class Fe extends y {
4623
4623
  static isPayloadValid(e, t) {
4624
4624
  switch (e) {
4625
4625
  case m.CONNECT:
4626
- return Ze(t);
4626
+ return et(t);
4627
4627
  case m.DISCONNECT:
4628
4628
  return t === void 0;
4629
4629
  case m.CONNECT_ERROR:
4630
- return typeof t == "string" || Ze(t);
4630
+ return typeof t == "string" || et(t);
4631
4631
  case m.EVENT:
4632
4632
  case m.BINARY_EVENT:
4633
- return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && yr.indexOf(t[0]) === -1);
4633
+ return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && _r.indexOf(t[0]) === -1);
4634
4634
  case m.ACK:
4635
4635
  case m.BINARY_ACK:
4636
4636
  return Array.isArray(t);
@@ -4643,7 +4643,7 @@ class Fe extends y {
4643
4643
  this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
4644
4644
  }
4645
4645
  }
4646
- class br {
4646
+ class Cr {
4647
4647
  constructor(e) {
4648
4648
  this.packet = e, this.buffers = [], this.reconPack = e;
4649
4649
  }
@@ -4657,7 +4657,7 @@ class br {
4657
4657
  */
4658
4658
  takeBinaryData(e) {
4659
4659
  if (this.buffers.push(e), this.buffers.length === this.reconPack.attachments) {
4660
- const t = gr(this.reconPack, this.buffers);
4660
+ const t = yr(this.reconPack, this.buffers);
4661
4661
  return this.finishedReconstruction(), t;
4662
4662
  }
4663
4663
  return null;
@@ -4669,26 +4669,26 @@ class br {
4669
4669
  this.reconPack = null, this.buffers = [];
4670
4670
  }
4671
4671
  }
4672
- const Cr = Number.isInteger || function(r) {
4672
+ const vr = Number.isInteger || function(r) {
4673
4673
  return typeof r == "number" && isFinite(r) && Math.floor(r) === r;
4674
4674
  };
4675
- function Ze(r) {
4675
+ function et(r) {
4676
4676
  return Object.prototype.toString.call(r) === "[object Object]";
4677
4677
  }
4678
- const vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4678
+ const Sr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4679
4679
  __proto__: null,
4680
- Decoder: Fe,
4681
- Encoder: _r,
4680
+ Decoder: je,
4681
+ Encoder: br,
4682
4682
  get PacketType() {
4683
4683
  return m;
4684
4684
  }
4685
4685
  }, Symbol.toStringTag, { value: "Module" }));
4686
- function x(r, e, t) {
4686
+ function R(r, e, t) {
4687
4687
  return r.on(e, t), function() {
4688
4688
  r.off(e, t);
4689
4689
  };
4690
4690
  }
4691
- const Sr = Object.freeze({
4691
+ const kr = Object.freeze({
4692
4692
  connect: 1,
4693
4693
  connect_error: 1,
4694
4694
  disconnect: 1,
@@ -4697,7 +4697,7 @@ const Sr = Object.freeze({
4697
4697
  newListener: 1,
4698
4698
  removeListener: 1
4699
4699
  });
4700
- class en extends y {
4700
+ class tn extends y {
4701
4701
  /**
4702
4702
  * `Socket` constructor.
4703
4703
  */
@@ -4731,10 +4731,10 @@ class en extends y {
4731
4731
  return;
4732
4732
  const e = this.io;
4733
4733
  this.subs = [
4734
- x(e, "open", this.onopen.bind(this)),
4735
- x(e, "packet", this.onpacket.bind(this)),
4736
- x(e, "error", this.onerror.bind(this)),
4737
- x(e, "close", this.onclose.bind(this))
4734
+ R(e, "open", this.onopen.bind(this)),
4735
+ R(e, "packet", this.onpacket.bind(this)),
4736
+ R(e, "error", this.onerror.bind(this)),
4737
+ R(e, "close", this.onclose.bind(this))
4738
4738
  ];
4739
4739
  }
4740
4740
  /**
@@ -4813,7 +4813,7 @@ class en extends y {
4813
4813
  */
4814
4814
  emit(e, ...t) {
4815
4815
  var n, s, i;
4816
- if (Sr.hasOwnProperty(e))
4816
+ if (kr.hasOwnProperty(e))
4817
4817
  throw new Error('"' + e.toString() + '" is a reserved event name');
4818
4818
  if (t.unshift(e), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
4819
4819
  return this._addToQueue(t), this;
@@ -5312,7 +5312,7 @@ $.prototype.setMax = function(r) {
5312
5312
  $.prototype.setJitter = function(r) {
5313
5313
  this.jitter = r;
5314
5314
  };
5315
- class Re extends y {
5315
+ class xe extends y {
5316
5316
  constructor(e, t) {
5317
5317
  var n;
5318
5318
  super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t = t || {}, t.path = t.path || "/socket.io", this.opts = t, ae(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || 1 / 0), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor((n = t.randomizationFactor) !== null && n !== void 0 ? n : 0.5), this.backoff = new $({
@@ -5320,7 +5320,7 @@ class Re extends y {
5320
5320
  max: this.reconnectionDelayMax(),
5321
5321
  jitter: this.randomizationFactor()
5322
5322
  }), this.timeout(t.timeout == null ? 2e4 : t.timeout), this._readyState = "closed", this.uri = e;
5323
- const s = t.parser || vr;
5323
+ const s = t.parser || Sr;
5324
5324
  this.encoder = new s.Encoder(), this.decoder = new s.Decoder(), this._autoConnect = t.autoConnect !== !1, this._autoConnect && this.open();
5325
5325
  }
5326
5326
  reconnection(e) {
@@ -5363,14 +5363,14 @@ class Re extends y {
5363
5363
  open(e) {
5364
5364
  if (~this._readyState.indexOf("open"))
5365
5365
  return this;
5366
- this.engine = new hr(this.uri, this.opts);
5366
+ this.engine = new fr(this.uri, this.opts);
5367
5367
  const t = this.engine, n = this;
5368
5368
  this._readyState = "opening", this.skipReconnect = !1;
5369
- const s = x(t, "open", function() {
5369
+ const s = R(t, "open", function() {
5370
5370
  n.onopen(), e && e();
5371
5371
  }), i = (a) => {
5372
5372
  this.cleanup(), this._readyState = "closed", this.emitReserved("error", a), e ? e(a) : this.maybeReconnectOnOpen();
5373
- }, o = x(t, "error", i);
5373
+ }, o = R(t, "error", i);
5374
5374
  if (this._timeout !== !1) {
5375
5375
  const a = this._timeout, c = this.setTimeoutFn(() => {
5376
5376
  s(), i(new Error("timeout")), t.close();
@@ -5399,12 +5399,12 @@ class Re extends y {
5399
5399
  this.cleanup(), this._readyState = "open", this.emitReserved("open");
5400
5400
  const e = this.engine;
5401
5401
  this.subs.push(
5402
- x(e, "ping", this.onping.bind(this)),
5403
- x(e, "data", this.ondata.bind(this)),
5404
- x(e, "error", this.onerror.bind(this)),
5405
- x(e, "close", this.onclose.bind(this)),
5402
+ R(e, "ping", this.onping.bind(this)),
5403
+ R(e, "data", this.ondata.bind(this)),
5404
+ R(e, "error", this.onerror.bind(this)),
5405
+ R(e, "close", this.onclose.bind(this)),
5406
5406
  // @ts-ignore
5407
- x(this.decoder, "decoded", this.ondecoded.bind(this))
5407
+ R(this.decoder, "decoded", this.ondecoded.bind(this))
5408
5408
  );
5409
5409
  }
5410
5410
  /**
@@ -5453,7 +5453,7 @@ class Re extends y {
5453
5453
  */
5454
5454
  socket(e, t) {
5455
5455
  let n = this.nsps[e];
5456
- return n ? this._autoConnect && !n.active && n.connect() : (n = new en(this, e, t), this.nsps[e] = n), n;
5456
+ return n ? this._autoConnect && !n.active && n.connect() : (n = new tn(this, e, t), this.nsps[e] = n), n;
5457
5457
  }
5458
5458
  /**
5459
5459
  * Called upon a socket close.
@@ -5550,20 +5550,20 @@ class Re extends y {
5550
5550
  this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", e);
5551
5551
  }
5552
5552
  }
5553
- const j = {};
5553
+ const N = {};
5554
5554
  function ne(r, e) {
5555
5555
  typeof r == "object" && (e = r, r = void 0), e = e || {};
5556
- const t = fr(r, e.path || "/socket.io"), n = t.source, s = t.id, i = t.path, o = j[s] && i in j[s].nsps, a = e.forceNew || e["force new connection"] || e.multiplex === !1 || o;
5556
+ const t = lr(r, e.path || "/socket.io"), n = t.source, s = t.id, i = t.path, o = N[s] && i in N[s].nsps, a = e.forceNew || e["force new connection"] || e.multiplex === !1 || o;
5557
5557
  let c;
5558
- return a ? c = new Re(n, e) : (j[s] || (j[s] = new Re(n, e)), c = j[s]), t.query && !e.query && (e.query = t.queryKey), c.socket(t.path, e);
5558
+ return a ? c = new xe(n, e) : (N[s] || (N[s] = new xe(n, e)), c = N[s]), t.query && !e.query && (e.query = t.queryKey), c.socket(t.path, e);
5559
5559
  }
5560
5560
  Object.assign(ne, {
5561
- Manager: Re,
5562
- Socket: en,
5561
+ Manager: xe,
5562
+ Socket: tn,
5563
5563
  io: ne,
5564
5564
  connect: ne
5565
5565
  });
5566
- class kr {
5566
+ class Tr {
5567
5567
  constructor(e) {
5568
5568
  this.config = e, this.socket = null, this.callbacks = {
5569
5569
  onMessage: null,
@@ -5621,7 +5621,7 @@ class kr {
5621
5621
  this.socket && (this.socket.close(), this.socket = null);
5622
5622
  }
5623
5623
  }
5624
- class Tr {
5624
+ class Rr {
5625
5625
  constructor() {
5626
5626
  this.localStream = null, this.remoteStreams = {};
5627
5627
  }
@@ -5666,20 +5666,76 @@ class Tr {
5666
5666
  this.stopLocalStream(), this.remoteStreams = {};
5667
5667
  }
5668
5668
  }
5669
- class xr {
5669
+ class Fe {
5670
5670
  constructor() {
5671
- this.container = null, this.videoElements = {}, this.chatMessages = [];
5671
+ this.recorder = null, this.chunks = [], this.startedAt = null, this.stream = null, this.state = "idle", this.callbacks = { onStateChange: null };
5672
+ }
5673
+ static isSupported() {
5674
+ return typeof window < "u" && typeof window.MediaRecorder < "u";
5675
+ }
5676
+ pickMimeType() {
5677
+ const e = [
5678
+ "video/webm;codecs=vp9,opus",
5679
+ "video/webm;codecs=vp8,opus",
5680
+ "video/webm",
5681
+ "video/mp4"
5682
+ ];
5683
+ for (const t of e)
5684
+ if (window.MediaRecorder.isTypeSupported(t)) return t;
5685
+ return "";
5686
+ }
5687
+ setState(e) {
5688
+ this.state = e, this.callbacks.onStateChange && this.callbacks.onStateChange(e);
5689
+ }
5690
+ on(e, t) {
5691
+ e === "stateChange" && (this.callbacks.onStateChange = t);
5692
+ }
5693
+ start(e) {
5694
+ if (!Fe.isSupported())
5695
+ throw new Error("MediaRecorder API not supported in this browser");
5696
+ if (this.state === "recording") return;
5697
+ if (!e) throw new Error("stream is required to start recording");
5698
+ this.stream = e, this.chunks = [];
5699
+ const t = this.pickMimeType();
5700
+ this.recorder = new window.MediaRecorder(e, t ? { mimeType: t } : void 0), this.recorder.ondataavailable = (n) => {
5701
+ n.data && n.data.size > 0 && this.chunks.push(n.data);
5702
+ }, this.recorder.onerror = (n) => {
5703
+ console.error("MediaRecorder error:", n);
5704
+ }, this.startedAt = /* @__PURE__ */ new Date(), this.recorder.start(1e3), this.setState("recording");
5705
+ }
5706
+ stop() {
5707
+ return new Promise((e) => {
5708
+ if (this.state !== "recording" || !this.recorder) {
5709
+ e(null);
5710
+ return;
5711
+ }
5712
+ const t = this.recorder.mimeType || "video/webm";
5713
+ this.recorder.onstop = () => {
5714
+ const n = /* @__PURE__ */ new Date(), s = new Blob(this.chunks, { type: t }), i = this.startedAt;
5715
+ this.recorder = null, this.chunks = [], this.stream = null, this.startedAt = null, this.setState("stopped"), e({ blob: s, mimeType: t, startedAt: i, endedAt: n });
5716
+ }, this.recorder.stop();
5717
+ });
5718
+ }
5719
+ isRecording() {
5720
+ return this.state === "recording";
5721
+ }
5722
+ }
5723
+ class xr {
5724
+ constructor(e = {}) {
5725
+ this.container = null, this.videoElements = {}, this.chatMessages = [], this.recording = e.recording || "off";
5672
5726
  }
5673
5727
  mount(e) {
5674
- if (this.container = document.querySelector(e), !this.container)
5728
+ if (typeof e == "string" ? this.container = document.querySelector(e) : e instanceof Element && (this.container = e), !this.container)
5675
5729
  throw new Error(`Container not found: ${e}`);
5676
5730
  this.render();
5677
5731
  }
5678
5732
  render() {
5733
+ const e = this.recording === "manual" ? '<button id="toggle-record" style="padding: 10px 20px; background-color: #7a3a3a; border: none; border-radius: 6px; color: white; cursor: pointer; font-size: 14px;">● Record</button>' : "", t = this.recording !== "off" ? '<span id="recording-indicator" style="display:none; margin-left: 12px; color: #ff5252; font-size: 13px; font-weight: 600;">● REC</span>' : "";
5679
5734
  this.container.innerHTML = `
5680
5735
  <div style="display: flex; flex-direction: column; height: 100%; background-color: #1a1a1a; color: #ffffff; font-family: sans-serif;">
5681
- <div style="padding: 15px; background-color: #2a2a2a; border-bottom: 1px solid #333;">
5736
+ <div style="padding: 15px; background-color: #2a2a2a; border-bottom: 1px solid #333; display: flex; align-items: center;">
5682
5737
  <h3 style="margin: 0; font-size: 18px;">Video Meeting</h3>
5738
+ ${t}
5683
5739
  </div>
5684
5740
 
5685
5741
  <div style="display: flex; flex: 1; overflow: hidden;">
@@ -5704,6 +5760,7 @@ class xr {
5704
5760
  <div id="controls-container" style="padding: 20px; background-color: #1a1a1a; border-top: 1px solid #333; display: flex; justify-content: center; gap: 10px;">
5705
5761
  <button id="toggle-video" style="padding: 10px 20px; background-color: #3a5a7a; border: none; border-radius: 6px; color: white; cursor: pointer; font-size: 14px;">Video On</button>
5706
5762
  <button id="toggle-audio" style="padding: 10px 20px; background-color: #3a5a7a; border: none; border-radius: 6px; color: white; cursor: pointer; font-size: 14px;">Mic On</button>
5763
+ ${e}
5707
5764
  <button id="leave-meeting" style="padding: 10px 20px; background-color: #5a3a3a; border: none; border-radius: 6px; color: white; cursor: pointer; font-size: 14px;">Leave</button>
5708
5765
  </div>
5709
5766
  </div>
@@ -5754,12 +5811,19 @@ class xr {
5754
5811
  const n = this.container.querySelector(`#${e}`);
5755
5812
  n && (n.textContent = t);
5756
5813
  }
5814
+ updateRecordingIndicator(e) {
5815
+ if (!this.container) return;
5816
+ const t = this.container.querySelector("#recording-indicator");
5817
+ t && (t.style.display = e === "recording" ? "inline" : "none");
5818
+ const n = this.container.querySelector("#toggle-record");
5819
+ n && (n.textContent = e === "recording" ? "■ Stop" : "● Record", n.style.backgroundColor = e === "recording" ? "#c53030" : "#7a3a3a");
5820
+ }
5757
5821
  destroy() {
5758
5822
  this.container && (this.container.innerHTML = ""), this.videoElements = {}, this.chatMessages = [];
5759
5823
  }
5760
5824
  }
5761
- const Rr = "http://47.131.15.9:31599";
5762
- function Er(r) {
5825
+ const Er = /* @__PURE__ */ new Set(["auto", "manual", "off"]), Pr = "http://47.131.15.9:31599";
5826
+ function Or(r) {
5763
5827
  const e = new URL(r), t = e.protocol === "https:";
5764
5828
  return {
5765
5829
  host: e.hostname,
@@ -5768,22 +5832,23 @@ function Er(r) {
5768
5832
  secure: t
5769
5833
  };
5770
5834
  }
5771
- class Pr {
5835
+ class Mr {
5772
5836
  constructor() {
5773
5837
  this.config = null, this.peerManager = null, this.socketManager = null, this.mediaManager = null, this.uiManager = null, this.isInitialized = !1, this.currentRoom = null, this.currentUser = null;
5774
5838
  }
5775
5839
  init(e) {
5776
5840
  if (!e || !e.workspace || !e.roomId || !e.user)
5777
5841
  throw new Error("workspace, roomId, and user are required");
5778
- const t = e.host || Rr;
5842
+ const t = e.host || Pr, n = Er.has(e.recording) ? e.recording : "off";
5779
5843
  this.config = {
5780
5844
  ...e,
5781
5845
  host: t,
5782
5846
  apiUrl: e.apiUrl || `${t}/api`,
5783
5847
  socketUrl: e.socketUrl || t,
5784
- peerServer: e.peerServer || Er(t),
5785
- ai: { ...e.ai || {} }
5786
- }, this.currentRoom = this.config.roomId, this.currentUser = this.config.user, this.peerManager = new On(this.config), this.socketManager = new kr(this.config), this.mediaManager = new Tr(), this.uiManager = new xr(), this.setupEventHandlers(), this.isInitialized = !0, console.log("MeetSDK initialized");
5848
+ peerServer: e.peerServer || Or(t),
5849
+ ai: { ...e.ai || {} },
5850
+ recording: n
5851
+ }, this.currentRoom = this.config.roomId, this.currentUser = this.config.user, this.peerManager = new Mn(this.config), this.socketManager = new Tr(this.config), this.mediaManager = new Rr(), this.uiManager = new xr({ recording: n }), this.recorder = n === "off" ? null : new Fe(), this.setupEventHandlers(), this.isInitialized = !0, console.log("MeetSDK initialized");
5787
5852
  }
5788
5853
  setupEventHandlers() {
5789
5854
  this.peerManager.on("stream", (e, t, n) => {
@@ -5816,7 +5881,59 @@ class Pr {
5816
5881
  this.currentUser.name,
5817
5882
  t
5818
5883
  );
5819
- }, 500), this.setupUIControls(), console.log("MeetSDK mounted");
5884
+ }, 500), this.setupUIControls(), this.setupRecording(n), console.log("MeetSDK mounted");
5885
+ }
5886
+ setupRecording(e) {
5887
+ if (this.recorder) {
5888
+ if (this.recorder.on("stateChange", (t) => {
5889
+ this.uiManager.updateRecordingIndicator(t);
5890
+ }), this.config.recording === "auto")
5891
+ try {
5892
+ this.recorder.start(e);
5893
+ } catch (t) {
5894
+ console.error("Auto-record failed:", t);
5895
+ }
5896
+ this.config.recording === "manual" && this.uiManager.onControlClick("toggle-record", async () => {
5897
+ this.recorder.isRecording() ? await this.stopRecording() : this.startRecording();
5898
+ });
5899
+ }
5900
+ }
5901
+ startRecording() {
5902
+ if (!this.recorder) throw new Error("recording is disabled in SDK config");
5903
+ const e = this.peerManager.localStream;
5904
+ if (!e) throw new Error("local stream not ready");
5905
+ this.recorder.start(e);
5906
+ }
5907
+ async stopRecording() {
5908
+ if (!this.recorder) return null;
5909
+ const e = await this.recorder.stop();
5910
+ if (!e) return null;
5911
+ try {
5912
+ return await this.uploadRecording(
5913
+ e.blob,
5914
+ e.startedAt,
5915
+ e.endedAt
5916
+ );
5917
+ } catch (t) {
5918
+ throw console.error("Recording upload failed:", t), t;
5919
+ }
5920
+ }
5921
+ async uploadRecording(e, t, n) {
5922
+ const s = Math.max(0, Math.round((n - t) / 1e3)), i = (e.type || "").includes("mp4") ? "mp4" : "webm", o = `${this.currentRoom}-${Date.now()}.${i}`, a = new FormData();
5923
+ a.append("recording", e, o), a.append("recordedBy", this.currentUser.id), a.append("durationSec", String(s)), a.append("startedAt", t.toISOString()), a.append("endedAt", n.toISOString());
5924
+ const c = await fetch(
5925
+ `${this.config.apiUrl}/rooms/${encodeURIComponent(this.currentRoom)}/recordings`,
5926
+ { method: "POST", headers: this.buildHeaders(), body: a }
5927
+ );
5928
+ if (!c.ok) throw new Error(`Upload failed: HTTP ${c.status}`);
5929
+ return c.json();
5930
+ }
5931
+ async listRecordings() {
5932
+ if (!this.isInitialized) throw new Error("SDK not initialized");
5933
+ return (await fetch(
5934
+ `${this.config.apiUrl}/rooms/${encodeURIComponent(this.currentRoom)}/recordings`,
5935
+ { headers: this.buildHeaders() }
5936
+ )).json();
5820
5937
  }
5821
5938
  setupUIControls() {
5822
5939
  let e = !0, t = !0;
@@ -5878,11 +5995,17 @@ class Pr {
5878
5995
  { method: "POST", headers: this.buildHeaders(), body: n }
5879
5996
  )).json();
5880
5997
  }
5881
- leave() {
5998
+ async leave() {
5999
+ if (this.recorder && this.recorder.isRecording())
6000
+ try {
6001
+ await this.stopRecording();
6002
+ } catch (e) {
6003
+ console.warn("Recording upload on leave failed:", e);
6004
+ }
5882
6005
  this.socketManager.leaveRoom(), this.socketManager.disconnect(), this.peerManager.disconnect(), this.mediaManager.cleanup(), this.uiManager.destroy(), this.isInitialized = !1, console.log("Left meeting");
5883
6006
  }
5884
6007
  }
5885
- typeof window < "u" && (window.MeetSDK = new Pr());
6008
+ typeof window < "u" && (window.MeetSDK = new Mr());
5886
6009
  export {
5887
- Pr as default
6010
+ Mr as default
5888
6011
  };