@100mslive/hms-video-store 0.2.64 → 0.2.65
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/core/hmsSDKStore/adapter.d.ts +3 -3
- package/dist/hms-video-store.cjs.development.js +21 -7
- package/dist/hms-video-store.cjs.development.js.map +1 -1
- package/dist/hms-video-store.cjs.production.min.js +1 -1
- package/dist/hms-video-store.cjs.production.min.js.map +1 -1
- package/dist/hms-video-store.esm.js +21 -7
- package/dist/hms-video-store.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/core/hmsSDKStore/HMSSDKActions.ts +2 -3
- package/src/core/hmsSDKStore/adapter.ts +16 -12
- package/src/core/hmsSDKStore/sdkUtils/storeMergeUtils.ts +17 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("immer")),r=e(require("zustand/vanilla")),n=e(require("zustand/shallow")),i=require("@100mslive/hms-video"),o=require("reselect"),s=e(require("events"));function a(e,t,r,n,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,i)}function c(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function s(e){a(o,n,i,s,c,"next",e)}function c(e){a(o,n,i,s,c,"throw",e)}s(void 0)}))}}function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function d(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var p,f,h=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",s=n.toStringTag||"@@toStringTag";function a(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{a({},"")}catch(e){a=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var i=Object.create((t&&t.prototype instanceof d?t:d).prototype),o=new b(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var s=r.delegate;if(s){var a=k(s,r);if(a){if(a===l)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,o),i}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var l={};function d(){}function p(){}function f(){}var h={};a(h,i,(function(){return this}));var v=Object.getPrototypeOf,S=v&&v(v(R([])));S&&S!==t&&r.call(S,i)&&(h=S);var y=f.prototype=d.prototype=Object.create(h);function g(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){var n;this._invoke=function(i,o){function s(){return new t((function(n,s){!function n(i,o,s,a){var c=u(e[i],e,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,s,a)}),(function(e){n("throw",e,s,a)})):t.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,a)}))}a(c.arg)}(i,o,n,s)}))}return n=n?n.then(s,s):s()}}function k(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,k(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function b(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function R(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:E}}function E(){return{value:void 0,done:!0}}return p.prototype=f,a(y,"constructor",f),a(f,"constructor",p),p.displayName=a(f,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,a(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},g(m.prototype),a(m.prototype,o,(function(){return this})),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new m(c(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},g(y),a(y,s,"Generator"),a(y,i,(function(){return this})),a(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=R,b.prototype={constructor:b,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var a=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;x(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:R(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(f={exports:{}}),f.exports);(p=exports.HMSRoomState||(exports.HMSRoomState={})).Disconnected="Disconnected",p.Preview="Preview",p.Connecting="Connecting",p.Connected="Connected",p.Reconnecting="Reconnecting",p.Failed="Failed";var v,S,y,g=function(){return{room:{id:"",isConnected:!1,name:"",peers:[],shareableLink:"",localPeer:"",hasWaitingRoom:!1,roomState:exports.HMSRoomState.Disconnected,recording:{browser:{running:!1},server:{running:!1}},rtmp:{running:!1}},peers:{},tracks:{},playlist:{audio:{list:{},selection:{id:"",hasPrevious:!1,hasNext:!1},progress:0,volume:0,currentTime:0},video:{list:{},selection:{id:"",hasPrevious:!1,hasNext:!1},progress:0,volume:0,currentTime:0}},messages:{byID:{},allIDs:[]},speakers:{},settings:{audioInputDeviceId:"",audioOutputDeviceId:"",videoInputDeviceId:""},devices:{audioInput:[],audioOutput:[],videoInput:[]},roles:{},roleChangeRequests:[],errors:[]}};(exports.HMSMessageType||(exports.HMSMessageType={})).CHAT="chat",(v=exports.HMSNotificationSeverity||(exports.HMSNotificationSeverity={})).INFO="info",v.ERROR="error",v.CRITICAL="critical",(S=exports.HMSNotificationTypes||(exports.HMSNotificationTypes={})).PEER_JOINED="PEER_JOINED",S.PEER_LEFT="PEER_LEFT",S.NEW_MESSAGE="NEW_MESSAGE",S.ERROR="ERROR",S.RECONNECTING="RECONNECTING",S.RECONNECTED="RECONNECTED",S.TRACK_ADDED="TRACK_ADDED",S.TRACK_REMOVED="TRACK_REMOVED",S.TRACK_MUTED="TRACK_MUTED",S.TRACK_UNMUTED="TRACK_UNMUTED",S.ROLE_CHANGE_REQUEST="ROLE_CHANGE_REQUEST",S.ROLE_UPDATED="ROLE_UPDATED",S.CHANGE_TRACK_STATE_REQUEST="CHANGE_TRACK_STATE_REQUEST",S.CHANGE_MULTI_TRACK_STATE_REQUEST="CHANGE_MULTI_TRACK_STATE_REQUEST",S.ROOM_ENDED="ROOM_ENDED",S.REMOVED_FROM_ROOM="REMOVED_FROM_ROOM",S.DEVICE_CHANGE_UPDATE="DEVICE_CHANGE_UPDATE",(y=exports.HMSPlaylistType||(exports.HMSPlaylistType={})).audio="audio",y.video="video";var m=function(e,t){return e&&t},k=function(e,t){return e&&!t},T=function(e,t){return!e&&t},x=function(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0},b=function(e,t){for(var r,n=new Set,i=d(e);!(r=i()).done;)n.add(r.value);for(var o,s=d(t);!(o=s()).done;)n.add(o.value);return Array.from(n)};function R(e,t,r,n){e.isLocal&&e.videoTrack&&t.videoTrack&&e.videoTrack!==t.videoTrack&&(n[e.videoTrack]=n[t.videoTrack],delete n[t.videoTrack],r[e.videoTrack]=r[t.videoTrack],r[e.videoTrack].id=e.videoTrack,delete r[t.videoTrack],t.videoTrack=e.videoTrack)}var E=function(){function e(){}return e.convertPeer=function(e){var t,r,n;return{id:e.peerId,name:e.name,roleName:null==(t=e.role)?void 0:t.name,isLocal:e.isLocal,videoTrack:null==(r=e.videoTrack)?void 0:r.trackId,audioTrack:null==(n=e.audioTrack)?void 0:n.trackId,auxiliaryTracks:e.auxiliaryTracks.map((function(e){return e.trackId})),customerUserId:e.customerUserId,customerDescription:e.customerDescription}},e.convertTrack=function(e,t){var r={id:e.trackId,source:e.source,type:e.type,enabled:e.enabled,displayEnabled:e.enabled,peerId:e.peerId||t};return this.enrichTrack(r,e),r},e.enrichTrack=function(t,r){var n=r.getMediaTrackSettings();if("screen"===t.source&&"video"===t.type&&(t.displaySurface=n.displaySurface),t.height=n.height,t.width=n.width,t.deviceID=n.deviceId,r instanceof i.HMSRemoteAudioTrack){var o=r.getVolume()||0;t.volume=o}e.enrichVideoTrack(t,r)},e.enrichVideoTrack=function(e,t){t instanceof i.HMSRemoteVideoTrack&&(e.layer=t.getSimulcastLayer(),e.degraded=t.degraded,x(t.getSimulcastDefinitions(),e.layerDefinitions)||(e.layerDefinitions=t.getSimulcastDefinitions())),(t instanceof i.HMSLocalVideoTrack||t instanceof i.HMSLocalAudioTrack)&&(x(t.getPlugins(),e.plugins)||(e.plugins=t.getPlugins()))},e.convertRoom=function(e){var t,r,n,i,o;return{id:e.id,name:e.name,localPeer:null!=(t=null==(r=e.localPeer)?void 0:r.peerId)?t:"",hasWaitingRoom:e.hasWaitingRoom,shareableLink:e.shareableLink,recording:{browser:{running:!(null==(n=e.recording)||!n.browser.running)},server:{running:!(null==(i=e.recording)||!i.server.running)}},rtmp:{running:!(null==(o=e.rtmp)||!o.running)}}},e.convertMessage=function(e){var t,r,n;return{sender:e.sender.peerId,senderName:e.sender.name,senderRole:null==(t=e.sender.role)?void 0:t.name,senderUserId:e.sender.customerUserId,recipientPeer:null==(r=e.recipientPeer)?void 0:r.peerId,recipientRoles:null==(n=e.recipientRoles)?void 0:n.map((function(e){return e.name})),time:e.time,type:e.type,message:e.message}},e.convertRoles=function(e){var t={};return e&&e.forEach((function(e){t[e.name]=e})),t},e.convertRoleChangeRequest=function(e){return{requestedBy:e.requestedBy.peerId,roleName:e.role.name,token:e.token}},e.convertException=function(e){return{code:e.code,action:e.action,name:e.name,message:e.message,description:e.description,isTerminal:e.isTerminal,nativeError:e.nativeError,timestamp:new Date}},e.convertDeviceChangeUpdate=function(e){var t={devices:e.devices,selection:e.selection,type:e.type};return e.error&&(t.error=this.convertException(e.error)),t},e.convertPlaylist=function(e){return{audio:this.getConvertedPlaylistType(e,exports.HMSPlaylistType.audio),video:this.getConvertedPlaylistType(e,exports.HMSPlaylistType.video)}},e.getConvertedPlaylistType=function(e,t){var r={},n=e.getCurrentSelection(t),i=e.getCurrentProgress(t),o=e.isPlaying(t),s=e.getVolume(t),a=e.getList(t),c=e.getCurrentIndex(t);return e.getList(t).forEach((function(e){var t=e.url===(null==n?void 0:n.url);r[e.id]=u({},e,{type:e.type,selected:t,playing:t&&o})})),{list:r,selection:{id:null==n?void 0:n.id,hasPrevious:c>0,hasNext:c<a.length-1},progress:i,volume:s,currentTime:e.getCurrentTime(t)}},e.convertRecordingRTMPState=function(e,t){var r,n;return{recording:{browser:{running:!(null==e||null==(r=e.browser)||!r.running)},server:{running:!(null==e||null==(n=e.server)||!n.running)}},rtmp:{running:!(null==t||!t.running)}}},e}();function P(e,t,r){void 0===r&&(r=w);var n=void 0,i=void 0;if(t)for(var o,s=d(t.auxiliaryTracks);!(o=s()).done;){var a=e[o.value];r(a)&&(i=M(a)?a:i,n=I(a)?a:n)}return{video:n,audio:i}}function M(e){return e&&"audio"===e.type}function I(e){return e&&"video"===e.type}function w(e){return e&&"screen"===e.source}function D(e){return e&&"videoplaylist"===e.source}function N(e){return Boolean(null==e?void 0:e.degraded)}function O(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].enabled}var L=function(e){return e.room},A=function(e){return e.peers},H=function(e){return e.messages.byID},C=function(e){return e.messages.allIDs},_=function(e){return e.tracks},U=function(e){return e.settings},V=function(e){return e.speakers},K=o.createSelector([L],(function(e){return e&&e.isConnected})),q=o.createSelector(L,(function(e){return e.peers.length})),B=o.createSelector([L,A],(function(e,t){return e.peers.map((function(e){return t[e]}))})),j=o.createSelector(_,(function(e){return Object.values(e)})),F=o.createSelector(L,A,(function(e,t){return t[e.localPeer]})),G=o.createSelector(L,(function(e){return e.localPeer})),J=o.createSelector(F,(function(e){return null==e?void 0:e.audioTrack})),W=o.createSelector(F,(function(e){return null==e?void 0:e.videoTrack})),Q=o.createSelector([J,W,o.createSelector(F,(function(e){return null==e?void 0:e.auxiliaryTracks}))],(function(e,t,r){var n=[].concat(r);return e&&n.unshift(e),t&&n.unshift(t),n})),X=o.createSelector(B,(function(e){return e.filter((function(e){return!e.isLocal}))})),Y=o.createSelector(A,V,(function(e,t){var r=Object.entries(t).sort((function(e,t){var r,n,i=(null==(r=e[1])?void 0:r.audioLevel)||0;return((null==(n=t[1])?void 0:n.audioLevel)||0)>i?1:-1}));if(r.length>0&&r[0][1].audioLevel&&r[0][1].audioLevel>0){var n=r[0][1].peerID;if(n in e)return e[n]}return null})),z=function(e){var t=F(e);return O(e,null==t?void 0:t.videoTrack)},$=function(e){var t=F(e);return function(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].displayEnabled}(e,null==t?void 0:t.videoTrack)},Z=o.createSelector(F,_,(function(e,t){var r=P(t,e);return!(!r.video&&!r.audio)})),ee=o.createSelector(A,_,(function(e,t){var r=void 0;for(var n in e){var i=e[n],o=P(t,i);if(o.video)return i;o.audio&&!r&&(r=i)}return r})),te=o.createSelector(ee,(function(e){return!!e})),re=o.createSelector(A,_,(function(e,t){for(var r in e){var n=e[r],i=P(t,n);if(!i.video&&i.audio)return n}})),ne=o.createSelector(A,_,(function(e,t){var r=[],n=[];for(var i in e){var o=e[i],s=P(t,o),a=s.audio;s.video?r.push(o):a&&n.push(o)}return r.concat(n)})),ie=o.createSelector(A,_,(function(e,t){for(var r in e){var n=e[r];if(P(t,n,D).video)return n}})),oe=o.createSelector(j,(function(e){return e.filter(N)})),se=o.createSelector(C,(function(e){return e.length})),ae=o.createSelector(H,(function(e){return Object.values(e).filter((function(e){return!e.read})).length})),ce=o.createSelector(C,H,(function(e,t){var r=[];return e.forEach((function(e){r.push(t[e])})),r})),ue=o.createSelector([L],(function(e){return e&&e.roomState})),le=o.createSelector(ue,(function(e){return e===exports.HMSRoomState.Preview})),de=o.createSelector(L,(function(e){return e.roomState!==exports.HMSRoomState.Disconnected})),pe=function(e){return e.roles},fe=o.createSelector([pe],(function(e){return Object.keys(e)})),he=o.createSelector([F,pe],(function(e,t){return null!=e&&e.roleName?t[e.roleName]:null})),ve=o.createSelector([he],(function(e){var t;return!(null==e||null==(t=e.subscribeParams)||!t.subscribeToRoles)&&e.subscribeParams.subscribeToRoles.length>0})),Se=o.createSelector(he,(function(e){return null==e?void 0:e.permissions})),ye=o.createSelector(L,(function(e){return e.recording})),ge=o.createSelector(L,(function(e){return e.rtmp})),me=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].list}},ke=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].selection}},Te=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].progress}},xe=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].currentTime}},be=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].volume}},Re=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),o.createSelector(me(e),(function(e){return Object.values(e)}))},Ee=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),o.createSelector(me(e),ke(e),(function(e,t){if(t.id)return e[t.id]}))},Pe={selection:ke(exports.HMSPlaylistType.audio),progress:Te(exports.HMSPlaylistType.audio),currentTime:xe(exports.HMSPlaylistType.audio),volume:be(exports.HMSPlaylistType.audio),list:Re(exports.HMSPlaylistType.audio),selectedItem:Ee(exports.HMSPlaylistType.audio)},Me={selection:ke(exports.HMSPlaylistType.video),progress:Te(exports.HMSPlaylistType.video),currentTime:xe(exports.HMSPlaylistType.audio),volume:be(exports.HMSPlaylistType.video),list:Re(exports.HMSPlaylistType.video),selectedItem:Ee(exports.HMSPlaylistType.video)},Ie="HMS-Store:",we=function(){function e(){}return e.v=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.log.apply(this,[i.HMSLogLevel.VERBOSE,e].concat(r))},e.d=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log.apply(this,[i.HMSLogLevel.DEBUG].concat(t))},e.i=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log.apply(this,[i.HMSLogLevel.INFO].concat(t))},e.w=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log.apply(this,[i.HMSLogLevel.WARN].concat(t))},e.e=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log.apply(this,[i.HMSLogLevel.ERROR].concat(t))},e.log=function(e){if(!(this.level.valueOf()>e.valueOf())){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];switch(e){case i.HMSLogLevel.VERBOSE:var o;(o=console).log.apply(o,[Ie].concat(r));break;case i.HMSLogLevel.DEBUG:var s;(s=console).debug.apply(s,[Ie].concat(r));break;case i.HMSLogLevel.INFO:var a;(a=console).info.apply(a,[Ie].concat(r));break;case i.HMSLogLevel.WARN:var c;(c=console).warn.apply(c,[Ie].concat(r));break;case i.HMSLogLevel.ERROR:var u;(u=console).error.apply(u,[Ie].concat(r))}}},e}();function De(e){return function(t){return function(r){return e(r,t)}}}we.level=i.HMSLogLevel.VERBOSE;var Ne=function(e,t){return t},Oe=function(e,t){return t},Le=o.createSelector([A,Ne],(function(e,t){return t?e[t]:null})),Ae=o.createSelector([_,function(e,t){return t}],(function(e,t){return t?e[t]:null})),He=De(Le),Ce=De(o.createSelector(Le,(function(e){return null==e?void 0:e.name}))),_e=De(Ae),Ue=De((function(e,t){var r=Le(e,t);if(r&&r.videoTrack&&""!==r.videoTrack)return e.tracks[r.videoTrack]})),Ve=De((function(e,t){var r=Le(e,t);if(r&&r.audioTrack&&""!==r.audioTrack)return e.tracks[r.audioTrack]})),Ke=Ue,qe=De((function(e,t){var r=Le(e,t);return(null==r?void 0:r.auxiliaryTracks.map((function(t){return e.tracks[t]})))||[]})),Be=function(e,t){return t?e.speakers[t]:null},je=De(o.createSelector(Be,(function(e){return(null==e?void 0:e.audioLevel)||0}))),Fe=De(o.createSelector((function(e,t){var r=Ve(t)(e);return Be(e,null==r?void 0:r.id)}),(function(e){return(null==e?void 0:e.audioLevel)||0}))),Ge=De((function(e,t){var r=Le(e,t);if(r){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){return M(e.tracks[t])}));return n?e.tracks[n]:void 0}})),Je=De(o.createSelector(_,Le,(function(e,t){var r=null==t?void 0:t.auxiliaryTracks.find((function(t){var r=e[t];return D(r)&&I(r)}));return r?e[r]:void 0}))),We=De(o.createSelector(_,Le,(function(e,t){var r=null==t?void 0:t.auxiliaryTracks.find((function(t){var r=e[t];return D(r)&&M(r)}));return r?e[r]:void 0}))),Qe=De(o.createSelector(_,Le,(function(e,t){var r=null==t?void 0:t.auxiliaryTracks.find((function(t){var r=e[t];return function(e){return e&&"audioplaylist"===e.source}(r)&&M(r)}));return r?e[r]:void 0}))),Xe=De(o.createSelector(_,Le,(function(e,t){return P(e,t)}))),Ye=function(e){return o.createSelector(Xe(e),(function(e){return e.audio}))},ze=De((function(e,t){var r=Le(e,t);return O(e,null==r?void 0:r.audioTrack)})),$e=De((function(e,t){var r=Le(e,t);return O(e,null==r?void 0:r.videoTrack)})),Ze=De((function(e,t){if(t&&e.tracks[t])return 0===e.tracks[t].volume})),et=De((function(e,t){var r=Le(e,t);return Ze(null==r?void 0:r.audioTrack)(e)})),tt=De((function(e,t){var r=Ye(t)(e);return Ze(null==r?void 0:r.id)(e)})),rt=De((function(e,t){var r=Ae(e,t);if(r)return"audio"!==r.type?void we.w("Please pass audio track here"):r.volume})),nt=De((function(e,t){var r=Le(e,t);return rt(null==r?void 0:r.audioTrack)(e)})),it=De((function(e,t){var r=Ye(t)(e);return rt(null==r?void 0:r.id)(e)})),ot=De((function(e,t){var r=Ae(e,t);if(r)return"video"!==r.type?void we.w("Please pass video track here"):r.layer})),st=o.createSelector([ce,G,Ne],(function(e,t,r){if(r)return e.filter((function(e){var n;return!!(e.recipientPeer||null!=(n=e.recipientRoles)&&n.length)&&!![t,r].includes(e.sender)&&[t,r].includes(e.recipientPeer)}))})),at=o.createSelector([ce,Oe],(function(e,t){if(t)return e.filter((function(e){var r,n;return!(null==(r=e.recipientRoles)||!r.length)&&(null==(n=e.recipientRoles)?void 0:n.includes(t))}))})),ct=o.createSelector(ce,(function(e){return e.filter((function(e){var t;return!(e.recipientPeer||null!=(t=e.recipientRoles)&&t.length)}))})),ut=o.createSelector([at,Oe],(function(e){return e?e.filter((function(e){return!e.read})).length:0})),lt=o.createSelector([st,Ne],(function(e){return e?e.filter((function(e){return!e.read})).length:0})),dt=o.createSelector(ct,(function(e){return e.filter((function(e){return!e.read})).length})),pt=De(st),ft=De(at),ht=De(ut),vt=De(lt),St=o.createSelector([A,_],(function(e,t){return Object.values(e).map((function(e){var r;return{peer:e,isAudioEnabled:!!e.audioTrack&&(null==(r=t[e.audioTrack])?void 0:r.enabled)}}))})),yt=o.createSelector([function(e){return e.roleChangeRequests[0]||null},A,pe],(function(e,t,r){return e?{requestedBy:t[e.requestedBy],role:r[e.roleName],token:e.token}:null})),gt=o.createSelector([he],(function(e){var t,r=!1,n=!1,i=!1;return null!=e&&null!=(t=e.publishParams)&&t.allowed&&(r=e.publishParams.allowed.includes("video"),n=e.publishParams.allowed.includes("audio"),i=e.publishParams.allowed.includes("screen")),{video:r,audio:n,screen:i}})),mt=o.createSelector([W,_],(function(e,t){var r,n=null;return e&&(n=t[e]),(null==(r=n)?void 0:r.plugins)||[]})),kt=o.createSelector([J,_],(function(e,t){var r,n=null;return e&&(n=t[e]),(null==(r=n)?void 0:r.plugins)||[]}));function Tt(e){return e instanceof i.HMSRemoteAudioTrack||e instanceof i.HMSRemoteVideoTrack}var xt,bt,Rt=function(){function e(e,t,r,n){this.playlistManager=e,this.syncPlaylistState=r,this.store=n,this.type=t}var t=e.prototype;return t.play=function(){var e=c(h.mark((function e(t){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return we.w("Please pass id to play"),e.abrupt("return");case 3:return e.next=5,this.playlistManager.setEnabled(!0,{id:t,type:this.type});case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.pause=function(){var e=c(h.mark((function e(){var t,r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.type===exports.HMSPlaylistType.audio?Pe:Me,(r=this.store.getState(t.selection)).id){e.next=5;break}return we.w("No item is currently playing to pause"),e.abrupt("return");case 5:return e.next=7,this.playlistManager.setEnabled(!1,{id:r.id,type:this.type});case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.playNext=function(){var e=c(h.mark((function e(){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.playlistManager.playNext(this.type);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.playPrevious=function(){var e=c(h.mark((function e(){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.playlistManager.playPrevious(this.type);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.seek=function(e){this.playlistManager.seek(e,this.type),this.syncPlaylistState("seekOn"+this.type+"Playlist")},t.seekTo=function(e){this.playlistManager.seekTo(e,this.type),this.syncPlaylistState("seekToOn"+this.type+"Playlist")},t.setVolume=function(e){this.playlistManager.setVolume(e,this.type),this.syncPlaylistState("setVolumeOn"+this.type+"Playlist")},t.setList=function(e){this.playlistManager.setList(e),this.syncPlaylistState("setListOn"+this.type+"Playlist")},t.stop=function(){var e=c(h.mark((function e(){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.playlistManager.stop(this.type);case 2:this.syncPlaylistState("stop"+this.type+"Playlist");case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),e}(),Et=function(){function e(e,t,r){var n=this;this.hmsSDKTracks={},this.hmsSDKPeers={},this.isRoomJoinCalled=!1,this.setProgress=function(e){var t=e.type,r=e.progress;n.setState((function(e){e.playlist[t].progress=r,e.playlist[t].currentTime=n.sdk.getPlaylistManager().getCurrentTime(t)}),"playlistProgress")},this.syncPlaylistState=function(e){n.setState((function(e){Object.assign(e.playlist,E.convertPlaylist(n.sdk.getPlaylistManager()))}),e)},this.syncRemoteTrackState=function(e,t,r){console.time("trackUpdate"),n.setState((function(i){var o=i.peers[r.peerId];if(!o){var s=E.convertPeer(r);i.peers[r.peerId]=s,o=s}var a=E.convertTrack(t,r.peerId);"trackAdded"===e?(i.tracks[a.id]=a,n.updateTracksInPeer(r,o,a)):i.tracks[a.id]?Object.assign(i.tracks[a.id],a):n.logPossibleInconsistency("track "+a.id+" not present, unable to update track"),n.hmsSDKTracks[t.trackId]=t}),e)},this.setState=function(e,t){return n.store.namedSetState(e,t)},this.store=e,this.sdk=t,this.hmsNotifications=r}var t=e.prototype;return t.unblockAudio=function(){var e=c(h.mark((function e(){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.getAudioOutput().unblockAutoplay();case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.setVolume=function(e,t){t?this.setTrackVolume(e,t):(this.sdk.getAudioOutput().setVolume(e),this.syncRoomState("setOutputVolume"))},t.setAudioOutputDevice=function(e){this.sdk.getAudioOutput().setDevice(e)&&this.setState((function(t){t.settings.audioOutputDeviceId=e}),"setAudioOutputDevice")},t.setPreferredLayer=function(e,t){var r=this.hmsSDKTracks[e];r?r instanceof i.HMSRemoteVideoTrack?(r.preferLayer(t),this.updateVideoLayer(e,"setPreferredLayer")):we.w("track "+e+" is not an video track"):this.logPossibleInconsistency("track "+e+" not present, unable to set preffer layer")},t.preview=function(){var e=c(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isRoomJoinCalled){e.next=3;break}return this.logPossibleInconsistency("attempting to call preview after join was called"),e.abrupt("return");case 3:if((r=this.store.getState(ue))!==exports.HMSRoomState.Preview&&r!==exports.HMSRoomState.Connecting){e.next=7;break}return this.logPossibleInconsistency("attempting to call preview while room is in preview/connecting"),e.abrupt("return");case 7:return e.prev=7,e.next=10,this.sdkPreviewWithListeners(t);case 10:this.setState((function(e){e.room.roomState=exports.HMSRoomState.Connecting}),"preview"),e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(7),we.e("Cannot show preview. Failed to connect to room - ",e.t0),e.t0;case 17:case"end":return e.stop()}}),e,this,[[7,13]])})));return function(t){return e.apply(this,arguments)}}(),t.join=function(e){if(this.isRoomJoinCalled)this.logPossibleInconsistency("room join is called again");else try{this.sdkJoinWithListeners(e),this.isRoomJoinCalled=!0,this.setState((function(e){e.room.roomState=exports.HMSRoomState.Connecting}),"join")}catch(e){throw this.isRoomJoinCalled=!1,we.e("Failed to connect to room - ",e),e}},t.leave=function(){var e=c(h.mark((function e(){var t=this;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.store.getState(de)){e.next=4;break}return this.logPossibleInconsistency("room leave is called when no room is connected"),e.abrupt("return");case 4:return e.abrupt("return",this.sdk.leave().then((function(){t.resetState("leave"),we.i("left room")})).catch((function(e){we.e("error in leaving room - ",e)})));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.setScreenShareEnabled=function(){var e=c(h.mark((function e(t,r){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=5;break}return e.next=3,this.startScreenShare(r);case 3:e.next=7;break;case 5:return e.next=7,this.stopScreenShare();case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.addTrack=function(){var e=c(h.mark((function e(t,r){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r="regular"),e.next=3,this.sdk.addTrack(t,r);case 3:this.syncRoomState("addTrack");case 4:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.removeTrack=function(){var e=c(h.mark((function e(t){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.removeTrack(t);case 2:this.syncRoomState("removeTrack");case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setLocalAudioEnabled=function(){var e=c(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(J))){e.next=4;break}return e.next=4,this.setEnabledTrack(r,t);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setLocalVideoEnabled=function(){var e=c(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(W))){e.next=4;break}return e.next=4,this.setEnabledTrack(r,t);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setEnabledTrack=function(){var e=c(h.mark((function e(t,r){var n,o=this;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((null==(n=this.store.getState().tracks[t])?void 0:n.enabled)!==r){e.next=4;break}return this.logPossibleInconsistency("local track["+t+"] enabled state - "+r),e.abrupt("return");case 4:return this.setState((function(e){e.tracks[t]?e.tracks[t].displayEnabled=r:o.logPossibleInconsistency("track id not found for setEnabled")}),"displayEnabled"),e.prev=5,e.next=8,this.setEnabledSDKTrack(t,r);case 8:this.syncRoomState("setEnabled"),e.next=16;break;case 11:throw e.prev=11,e.t0=e.catch(5),this.setState((function(e){e.tracks[t].displayEnabled=!r}),"rollbackDisplayEnabled"),this.hmsNotifications.sendError(E.convertException(e.t0)),e.t0;case 16:this.hmsNotifications.sendTrackUpdate(r?i.HMSTrackUpdate.TRACK_UNMUTED:i.HMSTrackUpdate.TRACK_MUTED,t);case 18:case"end":return e.stop()}}),e,this,[[5,11]])})));return function(t,r){return e.apply(this,arguments)}}(),t.setAudioSettings=function(){var e=c(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(J))){e.next=5;break}return e.next=4,this.setSDKLocalAudioTrackSettings(r,t);case 4:this.syncRoomState("setAudioSettings");case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setVideoSettings=function(){var e=c(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(W))){e.next=5;break}return e.next=4,this.setSDKLocalVideoTrackSettings(r,t);case 4:this.syncRoomState("setVideoSettings");case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.sendMessage=function(e){this.sendBroadcastMessage(e)},t.sendBroadcastMessage=function(){var e=c(h.mark((function e(t,r){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.sendBroadcastMessage(t,r);case 2:this.updateMessageInStore(e.sent,{message:t,type:r});case 4:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.sendGroupMessage=function(){var e=c(h.mark((function e(t,r,n){var i,o;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=this.store.getState(pe),o=r.map((function(e){return i[e]})),e.next=4,this.sdk.sendGroupMessage(t,o,n);case 4:this.updateMessageInStore(e.sent,{message:t,recipientRoles:r,type:n});case 6:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t.sendDirectMessage=function(){var e=c(h.mark((function e(t,r,n){var i;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=this.hmsSDKPeers[r],e.next=3,this.sdk.sendDirectMessage(t,i);case 3:this.updateMessageInStore(e.sent,{message:t,recipientPeer:i.peerId,type:n});case 5:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t.updateMessageInStore=function(e,t){if(!e)throw we.w("sendMessage","Failed to send message",t),Error("sendMessage Failed - "+JSON.stringify(t));var r=E.convertMessage(e);return r.read=!0,r.senderName="You",this.onHMSMessage(r),r},t.setMessageRead=function(e,t){var r=this;this.setState((function(n){t?n.messages.byID[t]?n.messages.byID[t].read=e:r.logPossibleInconsistency("no message with id is found"):n.messages.allIDs.forEach((function(t){n.messages.byID[t].read=e}))}),"setMessageRead")},t.attachVideo=function(){var e=c(h.mark((function e(t,r){var n=this;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localAndVideoUnmuting(t)){e.next=4;break}return e.abrupt("return",new Promise((function(e){var i=n.store.subscribe(function(){var o=c(h.mark((function o(s){return h.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(!s){o.next=5;break}return o.next=3,n.attachVideoInternal(t,r);case 3:i(),e();case 5:case"end":return o.stop()}}),o)})));return function(e){return o.apply(this,arguments)}}(),z)})));case 4:return e.next=6,this.attachVideoInternal(t,r);case 6:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.detachVideo=function(){var e=c(h.mark((function e(t,r){var n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])||"video"!==n.type){e.next=7;break}return e.next=4,n.removeSink(r);case 4:this.updateVideoLayer(t,"detachVideo"),e.next=8;break;case 7:this.logPossibleInconsistency("no video track found to remove sink");case 8:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.addPluginToVideoTrack=function(){var e=c(h.mark((function e(t,r){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.addRemoveVideoPlugin(t,"add",r));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.addPluginToAudioTrack=function(){var e=c(h.mark((function e(t){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.addRemoveAudioPlugin(t,"add"));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.removePluginFromVideoTrack=function(){var e=c(h.mark((function e(t){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.addRemoveVideoPlugin(t,"remove"));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.removePluginFromAudioTrack=function(){var e=c(h.mark((function e(t){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.addRemoveAudioPlugin(t,"remove"));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.changeRole=function(){var e=c(h.mark((function e(t,r,n){var i;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===n&&(n=!1),i=this.hmsSDKPeers[t]){e.next=5;break}return this.logPossibleInconsistency("Unknown peer ID given "+t+" for changerole"),e.abrupt("return");case 5:return e.next=7,this.sdk.changeRole(i,r,n);case 7:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t.acceptChangeRole=function(){var e=c(h.mark((function e(t){var r,n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=t.requestedBy?this.hmsSDKPeers[t.requestedBy.id]:void 0)||we.w("peer for which role change is requested no longer available - "+t.requestedBy),n={requestedBy:r,role:t.role,token:t.token},e.next=5,this.sdk.acceptChangeRole(n);case 5:this.removeRoleChangeRequest(t);case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.rejectChangeRole=function(e){this.removeRoleChangeRequest(e)},t.endRoom=function(){var e=c(h.mark((function e(t,r){var n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(n=this.store.getState(Se))&&n.endRoom){e.next=4;break}return we.w("You are not allowed to perform this action - endRoom"),e.abrupt("return");case 4:return e.next=6,this.sdk.endRoom(t,r);case 6:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.removePeer=function(){var e=c(h.mark((function e(t,r){var n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKPeers[t])||n.isLocal){e.next=6;break}return e.next=4,this.sdk.removePeer(n,r);case 4:e.next=8;break;case 6:return this.logPossibleInconsistency("No remote peer found for peerID - "+t),e.abrupt("return");case 8:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.startRTMPOrRecording=function(){var e=c(h.mark((function e(t){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.startRTMPOrRecording(t);case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.stopRTMPAndRecording=function(){var e=c(h.mark((function e(){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.stopRTMPAndRecording();case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.setRemoteTrackEnabled=function(){var e=c(h.mark((function e(t,r){var n,i=this;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t){e.next=10;break}if(!(n=this.hmsSDKTracks[t])||!Tt(n)){e.next=7;break}return e.next=5,this.sdk.changeTrackState(n,r);case 5:e.next=8;break;case 7:this.logPossibleInconsistency("No remote track with ID "+t+" found for change track state");case 8:e.next=11;break;case 10:Array.isArray(t)&&t.forEach((function(e){return i.setRemoteTrackEnabled(e,r)}));case 11:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setRemoteTracksEnabled=function(){var e=c(h.mark((function e(t){var r,n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={enabled:t.enabled,type:t.type,source:t.source},t.roles&&(n=this.store.getState(pe),r.roles=t.roles.map((function(e){return n[e]}))),e.next=4,this.sdk.changeMultiTrackState(r);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setLogLevel=function(e){we.level=e,this.sdk.setLogLevel(e)},t.resetState=function(e){void 0===e&&(e="resetState"),this.setState((function(e){Object.assign(e,g())}),e),this.isRoomJoinCalled=!1,this.hmsSDKTracks={}},t.sdkJoinWithListeners=function(e){this.sdk.join(e,{onJoin:this.onJoin.bind(this),onRoomUpdate:this.onRoomUpdate.bind(this),onPeerUpdate:this.onPeerUpdate.bind(this),onTrackUpdate:this.onTrackUpdate.bind(this),onMessageReceived:this.onMessageReceived.bind(this),onError:this.onError.bind(this),onReconnected:this.onReconnected.bind(this),onReconnecting:this.onReconnecting.bind(this),onRoleChangeRequest:this.onRoleChangeRequest.bind(this),onRoleUpdate:this.onRoleUpdate.bind(this),onDeviceChange:this.onDeviceChange.bind(this),onChangeTrackStateRequest:this.onChangeTrackStateRequest.bind(this),onChangeMultiTrackStateRequest:this.onChangeMultiTrackStateRequest.bind(this),onRemovedFromRoom:this.onRemovedFromRoom.bind(this)}),this.sdk.addAudioListener({onAudioLevelUpdate:this.onAudioLevelUpdate.bind(this)})},t.onRemovedFromRoom=function(e){var t=this.store.getState(He(e.requestedBy.peerId));t?(this.hmsNotifications.sendLeaveRoom(u({},e,{requestedBy:t})),we.i("resetting state after peer removed",e),this.resetState(e.roomEnded?"roomEnded":"removedFromRoom")):this.logPossibleInconsistency("Not found peer who requested leave room, "+e.requestedBy)},t.onDeviceChange=function(e){var t=this,r=e.devices;if(r){var n=this.store.getState(F);if(this.setState((function(e){x(e.devices.audioInput,r.audioInput)||(e.devices.audioInput=r.audioInput),x(e.devices.videoInput,r.videoInput)||(e.devices.videoInput=r.videoInput),x(e.devices.audioOutput,r.audioOutput)||(e.devices.audioOutput=r.audioOutput),t.hmsSDKPeers[null==n?void 0:n.id]&&Object.assign(e.settings,t.getMediaSettings(t.hmsSDKPeers[null==n?void 0:n.id]))}),"deviceChange"),e.selection){var i=E.convertDeviceChangeUpdate(e);this.hmsNotifications.sendDeviceChange(i)}}},t.sdkPreviewWithListeners=function(){var e=c(h.mark((function e(t){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.preview(t,{onPreview:this.onPreview.bind(this),onError:this.onError.bind(this),onDeviceChange:this.onDeviceChange.bind(this)});case 2:this.sdk.addAudioListener({onAudioLevelUpdate:this.onAudioLevelUpdate.bind(this)});case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.startScreenShare=function(){var e=c(h.mark((function e(t){var r=this;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.store.getState(Z)){e.next=7;break}return e.next=4,this.sdk.startScreenShare((function(){return r.syncRoomState("screenshareStopped")}),t);case 4:this.syncRoomState("startScreenShare"),e.next=8;break;case 7:this.logPossibleInconsistency("start screenshare is called while it's on");case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.stopScreenShare=function(){var e=c(h.mark((function e(){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.store.getState(Z)){e.next=7;break}return e.next=4,this.sdk.stopScreenShare();case 4:this.syncRoomState("stopScreenShare"),e.next=8;break;case 7:this.logPossibleInconsistency("stop screenshare is called while it's not on");case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.attachVideoInternal=function(){var e=c(h.mark((function e(t,r){var n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])||"video"!==n.type){e.next=7;break}return e.next=4,n.addSink(r);case 4:this.updateVideoLayer(t,"attachVideo"),e.next=8;break;case 7:this.logPossibleInconsistency("no video track found to add sink");case 8:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.syncRoomState=function(e){var t=this;console.time("syncRoomState");for(var r,n={},i=[],o={},s={},a={},c=d(this.sdk.getPeers());!(r=c()).done;){var u=r.value,l=E.convertPeer(u);n[l.id]=l,i.push(l.id),this.hmsSDKPeers[l.id]=u;for(var p,f=d([u.audioTrack,u.videoTrack].concat(u.auxiliaryTracks));!(p=f()).done;){var h=p.value;if(h){var v=E.convertTrack(h);o[v.id]=v,s[h.trackId]=h}}l.isLocal&&Object.assign(a,this.getMediaSettings(u))}var S=this.sdk.getRecordingState(),y=this.sdk.getRTMPState();this.setState((function(e){e.room.peers=i;var r=e.tracks;!function(e,t,r,n){for(var i,o=d(b(Object.keys(e),Object.keys(t)));!(i=o()).done;){var s=i.value,a=e[s],c=t[s];m(a,c)?(x(a.auxiliaryTracks,c.auxiliaryTracks)&&(c.auxiliaryTracks=a.auxiliaryTracks),R(a,c,r,n),Object.assign(a,c)):k(a,c)?delete e[s]:T(a,c)&&(e[s]=c)}}(e.peers,n,o,s),function(e,t){for(var r,n=d(b(Object.keys(e),Object.keys(t)));!(r=n()).done;){var i=r.value,o=e[i],s=t[i];m(o,s)?Object.assign(o,s):k(o,s)?delete e[i]:T(o,s)&&(e[i]=s)}}(r,o),Object.assign(e.settings,a),t.hmsSDKTracks=s,Object.assign(e.roles,E.convertRoles(t.sdk.getRoles())),Object.assign(e.playlist,E.convertPlaylist(t.sdk.getPlaylistManager())),Object.assign(e.room,E.convertRecordingRTMPState(S,y))}),e),console.timeEnd("syncRoomState")},t.onPreview=function(e){this.setState((function(t){Object.assign(t.room,E.convertRoom(e)),t.room.roomState=exports.HMSRoomState.Preview}),"previewStart"),this.syncRoomState("previewSync")},t.onJoin=function(e){var t=this;this.audioPlaylist=new Rt(this.sdk.getPlaylistManager(),exports.HMSPlaylistType.audio,this.syncPlaylistState.bind(this),this.store),this.videoPlaylist=new Rt(this.sdk.getPlaylistManager(),exports.HMSPlaylistType.video,this.syncRoomState.bind(this),this.store),this.syncRoomState("joinSync"),this.setState((function(t){Object.assign(t.room,E.convertRoom(e)),t.room.isConnected=!0,t.room.roomState=exports.HMSRoomState.Connected}),"joined"),this.sdk.getPlaylistManager().onProgress(this.setProgress),this.sdk.getPlaylistManager().onNewTrackStart((function(e){t.syncPlaylistState(e.type+"PlaylistUpdate")})),this.sdk.getPlaylistManager().onPlaylistEnded((function(e){t.syncPlaylistState(e+"PlaylistEnded")}))},t.onRoomUpdate=function(e,t){this.setState((function(e){Object.assign(e.room,E.convertRoom(t))}),"RoomUpdate")},t.onPeerUpdate=function(e,t){if(e!==i.HMSPeerUpdate.BECAME_DOMINANT_SPEAKER&&e!==i.HMSPeerUpdate.RESIGNED_DOMINANT_SPEAKER)if(Array.isArray(t)){this.syncRoomState("peersJoined");for(var r,n=d(t);!(r=n()).done;){var o=this.store.getState(He(r.value.peerId));this.hmsNotifications.sendPeerUpdate(e,o)}}else this.peerUpdateInternal(e,t)},t.onTrackUpdate=function(e,t,r){e===i.HMSTrackUpdate.TRACK_REMOVED?(this.hmsNotifications.sendTrackUpdate(e,t.trackId),this.handleTrackRemove(t,r)):(this.syncRemoteTrackState(e===i.HMSTrackUpdate.TRACK_ADDED?"trackAdded":"trackUpdate",t,r),this.hmsNotifications.sendTrackUpdate(e,t.trackId))},t.onMessageReceived=function(e){var t=E.convertMessage(e);t.read=!1,this.onHMSMessage(t),this.hmsNotifications.sendMessageReceived(t)},t.onHMSMessage=function(e){var t=this;this.setState((function(r){e.id=String(t.store.getState(se)+1),r.messages.byID[e.id]=e,r.messages.allIDs.push(e.id)}),"newMessage")},t.onAudioLevelUpdate=function(e){this.setState((function(t){var r={};e.forEach((function(e){if(e.track&&e.peer){var n=e.track.trackId;r[n]=e.audioLevel,t.speakers[n]||(t.speakers[n]={audioLevel:e.audioLevel,peerID:e.peer.peerId,trackID:n})}}));for(var n=0,i=Object.entries(t.speakers);n<i.length;n++){var o=i[n],s=o[0],a=o[1];a.audioLevel=r[s]||0,0===a.audioLevel&&delete t.speakers[s]}}),"audioLevel")},t.onChangeTrackStateRequest=function(e){var t=this.store.getState(He(e.requestedBy.peerId)),r=this.getStoreLocalTrackIDfromSDKTrack(e.track),n=this.store.getState(_e(r));return t?n?(e.enabled||this.syncRoomState("changeTrackStateRequest"),void this.hmsNotifications.sendChangeTrackStateRequest({requestedBy:t,track:n,enabled:e.enabled})):this.logPossibleInconsistency("Not found track for which track state change was requested, "+e.track):this.logPossibleInconsistency("Not found peer who requested track state change, "+e.requestedBy)},t.onChangeMultiTrackStateRequest=function(e){var t=this.store.getState(He(e.requestedBy.peerId));if(!t)return this.logPossibleInconsistency("Not found peer who requested track state change, "+e.requestedBy);e.enabled||this.syncRoomState("changeMultiTrackStateRequest");for(var r,n=[],i=this.store.getState(_),o=d(e.tracks);!(r=o()).done;){var s=this.getStoreLocalTrackIDfromSDKTrack(r.value);s&&i[s]&&n.push(i[s])}this.hmsNotifications.sendChangeMultiTrackStateRequest({requestedBy:t,tracks:n,enabled:e.enabled,type:e.type,source:e.source})},t.onReconnected=function(){this.syncRoomState("reconnectedSync"),this.hmsNotifications.sendReconnected(),this.setState((function(e){e.room.roomState=exports.HMSRoomState.Connected}),"reconnected")},t.onReconnecting=function(e){var t=E.convertException(e);we.e("Reconnection: received error from sdk",t),this.hmsNotifications.sendReconnecting(t),this.setState((function(e){e.room.roomState=exports.HMSRoomState.Reconnecting,e.errors.push(t)}),"reconnecting")},t.onError=function(e){var t=E.convertException(e);t.isTerminal?(this.leave().then((function(){return console.log("error from SDK, left room.")})),this.setState((function(e){e.room.roomState=exports.HMSRoomState.Failed,e.errors.push(t)}),"errorTerminal")):this.store.getState().errors.length<50&&this.setState((function(e){e.errors.push(t)}),"error"),this.hmsNotifications.sendError(t),we.e("received error from sdk",t)},t.updateVideoLayer=function(e,t){var r=this.hmsSDKTracks[e];r&&r instanceof i.HMSRemoteVideoTrack&&this.setState((function(t){t.tracks[e].layer=r.getSimulcastLayer()}),t)},t.handleTrackRemove=function(e,t){var r=this;this.setState((function(n){var i=n.peers[t.peerId],o=n.tracks;if(r.isSameStoreSDKTrack(e.trackId,null==i?void 0:i.audioTrack))null==i||delete i.audioTrack;else if(r.isSameStoreSDKTrack(e.trackId,null==i?void 0:i.videoTrack))null==i||delete i.videoTrack;else{var s=null==i?void 0:i.auxiliaryTracks.indexOf(e.trackId);s>-1&&r.isSameStoreSDKTrack(e.trackId,null==i?void 0:i.auxiliaryTracks[s])&&(null==i||i.auxiliaryTracks.splice(s,1))}delete o[e.trackId],delete r.hmsSDKTracks[e.trackId]}),"trackRemoved")},t.setEnabledSDKTrack=function(){var e=c(h.mark((function e(t,r){var n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setEnabled(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("track "+t+" not present, unable to enabled/disable");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setSDKLocalVideoTrackSettings=function(){var e=c(h.mark((function e(t,r){var n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setSettings(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("local track "+t+" not present, unable to set settings");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setSDKLocalAudioTrackSettings=function(){var e=c(h.mark((function e(t,r){var n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setSettings(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("local track "+t+" not present, unable to set settings");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.getMediaSettings=function(e){var t,r,n,i=this.store.getState(U),o=e.audioTrack,s=e.videoTrack;return{audioInputDeviceId:o&&o.enabled?null==(t=o.getMediaTrackSettings())?void 0:t.deviceId:i.audioInputDeviceId,videoInputDeviceId:s&&s.enabled?null==(r=s.getMediaTrackSettings())?void 0:r.deviceId:i.videoInputDeviceId,audioOutputDeviceId:null==(n=this.sdk.getAudioOutput().getDevice())?void 0:n.deviceId}},t.setTrackVolume=function(e,t){var r=this.hmsSDKTracks[t];r?r instanceof i.HMSAudioTrack?(r.setVolume(e),this.setState((function(r){var n=r.tracks[t];n&&(n.volume=e)}),"trackVolume")):we.w("track "+t+" is not an audio track"):this.logPossibleInconsistency("track "+t+" not present, unable to set volume")},t.localAndVideoUnmuting=function(e){if(this.store.getState(F).videoTrack!==e)return!1;var t=this.store.getState($),r=this.store.getState(z);return t&&!r},t.logPossibleInconsistency=function(e){we.w("possible inconsistency detected - ",e)},t.addRemoveVideoPlugin=function(){var e=c(h.mark((function e(t,r,n){var i,o;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return we.w("Invalid plugin received in store"),e.abrupt("return");case 3:if(!(i=this.store.getState(W))){e.next=19;break}if(!(o=this.hmsSDKTracks[i])){e.next=18;break}if("add"!==r){e.next=12;break}return e.next=10,o.addPlugin(t,n);case 10:e.next=15;break;case 12:if("remove"!==r){e.next=15;break}return e.next=15,o.removePlugin(t);case 15:this.syncRoomState(r+"VideoPlugin"),e.next=19;break;case 18:this.logPossibleInconsistency("track "+i+" not present, unable to remove plugin");case 19:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t.addRemoveAudioPlugin=function(){var e=c(h.mark((function e(t,r){var n,i;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return we.w("Invalid plugin received in store"),e.abrupt("return");case 3:if(!(n=this.store.getState(J))){e.next=19;break}if(!(i=this.hmsSDKTracks[n])){e.next=18;break}if("add"!==r){e.next=12;break}return e.next=10,i.addPlugin(t);case 10:e.next=15;break;case 12:if("remove"!==r){e.next=15;break}return e.next=15,i.removePlugin(t);case 15:this.syncRoomState(r+"AudioPlugin"),e.next=19;break;case 18:this.logPossibleInconsistency("track "+n+" not present, unable to remove plugin");case 19:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.isSameStoreSDKTrack=function(e,t){var r;return!!t&&(null==(r=this.hmsSDKTracks[t])?void 0:r.trackId)===e},t.onRoleChangeRequest=function(e){this.setState((function(t){0===t.roleChangeRequests.length&&t.roleChangeRequests.push(E.convertRoleChangeRequest(e))}),"roleChangeRequest")},t.removeRoleChangeRequest=function(e){this.setState((function(t){var r=t.roleChangeRequests.findIndex((function(t){return t.token===e.token}));-1!==r&&t.roleChangeRequests.splice(r,1)}),"removeRoleChangeRequest")},t.onRoleUpdate=function(){this.syncRoomState("roleUpdate")},t.getStoreLocalTrackIDfromSDKTrack=function(e){var t=this;return this.store.getState(Q).find((function(r){return t.hmsSDKTracks[r].trackId===e.trackId}))},t.peerUpdateInternal=function(e,t){var r=this,n=this.store.getState(He(t.peerId)),o="peerUpdate";e===i.HMSPeerUpdate.PEER_JOINED?o="peerJoined":e===i.HMSPeerUpdate.PEER_LEFT&&(o="peerLeft"),this.setState((function(e){if("peerLeft"===o){var n=e.room.peers.indexOf(t.peerId);n>-1&&e.room.peers.splice(n,1),delete e.peers[t.peerId],delete r.hmsSDKPeers[t.peerId]}else{var i=E.convertPeer(t);e.peers[i.id]?Object.assign(e.peers[i.id],i):(e.peers[i.id]=i,e.room.peers.push(i.id)),r.hmsSDKPeers[t.peerId]=t}}),o),n||(n=this.store.getState(He(t.peerId))),this.hmsNotifications.sendPeerUpdate(e,n)},t.updateTracksInPeer=function(e,t,r){var n,i;(null==(n=e.audioTrack)?void 0:n.trackId)===r.id?t.audioTrack=r.id:(null==(i=e.videoTrack)?void 0:i.trackId)===r.id?t.videoTrack=r.id:t.auxiliaryTracks.includes(r.id)||t.auxiliaryTracks.push(r.id)},e}(),Pt=((xt={})[i.HMSPeerUpdate.PEER_JOINED]=exports.HMSNotificationTypes.PEER_JOINED,xt[i.HMSPeerUpdate.PEER_LEFT]=exports.HMSNotificationTypes.PEER_LEFT,xt[i.HMSPeerUpdate.ROLE_UPDATED]=exports.HMSNotificationTypes.ROLE_UPDATED,xt[i.HMSPeerUpdate.AUDIO_TOGGLED]="PEER_AUDIO_UPDATED",xt[i.HMSPeerUpdate.VIDEO_TOGGLED]="PEER_VIDEO_UPDATED",xt),Mt=((bt={})[i.HMSTrackUpdate.TRACK_ADDED]=exports.HMSNotificationTypes.TRACK_ADDED,bt[i.HMSTrackUpdate.TRACK_REMOVED]=exports.HMSNotificationTypes.TRACK_REMOVED,bt[i.HMSTrackUpdate.TRACK_MUTED]=exports.HMSNotificationTypes.TRACK_MUTED,bt[i.HMSTrackUpdate.TRACK_UNMUTED]=exports.HMSNotificationTypes.TRACK_UNMUTED,bt),It=function(){function e(e){var t=this;this.id=0,this.onNotification=function(e){return t.eventEmitter.addListener("hmsNotification",e),function(){t.eventEmitter.removeListener("hmsNotification",e)}},this.store=e,this.eventEmitter=new s}var t=e.prototype;return t.sendDeviceChange=function(e){var t,r=this.createNotification(exports.HMSNotificationTypes.DEVICE_CHANGE_UPDATE,e,e.error?exports.HMSNotificationSeverity.ERROR:exports.HMSNotificationSeverity.INFO,"Selected "+e.type+" device - "+(null==(t=e.selection)?void 0:t.label));this.emitEvent(r)},t.sendLeaveRoom=function(e){var t=this.createNotification(e.roomEnded?exports.HMSNotificationTypes.ROOM_ENDED:exports.HMSNotificationTypes.REMOVED_FROM_ROOM,e,exports.HMSNotificationSeverity.INFO,(e.roomEnded?"Room ended":"Removed from room")+" by "+e.requestedBy.name);this.emitEvent(t)},t.sendPeerUpdate=function(e,t){var r=this.store.getState(He(null==t?void 0:t.id))||t,n=Pt[e];if(n){var i=this.createNotification(n,r,exports.HMSNotificationSeverity.INFO);this.emitEvent(i)}},t.sendTrackUpdate=function(e,t){var r=this.store.getState(_e(t)),n=Mt[e];if(n){var i=this.createNotification(n,r,exports.HMSNotificationSeverity.INFO);this.emitEvent(i)}},t.sendMessageReceived=function(e){var t=this.createNotification(exports.HMSNotificationTypes.NEW_MESSAGE,e,exports.HMSNotificationSeverity.INFO);this.emitEvent(t)},t.sendError=function(e){var t=this.createNotification(exports.HMSNotificationTypes.ERROR,e,exports.HMSNotificationSeverity.ERROR);this.emitEvent(t)},t.sendReconnecting=function(e){var t=this.createNotification(exports.HMSNotificationTypes.RECONNECTING,e,exports.HMSNotificationSeverity.ERROR);this.emitEvent(t)},t.sendReconnected=function(){var e=this.createNotification(exports.HMSNotificationTypes.RECONNECTED,null,exports.HMSNotificationSeverity.INFO);this.emitEvent(e)},t.sendChangeTrackStateRequest=function(e){var t=this.createNotification(exports.HMSNotificationTypes.CHANGE_TRACK_STATE_REQUEST,e,exports.HMSNotificationSeverity.INFO);this.emitEvent(t)},t.sendChangeMultiTrackStateRequest=function(e){var t=this.createNotification(exports.HMSNotificationTypes.CHANGE_MULTI_TRACK_STATE_REQUEST,e,exports.HMSNotificationSeverity.INFO);this.emitEvent(t)},t.emitEvent=function(e){this.eventEmitter.emit("hmsNotification",e)},t.createNotification=function(e,t,r,n){return void 0===n&&(n=""),this.id++,{id:this.id,type:e,message:n,data:t,severity:r}},e}(),wt=function(){function e(t,r,n){this.store=t||e.createNewHMSStore(),this.notifications=n||new It(this.store),this.actions=r||new Et(this.store,new i.HMSSdk,this.notifications),this.initialTriggerOnSubscribe=!1}var o=e.prototype;return o.triggerOnSubscribe=function(){this.initialTriggerOnSubscribe||(e.makeStoreTriggerOnSubscribe(this.store),this.initialTriggerOnSubscribe=!0)},o.getStore=function(){return this.store},o.getHMSActions=function(){return this.actions},o.getNotifications=function(){return{onNotification:this.notifications.onNotification}},e.createNewHMSStore=function(){var n=r((function(){return g()})),i=n.setState;n.setState=function(e){var r="function"==typeof e?t(e):e;i(r)};var o=n.getState;return n.getState=function(e){return e?e(o()):o()},e.useShallowCheckInSubscribe(n),u({},n,{namedSetState:e.setUpDevtools(n,"HMSStore")})},e.makeStoreTriggerOnSubscribe=function(e){var t=e.subscribe;e.subscribe=function(r,n,i){return r(e.getState(n),void 0),t(r,n,i)}},e.useShallowCheckInSubscribe=function(e){var t=e.subscribe;e.subscribe=function(e,r,i){return r||(r=function(e){return e}),t(e,r,i=i||n)}},e.setUpDevtools=function(t,r){var n;try{n=window.__REDUX_DEVTOOLS_EXTENSION__||window.top.__REDUX_DEVTOOLS_EXTENSION__}catch(e){}if(!n)return function(e){t.setState(e)};var i=n.connect(e.devtoolsOptions(r));i.prefix=r?r+" > ":"";var o=t.setState;return t.setState=function(e){o(e),i.send(i.prefix+"setState",t.getState())},i.subscribe(e.devtoolsSubscribe(i,t,o)),i.send("setUpStore",t.getState()),function(e,r){o(e),i.send(r||i.prefix+"action",t.getState())}},e.devtoolsOptions=function(e){return{name:e,actionsBlacklist:["audioLevel","playlistProgress"]}},e.devtoolsSubscribe=function(e,t,r){return function(n){var i,o;if("DISPATCH"===n.type&&n.state)["JUMP_TO_ACTION","JUMP_TO_STATE"].includes(n.payload.type)?r(JSON.parse(n.state)):t.setState(JSON.parse(n.state));else if("DISPATCH"===n.type&&"COMMIT"===(null==(i=n.payload)?void 0:i.type))e.init(t.getState());else if("DISPATCH"===n.type&&"IMPORT_STATE"===(null==(o=n.payload)?void 0:o.type)){var s,a,c=null==(s=n.payload.nextLiftedState)?void 0:s.actionsById;((null==(a=n.payload.nextLiftedState)?void 0:a.computedStates)||[]).forEach((function(n,i){var o=n.state,s=c[i]||e.prefix+"setState";0===i?e.init(o):(r(o),e.send(s,t.getState()))}))}}},e}();Object.defineProperty(exports,"HMSLogLevel",{enumerable:!0,get:function(){return i.HMSLogLevel}}),Object.defineProperty(exports,"HMSSimulcastLayer",{enumerable:!0,get:function(){return i.HMSSimulcastLayer}}),exports.HMSReactiveStore=wt,exports.createDefaultStoreState=g,exports.selectAudioPlaylist=Pe,exports.selectAudioPlaylistTrackByPeerID=Qe,exports.selectAudioTrackByPeerID=Ve,exports.selectAudioTrackVolume=rt,exports.selectAudioVolumeByPeerID=nt,exports.selectAuxiliaryAudioByPeerID=Ge,exports.selectAuxiliaryTracksByPeerID=qe,exports.selectAvailableRoleNames=fe,exports.selectBroadcastMessages=ct,exports.selectBroadcastMessagesUnreadCount=dt,exports.selectCameraStreamByPeerID=Ke,exports.selectDegradedTracks=oe,exports.selectDevices=function(e){return e.devices},exports.selectDominantSpeaker=Y,exports.selectHMSMessages=ce,exports.selectHMSMessagesCount=se,exports.selectIsAllowedToPublish=gt,exports.selectIsAllowedToSubscribe=ve,exports.selectIsAudioLocallyMuted=Ze,exports.selectIsConnectedToRoom=K,exports.selectIsInPreview=le,exports.selectIsLocalAudioEnabled=function(e){var t=F(e);return O(e,null==t?void 0:t.audioTrack)},exports.selectIsLocalAudioPluginPresent=function(e){return o.createSelector([kt],(function(t){return t.includes(e)}))},exports.selectIsLocalScreenShared=Z,exports.selectIsLocalVideoDisplayEnabled=$,exports.selectIsLocalVideoEnabled=z,exports.selectIsLocalVideoPluginPresent=function(e){return o.createSelector([mt],(function(t){return t.includes(e)}))},exports.selectIsLocallyMutedByPeerID=et,exports.selectIsPeerAudioEnabled=ze,exports.selectIsPeerVideoEnabled=$e,exports.selectIsScreenShareLocallyMutedByPeerID=tt,exports.selectIsSomeoneScreenSharing=te,exports.selectLocalAudioTrackID=J,exports.selectLocalMediaSettings=U,exports.selectLocalPeer=F,exports.selectLocalPeerID=G,exports.selectLocalPeerRole=he,exports.selectLocalTrackIDs=Q,exports.selectLocalVideoTrackID=W,exports.selectMessageIDsInOrder=C,exports.selectMessagesByPeerID=pt,exports.selectMessagesByRole=ft,exports.selectMessagesMap=H,exports.selectMessagesUnreadCountByPeerID=vt,exports.selectMessagesUnreadCountByRole=ht,exports.selectPeerAudioByID=Fe,exports.selectPeerByID=He,exports.selectPeerCount=q,exports.selectPeerNameByID=Ce,exports.selectPeerScreenSharing=ee,exports.selectPeerSharingAudio=re,exports.selectPeerSharingVideoPlaylist=ie,exports.selectPeers=B,exports.selectPeersMap=A,exports.selectPeersScreenSharing=ne,exports.selectPeersWithAudioStatus=St,exports.selectPermissions=Se,exports.selectRTMPState=ge,exports.selectRecordingState=ye,exports.selectRemotePeers=X,exports.selectRoleByRoleName=function(e){return o.createSelector([pe],(function(t){return t[e]}))},exports.selectRoleChangeRequest=yt,exports.selectRolesMap=pe,exports.selectRoom=L,exports.selectRoomStarted=de,exports.selectRoomState=ue,exports.selectScreenShareAudioByPeerID=Ye,exports.selectScreenShareByPeerID=function(e){return o.createSelector(Xe(e),(function(e){return e.video}))},exports.selectScreenSharesByPeerId=Xe,exports.selectScreenshareAudioVolumeByPeerID=it,exports.selectSimulcastLayerByTrack=ot,exports.selectSpeakers=V,exports.selectTrackAudioByID=je,exports.selectTrackByID=_e,exports.selectTracksMap=_,exports.selectUnreadHMSMessagesCount=ae,exports.selectVideoPlaylist=Me,exports.selectVideoPlaylistAudioTrackByPeerID=We,exports.selectVideoPlaylistVideoTrackByPeerID=Je,exports.selectVideoTrackByPeerID=Ue;
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("immer")),r=e(require("zustand/vanilla")),n=e(require("zustand/shallow")),i=require("@100mslive/hms-video"),o=require("reselect"),s=e(require("events"));function a(e,t,r,n,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,i)}function c(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function s(e){a(o,n,i,s,c,"next",e)}function c(e){a(o,n,i,s,c,"throw",e)}s(void 0)}))}}function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function d(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var p,f,h=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",s=n.toStringTag||"@@toStringTag";function a(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{a({},"")}catch(e){a=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var i=Object.create((t&&t.prototype instanceof d?t:d).prototype),o=new b(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var s=r.delegate;if(s){var a=k(s,r);if(a){if(a===l)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,o),i}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var l={};function d(){}function p(){}function f(){}var h={};a(h,i,(function(){return this}));var v=Object.getPrototypeOf,S=v&&v(v(R([])));S&&S!==t&&r.call(S,i)&&(h=S);var y=f.prototype=d.prototype=Object.create(h);function g(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){var n;this._invoke=function(i,o){function s(){return new t((function(n,s){!function n(i,o,s,a){var c=u(e[i],e,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,s,a)}),(function(e){n("throw",e,s,a)})):t.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,a)}))}a(c.arg)}(i,o,n,s)}))}return n=n?n.then(s,s):s()}}function k(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,k(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function b(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function R(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:E}}function E(){return{value:void 0,done:!0}}return p.prototype=f,a(y,"constructor",f),a(f,"constructor",p),p.displayName=a(f,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,a(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},g(m.prototype),a(m.prototype,o,(function(){return this})),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new m(c(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},g(y),a(y,s,"Generator"),a(y,i,(function(){return this})),a(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=R,b.prototype={constructor:b,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var a=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;x(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:R(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(f={exports:{}}),f.exports);(p=exports.HMSRoomState||(exports.HMSRoomState={})).Disconnected="Disconnected",p.Preview="Preview",p.Connecting="Connecting",p.Connected="Connected",p.Reconnecting="Reconnecting",p.Failed="Failed";var v,S,y,g=function(){return{room:{id:"",isConnected:!1,name:"",peers:[],shareableLink:"",localPeer:"",hasWaitingRoom:!1,roomState:exports.HMSRoomState.Disconnected,recording:{browser:{running:!1},server:{running:!1}},rtmp:{running:!1}},peers:{},tracks:{},playlist:{audio:{list:{},selection:{id:"",hasPrevious:!1,hasNext:!1},progress:0,volume:0,currentTime:0},video:{list:{},selection:{id:"",hasPrevious:!1,hasNext:!1},progress:0,volume:0,currentTime:0}},messages:{byID:{},allIDs:[]},speakers:{},settings:{audioInputDeviceId:"",audioOutputDeviceId:"",videoInputDeviceId:""},devices:{audioInput:[],audioOutput:[],videoInput:[]},roles:{},roleChangeRequests:[],errors:[]}};(exports.HMSMessageType||(exports.HMSMessageType={})).CHAT="chat",(v=exports.HMSNotificationSeverity||(exports.HMSNotificationSeverity={})).INFO="info",v.ERROR="error",v.CRITICAL="critical",(S=exports.HMSNotificationTypes||(exports.HMSNotificationTypes={})).PEER_JOINED="PEER_JOINED",S.PEER_LEFT="PEER_LEFT",S.NEW_MESSAGE="NEW_MESSAGE",S.ERROR="ERROR",S.RECONNECTING="RECONNECTING",S.RECONNECTED="RECONNECTED",S.TRACK_ADDED="TRACK_ADDED",S.TRACK_REMOVED="TRACK_REMOVED",S.TRACK_MUTED="TRACK_MUTED",S.TRACK_UNMUTED="TRACK_UNMUTED",S.ROLE_CHANGE_REQUEST="ROLE_CHANGE_REQUEST",S.ROLE_UPDATED="ROLE_UPDATED",S.CHANGE_TRACK_STATE_REQUEST="CHANGE_TRACK_STATE_REQUEST",S.CHANGE_MULTI_TRACK_STATE_REQUEST="CHANGE_MULTI_TRACK_STATE_REQUEST",S.ROOM_ENDED="ROOM_ENDED",S.REMOVED_FROM_ROOM="REMOVED_FROM_ROOM",S.DEVICE_CHANGE_UPDATE="DEVICE_CHANGE_UPDATE",(y=exports.HMSPlaylistType||(exports.HMSPlaylistType={})).audio="audio",y.video="video";var m=function(e,t){e.plugins&&b(e.plugins,t.plugins)&&(t.plugins=e.plugins),e.layerDefinitions&&b(e.layerDefinitions,t.layerDefinitions)&&(t.layerDefinitions=e.layerDefinitions)},k=function(e,t){return e&&t},T=function(e,t){return e&&!t},x=function(e,t){return!e&&t},b=function(e,t){if(e===t||0===e.length&&0===(null==t?void 0:t.length))return!0;if(!e||!t||e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0},R=function(e,t){for(var r,n=new Set,i=d(e);!(r=i()).done;)n.add(r.value);for(var o,s=d(t);!(o=s()).done;)n.add(o.value);return Array.from(n)};function E(e,t,r,n){e.isLocal&&e.videoTrack&&t.videoTrack&&e.videoTrack!==t.videoTrack&&(n[e.videoTrack]=n[t.videoTrack],delete n[t.videoTrack],r[e.videoTrack]=r[t.videoTrack],r[e.videoTrack].id=e.videoTrack,delete r[t.videoTrack],t.videoTrack=e.videoTrack)}var P=function(){function e(){}return e.convertPeer=function(e){var t,r,n;return{id:e.peerId,name:e.name,roleName:null==(t=e.role)?void 0:t.name,isLocal:e.isLocal,videoTrack:null==(r=e.videoTrack)?void 0:r.trackId,audioTrack:null==(n=e.audioTrack)?void 0:n.trackId,auxiliaryTracks:e.auxiliaryTracks.map((function(e){return e.trackId})),customerUserId:e.customerUserId,customerDescription:e.customerDescription}},e.convertTrack=function(e,t){var r={id:e.trackId,source:e.source,type:e.type,enabled:e.enabled,displayEnabled:e.enabled,peerId:e.peerId||t};return this.enrichTrack(r,e),r},e.enrichTrack=function(t,r){var n=r.getMediaTrackSettings();"screen"===t.source&&"video"===t.type&&(t.displaySurface=n.displaySurface),t.height=n.height,t.width=n.width,t.deviceID=n.deviceId,r instanceof i.HMSRemoteAudioTrack&&(t.volume=r.getVolume()||0),e.enrichVideoTrack(t,r),e.enrichPluginsDetails(t,r)},e.enrichVideoTrack=function(e,t){t instanceof i.HMSRemoteVideoTrack&&(e.layer=t.getSimulcastLayer(),e.degraded=t.degraded,b(t.getSimulcastDefinitions(),e.layerDefinitions)||(e.layerDefinitions=t.getSimulcastDefinitions()))},e.enrichPluginsDetails=function(e,t){(t instanceof i.HMSLocalVideoTrack||t instanceof i.HMSLocalAudioTrack)&&(b(t.getPlugins(),e.plugins)||(e.plugins=t.getPlugins()))},e.convertRoom=function(e){var t,r,n,i,o;return{id:e.id,name:e.name,localPeer:null!=(t=null==(r=e.localPeer)?void 0:r.peerId)?t:"",hasWaitingRoom:e.hasWaitingRoom,shareableLink:e.shareableLink,recording:{browser:{running:!(null==(n=e.recording)||!n.browser.running)},server:{running:!(null==(i=e.recording)||!i.server.running)}},rtmp:{running:!(null==(o=e.rtmp)||!o.running)}}},e.convertMessage=function(e){var t,r,n;return{sender:e.sender.peerId,senderName:e.sender.name,senderRole:null==(t=e.sender.role)?void 0:t.name,senderUserId:e.sender.customerUserId,recipientPeer:null==(r=e.recipientPeer)?void 0:r.peerId,recipientRoles:null==(n=e.recipientRoles)?void 0:n.map((function(e){return e.name})),time:e.time,type:e.type,message:e.message}},e.convertRoles=function(e){var t={};return e&&e.forEach((function(e){t[e.name]=e})),t},e.convertRoleChangeRequest=function(e){return{requestedBy:e.requestedBy.peerId,roleName:e.role.name,token:e.token}},e.convertException=function(e){return{code:e.code,action:e.action,name:e.name,message:e.message,description:e.description,isTerminal:e.isTerminal,nativeError:e.nativeError,timestamp:new Date}},e.convertDeviceChangeUpdate=function(e){var t={devices:e.devices,selection:e.selection,type:e.type};return e.error&&(t.error=this.convertException(e.error)),t},e.convertPlaylist=function(e){return{audio:this.getConvertedPlaylistType(e,exports.HMSPlaylistType.audio),video:this.getConvertedPlaylistType(e,exports.HMSPlaylistType.video)}},e.getConvertedPlaylistType=function(e,t){var r={},n=e.getCurrentSelection(t),i=e.getCurrentProgress(t),o=e.isPlaying(t),s=e.getVolume(t),a=e.getList(t),c=e.getCurrentIndex(t);return e.getList(t).forEach((function(e){var t=e.url===(null==n?void 0:n.url);r[e.id]=u({},e,{type:e.type,selected:t,playing:t&&o})})),{list:r,selection:{id:null==n?void 0:n.id,hasPrevious:c>0,hasNext:c<a.length-1},progress:i,volume:s,currentTime:e.getCurrentTime(t)}},e.convertRecordingRTMPState=function(e,t){var r,n;return{recording:{browser:{running:!(null==e||null==(r=e.browser)||!r.running)},server:{running:!(null==e||null==(n=e.server)||!n.running)}},rtmp:{running:!(null==t||!t.running)}}},e}();function M(e,t,r){void 0===r&&(r=D);var n=void 0,i=void 0;if(t)for(var o,s=d(t.auxiliaryTracks);!(o=s()).done;){var a=e[o.value];r(a)&&(i=I(a)?a:i,n=w(a)?a:n)}return{video:n,audio:i}}function I(e){return e&&"audio"===e.type}function w(e){return e&&"video"===e.type}function D(e){return e&&"screen"===e.source}function N(e){return e&&"videoplaylist"===e.source}function O(e){return Boolean(null==e?void 0:e.degraded)}function L(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].enabled}var A=function(e){return e.room},H=function(e){return e.peers},C=function(e){return e.messages.byID},_=function(e){return e.messages.allIDs},U=function(e){return e.tracks},V=function(e){return e.settings},K=function(e){return e.speakers},q=o.createSelector([A],(function(e){return e&&e.isConnected})),B=o.createSelector(A,(function(e){return e.peers.length})),j=o.createSelector([A,H],(function(e,t){return e.peers.map((function(e){return t[e]}))})),F=o.createSelector(U,(function(e){return Object.values(e)})),G=o.createSelector(A,H,(function(e,t){return t[e.localPeer]})),J=o.createSelector(A,(function(e){return e.localPeer})),W=o.createSelector(G,(function(e){return null==e?void 0:e.audioTrack})),Q=o.createSelector(G,(function(e){return null==e?void 0:e.videoTrack})),X=o.createSelector([W,Q,o.createSelector(G,(function(e){return null==e?void 0:e.auxiliaryTracks}))],(function(e,t,r){var n=[].concat(r);return e&&n.unshift(e),t&&n.unshift(t),n})),Y=o.createSelector(j,(function(e){return e.filter((function(e){return!e.isLocal}))})),z=o.createSelector(H,K,(function(e,t){var r=Object.entries(t).sort((function(e,t){var r,n,i=(null==(r=e[1])?void 0:r.audioLevel)||0;return((null==(n=t[1])?void 0:n.audioLevel)||0)>i?1:-1}));if(r.length>0&&r[0][1].audioLevel&&r[0][1].audioLevel>0){var n=r[0][1].peerID;if(n in e)return e[n]}return null})),$=function(e){var t=G(e);return L(e,null==t?void 0:t.videoTrack)},Z=function(e){var t=G(e);return function(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].displayEnabled}(e,null==t?void 0:t.videoTrack)},ee=o.createSelector(G,U,(function(e,t){var r=M(t,e);return!(!r.video&&!r.audio)})),te=o.createSelector(H,U,(function(e,t){var r=void 0;for(var n in e){var i=e[n],o=M(t,i);if(o.video)return i;o.audio&&!r&&(r=i)}return r})),re=o.createSelector(te,(function(e){return!!e})),ne=o.createSelector(H,U,(function(e,t){for(var r in e){var n=e[r],i=M(t,n);if(!i.video&&i.audio)return n}})),ie=o.createSelector(H,U,(function(e,t){var r=[],n=[];for(var i in e){var o=e[i],s=M(t,o),a=s.audio;s.video?r.push(o):a&&n.push(o)}return r.concat(n)})),oe=o.createSelector(H,U,(function(e,t){for(var r in e){var n=e[r];if(M(t,n,N).video)return n}})),se=o.createSelector(F,(function(e){return e.filter(O)})),ae=o.createSelector(_,(function(e){return e.length})),ce=o.createSelector(C,(function(e){return Object.values(e).filter((function(e){return!e.read})).length})),ue=o.createSelector(_,C,(function(e,t){var r=[];return e.forEach((function(e){r.push(t[e])})),r})),le=o.createSelector([A],(function(e){return e&&e.roomState})),de=o.createSelector(le,(function(e){return e===exports.HMSRoomState.Preview})),pe=o.createSelector(A,(function(e){return e.roomState!==exports.HMSRoomState.Disconnected})),fe=function(e){return e.roles},he=o.createSelector([fe],(function(e){return Object.keys(e)})),ve=o.createSelector([G,fe],(function(e,t){return null!=e&&e.roleName?t[e.roleName]:null})),Se=o.createSelector([ve],(function(e){var t;return!(null==e||null==(t=e.subscribeParams)||!t.subscribeToRoles)&&e.subscribeParams.subscribeToRoles.length>0})),ye=o.createSelector(ve,(function(e){return null==e?void 0:e.permissions})),ge=o.createSelector(A,(function(e){return e.recording})),me=o.createSelector(A,(function(e){return e.rtmp})),ke=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].list}},Te=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].selection}},xe=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].progress}},be=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].currentTime}},Re=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].volume}},Ee=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),o.createSelector(ke(e),(function(e){return Object.values(e)}))},Pe=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),o.createSelector(ke(e),Te(e),(function(e,t){if(t.id)return e[t.id]}))},Me={selection:Te(exports.HMSPlaylistType.audio),progress:xe(exports.HMSPlaylistType.audio),currentTime:be(exports.HMSPlaylistType.audio),volume:Re(exports.HMSPlaylistType.audio),list:Ee(exports.HMSPlaylistType.audio),selectedItem:Pe(exports.HMSPlaylistType.audio)},Ie={selection:Te(exports.HMSPlaylistType.video),progress:xe(exports.HMSPlaylistType.video),currentTime:be(exports.HMSPlaylistType.audio),volume:Re(exports.HMSPlaylistType.video),list:Ee(exports.HMSPlaylistType.video),selectedItem:Pe(exports.HMSPlaylistType.video)},we="HMS-Store:",De=function(){function e(){}return e.v=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.log.apply(this,[i.HMSLogLevel.VERBOSE,e].concat(r))},e.d=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log.apply(this,[i.HMSLogLevel.DEBUG].concat(t))},e.i=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log.apply(this,[i.HMSLogLevel.INFO].concat(t))},e.w=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log.apply(this,[i.HMSLogLevel.WARN].concat(t))},e.e=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log.apply(this,[i.HMSLogLevel.ERROR].concat(t))},e.log=function(e){if(!(this.level.valueOf()>e.valueOf())){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];switch(e){case i.HMSLogLevel.VERBOSE:var o;(o=console).log.apply(o,[we].concat(r));break;case i.HMSLogLevel.DEBUG:var s;(s=console).debug.apply(s,[we].concat(r));break;case i.HMSLogLevel.INFO:var a;(a=console).info.apply(a,[we].concat(r));break;case i.HMSLogLevel.WARN:var c;(c=console).warn.apply(c,[we].concat(r));break;case i.HMSLogLevel.ERROR:var u;(u=console).error.apply(u,[we].concat(r))}}},e}();function Ne(e){return function(t){return function(r){return e(r,t)}}}De.level=i.HMSLogLevel.VERBOSE;var Oe=function(e,t){return t},Le=function(e,t){return t},Ae=o.createSelector([H,Oe],(function(e,t){return t?e[t]:null})),He=o.createSelector([U,function(e,t){return t}],(function(e,t){return t?e[t]:null})),Ce=Ne(Ae),_e=Ne(o.createSelector(Ae,(function(e){return null==e?void 0:e.name}))),Ue=Ne(He),Ve=Ne((function(e,t){var r=Ae(e,t);if(r&&r.videoTrack&&""!==r.videoTrack)return e.tracks[r.videoTrack]})),Ke=Ne((function(e,t){var r=Ae(e,t);if(r&&r.audioTrack&&""!==r.audioTrack)return e.tracks[r.audioTrack]})),qe=Ve,Be=Ne((function(e,t){var r=Ae(e,t);return(null==r?void 0:r.auxiliaryTracks.map((function(t){return e.tracks[t]})))||[]})),je=function(e,t){return t?e.speakers[t]:null},Fe=Ne(o.createSelector(je,(function(e){return(null==e?void 0:e.audioLevel)||0}))),Ge=Ne(o.createSelector((function(e,t){var r=Ke(t)(e);return je(e,null==r?void 0:r.id)}),(function(e){return(null==e?void 0:e.audioLevel)||0}))),Je=Ne((function(e,t){var r=Ae(e,t);if(r){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){return I(e.tracks[t])}));return n?e.tracks[n]:void 0}})),We=Ne(o.createSelector(U,Ae,(function(e,t){var r=null==t?void 0:t.auxiliaryTracks.find((function(t){var r=e[t];return N(r)&&w(r)}));return r?e[r]:void 0}))),Qe=Ne(o.createSelector(U,Ae,(function(e,t){var r=null==t?void 0:t.auxiliaryTracks.find((function(t){var r=e[t];return N(r)&&I(r)}));return r?e[r]:void 0}))),Xe=Ne(o.createSelector(U,Ae,(function(e,t){var r=null==t?void 0:t.auxiliaryTracks.find((function(t){var r=e[t];return function(e){return e&&"audioplaylist"===e.source}(r)&&I(r)}));return r?e[r]:void 0}))),Ye=Ne(o.createSelector(U,Ae,(function(e,t){return M(e,t)}))),ze=function(e){return o.createSelector(Ye(e),(function(e){return e.audio}))},$e=Ne((function(e,t){var r=Ae(e,t);return L(e,null==r?void 0:r.audioTrack)})),Ze=Ne((function(e,t){var r=Ae(e,t);return L(e,null==r?void 0:r.videoTrack)})),et=Ne((function(e,t){if(t&&e.tracks[t])return 0===e.tracks[t].volume})),tt=Ne((function(e,t){var r=Ae(e,t);return et(null==r?void 0:r.audioTrack)(e)})),rt=Ne((function(e,t){var r=ze(t)(e);return et(null==r?void 0:r.id)(e)})),nt=Ne((function(e,t){var r=He(e,t);if(r)return"audio"!==r.type?void De.w("Please pass audio track here"):r.volume})),it=Ne((function(e,t){var r=Ae(e,t);return nt(null==r?void 0:r.audioTrack)(e)})),ot=Ne((function(e,t){var r=ze(t)(e);return nt(null==r?void 0:r.id)(e)})),st=Ne((function(e,t){var r=He(e,t);if(r)return"video"!==r.type?void De.w("Please pass video track here"):r.layer})),at=o.createSelector([ue,J,Oe],(function(e,t,r){if(r)return e.filter((function(e){var n;return!!(e.recipientPeer||null!=(n=e.recipientRoles)&&n.length)&&!![t,r].includes(e.sender)&&[t,r].includes(e.recipientPeer)}))})),ct=o.createSelector([ue,Le],(function(e,t){if(t)return e.filter((function(e){var r,n;return!(null==(r=e.recipientRoles)||!r.length)&&(null==(n=e.recipientRoles)?void 0:n.includes(t))}))})),ut=o.createSelector(ue,(function(e){return e.filter((function(e){var t;return!(e.recipientPeer||null!=(t=e.recipientRoles)&&t.length)}))})),lt=o.createSelector([ct,Le],(function(e){return e?e.filter((function(e){return!e.read})).length:0})),dt=o.createSelector([at,Oe],(function(e){return e?e.filter((function(e){return!e.read})).length:0})),pt=o.createSelector(ut,(function(e){return e.filter((function(e){return!e.read})).length})),ft=Ne(at),ht=Ne(ct),vt=Ne(lt),St=Ne(dt),yt=o.createSelector([H,U],(function(e,t){return Object.values(e).map((function(e){var r;return{peer:e,isAudioEnabled:!!e.audioTrack&&(null==(r=t[e.audioTrack])?void 0:r.enabled)}}))})),gt=o.createSelector([function(e){return e.roleChangeRequests[0]||null},H,fe],(function(e,t,r){return e?{requestedBy:t[e.requestedBy],role:r[e.roleName],token:e.token}:null})),mt=o.createSelector([ve],(function(e){var t,r=!1,n=!1,i=!1;return null!=e&&null!=(t=e.publishParams)&&t.allowed&&(r=e.publishParams.allowed.includes("video"),n=e.publishParams.allowed.includes("audio"),i=e.publishParams.allowed.includes("screen")),{video:r,audio:n,screen:i}})),kt=o.createSelector([Q,U],(function(e,t){var r,n=null;return e&&(n=t[e]),(null==(r=n)?void 0:r.plugins)||[]})),Tt=o.createSelector([W,U],(function(e,t){var r,n=null;return e&&(n=t[e]),(null==(r=n)?void 0:r.plugins)||[]}));function xt(e){return e instanceof i.HMSRemoteAudioTrack||e instanceof i.HMSRemoteVideoTrack}var bt,Rt,Et=function(){function e(e,t,r,n){this.playlistManager=e,this.syncPlaylistState=r,this.store=n,this.type=t}var t=e.prototype;return t.play=function(){var e=c(h.mark((function e(t){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return De.w("Please pass id to play"),e.abrupt("return");case 3:return e.next=5,this.playlistManager.setEnabled(!0,{id:t,type:this.type});case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.pause=function(){var e=c(h.mark((function e(){var t,r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.type===exports.HMSPlaylistType.audio?Me:Ie,(r=this.store.getState(t.selection)).id){e.next=5;break}return De.w("No item is currently playing to pause"),e.abrupt("return");case 5:return e.next=7,this.playlistManager.setEnabled(!1,{id:r.id,type:this.type});case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.playNext=function(){var e=c(h.mark((function e(){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.playlistManager.playNext(this.type);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.playPrevious=function(){var e=c(h.mark((function e(){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.playlistManager.playPrevious(this.type);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.seek=function(e){this.playlistManager.seek(e,this.type),this.syncPlaylistState("seekOn"+this.type+"Playlist")},t.seekTo=function(e){this.playlistManager.seekTo(e,this.type),this.syncPlaylistState("seekToOn"+this.type+"Playlist")},t.setVolume=function(e){this.playlistManager.setVolume(e,this.type),this.syncPlaylistState("setVolumeOn"+this.type+"Playlist")},t.setList=function(e){this.playlistManager.setList(e),this.syncPlaylistState("setListOn"+this.type+"Playlist")},t.stop=function(){var e=c(h.mark((function e(){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.playlistManager.stop(this.type);case 2:this.syncPlaylistState("stop"+this.type+"Playlist");case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),e}(),Pt=function(){function e(e,t,r){var n=this;this.hmsSDKTracks={},this.hmsSDKPeers={},this.isRoomJoinCalled=!1,this.setProgress=function(e){var t=e.type,r=e.progress;n.setState((function(e){e.playlist[t].progress=r,e.playlist[t].currentTime=n.sdk.getPlaylistManager().getCurrentTime(t)}),"playlistProgress")},this.syncPlaylistState=function(e){n.setState((function(e){Object.assign(e.playlist,P.convertPlaylist(n.sdk.getPlaylistManager()))}),e)},this.syncRemoteTrackState=function(e,t,r){n.setState((function(i){var o=i.peers[r.peerId];if(!o){var s=P.convertPeer(r);i.peers[r.peerId]=s,o=s}var a=P.convertTrack(t,r.peerId);"trackAdded"===e?(i.tracks[a.id]=a,n.updateTracksInPeer(r,o,a)):i.tracks[a.id]?Object.assign(i.tracks[a.id],a):n.logPossibleInconsistency("track "+a.id+" not present, unable to update track"),n.hmsSDKTracks[t.trackId]=t}),e)},this.setState=function(e,t){return n.store.namedSetState(e,t)},this.store=e,this.sdk=t,this.hmsNotifications=r}var t=e.prototype;return t.unblockAudio=function(){var e=c(h.mark((function e(){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.getAudioOutput().unblockAutoplay();case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.setVolume=function(e,t){t?this.setTrackVolume(e,t):(this.sdk.getAudioOutput().setVolume(e),this.syncRoomState("setOutputVolume"))},t.setAudioOutputDevice=function(e){this.sdk.getAudioOutput().setDevice(e)&&this.setState((function(t){t.settings.audioOutputDeviceId=e}),"setAudioOutputDevice")},t.setPreferredLayer=function(e,t){var r=this.hmsSDKTracks[e];r?r instanceof i.HMSRemoteVideoTrack?(r.preferLayer(t),this.updateVideoLayer(e,"setPreferredLayer")):De.w("track "+e+" is not an video track"):this.logPossibleInconsistency("track "+e+" not present, unable to set preffer layer")},t.preview=function(){var e=c(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isRoomJoinCalled){e.next=3;break}return this.logPossibleInconsistency("attempting to call preview after join was called"),e.abrupt("return");case 3:if((r=this.store.getState(le))!==exports.HMSRoomState.Preview&&r!==exports.HMSRoomState.Connecting){e.next=7;break}return this.logPossibleInconsistency("attempting to call preview while room is in preview/connecting"),e.abrupt("return");case 7:return e.prev=7,e.next=10,this.sdkPreviewWithListeners(t);case 10:this.setState((function(e){e.room.roomState=exports.HMSRoomState.Connecting}),"preview"),e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(7),De.e("Cannot show preview. Failed to connect to room - ",e.t0),e.t0;case 17:case"end":return e.stop()}}),e,this,[[7,13]])})));return function(t){return e.apply(this,arguments)}}(),t.join=function(e){if(this.isRoomJoinCalled)this.logPossibleInconsistency("room join is called again");else try{this.sdkJoinWithListeners(e),this.isRoomJoinCalled=!0,this.setState((function(e){e.room.roomState=exports.HMSRoomState.Connecting}),"join")}catch(e){throw this.isRoomJoinCalled=!1,De.e("Failed to connect to room - ",e),e}},t.leave=function(){var e=c(h.mark((function e(){var t=this;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.store.getState(pe)){e.next=4;break}return this.logPossibleInconsistency("room leave is called when no room is connected"),e.abrupt("return");case 4:return e.abrupt("return",this.sdk.leave().then((function(){t.resetState("leave"),De.i("left room")})).catch((function(e){De.e("error in leaving room - ",e)})));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.setScreenShareEnabled=function(){var e=c(h.mark((function e(t,r){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=5;break}return e.next=3,this.startScreenShare(r);case 3:e.next=7;break;case 5:return e.next=7,this.stopScreenShare();case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.addTrack=function(){var e=c(h.mark((function e(t,r){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r="regular"),e.next=3,this.sdk.addTrack(t,r);case 3:this.syncRoomState("addTrack");case 4:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.removeTrack=function(){var e=c(h.mark((function e(t){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.removeTrack(t);case 2:this.syncRoomState("removeTrack");case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setLocalAudioEnabled=function(){var e=c(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(W))){e.next=4;break}return e.next=4,this.setEnabledTrack(r,t);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setLocalVideoEnabled=function(){var e=c(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(Q))){e.next=4;break}return e.next=4,this.setEnabledTrack(r,t);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setEnabledTrack=function(){var e=c(h.mark((function e(t,r){var n,o=this;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((null==(n=this.store.getState().tracks[t])?void 0:n.enabled)!==r){e.next=4;break}return this.logPossibleInconsistency("local track["+t+"] enabled state - "+r),e.abrupt("return");case 4:return this.setState((function(e){e.tracks[t]?e.tracks[t].displayEnabled=r:o.logPossibleInconsistency("track id not found for setEnabled")}),"displayEnabled"),e.prev=5,e.next=8,this.setEnabledSDKTrack(t,r);case 8:this.syncRoomState("setEnabled"),e.next=16;break;case 11:throw e.prev=11,e.t0=e.catch(5),this.setState((function(e){e.tracks[t].displayEnabled=!r}),"rollbackDisplayEnabled"),this.hmsNotifications.sendError(P.convertException(e.t0)),e.t0;case 16:this.hmsNotifications.sendTrackUpdate(r?i.HMSTrackUpdate.TRACK_UNMUTED:i.HMSTrackUpdate.TRACK_MUTED,t);case 18:case"end":return e.stop()}}),e,this,[[5,11]])})));return function(t,r){return e.apply(this,arguments)}}(),t.setAudioSettings=function(){var e=c(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(W))){e.next=5;break}return e.next=4,this.setSDKLocalAudioTrackSettings(r,t);case 4:this.syncRoomState("setAudioSettings");case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setVideoSettings=function(){var e=c(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(Q))){e.next=5;break}return e.next=4,this.setSDKLocalVideoTrackSettings(r,t);case 4:this.syncRoomState("setVideoSettings");case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.sendMessage=function(e){this.sendBroadcastMessage(e)},t.sendBroadcastMessage=function(){var e=c(h.mark((function e(t,r){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.sendBroadcastMessage(t,r);case 2:this.updateMessageInStore(e.sent,{message:t,type:r});case 4:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.sendGroupMessage=function(){var e=c(h.mark((function e(t,r,n){var i,o;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=this.store.getState(fe),o=r.map((function(e){return i[e]})),e.next=4,this.sdk.sendGroupMessage(t,o,n);case 4:this.updateMessageInStore(e.sent,{message:t,recipientRoles:r,type:n});case 6:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t.sendDirectMessage=function(){var e=c(h.mark((function e(t,r,n){var i;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=this.hmsSDKPeers[r],e.next=3,this.sdk.sendDirectMessage(t,i);case 3:this.updateMessageInStore(e.sent,{message:t,recipientPeer:i.peerId,type:n});case 5:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t.updateMessageInStore=function(e,t){if(!e)throw De.w("sendMessage","Failed to send message",t),Error("sendMessage Failed - "+JSON.stringify(t));var r=P.convertMessage(e);return r.read=!0,r.senderName="You",this.onHMSMessage(r),r},t.setMessageRead=function(e,t){var r=this;this.setState((function(n){t?n.messages.byID[t]?n.messages.byID[t].read=e:r.logPossibleInconsistency("no message with id is found"):n.messages.allIDs.forEach((function(t){n.messages.byID[t].read=e}))}),"setMessageRead")},t.attachVideo=function(){var e=c(h.mark((function e(t,r){var n=this;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localAndVideoUnmuting(t)){e.next=4;break}return e.abrupt("return",new Promise((function(e){var i=n.store.subscribe(function(){var o=c(h.mark((function o(s){return h.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(!s){o.next=5;break}return o.next=3,n.attachVideoInternal(t,r);case 3:i(),e();case 5:case"end":return o.stop()}}),o)})));return function(e){return o.apply(this,arguments)}}(),$)})));case 4:return e.next=6,this.attachVideoInternal(t,r);case 6:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.detachVideo=function(){var e=c(h.mark((function e(t,r){var n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])||"video"!==n.type){e.next=7;break}return e.next=4,n.removeSink(r);case 4:this.updateVideoLayer(t,"detachVideo"),e.next=8;break;case 7:this.logPossibleInconsistency("no video track found to remove sink");case 8:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.addPluginToVideoTrack=function(){var e=c(h.mark((function e(t,r){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.addRemoveVideoPlugin(t,"add",r));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.addPluginToAudioTrack=function(){var e=c(h.mark((function e(t){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.addRemoveAudioPlugin(t,"add"));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.removePluginFromVideoTrack=function(){var e=c(h.mark((function e(t){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.addRemoveVideoPlugin(t,"remove"));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.removePluginFromAudioTrack=function(){var e=c(h.mark((function e(t){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.addRemoveAudioPlugin(t,"remove"));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.changeRole=function(){var e=c(h.mark((function e(t,r,n){var i;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===n&&(n=!1),i=this.hmsSDKPeers[t]){e.next=5;break}return this.logPossibleInconsistency("Unknown peer ID given "+t+" for changerole"),e.abrupt("return");case 5:return e.next=7,this.sdk.changeRole(i,r,n);case 7:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t.acceptChangeRole=function(){var e=c(h.mark((function e(t){var r,n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=t.requestedBy?this.hmsSDKPeers[t.requestedBy.id]:void 0)||De.w("peer for which role change is requested no longer available - "+t.requestedBy),n={requestedBy:r,role:t.role,token:t.token},e.next=5,this.sdk.acceptChangeRole(n);case 5:this.removeRoleChangeRequest(t);case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.rejectChangeRole=function(e){this.removeRoleChangeRequest(e)},t.endRoom=function(){var e=c(h.mark((function e(t,r){var n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(n=this.store.getState(ye))&&n.endRoom){e.next=4;break}return De.w("You are not allowed to perform this action - endRoom"),e.abrupt("return");case 4:return e.next=6,this.sdk.endRoom(t,r);case 6:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.removePeer=function(){var e=c(h.mark((function e(t,r){var n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKPeers[t])||n.isLocal){e.next=6;break}return e.next=4,this.sdk.removePeer(n,r);case 4:e.next=8;break;case 6:return this.logPossibleInconsistency("No remote peer found for peerID - "+t),e.abrupt("return");case 8:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.startRTMPOrRecording=function(){var e=c(h.mark((function e(t){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.startRTMPOrRecording(t);case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.stopRTMPAndRecording=function(){var e=c(h.mark((function e(){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.stopRTMPAndRecording();case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.setRemoteTrackEnabled=function(){var e=c(h.mark((function e(t,r){var n,i=this;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t){e.next=10;break}if(!(n=this.hmsSDKTracks[t])||!xt(n)){e.next=7;break}return e.next=5,this.sdk.changeTrackState(n,r);case 5:e.next=8;break;case 7:this.logPossibleInconsistency("No remote track with ID "+t+" found for change track state");case 8:e.next=11;break;case 10:Array.isArray(t)&&t.forEach((function(e){return i.setRemoteTrackEnabled(e,r)}));case 11:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setRemoteTracksEnabled=function(){var e=c(h.mark((function e(t){var r,n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={enabled:t.enabled,type:t.type,source:t.source},t.roles&&(n=this.store.getState(fe),r.roles=t.roles.map((function(e){return n[e]}))),e.next=4,this.sdk.changeMultiTrackState(r);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setLogLevel=function(e){De.level=e,this.sdk.setLogLevel(e)},t.resetState=function(e){void 0===e&&(e="resetState"),this.setState((function(e){Object.assign(e,g())}),e),this.isRoomJoinCalled=!1,this.hmsSDKTracks={}},t.sdkJoinWithListeners=function(e){this.sdk.join(e,{onJoin:this.onJoin.bind(this),onRoomUpdate:this.onRoomUpdate.bind(this),onPeerUpdate:this.onPeerUpdate.bind(this),onTrackUpdate:this.onTrackUpdate.bind(this),onMessageReceived:this.onMessageReceived.bind(this),onError:this.onError.bind(this),onReconnected:this.onReconnected.bind(this),onReconnecting:this.onReconnecting.bind(this),onRoleChangeRequest:this.onRoleChangeRequest.bind(this),onRoleUpdate:this.onRoleUpdate.bind(this),onDeviceChange:this.onDeviceChange.bind(this),onChangeTrackStateRequest:this.onChangeTrackStateRequest.bind(this),onChangeMultiTrackStateRequest:this.onChangeMultiTrackStateRequest.bind(this),onRemovedFromRoom:this.onRemovedFromRoom.bind(this)}),this.sdk.addAudioListener({onAudioLevelUpdate:this.onAudioLevelUpdate.bind(this)})},t.onRemovedFromRoom=function(e){var t=this.store.getState(Ce(e.requestedBy.peerId));t?(this.hmsNotifications.sendLeaveRoom(u({},e,{requestedBy:t})),De.i("resetting state after peer removed",e),this.resetState(e.roomEnded?"roomEnded":"removedFromRoom")):this.logPossibleInconsistency("Not found peer who requested leave room, "+e.requestedBy)},t.onDeviceChange=function(e){var t=this,r=e.devices;if(r){var n=this.store.getState(G);if(this.setState((function(e){b(e.devices.audioInput,r.audioInput)||(e.devices.audioInput=r.audioInput),b(e.devices.videoInput,r.videoInput)||(e.devices.videoInput=r.videoInput),b(e.devices.audioOutput,r.audioOutput)||(e.devices.audioOutput=r.audioOutput),t.hmsSDKPeers[null==n?void 0:n.id]&&Object.assign(e.settings,t.getMediaSettings(t.hmsSDKPeers[null==n?void 0:n.id]))}),"deviceChange"),e.selection){var i=P.convertDeviceChangeUpdate(e);this.hmsNotifications.sendDeviceChange(i)}}},t.sdkPreviewWithListeners=function(){var e=c(h.mark((function e(t){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.preview(t,{onPreview:this.onPreview.bind(this),onError:this.onError.bind(this),onDeviceChange:this.onDeviceChange.bind(this)});case 2:this.sdk.addAudioListener({onAudioLevelUpdate:this.onAudioLevelUpdate.bind(this)});case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.startScreenShare=function(){var e=c(h.mark((function e(t){var r=this;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.store.getState(ee)){e.next=7;break}return e.next=4,this.sdk.startScreenShare((function(){return r.syncRoomState("screenshareStopped")}),t);case 4:this.syncRoomState("startScreenShare"),e.next=8;break;case 7:this.logPossibleInconsistency("start screenshare is called while it's on");case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.stopScreenShare=function(){var e=c(h.mark((function e(){return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.store.getState(ee)){e.next=7;break}return e.next=4,this.sdk.stopScreenShare();case 4:this.syncRoomState("stopScreenShare"),e.next=8;break;case 7:this.logPossibleInconsistency("stop screenshare is called while it's not on");case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.attachVideoInternal=function(){var e=c(h.mark((function e(t,r){var n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])||"video"!==n.type){e.next=7;break}return e.next=4,n.addSink(r);case 4:this.updateVideoLayer(t,"attachVideo"),e.next=8;break;case 7:this.logPossibleInconsistency("no video track found to add sink");case 8:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.syncRoomState=function(e){var t=this;console.time("syncRoomState");for(var r,n={},i=[],o={},s={},a={},c=d(this.sdk.getPeers());!(r=c()).done;){var u=r.value,l=P.convertPeer(u);n[l.id]=l,i.push(l.id),this.hmsSDKPeers[l.id]=u;for(var p,f=d([u.audioTrack,u.videoTrack].concat(u.auxiliaryTracks));!(p=f()).done;){var h=p.value;if(h){var v=P.convertTrack(h);o[v.id]=v,s[h.trackId]=h}}l.isLocal&&Object.assign(a,this.getMediaSettings(u))}var S=this.sdk.getRecordingState(),y=this.sdk.getRTMPState();this.setState((function(e){e.room.peers=i;var r=e.tracks;!function(e,t,r,n){for(var i,o=d(R(Object.keys(e),Object.keys(t)));!(i=o()).done;){var s=i.value,a=e[s],c=t[s];k(a,c)?(b(a.auxiliaryTracks,c.auxiliaryTracks)&&(c.auxiliaryTracks=a.auxiliaryTracks),E(a,c,r,n),Object.assign(a,c)):T(a,c)?delete e[s]:x(a,c)&&(e[s]=c)}}(e.peers,n,o,s),function(e,t){for(var r,n=d(R(Object.keys(e),Object.keys(t)));!(r=n()).done;){var i=r.value,o=e[i],s=t[i];k(o,s)?(m(o,s),Object.assign(o,s)):T(o,s)?delete e[i]:x(o,s)&&(e[i]=s)}}(r,o),Object.assign(e.settings,a),t.hmsSDKTracks=s,Object.assign(e.roles,P.convertRoles(t.sdk.getRoles())),Object.assign(e.playlist,P.convertPlaylist(t.sdk.getPlaylistManager())),Object.assign(e.room,P.convertRecordingRTMPState(S,y))}),e),console.timeEnd("syncRoomState")},t.onPreview=function(e){this.setState((function(t){Object.assign(t.room,P.convertRoom(e)),t.room.roomState=exports.HMSRoomState.Preview}),"previewStart"),this.syncRoomState("previewSync")},t.onJoin=function(e){var t=this;this.audioPlaylist=new Et(this.sdk.getPlaylistManager(),exports.HMSPlaylistType.audio,this.syncPlaylistState.bind(this),this.store),this.videoPlaylist=new Et(this.sdk.getPlaylistManager(),exports.HMSPlaylistType.video,this.syncRoomState.bind(this),this.store),this.syncRoomState("joinSync"),this.setState((function(t){Object.assign(t.room,P.convertRoom(e)),t.room.isConnected=!0,t.room.roomState=exports.HMSRoomState.Connected}),"joined"),this.sdk.getPlaylistManager().onProgress(this.setProgress),this.sdk.getPlaylistManager().onNewTrackStart((function(e){t.syncPlaylistState(e.type+"PlaylistUpdate")})),this.sdk.getPlaylistManager().onPlaylistEnded((function(e){t.syncPlaylistState(e+"PlaylistEnded")}))},t.onRoomUpdate=function(e,t){this.setState((function(e){Object.assign(e.room,P.convertRoom(t))}),"RoomUpdate")},t.onPeerUpdate=function(e,t){if(e!==i.HMSPeerUpdate.BECAME_DOMINANT_SPEAKER&&e!==i.HMSPeerUpdate.RESIGNED_DOMINANT_SPEAKER)if(Array.isArray(t)){this.syncRoomState("peersJoined");for(var r,n=d(t);!(r=n()).done;){var o=this.store.getState(Ce(r.value.peerId));this.hmsNotifications.sendPeerUpdate(e,o)}}else this.peerUpdateInternal(e,t)},t.onTrackUpdate=function(e,t,r){e===i.HMSTrackUpdate.TRACK_REMOVED?(this.hmsNotifications.sendTrackUpdate(e,t.trackId),this.handleTrackRemove(t,r)):(this.syncRemoteTrackState(e===i.HMSTrackUpdate.TRACK_ADDED?"trackAdded":"trackUpdate",t,r),this.hmsNotifications.sendTrackUpdate(e,t.trackId))},t.onMessageReceived=function(e){var t=P.convertMessage(e);t.read=!1,this.onHMSMessage(t),this.hmsNotifications.sendMessageReceived(t)},t.onHMSMessage=function(e){var t=this;this.setState((function(r){e.id=String(t.store.getState(ae)+1),r.messages.byID[e.id]=e,r.messages.allIDs.push(e.id)}),"newMessage")},t.onAudioLevelUpdate=function(e){this.setState((function(t){var r={};e.forEach((function(e){if(e.track&&e.peer){var n=e.track.trackId;r[n]=e.audioLevel,t.speakers[n]||(t.speakers[n]={audioLevel:e.audioLevel,peerID:e.peer.peerId,trackID:n})}}));for(var n=0,i=Object.entries(t.speakers);n<i.length;n++){var o=i[n],s=o[0],a=o[1];a.audioLevel=r[s]||0,0===a.audioLevel&&delete t.speakers[s]}}),"audioLevel")},t.onChangeTrackStateRequest=function(e){var t=this.store.getState(Ce(e.requestedBy.peerId)),r=this.getStoreLocalTrackIDfromSDKTrack(e.track),n=this.store.getState(Ue(r));return t?n?(e.enabled||this.syncRoomState("changeTrackStateRequest"),void this.hmsNotifications.sendChangeTrackStateRequest({requestedBy:t,track:n,enabled:e.enabled})):this.logPossibleInconsistency("Not found track for which track state change was requested, "+e.track):this.logPossibleInconsistency("Not found peer who requested track state change, "+e.requestedBy)},t.onChangeMultiTrackStateRequest=function(e){var t=this.store.getState(Ce(e.requestedBy.peerId));if(!t)return this.logPossibleInconsistency("Not found peer who requested track state change, "+e.requestedBy);e.enabled||this.syncRoomState("changeMultiTrackStateRequest");for(var r,n=[],i=this.store.getState(U),o=d(e.tracks);!(r=o()).done;){var s=this.getStoreLocalTrackIDfromSDKTrack(r.value);s&&i[s]&&n.push(i[s])}this.hmsNotifications.sendChangeMultiTrackStateRequest({requestedBy:t,tracks:n,enabled:e.enabled,type:e.type,source:e.source})},t.onReconnected=function(){this.syncRoomState("reconnectedSync"),this.hmsNotifications.sendReconnected(),this.setState((function(e){e.room.roomState=exports.HMSRoomState.Connected}),"reconnected")},t.onReconnecting=function(e){var t=P.convertException(e);De.e("Reconnection: received error from sdk",t),this.hmsNotifications.sendReconnecting(t),this.setState((function(e){e.room.roomState=exports.HMSRoomState.Reconnecting,e.errors.push(t)}),"reconnecting")},t.onError=function(e){var t=P.convertException(e);t.isTerminal?(this.leave().then((function(){return console.log("error from SDK, left room.")})),this.setState((function(e){e.room.roomState=exports.HMSRoomState.Failed,e.errors.push(t)}),"errorTerminal")):this.store.getState().errors.length<50&&this.setState((function(e){e.errors.push(t)}),"error"),this.hmsNotifications.sendError(t),De.e("received error from sdk",t)},t.updateVideoLayer=function(e,t){var r=this.hmsSDKTracks[e];r&&r instanceof i.HMSRemoteVideoTrack&&this.setState((function(t){t.tracks[e].layer=r.getSimulcastLayer()}),t)},t.handleTrackRemove=function(e,t){var r=this;this.setState((function(n){var i=n.peers[t.peerId],o=n.tracks;if(r.isSameStoreSDKTrack(e.trackId,null==i?void 0:i.audioTrack))null==i||delete i.audioTrack;else if(r.isSameStoreSDKTrack(e.trackId,null==i?void 0:i.videoTrack))null==i||delete i.videoTrack;else{var s=null==i?void 0:i.auxiliaryTracks.indexOf(e.trackId);s>-1&&r.isSameStoreSDKTrack(e.trackId,null==i?void 0:i.auxiliaryTracks[s])&&(null==i||i.auxiliaryTracks.splice(s,1))}delete o[e.trackId],delete r.hmsSDKTracks[e.trackId]}),"trackRemoved")},t.setEnabledSDKTrack=function(){var e=c(h.mark((function e(t,r){var n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setEnabled(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("track "+t+" not present, unable to enabled/disable");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setSDKLocalVideoTrackSettings=function(){var e=c(h.mark((function e(t,r){var n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setSettings(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("local track "+t+" not present, unable to set settings");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setSDKLocalAudioTrackSettings=function(){var e=c(h.mark((function e(t,r){var n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setSettings(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("local track "+t+" not present, unable to set settings");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.getMediaSettings=function(e){var t,r,n,i=this.store.getState(V),o=e.audioTrack,s=e.videoTrack;return{audioInputDeviceId:o&&o.enabled?null==(t=o.getMediaTrackSettings())?void 0:t.deviceId:i.audioInputDeviceId,videoInputDeviceId:s&&s.enabled?null==(r=s.getMediaTrackSettings())?void 0:r.deviceId:i.videoInputDeviceId,audioOutputDeviceId:null==(n=this.sdk.getAudioOutput().getDevice())?void 0:n.deviceId}},t.setTrackVolume=function(e,t){var r=this.hmsSDKTracks[t];r?r instanceof i.HMSAudioTrack?(r.setVolume(e),this.setState((function(r){var n=r.tracks[t];n&&(n.volume=e)}),"trackVolume")):De.w("track "+t+" is not an audio track"):this.logPossibleInconsistency("track "+t+" not present, unable to set volume")},t.localAndVideoUnmuting=function(e){if(this.store.getState(G).videoTrack!==e)return!1;var t=this.store.getState(Z),r=this.store.getState($);return t&&!r},t.logPossibleInconsistency=function(e){De.w("possible inconsistency detected - ",e)},t.addRemoveVideoPlugin=function(){var e=c(h.mark((function e(t,r,n){var i,o;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return De.w("Invalid plugin received in store"),e.abrupt("return");case 3:if(!(i=this.store.getState(Q))){e.next=19;break}if(!(o=this.hmsSDKTracks[i])){e.next=18;break}if("add"!==r){e.next=12;break}return e.next=10,o.addPlugin(t,n);case 10:e.next=15;break;case 12:if("remove"!==r){e.next=15;break}return e.next=15,o.removePlugin(t);case 15:this.syncRoomState(r+"VideoPlugin"),e.next=19;break;case 18:this.logPossibleInconsistency("track "+i+" not present, unable to remove plugin");case 19:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t.addRemoveAudioPlugin=function(){var e=c(h.mark((function e(t,r){var n,i;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return De.w("Invalid plugin received in store"),e.abrupt("return");case 3:if(!(n=this.store.getState(W))){e.next=19;break}if(!(i=this.hmsSDKTracks[n])){e.next=18;break}if("add"!==r){e.next=12;break}return e.next=10,i.addPlugin(t);case 10:e.next=15;break;case 12:if("remove"!==r){e.next=15;break}return e.next=15,i.removePlugin(t);case 15:this.syncRoomState(r+"AudioPlugin"),e.next=19;break;case 18:this.logPossibleInconsistency("track "+n+" not present, unable to remove plugin");case 19:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.isSameStoreSDKTrack=function(e,t){var r;return!!t&&(null==(r=this.hmsSDKTracks[t])?void 0:r.trackId)===e},t.onRoleChangeRequest=function(e){this.setState((function(t){0===t.roleChangeRequests.length&&t.roleChangeRequests.push(P.convertRoleChangeRequest(e))}),"roleChangeRequest")},t.removeRoleChangeRequest=function(e){this.setState((function(t){var r=t.roleChangeRequests.findIndex((function(t){return t.token===e.token}));-1!==r&&t.roleChangeRequests.splice(r,1)}),"removeRoleChangeRequest")},t.onRoleUpdate=function(){this.syncRoomState("roleUpdate")},t.getStoreLocalTrackIDfromSDKTrack=function(e){var t=this;return this.store.getState(X).find((function(r){return t.hmsSDKTracks[r].trackId===e.trackId}))},t.peerUpdateInternal=function(e,t){var r=this,n=this.store.getState(Ce(t.peerId)),o="peerUpdate";e===i.HMSPeerUpdate.PEER_JOINED?o="peerJoined":e===i.HMSPeerUpdate.PEER_LEFT&&(o="peerLeft"),this.setState((function(e){if("peerLeft"===o){var n=e.room.peers.indexOf(t.peerId);n>-1&&e.room.peers.splice(n,1),delete e.peers[t.peerId],delete r.hmsSDKPeers[t.peerId]}else{var i=P.convertPeer(t);e.peers[i.id]?Object.assign(e.peers[i.id],i):(e.peers[i.id]=i,e.room.peers.push(i.id)),r.hmsSDKPeers[t.peerId]=t}}),o),n||(n=this.store.getState(Ce(t.peerId))),this.hmsNotifications.sendPeerUpdate(e,n)},t.updateTracksInPeer=function(e,t,r){var n,i;(null==(n=e.audioTrack)?void 0:n.trackId)===r.id?t.audioTrack=r.id:(null==(i=e.videoTrack)?void 0:i.trackId)===r.id?t.videoTrack=r.id:t.auxiliaryTracks.includes(r.id)||t.auxiliaryTracks.push(r.id)},e}(),Mt=((bt={})[i.HMSPeerUpdate.PEER_JOINED]=exports.HMSNotificationTypes.PEER_JOINED,bt[i.HMSPeerUpdate.PEER_LEFT]=exports.HMSNotificationTypes.PEER_LEFT,bt[i.HMSPeerUpdate.ROLE_UPDATED]=exports.HMSNotificationTypes.ROLE_UPDATED,bt[i.HMSPeerUpdate.AUDIO_TOGGLED]="PEER_AUDIO_UPDATED",bt[i.HMSPeerUpdate.VIDEO_TOGGLED]="PEER_VIDEO_UPDATED",bt),It=((Rt={})[i.HMSTrackUpdate.TRACK_ADDED]=exports.HMSNotificationTypes.TRACK_ADDED,Rt[i.HMSTrackUpdate.TRACK_REMOVED]=exports.HMSNotificationTypes.TRACK_REMOVED,Rt[i.HMSTrackUpdate.TRACK_MUTED]=exports.HMSNotificationTypes.TRACK_MUTED,Rt[i.HMSTrackUpdate.TRACK_UNMUTED]=exports.HMSNotificationTypes.TRACK_UNMUTED,Rt),wt=function(){function e(e){var t=this;this.id=0,this.onNotification=function(e){return t.eventEmitter.addListener("hmsNotification",e),function(){t.eventEmitter.removeListener("hmsNotification",e)}},this.store=e,this.eventEmitter=new s}var t=e.prototype;return t.sendDeviceChange=function(e){var t,r=this.createNotification(exports.HMSNotificationTypes.DEVICE_CHANGE_UPDATE,e,e.error?exports.HMSNotificationSeverity.ERROR:exports.HMSNotificationSeverity.INFO,"Selected "+e.type+" device - "+(null==(t=e.selection)?void 0:t.label));this.emitEvent(r)},t.sendLeaveRoom=function(e){var t=this.createNotification(e.roomEnded?exports.HMSNotificationTypes.ROOM_ENDED:exports.HMSNotificationTypes.REMOVED_FROM_ROOM,e,exports.HMSNotificationSeverity.INFO,(e.roomEnded?"Room ended":"Removed from room")+" by "+e.requestedBy.name);this.emitEvent(t)},t.sendPeerUpdate=function(e,t){var r=this.store.getState(Ce(null==t?void 0:t.id))||t,n=Mt[e];if(n){var i=this.createNotification(n,r,exports.HMSNotificationSeverity.INFO);this.emitEvent(i)}},t.sendTrackUpdate=function(e,t){var r=this.store.getState(Ue(t)),n=It[e];if(n){var i=this.createNotification(n,r,exports.HMSNotificationSeverity.INFO);this.emitEvent(i)}},t.sendMessageReceived=function(e){var t=this.createNotification(exports.HMSNotificationTypes.NEW_MESSAGE,e,exports.HMSNotificationSeverity.INFO);this.emitEvent(t)},t.sendError=function(e){var t=this.createNotification(exports.HMSNotificationTypes.ERROR,e,exports.HMSNotificationSeverity.ERROR);this.emitEvent(t)},t.sendReconnecting=function(e){var t=this.createNotification(exports.HMSNotificationTypes.RECONNECTING,e,exports.HMSNotificationSeverity.ERROR);this.emitEvent(t)},t.sendReconnected=function(){var e=this.createNotification(exports.HMSNotificationTypes.RECONNECTED,null,exports.HMSNotificationSeverity.INFO);this.emitEvent(e)},t.sendChangeTrackStateRequest=function(e){var t=this.createNotification(exports.HMSNotificationTypes.CHANGE_TRACK_STATE_REQUEST,e,exports.HMSNotificationSeverity.INFO);this.emitEvent(t)},t.sendChangeMultiTrackStateRequest=function(e){var t=this.createNotification(exports.HMSNotificationTypes.CHANGE_MULTI_TRACK_STATE_REQUEST,e,exports.HMSNotificationSeverity.INFO);this.emitEvent(t)},t.emitEvent=function(e){this.eventEmitter.emit("hmsNotification",e)},t.createNotification=function(e,t,r,n){return void 0===n&&(n=""),this.id++,{id:this.id,type:e,message:n,data:t,severity:r}},e}(),Dt=function(){function e(t,r,n){this.store=t||e.createNewHMSStore(),this.notifications=n||new wt(this.store),this.actions=r||new Pt(this.store,new i.HMSSdk,this.notifications),this.initialTriggerOnSubscribe=!1}var o=e.prototype;return o.triggerOnSubscribe=function(){this.initialTriggerOnSubscribe||(e.makeStoreTriggerOnSubscribe(this.store),this.initialTriggerOnSubscribe=!0)},o.getStore=function(){return this.store},o.getHMSActions=function(){return this.actions},o.getNotifications=function(){return{onNotification:this.notifications.onNotification}},e.createNewHMSStore=function(){var n=r((function(){return g()})),i=n.setState;n.setState=function(e){var r="function"==typeof e?t(e):e;i(r)};var o=n.getState;return n.getState=function(e){return e?e(o()):o()},e.useShallowCheckInSubscribe(n),u({},n,{namedSetState:e.setUpDevtools(n,"HMSStore")})},e.makeStoreTriggerOnSubscribe=function(e){var t=e.subscribe;e.subscribe=function(r,n,i){return r(e.getState(n),void 0),t(r,n,i)}},e.useShallowCheckInSubscribe=function(e){var t=e.subscribe;e.subscribe=function(e,r,i){return r||(r=function(e){return e}),t(e,r,i=i||n)}},e.setUpDevtools=function(t,r){var n;try{n=window.__REDUX_DEVTOOLS_EXTENSION__||window.top.__REDUX_DEVTOOLS_EXTENSION__}catch(e){}if(!n)return function(e){t.setState(e)};var i=n.connect(e.devtoolsOptions(r));i.prefix=r?r+" > ":"";var o=t.setState;return t.setState=function(e){o(e),i.send(i.prefix+"setState",t.getState())},i.subscribe(e.devtoolsSubscribe(i,t,o)),i.send("setUpStore",t.getState()),function(e,r){o(e),i.send(r||i.prefix+"action",t.getState())}},e.devtoolsOptions=function(e){return{name:e,actionsBlacklist:["audioLevel","playlistProgress"]}},e.devtoolsSubscribe=function(e,t,r){return function(n){var i,o;if("DISPATCH"===n.type&&n.state)["JUMP_TO_ACTION","JUMP_TO_STATE"].includes(n.payload.type)?r(JSON.parse(n.state)):t.setState(JSON.parse(n.state));else if("DISPATCH"===n.type&&"COMMIT"===(null==(i=n.payload)?void 0:i.type))e.init(t.getState());else if("DISPATCH"===n.type&&"IMPORT_STATE"===(null==(o=n.payload)?void 0:o.type)){var s,a,c=null==(s=n.payload.nextLiftedState)?void 0:s.actionsById;((null==(a=n.payload.nextLiftedState)?void 0:a.computedStates)||[]).forEach((function(n,i){var o=n.state,s=c[i]||e.prefix+"setState";0===i?e.init(o):(r(o),e.send(s,t.getState()))}))}}},e}();Object.defineProperty(exports,"HMSLogLevel",{enumerable:!0,get:function(){return i.HMSLogLevel}}),Object.defineProperty(exports,"HMSSimulcastLayer",{enumerable:!0,get:function(){return i.HMSSimulcastLayer}}),exports.HMSReactiveStore=Dt,exports.createDefaultStoreState=g,exports.selectAudioPlaylist=Me,exports.selectAudioPlaylistTrackByPeerID=Xe,exports.selectAudioTrackByPeerID=Ke,exports.selectAudioTrackVolume=nt,exports.selectAudioVolumeByPeerID=it,exports.selectAuxiliaryAudioByPeerID=Je,exports.selectAuxiliaryTracksByPeerID=Be,exports.selectAvailableRoleNames=he,exports.selectBroadcastMessages=ut,exports.selectBroadcastMessagesUnreadCount=pt,exports.selectCameraStreamByPeerID=qe,exports.selectDegradedTracks=se,exports.selectDevices=function(e){return e.devices},exports.selectDominantSpeaker=z,exports.selectHMSMessages=ue,exports.selectHMSMessagesCount=ae,exports.selectIsAllowedToPublish=mt,exports.selectIsAllowedToSubscribe=Se,exports.selectIsAudioLocallyMuted=et,exports.selectIsConnectedToRoom=q,exports.selectIsInPreview=de,exports.selectIsLocalAudioEnabled=function(e){var t=G(e);return L(e,null==t?void 0:t.audioTrack)},exports.selectIsLocalAudioPluginPresent=function(e){return o.createSelector([Tt],(function(t){return t.includes(e)}))},exports.selectIsLocalScreenShared=ee,exports.selectIsLocalVideoDisplayEnabled=Z,exports.selectIsLocalVideoEnabled=$,exports.selectIsLocalVideoPluginPresent=function(e){return o.createSelector([kt],(function(t){return t.includes(e)}))},exports.selectIsLocallyMutedByPeerID=tt,exports.selectIsPeerAudioEnabled=$e,exports.selectIsPeerVideoEnabled=Ze,exports.selectIsScreenShareLocallyMutedByPeerID=rt,exports.selectIsSomeoneScreenSharing=re,exports.selectLocalAudioTrackID=W,exports.selectLocalMediaSettings=V,exports.selectLocalPeer=G,exports.selectLocalPeerID=J,exports.selectLocalPeerRole=ve,exports.selectLocalTrackIDs=X,exports.selectLocalVideoTrackID=Q,exports.selectMessageIDsInOrder=_,exports.selectMessagesByPeerID=ft,exports.selectMessagesByRole=ht,exports.selectMessagesMap=C,exports.selectMessagesUnreadCountByPeerID=St,exports.selectMessagesUnreadCountByRole=vt,exports.selectPeerAudioByID=Ge,exports.selectPeerByID=Ce,exports.selectPeerCount=B,exports.selectPeerNameByID=_e,exports.selectPeerScreenSharing=te,exports.selectPeerSharingAudio=ne,exports.selectPeerSharingVideoPlaylist=oe,exports.selectPeers=j,exports.selectPeersMap=H,exports.selectPeersScreenSharing=ie,exports.selectPeersWithAudioStatus=yt,exports.selectPermissions=ye,exports.selectRTMPState=me,exports.selectRecordingState=ge,exports.selectRemotePeers=Y,exports.selectRoleByRoleName=function(e){return o.createSelector([fe],(function(t){return t[e]}))},exports.selectRoleChangeRequest=gt,exports.selectRolesMap=fe,exports.selectRoom=A,exports.selectRoomStarted=pe,exports.selectRoomState=le,exports.selectScreenShareAudioByPeerID=ze,exports.selectScreenShareByPeerID=function(e){return o.createSelector(Ye(e),(function(e){return e.video}))},exports.selectScreenSharesByPeerId=Ye,exports.selectScreenshareAudioVolumeByPeerID=ot,exports.selectSimulcastLayerByTrack=st,exports.selectSpeakers=K,exports.selectTrackAudioByID=Fe,exports.selectTrackByID=Ue,exports.selectTracksMap=U,exports.selectUnreadHMSMessagesCount=ce,exports.selectVideoPlaylist=Ie,exports.selectVideoPlaylistAudioTrackByPeerID=Qe,exports.selectVideoPlaylistVideoTrackByPeerID=We,exports.selectVideoTrackByPeerID=Ve;
|
|
2
2
|
//# sourceMappingURL=hms-video-store.cjs.production.min.js.map
|