@100mslive/hms-video-store
Advanced tools
Comparing version 0.2.41-4 to 0.2.41-5
@@ -18,5 +18,7 @@ import { HMSTrack as SDKHMSTrack, HMSRoleChangeRequest as SDKHMSRoleChangeRequest } from '@100mslive/hms-video'; | ||
audio: { | ||
list: Record<string, HMSPlaylistItem>; | ||
list: Record<string, HMSPlaylistItem<any>>; | ||
selection: { | ||
id: string | undefined; | ||
hasPrevious: boolean; | ||
hasNext: boolean; | ||
}; | ||
@@ -27,5 +29,7 @@ progress: number; | ||
video: { | ||
list: Record<string, HMSPlaylistItem>; | ||
list: Record<string, HMSPlaylistItem<any>>; | ||
selection: { | ||
id: string | undefined; | ||
hasPrevious: boolean; | ||
hasNext: boolean; | ||
}; | ||
@@ -32,0 +36,0 @@ progress: number; |
@@ -38,10 +38,10 @@ import { HMSMessage, HMSTrackID, HMSTrackSource } from '../schema'; | ||
get playlist(): { | ||
play: ({ url, type }: HMSPlaylistAction) => Promise<void>; | ||
pause: ({ url, type }: HMSPlaylistAction) => Promise<void>; | ||
playNext: ({ type }: HMSPlaylistAction) => Promise<void>; | ||
playPrevious: ({ type }: HMSPlaylistAction) => Promise<void>; | ||
seek: ({ seekValue, type }: HMSPlaylistAction) => Promise<void>; | ||
setVolume: ({ volume, type }: HMSPlaylistAction) => void; | ||
setList: ({ list }: HMSPlaylistAction) => void; | ||
stop: ({ type }: HMSPlaylistAction) => Promise<void>; | ||
play: <T>({ id, type }: HMSPlaylistAction<T>) => Promise<void>; | ||
pause: <T_1>({ id, type }: HMSPlaylistAction<T_1>) => Promise<void>; | ||
playNext: <T_2>({ type }: HMSPlaylistAction<T_2>) => Promise<void>; | ||
playPrevious: <T_3>({ type }: HMSPlaylistAction<T_3>) => Promise<void>; | ||
seek: <T_4>({ seekValue, type }: HMSPlaylistAction<T_4>) => Promise<void>; | ||
setVolume: <T_5>({ volume, type }: HMSPlaylistAction<T_5>) => void; | ||
setList: <T_6>({ list }: HMSPlaylistAction<T_6>) => void; | ||
stop: <T_7>({ type }: HMSPlaylistAction<T_7>) => Promise<void>; | ||
}; | ||
@@ -48,0 +48,0 @@ unblockAudio(): Promise<void>; |
@@ -1,2 +0,2 @@ | ||
import { HMSException, HMSSimulcastLayer, HMSPeerUpdate, HMSRoomUpdate, HMSTrackUpdate, HMSAudioTrackSettings, HMSVideoTrackSettings, HMSPeer, HMSRoom, HMSMessage, HMSConfig, HMSSpeaker, HMSRole, HMSLocalPeer, HMSRemotePeer, SimulcastLayerDefinition, DeviceMap, HMSLogLevel, HMSDeviceChangeEvent, HMSPlaylistItem, IPlaylistManager as HMSPlaylistManager } from '@100mslive/hms-video'; | ||
import { HMSException, HMSSimulcastLayer, HMSPeerUpdate, HMSRoomUpdate, HMSTrackUpdate, HMSAudioTrackSettings, HMSVideoTrackSettings, HMSPeer, HMSRoom, HMSMessage, HMSConfig, HMSSpeaker, HMSRole, HMSLocalPeer, HMSRemotePeer, SimulcastLayerDefinition, DeviceMap, HMSLogLevel, HMSDeviceChangeEvent, HMSPlaylistItem, HMSPlaylistManager } from '@100mslive/hms-video'; | ||
export { HMSPeer, HMSRoom, HMSMessage, HMSSpeaker, HMSConfig, HMSAudioTrackSettings, HMSVideoTrackSettings, HMSException, HMSSimulcastLayer, HMSRoomUpdate, HMSPeerUpdate, HMSTrackUpdate, HMSRole, HMSLocalPeer, HMSRemotePeer, HMSLogLevel, SimulcastLayerDefinition, DeviceMap, HMSDeviceChangeEvent, HMSPlaylistItem, HMSPlaylistManager, }; |
@@ -6,13 +6,13 @@ import * as sdkTypes from '../hmsSDKStore/sdkTypes'; | ||
} | ||
export interface HMSPlaylistAction { | ||
url?: string; | ||
export interface HMSPlaylistAction<T> { | ||
id?: string; | ||
seekValue?: number; | ||
type?: HMSPlaylistType; | ||
volume?: number; | ||
list?: sdkTypes.HMSPlaylistItem[]; | ||
list?: sdkTypes.HMSPlaylistItem<T>[]; | ||
} | ||
export interface HMSPlaylistItem { | ||
export interface HMSPlaylistItem<T> { | ||
name: string; | ||
id: string; | ||
description?: string; | ||
metadata?: Record<string, T>; | ||
url: string; | ||
@@ -25,7 +25,9 @@ thumbnailUrl?: string; | ||
} | ||
export interface HMSPlaylist { | ||
export interface HMSPlaylist<T> { | ||
audio: { | ||
list: Record<string, HMSPlaylistItem>; | ||
list: Record<string, HMSPlaylistItem<T>>; | ||
selection: { | ||
id: string; | ||
hasPrevious: boolean; | ||
hasNext: boolean; | ||
}; | ||
@@ -36,5 +38,7 @@ progress: number; | ||
video: { | ||
list: Record<string, HMSPlaylistItem>; | ||
list: Record<string, HMSPlaylistItem<T>>; | ||
selection: { | ||
id: string; | ||
hasPrevious: boolean; | ||
hasNext: boolean; | ||
}; | ||
@@ -41,0 +45,0 @@ progress: number; |
@@ -1,2 +0,2 @@ | ||
"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")),o=require("@100mslive/hms-video"),i=require("reselect"),s=e(require("events"));function a(e,t,r,n,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}function c(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){a(i,n,o,s,c,"next",e)}function c(e){a(i,n,o,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 f,p,h=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=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 o=Object.create((t&&t.prototype instanceof d?t:d).prototype),i=new b(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){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,i),o}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 f(){}function p(){}var h={};a(h,o,(function(){return this}));var v=Object.getPrototypeOf,S=v&&v(v(R([])));S&&S!==t&&r.call(S,o)&&(h=S);var y=p.prototype=d.prototype=Object.create(h);function m(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){var n;this._invoke=function(o,i){function s(){return new t((function(n,s){!function n(o,i,s,a){var c=u(e[o],e,i);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)}(o,i,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 o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function x(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 T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function b(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function R(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=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 i.next=i}}return{next:E}}function E(){return{value:void 0,done:!0}}return f.prototype=p,a(y,"constructor",p),a(p,"constructor",f),f.displayName=a(p,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,a(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},m(g.prototype),a(g.prototype,i,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var s=new g(c(t,r,n,o),i);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},m(y),a(y,s,"Generator"),a(y,o,(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(T),!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 o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.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),T(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 o=n.arg;T(r)}return o}}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)}}(p={exports:{}}),p.exports);(f=exports.HMSRoomState||(exports.HMSRoomState={})).Disconnected="Disconnected",f.Preview="Preview",f.Connecting="Connecting",f.Connected="Connected",f.Reconnecting="Reconnecting",f.Failed="Failed";var v,S,y,m=function(){return{room:{id:"",isConnected:!1,name:"",peers:[],shareableLink:"",hasWaitingRoom:!1,roomState:exports.HMSRoomState.Disconnected},peers:{},tracks:{},playlist:{audio:{list:{},selection:{id:""},progress:0,volume:0},video:{list:{},selection:{id:""},progress:0,volume: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.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 g=function(e,t){return e&&t},k=function(e,t){return e&&!t},x=function(e,t){return!e&&t},T=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,o=d(e);!(r=o()).done;)n.add(r.value);for(var i,s=d(t);!(i=s()).done;)n.add(i.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){var t={id:e.trackId,source:e.source,type:e.type,enabled:e.enabled,displayEnabled:e.enabled};return this.enrichTrack(t,e),t},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 o.HMSRemoteAudioTrack){var i=r.getVolume()||0;t.volume=i}e.enrichVideoTrack(t,r)},e.enrichVideoTrack=function(e,t){t instanceof o.HMSRemoteVideoTrack&&(e.layer=t.getSimulcastLayer(),e.degraded=t.degraded,T(t.getSimulcastDefinitions(),e.layerDefinitions)||(e.layerDefinitions=t.getSimulcastDefinitions())),(t instanceof o.HMSLocalVideoTrack||t instanceof o.HMSLocalAudioTrack)&&(T(t.getPlugins(),e.plugins)||(e.plugins=t.getPlugins()))},e.convertRoom=function(e){return{id:e.id,name:e.name,hasWaitingRoom:e.hasWaitingRoom,shareableLink:e.shareableLink}},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,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),o=e.getCurrentProgress(t),i=e.isPlaying(t),s=e.getVolume(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&&i})})),{list:r,selection:{id:null==n?void 0:n.id},progress:o,volume:s}},e}();function P(e,t,r){void 0===r&&(r=D);var n=void 0,o=void 0;if(t)for(var i,s=d(t.auxiliaryTracks);!(i=s()).done;){var a=e[i.value];r(a)&&(o=w(a)?a:o,n=M(a)?a:n)}return{video:n,audio:o}}function w(e){return e&&"audio"===e.type}function M(e){return e&&"video"===e.type}function D(e){return e&&"screen"===e.source}function I(e){return e&&"playlist"===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 N=function(e){return e.room},A=function(e){return e.peers},C=function(e){return e.messages.byID},H=function(e){return e.messages.allIDs},_=function(e){return e.tracks},U=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].list}},V=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].selection}},K=function(e){return e.speakers},B=i.createSelector([N],(function(e){return e&&e.isConnected})),j=i.createSelector([N,A],(function(e,t){return e.peers.map((function(e){return t[e]}))})),q=i.createSelector(_,(function(e){return Object.values(e)})),F=i.createSelector(j,(function(e){return e.filter((function(e){return e.isLocal}))[0]})),G=i.createSelector(F,(function(e){return null==e?void 0:e.id})),J=i.createSelector(F,(function(e){return null==e?void 0:e.audioTrack})),W=i.createSelector(F,(function(e){return null==e?void 0:e.videoTrack})),Q=i.createSelector([J,W,i.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=i.createSelector(j,(function(e){return e.filter((function(e){return!e.isLocal}))})),Y=i.createSelector(A,K,(function(e,t){var r=Object.entries(t).sort((function(e,t){var r,n,o=(null==(r=e[1])?void 0:r.audioLevel)||0;return((null==(n=t[1])?void 0:n.audioLevel)||0)>o?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 L(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=i.createSelector(F,_,(function(e,t){var r=P(t,e);return!(!r.video&&!r.audio)})),ee=i.createSelector(A,_,(function(e,t){var r=void 0;for(var n in e){var o=e[n],i=P(t,o);if(i.video)return o;i.audio&&!r&&(r=o)}return r})),te=i.createSelector(ee,(function(e){return!!e})),re=i.createSelector(A,_,(function(e,t){for(var r in e){var n=e[r],o=P(t,n);if(!o.video&&o.audio)return n}})),ne=i.createSelector(A,_,(function(e,t){var r=[],n=[];for(var o in e){var i=e[o],s=P(t,i),a=s.audio;s.video?r.push(i):a&&n.push(i)}return r.concat(n)})),oe=i.createSelector(A,_,(function(e,t){for(var r in e){var n=e[r];if(P(t,n,I).video)return n}})),ie=i.createSelector(q,(function(e){return e.filter(O)})),se=i.createSelector(H,(function(e){return e.length})),ae=i.createSelector(C,(function(e){return Object.values(e).filter((function(e){return!e.read})).length})),ce=i.createSelector(H,C,(function(e,t){var r=[];return e.forEach((function(e){r.push(t[e])})),r})),ue=i.createSelector([N],(function(e){return e&&e.roomState})),le=i.createSelector(ue,(function(e){return e===exports.HMSRoomState.Preview})),de=i.createSelector(N,(function(e){return e.roomState!==exports.HMSRoomState.Disconnected})),fe=function(e){return e.roles},pe=i.createSelector([fe],(function(e){return Object.keys(e)})),he=i.createSelector([F,fe],(function(e,t){return null!=e&&e.roleName?t[e.roleName]:null})),ve=i.createSelector([he],(function(e){var t;return!(null==e||null==(t=e.subscribeParams)||!t.subscribeToRoles)&&e.subscribeParams.subscribeToRoles.length>0})),Se=i.createSelector(he,(function(e){return null==e?void 0:e.permissions})),ye="HMS-Store:",me=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,[o.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,[o.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,[o.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,[o.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,[o.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 o.HMSLogLevel.VERBOSE:var i;(i=console).log.apply(i,[ye].concat(r));break;case o.HMSLogLevel.DEBUG:var s;(s=console).debug.apply(s,[ye].concat(r));break;case o.HMSLogLevel.INFO:var a;(a=console).info.apply(a,[ye].concat(r));break;case o.HMSLogLevel.WARN:var c;(c=console).warn.apply(c,[ye].concat(r));break;case o.HMSLogLevel.ERROR:var u;(u=console).error.apply(u,[ye].concat(r))}}},e}();function ge(e){return function(t){return function(r){return e(r,t)}}}me.level=o.HMSLogLevel.VERBOSE;var ke=function(e,t){return t},xe=function(e,t){return t},Te=i.createSelector([A,ke],(function(e,t){return t?e[t]:null})),be=i.createSelector([_,function(e,t){return t}],(function(e,t){return t?e[t]:null})),Re=ge(Te),Ee=ge(i.createSelector(Te,(function(e){return null==e?void 0:e.name}))),Pe=ge(be),we=ge((function(e,t){var r=Te(e,t);if(r&&r.videoTrack&&""!==r.videoTrack)return e.tracks[r.videoTrack]})),Me=ge((function(e,t){var r=Te(e,t);if(r&&r.audioTrack&&""!==r.audioTrack)return e.tracks[r.audioTrack]})),De=we,Ie=ge((function(e,t){var r=Te(e,t);return(null==r?void 0:r.auxiliaryTracks.map((function(t){return e.tracks[t]})))||[]})),Oe=function(e,t){return t?e.speakers[t]:null},Le=ge(i.createSelector(Oe,(function(e){return(null==e?void 0:e.audioLevel)||0}))),Ne=ge(i.createSelector((function(e,t){var r=Me(t)(e);return Oe(e,null==r?void 0:r.id)}),(function(e){return(null==e?void 0:e.audioLevel)||0}))),Ae=ge((function(e,t){var r=Te(e,t);if(r){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){return w(e.tracks[t])}));return n?e.tracks[n]:void 0}})),Ce=ge(i.createSelector(_,Te,(function(e,t){var r=null==t?void 0:t.auxiliaryTracks.find((function(t){var r=e[t];return I(r)&&M(r)}));return r?e[r]:void 0}))),He=ge(i.createSelector(_,Te,(function(e,t){var r=null==t?void 0:t.auxiliaryTracks.find((function(t){var r=e[t];return I(r)&&w(r)}));return r?e[r]:void 0}))),_e=ge(i.createSelector(_,Te,(function(e,t){return P(e,t)}))),Ue=function(e){return i.createSelector(_e(e),(function(e){return e.audio}))},Ve=ge((function(e,t){var r=Te(e,t);return L(e,null==r?void 0:r.audioTrack)})),Ke=ge((function(e,t){var r=Te(e,t);return L(e,null==r?void 0:r.videoTrack)})),Be=ge((function(e,t){if(t&&e.tracks[t])return 0===e.tracks[t].volume})),je=ge((function(e,t){var r=Te(e,t);return Be(null==r?void 0:r.audioTrack)(e)})),qe=ge((function(e,t){var r=Ue(t)(e);return Be(null==r?void 0:r.id)(e)})),Fe=ge((function(e,t){var r=be(e,t);if(r)return"audio"!==r.type?void me.w("Please pass audio track here"):r.volume})),Ge=ge((function(e,t){var r=Te(e,t);return Fe(null==r?void 0:r.audioTrack)(e)})),Je=ge((function(e,t){var r=Ue(t)(e);return Fe(null==r?void 0:r.id)(e)})),We=ge((function(e,t){var r=be(e,t);if(r)return"video"!==r.type?void me.w("Please pass video track here"):r.layer})),Qe=i.createSelector([ce,G,ke],(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)}))})),Xe=i.createSelector([ce,xe],(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))}))})),Ye=i.createSelector(ce,(function(e){return e.filter((function(e){var t;return!(e.recipientPeer||null!=(t=e.recipientRoles)&&t.length)}))})),ze=i.createSelector([Xe,xe],(function(e){return e?e.filter((function(e){return!e.read})).length:0})),$e=i.createSelector([Qe,ke],(function(e){return e?e.filter((function(e){return!e.read})).length:0})),Ze=i.createSelector(Ye,(function(e){return e.filter((function(e){return!e.read})).length})),et=ge(Qe),tt=ge(Xe),rt=ge(ze),nt=ge($e),ot=i.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)}}))})),it=i.createSelector([function(e){return e.roleChangeRequests[0]||null},A,fe],(function(e,t,r){return e?{requestedBy:t[e.requestedBy],role:r[e.roleName],token:e.token}:null})),st=i.createSelector([he],(function(e){var t,r=!1,n=!1,o=!1;return null!=e&&null!=(t=e.publishParams)&&t.allowed&&(r=e.publishParams.allowed.includes("video"),n=e.publishParams.allowed.includes("audio"),o=e.publishParams.allowed.includes("screen")),{video:r,audio:n,screen:o}})),at=i.createSelector([W,_],(function(e,t){var r,n=null;return e&&(n=t[e]),(null==(r=n)?void 0:r.plugins)||[]})),ct=i.createSelector([J,_],(function(e,t){var r,n=null;return e&&(n=t[e]),(null==(r=n)?void 0:r.plugins)||[]}));function ut(e){return e instanceof o.HMSRemoteAudioTrack||e instanceof o.HMSRemoteVideoTrack}var lt,dt,ft=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}),"playlistProgress")},this.setState=function(e,t){return n.store.namedSetState(e,t)},this.store=e,this.sdk=t,this.hmsNotifications=r}var t,r=e.prototype;return r.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)}}(),r.setVolume=function(e,t){t?this.setTrackVolume(e,t):(this.sdk.getAudioOutput().setVolume(e),this.syncRoomState("setVolume"))},r.setAudioOutputDevice=function(e){this.sdk.getAudioOutput().setDevice(e),this.syncRoomState("setAudioOutput")},r.setPreferredLayer=function(e,t){var r=this.hmsSDKTracks[e];r?r instanceof o.HMSRemoteVideoTrack?(r.preferLayer(t),this.syncRoomState("setPreferredLayer")):me.w("track "+e+" is not an video track"):this.logPossibleInconsistency("track "+e+" not present, unable to set preffer layer")},r.preview=function(){var e=c(h.mark((function e(t){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:return e.prev=3,e.next=6,this.sdkPreviewWithListeners(t);case 6:this.setState((function(e){e.room.roomState=exports.HMSRoomState.Connecting}),"preview"),e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(3),me.e("Cannot show preview. Failed to connect to room - ",e.t0),e.t0;case 13:case"end":return e.stop()}}),e,this,[[3,9]])})));return function(t){return e.apply(this,arguments)}}(),r.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,me.e("Failed to connect to room - ",e),e}},r.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"),me.i("left room")})).catch((function(e){me.e("error in leaving room - ",e)})));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.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)}}(),r.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)}}(),r.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)}}(),r.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)}}(),r.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)}}(),r.setEnabledTrack=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((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:i.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=15;break;case 11:throw e.prev=11,e.t0=e.catch(5),this.setState((function(e){e.tracks[t].displayEnabled=!r}),"rollbackDisplayEnabled"),e.t0;case 15:this.hmsNotifications.sendTrackUpdate(r?o.HMSTrackUpdate.TRACK_UNMUTED:o.HMSTrackUpdate.TRACK_MUTED,t);case 17:case"end":return e.stop()}}),e,this,[[5,11]])})));return function(t,r){return e.apply(this,arguments)}}(),r.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)}}(),r.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)}}(),r.sendMessage=function(e){this.sendBroadcastMessage(e)},r.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)}}(),r.sendGroupMessage=function(){var e=c(h.mark((function e(t,r,n){var o,i;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=this.store.getState(fe),i=r.map((function(e){return o[e]})),e.next=4,this.sdk.sendGroupMessage(t,i,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)}}(),r.sendDirectMessage=function(){var e=c(h.mark((function e(t,r,n){var o;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=this.hmsSDKPeers[r],e.next=3,this.sdk.sendDirectMessage(t,o);case 3:this.updateMessageInStore(e.sent,{message:t,recipientPeer:o.peerId,type:n});case 5:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),r.updateMessageInStore=function(e,t){if(!e)throw me.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},r.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")},r.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 o=n.store.subscribe(function(){var i=c(h.mark((function i(s){return h.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!s){i.next=5;break}return i.next=3,n.attachVideoInternal(t,r);case 3:o(),e();case 5:case"end":return i.stop()}}),i)})));return function(e){return i.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)}}(),r.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=6;break}return e.next=4,n.removeSink(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("no video track found to remove sink");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),r.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)}}(),r.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)}}(),r.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)}}(),r.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)}}(),r.changeRole=function(){var e=c(h.mark((function e(t,r,n){var o;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===n&&(n=!1),o=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(o,r,n);case 7:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),r.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)||me.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)}}(),r.rejectChangeRole=function(e){this.removeRoleChangeRequest(e)},r.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 me.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)}}(),r.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)}}(),r.setRemoteTrackEnabled=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("string"!=typeof t){e.next=10;break}if(!(n=this.hmsSDKTracks[t])||!ut(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 o.setRemoteTrackEnabled(e,r)}));case 11:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),r.setLogLevel=function(e){me.level=e,this.sdk.setLogLevel(e)},r.resetState=function(e){void 0===e&&(e="resetState"),this.setState((function(e){Object.assign(e,m())}),e),this.isRoomJoinCalled=!1,this.hmsSDKTracks={}},r.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),onRemovedFromRoom:this.onRemovedFromRoom.bind(this)}),this.sdk.addAudioListener({onAudioLevelUpdate:this.onAudioLevelUpdate.bind(this)})},r.onRemovedFromRoom=function(e){var t=this.store.getState(Re(e.requestedBy.peerId));t?(this.hmsNotifications.sendLeaveRoom(u({},e,{requestedBy:t})),me.i("resetting state after peer removed",e),this.resetState(e.roomEnded?"roomEnded":"removedFromRoom")):this.logPossibleInconsistency("Not found peer who requested leave room, "+e.requestedBy)},r.onDeviceChange=function(e){var t=e.devices;if(t&&(this.setState((function(e){T(e.devices.audioInput,t.audioInput)||(e.devices.audioInput=t.audioInput),T(e.devices.videoInput,t.videoInput)||(e.devices.videoInput=t.videoInput),T(e.devices.audioOutput,t.audioOutput)||(e.devices.audioOutput=t.audioOutput)}),"deviceChange"),this.syncRoomState("deviceChangeSync"),e.selection)){var r=E.convertDeviceChangeUpdate(e);this.hmsNotifications.sendDeviceChange(r)}},r.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)}}(),r.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)}}(),r.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)}}(),r.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:n instanceof o.HMSRemoteVideoTrack&&n.getSimulcastDefinitions().length>0&&this.setState((function(e){var r=n.getSimulcastLayer();e.tracks[t].layer=r}),"updateLayerOnAttach"),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)}}(),r.syncRoomState=function(e){for(var t,r=this,n={},o=[],i={},s={},a={},c=d(this.sdk.getPeers());!(t=c()).done;){var u=t.value,l=E.convertPeer(u);n[l.id]=l,o.push(l.id),this.hmsSDKPeers[l.id]=u;for(var f,p=d([u.audioTrack,u.videoTrack].concat(u.auxiliaryTracks));!(f=p()).done;){var h=f.value;if(h){var v=E.convertTrack(h);i[v.id]=v,s[h.trackId]=h}}l.isLocal&&Object.assign(a,this.getMediaSettings(u))}this.setState((function(e){e.room.peers=o;var t=e.tracks;!function(e,t,r,n){for(var o,i=d(b(Object.keys(e),Object.keys(t)));!(o=i()).done;){var s=o.value,a=e[s],c=t[s];g(a,c)?(T(a.auxiliaryTracks,c.auxiliaryTracks)&&(c.auxiliaryTracks=a.auxiliaryTracks),R(a,c,r,n),Object.assign(a,c)):k(a,c)?delete e[s]:x(a,c)&&(e[s]=c)}}(e.peers,n,i,s),function(e,t){for(var r,n=d(b(Object.keys(e),Object.keys(t)));!(r=n()).done;){var o=r.value,i=e[o],s=t[o];g(i,s)?Object.assign(i,s):k(i,s)?delete e[o]:x(i,s)&&(e[o]=s)}}(t,i),Object.assign(e.settings,a),r.hmsSDKTracks=s,Object.assign(e.roles,E.convertRoles(r.sdk.getRoles())),Object.assign(e.playlist,E.convertPlaylist(r.sdk.getPlaylistManager()))}),e)},r.onPreview=function(e){this.setState((function(t){Object.assign(t.room,E.convertRoom(e)),t.room.roomState=exports.HMSRoomState.Preview}),"previewStart"),this.syncRoomState("previewSync")},r.onJoin=function(e){this.setState((function(t){Object.assign(t.room,E.convertRoom(e)),t.room.isConnected=!0,t.room.roomState=exports.HMSRoomState.Connected}),"joined"),this.syncRoomState("joinSync"),this.sdk.getPlaylistManager().on("progress",this.setProgress)},r.onRoomUpdate=function(){this.syncRoomState("roomUpdate")},r.onPeerUpdate=function(e,t){if(e!==o.HMSPeerUpdate.BECAME_DOMINANT_SPEAKER&&e!==o.HMSPeerUpdate.RESIGNED_DOMINANT_SPEAKER){var r=this.store.getState(Re(t.peerId)),n="peerUpdate";e===o.HMSPeerUpdate.PEER_JOINED?n="peerJoined":e===o.HMSPeerUpdate.PEER_LEFT&&(n="peerLeft"),this.syncRoomState(n),r||(r=this.store.getState(Re(t.peerId))),this.hmsNotifications.sendPeerUpdate(e,r)}},r.onTrackUpdate=function(e,t,r){e===o.HMSTrackUpdate.TRACK_REMOVED?(this.hmsNotifications.sendTrackUpdate(e,t.trackId),this.handleTrackRemove(t,r)):(this.syncRoomState(e===o.HMSTrackUpdate.TRACK_ADDED?"trackAdded":"trackUpdate"),this.hmsNotifications.sendTrackUpdate(e,t.trackId))},r.onMessageReceived=function(e){var t=E.convertMessage(e);t.read=!1,this.onHMSMessage(t),this.hmsNotifications.sendMessageReceived(t)},r.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")},r.onAudioLevelUpdate=function(e){this.setState((function(t){var r={};e.forEach((function(e){if(e.track){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,o=Object.entries(t.speakers);n<o.length;n++){var i=o[n],s=i[0],a=i[1];a.audioLevel=r[s]||0,0===a.audioLevel&&delete t.speakers[s]}}),"audioLevel")},r.onChangeTrackStateRequest=function(e){var t=this.store.getState(Re(e.requestedBy.peerId)),r=this.getStoreLocalTrackIDfromSDKTrack(e.track),n=this.store.getState(Pe(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)},r.onReconnected=function(){this.syncRoomState("reconnectedSync"),this.hmsNotifications.sendReconnected(),this.setState((function(e){e.room.roomState=exports.HMSRoomState.Connected}),"reconnected")},r.onReconnecting=function(e){var t=E.convertException(e);me.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")},r.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),me.e("received error from sdk",t)},r.handleTrackRemove=function(e,t){var r=this;this.setState((function(n){var o=n.peers[t.peerId],i=n.tracks;if(r.isSameStoreSDKTrack(e.trackId,null==o?void 0:o.audioTrack))null==o||delete o.audioTrack;else if(r.isSameStoreSDKTrack(e.trackId,null==o?void 0:o.videoTrack))null==o||delete o.videoTrack;else{var s=null==o?void 0:o.auxiliaryTracks.indexOf(e.trackId);s>-1&&r.isSameStoreSDKTrack(e.trackId,null==o?void 0:o.auxiliaryTracks[s])&&(null==o||o.auxiliaryTracks.splice(s,1))}delete i[e.trackId],delete r.hmsSDKTracks[e.trackId]}),"trackRemoved")},r.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)}}(),r.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)}}(),r.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)}}(),r.getMediaSettings=function(e){var t,r,n,o,i;return{audioInputDeviceId:null==(t=e.audioTrack)||null==(r=t.getMediaTrackSettings())?void 0:r.deviceId,videoInputDeviceId:null==(n=e.videoTrack)||null==(o=n.getMediaTrackSettings())?void 0:o.deviceId,audioOutputDeviceId:null==(i=this.sdk.getAudioOutput().getDevice())?void 0:i.deviceId}},r.setTrackVolume=function(e,t){var r=this.hmsSDKTracks[t];r?r instanceof o.HMSAudioTrack?(r.setVolume(e),this.syncRoomState("trackVolume")):me.w("track "+t+" is not an audio track"):this.logPossibleInconsistency("track "+t+" not present, unable to set volume")},r.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},r.logPossibleInconsistency=function(e){me.w("possible inconsistency detected - ",e)},r.addRemoveVideoPlugin=function(){var e=c(h.mark((function e(t,r,n){var o,i;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return me.w("Invalid plugin received in store"),e.abrupt("return");case 3:if(!(o=this.store.getState(W))){e.next=19;break}if(!(i=this.hmsSDKTracks[o])){e.next=18;break}if("add"!==r){e.next=12;break}return e.next=10,i.addPlugin(t,n);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+"VideoPlugin"),e.next=19;break;case 18:this.logPossibleInconsistency("track "+o+" 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)}}(),r.addRemoveAudioPlugin=function(){var e=c(h.mark((function e(t,r){var n,o;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return me.w("Invalid plugin received in store"),e.abrupt("return");case 3:if(!(n=this.store.getState(J))){e.next=19;break}if(!(o=this.hmsSDKTracks[n])){e.next=18;break}if("add"!==r){e.next=12;break}return e.next=10,o.addPlugin(t);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+"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)}}(),r.isSameStoreSDKTrack=function(e,t){var r;return!!t&&(null==(r=this.hmsSDKTracks[t])?void 0:r.trackId)===e},r.onRoleChangeRequest=function(e){this.setState((function(t){0===t.roleChangeRequests.length&&t.roleChangeRequests.push(E.convertRoleChangeRequest(e))}),"roleChangeRequest")},r.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")},r.onRoleUpdate=function(){this.syncRoomState("roleUpdate")},r.getStoreLocalTrackIDfromSDKTrack=function(e){var t=this;return this.store.getState(Q).find((function(r){return t.hmsSDKTracks[r].trackId===e.trackId}))},(t=[{key:"playlist",get:function(){var e,t,r,n,o,i,s=this,a=this.sdk.getPlaylistManager();return{play:(i=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.url,n=t.type,e.next=3,null==a?void 0:a.setEnabled(!0,{url:r,type:n});case 3:s.syncRoomState("playOnPlaylist");case 4:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)}),pause:(o=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.url,n=t.type,e.next=3,null==a?void 0:a.setEnabled(!1,{url:r,type:n});case 3:s.syncRoomState("pauseOnPlaylist");case 4:case"end":return e.stop()}}),e)}))),function(e){return o.apply(this,arguments)}),playNext:(n=c(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.type,e.next=3,null==a?void 0:a.playNext(r);case 3:s.syncRoomState("playNextOnPlaylist");case 4:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)}),playPrevious:(r=c(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.type,e.next=3,null==a?void 0:a.playPrevious(r);case 3:s.syncRoomState("playPreviousOnPlaylist");case 4:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)}),seek:(t=c(h.mark((function e(t){var r,n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.type,void 0!==(r=t.seekValue)){e.next=3;break}throw Error("Please pass a valid seekValue");case 3:null==a||a.seek(r,n),s.syncRoomState("seekOnPlaylist");case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)}),setVolume:function(e){var t=e.volume,r=e.type;if("number"!=typeof t)throw Error("Please pass a valid volume between 0-100");s.sdk.getPlaylistManager().setVolume(t,r),s.syncRoomState("volumeOnPlaylist")},setList:function(e){var t=e.list;if(!t)throw Error("Please pass a list of playlist items in the action");null==a||a.setList(t),s.syncRoomState("setListOnPlaylist")},stop:(e=c(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.type,e.next=3,null==a?void 0:a.stop(r);case 3:s.syncRoomState("stop"+r+"Playlist");case 4:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),e}(),pt=((lt={})[o.HMSPeerUpdate.PEER_JOINED]=exports.HMSNotificationTypes.PEER_JOINED,lt[o.HMSPeerUpdate.PEER_LEFT]=exports.HMSNotificationTypes.PEER_LEFT,lt[o.HMSPeerUpdate.ROLE_UPDATED]=exports.HMSNotificationTypes.ROLE_UPDATED,lt[o.HMSPeerUpdate.AUDIO_TOGGLED]="PEER_AUDIO_UPDATED",lt[o.HMSPeerUpdate.VIDEO_TOGGLED]="PEER_VIDEO_UPDATED",lt),ht=((dt={})[o.HMSTrackUpdate.TRACK_ADDED]=exports.HMSNotificationTypes.TRACK_ADDED,dt[o.HMSTrackUpdate.TRACK_REMOVED]=exports.HMSNotificationTypes.TRACK_REMOVED,dt[o.HMSTrackUpdate.TRACK_MUTED]=exports.HMSNotificationTypes.TRACK_MUTED,dt[o.HMSTrackUpdate.TRACK_UNMUTED]=exports.HMSNotificationTypes.TRACK_UNMUTED,dt),vt=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(Re(null==t?void 0:t.id))||t,n=pt[e];if(n){var o=this.createNotification(n,r,exports.HMSNotificationSeverity.INFO);this.emitEvent(o)}},t.sendTrackUpdate=function(e,t){var r=this.store.getState(Pe(t)),n=ht[e];if(n){var o=this.createNotification(n,r,exports.HMSNotificationSeverity.INFO);this.emitEvent(o)}},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.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}(),St=function(){function e(t,r,n){this.store=t||e.createNewHMSStore(),this.notifications=n||new vt(this.store),this.actions=r||new ft(this.store,new o.HMSSdk,this.notifications),this.initialTriggerOnSubscribe=!1}var i=e.prototype;return i.triggerOnSubscribe=function(){this.initialTriggerOnSubscribe||(e.makeStoreTriggerOnSubscribe(this.store),this.initialTriggerOnSubscribe=!0)},i.getStore=function(){return this.store},i.getHMSActions=function(){return this.actions},i.getNotifications=function(){return{onNotification:this.notifications.onNotification}},e.createNewHMSStore=function(){var n=r((function(){return m()})),o=n.setState;n.setState=function(e){var r="function"==typeof e?t(e):e;o(r)};var i=n.getState;return n.getState=function(e){return e?e(i()):i()},e.useShallowCheckInSubscribe(n),u({},n,{namedSetState:e.setUpDevtools(n,"HMSStore")})},e.makeStoreTriggerOnSubscribe=function(e){var t=e.subscribe;e.subscribe=function(r,n,o){return r(e.getState(n),void 0),t(r,n,o)}},e.useShallowCheckInSubscribe=function(e){var t=e.subscribe;e.subscribe=function(e,r,o){return r||(r=function(e){return e}),t(e,r,o=o||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 o=n.connect(e.devtoolsOptions(r));o.prefix=r?r+" > ":"";var i=t.setState;return t.setState=function(e){i(e),o.send(o.prefix+"setState",t.getState())},o.subscribe(e.devtoolsSubscribe(o,t,i)),o.send("setUpStore",t.getState()),function(e,r){i(e),o.send(r||o.prefix+"action",t.getState())}},e.devtoolsOptions=function(e){return{name:e,actionsBlacklist:["audioLevel","playlistProgress"]}},e.devtoolsSubscribe=function(e,t,r){return function(n){var o,i;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==(o=n.payload)?void 0:o.type))e.init(t.getState());else if("DISPATCH"===n.type&&"IMPORT_STATE"===(null==(i=n.payload)?void 0:i.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,o){var i=n.state,s=c[o]||e.prefix+"setState";0===o?e.init(i):(r(i),e.send(s,t.getState()))}))}}},e}();Object.defineProperty(exports,"HMSLogLevel",{enumerable:!0,get:function(){return o.HMSLogLevel}}),Object.defineProperty(exports,"HMSSimulcastLayer",{enumerable:!0,get:function(){return o.HMSSimulcastLayer}}),exports.HMSReactiveStore=St,exports.createDefaultStoreState=m,exports.selectAudioTrackByPeerID=Me,exports.selectAudioTrackVolume=Fe,exports.selectAudioVolumeByPeerID=Ge,exports.selectAuxiliaryAudioByPeerID=Ae,exports.selectAuxiliaryTracksByPeerID=Ie,exports.selectAvailableRoleNames=pe,exports.selectBroadcastMessages=Ye,exports.selectBroadcastMessagesUnreadCount=Ze,exports.selectCameraStreamByPeerID=De,exports.selectDegradedTracks=ie,exports.selectDevices=function(e){return e.devices},exports.selectDominantSpeaker=Y,exports.selectHMSMessages=ce,exports.selectHMSMessagesCount=se,exports.selectIsAllowedToPublish=st,exports.selectIsAllowedToSubscribe=ve,exports.selectIsAudioLocallyMuted=Be,exports.selectIsConnectedToRoom=B,exports.selectIsInPreview=le,exports.selectIsLocalAudioEnabled=function(e){var t=F(e);return L(e,null==t?void 0:t.audioTrack)},exports.selectIsLocalAudioPluginPresent=function(e){return i.createSelector([ct],(function(t){return t.includes(e)}))},exports.selectIsLocalScreenShared=Z,exports.selectIsLocalVideoDisplayEnabled=$,exports.selectIsLocalVideoEnabled=z,exports.selectIsLocalVideoPluginPresent=function(e){return i.createSelector([at],(function(t){return t.includes(e)}))},exports.selectIsLocallyMutedByPeerID=je,exports.selectIsPeerAudioEnabled=Ve,exports.selectIsPeerVideoEnabled=Ke,exports.selectIsScreenShareLocallyMutedByPeerID=qe,exports.selectIsSomeoneScreenSharing=te,exports.selectLocalAudioTrackID=J,exports.selectLocalMediaSettings=function(e){return e.settings},exports.selectLocalPeer=F,exports.selectLocalPeerID=G,exports.selectLocalPeerRole=he,exports.selectLocalTrackIDs=Q,exports.selectLocalVideoTrackID=W,exports.selectMessageIDsInOrder=H,exports.selectMessagesByPeerID=et,exports.selectMessagesByRole=tt,exports.selectMessagesMap=C,exports.selectMessagesUnreadCountByPeerID=nt,exports.selectMessagesUnreadCountByRole=rt,exports.selectPeerAudioByID=Ne,exports.selectPeerByID=Re,exports.selectPeerNameByID=Ee,exports.selectPeerScreenSharing=ee,exports.selectPeerSharingAudio=re,exports.selectPeerSharingVideoPlaylist=oe,exports.selectPeers=j,exports.selectPeersMap=A,exports.selectPeersScreenSharing=ne,exports.selectPeersWithAudioStatus=ot,exports.selectPermissions=Se,exports.selectPlaylist=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),i.createSelector(U(e),(function(e){return Object.values(e)}))},exports.selectPlaylistAudioTrackByPeerID=He,exports.selectPlaylistCurrentSelection=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),i.createSelector(U(e),V(e),(function(e,t){if(t.id)return e[t.id]}))},exports.selectPlaylistMap=U,exports.selectPlaylistProgress=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].progress}},exports.selectPlaylistSelection=V,exports.selectPlaylistVideoTrackByPeerID=Ce,exports.selectPlaylistVolume=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].volume}},exports.selectRemotePeers=X,exports.selectRoleByRoleName=function(e){return i.createSelector([fe],(function(t){return t[e]}))},exports.selectRoleChangeRequest=it,exports.selectRolesMap=fe,exports.selectRoom=N,exports.selectRoomStarted=de,exports.selectRoomState=ue,exports.selectScreenShareAudioByPeerID=Ue,exports.selectScreenShareByPeerID=function(e){return i.createSelector(_e(e),(function(e){return e.video}))},exports.selectScreenSharesByPeerId=_e,exports.selectScreenshareAudioVolumeByPeerID=Je,exports.selectSimulcastLayerByTrack=We,exports.selectSpeakers=K,exports.selectTrackAudioByID=Le,exports.selectTrackByID=Pe,exports.selectTracksMap=_,exports.selectUnreadHMSMessagesCount=ae,exports.selectVideoTrackByPeerID=we; | ||
"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")),o=require("@100mslive/hms-video"),i=require("reselect"),s=e(require("events"));function a(e,t,r,n,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}function c(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){a(i,n,o,s,c,"next",e)}function c(e){a(i,n,o,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 f,p,h=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=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 o=Object.create((t&&t.prototype instanceof d?t:d).prototype),i=new b(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){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,i),o}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 f(){}function p(){}var h={};a(h,o,(function(){return this}));var v=Object.getPrototypeOf,S=v&&v(v(R([])));S&&S!==t&&r.call(S,o)&&(h=S);var y=p.prototype=d.prototype=Object.create(h);function m(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){var n;this._invoke=function(o,i){function s(){return new t((function(n,s){!function n(o,i,s,a){var c=u(e[o],e,i);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)}(o,i,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 o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function x(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 T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function b(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function R(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=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 i.next=i}}return{next:E}}function E(){return{value:void 0,done:!0}}return f.prototype=p,a(y,"constructor",p),a(p,"constructor",f),f.displayName=a(p,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,a(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},m(g.prototype),a(g.prototype,i,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var s=new g(c(t,r,n,o),i);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},m(y),a(y,s,"Generator"),a(y,o,(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(T),!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 o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.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),T(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 o=n.arg;T(r)}return o}}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)}}(p={exports:{}}),p.exports);(f=exports.HMSRoomState||(exports.HMSRoomState={})).Disconnected="Disconnected",f.Preview="Preview",f.Connecting="Connecting",f.Connected="Connected",f.Reconnecting="Reconnecting",f.Failed="Failed";var v,S,y,m=function(){return{room:{id:"",isConnected:!1,name:"",peers:[],shareableLink:"",hasWaitingRoom:!1,roomState:exports.HMSRoomState.Disconnected},peers:{},tracks:{},playlist:{audio:{list:{},selection:{id:""},progress:0,volume:0},video:{list:{},selection:{id:""},progress:0,volume: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.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 g=function(e,t){return e&&t},k=function(e,t){return e&&!t},x=function(e,t){return!e&&t},T=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,o=d(e);!(r=o()).done;)n.add(r.value);for(var i,s=d(t);!(i=s()).done;)n.add(i.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){var t={id:e.trackId,source:e.source,type:e.type,enabled:e.enabled,displayEnabled:e.enabled};return this.enrichTrack(t,e),t},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 o.HMSRemoteAudioTrack){var i=r.getVolume()||0;t.volume=i}e.enrichVideoTrack(t,r)},e.enrichVideoTrack=function(e,t){t instanceof o.HMSRemoteVideoTrack&&(e.layer=t.getSimulcastLayer(),e.degraded=t.degraded,T(t.getSimulcastDefinitions(),e.layerDefinitions)||(e.layerDefinitions=t.getSimulcastDefinitions())),(t instanceof o.HMSLocalVideoTrack||t instanceof o.HMSLocalAudioTrack)&&(T(t.getPlugins(),e.plugins)||(e.plugins=t.getPlugins()))},e.convertRoom=function(e){return{id:e.id,name:e.name,hasWaitingRoom:e.hasWaitingRoom,shareableLink:e.shareableLink}},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,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),o=e.getCurrentProgress(t),i=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&&i})})),{list:r,selection:{id:null==n?void 0:n.id,hasPrevious:c>0,hasNext:c<a.length-1},progress:o,volume:s}},e}();function P(e,t,r){void 0===r&&(r=D);var n=void 0,o=void 0;if(t)for(var i,s=d(t.auxiliaryTracks);!(i=s()).done;){var a=e[i.value];r(a)&&(o=w(a)?a:o,n=M(a)?a:n)}return{video:n,audio:o}}function w(e){return e&&"audio"===e.type}function M(e){return e&&"video"===e.type}function D(e){return e&&"screen"===e.source}function I(e){return e&&"playlist"===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 N=function(e){return e.room},A=function(e){return e.peers},C=function(e){return e.messages.byID},H=function(e){return e.messages.allIDs},_=function(e){return e.tracks},U=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].list}},V=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].selection}},K=function(e){return e.speakers},B=i.createSelector([N],(function(e){return e&&e.isConnected})),j=i.createSelector([N,A],(function(e,t){return e.peers.map((function(e){return t[e]}))})),q=i.createSelector(_,(function(e){return Object.values(e)})),F=i.createSelector(j,(function(e){return e.filter((function(e){return e.isLocal}))[0]})),G=i.createSelector(F,(function(e){return null==e?void 0:e.id})),J=i.createSelector(F,(function(e){return null==e?void 0:e.audioTrack})),W=i.createSelector(F,(function(e){return null==e?void 0:e.videoTrack})),Q=i.createSelector([J,W,i.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=i.createSelector(j,(function(e){return e.filter((function(e){return!e.isLocal}))})),Y=i.createSelector(A,K,(function(e,t){var r=Object.entries(t).sort((function(e,t){var r,n,o=(null==(r=e[1])?void 0:r.audioLevel)||0;return((null==(n=t[1])?void 0:n.audioLevel)||0)>o?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 L(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=i.createSelector(F,_,(function(e,t){var r=P(t,e);return!(!r.video&&!r.audio)})),ee=i.createSelector(A,_,(function(e,t){var r=void 0;for(var n in e){var o=e[n],i=P(t,o);if(i.video)return o;i.audio&&!r&&(r=o)}return r})),te=i.createSelector(ee,(function(e){return!!e})),re=i.createSelector(A,_,(function(e,t){for(var r in e){var n=e[r],o=P(t,n);if(!o.video&&o.audio)return n}})),ne=i.createSelector(A,_,(function(e,t){var r=[],n=[];for(var o in e){var i=e[o],s=P(t,i),a=s.audio;s.video?r.push(i):a&&n.push(i)}return r.concat(n)})),oe=i.createSelector(A,_,(function(e,t){for(var r in e){var n=e[r];if(P(t,n,I).video)return n}})),ie=i.createSelector(q,(function(e){return e.filter(O)})),se=i.createSelector(H,(function(e){return e.length})),ae=i.createSelector(C,(function(e){return Object.values(e).filter((function(e){return!e.read})).length})),ce=i.createSelector(H,C,(function(e,t){var r=[];return e.forEach((function(e){r.push(t[e])})),r})),ue=i.createSelector([N],(function(e){return e&&e.roomState})),le=i.createSelector(ue,(function(e){return e===exports.HMSRoomState.Preview})),de=i.createSelector(N,(function(e){return e.roomState!==exports.HMSRoomState.Disconnected})),fe=function(e){return e.roles},pe=i.createSelector([fe],(function(e){return Object.keys(e)})),he=i.createSelector([F,fe],(function(e,t){return null!=e&&e.roleName?t[e.roleName]:null})),ve=i.createSelector([he],(function(e){var t;return!(null==e||null==(t=e.subscribeParams)||!t.subscribeToRoles)&&e.subscribeParams.subscribeToRoles.length>0})),Se=i.createSelector(he,(function(e){return null==e?void 0:e.permissions})),ye="HMS-Store:",me=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,[o.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,[o.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,[o.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,[o.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,[o.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 o.HMSLogLevel.VERBOSE:var i;(i=console).log.apply(i,[ye].concat(r));break;case o.HMSLogLevel.DEBUG:var s;(s=console).debug.apply(s,[ye].concat(r));break;case o.HMSLogLevel.INFO:var a;(a=console).info.apply(a,[ye].concat(r));break;case o.HMSLogLevel.WARN:var c;(c=console).warn.apply(c,[ye].concat(r));break;case o.HMSLogLevel.ERROR:var u;(u=console).error.apply(u,[ye].concat(r))}}},e}();function ge(e){return function(t){return function(r){return e(r,t)}}}me.level=o.HMSLogLevel.VERBOSE;var ke=function(e,t){return t},xe=function(e,t){return t},Te=i.createSelector([A,ke],(function(e,t){return t?e[t]:null})),be=i.createSelector([_,function(e,t){return t}],(function(e,t){return t?e[t]:null})),Re=ge(Te),Ee=ge(i.createSelector(Te,(function(e){return null==e?void 0:e.name}))),Pe=ge(be),we=ge((function(e,t){var r=Te(e,t);if(r&&r.videoTrack&&""!==r.videoTrack)return e.tracks[r.videoTrack]})),Me=ge((function(e,t){var r=Te(e,t);if(r&&r.audioTrack&&""!==r.audioTrack)return e.tracks[r.audioTrack]})),De=we,Ie=ge((function(e,t){var r=Te(e,t);return(null==r?void 0:r.auxiliaryTracks.map((function(t){return e.tracks[t]})))||[]})),Oe=function(e,t){return t?e.speakers[t]:null},Le=ge(i.createSelector(Oe,(function(e){return(null==e?void 0:e.audioLevel)||0}))),Ne=ge(i.createSelector((function(e,t){var r=Me(t)(e);return Oe(e,null==r?void 0:r.id)}),(function(e){return(null==e?void 0:e.audioLevel)||0}))),Ae=ge((function(e,t){var r=Te(e,t);if(r){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){return w(e.tracks[t])}));return n?e.tracks[n]:void 0}})),Ce=ge(i.createSelector(_,Te,(function(e,t){var r=null==t?void 0:t.auxiliaryTracks.find((function(t){var r=e[t];return I(r)&&M(r)}));return r?e[r]:void 0}))),He=ge(i.createSelector(_,Te,(function(e,t){var r=null==t?void 0:t.auxiliaryTracks.find((function(t){var r=e[t];return I(r)&&w(r)}));return r?e[r]:void 0}))),_e=ge(i.createSelector(_,Te,(function(e,t){return P(e,t)}))),Ue=function(e){return i.createSelector(_e(e),(function(e){return e.audio}))},Ve=ge((function(e,t){var r=Te(e,t);return L(e,null==r?void 0:r.audioTrack)})),Ke=ge((function(e,t){var r=Te(e,t);return L(e,null==r?void 0:r.videoTrack)})),Be=ge((function(e,t){if(t&&e.tracks[t])return 0===e.tracks[t].volume})),je=ge((function(e,t){var r=Te(e,t);return Be(null==r?void 0:r.audioTrack)(e)})),qe=ge((function(e,t){var r=Ue(t)(e);return Be(null==r?void 0:r.id)(e)})),Fe=ge((function(e,t){var r=be(e,t);if(r)return"audio"!==r.type?void me.w("Please pass audio track here"):r.volume})),Ge=ge((function(e,t){var r=Te(e,t);return Fe(null==r?void 0:r.audioTrack)(e)})),Je=ge((function(e,t){var r=Ue(t)(e);return Fe(null==r?void 0:r.id)(e)})),We=ge((function(e,t){var r=be(e,t);if(r)return"video"!==r.type?void me.w("Please pass video track here"):r.layer})),Qe=i.createSelector([ce,G,ke],(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)}))})),Xe=i.createSelector([ce,xe],(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))}))})),Ye=i.createSelector(ce,(function(e){return e.filter((function(e){var t;return!(e.recipientPeer||null!=(t=e.recipientRoles)&&t.length)}))})),ze=i.createSelector([Xe,xe],(function(e){return e?e.filter((function(e){return!e.read})).length:0})),$e=i.createSelector([Qe,ke],(function(e){return e?e.filter((function(e){return!e.read})).length:0})),Ze=i.createSelector(Ye,(function(e){return e.filter((function(e){return!e.read})).length})),et=ge(Qe),tt=ge(Xe),rt=ge(ze),nt=ge($e),ot=i.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)}}))})),it=i.createSelector([function(e){return e.roleChangeRequests[0]||null},A,fe],(function(e,t,r){return e?{requestedBy:t[e.requestedBy],role:r[e.roleName],token:e.token}:null})),st=i.createSelector([he],(function(e){var t,r=!1,n=!1,o=!1;return null!=e&&null!=(t=e.publishParams)&&t.allowed&&(r=e.publishParams.allowed.includes("video"),n=e.publishParams.allowed.includes("audio"),o=e.publishParams.allowed.includes("screen")),{video:r,audio:n,screen:o}})),at=i.createSelector([W,_],(function(e,t){var r,n=null;return e&&(n=t[e]),(null==(r=n)?void 0:r.plugins)||[]})),ct=i.createSelector([J,_],(function(e,t){var r,n=null;return e&&(n=t[e]),(null==(r=n)?void 0:r.plugins)||[]}));function ut(e){return e instanceof o.HMSRemoteAudioTrack||e instanceof o.HMSRemoteVideoTrack}var lt,dt,ft=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}),"playlistProgress")},this.setState=function(e,t){return n.store.namedSetState(e,t)},this.store=e,this.sdk=t,this.hmsNotifications=r}var t,r=e.prototype;return r.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)}}(),r.setVolume=function(e,t){t?this.setTrackVolume(e,t):(this.sdk.getAudioOutput().setVolume(e),this.syncRoomState("setVolume"))},r.setAudioOutputDevice=function(e){this.sdk.getAudioOutput().setDevice(e),this.syncRoomState("setAudioOutput")},r.setPreferredLayer=function(e,t){var r=this.hmsSDKTracks[e];r?r instanceof o.HMSRemoteVideoTrack?(r.preferLayer(t),this.syncRoomState("setPreferredLayer")):me.w("track "+e+" is not an video track"):this.logPossibleInconsistency("track "+e+" not present, unable to set preffer layer")},r.preview=function(){var e=c(h.mark((function e(t){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:return e.prev=3,e.next=6,this.sdkPreviewWithListeners(t);case 6:this.setState((function(e){e.room.roomState=exports.HMSRoomState.Connecting}),"preview"),e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(3),me.e("Cannot show preview. Failed to connect to room - ",e.t0),e.t0;case 13:case"end":return e.stop()}}),e,this,[[3,9]])})));return function(t){return e.apply(this,arguments)}}(),r.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,me.e("Failed to connect to room - ",e),e}},r.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"),me.i("left room")})).catch((function(e){me.e("error in leaving room - ",e)})));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.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)}}(),r.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)}}(),r.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)}}(),r.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)}}(),r.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)}}(),r.setEnabledTrack=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((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:i.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?o.HMSTrackUpdate.TRACK_UNMUTED:o.HMSTrackUpdate.TRACK_MUTED,t);case 18:case"end":return e.stop()}}),e,this,[[5,11]])})));return function(t,r){return e.apply(this,arguments)}}(),r.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)}}(),r.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)}}(),r.sendMessage=function(e){this.sendBroadcastMessage(e)},r.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)}}(),r.sendGroupMessage=function(){var e=c(h.mark((function e(t,r,n){var o,i;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=this.store.getState(fe),i=r.map((function(e){return o[e]})),e.next=4,this.sdk.sendGroupMessage(t,i,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)}}(),r.sendDirectMessage=function(){var e=c(h.mark((function e(t,r,n){var o;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=this.hmsSDKPeers[r],e.next=3,this.sdk.sendDirectMessage(t,o);case 3:this.updateMessageInStore(e.sent,{message:t,recipientPeer:o.peerId,type:n});case 5:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),r.updateMessageInStore=function(e,t){if(!e)throw me.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},r.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")},r.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 o=n.store.subscribe(function(){var i=c(h.mark((function i(s){return h.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!s){i.next=5;break}return i.next=3,n.attachVideoInternal(t,r);case 3:o(),e();case 5:case"end":return i.stop()}}),i)})));return function(e){return i.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)}}(),r.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=6;break}return e.next=4,n.removeSink(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("no video track found to remove sink");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),r.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)}}(),r.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)}}(),r.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)}}(),r.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)}}(),r.changeRole=function(){var e=c(h.mark((function e(t,r,n){var o;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===n&&(n=!1),o=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(o,r,n);case 7:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),r.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)||me.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)}}(),r.rejectChangeRole=function(e){this.removeRoleChangeRequest(e)},r.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 me.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)}}(),r.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)}}(),r.setRemoteTrackEnabled=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("string"!=typeof t){e.next=10;break}if(!(n=this.hmsSDKTracks[t])||!ut(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 o.setRemoteTrackEnabled(e,r)}));case 11:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),r.setLogLevel=function(e){me.level=e,this.sdk.setLogLevel(e)},r.resetState=function(e){void 0===e&&(e="resetState"),this.setState((function(e){Object.assign(e,m())}),e),this.isRoomJoinCalled=!1,this.hmsSDKTracks={}},r.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),onRemovedFromRoom:this.onRemovedFromRoom.bind(this)}),this.sdk.addAudioListener({onAudioLevelUpdate:this.onAudioLevelUpdate.bind(this)})},r.onRemovedFromRoom=function(e){var t=this.store.getState(Re(e.requestedBy.peerId));t?(this.hmsNotifications.sendLeaveRoom(u({},e,{requestedBy:t})),me.i("resetting state after peer removed",e),this.resetState(e.roomEnded?"roomEnded":"removedFromRoom")):this.logPossibleInconsistency("Not found peer who requested leave room, "+e.requestedBy)},r.onDeviceChange=function(e){var t=e.devices;if(t&&(this.setState((function(e){T(e.devices.audioInput,t.audioInput)||(e.devices.audioInput=t.audioInput),T(e.devices.videoInput,t.videoInput)||(e.devices.videoInput=t.videoInput),T(e.devices.audioOutput,t.audioOutput)||(e.devices.audioOutput=t.audioOutput)}),"deviceChange"),this.syncRoomState("deviceChangeSync"),e.selection)){var r=E.convertDeviceChangeUpdate(e);this.hmsNotifications.sendDeviceChange(r)}},r.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)}}(),r.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)}}(),r.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)}}(),r.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:n instanceof o.HMSRemoteVideoTrack&&n.getSimulcastDefinitions().length>0&&this.setState((function(e){var r=n.getSimulcastLayer();e.tracks[t].layer=r}),"updateLayerOnAttach"),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)}}(),r.syncRoomState=function(e){for(var t,r=this,n={},o=[],i={},s={},a={},c=d(this.sdk.getPeers());!(t=c()).done;){var u=t.value,l=E.convertPeer(u);n[l.id]=l,o.push(l.id),this.hmsSDKPeers[l.id]=u;for(var f,p=d([u.audioTrack,u.videoTrack].concat(u.auxiliaryTracks));!(f=p()).done;){var h=f.value;if(h){var v=E.convertTrack(h);i[v.id]=v,s[h.trackId]=h}}l.isLocal&&Object.assign(a,this.getMediaSettings(u))}this.setState((function(e){e.room.peers=o;var t=e.tracks;!function(e,t,r,n){for(var o,i=d(b(Object.keys(e),Object.keys(t)));!(o=i()).done;){var s=o.value,a=e[s],c=t[s];g(a,c)?(T(a.auxiliaryTracks,c.auxiliaryTracks)&&(c.auxiliaryTracks=a.auxiliaryTracks),R(a,c,r,n),Object.assign(a,c)):k(a,c)?delete e[s]:x(a,c)&&(e[s]=c)}}(e.peers,n,i,s),function(e,t){for(var r,n=d(b(Object.keys(e),Object.keys(t)));!(r=n()).done;){var o=r.value,i=e[o],s=t[o];g(i,s)?Object.assign(i,s):k(i,s)?delete e[o]:x(i,s)&&(e[o]=s)}}(t,i),Object.assign(e.settings,a),r.hmsSDKTracks=s,Object.assign(e.roles,E.convertRoles(r.sdk.getRoles())),Object.assign(e.playlist,E.convertPlaylist(r.sdk.getPlaylistManager()))}),e)},r.onPreview=function(e){this.setState((function(t){Object.assign(t.room,E.convertRoom(e)),t.room.roomState=exports.HMSRoomState.Preview}),"previewStart"),this.syncRoomState("previewSync")},r.onJoin=function(e){this.setState((function(t){Object.assign(t.room,E.convertRoom(e)),t.room.isConnected=!0,t.room.roomState=exports.HMSRoomState.Connected}),"joined"),this.syncRoomState("joinSync"),this.sdk.getPlaylistManager().on("progress",this.setProgress)},r.onRoomUpdate=function(){this.syncRoomState("roomUpdate")},r.onPeerUpdate=function(e,t){if(e!==o.HMSPeerUpdate.BECAME_DOMINANT_SPEAKER&&e!==o.HMSPeerUpdate.RESIGNED_DOMINANT_SPEAKER){var r=this.store.getState(Re(t.peerId)),n="peerUpdate";e===o.HMSPeerUpdate.PEER_JOINED?n="peerJoined":e===o.HMSPeerUpdate.PEER_LEFT&&(n="peerLeft"),this.syncRoomState(n),r||(r=this.store.getState(Re(t.peerId))),this.hmsNotifications.sendPeerUpdate(e,r)}},r.onTrackUpdate=function(e,t,r){e===o.HMSTrackUpdate.TRACK_REMOVED?(this.hmsNotifications.sendTrackUpdate(e,t.trackId),this.handleTrackRemove(t,r)):(this.syncRoomState(e===o.HMSTrackUpdate.TRACK_ADDED?"trackAdded":"trackUpdate"),this.hmsNotifications.sendTrackUpdate(e,t.trackId))},r.onMessageReceived=function(e){var t=E.convertMessage(e);t.read=!1,this.onHMSMessage(t),this.hmsNotifications.sendMessageReceived(t)},r.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")},r.onAudioLevelUpdate=function(e){this.setState((function(t){var r={};e.forEach((function(e){if(e.track){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,o=Object.entries(t.speakers);n<o.length;n++){var i=o[n],s=i[0],a=i[1];a.audioLevel=r[s]||0,0===a.audioLevel&&delete t.speakers[s]}}),"audioLevel")},r.onChangeTrackStateRequest=function(e){var t=this.store.getState(Re(e.requestedBy.peerId)),r=this.getStoreLocalTrackIDfromSDKTrack(e.track),n=this.store.getState(Pe(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)},r.onReconnected=function(){this.syncRoomState("reconnectedSync"),this.hmsNotifications.sendReconnected(),this.setState((function(e){e.room.roomState=exports.HMSRoomState.Connected}),"reconnected")},r.onReconnecting=function(e){var t=E.convertException(e);me.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")},r.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),me.e("received error from sdk",t)},r.handleTrackRemove=function(e,t){var r=this;this.setState((function(n){var o=n.peers[t.peerId],i=n.tracks;if(r.isSameStoreSDKTrack(e.trackId,null==o?void 0:o.audioTrack))null==o||delete o.audioTrack;else if(r.isSameStoreSDKTrack(e.trackId,null==o?void 0:o.videoTrack))null==o||delete o.videoTrack;else{var s=null==o?void 0:o.auxiliaryTracks.indexOf(e.trackId);s>-1&&r.isSameStoreSDKTrack(e.trackId,null==o?void 0:o.auxiliaryTracks[s])&&(null==o||o.auxiliaryTracks.splice(s,1))}delete i[e.trackId],delete r.hmsSDKTracks[e.trackId]}),"trackRemoved")},r.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)}}(),r.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)}}(),r.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)}}(),r.getMediaSettings=function(e){var t,r,n,o,i;return{audioInputDeviceId:null==(t=e.audioTrack)||null==(r=t.getMediaTrackSettings())?void 0:r.deviceId,videoInputDeviceId:null==(n=e.videoTrack)||null==(o=n.getMediaTrackSettings())?void 0:o.deviceId,audioOutputDeviceId:null==(i=this.sdk.getAudioOutput().getDevice())?void 0:i.deviceId}},r.setTrackVolume=function(e,t){var r=this.hmsSDKTracks[t];r?r instanceof o.HMSAudioTrack?(r.setVolume(e),this.syncRoomState("trackVolume")):me.w("track "+t+" is not an audio track"):this.logPossibleInconsistency("track "+t+" not present, unable to set volume")},r.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},r.logPossibleInconsistency=function(e){me.w("possible inconsistency detected - ",e)},r.addRemoveVideoPlugin=function(){var e=c(h.mark((function e(t,r,n){var o,i;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return me.w("Invalid plugin received in store"),e.abrupt("return");case 3:if(!(o=this.store.getState(W))){e.next=19;break}if(!(i=this.hmsSDKTracks[o])){e.next=18;break}if("add"!==r){e.next=12;break}return e.next=10,i.addPlugin(t,n);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+"VideoPlugin"),e.next=19;break;case 18:this.logPossibleInconsistency("track "+o+" 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)}}(),r.addRemoveAudioPlugin=function(){var e=c(h.mark((function e(t,r){var n,o;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return me.w("Invalid plugin received in store"),e.abrupt("return");case 3:if(!(n=this.store.getState(J))){e.next=19;break}if(!(o=this.hmsSDKTracks[n])){e.next=18;break}if("add"!==r){e.next=12;break}return e.next=10,o.addPlugin(t);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+"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)}}(),r.isSameStoreSDKTrack=function(e,t){var r;return!!t&&(null==(r=this.hmsSDKTracks[t])?void 0:r.trackId)===e},r.onRoleChangeRequest=function(e){this.setState((function(t){0===t.roleChangeRequests.length&&t.roleChangeRequests.push(E.convertRoleChangeRequest(e))}),"roleChangeRequest")},r.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")},r.onRoleUpdate=function(){this.syncRoomState("roleUpdate")},r.getStoreLocalTrackIDfromSDKTrack=function(e){var t=this;return this.store.getState(Q).find((function(r){return t.hmsSDKTracks[r].trackId===e.trackId}))},(t=[{key:"playlist",get:function(){var e,t,r,n,o,i,s=this,a=this.sdk.getPlaylistManager();return{play:(i=c(h.mark((function e(t){var r,n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.type,(r=t.id)&&n){e.next=4;break}return me.w("Please pass id and type to play"),e.abrupt("return");case 4:return e.next=6,null==a?void 0:a.setEnabled(!0,{id:r,type:n});case 6:s.syncRoomState("playOnPlaylist");case 7:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)}),pause:(o=c(h.mark((function e(t){var r,n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.type,(r=t.id)&&n){e.next=4;break}return me.w("Please pass id and type to pause"),e.abrupt("return");case 4:return e.next=6,null==a?void 0:a.setEnabled(!1,{id:r,type:n});case 6:s.syncRoomState("pauseOnPlaylist");case 7:case"end":return e.stop()}}),e)}))),function(e){return o.apply(this,arguments)}),playNext:(n=c(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.type,e.next=3,null==a?void 0:a.playNext(r);case 3:s.syncRoomState("playNextOnPlaylist");case 4:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)}),playPrevious:(r=c(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.type,e.next=3,null==a?void 0:a.playPrevious(r);case 3:s.syncRoomState("playPreviousOnPlaylist");case 4:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)}),seek:(t=c(h.mark((function e(t){var r,n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.type,void 0!==(r=t.seekValue)){e.next=3;break}throw Error("Please pass a valid seekValue");case 3:null==a||a.seek(r,n),s.syncRoomState("seekOnPlaylist");case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)}),setVolume:function(e){var t=e.volume,r=e.type;if("number"!=typeof t)throw Error("Please pass a valid volume between 0-100");s.sdk.getPlaylistManager().setVolume(t,r),s.syncRoomState("volumeOnPlaylist")},setList:function(e){var t=e.list;if(!t)throw Error("Please pass a list of playlist items in the action");null==a||a.setList(t),s.syncRoomState("setListOnPlaylist")},stop:(e=c(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.type,e.next=3,null==a?void 0:a.stop(r);case 3:s.syncRoomState("stop"+r+"Playlist");case 4:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),e}(),pt=((lt={})[o.HMSPeerUpdate.PEER_JOINED]=exports.HMSNotificationTypes.PEER_JOINED,lt[o.HMSPeerUpdate.PEER_LEFT]=exports.HMSNotificationTypes.PEER_LEFT,lt[o.HMSPeerUpdate.ROLE_UPDATED]=exports.HMSNotificationTypes.ROLE_UPDATED,lt[o.HMSPeerUpdate.AUDIO_TOGGLED]="PEER_AUDIO_UPDATED",lt[o.HMSPeerUpdate.VIDEO_TOGGLED]="PEER_VIDEO_UPDATED",lt),ht=((dt={})[o.HMSTrackUpdate.TRACK_ADDED]=exports.HMSNotificationTypes.TRACK_ADDED,dt[o.HMSTrackUpdate.TRACK_REMOVED]=exports.HMSNotificationTypes.TRACK_REMOVED,dt[o.HMSTrackUpdate.TRACK_MUTED]=exports.HMSNotificationTypes.TRACK_MUTED,dt[o.HMSTrackUpdate.TRACK_UNMUTED]=exports.HMSNotificationTypes.TRACK_UNMUTED,dt),vt=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(Re(null==t?void 0:t.id))||t,n=pt[e];if(n){var o=this.createNotification(n,r,exports.HMSNotificationSeverity.INFO);this.emitEvent(o)}},t.sendTrackUpdate=function(e,t){var r=this.store.getState(Pe(t)),n=ht[e];if(n){var o=this.createNotification(n,r,exports.HMSNotificationSeverity.INFO);this.emitEvent(o)}},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.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}(),St=function(){function e(t,r,n){this.store=t||e.createNewHMSStore(),this.notifications=n||new vt(this.store),this.actions=r||new ft(this.store,new o.HMSSdk,this.notifications),this.initialTriggerOnSubscribe=!1}var i=e.prototype;return i.triggerOnSubscribe=function(){this.initialTriggerOnSubscribe||(e.makeStoreTriggerOnSubscribe(this.store),this.initialTriggerOnSubscribe=!0)},i.getStore=function(){return this.store},i.getHMSActions=function(){return this.actions},i.getNotifications=function(){return{onNotification:this.notifications.onNotification}},e.createNewHMSStore=function(){var n=r((function(){return m()})),o=n.setState;n.setState=function(e){var r="function"==typeof e?t(e):e;o(r)};var i=n.getState;return n.getState=function(e){return e?e(i()):i()},e.useShallowCheckInSubscribe(n),u({},n,{namedSetState:e.setUpDevtools(n,"HMSStore")})},e.makeStoreTriggerOnSubscribe=function(e){var t=e.subscribe;e.subscribe=function(r,n,o){return r(e.getState(n),void 0),t(r,n,o)}},e.useShallowCheckInSubscribe=function(e){var t=e.subscribe;e.subscribe=function(e,r,o){return r||(r=function(e){return e}),t(e,r,o=o||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 o=n.connect(e.devtoolsOptions(r));o.prefix=r?r+" > ":"";var i=t.setState;return t.setState=function(e){i(e),o.send(o.prefix+"setState",t.getState())},o.subscribe(e.devtoolsSubscribe(o,t,i)),o.send("setUpStore",t.getState()),function(e,r){i(e),o.send(r||o.prefix+"action",t.getState())}},e.devtoolsOptions=function(e){return{name:e,actionsBlacklist:["audioLevel","playlistProgress"]}},e.devtoolsSubscribe=function(e,t,r){return function(n){var o,i;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==(o=n.payload)?void 0:o.type))e.init(t.getState());else if("DISPATCH"===n.type&&"IMPORT_STATE"===(null==(i=n.payload)?void 0:i.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,o){var i=n.state,s=c[o]||e.prefix+"setState";0===o?e.init(i):(r(i),e.send(s,t.getState()))}))}}},e}();Object.defineProperty(exports,"HMSLogLevel",{enumerable:!0,get:function(){return o.HMSLogLevel}}),Object.defineProperty(exports,"HMSSimulcastLayer",{enumerable:!0,get:function(){return o.HMSSimulcastLayer}}),exports.HMSReactiveStore=St,exports.createDefaultStoreState=m,exports.selectAudioTrackByPeerID=Me,exports.selectAudioTrackVolume=Fe,exports.selectAudioVolumeByPeerID=Ge,exports.selectAuxiliaryAudioByPeerID=Ae,exports.selectAuxiliaryTracksByPeerID=Ie,exports.selectAvailableRoleNames=pe,exports.selectBroadcastMessages=Ye,exports.selectBroadcastMessagesUnreadCount=Ze,exports.selectCameraStreamByPeerID=De,exports.selectDegradedTracks=ie,exports.selectDevices=function(e){return e.devices},exports.selectDominantSpeaker=Y,exports.selectHMSMessages=ce,exports.selectHMSMessagesCount=se,exports.selectIsAllowedToPublish=st,exports.selectIsAllowedToSubscribe=ve,exports.selectIsAudioLocallyMuted=Be,exports.selectIsConnectedToRoom=B,exports.selectIsInPreview=le,exports.selectIsLocalAudioEnabled=function(e){var t=F(e);return L(e,null==t?void 0:t.audioTrack)},exports.selectIsLocalAudioPluginPresent=function(e){return i.createSelector([ct],(function(t){return t.includes(e)}))},exports.selectIsLocalScreenShared=Z,exports.selectIsLocalVideoDisplayEnabled=$,exports.selectIsLocalVideoEnabled=z,exports.selectIsLocalVideoPluginPresent=function(e){return i.createSelector([at],(function(t){return t.includes(e)}))},exports.selectIsLocallyMutedByPeerID=je,exports.selectIsPeerAudioEnabled=Ve,exports.selectIsPeerVideoEnabled=Ke,exports.selectIsScreenShareLocallyMutedByPeerID=qe,exports.selectIsSomeoneScreenSharing=te,exports.selectLocalAudioTrackID=J,exports.selectLocalMediaSettings=function(e){return e.settings},exports.selectLocalPeer=F,exports.selectLocalPeerID=G,exports.selectLocalPeerRole=he,exports.selectLocalTrackIDs=Q,exports.selectLocalVideoTrackID=W,exports.selectMessageIDsInOrder=H,exports.selectMessagesByPeerID=et,exports.selectMessagesByRole=tt,exports.selectMessagesMap=C,exports.selectMessagesUnreadCountByPeerID=nt,exports.selectMessagesUnreadCountByRole=rt,exports.selectPeerAudioByID=Ne,exports.selectPeerByID=Re,exports.selectPeerNameByID=Ee,exports.selectPeerScreenSharing=ee,exports.selectPeerSharingAudio=re,exports.selectPeerSharingVideoPlaylist=oe,exports.selectPeers=j,exports.selectPeersMap=A,exports.selectPeersScreenSharing=ne,exports.selectPeersWithAudioStatus=ot,exports.selectPermissions=Se,exports.selectPlaylist=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),i.createSelector(U(e),(function(e){return Object.values(e)}))},exports.selectPlaylistAudioTrackByPeerID=He,exports.selectPlaylistCurrentSelection=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),i.createSelector(U(e),V(e),(function(e,t){if(t.id)return e[t.id]}))},exports.selectPlaylistMap=U,exports.selectPlaylistProgress=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].progress}},exports.selectPlaylistSelection=V,exports.selectPlaylistVideoTrackByPeerID=Ce,exports.selectPlaylistVolume=function(e){return void 0===e&&(e=exports.HMSPlaylistType.audio),function(t){return t.playlist[e].volume}},exports.selectRemotePeers=X,exports.selectRoleByRoleName=function(e){return i.createSelector([fe],(function(t){return t[e]}))},exports.selectRoleChangeRequest=it,exports.selectRolesMap=fe,exports.selectRoom=N,exports.selectRoomStarted=de,exports.selectRoomState=ue,exports.selectScreenShareAudioByPeerID=Ue,exports.selectScreenShareByPeerID=function(e){return i.createSelector(_e(e),(function(e){return e.video}))},exports.selectScreenSharesByPeerId=_e,exports.selectScreenshareAudioVolumeByPeerID=Je,exports.selectSimulcastLayerByTrack=We,exports.selectSpeakers=K,exports.selectTrackAudioByID=Le,exports.selectTrackByID=Pe,exports.selectTracksMap=_,exports.selectUnreadHMSMessagesCount=ae,exports.selectVideoTrackByPeerID=we; | ||
//# sourceMappingURL=hms-video-store.cjs.production.min.js.map |
@@ -15,3 +15,3 @@ import { HMSPeer, HMSSpeaker, HMSStore, HMSTrack } from '../core'; | ||
export declare let speakerRole: HMSRole; | ||
export declare let playlist: HMSPlaylist; | ||
export declare let playlist: HMSPlaylist<any>; | ||
export declare const ROLES: { | ||
@@ -18,0 +18,0 @@ HOST: string; |
{ | ||
"version": "0.2.41-4", | ||
"version": "0.2.41-5", | ||
"license": "MIT", | ||
@@ -58,3 +58,3 @@ "main": "dist/index.js", | ||
"peerDependencies": { | ||
"@100mslive/hms-video": "0.0.182-5", | ||
"@100mslive/hms-video": "0.0.182-7", | ||
"events": "^3.3.0" | ||
@@ -64,3 +64,3 @@ }, | ||
"@size-limit/file": "^5.0.3", | ||
"@100mslive/hms-video": "0.0.182-5", | ||
"@100mslive/hms-video": "0.0.182-7", | ||
"events": "^3.3.0", | ||
@@ -67,0 +67,0 @@ "husky": "^6.0.0", |
@@ -162,3 +162,3 @@ import { | ||
) { | ||
const convertedPlaylist: Record<string, HMSPlaylistItem> = {}; | ||
const convertedPlaylist: Record<string, HMSPlaylistItem<any>> = {}; | ||
const currentSelection = playlistManager.getCurrentSelection(type); | ||
@@ -168,2 +168,4 @@ const progress = playlistManager.getCurrentProgress(type); | ||
const volume = playlistManager.getVolume(type); | ||
const list = playlistManager.getList(type); | ||
const currentIndex = playlistManager.getCurrentIndex(type); | ||
@@ -179,4 +181,13 @@ playlistManager.getList(type).forEach(value => { | ||
}); | ||
return { list: convertedPlaylist, selection: { id: currentSelection?.id }, progress, volume }; | ||
return { | ||
list: convertedPlaylist, | ||
selection: { | ||
id: currentSelection?.id, | ||
hasPrevious: currentIndex > 0, | ||
hasNext: currentIndex < list.length - 1, | ||
}, | ||
progress, | ||
volume, | ||
}; | ||
} | ||
} |
@@ -102,19 +102,27 @@ import { | ||
return { | ||
play: async ({ url, type }: HMSPlaylistAction) => { | ||
await playlistManager?.setEnabled(true, { url: url!, type: type! }); | ||
play: async <T>({ id, type }: HMSPlaylistAction<T>) => { | ||
if(!id || !type) { | ||
HMSLogger.w("Please pass id and type to play"); | ||
return; | ||
} | ||
await playlistManager?.setEnabled(true, { id, type: type }); | ||
this.syncRoomState('playOnPlaylist'); | ||
}, | ||
pause: async ({ url, type }: HMSPlaylistAction) => { | ||
await playlistManager?.setEnabled(false, { url: url!, type: type! }); | ||
pause: async <T>({ id, type }: HMSPlaylistAction<T>) => { | ||
if(!id || !type) { | ||
HMSLogger.w("Please pass id and type to pause"); | ||
return; | ||
} | ||
await playlistManager?.setEnabled(false, { id, type }); | ||
this.syncRoomState('pauseOnPlaylist'); | ||
}, | ||
playNext: async ({ type }: HMSPlaylistAction) => { | ||
playNext: async <T>({ type }: HMSPlaylistAction<T>) => { | ||
await playlistManager?.playNext(type); | ||
this.syncRoomState('playNextOnPlaylist'); | ||
}, | ||
playPrevious: async ({ type }: HMSPlaylistAction) => { | ||
playPrevious: async <T>({ type }: HMSPlaylistAction<T>) => { | ||
await playlistManager?.playPrevious(type); | ||
this.syncRoomState('playPreviousOnPlaylist'); | ||
}, | ||
seek: async ({ seekValue, type }: HMSPlaylistAction) => { | ||
seek: async <T>({ seekValue, type }: HMSPlaylistAction<T>) => { | ||
if (seekValue === undefined) { | ||
@@ -126,3 +134,3 @@ throw Error('Please pass a valid seekValue'); | ||
}, | ||
setVolume: ({ volume, type }: HMSPlaylistAction) => { | ||
setVolume: <T>({ volume, type }: HMSPlaylistAction<T>) => { | ||
if (typeof volume !== 'number') { | ||
@@ -134,3 +142,3 @@ throw Error('Please pass a valid volume between 0-100'); | ||
}, | ||
setList: ({ list }: HMSPlaylistAction) => { | ||
setList: <T>({ list }: HMSPlaylistAction<T>) => { | ||
if (!list) { | ||
@@ -142,3 +150,3 @@ throw Error('Please pass a list of playlist items in the action'); | ||
}, | ||
stop: async ({ type }: HMSPlaylistAction) => { | ||
stop: async <T>({ type }: HMSPlaylistAction<T>) => { | ||
await playlistManager?.stop(type); | ||
@@ -290,2 +298,3 @@ this.syncRoomState(`stop${type}Playlist`); | ||
}, 'rollbackDisplayEnabled'); | ||
this.hmsNotifications.sendError(SDKToHMS.convertException(err as SDKHMSException)); | ||
throw err; | ||
@@ -292,0 +301,0 @@ } |
@@ -22,3 +22,3 @@ import { | ||
HMSPlaylistItem, | ||
IPlaylistManager as HMSPlaylistManager, | ||
HMSPlaylistManager, | ||
} from '@100mslive/hms-video'; | ||
@@ -25,0 +25,0 @@ |
@@ -8,14 +8,14 @@ import * as sdkTypes from '../hmsSDKStore/sdkTypes'; | ||
export interface HMSPlaylistAction { | ||
url?: string; | ||
export interface HMSPlaylistAction<T> { | ||
id?: string; | ||
seekValue?: number; | ||
type?: HMSPlaylistType; | ||
volume?: number; | ||
list?: sdkTypes.HMSPlaylistItem[]; | ||
list?: sdkTypes.HMSPlaylistItem<T>[]; | ||
} | ||
export interface HMSPlaylistItem { | ||
export interface HMSPlaylistItem<T> { | ||
name: string; | ||
id: string; | ||
description?: string; | ||
metadata?: Record<string, T>; | ||
url: string; | ||
@@ -29,7 +29,9 @@ thumbnailUrl?: string; | ||
export interface HMSPlaylist { | ||
export interface HMSPlaylist<T> { | ||
audio: { | ||
list: Record<string, HMSPlaylistItem>; | ||
list: Record<string, HMSPlaylistItem<T>>; | ||
selection: { | ||
id: string; | ||
hasPrevious: boolean; | ||
hasNext: boolean; | ||
}; | ||
@@ -40,5 +42,7 @@ progress: number; | ||
video: { | ||
list: Record<string, HMSPlaylistItem>; | ||
list: Record<string, HMSPlaylistItem<T>>; | ||
selection: { | ||
id: string; | ||
hasPrevious: boolean; | ||
hasNext: boolean; | ||
}; | ||
@@ -45,0 +49,0 @@ progress: number; |
@@ -44,3 +44,3 @@ import { | ||
export let speakerRole: HMSRole; | ||
export let playlist: HMSPlaylist; | ||
export let playlist: HMSPlaylist<any>; | ||
@@ -47,0 +47,0 @@ export const ROLES = { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1254725
14157