@signalwire/js 4.0.0-beta.1 → 4.0.0-beta.3

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.
@@ -6689,7 +6689,7 @@ var require_share = /* @__PURE__ */ __commonJSMin(((exports) => {
6689
6689
  var Subject_1$6 = require_Subject();
6690
6690
  var Subscriber_1$1 = require_Subscriber();
6691
6691
  var lift_1$19 = require_lift();
6692
- function share$1(options) {
6692
+ function share$3(options) {
6693
6693
  if (options === void 0) options = {};
6694
6694
  var _a = options.connector, connector = _a === void 0 ? function() {
6695
6695
  return new Subject_1$6.Subject();
@@ -6747,7 +6747,7 @@ var require_share = /* @__PURE__ */ __commonJSMin(((exports) => {
6747
6747
  })(wrapperSource);
6748
6748
  };
6749
6749
  }
6750
- exports.share = share$1;
6750
+ exports.share = share$3;
6751
6751
  function handleReset(reset, on) {
6752
6752
  var args = [];
6753
6753
  for (var _i = 2; _i < arguments.length; _i++) args[_i - 2] = arguments[_i];
@@ -8945,11 +8945,21 @@ var Destroyable = class {
8945
8945
  this._destroyed$ = new import_cjs$22.Subject();
8946
8946
  }
8947
8947
  destroy() {
8948
+ this._observableCache?.clear();
8948
8949
  this.subscriptions.forEach((sub) => sub.unsubscribe());
8949
8950
  this.subjects.forEach((subject) => subject.complete());
8950
8951
  this._destroyed$.next();
8951
8952
  this._destroyed$.complete();
8952
8953
  }
8954
+ cachedObservable(key, factory) {
8955
+ this._observableCache ??= /* @__PURE__ */ new Map();
8956
+ let cached = this._observableCache.get(key);
8957
+ if (!cached) {
8958
+ cached = factory();
8959
+ this._observableCache.set(key, cached);
8960
+ }
8961
+ return cached;
8962
+ }
8953
8963
  subscribeTo(observable, observerOrNext) {
8954
8964
  const subscription = observable.subscribe(observerOrNext);
8955
8965
  this.subscriptions.push(subscription);
@@ -8970,7 +8980,7 @@ var Destroyable = class {
8970
8980
  return subject;
8971
8981
  }
8972
8982
  get $() {
8973
- return (0, import_cjs$22.merge)(...this.subjects.map((s) => s instanceof import_cjs$22.BehaviorSubject ? s.pipe((0, import_cjs$22.skip)(1)) : s)).pipe((0, import_cjs$22.map)((_) => this));
8983
+ return this.cachedObservable("$", () => (0, import_cjs$22.merge)(...this.subjects.map((s) => s instanceof import_cjs$22.BehaviorSubject ? s.pipe((0, import_cjs$22.skip)(1)) : s)).pipe((0, import_cjs$22.map)((_) => this)));
8974
8984
  }
8975
8985
  /**
8976
8986
  * Observable that emits when the instance is destroyed
@@ -9958,8 +9968,9 @@ const selectDevice = (devices = [], selected, preferred) => {
9958
9968
  return selected;
9959
9969
  };
9960
9970
  var NavigatorDeviceController = class extends Destroyable {
9961
- constructor() {
9971
+ constructor(webRTCApiProvider) {
9962
9972
  super();
9973
+ this.webRTCApiProvider = webRTCApiProvider;
9963
9974
  this.deviceChangeHandler = () => {
9964
9975
  logger$19.debug("[DeviceController] Device change detected");
9965
9976
  this.enumerateDevices();
@@ -9983,25 +9994,25 @@ var NavigatorDeviceController = class extends Destroyable {
9983
9994
  return {};
9984
9995
  }
9985
9996
  get errors$() {
9986
- return this._errors$.asObservable().pipe((0, import_cjs$20.takeUntil)(this.destroyed$));
9997
+ return this.cachedObservable("errors$", () => this._errors$.asObservable().pipe((0, import_cjs$20.takeUntil)(this.destroyed$)));
9987
9998
  }
9988
9999
  get audioInputDevices$() {
9989
- return this._devicesState$.pipe((0, import_cjs$20.map)((state) => state.audioinput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$));
10000
+ return this.cachedObservable("audioInputDevices$", () => this._devicesState$.pipe((0, import_cjs$20.map)((state) => state.audioinput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$)));
9990
10001
  }
9991
10002
  get audioOutputDevices$() {
9992
- return this._devicesState$.pipe((0, import_cjs$20.map)((state) => state.audiooutput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$));
10003
+ return this.cachedObservable("audioOutputDevices$", () => this._devicesState$.pipe((0, import_cjs$20.map)((state) => state.audiooutput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$)));
9993
10004
  }
9994
10005
  get videoInputDevices$() {
9995
- return this._devicesState$.pipe((0, import_cjs$20.map)((state) => state.videoinput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$));
10006
+ return this.cachedObservable("videoInputDevices$", () => this._devicesState$.pipe((0, import_cjs$20.map)((state) => state.videoinput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$)));
9996
10007
  }
9997
10008
  get selectedAudioInputDevice$() {
9998
- return this._selectedDevicesState$.asObservable().pipe((0, import_cjs$20.map)((state) => state.audioinput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$), (0, import_cjs$20.tap)((info) => logger$19.debug("[DeviceController] Selected audio input device changed:", info)));
10009
+ return this.cachedObservable("selectedAudioInputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, import_cjs$20.map)((state) => state.audioinput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$), (0, import_cjs$20.tap)((info) => logger$19.debug("[DeviceController] Selected audio input device changed:", info))));
9999
10010
  }
10000
10011
  get selectedAudioOutputDevice$() {
10001
- return this._selectedDevicesState$.asObservable().pipe((0, import_cjs$20.map)((state) => state.audiooutput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$), (0, import_cjs$20.tap)((info) => logger$19.debug("[DeviceController] Selected audio output device changed:", info)));
10012
+ return this.cachedObservable("selectedAudioOutputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, import_cjs$20.map)((state) => state.audiooutput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$), (0, import_cjs$20.tap)((info) => logger$19.debug("[DeviceController] Selected audio output device changed:", info))));
10002
10013
  }
10003
10014
  get selectedVideoInputDevice$() {
10004
- return this._selectedDevicesState$.asObservable().pipe((0, import_cjs$20.map)((state) => state.videoinput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$), (0, import_cjs$20.tap)((info) => logger$19.debug("[DeviceController] Selected video input device changed:", info)));
10015
+ return this.cachedObservable("selectedVideoInputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, import_cjs$20.map)((state) => state.videoinput), (0, import_cjs$20.distinctUntilChanged)(), (0, import_cjs$20.takeUntil)(this.destroyed$), (0, import_cjs$20.tap)((info) => logger$19.debug("[DeviceController] Selected video input device changed:", info))));
10005
10016
  }
10006
10017
  get selectedAudioInputDevice() {
10007
10018
  return this._selectedDevicesState$.value.audioinput;
@@ -10041,24 +10052,22 @@ var NavigatorDeviceController = class extends Destroyable {
10041
10052
  });
10042
10053
  }
10043
10054
  init() {
10044
- if (navigator.mediaDevices) {
10045
- this.subscribeTo(this._devicesState$.pipe((0, import_cjs$20.debounceTime)(PreferencesContainer.instance.deviceDebounceTime)), (devicesState) => {
10046
- const currentSelected = this._selectedDevicesState$.value;
10047
- const newAudioInput = selectDevice(devicesState.audioinput, currentSelected.audioinput, PreferencesContainer.instance.preferredAudioInput);
10048
- const newAudioOutput = selectDevice(devicesState.audiooutput, currentSelected.audiooutput, PreferencesContainer.instance.preferredAudioOutput);
10049
- const newVideoInput = selectDevice(devicesState.videoinput, currentSelected.videoinput, PreferencesContainer.instance.preferredVideoInput);
10050
- if (newAudioInput !== currentSelected.audioinput || newAudioOutput !== currentSelected.audiooutput || newVideoInput !== currentSelected.videoinput) this._selectedDevicesState$.next({
10051
- audioinput: newAudioInput,
10052
- audiooutput: newAudioOutput,
10053
- videoinput: newVideoInput
10054
- });
10055
+ this.subscribeTo(this._devicesState$.pipe((0, import_cjs$20.debounceTime)(PreferencesContainer.instance.deviceDebounceTime)), (devicesState) => {
10056
+ const currentSelected = this._selectedDevicesState$.value;
10057
+ const newAudioInput = selectDevice(devicesState.audioinput, currentSelected.audioinput, PreferencesContainer.instance.preferredAudioInput);
10058
+ const newAudioOutput = selectDevice(devicesState.audiooutput, currentSelected.audiooutput, PreferencesContainer.instance.preferredAudioOutput);
10059
+ const newVideoInput = selectDevice(devicesState.videoinput, currentSelected.videoinput, PreferencesContainer.instance.preferredVideoInput);
10060
+ if (newAudioInput !== currentSelected.audioinput || newAudioOutput !== currentSelected.audiooutput || newVideoInput !== currentSelected.videoinput) this._selectedDevicesState$.next({
10061
+ audioinput: newAudioInput,
10062
+ audiooutput: newAudioOutput,
10063
+ videoinput: newVideoInput
10055
10064
  });
10056
- this.enumerateDevices();
10057
- }
10065
+ });
10066
+ this.enumerateDevices();
10058
10067
  }
10059
10068
  enableDeviceMonitoring() {
10060
10069
  this.disableDeviceMonitoring();
10061
- navigator.mediaDevices.addEventListener("devicechange", this.deviceChangeHandler);
10070
+ this.webRTCApiProvider.mediaDevices.addEventListener("devicechange", this.deviceChangeHandler);
10062
10071
  if (PreferencesContainer.instance.devicePollingInterval > 0) this._devicesPoolingSubscription = (0, import_cjs$20.interval)(PreferencesContainer.instance.devicePollingInterval).subscribe(() => {
10063
10072
  logger$19.debug("[DeviceController] Polling devices due to interval");
10064
10073
  this.enumerateDevices();
@@ -10066,7 +10075,7 @@ var NavigatorDeviceController = class extends Destroyable {
10066
10075
  this.enumerateDevices();
10067
10076
  }
10068
10077
  disableDeviceMonitoring() {
10069
- navigator.mediaDevices.removeEventListener("devicechange", this.deviceChangeHandler);
10078
+ this.webRTCApiProvider.mediaDevices.removeEventListener("devicechange", this.deviceChangeHandler);
10070
10079
  if (this._devicesPoolingSubscription) {
10071
10080
  this._devicesPoolingSubscription.unsubscribe();
10072
10081
  this._devicesPoolingSubscription = void 0;
@@ -10074,7 +10083,7 @@ var NavigatorDeviceController = class extends Destroyable {
10074
10083
  }
10075
10084
  async enumerateDevices() {
10076
10085
  try {
10077
- const devicesByKind = (await navigator.mediaDevices.enumerateDevices()).reduce((acc, device) => {
10086
+ const devicesByKind = (await this.webRTCApiProvider.mediaDevices.enumerateDevices()).reduce((acc, device) => {
10078
10087
  acc[device.kind].push(device);
10079
10088
  return acc;
10080
10089
  }, {
@@ -10097,7 +10106,7 @@ var NavigatorDeviceController = class extends Destroyable {
10097
10106
  if (deviceInfo.kind === "audiooutput") return null;
10098
10107
  try {
10099
10108
  const constraints = this.deviceInfoToConstraints(deviceInfo);
10100
- const stream = await navigator.mediaDevices.getUserMedia({
10109
+ const stream = await this.webRTCApiProvider.mediaDevices.getUserMedia({
10101
10110
  audio: deviceInfo.kind === "audioinput" ? constraints : false,
10102
10111
  video: deviceInfo.kind === "videoinput" ? constraints : false
10103
10112
  });
@@ -10269,9 +10278,23 @@ var DependencyContainer = class {
10269
10278
  this._webSocketConstructor = WebSocketConstructor;
10270
10279
  }
10271
10280
  get deviceController() {
10272
- this._deviceController ??= new NavigatorDeviceController();
10281
+ this._deviceController ??= new NavigatorDeviceController(this.webRTCApiProvider);
10273
10282
  return this._deviceController;
10274
10283
  }
10284
+ get webRTCApiProvider() {
10285
+ if (!this._webRTCApiProvider) {
10286
+ if (typeof RTCPeerConnection === "undefined" || typeof navigator === "undefined") throw new DependencyError("WebRTCApiProvider: RTCPeerConnection or navigator.mediaDevices is not available. Please provide a custom webRTCApiProvider in SignalWireOptions.");
10287
+ this._webRTCApiProvider = {
10288
+ RTCPeerConnection,
10289
+ mediaDevices: navigator.mediaDevices
10290
+ };
10291
+ }
10292
+ return this._webRTCApiProvider;
10293
+ }
10294
+ set webRTCApiProvider(webRTCApiProvider) {
10295
+ this._webRTCApiProvider = webRTCApiProvider;
10296
+ this._deviceController = void 0;
10297
+ }
10275
10298
  get authorizationStateKey() {
10276
10299
  return `sw:${this.subscriberId}:as`;
10277
10300
  }
@@ -11662,7 +11685,7 @@ var SelfCapabilities = class extends Destroyable {
11662
11685
  }
11663
11686
  /** Observable for self member capabilities */
11664
11687
  get self$() {
11665
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.self), (0, import_cjs$17.distinctUntilChanged)());
11688
+ return this.cachedObservable("self$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.self), (0, import_cjs$17.distinctUntilChanged)()));
11666
11689
  }
11667
11690
  /** Current self member capabilities */
11668
11691
  get self() {
@@ -11670,7 +11693,7 @@ var SelfCapabilities = class extends Destroyable {
11670
11693
  }
11671
11694
  /** Observable for other member capabilities */
11672
11695
  get member$() {
11673
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.member), (0, import_cjs$17.distinctUntilChanged)());
11696
+ return this.cachedObservable("member$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.member), (0, import_cjs$17.distinctUntilChanged)()));
11674
11697
  }
11675
11698
  /** Current other member capabilities */
11676
11699
  get member() {
@@ -11678,7 +11701,7 @@ var SelfCapabilities = class extends Destroyable {
11678
11701
  }
11679
11702
  /** Observable for end call capability */
11680
11703
  get end$() {
11681
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.end), (0, import_cjs$17.distinctUntilChanged)());
11704
+ return this.cachedObservable("end$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.end), (0, import_cjs$17.distinctUntilChanged)()));
11682
11705
  }
11683
11706
  /** Current end call capability */
11684
11707
  get end() {
@@ -11686,7 +11709,7 @@ var SelfCapabilities = class extends Destroyable {
11686
11709
  }
11687
11710
  /** Observable for set layout capability */
11688
11711
  get setLayout$() {
11689
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.setLayout), (0, import_cjs$17.distinctUntilChanged)());
11712
+ return this.cachedObservable("setLayout$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.setLayout), (0, import_cjs$17.distinctUntilChanged)()));
11690
11713
  }
11691
11714
  /** Current set layout capability */
11692
11715
  get setLayout() {
@@ -11694,7 +11717,7 @@ var SelfCapabilities = class extends Destroyable {
11694
11717
  }
11695
11718
  /** Observable for send digit capability */
11696
11719
  get sendDigit$() {
11697
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.sendDigit), (0, import_cjs$17.distinctUntilChanged)());
11720
+ return this.cachedObservable("sendDigit$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.sendDigit), (0, import_cjs$17.distinctUntilChanged)()));
11698
11721
  }
11699
11722
  /** Current send digit capability */
11700
11723
  get sendDigit() {
@@ -11702,7 +11725,7 @@ var SelfCapabilities = class extends Destroyable {
11702
11725
  }
11703
11726
  /** Observable for vmuted hide capability */
11704
11727
  get vmutedHide$() {
11705
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.vmutedHide), (0, import_cjs$17.distinctUntilChanged)());
11728
+ return this.cachedObservable("vmutedHide$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.vmutedHide), (0, import_cjs$17.distinctUntilChanged)()));
11706
11729
  }
11707
11730
  /** Current vmuted hide capability */
11708
11731
  get vmutedHide() {
@@ -11710,7 +11733,7 @@ var SelfCapabilities = class extends Destroyable {
11710
11733
  }
11711
11734
  /** Observable for lock capability */
11712
11735
  get lock$() {
11713
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.lock), (0, import_cjs$17.distinctUntilChanged)());
11736
+ return this.cachedObservable("lock$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.lock), (0, import_cjs$17.distinctUntilChanged)()));
11714
11737
  }
11715
11738
  /** Current lock capability */
11716
11739
  get lock() {
@@ -11718,7 +11741,7 @@ var SelfCapabilities = class extends Destroyable {
11718
11741
  }
11719
11742
  /** Observable for device capability */
11720
11743
  get device$() {
11721
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.device), (0, import_cjs$17.distinctUntilChanged)());
11744
+ return this.cachedObservable("device$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.device), (0, import_cjs$17.distinctUntilChanged)()));
11722
11745
  }
11723
11746
  /** Current device capability */
11724
11747
  get device() {
@@ -11726,7 +11749,7 @@ var SelfCapabilities = class extends Destroyable {
11726
11749
  }
11727
11750
  /** Observable for screenshare capability */
11728
11751
  get screenshare$() {
11729
- return this._state$.pipe((0, import_cjs$17.map)((state) => state.screenshare), (0, import_cjs$17.distinctUntilChanged)());
11752
+ return this.cachedObservable("screenshare$", () => this._state$.pipe((0, import_cjs$17.map)((state) => state.screenshare), (0, import_cjs$17.distinctUntilChanged)()));
11730
11753
  }
11731
11754
  /** Current screenshare capability */
11732
11755
  get screenshare() {
@@ -11779,83 +11802,83 @@ var Participant = class extends Destroyable {
11779
11802
  }
11780
11803
  /** Observable of the participant's display name. */
11781
11804
  get name$() {
11782
- return this._state$.pipe((0, import_operators$1.map)((state) => state.name), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11805
+ return this.cachedObservable("name$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.name), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11783
11806
  }
11784
11807
  /** Observable of the participant type (e.g. `'member'`, `'screen'`). */
11785
11808
  get type$() {
11786
- return this._state$.pipe((0, import_operators$1.map)((state) => state.type), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11809
+ return this.cachedObservable("type$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.type), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11787
11810
  }
11788
11811
  /** Observable indicating whether the participant has raised their hand. */
11789
11812
  get handraised$() {
11790
- return this._state$.pipe((0, import_operators$1.map)((state) => state.handraised), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11813
+ return this.cachedObservable("handraised$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.handraised), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11791
11814
  }
11792
11815
  /** Observable indicating whether the participant is visible in the layout. */
11793
11816
  get visible$() {
11794
- return this._state$.pipe((0, import_operators$1.map)((state) => state.visible), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11817
+ return this.cachedObservable("visible$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.visible), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11795
11818
  }
11796
11819
  /** Observable indicating whether the participant's audio is muted. */
11797
11820
  get audioMuted$() {
11798
- return this._state$.pipe((0, import_operators$1.map)((state) => state.audio_muted), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11821
+ return this.cachedObservable("audioMuted$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.audio_muted), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11799
11822
  }
11800
11823
  /** Observable indicating whether the participant's video is muted. */
11801
11824
  get videoMuted$() {
11802
- return this._state$.pipe((0, import_operators$1.map)((state) => state.video_muted), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11825
+ return this.cachedObservable("videoMuted$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.video_muted), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11803
11826
  }
11804
11827
  /** Observable indicating whether the participant is deafened. */
11805
11828
  get deaf$() {
11806
- return this._state$.pipe((0, import_operators$1.map)((state) => state.deaf), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11829
+ return this.cachedObservable("deaf$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.deaf), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11807
11830
  }
11808
11831
  /** Observable of the participant's microphone input volume. */
11809
11832
  get inputVolume$() {
11810
- return this._state$.pipe((0, import_operators$1.map)((state) => state.input_volume), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11833
+ return this.cachedObservable("inputVolume$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.input_volume), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11811
11834
  }
11812
11835
  /** Observable of the participant's speaker output volume. */
11813
11836
  get outputVolume$() {
11814
- return this._state$.pipe((0, import_operators$1.map)((state) => state.output_volume), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11837
+ return this.cachedObservable("outputVolume$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.output_volume), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11815
11838
  }
11816
11839
  /** Observable of the microphone input sensitivity level. */
11817
11840
  get inputSensitivity$() {
11818
- return this._state$.pipe((0, import_operators$1.map)((state) => state.input_sensitivity), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11841
+ return this.cachedObservable("inputSensitivity$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.input_sensitivity), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11819
11842
  }
11820
11843
  /** Observable indicating whether echo cancellation is enabled. */
11821
11844
  get echoCancellation$() {
11822
- return this._state$.pipe((0, import_operators$1.map)((state) => state.echo_cancellation), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11845
+ return this.cachedObservable("echoCancellation$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.echo_cancellation), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11823
11846
  }
11824
11847
  /** Observable indicating whether auto-gain control is enabled. */
11825
11848
  get autoGain$() {
11826
- return this._state$.pipe((0, import_operators$1.map)((state) => state.auto_gain), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11849
+ return this.cachedObservable("autoGain$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.auto_gain), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11827
11850
  }
11828
11851
  /** Observable indicating whether noise suppression is enabled. */
11829
11852
  get noiseSuppression$() {
11830
- return this._state$.pipe((0, import_operators$1.map)((state) => state.noise_suppression), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11853
+ return this.cachedObservable("noiseSuppression$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.noise_suppression), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11831
11854
  }
11832
11855
  /** Observable indicating whether low-bitrate mode is active. */
11833
11856
  get lowbitrate$() {
11834
- return this._state$.pipe((0, import_operators$1.map)((state) => state.lowbitrate), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11857
+ return this.cachedObservable("lowbitrate$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.lowbitrate), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11835
11858
  }
11836
11859
  /** Observable indicating whether noise reduction is active. */
11837
11860
  get denoise$() {
11838
- return this._state$.pipe((0, import_operators$1.map)((state) => state.denoise), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11861
+ return this.cachedObservable("denoise$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.denoise), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11839
11862
  }
11840
11863
  /** Observable of custom metadata for this participant. */
11841
11864
  get meta$() {
11842
- return this._state$.pipe((0, import_operators$1.map)((state) => state.meta), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11865
+ return this.cachedObservable("meta$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.meta), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11843
11866
  }
11844
11867
  /** Observable of the participant's subscriber ID. */
11845
11868
  get subscriberId$() {
11846
- return this._state$.pipe((0, import_operators$1.map)((state) => state.subscriber_id), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11869
+ return this.cachedObservable("subscriberId$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.subscriber_id), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11847
11870
  }
11848
11871
  /** Observable of the participant's address ID. */
11849
11872
  get addressId$() {
11850
- return this._state$.pipe((0, import_operators$1.map)((state) => state.address_id), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11873
+ return this.cachedObservable("addressId$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.address_id), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11851
11874
  }
11852
11875
  /** Observable of the server node ID for this participant. */
11853
11876
  get nodeId$() {
11854
- return this._state$.pipe((0, import_operators$1.map)((state) => state.node_id), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11877
+ return this.cachedObservable("nodeId$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.node_id), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11855
11878
  }
11856
11879
  /** Observable indicating whether the participant is currently speaking. */
11857
11880
  get isTalking$() {
11858
- return this._state$.pipe((0, import_operators$1.map)((state) => state.talking), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11881
+ return this.cachedObservable("isTalking$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.talking), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11859
11882
  }
11860
11883
  /** Whether the participant is currently speaking. */
11861
11884
  get isTalking() {
@@ -11863,7 +11886,7 @@ var Participant = class extends Destroyable {
11863
11886
  }
11864
11887
  /** Observable of the participant's layout position. */
11865
11888
  get position$() {
11866
- return this._state$.pipe((0, import_operators$1.map)((state) => state.position), (0, import_operators$1.distinctUntilChanged)(), filterNull());
11889
+ return this.cachedObservable("position$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.position), (0, import_operators$1.distinctUntilChanged)(), filterNull()));
11867
11890
  }
11868
11891
  /** Current layout position. */
11869
11892
  get position() {
@@ -12182,7 +12205,7 @@ function isJSONRPCRequest(value) {
12182
12205
  return isObject(value) && hasProperty(value, "jsonrpc") && value.jsonrpc === "2.0" && hasProperty(value, "id") && typeof value.id === "string" && hasProperty(value, "method") && typeof value.method === "string";
12183
12206
  }
12184
12207
  function isJSONRPCResponse(value) {
12185
- return isObject(value) && hasProperty(value, "jsonrpc") && value.jsonrpc === "2.0" && hasProperty(value, "id") && typeof value.id === "string" && hasProperty(value, "result");
12208
+ return isObject(value) && hasProperty(value, "jsonrpc") && value.jsonrpc === "2.0" && hasProperty(value, "id") && typeof value.id === "string" && (hasProperty(value, "result") || hasProperty(value, "error"));
12186
12209
  }
12187
12210
 
12188
12211
  //#endregion
@@ -12380,10 +12403,10 @@ var CallEventsManager = class extends Destroyable {
12380
12403
  this.initSubscriptions();
12381
12404
  }
12382
12405
  get participants$() {
12383
- return this._participants$.asObservable().pipe((0, import_cjs$14.map)((participantsRecord) => Object.values(participantsRecord)));
12406
+ return this.cachedObservable("participants$", () => this._participants$.asObservable().pipe((0, import_cjs$14.map)((participantsRecord) => Object.values(participantsRecord))));
12384
12407
  }
12385
12408
  get self$() {
12386
- return this._self$.asObservable().pipe(filterNull());
12409
+ return this.cachedObservable("self$", () => this._self$.asObservable().pipe(filterNull()));
12387
12410
  }
12388
12411
  get status$() {
12389
12412
  return this._status$.asObservable();
@@ -12401,40 +12424,40 @@ var CallEventsManager = class extends Destroyable {
12401
12424
  return this.callIds.has(callId);
12402
12425
  }
12403
12426
  get recording$() {
12404
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.recording), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12427
+ return this.cachedObservable("recording$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.recording), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12405
12428
  }
12406
12429
  get recordings$() {
12407
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.recordings), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12430
+ return this.cachedObservable("recordings$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.recordings), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12408
12431
  }
12409
12432
  get streaming$() {
12410
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.streaming), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12433
+ return this.cachedObservable("streaming$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.streaming), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12411
12434
  }
12412
12435
  get streams$() {
12413
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.streams), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12436
+ return this.cachedObservable("streams$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.streams), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12414
12437
  }
12415
12438
  get playbacks$() {
12416
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.playbacks), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12439
+ return this.cachedObservable("playbacks$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.playbacks), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12417
12440
  }
12418
12441
  get raiseHandPriority$() {
12419
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.prioritize_handraise), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12442
+ return this.cachedObservable("raiseHandPriority$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.prioritize_handraise), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12420
12443
  }
12421
12444
  get locked$() {
12422
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.locked), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12445
+ return this.cachedObservable("locked$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.locked), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12423
12446
  }
12424
12447
  get meta$() {
12425
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.meta), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12448
+ return this.cachedObservable("meta$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.meta), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12426
12449
  }
12427
12450
  get capabilities$() {
12428
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.capabilities), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12451
+ return this.cachedObservable("capabilities$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.capabilities), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12429
12452
  }
12430
12453
  get layout$() {
12431
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.layout_name), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12454
+ return this.cachedObservable("layout$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.layout_name), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12432
12455
  }
12433
12456
  get layouts$() {
12434
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.layouts), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12457
+ return this.cachedObservable("layouts$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.layouts), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12435
12458
  }
12436
12459
  get layoutLayers$() {
12437
- return this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.layout_layers), (0, import_cjs$14.distinctUntilChanged)(), filterNull());
12460
+ return this.cachedObservable("layoutLayers$", () => this._sessionState$.pipe((0, import_cjs$14.map)((state) => state.layout_layers), (0, import_cjs$14.distinctUntilChanged)(), filterNull()));
12438
12461
  }
12439
12462
  get self() {
12440
12463
  return this._self$.value;
@@ -12570,19 +12593,19 @@ var CallEventsManager = class extends Destroyable {
12570
12593
  this._participants$.next(this._participants$.value);
12571
12594
  }
12572
12595
  get callJoinedEvent$() {
12573
- return this.webRtcCallSession.callEvent$.pipe((0, import_cjs$14.filter)(isCallJoinedPayload), (0, import_cjs$14.tap)((event) => {
12596
+ return this.cachedObservable("callJoinedEvent$", () => this.webRtcCallSession.callEvent$.pipe((0, import_cjs$14.filter)(isCallJoinedPayload), (0, import_cjs$14.tap)((event) => {
12574
12597
  logger$15.debug("[CallEventsManager] Call joined event:", event);
12575
- }));
12598
+ })));
12576
12599
  }
12577
12600
  get layoutChangedEvent$() {
12578
- return this.webRtcCallSession.callEvent$.pipe(filterAs(isLayoutChangedPayload, "layout"), (0, import_cjs$14.tap)((event) => {
12601
+ return this.cachedObservable("layoutChangedEvent$", () => this.webRtcCallSession.callEvent$.pipe(filterAs(isLayoutChangedPayload, "layout"), (0, import_cjs$14.tap)((event) => {
12579
12602
  logger$15.debug("[CallEventsManager] Layout changed event:", event);
12580
- }));
12603
+ })));
12581
12604
  }
12582
12605
  get memberUpdates$() {
12583
- return (0, import_cjs$14.merge)(this.webRtcCallSession.memberJoined$, this.webRtcCallSession.memberUpdated$, this.webRtcCallSession.memberTalking$).pipe((0, import_cjs$14.map)((event) => event.member), (0, import_cjs$14.tap)((event) => {
12606
+ return this.cachedObservable("memberUpdates$", () => (0, import_cjs$14.merge)(this.webRtcCallSession.memberJoined$, this.webRtcCallSession.memberUpdated$, this.webRtcCallSession.memberTalking$).pipe((0, import_cjs$14.map)((event) => event.member), (0, import_cjs$14.tap)((event) => {
12584
12607
  logger$15.debug("[CallEventsManager] Member update event:", event);
12585
- }));
12608
+ })));
12586
12609
  }
12587
12610
  destroy() {
12588
12611
  Object.values(this._participants$.value).forEach((participant) => {
@@ -13224,7 +13247,7 @@ var RTCPeerConnectionController = class extends Destroyable {
13224
13247
  logger$11.debug(`[RTCPeerConnectionController] ${kind} input device selected: none`);
13225
13248
  return;
13226
13249
  }
13227
- const streamTrack = (await navigator.mediaDevices.getUserMedia({ [kind]: {
13250
+ const streamTrack = (await this.getUserMedia({ [kind]: {
13228
13251
  ...track.getConstraints(),
13229
13252
  ...this.deviceController.deviceInfoToConstraints(deviceInfo)
13230
13253
  } })).getTracks().find((t) => t.kind === kind);
@@ -13313,43 +13336,43 @@ var RTCPeerConnectionController = class extends Destroyable {
13313
13336
  };
13314
13337
  }
13315
13338
  get iceGatheringState$() {
13316
- return this._iceGatheringState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13339
+ return this.cachedObservable("iceGatheringState$", () => this._iceGatheringState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13317
13340
  }
13318
13341
  get mediaTrackEnded$() {
13319
- return this.localStreamController.mediaTrackEnded$.pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13342
+ return this.cachedObservable("mediaTrackEnded$", () => this.localStreamController.mediaTrackEnded$.pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13320
13343
  }
13321
13344
  get errors$() {
13322
- return this._errors$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13345
+ return this.cachedObservable("errors$", () => this._errors$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13323
13346
  }
13324
13347
  get iceCandidates$() {
13325
- return this._iceCandidates$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13348
+ return this.cachedObservable("iceCandidates$", () => this._iceCandidates$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13326
13349
  }
13327
13350
  get initialized$() {
13328
- return this._initialized$.asObservable().pipe((0, import_cjs$11.filter)((initialized) => initialized), (0, import_cjs$11.takeUntil)(this.destroyed$));
13351
+ return this.cachedObservable("initialized$", () => this._initialized$.asObservable().pipe((0, import_cjs$11.filter)((initialized) => initialized), (0, import_cjs$11.takeUntil)(this.destroyed$)));
13329
13352
  }
13330
13353
  get remoteDescription$() {
13331
- return this._remoteDescription$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13354
+ return this.cachedObservable("remoteDescription$", () => this._remoteDescription$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13332
13355
  }
13333
13356
  get localStream$() {
13334
- return this.localStreamController.localStream$.pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13357
+ return this.cachedObservable("localStream$", () => this.localStreamController.localStream$.pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13335
13358
  }
13336
13359
  get remoteStream$() {
13337
- return this._remoteStream$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13360
+ return this.cachedObservable("remoteStream$", () => this._remoteStream$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13338
13361
  }
13339
13362
  get localAudioTracks$() {
13340
- return this.localStreamController.localAudioTracks$.pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13363
+ return this.cachedObservable("localAudioTracks$", () => this.localStreamController.localAudioTracks$.pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13341
13364
  }
13342
13365
  get localVideoTracks$() {
13343
- return this.localStreamController.localVideoTracks$.pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13366
+ return this.cachedObservable("localVideoTracks$", () => this.localStreamController.localVideoTracks$.pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13344
13367
  }
13345
13368
  get iceConnectionState$() {
13346
- return this._iceConnectionState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13369
+ return this.cachedObservable("iceConnectionState$", () => this._iceConnectionState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13347
13370
  }
13348
13371
  get connectionState$() {
13349
- return this._connectionState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13372
+ return this.cachedObservable("connectionState$", () => this._connectionState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13350
13373
  }
13351
13374
  get signalingState$() {
13352
- return this._signalingState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$));
13375
+ return this.cachedObservable("signalingState$", () => this._signalingState$.asObservable().pipe((0, import_cjs$11.takeUntil)(this.destroyed$)));
13353
13376
  }
13354
13377
  get type() {
13355
13378
  return this._type;
@@ -13415,7 +13438,7 @@ var RTCPeerConnectionController = class extends Destroyable {
13415
13438
  };
13416
13439
  }
13417
13440
  get WebRTCPeerConnectionConstructor() {
13418
- return this.options.WebRTCPeerConnectionConstructor ?? RTCPeerConnection;
13441
+ return this.options.webRTCApiProvider?.RTCPeerConnection ?? RTCPeerConnection;
13419
13442
  }
13420
13443
  get offerOptions() {
13421
13444
  const options = { iceRestart: this.firstSDPExchangeCompleted ? true : void 0 };
@@ -13682,10 +13705,12 @@ var RTCPeerConnectionController = class extends Destroyable {
13682
13705
  }
13683
13706
  }
13684
13707
  async getUserMedia(constraints) {
13685
- return this.options.getUserMedia?.(constraints) ?? navigator.mediaDevices.getUserMedia(constraints);
13708
+ return (this.options.webRTCApiProvider?.mediaDevices ?? navigator.mediaDevices).getUserMedia(constraints);
13686
13709
  }
13687
13710
  async getDisplayMedia(options) {
13688
- return this.options.getDisplayMedia?.(options) ?? navigator.mediaDevices.getDisplayMedia(options);
13711
+ const mediaDevices = this.options.webRTCApiProvider?.mediaDevices ?? navigator.mediaDevices;
13712
+ if (!mediaDevices.getDisplayMedia) throw new DependencyError("getDisplayMedia is not supported by the current WebRTC provider");
13713
+ return mediaDevices.getDisplayMedia(options);
13689
13714
  }
13690
13715
  async setupRemoteTracks() {
13691
13716
  if (!this.peerConnection) throw new DependencyError("RTCPeerConnection is not initialized");
@@ -13850,11 +13875,12 @@ var VertoManager = class extends Destroyable {
13850
13875
  }
13851
13876
  };
13852
13877
  var WebRTCVertoManager = class extends VertoManager {
13853
- constructor(webRtcCallSession, attachManager, deviceController, options = {}) {
13878
+ constructor(webRtcCallSession, attachManager, deviceController, webRTCApiProvider, options = {}) {
13854
13879
  super(webRtcCallSession);
13855
13880
  this.webRtcCallSession = webRtcCallSession;
13856
13881
  this.attachManager = attachManager;
13857
13882
  this.deviceController = deviceController;
13883
+ this.webRTCApiProvider = webRTCApiProvider;
13858
13884
  this._rtcPeerConnections$ = this.createBehaviorSubject([]);
13859
13885
  this._selfId$ = this.createBehaviorSubject(null);
13860
13886
  this._signalingStatus$ = this.createBehaviorSubject(null);
@@ -13928,11 +13954,11 @@ var WebRTCVertoManager = class extends VertoManager {
13928
13954
  return rtcPeerConnection;
13929
13955
  }
13930
13956
  get signalingStatus$() {
13931
- return (0, import_cjs$10.merge)(this._signalingStatus$.pipe(filterNull()), this.mainPeerConnection.connectionState$.pipe((0, import_cjs$10.filter)((connectionState) => [
13957
+ return this.cachedObservable("signalingStatus$", () => (0, import_cjs$10.merge)(this._signalingStatus$.pipe(filterNull()), this.mainPeerConnection.connectionState$.pipe((0, import_cjs$10.filter)((connectionState) => [
13932
13958
  "connected",
13933
13959
  "disconnected",
13934
13960
  "failed"
13935
- ].includes(connectionState))));
13961
+ ].includes(connectionState)))));
13936
13962
  }
13937
13963
  initSubscriptions() {
13938
13964
  this.subscribeTo(this.vertoAnswer$, (event) => {
@@ -13980,19 +14006,19 @@ var WebRTCVertoManager = class extends VertoManager {
13980
14006
  return this._selfId$.value;
13981
14007
  }
13982
14008
  get vertoAnswer$() {
13983
- return this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoAnswerInnerParams, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$));
14009
+ return this.cachedObservable("vertoAnswer$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoAnswerInnerParams, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
13984
14010
  }
13985
14011
  get vertoMediaParams$() {
13986
- return this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoMediaParamsInnerParams, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$));
14012
+ return this.cachedObservable("vertoMediaParams$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoMediaParamsInnerParams, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
13987
14013
  }
13988
14014
  get vertoBye$() {
13989
- return this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoByeMessage, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$));
14015
+ return this.cachedObservable("vertoBye$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoByeMessage, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
13990
14016
  }
13991
14017
  get vertoAttach$() {
13992
- return this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoAttachMessage, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$));
14018
+ return this.cachedObservable("vertoAttach$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoAttachMessage, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
13993
14019
  }
13994
14020
  get vertoPing$() {
13995
- return this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoPingInnerParams, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$));
14021
+ return this.cachedObservable("vertoPing$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoPingInnerParams, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
13996
14022
  }
13997
14023
  async executeVerto(message, optionals = {}) {
13998
14024
  const webrtcVertoMessage = WebrtcVerto({
@@ -14017,7 +14043,7 @@ var WebRTCVertoManager = class extends VertoManager {
14017
14043
  }
14018
14044
  async sendLocalDescription(message, rtcPeerConnController) {
14019
14045
  const vertoMethod = message.method;
14020
- const optionalsParams = this.getSendLocalSDPOptionalParams(rtcPeerConnController);
14046
+ const optionalsParams = this.getSendLocalSDPOptionalParams(rtcPeerConnController, vertoMethod);
14021
14047
  try {
14022
14048
  const response = await this.executeVerto(message, optionalsParams);
14023
14049
  switch (vertoMethod) {
@@ -14094,6 +14120,7 @@ var WebRTCVertoManager = class extends VertoManager {
14094
14120
  inputVideoStream: options.inputVideoStream,
14095
14121
  receiveAudio: options.receiveAudio,
14096
14122
  receiveVideo: options.receiveVideo,
14123
+ webRTCApiProvider: this.webRTCApiProvider,
14097
14124
  ...this.RTCPeerConnectionConfig
14098
14125
  }, options.initOffer, this.deviceController);
14099
14126
  this.setupLocalDescriptionHandler(rtcPeerConnController);
@@ -14160,18 +14187,18 @@ var WebRTCVertoManager = class extends VertoManager {
14160
14187
  this.callSession?.destroy();
14161
14188
  });
14162
14189
  }
14163
- getSendLocalSDPOptionalParams(rtcPeerConnController) {
14190
+ getSendLocalSDPOptionalParams(rtcPeerConnController, vertoMethod) {
14164
14191
  let subscribe = void 0;
14165
- const initial = !rtcPeerConnController.firstSDPExchangeCompleted;
14166
- if (initial) {
14192
+ if (!rtcPeerConnController.firstSDPExchangeCompleted) {
14167
14193
  subscribe = [];
14168
14194
  if (rtcPeerConnController.isMainDevice) subscribe.push(...PreferencesContainer.instance.inviteSubscribeMainDevice);
14169
14195
  else if (rtcPeerConnController.isAdditionalDevice) subscribe.push(...PreferencesContainer.instance.inviteSubscribeAdditionalDevice);
14170
14196
  else if (rtcPeerConnController.isScreenShare) subscribe.push(...PreferencesContainer.instance.inviteSubscribeScreenshare);
14171
14197
  }
14198
+ const isInvite = vertoMethod === "verto.invite";
14172
14199
  return {
14173
14200
  callID: rtcPeerConnController.id,
14174
- node_id: initial ? "" : this._nodeId$.value ?? "",
14201
+ node_id: isInvite ? "" : this._nodeId$.value ?? "",
14175
14202
  subscribe
14176
14203
  };
14177
14204
  }
@@ -14272,7 +14299,8 @@ var WebRTCVertoManager = class extends VertoManager {
14272
14299
  rtcPeerConnController = new RTCPeerConnectionController({
14273
14300
  ...options,
14274
14301
  ...this.RTCPeerConnectionConfig,
14275
- propose
14302
+ propose,
14303
+ webRTCApiProvider: this.webRTCApiProvider
14276
14304
  }, void 0, this.deviceController);
14277
14305
  this.setupLocalDescriptionHandler(rtcPeerConnController);
14278
14306
  if (propose === "screenshare") this._screenShareId = rtcPeerConnController.id;
@@ -14554,7 +14582,7 @@ var WebRTCCall = class extends Destroyable {
14554
14582
  }
14555
14583
  /** Observable of the current call status (e.g. `'ringing'`, `'connected'`). */
14556
14584
  get status$() {
14557
- return (0, import_cjs$9.merge)(this._status$.asObservable(), this.vertoManager.signalingStatus$);
14585
+ return this.cachedObservable("status$", () => (0, import_cjs$9.merge)(this._status$.asObservable(), this.vertoManager.signalingStatus$));
14558
14586
  }
14559
14587
  /** Observable of the participants list, emits on join/leave/update. */
14560
14588
  get participants$() {
@@ -14658,7 +14686,7 @@ var WebRTCCall = class extends Destroyable {
14658
14686
  return this.vertoManager.mediaDirections;
14659
14687
  }
14660
14688
  get participantsId$() {
14661
- return this.participants$.pipe((0, import_cjs$9.map)((participants) => participants.map((participant) => participant.id)));
14689
+ return this.cachedObservable("participantsId$", () => this.participants$.pipe((0, import_cjs$9.map)((participants) => participants.map((participant) => participant.id))));
14662
14690
  }
14663
14691
  /** Executes a raw JSON-RPC request on the client session. */
14664
14692
  async execute(request, options) {
@@ -14693,35 +14721,35 @@ var WebRTCCall = class extends Destroyable {
14693
14721
  }
14694
14722
  }
14695
14723
  get callSessionEvents$() {
14696
- return this.clientSession.signalingEvent$.pipe((0, import_cjs$9.filter)((event) => this.isCallSessionEvent(event)), (0, import_cjs$9.tap)((event) => logger$9.debug("[Call] Received call session event:", event)), (0, import_cjs$9.takeUntil)(this.destroyed$));
14724
+ return this.cachedObservable("callSessionEvents$", () => this.clientSession.signalingEvent$.pipe((0, import_cjs$9.filter)((event) => this.isCallSessionEvent(event)), (0, import_cjs$9.tap)((event) => logger$9.debug("[Call] Received call session event:", event)), (0, import_cjs$9.takeUntil)(this.destroyed$), (0, import_cjs$9.share)()));
14697
14725
  }
14698
14726
  /** Observable of call-updated events. */
14699
14727
  get callUpdated$() {
14700
- return this.callSessionEvents$.pipe(filterAs(isCallUpdatedMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$));
14728
+ return this.cachedObservable("callUpdated$", () => this.callSessionEvents$.pipe(filterAs(isCallUpdatedMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$)));
14701
14729
  }
14702
14730
  /** Observable of member-joined events. */
14703
14731
  get memberJoined$() {
14704
- return this.callSessionEvents$.pipe(filterAs(isMemberJoinedMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$));
14732
+ return this.cachedObservable("memberJoined$", () => this.callSessionEvents$.pipe(filterAs(isMemberJoinedMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$)));
14705
14733
  }
14706
14734
  /** Observable of member-left events. */
14707
14735
  get memberLeft$() {
14708
- return this.callSessionEvents$.pipe(filterAs(isMemberLeftMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$));
14736
+ return this.cachedObservable("memberLeft$", () => this.callSessionEvents$.pipe(filterAs(isMemberLeftMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$)));
14709
14737
  }
14710
14738
  /** Observable of member-updated events (mute, volume, etc.). */
14711
14739
  get memberUpdated$() {
14712
- return this.callSessionEvents$.pipe(filterAs(isMemberUpdatedMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$));
14740
+ return this.cachedObservable("memberUpdated$", () => this.callSessionEvents$.pipe(filterAs(isMemberUpdatedMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$)));
14713
14741
  }
14714
14742
  /** Observable of member-talking events (speech start/stop). */
14715
14743
  get memberTalking$() {
14716
- return this.callSessionEvents$.pipe(filterAs(isMemberTalkingMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$));
14744
+ return this.cachedObservable("memberTalking$", () => this.callSessionEvents$.pipe(filterAs(isMemberTalkingMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$)));
14717
14745
  }
14718
14746
  /** Observable of call state-change events. */
14719
14747
  get callStates$() {
14720
- return this.callSessionEvents$.pipe(filterAs(isCallStateMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$));
14748
+ return this.cachedObservable("callStates$", () => this.callSessionEvents$.pipe(filterAs(isCallStateMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$)));
14721
14749
  }
14722
14750
  /** Observable of layout-changed events. */
14723
14751
  get layoutUpdates$() {
14724
- return this.callSessionEvents$.pipe(filterAs(isLayoutChangedMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$));
14752
+ return this.cachedObservable("layoutUpdates$", () => this.callSessionEvents$.pipe(filterAs(isLayoutChangedMetadata, "params"), (0, import_cjs$9.takeUntil)(this.destroyed$)));
14725
14753
  }
14726
14754
  /** Underlying `RTCPeerConnection`, for advanced use cases. */
14727
14755
  get rtcPeerConnection() {
@@ -14729,19 +14757,19 @@ var WebRTCCall = class extends Destroyable {
14729
14757
  }
14730
14758
  /** Observable of raw signaling events as plain objects. */
14731
14759
  get signalingEvent$() {
14732
- return this.callEvent$.pipe((0, import_cjs$9.map)((event) => JSON.parse(JSON.stringify(event))));
14760
+ return this.cachedObservable("signalingEvent$", () => this.callEvent$.pipe((0, import_cjs$9.map)((event) => JSON.parse(JSON.stringify(event)))));
14733
14761
  }
14734
14762
  /** Observable of WebRTC-specific signaling messages. */
14735
14763
  get webrtcMessages$() {
14736
- return this.callSessionEvents$.pipe(filterAs(isWebrtcMessageMetadata, "params"), (0, import_cjs$9.tap)((event) => logger$9.debug("[Call] Event is a WebRTC message event:", event)), (0, import_cjs$9.takeUntil)(this.destroyed$));
14764
+ return this.cachedObservable("webrtcMessages$", () => this.callSessionEvents$.pipe(filterAs(isWebrtcMessageMetadata, "params"), (0, import_cjs$9.tap)((event) => logger$9.debug("[Call] Event is a WebRTC message event:", event)), (0, import_cjs$9.takeUntil)(this.destroyed$), (0, import_cjs$9.share)()));
14737
14765
  }
14738
14766
  /** Observable of call-level signaling events. */
14739
14767
  get callEvent$() {
14740
- return this.callSessionEvents$.pipe(filterAs(isSignalwireCallMetadata, "params"), (0, import_cjs$9.tap)((event) => logger$9.debug("[Call] Event is a call event:", event)), (0, import_cjs$9.takeUntil)(this.destroyed$));
14768
+ return this.cachedObservable("callEvent$", () => this.callSessionEvents$.pipe(filterAs(isSignalwireCallMetadata, "params"), (0, import_cjs$9.tap)((event) => logger$9.debug("[Call] Event is a call event:", event)), (0, import_cjs$9.takeUntil)(this.destroyed$), (0, import_cjs$9.share)()));
14741
14769
  }
14742
14770
  /** Observable of layout-changed signaling events. */
14743
14771
  get layoutEvent$() {
14744
- return this.callEvent$.pipe(filterAs(isLayoutChangedMetadata, "params"));
14772
+ return this.cachedObservable("layoutEvent$", () => this.callEvent$.pipe(filterAs(isLayoutChangedMetadata, "params")));
14745
14773
  }
14746
14774
  /** Hangs up the call and releases all resources. */
14747
14775
  async hangup() {
@@ -14802,10 +14830,11 @@ var WebRTCCall = class extends Destroyable {
14802
14830
  * Eliminates circular dependencies by centralizing Call and Manager creation.
14803
14831
  */
14804
14832
  var CallFactory = class {
14805
- constructor(sessionManager, deviceController, attachManager) {
14833
+ constructor(sessionManager, deviceController, attachManager, webRTCApiProvider) {
14806
14834
  this.sessionManager = sessionManager;
14807
14835
  this.deviceController = deviceController;
14808
14836
  this.attachManager = attachManager;
14837
+ this.webRTCApiProvider = webRTCApiProvider;
14809
14838
  }
14810
14839
  /**
14811
14840
  * Create a new WebRTCCall with properly initialized managers
@@ -14814,7 +14843,7 @@ var CallFactory = class {
14814
14843
  return new WebRTCCall(this.sessionManager, options, {
14815
14844
  initializeManagers: (callInstance) => {
14816
14845
  return {
14817
- vertoManager: new WebRTCVertoManager(callInstance, this.attachManager, this.deviceController, {
14846
+ vertoManager: new WebRTCVertoManager(callInstance, this.attachManager, this.deviceController, this.webRTCApiProvider, {
14818
14847
  nodeId: options.nodeId,
14819
14848
  onError: (error) => {
14820
14849
  callInstance.emitError(error);
@@ -14894,7 +14923,7 @@ var EntityCollection = class extends Destroyable {
14894
14923
  return this.fetchController.hasMore ?? true;
14895
14924
  }
14896
14925
  get updated$() {
14897
- return this.loading$.pipe((0, import_cjs$8.distinctUntilChanged)(), (0, import_cjs$8.skip)(1), (0, import_cjs$8.filter)((loading) => !loading), (0, import_cjs$8.map)(() => void 0), (0, import_cjs$8.takeUntil)(this._destroy$));
14926
+ return this.cachedObservable("updated$", () => this.loading$.pipe((0, import_cjs$8.distinctUntilChanged)(), (0, import_cjs$8.skip)(1), (0, import_cjs$8.filter)((loading) => !loading), (0, import_cjs$8.map)(() => void 0), (0, import_cjs$8.takeUntil)(this._destroy$)));
14898
14927
  }
14899
14928
  get values() {
14900
14929
  return Array.from(this.collectionData.values());
@@ -14974,7 +15003,7 @@ var EntityCollectionTransformed = class {
14974
15003
  return this.originalCollection.values.filter(this.filter).map(this.mapper);
14975
15004
  }
14976
15005
  get values$() {
14977
- return this.originalCollection.values$.pipe((0, import_cjs$8.map)((values) => values.filter(this.filter).map(this.mapper)));
15006
+ return this._values$ ??= this.originalCollection.values$.pipe((0, import_cjs$8.map)((values) => values.filter(this.filter).map(this.mapper)));
14978
15007
  }
14979
15008
  get$(id) {
14980
15009
  const original$ = this.originalCollection.get$(id);
@@ -15048,7 +15077,7 @@ var Address = class extends Destroyable {
15048
15077
  }
15049
15078
  /** Observable of the human-readable display name. */
15050
15079
  get displayName$() {
15051
- return this._state$.pipe(filterNull(), (0, import_cjs$7.map)((state) => state.display_name), (0, import_cjs$7.takeUntil)(this.destroyed$));
15080
+ return this.cachedObservable("displayName$", () => this._state$.pipe(filterNull(), (0, import_cjs$7.map)((state) => state.display_name), (0, import_cjs$7.takeUntil)(this.destroyed$)));
15052
15081
  }
15053
15082
  /** Human-readable display name. */
15054
15083
  get displayName() {
@@ -15057,7 +15086,7 @@ var Address = class extends Destroyable {
15057
15086
  }
15058
15087
  /** Observable of the preview image URL. */
15059
15088
  get previewUrl$() {
15060
- return this._state$.pipe(filterNull(), (0, import_cjs$7.map)((state) => state.preview_url), (0, import_cjs$7.takeUntil)(this.destroyed$));
15089
+ return this.cachedObservable("previewUrl$", () => this._state$.pipe(filterNull(), (0, import_cjs$7.map)((state) => state.preview_url), (0, import_cjs$7.takeUntil)(this.destroyed$)));
15061
15090
  }
15062
15091
  /** Preview image URL. */
15063
15092
  get previewUrl() {
@@ -15066,7 +15095,7 @@ var Address = class extends Destroyable {
15066
15095
  }
15067
15096
  /** Observable of the cover image URL. */
15068
15097
  get coverUrl$() {
15069
- return this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.cover_url), (0, import_cjs$7.takeUntil)(this.destroyed$));
15098
+ return this.cachedObservable("coverUrl$", () => this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.cover_url), (0, import_cjs$7.takeUntil)(this.destroyed$)));
15070
15099
  }
15071
15100
  /** Cover image URL. */
15072
15101
  get coverUrl() {
@@ -15075,7 +15104,7 @@ var Address = class extends Destroyable {
15075
15104
  }
15076
15105
  /** Observable of the underlying resource ID. */
15077
15106
  get resourceId$() {
15078
- return this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.resource_id), (0, import_cjs$7.takeUntil)(this.destroyed$));
15107
+ return this.cachedObservable("resourceId$", () => this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.resource_id), (0, import_cjs$7.takeUntil)(this.destroyed$)));
15079
15108
  }
15080
15109
  /** Underlying resource ID. */
15081
15110
  get resourceId() {
@@ -15084,7 +15113,7 @@ var Address = class extends Destroyable {
15084
15113
  }
15085
15114
  /** Observable of the resource type (e.g. `'room'`, `'subscriber'`). */
15086
15115
  get type$() {
15087
- return this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.type), (0, import_cjs$7.takeUntil)(this.destroyed$));
15116
+ return this.cachedObservable("type$", () => this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.type), (0, import_cjs$7.takeUntil)(this.destroyed$)));
15088
15117
  }
15089
15118
  /** Resource type (e.g. `'room'`, `'subscriber'`). */
15090
15119
  get type() {
@@ -15093,7 +15122,7 @@ var Address = class extends Destroyable {
15093
15122
  }
15094
15123
  /** Observable of available communication channels (audio, video, messaging). */
15095
15124
  get channels$() {
15096
- return this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.channels), (0, import_cjs$7.takeUntil)(this.destroyed$));
15125
+ return this.cachedObservable("channels$", () => this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.channels), (0, import_cjs$7.takeUntil)(this.destroyed$)));
15097
15126
  }
15098
15127
  /** Available communication channels. */
15099
15128
  get channels() {
@@ -15107,7 +15136,7 @@ var Address = class extends Destroyable {
15107
15136
  }
15108
15137
  /** Observable indicating whether the address (room) is locked. */
15109
15138
  get locked$() {
15110
- return this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.locked), (0, import_cjs$7.takeUntil)(this.destroyed$));
15139
+ return this.cachedObservable("locked$", () => this._state$.pipe(filterNull(), (0, import_cjs$7.shareReplay)(1), (0, import_cjs$7.map)((state) => state.locked), (0, import_cjs$7.takeUntil)(this.destroyed$)));
15111
15140
  }
15112
15141
  /** Sends a text message to this address. */
15113
15142
  async sendText(text) {
@@ -15230,7 +15259,7 @@ const getAddressSearchURI = (options) => {
15230
15259
  return name;
15231
15260
  };
15232
15261
  var ClientSessionManager = class extends Destroyable {
15233
- constructor(credential, transport, storage, authorizationStateKey, deviceController, attachManager) {
15262
+ constructor(credential, transport, storage, authorizationStateKey, deviceController, attachManager, webRTCApiProvider) {
15234
15263
  super();
15235
15264
  this.credential = credential;
15236
15265
  this.transport = transport;
@@ -15253,11 +15282,11 @@ var ClientSessionManager = class extends Destroyable {
15253
15282
  this._calls$ = this.createBehaviorSubject({});
15254
15283
  this._iceServers$ = this.createBehaviorSubject([]);
15255
15284
  attachManager.setSession(this);
15256
- this.callFactory = new CallFactory(this, deviceController, attachManager);
15285
+ this.callFactory = new CallFactory(this, deviceController, attachManager, webRTCApiProvider);
15257
15286
  this.initialized$ = (0, import_cjs$5.defer)(() => (0, import_cjs$5.from)(this.init())).pipe((0, import_cjs$5.shareReplay)(1), (0, import_cjs$5.takeUntil)(this.destroyed$));
15258
15287
  }
15259
15288
  get incomingCalls$() {
15260
- return this.calls$.pipe((0, import_cjs$5.map)((calls) => calls.filter((call) => call.direction === "inbound")));
15289
+ return this.cachedObservable("incomingCalls$", () => this.calls$.pipe((0, import_cjs$5.map)((calls) => calls.filter((call) => call.direction === "inbound"))));
15261
15290
  }
15262
15291
  get incomingCalls() {
15263
15292
  return Object.values(this._calls$.value).filter((call) => call.direction === "inbound");
@@ -15269,7 +15298,7 @@ var ClientSessionManager = class extends Destroyable {
15269
15298
  return this._subscriberInfo$.value;
15270
15299
  }
15271
15300
  get calls$() {
15272
- return this._calls$.pipe((0, import_cjs$5.map)((calls) => Object.values(calls)));
15301
+ return this.cachedObservable("calls$", () => this._calls$.pipe((0, import_cjs$5.map)((calls) => Object.values(calls))));
15273
15302
  }
15274
15303
  get calls() {
15275
15304
  return Object.values(this._calls$.value);
@@ -15372,20 +15401,20 @@ var ClientSessionManager = class extends Destroyable {
15372
15401
  }
15373
15402
  }
15374
15403
  get authStateEvent$() {
15375
- return this.signalingEvent$.pipe((0, import_cjs$5.tap)((msg) => {
15404
+ return this.cachedObservable("authStateEvent$", () => this.signalingEvent$.pipe((0, import_cjs$5.tap)((msg) => {
15376
15405
  logger$6.debug("[Session] Received incoming message:", msg);
15377
15406
  }), filterAs(isSignalwireAuthorizationStateMetadata, "params"), (0, import_cjs$5.tap)((event) => {
15378
15407
  logger$6.debug("[Session] Authorization state event received:", event.authorization_state);
15379
- }));
15408
+ })));
15380
15409
  }
15381
15410
  get signalingEvent$() {
15382
- return this.transport.incomingEvent$.pipe(filterAs(isSignalwireRequest, "params"));
15411
+ return this.cachedObservable("signalingEvent$", () => this.transport.incomingEvent$.pipe(filterAs(isSignalwireRequest, "params"), (0, import_cjs$5.share)()));
15383
15412
  }
15384
15413
  get vertoInvite$() {
15385
- return this.signalingEvent$.pipe((0, import_cjs$5.filter)(isWebrtcMessageMetadata), (0, import_cjs$5.filter)((event) => isVertoInviteMessage(event.params)), (0, import_cjs$5.map)((event) => ({
15414
+ return this.cachedObservable("vertoInvite$", () => this.signalingEvent$.pipe((0, import_cjs$5.filter)(isWebrtcMessageMetadata), (0, import_cjs$5.filter)((event) => isVertoInviteMessage(event.params)), (0, import_cjs$5.map)((event) => ({
15386
15415
  node_id: event.node_id,
15387
15416
  ...event.params.params
15388
- })));
15417
+ }))));
15389
15418
  }
15390
15419
  get contexts() {
15391
15420
  return [];
@@ -15550,6 +15579,9 @@ var ClientSessionWrapper = class {
15550
15579
  get signalingEvent$() {
15551
15580
  return this.clientSessionManager.signalingEvent$;
15552
15581
  }
15582
+ get iceServers() {
15583
+ return this.clientSessionManager.iceServers;
15584
+ }
15553
15585
  async execute(request, options) {
15554
15586
  return this.clientSessionManager.execute(request, options);
15555
15587
  }
@@ -16142,6 +16174,7 @@ var SignalWire = class extends Destroyable {
16142
16174
  if (this._options.storageImplementation) this._deps.storageImpl = this._options.storageImplementation;
16143
16175
  if (this._options.webSocketConstructor) this._deps.WebSocket = this._options.webSocketConstructor;
16144
16176
  if (this._options.savePreferences) this.preferences.enableSavePreferences(this._deps.storage);
16177
+ if (this._options.webRTCApiProvider) this._deps.webRTCApiProvider = this._options.webRTCApiProvider;
16145
16178
  this._deviceController = this._deps.deviceController;
16146
16179
  if (!this._options.skipDeviceMonitoring) this._deviceController.enableDeviceMonitoring();
16147
16180
  this.subscribeTo(this._deviceController.errors$, (error) => {
@@ -16197,7 +16230,7 @@ var SignalWire = class extends Destroyable {
16197
16230
  async init() {
16198
16231
  this._subscriber$.next(new Subscriber(this._deps.http));
16199
16232
  if (!this._options.skipConnection) await this.connect();
16200
- if (this._options.skipReconnect && this._attachManager) await this._attachManager.flush();
16233
+ if (!this._options.reconnectAttachedCalls && this._attachManager) await this._attachManager.flush();
16201
16234
  if (!this._options.skipRegister) this.register();
16202
16235
  this.handleAttachments();
16203
16236
  }
@@ -16266,7 +16299,7 @@ var SignalWire = class extends Destroyable {
16266
16299
  };
16267
16300
  this._transport = new TransportManager(this._deps.storage, this._deps.protocolKey, this._deps.WebSocket, PreferencesContainer.instance.relayHost ?? this._deps.relayHost, errorHandler);
16268
16301
  this._attachManager = new AttachManager(this._deps.storage, this._deps.deviceController, PreferencesContainer.instance.reconnectCallsTimeout, this._deps.attachedCallsKey);
16269
- this._clientSession = new ClientSessionManager(this._deps.credential, this._transport, this._deps.storage, this._deps.authorizationStateKey, this._deps.deviceController, this._attachManager);
16302
+ this._clientSession = new ClientSessionManager(this._deps.credential, this._transport, this._deps.storage, this._deps.authorizationStateKey, this._deps.deviceController, this._attachManager, this._deps.webRTCApiProvider);
16270
16303
  this._publicSession = new ClientSessionWrapper(this._clientSession);
16271
16304
  this.subscribeTo(this._clientSession.errors$, (error) => {
16272
16305
  this._errors$.next(error);
@@ -16336,7 +16369,7 @@ var SignalWire = class extends Destroyable {
16336
16369
  }
16337
16370
  /** Observable that emits `true` when the client is both connected and authenticated. */
16338
16371
  get ready$() {
16339
- return this._isConnected$.pipe((0, import_cjs.switchMap)((connected) => connected ? this._clientSession.authenticated$ : (0, import_cjs.of)(false)));
16372
+ return this.cachedObservable("ready$", () => this._isConnected$.pipe((0, import_cjs.switchMap)((connected) => connected ? this._clientSession.authenticated$ : (0, import_cjs.of)(false))));
16340
16373
  }
16341
16374
  /** Observable stream of errors from transport, authentication, and devices. */
16342
16375
  get errors$() {
@@ -16632,13 +16665,16 @@ exports.Address = Address;
16632
16665
  exports.CallCreateError = CallCreateError;
16633
16666
  exports.ClientPreferences = ClientPreferences;
16634
16667
  exports.CollectionFetchError = CollectionFetchError;
16668
+ exports.InvalidCredentialsError = InvalidCredentialsError;
16635
16669
  exports.MediaTrackError = MediaTrackError;
16636
16670
  exports.MessageParseError = MessageParseError;
16637
16671
  exports.Participant = Participant;
16672
+ exports.SelfCapabilities = SelfCapabilities;
16638
16673
  exports.SelfParticipant = SelfParticipant;
16639
16674
  exports.SignalWire = SignalWire;
16640
16675
  exports.StaticCredentialProvider = StaticCredentialProvider;
16641
16676
  exports.Subscriber = Subscriber;
16677
+ exports.UnexpectedError = UnexpectedError;
16642
16678
  exports.VertoPongError = VertoPongError;
16643
16679
  exports.WebRTCCall = WebRTCCall;
16644
16680
  exports.embeddableCall = embeddableCall;