cogito-client 1.0.72 → 1.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ var $a = Object.defineProperty, Za = (n, e, t) => e in n ? $a(n, e, {
17
17
  writable: !0,
18
18
  value: t
19
19
  }) : n[e] = t, is = (n, e, t) => Za(n, typeof e != "symbol" ? e + "" : e, t);
20
- class fe {
20
+ class me {
21
21
  constructor() {
22
22
  is(this, "_locking"), is(this, "_locks"), this._locking = Promise.resolve(), this._locks = 0;
23
23
  }
@@ -1977,7 +1977,7 @@ const p = Ao(
1977
1977
  }
1978
1978
  }
1979
1979
  );
1980
- class pe extends wn {
1980
+ class ge extends wn {
1981
1981
  constructor(e) {
1982
1982
  super(), this.seconds = Q.zero, this.nanos = 0, p.util.initPartial(e, this);
1983
1983
  }
@@ -2011,31 +2011,31 @@ class pe extends wn {
2011
2011
  return new Date(Number(this.seconds) * 1e3 + Math.ceil(this.nanos / 1e6));
2012
2012
  }
2013
2013
  static now() {
2014
- return pe.fromDate(/* @__PURE__ */ new Date());
2014
+ return ge.fromDate(/* @__PURE__ */ new Date());
2015
2015
  }
2016
2016
  static fromDate(e) {
2017
2017
  const t = e.getTime();
2018
- return new pe({
2018
+ return new ge({
2019
2019
  seconds: Q.parse(Math.floor(t / 1e3)),
2020
2020
  nanos: t % 1e3 * 1e6
2021
2021
  });
2022
2022
  }
2023
2023
  static fromBinary(e, t) {
2024
- return new pe().fromBinary(e, t);
2024
+ return new ge().fromBinary(e, t);
2025
2025
  }
2026
2026
  static fromJson(e, t) {
2027
- return new pe().fromJson(e, t);
2027
+ return new ge().fromJson(e, t);
2028
2028
  }
2029
2029
  static fromJsonString(e, t) {
2030
- return new pe().fromJsonString(e, t);
2030
+ return new ge().fromJsonString(e, t);
2031
2031
  }
2032
2032
  static equals(e, t) {
2033
- return p.util.equals(pe, e, t);
2033
+ return p.util.equals(ge, e, t);
2034
2034
  }
2035
2035
  }
2036
- pe.runtime = p;
2037
- pe.typeName = "google.protobuf.Timestamp";
2038
- pe.fields = p.util.newFieldList(() => [{
2036
+ ge.runtime = p;
2037
+ ge.typeName = "google.protobuf.Timestamp";
2038
+ ge.fields = p.util.newFieldList(() => [{
2039
2039
  no: 1,
2040
2040
  name: "seconds",
2041
2041
  kind: "scalar",
@@ -2058,7 +2058,7 @@ const Ko = /* @__PURE__ */ p.makeMessageType("livekit.MetricsBatch", () => [{
2058
2058
  no: 2,
2059
2059
  name: "normalized_timestamp",
2060
2060
  kind: "message",
2061
- T: pe
2061
+ T: ge
2062
2062
  }, {
2063
2063
  no: 3,
2064
2064
  name: "str_data",
@@ -2117,7 +2117,7 @@ const Ko = /* @__PURE__ */ p.makeMessageType("livekit.MetricsBatch", () => [{
2117
2117
  no: 2,
2118
2118
  name: "normalized_timestamp",
2119
2119
  kind: "message",
2120
- T: pe
2120
+ T: ge
2121
2121
  }, {
2122
2122
  no: 3,
2123
2123
  name: "value",
@@ -2158,12 +2158,12 @@ const Ko = /* @__PURE__ */ p.makeMessageType("livekit.MetricsBatch", () => [{
2158
2158
  no: 6,
2159
2159
  name: "normalized_start_timestamp",
2160
2160
  kind: "message",
2161
- T: pe
2161
+ T: ge
2162
2162
  }, {
2163
2163
  no: 7,
2164
2164
  name: "normalized_end_timestamp",
2165
2165
  kind: "message",
2166
- T: pe,
2166
+ T: ge,
2167
2167
  opt: !0
2168
2168
  }, {
2169
2169
  no: 8,
@@ -2829,7 +2829,7 @@ const Ko = /* @__PURE__ */ p.makeMessageType("livekit.MetricsBatch", () => [{
2829
2829
  }, {
2830
2830
  no: 3,
2831
2831
  name: "ONE_SPATIAL_LAYER_PER_STREAM_INCOMPLETE_RTCP_SR"
2832
- }]), he = /* @__PURE__ */ p.makeMessageType("livekit.DataPacket", () => [{
2832
+ }]), fe = /* @__PURE__ */ p.makeMessageType("livekit.DataPacket", () => [{
2833
2833
  no: 1,
2834
2834
  name: "kind",
2835
2835
  kind: "enum",
@@ -6896,7 +6896,7 @@ function Gc() {
6896
6896
  Gc({
6897
6897
  window: typeof window > "u" ? void 0 : window
6898
6898
  });
6899
- class ge extends Promise {
6899
+ class ve extends Promise {
6900
6900
  // eslint-disable-next-line @typescript-eslint/no-useless-constructor
6901
6901
  constructor(e) {
6902
6902
  super(e);
@@ -6916,7 +6916,7 @@ class ge extends Promise {
6916
6916
  }
6917
6917
  const Jc = /version\/(\d+(\.?_?\d+)+)/i;
6918
6918
  let Bi;
6919
- function be(n) {
6919
+ function ye(n) {
6920
6920
  let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
6921
6921
  if (typeof navigator > "u")
6922
6922
  return;
@@ -7051,13 +7051,13 @@ class Is extends Be {
7051
7051
  super(15, e), this.name = "SignalRequestError", this.reason = t, this.reasonName = typeof t == "string" ? t : Bn[t];
7052
7052
  }
7053
7053
  }
7054
- var ue;
7054
+ var he;
7055
7055
  (function(n) {
7056
7056
  n[n.AlreadyOpened = 0] = "AlreadyOpened", n[n.AbnormalEnd = 1] = "AbnormalEnd", n[n.DecodeFailed = 2] = "DecodeFailed", n[n.LengthExceeded = 3] = "LengthExceeded", n[n.Incomplete = 4] = "Incomplete", n[n.HandlerAlreadyRegistered = 7] = "HandlerAlreadyRegistered", n[n.EncryptionTypeMismatch = 8] = "EncryptionTypeMismatch";
7057
- })(ue || (ue = {}));
7057
+ })(he || (he = {}));
7058
7058
  class Ee extends Be {
7059
7059
  constructor(e, t) {
7060
- super(16, e), this.name = "DataStreamError", this.reason = t, this.reasonName = ue[t];
7060
+ super(16, e), this.name = "DataStreamError", this.reason = t, this.reasonName = he[t];
7061
7061
  }
7062
7062
  }
7063
7063
  class vt extends Be {
@@ -7501,10 +7501,10 @@ class T extends je.EventEmitter {
7501
7501
  });
7502
7502
  }
7503
7503
  addAppVisibilityListener() {
7504
- ve() ? (this.isInBackground = document.visibilityState === "hidden", document.addEventListener("visibilitychange", this.appVisibilityChangedListener)) : this.isInBackground = !1;
7504
+ be() ? (this.isInBackground = document.visibilityState === "hidden", document.addEventListener("visibilitychange", this.appVisibilityChangedListener)) : this.isInBackground = !1;
7505
7505
  }
7506
7506
  removeAppVisibilityListener() {
7507
- ve() && document.removeEventListener("visibilitychange", this.appVisibilityChangedListener);
7507
+ be() && document.removeEventListener("visibilitychange", this.appVisibilityChangedListener);
7508
7508
  }
7509
7509
  }
7510
7510
  function yt(n, e) {
@@ -7607,7 +7607,7 @@ function hd(n) {
7607
7607
  return e.length > 1 ? [e[0], n.substr(e[0].length + 1)] : [n, ""];
7608
7608
  }
7609
7609
  function ce(n) {
7610
- return new ge((e) => oe.setTimeout(e, n));
7610
+ return new ve((e) => oe.setTimeout(e, n));
7611
7611
  }
7612
7612
  function bn() {
7613
7613
  return "addTransceiver" in RTCPeerConnection.prototype;
@@ -7633,7 +7633,7 @@ function md() {
7633
7633
  if (!("getCapabilities" in RTCRtpSender) || ht())
7634
7634
  return !1;
7635
7635
  if (ft()) {
7636
- const t = be();
7636
+ const t = ye();
7637
7637
  if (t?.version && Fe(t.version, "16") < 0 || t?.os === "iOS" && t?.osVersion && Fe(t.osVersion, "16") < 0)
7638
7638
  return !1;
7639
7639
  }
@@ -7659,40 +7659,40 @@ function pd() {
7659
7659
  }
7660
7660
  function ht() {
7661
7661
  var n;
7662
- return ((n = be()) === null || n === void 0 ? void 0 : n.name) === "Firefox";
7662
+ return ((n = ye()) === null || n === void 0 ? void 0 : n.name) === "Firefox";
7663
7663
  }
7664
7664
  function xs() {
7665
- const n = be();
7665
+ const n = ye();
7666
7666
  return !!n && n.name === "Chrome" && n.os !== "iOS";
7667
7667
  }
7668
7668
  function ft() {
7669
7669
  var n;
7670
- return ((n = be()) === null || n === void 0 ? void 0 : n.name) === "Safari";
7670
+ return ((n = ye()) === null || n === void 0 ? void 0 : n.name) === "Safari";
7671
7671
  }
7672
7672
  function Yt() {
7673
- const n = be();
7673
+ const n = ye();
7674
7674
  return n?.name === "Safari" || n?.os === "iOS";
7675
7675
  }
7676
7676
  function gd() {
7677
- const n = be();
7677
+ const n = ye();
7678
7678
  return n?.name === "Safari" && n.version.startsWith("17.") || n?.os === "iOS" && !!n?.osVersion && Fe(n.osVersion, "17") >= 0;
7679
7679
  }
7680
7680
  function vd(n) {
7681
- return n || (n = be()), n?.name === "Safari" && Fe(n.version, "18.3") > 0 || n?.os === "iOS" && !!n?.osVersion && Fe(n.osVersion, "18.3") > 0;
7681
+ return n || (n = ye()), n?.name === "Safari" && Fe(n.version, "18.3") > 0 || n?.os === "iOS" && !!n?.osVersion && Fe(n.osVersion, "18.3") > 0;
7682
7682
  }
7683
7683
  function Aa() {
7684
7684
  var n, e;
7685
- return ve() ? (
7685
+ return be() ? (
7686
7686
  // @ts-expect-error `userAgentData` is not yet part of typescript
7687
7687
  (e = (n = navigator.userAgentData) === null || n === void 0 ? void 0 : n.mobile) !== null && e !== void 0 ? e : /Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent)
7688
7688
  ) : !1;
7689
7689
  }
7690
7690
  function bd() {
7691
- const n = be(), e = "17.2";
7691
+ const n = ye(), e = "17.2";
7692
7692
  if (n)
7693
7693
  return n.name !== "Safari" && n.os !== "iOS" || n.os === "iOS" && n.osVersion && Fe(n.osVersion, e) >= 0 ? !0 : n.name === "Safari" && Fe(n.version, e) >= 0;
7694
7694
  }
7695
- function ve() {
7695
+ function be() {
7696
7696
  return typeof document < "u";
7697
7697
  }
7698
7698
  function Ue() {
@@ -7716,7 +7716,7 @@ function La() {
7716
7716
  return n.platform;
7717
7717
  }
7718
7718
  function As() {
7719
- if (ve())
7719
+ if (be())
7720
7720
  return window.devicePixelRatio;
7721
7721
  if (Ue()) {
7722
7722
  let n = Na();
@@ -8510,7 +8510,7 @@ var Jt;
8510
8510
  })(Jt || (Jt = {}));
8511
8511
  class Wd {
8512
8512
  constructor() {
8513
- this.pendingTasks = /* @__PURE__ */ new Map(), this.taskMutex = new fe(), this.nextTaskIndex = 0;
8513
+ this.pendingTasks = /* @__PURE__ */ new Map(), this.taskMutex = new me(), this.nextTaskIndex = 0;
8514
8514
  }
8515
8515
  run(e) {
8516
8516
  return f(this, void 0, void 0, function* () {
@@ -8557,7 +8557,7 @@ class Kd {
8557
8557
  } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
8558
8558
  return r.close(a, c);
8559
8559
  };
8560
- this.opened = new ge((a, c) => {
8560
+ this.opened = new ve((a, c) => {
8561
8561
  const d = () => {
8562
8562
  c(L.websocket("Encountered websocket error during connection establishment"));
8563
8563
  };
@@ -8587,15 +8587,15 @@ class Kd {
8587
8587
  extensions: r.extensions
8588
8588
  }), r.removeEventListener("error", d);
8589
8589
  }, r.addEventListener("error", d);
8590
- }), this.closed = new ge((a, c) => {
8590
+ }), this.closed = new ve((a, c) => {
8591
8591
  const d = () => f(this, void 0, void 0, function* () {
8592
- const l = new ge((h) => {
8592
+ const l = new ve((h) => {
8593
8593
  r.readyState !== WebSocket.CLOSED && r.addEventListener("close", (m) => {
8594
8594
  h(m);
8595
8595
  }, {
8596
8596
  once: !0
8597
8597
  });
8598
- }), u = yield ge.race([ce(250), l]);
8598
+ }), u = yield ve.race([ce(250), l]);
8599
8599
  u ? a(u) : c(L.websocket("Encountered unspecified websocket error without a timely close event"));
8600
8600
  });
8601
8601
  r.onclose = (l) => {
@@ -8642,7 +8642,7 @@ class Jn {
8642
8642
  var i;
8643
8643
  this.rtt = 0, this.state = J.DISCONNECTED, this.log = F, this._requestId = 0, this.useV0SignalPath = !1, this.resetCallbacks = () => {
8644
8644
  this.onAnswer = void 0, this.onLeave = void 0, this.onLocalTrackPublished = void 0, this.onLocalTrackUnpublished = void 0, this.onNegotiateRequested = void 0, this.onOffer = void 0, this.onRemoteMuteChanged = void 0, this.onSubscribedQualityUpdate = void 0, this.onTokenRefresh = void 0, this.onTrickle = void 0, this.onClose = void 0, this.onMediaSectionsRequirement = void 0;
8645
- }, this.log = ze((i = t.loggerName) !== null && i !== void 0 ? i : xe.Signal), this.loggerContextCb = t.loggerContextCb, this.useJSON = e, this.requestQueue = new Wd(), this.queuedRequests = [], this.closingLock = new fe(), this.connectionLock = new fe(), this.state = J.DISCONNECTED;
8645
+ }, this.log = ze((i = t.loggerName) !== null && i !== void 0 ? i : xe.Signal), this.loggerContextCb = t.loggerContextCb, this.useJSON = e, this.requestQueue = new Wd(), this.queuedRequests = [], this.closingLock = new me(), this.connectionLock = new me(), this.state = J.DISCONNECTED;
8646
8646
  }
8647
8647
  get logContext() {
8648
8648
  var e, t;
@@ -9901,7 +9901,7 @@ class Qs extends je.EventEmitter {
9901
9901
  }
9902
9902
  }), tl), this.close = () => {
9903
9903
  this._pc && (this._pc.close(), this._pc.onconnectionstatechange = null, this._pc.oniceconnectionstatechange = null, this._pc.onicegatheringstatechange = null, this._pc.ondatachannel = null, this._pc.onnegotiationneeded = null, this._pc.onsignalingstatechange = null, this._pc.onicecandidate = null, this._pc.ondatachannel = null, this._pc.ontrack = null, this._pc.onconnectionstatechange = null, this._pc.oniceconnectionstatechange = null, this._pc = null);
9904
- }, this.log = ze((i = t.loggerName) !== null && i !== void 0 ? i : xe.PCTransport), this.loggerOptions = t, this.config = e, this._pc = this.createPC(), this.offerLock = new fe();
9904
+ }, this.log = ze((i = t.loggerName) !== null && i !== void 0 ? i : xe.PCTransport), this.loggerOptions = t, this.config = e, this._pc = this.createPC(), this.offerLock = new me();
9905
9905
  }
9906
9906
  createPC() {
9907
9907
  const e = new RTCPeerConnection(this.config);
@@ -10297,7 +10297,7 @@ class rl {
10297
10297
  }, this.publisher.onOffer = (r, o) => {
10298
10298
  var a;
10299
10299
  (a = this.onPublisherOffer) === null || a === void 0 || a.call(this, r, o);
10300
- }, this.state = X.NEW, this.connectionLock = new fe(), this.remoteOfferLock = new fe();
10300
+ }, this.state = X.NEW, this.connectionLock = new me(), this.remoteOfferLock = new me();
10301
10301
  }
10302
10302
  get logContext() {
10303
10303
  var e, t;
@@ -10379,7 +10379,7 @@ class rl {
10379
10379
  }
10380
10380
  negotiate(e) {
10381
10381
  return f(this, void 0, void 0, function* () {
10382
- return new ge((t, i) => f(this, void 0, void 0, function* () {
10382
+ return new ve((t, i) => f(this, void 0, void 0, function* () {
10383
10383
  const s = setTimeout(() => {
10384
10384
  i(new Et("negotiation timed out"));
10385
10385
  }, this.peerConnectionTimeout), r = () => {
@@ -10566,7 +10566,7 @@ class W {
10566
10566
  W.cache = /* @__PURE__ */ new Map();
10567
10567
  W.settingsTimeouts = /* @__PURE__ */ new Map();
10568
10568
  W.connectionTrackers = /* @__PURE__ */ new Map();
10569
- W.fetchLock = new fe();
10569
+ W.fetchLock = new me();
10570
10570
  function ol(n) {
10571
10571
  return "".concat(n.protocol.replace("ws", "http"), "//").concat(n.host, "/settings");
10572
10572
  }
@@ -10728,7 +10728,7 @@ class qa extends T {
10728
10728
  this.debouncedTrackMuteHandler.cancel("unmute"), yield this.resumeUpstream();
10729
10729
  }), this.handleEnded = () => {
10730
10730
  this.isInBackground && (this.reacquireTrack = !0), this._mediaStreamTrack.removeEventListener("mute", this.handleTrackMuteEvent), this._mediaStreamTrack.removeEventListener("unmute", this.handleTrackUnmuteEvent), this.emit(_.Ended, this);
10731
- }, this.reacquireTrack = !1, this.providedByUser = s, this.muteLock = new fe(), this.pauseUpstreamLock = new fe(), this.trackChangeLock = new fe(), this.trackChangeLock.lock().then((o) => f(this, void 0, void 0, function* () {
10731
+ }, this.reacquireTrack = !1, this.providedByUser = s, this.muteLock = new me(), this.pauseUpstreamLock = new me(), this.trackChangeLock = new me(), this.trackChangeLock.lock().then((o) => f(this, void 0, void 0, function* () {
10732
10732
  try {
10733
10733
  yield this.setMediaStreamTrack(e, !0);
10734
10734
  } finally {
@@ -10803,7 +10803,7 @@ class qa extends T {
10803
10803
  var i;
10804
10804
  if (e.kind === T.Kind.Audio)
10805
10805
  throw new Error("cannot get dimensions for audio tracks");
10806
- ((i = be()) === null || i === void 0 ? void 0 : i.os) === "iOS" && (yield ce(10));
10806
+ ((i = ye()) === null || i === void 0 ? void 0 : i.os) === "iOS" && (yield ce(10));
10807
10807
  const s = Date.now();
10808
10808
  for (; Date.now() - s < t; ) {
10809
10809
  const r = e.dimensions;
@@ -10931,7 +10931,7 @@ class qa extends T {
10931
10931
  return;
10932
10932
  }
10933
10933
  this._isUpstreamPaused = !0, this.emit(_.UpstreamPaused, this);
10934
- const i = be();
10934
+ const i = ye();
10935
10935
  if (i?.name === "Safari" && Fe(i.version, "12.0") < 0)
10936
10936
  throw new qn("pauseUpstream is not supported on Safari < 12.");
10937
10937
  ((e = this.sender.transport) === null || e === void 0 ? void 0 : e.state) !== "closed" && (yield this.sender.replaceTrack(null));
@@ -11183,7 +11183,7 @@ class Ci extends qa {
11183
11183
  }
11184
11184
  /* @internal */
11185
11185
  startMonitor() {
11186
- ve() && (this.monitorInterval || (this.monitorInterval = setInterval(() => {
11186
+ be() && (this.monitorInterval || (this.monitorInterval = setInterval(() => {
11187
11187
  this.monitorSender();
11188
11188
  }, $n)));
11189
11189
  }
@@ -11272,7 +11272,7 @@ function Pn(n, e, t, i) {
11272
11272
  const b = new Wa(c), g = [];
11273
11273
  if (b.spatial > 3)
11274
11274
  throw new Error("unsupported scalabilityMode: ".concat(c));
11275
- const R = be();
11275
+ const R = ye();
11276
11276
  if (Yt() || // Even tho RN runs M114, it does not produce SVC layers when a single encoding
11277
11277
  // is provided. So we'll use the legacy SVC specification for now.
11278
11278
  // TODO: when we upstream libwebrtc, this will need additional verification
@@ -11460,7 +11460,7 @@ class Ei extends qa {
11460
11460
  }), this._currentBitrate = c;
11461
11461
  }
11462
11462
  this.prevStats = o;
11463
- }), this.senderLock = new fe();
11463
+ }), this.senderLock = new me();
11464
11464
  }
11465
11465
  get isSimulcast() {
11466
11466
  return !!(this.sender && this.sender.getParameters().encodings.length > 1);
@@ -11468,7 +11468,7 @@ class Ei extends qa {
11468
11468
  /* @internal */
11469
11469
  startMonitor(e) {
11470
11470
  var t;
11471
- if (this.signalClient = e, !ve())
11471
+ if (this.signalClient = e, !be())
11472
11472
  return;
11473
11473
  const i = (t = this.sender) === null || t === void 0 ? void 0 : t.getParameters();
11474
11474
  i && (this.encodings = i.encodings), !this.monitorInterval && (this.monitorInterval = setInterval(() => {
@@ -11942,7 +11942,7 @@ class Ol extends je.EventEmitter {
11942
11942
  }));
11943
11943
  return;
11944
11944
  }
11945
- const u = he.fromBinary(new Uint8Array(l));
11945
+ const u = fe.fromBinary(new Uint8Array(l));
11946
11946
  if (u.sequence > 0 && u.participantSid !== "") {
11947
11947
  const h = this.reliableReceivedState.get(u.participantSid);
11948
11948
  if (h && u.sequence <= h)
@@ -11956,7 +11956,7 @@ class Ol extends je.EventEmitter {
11956
11956
  this.log.error("Received encrypted packet but E2EE not set up", this.logContext);
11957
11957
  return;
11958
11958
  }
11959
- const h = yield (o = this.e2eeManager) === null || o === void 0 ? void 0 : o.handleEncryptedData(u.value.value.encryptedValue, u.value.value.iv, u.participantIdentity, u.value.value.keyIndex), m = Ir.fromBinary(h.payload), b = new he({
11959
+ const h = yield (o = this.e2eeManager) === null || o === void 0 ? void 0 : o.handleEncryptedData(u.value.value.encryptedValue, u.value.value.iv, u.participantIdentity, u.value.value.keyIndex), m = Ir.fromBinary(h.payload), b = new fe({
11960
11960
  value: m.value,
11961
11961
  participantIdentity: u.participantIdentity,
11962
11962
  participantSid: u.participantSid
@@ -12040,7 +12040,7 @@ class Ol extends je.EventEmitter {
12040
12040
  }), this.log = ze((t = e.loggerName) !== null && t !== void 0 ? t : xe.Engine), this.loggerOptions = {
12041
12041
  loggerName: e.loggerName,
12042
12042
  loggerContextCb: () => this.logContext
12043
- }, this.client = new Jn(void 0, this.loggerOptions), this.client.signalLatency = this.options.expSignalLatency, this.reconnectPolicy = this.options.reconnectPolicy, this.closingLock = new fe(), this.dataProcessLock = new fe(), this.dcBufferStatus = /* @__PURE__ */ new Map([[B.LOSSY, !0], [B.RELIABLE, !0]]), this.client.onParticipantUpdate = (i) => this.emit(w.ParticipantUpdate, i), this.client.onConnectionQuality = (i) => this.emit(w.ConnectionQualityUpdate, i), this.client.onRoomUpdate = (i) => this.emit(w.RoomUpdate, i), this.client.onSubscriptionError = (i) => this.emit(w.SubscriptionError, i), this.client.onSubscriptionPermissionUpdate = (i) => this.emit(w.SubscriptionPermissionUpdate, i), this.client.onSpeakersChanged = (i) => this.emit(w.SpeakersChanged, i), this.client.onStreamStateUpdate = (i) => this.emit(w.StreamStateChanged, i), this.client.onRequestResponse = (i) => this.emit(w.SignalRequestResponse, i);
12043
+ }, this.client = new Jn(void 0, this.loggerOptions), this.client.signalLatency = this.options.expSignalLatency, this.reconnectPolicy = this.options.reconnectPolicy, this.closingLock = new me(), this.dataProcessLock = new me(), this.dcBufferStatus = /* @__PURE__ */ new Map([[B.LOSSY, !0], [B.RELIABLE, !0]]), this.client.onParticipantUpdate = (i) => this.emit(w.ParticipantUpdate, i), this.client.onConnectionQuality = (i) => this.emit(w.ConnectionQualityUpdate, i), this.client.onRoomUpdate = (i) => this.emit(w.RoomUpdate, i), this.client.onSubscriptionError = (i) => this.emit(w.SubscriptionError, i), this.client.onSubscriptionPermissionUpdate = (i) => this.emit(w.SubscriptionPermissionUpdate, i), this.client.onSpeakersChanged = (i) => this.emit(w.SpeakersChanged, i), this.client.onStreamStateUpdate = (i) => this.emit(w.StreamStateChanged, i), this.client.onRequestResponse = (i) => this.emit(w.SignalRequestResponse, i);
12044
12044
  }
12045
12045
  /** @internal */
12046
12046
  get logContext() {
@@ -12462,7 +12462,7 @@ class Ol extends je.EventEmitter {
12462
12462
  /** @internal */
12463
12463
  publishRpcResponse(e, t, i, s) {
12464
12464
  return f(this, void 0, void 0, function* () {
12465
- const r = new he({
12465
+ const r = new fe({
12466
12466
  destinationIdentities: [e],
12467
12467
  kind: B.RELIABLE,
12468
12468
  value: {
@@ -12485,7 +12485,7 @@ class Ol extends je.EventEmitter {
12485
12485
  /** @internal */
12486
12486
  publishRpcAck(e, t) {
12487
12487
  return f(this, void 0, void 0, function* () {
12488
- const i = new he({
12488
+ const i = new fe({
12489
12489
  destinationIdentities: [e],
12490
12490
  kind: B.RELIABLE,
12491
12491
  value: {
@@ -12547,7 +12547,7 @@ class Ol extends je.EventEmitter {
12547
12547
  });
12548
12548
  }
12549
12549
  waitForBufferStatusLow(e) {
12550
- return new ge((t, i) => f(this, void 0, void 0, function* () {
12550
+ return new ve((t, i) => f(this, void 0, void 0, function* () {
12551
12551
  if (this.isBufferStatusLow(e))
12552
12552
  t();
12553
12553
  else {
@@ -12601,7 +12601,7 @@ class Ol extends je.EventEmitter {
12601
12601
  /** @internal */
12602
12602
  negotiate() {
12603
12603
  return f(this, void 0, void 0, function* () {
12604
- return new ge((e, t) => f(this, void 0, void 0, function* () {
12604
+ return new ve((e, t) => f(this, void 0, void 0, function* () {
12605
12605
  if (!this.pcManager) {
12606
12606
  t(new Et("PC manager is closed"));
12607
12607
  return;
@@ -12700,10 +12700,10 @@ class Ol extends je.EventEmitter {
12700
12700
  this.clearReconnectTimeout(), this.reconnectAttempts = 0;
12701
12701
  }
12702
12702
  registerOnLineListener() {
12703
- ve() && (window.addEventListener("online", this.handleBrowserOnLine), window.addEventListener("offline", this.handleBrowserOffline));
12703
+ be() && (window.addEventListener("online", this.handleBrowserOnLine), window.addEventListener("offline", this.handleBrowserOffline));
12704
12704
  }
12705
12705
  deregisterOnLineListener() {
12706
- ve() && (window.removeEventListener("online", this.handleBrowserOnLine), window.removeEventListener("offline", this.handleBrowserOffline));
12706
+ be() && (window.removeEventListener("online", this.handleBrowserOnLine), window.removeEventListener("offline", this.handleBrowserOffline));
12707
12707
  }
12708
12708
  getTrackIdForReceiver(e) {
12709
12709
  var t;
@@ -12736,9 +12736,9 @@ class Ga {
12736
12736
  let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1;
12737
12737
  if (!(typeof this.totalByteSize != "number" || this.totalByteSize === 0)) {
12738
12738
  if (e && this.bytesReceived < this.totalByteSize)
12739
- throw new Ee("Not enough chunk(s) received - expected ".concat(this.totalByteSize, " bytes of data total, only received ").concat(this.bytesReceived, " bytes"), ue.Incomplete);
12739
+ throw new Ee("Not enough chunk(s) received - expected ".concat(this.totalByteSize, " bytes of data total, only received ").concat(this.bytesReceived, " bytes"), he.Incomplete);
12740
12740
  if (this.bytesReceived > this.totalByteSize)
12741
- throw new Ee("Extra chunk(s) received - expected ".concat(this.totalByteSize, " bytes of data total, received ").concat(this.bytesReceived, " bytes"), ue.LengthExceeded);
12741
+ throw new Ee("Extra chunk(s) received - expected ".concat(this.totalByteSize, " bytes of data total, received ").concat(this.bytesReceived, " bytes"), he.LengthExceeded);
12742
12742
  }
12743
12743
  }
12744
12744
  constructor(e, t, i, s) {
@@ -12906,7 +12906,7 @@ class xl extends Ga {
12906
12906
  try {
12907
12907
  u = t.decode(l.content);
12908
12908
  } catch (h) {
12909
- throw new Ee("Cannot decode datastream chunk ".concat(l.chunkIndex, " as text: ").concat(h), ue.DecodeFailed);
12909
+ throw new Ee("Cannot decode datastream chunk ".concat(l.chunkIndex, " as text: ").concat(h), he.DecodeFailed);
12910
12910
  }
12911
12911
  return {
12912
12912
  done: !1,
@@ -12972,7 +12972,7 @@ class Al {
12972
12972
  }
12973
12973
  registerTextStreamHandler(e, t) {
12974
12974
  if (this.textStreamHandlers.has(e))
12975
- throw new Ee('A text stream handler for topic "'.concat(e, '" has already been set.'), ue.HandlerAlreadyRegistered);
12975
+ throw new Ee('A text stream handler for topic "'.concat(e, '" has already been set.'), he.HandlerAlreadyRegistered);
12976
12976
  this.textStreamHandlers.set(e, t);
12977
12977
  }
12978
12978
  unregisterTextStreamHandler(e) {
@@ -12980,7 +12980,7 @@ class Al {
12980
12980
  }
12981
12981
  registerByteStreamHandler(e, t) {
12982
12982
  if (this.byteStreamHandlers.has(e))
12983
- throw new Ee('A byte stream handler for topic "'.concat(e, '" has already been set.'), ue.HandlerAlreadyRegistered);
12983
+ throw new Ee('A byte stream handler for topic "'.concat(e, '" has already been set.'), he.HandlerAlreadyRegistered);
12984
12984
  this.byteStreamHandlers.set(e, t);
12985
12985
  }
12986
12986
  unregisterByteStreamHandler(e) {
@@ -12993,7 +12993,7 @@ class Al {
12993
12993
  var t, i, s, r;
12994
12994
  const o = Array.from(this.textStreamControllers.entries()).filter((c) => c[1].sendingParticipantIdentity === e), a = Array.from(this.byteStreamControllers.entries()).filter((c) => c[1].sendingParticipantIdentity === e);
12995
12995
  if (o.length > 0 || a.length > 0) {
12996
- const c = new Ee("Participant ".concat(e, " unexpectedly disconnected in the middle of sending data"), ue.AbnormalEnd);
12996
+ const c = new Ee("Participant ".concat(e, " unexpectedly disconnected in the middle of sending data"), he.AbnormalEnd);
12997
12997
  for (const [d, l] of a)
12998
12998
  (i = (t = l.outOfBandFailureRejectingFuture).reject) === null || i === void 0 || i.call(t, c), this.byteStreamControllers.delete(d);
12999
12999
  for (const [d, l] of o)
@@ -13040,7 +13040,7 @@ class Al {
13040
13040
  }, d = new ReadableStream({
13041
13041
  start: (l) => {
13042
13042
  if (o = l, this.textStreamControllers.has(e.streamId))
13043
- throw new Ee("A data stream read is already in progress for a stream with id ".concat(e.streamId, "."), ue.AlreadyOpened);
13043
+ throw new Ee("A data stream read is already in progress for a stream with id ".concat(e.streamId, "."), he.AlreadyOpened);
13044
13044
  this.byteStreamControllers.set(e.streamId, {
13045
13045
  info: c,
13046
13046
  controller: o,
@@ -13075,7 +13075,7 @@ class Al {
13075
13075
  }, d = new ReadableStream({
13076
13076
  start: (l) => {
13077
13077
  if (o = l, this.textStreamControllers.has(e.streamId))
13078
- throw new Ee("A data stream read is already in progress for a stream with id ".concat(e.streamId, "."), ue.AlreadyOpened);
13078
+ throw new Ee("A data stream read is already in progress for a stream with id ".concat(e.streamId, "."), he.AlreadyOpened);
13079
13079
  this.textStreamControllers.set(e.streamId, {
13080
13080
  info: c,
13081
13081
  controller: o,
@@ -13093,15 +13093,15 @@ class Al {
13093
13093
  }
13094
13094
  handleStreamChunk(e, t) {
13095
13095
  const i = this.byteStreamControllers.get(e.streamId);
13096
- i && (i.info.encryptionType !== t ? (i.controller.error(new Ee("Encryption type mismatch for stream ".concat(e.streamId, ". Expected ").concat(t, ", got ").concat(i.info.encryptionType), ue.EncryptionTypeMismatch)), this.byteStreamControllers.delete(e.streamId)) : e.content.length > 0 && i.controller.enqueue(e));
13096
+ i && (i.info.encryptionType !== t ? (i.controller.error(new Ee("Encryption type mismatch for stream ".concat(e.streamId, ". Expected ").concat(t, ", got ").concat(i.info.encryptionType), he.EncryptionTypeMismatch)), this.byteStreamControllers.delete(e.streamId)) : e.content.length > 0 && i.controller.enqueue(e));
13097
13097
  const s = this.textStreamControllers.get(e.streamId);
13098
- s && (s.info.encryptionType !== t ? (s.controller.error(new Ee("Encryption type mismatch for stream ".concat(e.streamId, ". Expected ").concat(t, ", got ").concat(s.info.encryptionType), ue.EncryptionTypeMismatch)), this.textStreamControllers.delete(e.streamId)) : e.content.length > 0 && s.controller.enqueue(e));
13098
+ s && (s.info.encryptionType !== t ? (s.controller.error(new Ee("Encryption type mismatch for stream ".concat(e.streamId, ". Expected ").concat(t, ", got ").concat(s.info.encryptionType), he.EncryptionTypeMismatch)), this.textStreamControllers.delete(e.streamId)) : e.content.length > 0 && s.controller.enqueue(e));
13099
13099
  }
13100
13100
  handleStreamTrailer(e, t) {
13101
13101
  const i = this.textStreamControllers.get(e.streamId);
13102
- i && (i.info.encryptionType !== t ? i.controller.error(new Ee("Encryption type mismatch for stream ".concat(e.streamId, ". Expected ").concat(t, ", got ").concat(i.info.encryptionType), ue.EncryptionTypeMismatch)) : (i.info.attributes = Object.assign(Object.assign({}, i.info.attributes), e.attributes), i.controller.close(), this.textStreamControllers.delete(e.streamId)));
13102
+ i && (i.info.encryptionType !== t ? i.controller.error(new Ee("Encryption type mismatch for stream ".concat(e.streamId, ". Expected ").concat(t, ", got ").concat(i.info.encryptionType), he.EncryptionTypeMismatch)) : (i.info.attributes = Object.assign(Object.assign({}, i.info.attributes), e.attributes), i.controller.close(), this.textStreamControllers.delete(e.streamId)));
13103
13103
  const s = this.byteStreamControllers.get(e.streamId);
13104
- s && (s.info.encryptionType !== t ? s.controller.error(new Ee("Encryption type mismatch for stream ".concat(e.streamId, ". Expected ").concat(t, ", got ").concat(s.info.encryptionType), ue.EncryptionTypeMismatch)) : (s.info.attributes = Object.assign(Object.assign({}, s.info.attributes), e.attributes), s.controller.close()), this.byteStreamControllers.delete(e.streamId));
13104
+ s && (s.info.encryptionType !== t ? s.controller.error(new Ee("Encryption type mismatch for stream ".concat(e.streamId, ". Expected ").concat(t, ", got ").concat(s.info.encryptionType), he.EncryptionTypeMismatch)) : (s.info.attributes = Object.assign(Object.assign({}, s.info.attributes), e.attributes), s.controller.close()), this.byteStreamControllers.delete(e.streamId));
13105
13105
  }
13106
13106
  }
13107
13107
  class Ja {
@@ -13188,7 +13188,7 @@ class Ul {
13188
13188
  operationType: e?.type === "update" ? sn.UPDATE : sn.CREATE
13189
13189
  })
13190
13190
  }
13191
- }), c = e?.destinationIdentities, d = new he({
13191
+ }), c = e?.destinationIdentities, d = new fe({
13192
13192
  destinationIdentities: c,
13193
13193
  value: {
13194
13194
  case: "streamHeader",
@@ -13206,7 +13206,7 @@ class Ul {
13206
13206
  content: R,
13207
13207
  streamId: r,
13208
13208
  chunkIndex: dt(l)
13209
- }), P = new he({
13209
+ }), P = new fe({
13210
13210
  destinationIdentities: c,
13211
13211
  value: {
13212
13212
  case: "streamChunk",
@@ -13221,7 +13221,7 @@ class Ul {
13221
13221
  return f(this, void 0, void 0, function* () {
13222
13222
  const g = new Ti({
13223
13223
  streamId: r
13224
- }), R = new he({
13224
+ }), R = new fe({
13225
13225
  destinationIdentities: c,
13226
13226
  value: {
13227
13227
  case: "streamTrailer",
@@ -13299,7 +13299,7 @@ class Ul {
13299
13299
  name: l.name
13300
13300
  })
13301
13301
  }
13302
- }), h = new he({
13302
+ }), h = new fe({
13303
13303
  destinationIdentities: d,
13304
13304
  value: {
13305
13305
  case: "streamHeader",
@@ -13308,14 +13308,14 @@ class Ul {
13308
13308
  });
13309
13309
  yield this.engine.sendDataPacket(h, B.RELIABLE);
13310
13310
  let m = 0;
13311
- const b = new fe(), g = this.engine, R = this.log, k = new WritableStream({
13311
+ const b = new me(), g = this.engine, R = this.log, k = new WritableStream({
13312
13312
  write(O) {
13313
13313
  return f(this, void 0, void 0, function* () {
13314
13314
  const v = yield b.lock();
13315
13315
  let y = 0;
13316
13316
  try {
13317
13317
  for (; y < O.byteLength; ) {
13318
- const C = O.slice(y, y + ar), M = new he({
13318
+ const C = O.slice(y, y + ar), M = new fe({
13319
13319
  destinationIdentities: d,
13320
13320
  value: {
13321
13321
  case: "streamChunk",
@@ -13337,7 +13337,7 @@ class Ul {
13337
13337
  return f(this, void 0, void 0, function* () {
13338
13338
  const O = new Ti({
13339
13339
  streamId: c
13340
- }), v = new he({
13340
+ }), v = new fe({
13341
13341
  destinationIdentities: d,
13342
13342
  value: {
13343
13343
  case: "streamTrailer",
@@ -13720,7 +13720,7 @@ class Bl {
13720
13720
  }, this.onLeavePiP = () => {
13721
13721
  var i;
13722
13722
  this.isPiP = Bt(this.element), (i = this.handleVisibilityChanged) === null || i === void 0 || i.call(this);
13723
- }, this.element = e, this.isIntersecting = t ?? Rn(e), this.isPiP = ve() && Bt(e), this.visibilityChangedAt = 0;
13723
+ }, this.element = e, this.isIntersecting = t ?? Rn(e), this.isPiP = be() && Bt(e), this.visibilityChangedAt = 0;
13724
13724
  }
13725
13725
  width() {
13726
13726
  return this.element.clientWidth;
@@ -14261,7 +14261,7 @@ class Gl extends za {
14261
14261
  yield a.mute();
14262
14262
  else if (qe(a) || Xe(a))
14263
14263
  try {
14264
- if (ve())
14264
+ if (be())
14265
14265
  try {
14266
14266
  const c = yield navigator?.permissions.query({
14267
14267
  // the permission query for camera and microphone currently not supported in Safari and Firefox
@@ -14359,7 +14359,7 @@ class Gl extends za {
14359
14359
  attributes: o
14360
14360
  } = t;
14361
14361
  return (function* () {
14362
- return new ge((a, c) => f(i, void 0, void 0, function* () {
14362
+ return new ve((a, c) => f(i, void 0, void 0, function* () {
14363
14363
  var d, l;
14364
14364
  try {
14365
14365
  let u = !1;
@@ -14827,12 +14827,12 @@ class Gl extends za {
14827
14827
  try {
14828
14828
  for (var ae = !0, Se = Je(x), Qe; Qe = yield Se.next(), le = Qe.done, !le; ae = !0) {
14829
14829
  Y = Qe.value, ae = !1;
14830
- const ye = Y;
14831
- yield $t.write(ye);
14830
+ const ue = Y;
14831
+ yield $t.write(ue);
14832
14832
  }
14833
- } catch (ye) {
14833
+ } catch (ue) {
14834
14834
  Ve = {
14835
- error: ye
14835
+ error: ue
14836
14836
  };
14837
14837
  } finally {
14838
14838
  try {
@@ -14954,7 +14954,7 @@ class Gl extends za {
14954
14954
  var i = this;
14955
14955
  let s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
14956
14956
  return (function* () {
14957
- i.republishPromise && (yield i.republishPromise), i.republishPromise = new ge((r, o) => f(i, void 0, void 0, function* () {
14957
+ i.republishPromise && (yield i.republishPromise), i.republishPromise = new ve((r, o) => f(i, void 0, void 0, function* () {
14958
14958
  try {
14959
14959
  const a = [];
14960
14960
  this.trackPublications.forEach((c) => {
@@ -14993,7 +14993,7 @@ class Gl extends za {
14993
14993
  destinationIdentities: o,
14994
14994
  topic: a
14995
14995
  });
14996
- const d = new he({
14996
+ const d = new fe({
14997
14997
  kind: r,
14998
14998
  value: {
14999
14999
  case: "user",
@@ -15012,7 +15012,7 @@ class Gl extends za {
15012
15012
  */
15013
15013
  publishDtmf(e, t) {
15014
15014
  return f(this, void 0, void 0, function* () {
15015
- const i = new he({
15015
+ const i = new fe({
15016
15016
  kind: B.RELIABLE,
15017
15017
  value: {
15018
15018
  case: "sipDtmf",
@@ -15033,7 +15033,7 @@ class Gl extends za {
15033
15033
  message: e,
15034
15034
  timestamp: Date.now(),
15035
15035
  attachedFiles: t?.attachments
15036
- }, s = new he({
15036
+ }, s = new fe({
15037
15037
  value: {
15038
15038
  case: "chatMessage",
15039
15039
  value: new bi(Object.assign(Object.assign({}, i), {
@@ -15050,7 +15050,7 @@ class Gl extends za {
15050
15050
  const i = Object.assign(Object.assign({}, t), {
15051
15051
  message: e,
15052
15052
  editTimestamp: Date.now()
15053
- }), s = new he({
15053
+ }), s = new fe({
15054
15054
  value: {
15055
15055
  case: "chatMessage",
15056
15056
  value: new bi(Object.assign(Object.assign({}, i), {
@@ -15123,7 +15123,7 @@ class Gl extends za {
15123
15123
  responseTimeout: r = 15e3
15124
15124
  } = e;
15125
15125
  const o = 7e3, a = o + 1e3;
15126
- return new ge((c, d) => f(this, void 0, void 0, function* () {
15126
+ return new ve((c, d) => f(this, void 0, void 0, function* () {
15127
15127
  var l, u, h, m;
15128
15128
  if (Xn(s) > Va) {
15129
15129
  d(Z.builtIn("REQUEST_PAYLOAD_TOO_LARGE"));
@@ -15199,7 +15199,7 @@ class Gl extends za {
15199
15199
  /** @internal */
15200
15200
  publishRpcRequest(e, t, i, s, r) {
15201
15201
  return f(this, void 0, void 0, function* () {
15202
- const o = new he({
15202
+ const o = new fe({
15203
15203
  destinationIdentities: [e],
15204
15204
  kind: B.RELIABLE,
15205
15205
  value: {
@@ -15715,7 +15715,7 @@ class Dt extends je.EventEmitter {
15715
15715
  } catch (m) {
15716
15716
  throw yield this.engine.close(), this.recreateEngine(), m;
15717
15717
  }
15718
- ve() && this.options.disconnectOnPageLeave && (window.addEventListener("pagehide", this.onPageLeave), window.addEventListener("beforeunload", this.onPageLeave)), ve() && window.addEventListener("freeze", this.onPageLeave), this.setAndEmitConnectionState(K.Connected), this.emit(E.Connected), _t.getInstance().resetFailedConnectionAttempts(a), this.registerConnectionReconcile(), this.regionUrlProvider && this.regionUrlProvider.notifyConnected();
15718
+ be() && this.options.disconnectOnPageLeave && (window.addEventListener("pagehide", this.onPageLeave), window.addEventListener("beforeunload", this.onPageLeave)), be() && window.addEventListener("freeze", this.onPageLeave), this.setAndEmitConnectionState(K.Connected), this.emit(E.Connected), _t.getInstance().resetFailedConnectionAttempts(a), this.registerConnectionReconcile(), this.regionUrlProvider && this.regionUrlProvider.notifyConnected();
15719
15719
  }), this.disconnect = function() {
15720
15720
  for (var a = arguments.length, c = new Array(a), d = 0; d < a; d++)
15721
15721
  c[d] = arguments[d];
@@ -15743,7 +15743,7 @@ class Dt extends je.EventEmitter {
15743
15743
  }, this.onPageLeave = () => f(this, void 0, void 0, function* () {
15744
15744
  this.log.info("Page leave detected, disconnecting", this.logContext), yield this.disconnect();
15745
15745
  }), this.startAudio = () => f(this, void 0, void 0, function* () {
15746
- const a = [], c = be();
15746
+ const a = [], c = ye();
15747
15747
  if (c && c.os === "iOS") {
15748
15748
  const d = "livekit-dummy-audio-el";
15749
15749
  let l = document.getElementById(d);
@@ -15911,7 +15911,7 @@ class Dt extends je.EventEmitter {
15911
15911
  this.isVideoPlaybackBlocked || (this.isVideoPlaybackBlocked = !0, this.emit(E.VideoPlaybackStatusChanged, !1));
15912
15912
  }, this.handleDeviceChange = () => f(this, void 0, void 0, function* () {
15913
15913
  var a;
15914
- ((a = be()) === null || a === void 0 ? void 0 : a.os) !== "iOS" && (yield this.selectDefaultDevices()), this.emit(E.MediaDevicesChanged);
15914
+ ((a = ye()) === null || a === void 0 ? void 0 : a.os) !== "iOS" && (yield this.selectDefaultDevices()), this.emit(E.MediaDevicesChanged);
15915
15915
  }), this.handleRoomUpdate = (a) => {
15916
15916
  const c = this.roomInfo;
15917
15917
  this.roomInfo = a, c && c.metadata !== a.metadata && this.emitWhenConnected(E.RoomMetadataChanged, a.metadata), c?.activeRecording !== a.activeRecording && this.emitWhenConnected(E.RecordingStatusChanged, a.activeRecording);
@@ -15956,7 +15956,7 @@ class Dt extends je.EventEmitter {
15956
15956
  this.emit(E.ParticipantPermissionsChanged, a, this.localParticipant);
15957
15957
  }, this.onLocalChatMessageSent = (a) => {
15958
15958
  this.emit(E.ChatMessage, a, this.localParticipant);
15959
- }, this.setMaxListeners(100), this.remoteParticipants = /* @__PURE__ */ new Map(), this.sidToIdentity = /* @__PURE__ */ new Map(), this.options = Object.assign(Object.assign({}, sl), e), this.log = ze((i = this.options.loggerName) !== null && i !== void 0 ? i : xe.Room), this.transcriptionReceivedTimes = /* @__PURE__ */ new Map(), this.options.audioCaptureDefaults = Object.assign(Object.assign({}, Fa), e?.audioCaptureDefaults), this.options.videoCaptureDefaults = Object.assign(Object.assign({}, ja), e?.videoCaptureDefaults), this.options.publishDefaults = Object.assign(Object.assign({}, nl), e?.publishDefaults), this.maybeCreateEngine(), this.incomingDataStreamManager = new Al(), this.outgoingDataStreamManager = new Ul(this.engine, this.log), this.disconnectLock = new fe(), this.localParticipant = new Gl("", "", this.engine, this.options, this.rpcHandlers, this.outgoingDataStreamManager), (this.options.e2ee || this.options.encryption) && this.setupE2EE(), this.engine.e2eeManager = this.e2eeManager, this.options.videoCaptureDefaults.deviceId && this.localParticipant.activeDeviceMap.set("videoinput", it(this.options.videoCaptureDefaults.deviceId)), this.options.audioCaptureDefaults.deviceId && this.localParticipant.activeDeviceMap.set("audioinput", it(this.options.audioCaptureDefaults.deviceId)), !((s = this.options.audioOutput) === null || s === void 0) && s.deviceId && this.switchActiveDevice("audiooutput", it(this.options.audioOutput.deviceId)).catch((a) => this.log.warn("Could not set audio output: ".concat(a.message), this.logContext)), ve()) {
15959
+ }, this.setMaxListeners(100), this.remoteParticipants = /* @__PURE__ */ new Map(), this.sidToIdentity = /* @__PURE__ */ new Map(), this.options = Object.assign(Object.assign({}, sl), e), this.log = ze((i = this.options.loggerName) !== null && i !== void 0 ? i : xe.Room), this.transcriptionReceivedTimes = /* @__PURE__ */ new Map(), this.options.audioCaptureDefaults = Object.assign(Object.assign({}, Fa), e?.audioCaptureDefaults), this.options.videoCaptureDefaults = Object.assign(Object.assign({}, ja), e?.videoCaptureDefaults), this.options.publishDefaults = Object.assign(Object.assign({}, nl), e?.publishDefaults), this.maybeCreateEngine(), this.incomingDataStreamManager = new Al(), this.outgoingDataStreamManager = new Ul(this.engine, this.log), this.disconnectLock = new me(), this.localParticipant = new Gl("", "", this.engine, this.options, this.rpcHandlers, this.outgoingDataStreamManager), (this.options.e2ee || this.options.encryption) && this.setupE2EE(), this.engine.e2eeManager = this.e2eeManager, this.options.videoCaptureDefaults.deviceId && this.localParticipant.activeDeviceMap.set("videoinput", it(this.options.videoCaptureDefaults.deviceId)), this.options.audioCaptureDefaults.deviceId && this.localParticipant.activeDeviceMap.set("audioinput", it(this.options.audioCaptureDefaults.deviceId)), !((s = this.options.audioOutput) === null || s === void 0) && s.deviceId && this.switchActiveDevice("audiooutput", it(this.options.audioOutput.deviceId)).catch((a) => this.log.warn("Could not set audio output: ".concat(a.message), this.logContext)), be()) {
15960
15960
  const a = new AbortController();
15961
15961
  (o = (r = navigator.mediaDevices) === null || r === void 0 ? void 0 : r.addEventListener) === null || o === void 0 || o.call(r, "devicechange", this.handleDeviceChange, {
15962
15962
  signal: a.signal
@@ -16058,7 +16058,7 @@ class Dt extends je.EventEmitter {
16058
16058
  * returns once a sid has been issued by the server.
16059
16059
  */
16060
16060
  getSid() {
16061
- return this.state === K.Disconnected ? ge.resolve("") : this.roomInfo && this.roomInfo.sid !== "" ? ge.resolve(this.roomInfo.sid) : new ge((e, t) => {
16061
+ return this.state === K.Disconnected ? ve.resolve("") : this.roomInfo && this.roomInfo.sid !== "" ? ve.resolve(this.roomInfo.sid) : new ve((e, t) => {
16062
16062
  const i = (s) => {
16063
16063
  s.sid !== "" && (this.engine.off(w.RoomUpdate, i), e(s.sid));
16064
16064
  };
@@ -16437,7 +16437,7 @@ class Dt extends je.EventEmitter {
16437
16437
  }), this.localParticipant.trackPublications.forEach((r) => {
16438
16438
  var o, a, c;
16439
16439
  r.track && this.localParticipant.unpublishTrack(r.track, e), e ? ((o = r.track) === null || o === void 0 || o.detach(), (a = r.track) === null || a === void 0 || a.stop()) : (c = r.track) === null || c === void 0 || c.stopMonitor();
16440
- }), this.localParticipant.off(I.ParticipantMetadataChanged, this.onLocalParticipantMetadataChanged).off(I.ParticipantNameChanged, this.onLocalParticipantNameChanged).off(I.AttributesChanged, this.onLocalAttributesChanged).off(I.TrackMuted, this.onLocalTrackMuted).off(I.TrackUnmuted, this.onLocalTrackUnmuted).off(I.LocalTrackPublished, this.onLocalTrackPublished).off(I.LocalTrackUnpublished, this.onLocalTrackUnpublished).off(I.ConnectionQualityChanged, this.onLocalConnectionQualityChanged).off(I.MediaDevicesError, this.onMediaDevicesError).off(I.AudioStreamAcquired, this.startAudio).off(I.ChatMessage, this.onLocalChatMessageSent).off(I.ParticipantPermissionsChanged, this.onLocalParticipantPermissionsChanged), this.localParticipant.trackPublications.clear(), this.localParticipant.videoTrackPublications.clear(), this.localParticipant.audioTrackPublications.clear(), this.remoteParticipants.clear(), this.sidToIdentity.clear(), this.activeSpeakers = [], this.audioContext && typeof this.options.webAudioMix == "boolean" && (this.audioContext.close(), this.audioContext = void 0), ve() && (window.removeEventListener("beforeunload", this.onPageLeave), window.removeEventListener("pagehide", this.onPageLeave), window.removeEventListener("freeze", this.onPageLeave), (s = (i = navigator.mediaDevices) === null || i === void 0 ? void 0 : i.removeEventListener) === null || s === void 0 || s.call(i, "devicechange", this.handleDeviceChange));
16440
+ }), this.localParticipant.off(I.ParticipantMetadataChanged, this.onLocalParticipantMetadataChanged).off(I.ParticipantNameChanged, this.onLocalParticipantNameChanged).off(I.AttributesChanged, this.onLocalAttributesChanged).off(I.TrackMuted, this.onLocalTrackMuted).off(I.TrackUnmuted, this.onLocalTrackUnmuted).off(I.LocalTrackPublished, this.onLocalTrackPublished).off(I.LocalTrackUnpublished, this.onLocalTrackUnpublished).off(I.ConnectionQualityChanged, this.onLocalConnectionQualityChanged).off(I.MediaDevicesError, this.onMediaDevicesError).off(I.AudioStreamAcquired, this.startAudio).off(I.ChatMessage, this.onLocalChatMessageSent).off(I.ParticipantPermissionsChanged, this.onLocalParticipantPermissionsChanged), this.localParticipant.trackPublications.clear(), this.localParticipant.videoTrackPublications.clear(), this.localParticipant.audioTrackPublications.clear(), this.remoteParticipants.clear(), this.sidToIdentity.clear(), this.activeSpeakers = [], this.audioContext && typeof this.options.webAudioMix == "boolean" && (this.audioContext.close(), this.audioContext = void 0), be() && (window.removeEventListener("beforeunload", this.onPageLeave), window.removeEventListener("pagehide", this.onPageLeave), window.removeEventListener("freeze", this.onPageLeave), (s = (i = navigator.mediaDevices) === null || i === void 0 ? void 0 : i.removeEventListener) === null || s === void 0 || s.call(i, "devicechange", this.handleDeviceChange));
16441
16441
  } finally {
16442
16442
  this.setAndEmitConnectionState(K.Disconnected), this.emit(E.Disconnected, t);
16443
16443
  }
@@ -16481,7 +16481,7 @@ class Dt extends je.EventEmitter {
16481
16481
  selectDefaultDevices() {
16482
16482
  return f(this, void 0, void 0, function* () {
16483
16483
  var e, t, i;
16484
- const s = re.getInstance().previousDevices, r = yield re.getInstance().getDevices(void 0, !1), o = be();
16484
+ const s = re.getInstance().previousDevices, r = yield re.getInstance().getDevices(void 0, !1), o = ye();
16485
16485
  if (o?.name === "Chrome" && o.os !== "iOS")
16486
16486
  for (let c of r) {
16487
16487
  const d = s.find((l) => l.deviceId === c.deviceId);
@@ -17243,14 +17243,14 @@ function su(n) {
17243
17243
  }
17244
17244
  new TextEncoder();
17245
17245
  new TextDecoder();
17246
- class me extends Error {
17246
+ class pe extends Error {
17247
17247
  constructor(e, t) {
17248
17248
  var i;
17249
17249
  super(e, t), q(this, "code", "ERR_JOSE_GENERIC"), this.name = this.constructor.name, (i = Error.captureStackTrace) === null || i === void 0 || i.call(Error, this, this.constructor);
17250
17250
  }
17251
17251
  }
17252
- q(me, "code", "ERR_JOSE_GENERIC");
17253
- class ru extends me {
17252
+ q(pe, "code", "ERR_JOSE_GENERIC");
17253
+ class ru extends pe {
17254
17254
  constructor(e, t) {
17255
17255
  let i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "unspecified", s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "unspecified";
17256
17256
  super(e, {
@@ -17263,7 +17263,7 @@ class ru extends me {
17263
17263
  }
17264
17264
  }
17265
17265
  q(ru, "code", "ERR_JWT_CLAIM_VALIDATION_FAILED");
17266
- class au extends me {
17266
+ class au extends pe {
17267
17267
  constructor(e, t) {
17268
17268
  let i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "unspecified", s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "unspecified";
17269
17269
  super(e, {
@@ -17276,77 +17276,77 @@ class au extends me {
17276
17276
  }
17277
17277
  }
17278
17278
  q(au, "code", "ERR_JWT_EXPIRED");
17279
- class ou extends me {
17279
+ class ou extends pe {
17280
17280
  constructor() {
17281
17281
  super(...arguments), q(this, "code", "ERR_JOSE_ALG_NOT_ALLOWED");
17282
17282
  }
17283
17283
  }
17284
17284
  q(ou, "code", "ERR_JOSE_ALG_NOT_ALLOWED");
17285
- class cu extends me {
17285
+ class cu extends pe {
17286
17286
  constructor() {
17287
17287
  super(...arguments), q(this, "code", "ERR_JOSE_NOT_SUPPORTED");
17288
17288
  }
17289
17289
  }
17290
17290
  q(cu, "code", "ERR_JOSE_NOT_SUPPORTED");
17291
- class du extends me {
17291
+ class du extends pe {
17292
17292
  constructor() {
17293
17293
  let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "decryption operation failed", t = arguments.length > 1 ? arguments[1] : void 0;
17294
17294
  super(e, t), q(this, "code", "ERR_JWE_DECRYPTION_FAILED");
17295
17295
  }
17296
17296
  }
17297
17297
  q(du, "code", "ERR_JWE_DECRYPTION_FAILED");
17298
- class lu extends me {
17298
+ class lu extends pe {
17299
17299
  constructor() {
17300
17300
  super(...arguments), q(this, "code", "ERR_JWE_INVALID");
17301
17301
  }
17302
17302
  }
17303
17303
  q(lu, "code", "ERR_JWE_INVALID");
17304
- class uu extends me {
17304
+ class uu extends pe {
17305
17305
  constructor() {
17306
17306
  super(...arguments), q(this, "code", "ERR_JWS_INVALID");
17307
17307
  }
17308
17308
  }
17309
17309
  q(uu, "code", "ERR_JWS_INVALID");
17310
- class hu extends me {
17310
+ class hu extends pe {
17311
17311
  constructor() {
17312
17312
  super(...arguments), q(this, "code", "ERR_JWT_INVALID");
17313
17313
  }
17314
17314
  }
17315
17315
  q(hu, "code", "ERR_JWT_INVALID");
17316
- class fu extends me {
17316
+ class fu extends pe {
17317
17317
  constructor() {
17318
17318
  super(...arguments), q(this, "code", "ERR_JWK_INVALID");
17319
17319
  }
17320
17320
  }
17321
17321
  q(fu, "code", "ERR_JWK_INVALID");
17322
- class mu extends me {
17322
+ class mu extends pe {
17323
17323
  constructor() {
17324
17324
  super(...arguments), q(this, "code", "ERR_JWKS_INVALID");
17325
17325
  }
17326
17326
  }
17327
17327
  q(mu, "code", "ERR_JWKS_INVALID");
17328
- class pu extends me {
17328
+ class pu extends pe {
17329
17329
  constructor() {
17330
17330
  let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "no applicable key found in the JSON Web Key Set", t = arguments.length > 1 ? arguments[1] : void 0;
17331
17331
  super(e, t), q(this, "code", "ERR_JWKS_NO_MATCHING_KEY");
17332
17332
  }
17333
17333
  }
17334
17334
  q(pu, "code", "ERR_JWKS_NO_MATCHING_KEY");
17335
- class gu extends me {
17335
+ class gu extends pe {
17336
17336
  constructor() {
17337
17337
  let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "multiple matching keys found in the JSON Web Key Set", t = arguments.length > 1 ? arguments[1] : void 0;
17338
17338
  super(e, t), q(this, Symbol.asyncIterator, void 0), q(this, "code", "ERR_JWKS_MULTIPLE_MATCHING_KEYS");
17339
17339
  }
17340
17340
  }
17341
17341
  q(gu, "code", "ERR_JWKS_MULTIPLE_MATCHING_KEYS");
17342
- class vu extends me {
17342
+ class vu extends pe {
17343
17343
  constructor() {
17344
17344
  let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "request timed out", t = arguments.length > 1 ? arguments[1] : void 0;
17345
17345
  super(e, t), q(this, "code", "ERR_JWKS_TIMEOUT");
17346
17346
  }
17347
17347
  }
17348
17348
  q(vu, "code", "ERR_JWKS_TIMEOUT");
17349
- class bu extends me {
17349
+ class bu extends pe {
17350
17350
  constructor() {
17351
17351
  let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "signature verification failed", t = arguments.length > 1 ? arguments[1] : void 0;
17352
17352
  super(e, t), q(this, "code", "ERR_JWS_SIGNATURE_VERIFICATION_FAILED");
@@ -17395,18 +17395,20 @@ function Su({ mode: n, server: e, configuration: t, applicationId: i, tenantId:
17395
17395
  if (de !== or) return;
17396
17396
  const $t = new TextDecoder().decode(ae);
17397
17397
  try {
17398
- const ye = JSON.parse($t);
17399
- if (console.log("Received from agent:", ye), ye.type === "ready")
17400
- ye.messages && ye.messages.length > 0 && a(ye.messages), d("connected"), O.current = !1, v.current === "voice" && k(!0);
17401
- else if (ye.type === "message") {
17402
- const At = ye;
17398
+ const ue = JSON.parse($t);
17399
+ if (console.log("Received from agent:", ue), ue.type === "session_end")
17400
+ alert(ue.message), y();
17401
+ else if (ue.type === "ready")
17402
+ ue.messages && ue.messages.length > 0 && a(ue.messages), d("connected"), O.current = !1, v.current === "voice" && k(!0);
17403
+ else if (ue.type === "message") {
17404
+ const At = ue;
17403
17405
  a(function(Zt) {
17404
17406
  const es = Zt.findIndex((Ya) => Ya.id === At.message.id);
17405
17407
  return es >= 0 ? Zt[es] = At.message : Zt.push(At.message), [...Zt];
17406
17408
  }), At.message.role === "assistant" ? g("") : At.message.role === "user" && m(""), u(!1);
17407
17409
  }
17408
- } catch (ye) {
17409
- console.error("Failed to parse agent message:", ye);
17410
+ } catch (ue) {
17411
+ console.error("Failed to parse agent message:", ue);
17410
17412
  }
17411
17413
  };
17412
17414
  Te.on(E.DataReceived, Mt), Te.on(E.TrackSubscribed, (ae, Se, Qe) => {