Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ylink-sdk/stream

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ylink-sdk/stream - npm Package Compare versions

Comparing version 0.1.11-beta.0 to 0.1.11

28

dist/types/index.d.ts

@@ -82,3 +82,9 @@ import { MediaEventHandler } from './media';

export interface AudioReceiver {
/**
* 订阅 ssrc
*/
readonly ssrc: number;
/**
* 播放器
*/
sink?: HTMLMediaElement;

@@ -112,2 +118,5 @@ /**

readonly ssrc: number;
/**
* 视频数据已经加载
*/
loadeddata: boolean;

@@ -132,5 +141,18 @@ /**

getStats(): Promise<any>;
/**
* 视频数据已经加载事件
*/
onloadeddata?: () => void;
/**
* 已准备事件
*/
onready?: () => void;
/**
* 异常事件
*/
onfailed?: () => void;
/**
* 设置分辨率
* @param parameters
*/
setParameters(parameters: {

@@ -147,2 +169,5 @@ width: number;

}
/**
* 视频发送对象
*/
export interface VideoSender {

@@ -176,2 +201,5 @@ readonly ssrc: number;

}
/**
* Stream 事件处理
*/
export declare type StreamEventHandler = {

@@ -178,0 +206,0 @@ [EVENT.STREAM_STATUS]: (payload: {

3

dist/types/media.d.ts

@@ -19,2 +19,5 @@ import { EVENT, MEDIA_STREAM_DETAIL, MEDIA_STREAM_STATUS } from './enums';

}
/**
* Media 事件处理
*/
export interface MediaEventHandler {

@@ -21,0 +24,0 @@ [EVENT.AUDIO_INPUT_DEVICES_UPDATED]: (payload: {

2

dist/ylink-sdk-stream.es.js

@@ -1,1 +0,1 @@

var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},n.apply(this,arguments)};function i(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{u(i.next(t))}catch(t){o(t)}}function s(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((i=i.apply(t,e||[])).next())}))}function r(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var o,a=function(){function t(){this.events=new Map}return t.prototype.emit=function(t,e){var n=this.events.get(t);n&&n.slice().map((function(t){"function"==typeof t&&t(e)}))},t.prototype.off=function(t,e){var n=this.events.get(t);n&&(e?n.splice(n.indexOf(e)>>>0,1):this.events.set(t,[]))},t.prototype.on=function(t,e){var n=this.events.get(t);n?n.push(e):this.events.set(t,[e])},t}(),s=function(t){function n(e){var n=t.call(this)||this;return n.stream=null,n._enable=!1,n.interval=100,n.timer=null,n.stream=e,n}return e(n,t),n.prototype.analyse=function(){},n.prototype.start=function(){var t=this;this.stream&&(this.timer&&(clearInterval(this.timer),this.timer=null),this.analyse(),this.timer=setInterval((function(){return t.analyse()}),this.interval))},n.prototype.stop=function(){this.timer&&(clearInterval(this.timer),this.timer=null)},n.prototype.destroy=function(){this.stop()},n}(a);!function(t){t.AUDIO_STATUS_CHANGED="audioStatusChanged",t.VIDEO_STATUS_CHANGED="videoStatusChanged"}(o||(o={}));var u,c,d,h,l,p=function(t){function n(e){var n=t.call(this,e)||this;return n._status={active:!1,hasStream:!1,track:!1},n.interval=3e3,n}return e(n,t),Object.defineProperty(n.prototype,"status",{get:function(){return this._status},set:function(t){var e=this._status;e.active===t.active&&e.hasStream===t.hasStream&&e.track===t.track||(this._status=t,this.emit(o.AUDIO_STATUS_CHANGED,{status:this._status}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.stream){var t=this.stream.getAudioTracks();this.status.active=void 0===this.stream.active?Boolean(t[0]):this.stream.active,void 0!==this.stream.active&&void 0!==this.stream.id?this.status.hasStream=!0:this.status.hasStream=!1,(this.status.active||this.status.hasStream)&&(this.status.track=this.checkAvariable(t))}else this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.streamInactive=function(){this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.checkAvariable=function(t){return void 0===t&&(t=[]),t.some((function(t){return!("readyState"in t&&"live"!==t.readyState||"muted"in t&&!0===t.muted)}))},n.prototype.destroy=function(){this.stream&&this.stream.removeEventListener("inactive",this.streamInactive),t.prototype.destroy.call(this)},n}(s),v=function(t){function n(e){var n=t.call(this,e)||this;return n._status={active:!1,hasStream:!1,track:!1},n.interval=3e3,n}return e(n,t),Object.defineProperty(n.prototype,"status",{get:function(){return this._status},set:function(t){var e=this._status;e.active===t.active&&e.hasStream===t.hasStream&&e.track===t.track||(this._status=t,this.emit(o.VIDEO_STATUS_CHANGED,{status:this._status}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.stream){var t=this.stream.getVideoTracks();this.status.active=void 0===this.stream.active?Boolean(t[0]):this.stream.active,void 0!==this.stream.active&&void 0!==this.stream.id?this.status.hasStream=!0:this.status.hasStream=!1,(this.status.active||this.status.hasStream)&&(this.status.track=this.checkAvariable(t))}else this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.streamInactive=function(){this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.checkAvariable=function(t){return void 0===t&&(t=[]),t.some((function(t){return!("readyState"in t&&"live"!==t.readyState||"muted"in t&&!0===t.muted)}))},n.prototype.destroy=function(){this.stream&&this.stream.removeEventListener("inactive",this.streamInactive),t.prototype.destroy.call(this)},n}(s),f=function(t){function n(e){var n=t.call(this,e)||this;return n.volume=0,n.context=null,n.contextAnalyser=null,n.streamSource=null,n}return e(n,t),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.context&&this.contextAnalyser&&this.streamSource){var t=this.contextAnalyser.frequencyBinCount,e=new Uint8Array(t);this.contextAnalyser.getByteFrequencyData(e);var n=e.reduce((function(t,e){return t+e}),0);this.volume=n/t}else this.volume=0},n.prototype.start=function(){this.createContextAnalyser(),this.createStreamSource(),this.streamSource&&t.prototype.start.call(this)},n.prototype.stop=function(){this.streamSource&&(this.streamSource.disconnect(),this.streamSource=null),this.volume=0,t.prototype.stop.call(this)},n.prototype.createContextAnalyser=function(){if((!this.context||!this.contextAnalyser)&&(window.AudioContext||window.webkitAudioContext)){var t=window.AudioContext||window.webkitAudioContext;this.context=new t,this.contextAnalyser=this.context.createAnalyser(),this.contextAnalyser.fftSize=1024,this.contextAnalyser.smoothingTimeConstant=.5}},n.prototype.createStreamSource=function(){if(this.streamSource&&(this.streamSource.disconnect(),this.streamSource=null),this.context&&this.stream&&this.stream.getAudioTracks().length>0){if(this.streamSource=this.context.createMediaStreamSource(this.stream),!this.contextAnalyser)return;this.streamSource.connect(this.contextAnalyser),"suspended"===this.context.state&&this.context.resume()}},n.prototype.destroy=function(){this.contextAnalyser&&(this.contextAnalyser.disconnect(),this.contextAnalyser=null),this.context&&(this.context=null),t.prototype.destroy.call(this)},n}(s);!function(t){t.STREAM_STATUS="streamStatus",t.CHANNEL_REFRESH="channelRefresh",t.CHANNEL_BUSY="channelBusy",t.AUDIO_CHANNEL_OPENED="audioChannelOpened",t.VIDEO_CHANNEL_OPENED="videoChannelOpened",t.DATA_CHANNEL_OPENED="dataChannelOpened",t.MESSAGE_CHANNEL_OPENED="messageChannelOpened",t.AUDIO_STREAM="audioStream",t.VIDEO_STREAM="videoStream",t.DATA_STREAM="dataStream",t.AUDIO_INPUT_DEVICES_UPDATED="audioInputDevicesUpdated",t.AUDIO_OUTPUT_DEVICES_UPDATED="audioOutputDevicesUpdated",t.VIDEO_INPUT_DEVICES_UPDATED="videoInputDevicesUpdated",t.AUDIO_INPUT_DEVICE_CHANGED="audioInputDeviceChanged",t.AUDIO_OUTPUT_DEVICE_CHANGED="audioOutputDeviceChanged",t.VIDEO_INPUT_DEVICE_CHANGED="videoInputDeviceChanged",t.AUDIO_STREAM_STATUS="audioStreamStatus",t.VIDEO_STREAM_STATUS="videoStreamStatus",t.DATA_STREAM_STATUS="dataStreamStatus",t.VOICE_ACTIVE_SSRC="voiceActiveSsrc"}(u||(u={})),function(t){t.NULL="null",t.INIT="initialized",t.START="started",t.STOP="stopped"}(c||(c={})),function(t){t.Null="null",t.INIT="initialized"}(d||(d={})),function(t){t.NULL="null",t.CAPTURING="capturing",t.FAILED="failed"}(h||(h={})),function(t){t.NO_DEVICE="No Device",t.PERMISSION_DENIED="Permission denied",t.COULD_NOT_START_VIDEO_SOURCE="Could not start video source",t.PERMISSION_DENIED_BY_SYSTEM="Permission denied by system",t.OTHER_EXCEPTIONS="Other exceptions"}(l||(l={}));var S,m=function(t,e){var n=e.match(t);return n&&n.length>0&&n[1]||""},I=/version\/(\d+(\.?_?\d+)+)/i,D=[{test:[/\sedg\//i],describe:function(t){var e={name:"Microsoft Edge"},n=m(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/edg([ea]|ios)/i],describe:function(t){var e={name:"Microsoft Edge"},n=function(t,e){var n=e.match(t);return n&&n.length>1&&n[2]||""}(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/firefox|iceweasel|fxios/i],describe:function(t){var e={name:"Firefox"},n=m(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/chromium/i],describe:function(t){var e={name:"Chromium"},n=m(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||m(I,t);return n&&(e.version=n),e}},{test:[/chrome|crios|crmo/i],describe:function(t){var e={name:"Chrome"},n=m(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/safari|applewebkit/i],describe:function(t){var e={name:"Safari"},n=m(I,t);return n&&(e.version=n),e}}],y=D.find((function(t){if(t.test instanceof Array)return t.test.some((function(t){return t.test(navigator.userAgent)}));throw new Error("Browser's test function is not valid")}));y&&(S=y.describe(navigator.userAgent));var A=S&&"Safari"===S.name,E=S&&"Firefox"===S.name,T=S&&"Chrome"===S.name,g=S&&"Microsoft Edge"===S.name,_=function(){function t(t){var e=t.namespace,n=t.debug;this.initialized=!0,this.isDebugging=n,this.backend=b(),this.namespace=e,this.useColors=this.backend.useColors,this.color=this.selectColor(e)}return t.prototype.logger=function(t){var e=this;t[0]=this.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");var n=0;return t[0]=t[0].replace(/%([a-zA-Z%])/g,(function(i,r){if("%%"===i)return i;n++;var o=e.backend.formatters[r];"function"==typeof o&&(i=o(t[n]),t.splice(n,1),n--);return i})),this.backend.formatArgs(t,this)},t.prototype.coerce=function(t){return t instanceof Error?t.stack||t.message:t},t.prototype.selectColor=function(t){var e=Array.from(t).reduce((function(t,e){return t=(t<<5)-t+e.charCodeAt(0),t|=0}),0);return this.backend.colors[Math.abs(e)%this.backend.colors.length]},t.prototype.switchDebug=function(t){this.isDebugging=t},t.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];t=this.logger(t),this.backend.log.apply(this,t)},t.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.isDebugging&&(t=this.logger(t),this.backend.debug.apply(this,t))},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.backend.warn.apply(this,t)},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.backend.error.apply(this,t)},t}(),b=function(){var t={colors:["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],formatters:{j:function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: ".concat(t.message)}}},log:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,t)},debug:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.debug&&Function.prototype.apply.call(console.debug,console,t)},warn:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.warn&&Function.prototype.apply.call(console.warn,console,t)},error:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.error&&Function.prototype.apply.call(console.error,console,t)},formatArgs:function(t,e){var n=e.useColors,i=e.namespace,r=e.color;if(t[0]="".concat((n?"%c":"")+i+(n?" %c":" ")+t[0]+(n?"%c ":" "),"+").concat(function(t){var e=Math.abs(t);if(e>=N)return"".concat(Math.round(t/N),"d");if(e>=w)return"".concat(Math.round(t/w),"h");if(e>=O)return"".concat(Math.round(t/O),"m");if(e>=C)return"".concat(Math.round(t/C),"s");return"".concat(t,"ms")}(0)),!n)return[];var o="color: ".concat(r);t.splice(1,0,o,"color: inherit");var a=0,s=0;return t[0].replace(/%[a-zA-Z%]/g,(function(t){"%%"!==t&&(a++,"%c"===t&&(s=a))})),t.splice(s,0,o),t},useColors:U()};return t},C=1e3,O=60*C,w=60*O,N=24*w;var U=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.webkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},R=function(t){return t.close=t.stop=function(){!function(t){if(t)try{t.getTracks?t.getTracks().forEach((function(t){return t.stop()})):(t.getAudioTracks().forEach((function(t){return t.stop()})),t.getVideoTracks().forEach((function(t){return t.stop()})))}catch(e){"function"!=typeof t.stop&&"object"!=typeof t.stop||t.stop()}}(this)},t.pause=function(){this.getTracks().forEach((function(t){return t.enabled=!1}))},t.play=function(){this.getTracks().forEach((function(t){return t.enabled=!0}))},t.muteAudio=function(t){void 0===t&&(t=!0),this.getAudioTracks().forEach((function(e){return e.enabled=!t}))},t.muteVideo=function(t){void 0===t&&(t=!0),this.getVideoTracks().forEach((function(e){return e.enabled=!t}))},t},P=function(t){return i(void 0,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return navigator.mediaDevices.getUserMedia?[4,navigator.mediaDevices.getUserMedia(t)]:[3,2];case 1:case 3:return e=n.sent(),[3,5];case 2:return navigator.getUserMedia?[4,new Promise((function(e,n){navigator.getUserMedia(t,e,n)}))]:[3,4];case 4:throw new Error("Not Supported");case 5:return[2,R(e)]}}))}))},L=function(t){return i(void 0,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return navigator.mediaDevices.getDisplayMedia?[4,navigator.mediaDevices.getDisplayMedia(t)]:[3,2];case 1:case 3:return e=n.sent(),[3,5];case 2:return navigator.getDisplayMedia?[4,new Promise((function(e,n){navigator.getDisplayMedia(t,e,n)}))]:[3,4];case 4:throw new Error("Not Supported");case 5:return[2,R(e)]}}))}))},V=new _({namespace:"STREAM:Media",debug:!1}),M=function(t){function a(e){var n=e.debug,i=t.call(this)||this;return i.status=d.Null,i.deviceList=[],i.audioQueue=Promise.resolve(null),i.videoQueue=Promise.resolve(null),i.dataQueue=Promise.resolve(null),i._audioStream=null,i._videoStream=null,i._displayStream=null,i._audioInputDevice=null,i._audioOutputDevice=null,i._videoInputDevice=null,i._audioInputDeviceId="",i._audioOutputDeviceId="",i._videoInputDeviceId="",i._audioInputDevices=[],i._audioOutputDevices=[],i._videoInputDevices=[],i._audioStreamStatus={status:h.NULL},i._videoStreamStatus={status:h.NULL},i._dataStreamStatus={status:h.NULL},i.onDataStreamInactive=i.dataStreamInactive.bind(i),V.switchDebug(n),i.volumeAnalyser=new f(i.audioStream),i.audioAnalyser=new p(i.audioStream),i.videoAnalyser=new v(i.videoStream),i.setup(),i}return e(a,t),a.createInstance=function(t){return this.instance||(this.instance=new a(t)),this.instance},Object.defineProperty(a.prototype,"audioInputDevices",{get:function(){return this._audioInputDevices||[]},set:function(t){this.checkDeviceList(t,this._audioInputDevices)||(this._audioInputDevices=t,this.status===d.INIT&&this.emit(u.AUDIO_INPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDevices",{get:function(){return this._audioOutputDevices||[]},set:function(t){this.checkDeviceList(t,this._audioOutputDevices)||(this._audioOutputDevices=t,this.status===d.INIT&&this.emit(u.AUDIO_OUTPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDevices",{get:function(){return this._videoInputDevices||[]},set:function(t){this.checkDeviceList(t,this._videoInputDevices)||(this._videoInputDevices=t,this.status===d.INIT&&this.emit(u.VIDEO_INPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioInputDeviceId",{get:function(){return this._audioInputDeviceId||""},set:function(t){if(!this._audioInputDeviceId||this._audioInputDeviceId!==t){var e=this.audioInputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.audioInputDevice=i,this._audioInputDeviceId=i?i.deviceId:"",this.audioStreamStatus.status!==h.NULL&&this.captureAudioStream()}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDeviceId",{get:function(){return this._audioOutputDeviceId||""},set:function(t){if(!this._audioOutputDeviceId||this._audioOutputDeviceId!==t){var e=this.audioOutputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.audioOutputDevice=i,this._audioOutputDeviceId=i?i.deviceId:""}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDeviceId",{get:function(){return this._videoInputDeviceId||""},set:function(t){if(!this._videoInputDeviceId||this._videoInputDeviceId!==t){var e=this.videoInputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.videoInputDevice=i,this._videoInputDeviceId=i?i.deviceId:"",this.videoStreamStatus.status!==h.NULL&&this.captureVideoStream()}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioInputDevice",{get:function(){return this._audioInputDevice},set:function(t){var e=this._audioInputDevice&&!this.isSameDevice(this._audioInputDevice,t),n=!this._audioInputDevice&&!!t;(n||e)&&(this._audioInputDevice=t,!n&&e&&this.emit(u.AUDIO_INPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDevice",{get:function(){return this._audioOutputDevice},set:function(t){var e=this._audioOutputDevice&&!this.isSameDevice(this._audioOutputDevice,t),n=!this._audioOutputDevice&&!!t;(n||e)&&(this._audioOutputDevice=t,!n&&e&&this.emit(u.AUDIO_OUTPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDevice",{get:function(){return this._videoInputDevice},set:function(t){var e=this._videoInputDevice&&!this.isSameDevice(this._videoInputDevice,t),n=!this._videoInputDevice&&!!t;(n||e)&&(this._videoInputDevice=t,!n&&e&&this.emit(u.VIDEO_INPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"supportNativeShare",{get:function(){return navigator.getDisplayMedia||navigator.mediaDevices.getDisplayMedia},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioStream",{get:function(){return this._audioStream},set:function(t){this._audioStream!==t&&(this._audioStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoStream",{get:function(){return this._videoStream},set:function(t){this._videoStream!==t&&(this._videoStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"dataStream",{get:function(){return this._displayStream},set:function(t){this._displayStream!==t&&(this._displayStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioStreamStatus",{get:function(){return this._audioStreamStatus},set:function(t){var e=this._audioStreamStatus;e.status===t.status&&e.detail===t.detail||(this._audioStreamStatus=t,this.emit(u.AUDIO_STREAM_STATUS,this._audioStreamStatus))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoStreamStatus",{get:function(){return this._videoStreamStatus},set:function(t){var e=this._videoStreamStatus;e.status===t.status&&e.detail===t.detail||(this._videoStreamStatus=t,this.emit(u.VIDEO_STREAM_STATUS,this._videoStreamStatus))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"dataStreamStatus",{get:function(){return this._dataStreamStatus},set:function(t){var e=this._dataStreamStatus;e.status===t.status&&e.detail===t.detail||(this._dataStreamStatus=t,this.emit(u.DATA_STREAM_STATUS,this._dataStreamStatus))},enumerable:!1,configurable:!0}),a.prototype.setup=function(){var t=this;this.audioAnalyser.on(o.AUDIO_STATUS_CHANGED,(function(e){var n=e.status;V.debug("".concat(o.AUDIO_STATUS_CHANGED," ").concat(JSON.stringify(n))),!n.hasStream||n.track&&n.active||(t.audioStreamStatus={status:h.FAILED,detail:l.OTHER_EXCEPTIONS})})),this.videoAnalyser.on(o.VIDEO_STATUS_CHANGED,(function(e){var n=e.status;V.debug("".concat(o.VIDEO_STATUS_CHANGED," ").concat(JSON.stringify(n))),!n.hasStream||n.track&&n.active||(t.videoStreamStatus={status:h.FAILED,detail:l.OTHER_EXCEPTIONS})}))},a.prototype.cleanup=function(){this.deviceList=[],this.audioInputDevices=[],this.audioInputDeviceId="",this.audioOutputDevices=[],this.audioOutputDeviceId="",this.videoInputDevices=[],this.videoInputDeviceId="",this.volumeAnalyser.destroy(),this.audioAnalyser.destroy(),this.videoAnalyser.destroy()},a.prototype.init=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return this.throwIfStatus(d.INIT),navigator.mediaDevices&&(e=this,navigator.mediaDevices.ondevicechange=function(){e.detectDevice()}),[4,this.detectDevice(t)];case 1:return n.sent(),this.status=d.INIT,[2]}}))}))},a.prototype.destroy=function(){try{this.closeAudioStream(),this.closeVideoStream(),this.closeDataStream(),this.cleanup()}catch(t){V.error(t)}this.status=d.Null},a.prototype.detectDevice=function(t){return i(this,void 0,void 0,(function(){var e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:return navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices?[4,this.enumerateDevices().catch((function(t){return V.error("enumerate devices error: ",t)}))]:(V.error("mediaDevices or enumerateDevices is miss"),[2]);case 1:return e=r.sent(),this.deviceList=e&&e.map((function(t){return t.toJSON()}))||[],V.debug("deviceList: ".concat(JSON.stringify(this.deviceList))),i=(n=this).audioInputDevice,o=n.audioOutputDevice,a=n.videoInputDevice,this.audioInputDevices=this.deviceList.filter((function(t){return"audioinput"===t.kind}))||[],this.audioInputDeviceId=this.checkDevice({deviceList:this.audioInputDevices,device:i,deviceId:t&&t.audioInputDeviceId||""}),this.audioOutputDevices=this.deviceList.filter((function(t){return"audiooutput"===t.kind}))||[],this.audioOutputDeviceId=this.checkDevice({deviceList:this.audioOutputDevices,device:o,deviceId:t&&t.audioOutputDeviceId||""}),this.videoInputDevices=this.deviceList.filter((function(t){return"videoinput"===t.kind}))||[],this.videoInputDeviceId=this.checkDevice({deviceList:this.videoInputDevices,device:a,deviceId:t&&t.videoInputDeviceId||""}),[2]}}))}))},a.prototype.enumerateDevices=function(){return new Promise((function(t,e){navigator.mediaDevices.enumerateDevices().then((function(e){t(e)})).catch((function(t){e(t)}))}))},a.prototype.genAudioConstraints=function(t){var e={audio:!1,video:!1},n=this.audioInputDevice,i=n||{deviceId:"",groupId:""},r=i.deviceId,o=i.groupId;return e.audio=!!n&&(t&&E?{deviceId:{exact:r},groupId:{exact:o}}:{deviceId:r,groupId:o}),e.audio&&!A&&Object.assign(e.audio,k),e},a.prototype.genVideoConstraints=function(){var t={audio:!1,video:!1},e=this.videoInputDevice,n=e||{deviceId:"",groupId:""},i=n.deviceId,r=n.groupId;return t.video=!!e&&(E?{deviceId:{exact:i},groupId:{exact:r}}:{deviceId:i,groupId:r}),t.video&&Object.assign(t.video,x),t},a.prototype.genDisplayConstraints=function(t){var e,i=t.quality;return this.supportNativeShare?e={video:n({},i)}:e},a.prototype.createAudioStream=function(t){return i(this,void 0,void 0,(function(){var e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:if(e=this.genAudioConstraints(t),V.debug("audio constraints: ".concat(JSON.stringify(e))),n=this.audioStreamStatus,!e.audio)return[2,{stream:null,audioStreamStatus:n={status:h.FAILED,detail:l.NO_DEVICE}}];i=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,P(e)];case 2:return i=r.sent(),[3,4];case 3:return a=r.sent(),V.debug("getUserMedia error: ".concat(a)),o=a,[3,4];case 4:return i?n={status:h.CAPTURING}:(o=o||new Error("Stream is null"),n={status:h.FAILED,detail:H.get(o.message)||l.OTHER_EXCEPTIONS}),[2,{stream:i,audioStreamStatus:n}]}}))}))},a.prototype.createVideoStream=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:if(t=this.genVideoConstraints(),V.debug("video constraints: ".concat(JSON.stringify(t))),e=this.videoStreamStatus,!t.video)return[2,{stream:null,videoStreamStatus:e={status:h.FAILED,detail:l.NO_DEVICE}}];n=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,P(t)];case 2:return n=r.sent(),[3,4];case 3:return o=r.sent(),V.debug("getUserMedia error: ".concat(o)),i=o,[3,4];case 4:return n?e={status:h.CAPTURING}:(i=i||new Error("Stream is null"),e={status:h.FAILED,detail:G.get(i.message)||l.OTHER_EXCEPTIONS}),[2,{stream:n,videoStreamStatus:e}]}}))}))},a.prototype.createDataStream=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:t=this.genDisplayConstraints({quality:j}),V.debug("data constraints: ".concat(JSON.stringify(t))),e=null,i=this.dataStreamStatus,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,L(t)];case 2:return e=r.sent(),[3,4];case 3:return o=r.sent(),V.debug("getDisplayMedia error: ".concat(o)),n=o,[3,4];case 4:return e?i={status:h.CAPTURING}:(n=n||new Error("Stream is null"),i={status:h.FAILED,detail:F.get(n.message)||l.OTHER_EXCEPTIONS}),[2,{stream:e,dataStreamStatus:i}]}}))}))},a.prototype.closeAudioStream=function(){this.audioStream&&this.audioStream.close(),this.audioStream=null,this.switchAudioAnalyserEnable({enable:!1}),this.setAudioAnalyserStream(this.audioStream),this.audioStreamStatus={status:h.NULL},this.emit(u.AUDIO_STREAM,{stream:this.audioStream})},a.prototype.closeVideoStream=function(){this.videoStream&&this.videoStream.close(),this.videoStream=null,this.switchVideoAnalyserEnable({enable:!1}),this.setVideoAnalyserStream(this.videoStream),this.videoStreamStatus={status:h.NULL},this.emit(u.VIDEO_STREAM,{stream:this.videoStream})},a.prototype.closeDataStream=function(){var t=this;this.dataStream&&(this.dataStream.removeEventListener("inactive",this.onDataStreamInactive),(this.dataStream.getVideoTracks()||[]).forEach((function(e){e.removeEventListener("ended",t.onDataStreamInactive)})),this.dataStream.close());this.dataStream=null,this.dataStreamStatus={status:h.NULL},this.emit(u.DATA_STREAM,{stream:this.dataStream})},a.prototype.captureAudioStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.audioQueue=this.audioQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return this.switchAudioAnalyserEnable({enable:!1}),t=!(this.audioStreamStatus.status!==h.CAPTURING||!this.audioStream),[4,this.createAudioStream(t)];case 1:return e=r.sent(),n=e.stream,i=e.audioStreamStatus,this.audioStreamStatus.status===h.CAPTURING&&this.audioStream&&(this.audioStream.close(),this.audioStream=null),this.status!==d.INIT?(n&&n.close(),this.emit(u.AUDIO_STREAM,{stream:this.audioStream}),[2,Promise.resolve(this.audioStream)]):(this.audioStream=n,this.audioStreamStatus=i,this.emit(u.AUDIO_STREAM,{stream:this.audioStream}),o=!0,n||i.status!==h.FAILED||(o=!1),this.setAudioAnalyserStream(n),this.switchAudioAnalyserEnable({enable:o}),[2,Promise.resolve(this.audioStream)])}}))}))}))},a.prototype.captureVideoStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.videoQueue=this.videoQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i;return r(this,(function(r){switch(r.label){case 0:return this.switchVideoAnalyserEnable({enable:!1}),[4,this.createVideoStream()];case 1:return t=r.sent(),e=t.stream,n=t.videoStreamStatus,this.videoStreamStatus.status===h.CAPTURING&&this.videoStream&&(this.videoStream.close(),this.videoStream=null),this.status!==d.INIT?(e&&e.close(),this.emit(u.VIDEO_STREAM,{stream:this.videoStream}),[2,Promise.resolve(this.videoStream)]):(this.videoStream=e,this.videoStreamStatus=n,this.emit(u.VIDEO_STREAM,{stream:this.videoStream}),i=!0,e||n.status!==h.FAILED||(i=!1),this.setVideoAnalyserStream(e),this.switchVideoAnalyserEnable({enable:i}),[2,Promise.resolve(this.videoStream)])}}))}))}))},a.prototype.captureDataStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.dataQueue=this.dataQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i=this;return r(this,(function(r){switch(r.label){case 0:return[4,this.createDataStream()];case 1:return t=r.sent(),e=t.stream,n=t.dataStreamStatus,this.dataStreamStatus.status!==h.NULL||e?(this.dataStreamStatus.status===h.CAPTURING&&this.dataStream&&!e||(this.dataStreamStatus.status===h.CAPTURING&&this.dataStream&&(this.dataStream.removeEventListener("inactive",this.onDataStreamInactive),(this.dataStream.getVideoTracks()||[]).forEach((function(t){t.removeEventListener("ended",i.onDataStreamInactive)})),this.dataStream.close(),this.dataStream=null),e&&e.addEventListener("inactive",this.onDataStreamInactive),E&&e&&(e.getVideoTracks()||[]).forEach((function(t){t.addEventListener("ended",i.onDataStreamInactive)})),this.dataStream=e,this.dataStreamStatus=n,this.emit(u.DATA_STREAM,{stream:this.dataStream})),[2,Promise.resolve(this.dataStream)]):[2,Promise.resolve(this.dataStream)]}}))}))}))},a.prototype.setAudioAnalyserStream=function(t){this.volumeAnalyser.stream=t,this.audioAnalyser.stream=t},a.prototype.setVideoAnalyserStream=function(t){this.videoAnalyser.stream=t},a.prototype.switchAudioAnalyserEnable=function(t){var e=t.enable,n=void 0!==e&&e;this.volumeAnalyser.enable=n,this.audioAnalyser.enable=n},a.prototype.switchVideoAnalyserEnable=function(t){var e=t.enable,n=void 0!==e&&e;this.videoAnalyser.enable=n},a.prototype.dataStreamInactive=function(){this.dataStream&&(this.dataStream.close(),this.dataStream=null,this.dataStreamStatus={status:h.NULL},this.emit(u.DATA_STREAM,{stream:this.dataStream}))},a.prototype.checkDevice=function(t){var e=this,n=t.deviceList,i=t.device,r=t.deviceId;return(i=(i=r?n.find((function(t){return t.deviceId===r}))||null:i&&n.find((function(t){return e.isSameDevice(t,i)}))||null)||(n[0]||null))&&i.deviceId?i.deviceId:""},a.prototype.checkDeviceList=function(t,e){if(!t||!e||t.length!==e.length)return!1;for(var n=!0,i=0;i<t.length;i++){var r=t[i],o=e[i];if(!this.isSameDevice(r,o)){n=!1;break}}return n},a.prototype.isSameDevice=function(t,e,n){if(void 0===n&&(n=!1),!t||!e)return!1;var i=t.deviceId===e.deviceId&&t.label===e.label&&t.kind===e.kind;return n?t.groupId===e.groupId&&i:i},a.prototype.throwIfStatus=function(t,e){if(this.status===t)throw new Error(e||"Invalid State")},a.prototype.throwIfNotStatus=function(t,e){if(this.status!==t)throw new Error(e||"Invalid State")},a}(a),k={autoGainControl:!0,echoCancellation:!0,latency:0,noiseSuppression:!0},x={aspectRatio:16/9,frameRate:30,width:640,height:360},j={width:1920,height:1080,frameRate:5},H=new Map([["No Device",l.NO_DEVICE],["Permission denied",l.PERMISSION_DENIED],["Permission dismissed",l.PERMISSION_DENIED],["Could not start video source",l.OTHER_EXCEPTIONS],["The request is not allowed by the user agent or the platform in the current context.",l.PERMISSION_DENIED],["Failed to allocate videosource",l.OTHER_EXCEPTIONS],["Stream is null",l.OTHER_EXCEPTIONS]]),G=new Map([["No Device",l.NO_DEVICE],["Permission denied",l.PERMISSION_DENIED],["Permission dismissed",l.PERMISSION_DENIED],["Could not start video source",l.COULD_NOT_START_VIDEO_SOURCE],["The request is not allowed by the user agent or the platform in the current context.",l.PERMISSION_DENIED],["Failed to allocate videosource",l.COULD_NOT_START_VIDEO_SOURCE],["Stream is null",l.OTHER_EXCEPTIONS]]),F=new Map([["Permission denied by system",l.PERMISSION_DENIED_BY_SYSTEM],["The object can not be found here.",l.PERMISSION_DENIED_BY_SYSTEM],["The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.",l.PERMISSION_DENIED_BY_SYSTEM]]),B=function(){return M.instance},X=new _({namespace:"STREAM:Store",debug:!1}),J=function(){function t(t){var e=this,n=t.debug;this.status=c.NULL,this.remoteControlStream=null,this.videoSender=null,this.audioSender=null,this.dataSender=null,this.audioReceiver=null,this.voiceActiveSsrc=[],this.audioPlayer=null,this.audioChannelOpened=!1,this.videoChannelOpened=!1,this.dataChannelOpened=!1,this.messageChannelOpened=!1,this.api={getMss:function(t){var n=e.baseURL;return"function"!=typeof fetch?Promise.reject():fetch(function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(n,"/webapp/front/getMss"),{headers:{"content-type":"application/json"},method:"POST",body:JSON.stringify(t)}).then((function(t){return i(e,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,t.json()];case 1:return[2,e.sent()]}}))}))}))}},this.baseURL="https://meetings.ylyun.com",this.videoSDKLibDir="",X.switchDebug(n),this.emitter=new a}return t.createInstance=function(e){return this.instance||(this.instance=new t(e)),this.instance},t.prototype.setApi=function(t){this.api=t},t.prototype.setBaseUrl=function(t){this.baseURL=t},t.prototype.setVideoSDKLibDir=function(t){this.videoSDKLibDir=t},t.prototype.setMediaEndpoint=function(t){this.mediaEndpoint=t},t.prototype.setMediaEngine=function(t){this.mediaEngine=t},t.prototype.setAudioChannel=function(t){this.audioChannel=t},t.prototype.setVideoChannel=function(t){this.videoChannel=t},t.prototype.setDataChannel=function(t){this.dataChannel=t},t.prototype.setMessageChannel=function(t){this.messageChannel=t},t.prototype.setRemoteControlStream=function(t){this.remoteControlStream=t},t.prototype.setVideoSender=function(t){this.videoSender=t},t.prototype.setAudioSender=function(t){this.audioSender=t},t.prototype.setDataSender=function(t){this.dataSender=t},t.prototype.setAudioReceiver=function(t){this.audioReceiver=t},t.prototype.setAudioPlayer=function(t){this.audioPlayer=t},t.prototype.setVoiceActiveSsrc=function(t){this.voiceActiveSsrc=t},t.prototype.throwIfAudioNotOpened=function(t){if(!this.audioChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfVideoNotOpened=function(t){if(!this.videoChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfDataNotOpened=function(t){if(!this.dataChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfMessageNotOpened=function(t){if(!this.messageChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfStatus=function(t,e){if(this.status===t)throw new Error(e||"Invalid State")},t.prototype.throwIfNotStatus=function(t,e){if(this.status!==t)throw new Error(e||"Invalid State")},t.prototype.loadLibRTCFiles=function(){var t=this.videoSDKLibDir;return Promise.all([this.createScriptTag({src:"".concat(t,"/libsfu.prod.js")}),this.createScriptTag({src:"".concat(t,"/librtc.global.prod.js")})])},t.prototype.getLibRTCContext=function(){var t=window.LIBRTC.SFUTransportType,e=this.mediaEndpoint,n=this.mediaEngine;return e&&n?{mediaEndpoint:e,mediaEngine:n,SFUTransportType:t}:{SFUTransportType:t}},t.prototype.createScriptTag=function(t){var e=t.src;return new Promise((function(t,n){var i=document.createElement("script");i.type="text/javascript",i.src=e,i.onload=function(){t(i)},i.onerror=function(t){n(t)},document.head.appendChild(i)}))},t.prototype.cleanup=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o,a,s,u;return r(this,(function(r){switch(r.label){case 0:e=(t=this).videoChannel,n=t.audioChannel,i=t.messageChannel,o=t.dataChannel,a=t.mediaEndpoint,s=t.remoteControlStream,r.label=1;case 1:return r.trys.push([1,12,,13]),n?[4,n.close()]:[3,3];case 2:r.sent(),r.label=3;case 3:return e?[4,e.close()]:[3,5];case 4:r.sent(),r.label=5;case 5:return o?[4,o.close()]:[3,7];case 6:r.sent(),r.label=7;case 7:return s&&i?[4,i.closeStream(s)]:[3,9];case 8:r.sent(),r.label=9;case 9:return i?[4,i.close()]:[3,11];case 10:r.sent(),r.label=11;case 11:return a&&(a.stop(),a.destroy()),[3,13];case 12:return u=r.sent(),X.error(u),[3,13];case 13:return this.mediaEndpoint=null,this.mediaEngine=null,this.videoChannel=null,this.audioChannel=null,this.dataChannel=null,this.messageChannel=null,this.videoSender=null,this.audioSender=null,this.dataSender=null,this.audioReceiver=null,this.audioPlayer=null,this.audioChannelOpened=!1,this.videoChannelOpened=!1,this.dataChannelOpened=!1,this.messageChannelOpened=!1,[2]}}))}))},t}(),z=function(){return J.instance},Y=new _({namespace:"STREAM:Store",debug:!1}),K=function(){function t(t){var e,n=t.baseURL,i=t.videoSDKLibDir,r=t.debug;n=n||"https://meetings.ylyun.com",i=i||"",r=r||!1,Y.switchDebug(r),e={debug:r},J.createInstance(e),function(t){M.createInstance(t)}({debug:r}),z().setBaseUrl(n),z().setVideoSDKLibDir(i),this.setup()}return t.prototype.setup=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){return B().on(u.AUDIO_STREAM,(function(t){z().emitter.emit(u.AUDIO_STREAM,t)})),B().on(u.VIDEO_STREAM,(function(t){z().emitter.emit(u.VIDEO_STREAM,t)})),B().on(u.DATA_STREAM,(function(t){z().emitter.emit(u.DATA_STREAM,t)})),B().on(u.AUDIO_INPUT_DEVICES_UPDATED,(function(t){z().emitter.emit(u.AUDIO_INPUT_DEVICES_UPDATED,t)})),B().on(u.AUDIO_OUTPUT_DEVICES_UPDATED,(function(t){z().emitter.emit(u.AUDIO_OUTPUT_DEVICES_UPDATED,t)})),B().on(u.VIDEO_INPUT_DEVICES_UPDATED,(function(t){z().emitter.emit(u.VIDEO_INPUT_DEVICES_UPDATED,t)})),B().on(u.AUDIO_INPUT_DEVICE_CHANGED,(function(t){z().emitter.emit(u.AUDIO_INPUT_DEVICE_CHANGED,t)})),B().on(u.AUDIO_OUTPUT_DEVICE_CHANGED,(function(t){z().emitter.emit(u.AUDIO_OUTPUT_DEVICE_CHANGED,t)})),B().on(u.VIDEO_INPUT_DEVICE_CHANGED,(function(t){z().emitter.emit(u.VIDEO_INPUT_DEVICE_CHANGED,t)})),B().on(u.AUDIO_STREAM_STATUS,(function(t){z().emitter.emit(u.AUDIO_STREAM_STATUS,t)})),B().on(u.VIDEO_STREAM_STATUS,(function(t){z().emitter.emit(u.VIDEO_STREAM_STATUS,t)})),B().on(u.DATA_STREAM_STATUS,(function(t){z().emitter.emit(u.DATA_STREAM_STATUS,t)})),[2]}))}))},t.prototype.cleanup=function(){},t.prototype.on=function(t,e){return z().emitter.on(t,e)},t.prototype.off=function(t,e){return z().emitter.off(t,e)},t.prototype.init=function(t){return i(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:if(window.ActiveXObject||"ActiveXObject"in window)throw new Error("Not compatible with this browser yet, please use other browsers instead.");return[4,B().init(t)];case 1:return e.sent(),z().status=c.INIT,z().emitter.emit(u.STREAM_STATUS,{status:z().status}),[2]}}))}))},t.prototype.start=function(t){return i(this,void 0,void 0,(function(){var e,n,o,a,s,d,h,l,p,v,f,S=this;return r(this,(function(m){switch(m.label){case 0:return z().throwIfStatus(c.NULL),z().throwIfStatus(c.START),[4,z().loadLibRTCFiles().catch((function(t){Y.error(t)}))];case 1:return m.sent(),e=window.LIBRTC,n=e.NativeMediaEndpoint,o=e.NativeMediaEngine,a=t.mediaContent,s=t.user,d=t.meetingID,h=t.ctrlID,l=t.meetingNum,p=t.account,[4,(v=new o).init()];case 2:return m.sent(),(f=new n).onrefresh=function(){return i(S,void 0,void 0,(function(){var t,e,n;return r(this,(function(i){switch(i.label){case 0:return z().emitter.emit(u.CHANNEL_REFRESH),[4,z().api.getMss({accessMCs:a.accessMCs,topMC:a.topMC,confId:d,ccid:s.userID,userType:"audience"===s.role?"Broadcast":"Interactive"}).catch((function(t){Y.error(t)}))];case 1:return t=i.sent(),Y.debug("response ".concat(JSON.stringify(t))),t&&t.data&&t.data.MssInfo?(e=t.data.MssInfo.map((function(t){return t.ExtranetlUri})).flat(),n=t.data.MssInfo.map((function(t){return t.IntranetUri})).flat(),[2,e.concat(n).filter((function(t){return t.startsWith("ws")||t.startsWith("wss")})).map((function(t){var e=z().baseURL,n=/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)?function(t){if(!t)return"";var e=/^([a-z][a-z\d+\-.]*:)?\/\/(\S+)/.exec(t);return!e||e.length<3?"":e[2]}(e):e,i="wss://".concat(n),r=window.btoa(t.replace(/\w+:\/\//,""));return"".concat(i,"/webapp/socket/").concat(r)}))]):(Y.error("getMss response error ",t),[2,[]])}}))}))},[4,f.init()];case 3:return m.sent(),[4,f.start({meeting_number:l||"",user_account:p||"",confid:d,ccid:s.userID,role:1,encrypt:a.crypto,token:h})];case 4:return m.sent(),z().setMediaEndpoint(f),z().setMediaEngine(v),z().status=c.START,z().emitter.emit(u.STREAM_STATUS,{status:z().status}),[2]}}))}))},t.prototype.stop=function(){z().throwIfNotStatus(c.START),z().cleanup(),B().dataStreamStatus.status!==h.NULL&&B().closeDataStream(),z().status=c.STOP,z().emitter.emit(u.STREAM_STATUS,{status:z().status})},t.prototype.destroy=function(){z().status===c.START&&this.stop(),this.cleanup(),z().status!==c.NULL&&(B().destroy(),z().status=c.NULL,z().emitter.emit(u.STREAM_STATUS,{status:z().status}))},t.prototype.getStatus=function(){return z().status},t.prototype.getBaseUrl=function(){return z().baseURL},t.prototype.getChannelStatus=function(){return{audioChannelOpened:z().audioChannelOpened,videoChannelOpened:z().videoChannelOpened,dataChannelOpened:z().dataChannelOpened,messageChannelOpened:z().messageChannelOpened}},t.prototype.setBaseUrl=function(t){z().throwIfStatus(c.START),t&&z().baseURL!==t&&z().setBaseUrl(t)},t.prototype.setVideoSDKLibDir=function(t){z().throwIfStatus(c.START),t&&z().videoSDKLibDir!==t&&z().setVideoSDKLibDir(t)},t.prototype.createAudioChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return z().throwIfNotStatus(c.START),t=z().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.audio.createChannel(n.createTransport(i.kAudio)),z().setAudioChannel(o),o.onopen=function(){Y.debug("audioChannel onopen()"),z().audioChannelOpened=!0,z().emitter.emit(u.AUDIO_CHANNEL_OPENED)},[4,o.open()];case 1:return r.sent(),[2]}}))}))},t.prototype.closeAudioChannel=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return(t=z().audioChannel)?[4,t.close()]:(Y.error("audioChannel is miss"),[2]);case 1:return e.sent(),z().setAudioChannel(null),z().setAudioSender(null),z().setAudioReceiver(null),[2]}}))}))},t.prototype.createVideoChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return z().throwIfNotStatus(c.START),t=z().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createChannel(n.createTransport(i.kVideo)),z().setVideoChannel(o),o.onopen=function(){Y.debug("videoChannel onopen()"),z().videoChannelOpened=!0,z().emitter.emit(u.VIDEO_CHANNEL_OPENED)},[4,o.open()];case 1:return r.sent(),[2]}}))}))},t.prototype.createDataChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return z().throwIfNotStatus(c.START),t=z().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createChannel(n.createTransport(i.kData)),z().setDataChannel(o),o.onopen=function(){Y.debug("dataChannel onopen()")},[4,o.open()];case 1:return r.sent(),z().dataChannelOpened=!0,z().emitter.emit(u.DATA_CHANNEL_OPENED),[2]}}))}))},t.prototype.createMessageChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:z().throwIfNotStatus(c.START),t=z().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createDataChannel(n.createTransport(i.kMessage)),z().setMessageChannel(o),o.onopen=function(){Y.debug("messageChannel onopen()")},r.label=1;case 1:return r.trys.push([1,3,,4]),[4,o.open()];case 2:return r.sent(),[3,4];case 3:return a=r.sent(),console.error(a),[3,4];case 4:return z().messageChannelOpened=!0,z().emitter.emit(u.MESSAGE_CHANNEL_OPENED),[2]}}))}))},t.prototype.closeMessageChannel=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return(t=z().messageChannel)?[4,t.close()]:(Y.error("messageChannel is miss"),[2]);case 1:return e.sent(),[2]}}))}))},t.prototype.closeMessageStream=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return(e=z().messageChannel)?t?[4,e.closeStream(t)]:[3,2]:(Y.error("messageChannel is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.setupRemoteControl=function(t){var e=t.element,n=t.remote;return i(this,void 0,void 0,(function(){var t,i;return r(this,(function(r){switch(r.label){case 0:return z().throwIfNotStatus(c.START),z().throwIfMessageNotOpened(),e.setAttribute("tabIndex","-1"),e.style.outline="0",t=window.LIBRTC,[4,z().messageChannel.createStream(t.DataType.kRemoteControl)];case 1:return i=r.sent(),z().setRemoteControlStream(i),[2,t.setupRemoteControl(i,e,n)]}}))}))},t.prototype.getRemoteControlStream=function(){return z().remoteControlStream},t.prototype.createAudioSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return z().throwIfNotStatus(c.START),z().throwIfAudioNotOpened(),(t=z().audioChannel)?(e=z().audioSender?z().audioSender:t.createSender(),z().setAudioSender(e),[2,e]):(Y.error("audioChannel is miss"),[2,null])}))}))},t.prototype.removeAudioSender=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){if(z().throwIfNotStatus(c.START),z().throwIfAudioNotOpened(),!(t=z().audioSender))return Y.error("audioSender is miss"),[2];try{t.stop(),z().audioChannel&&z().audioChannel.removeSender(t.ssrc)}catch(t){Y.error("audioChannel removeSender() error: ",t)}return[2]}))}))},t.prototype.createVideoSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return z().throwIfNotStatus(c.START),z().throwIfVideoNotOpened(),(t=z().videoChannel)?(e=z().videoSender?z().videoSender:t.createSender(),z().setVideoSender(e),e.onbusy=function(){Y.debug("onbusy"),z().emitter.emit(u.CHANNEL_BUSY);var t=z().audioChannel;t&&t.ans(!1)},[2,e]):(Y.error("videoChannel is miss"),[2,null])}))}))},t.prototype.removeVideoSender=function(){z().throwIfNotStatus(c.START),z().throwIfVideoNotOpened();var t=z().videoSender;if(t)try{t.stop(),z().videoChannel&&z().videoChannel.removeSender(t.ssrc)}catch(t){Y.error("videoChannel removeSender() error: ",t)}else Y.error("videoSender is miss")},t.prototype.createDataSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return z().throwIfNotStatus(c.START),z().throwIfDataNotOpened(),(t=z().dataChannel)?(e=z().dataSender?z().dataSender:t.createSender(),z().setDataSender(e),[2,e]):(Y.error("dataChannel is miss"),[2,null])}))}))},t.prototype.removeDataSender=function(){z().throwIfNotStatus(c.START),z().throwIfDataNotOpened();var t=z().dataSender;t?(t.stop(),z().dataChannel&&z().dataChannel.removeSender(t.ssrc),z().setDataSender(null)):Y.error("dataSender is miss")},t.prototype.createAudioReceiver=function(t){z().throwIfNotStatus(c.START),z().throwIfAudioNotOpened();var e=z().audioChannel;if(!e)return Y.error("audioChannel is miss"),null;var n=e.createReceiver();return z().setAudioReceiver(n),t?(n.setSink(t),z().setAudioPlayer(t),e.audioElement&&(e.audioElement.srcObject=null),n):(Y.error("audioPlayer is miss"),null)},t.prototype.createVideoReceiver=function(t){z().throwIfNotStatus(c.START),z().throwIfVideoNotOpened();var e=t.ccid;if(Y.debug("createVideoReceiver ccid: ",e),!e)return Y.error("params is missing or params error"),null;var n=z().videoChannel;return n?n.createReceiver(e):(Y.error("videoChannel is miss"),null)},t.prototype.createDataReceiver=function(t){z().throwIfNotStatus(c.START),z().throwIfDataNotOpened();var e=t.ccid;if(Y.debug("createDataReceiver ccid: ",e),!e)return Y.error("params is missing or params error"),null;var n=z().dataChannel;return n?n.createReceiver(e):(Y.error("dataChannel is miss"),null)},t.prototype.removeVideoReceiver=function(t){return z().throwIfNotStatus(c.START),z().throwIfVideoNotOpened(),t?(t.stop(),z().videoChannel&&z().videoChannel.removeReceiver(t.ssrc),null):t},t.prototype.removeDataReceiver=function(t){return z().throwIfNotStatus(c.START),z().throwIfDataNotOpened(),t?(t.stop(),z().dataChannel&&z().dataChannel.removeReceiver(t.ssrc),null):t},t.prototype.loadVideoRenderer=function(t,e){return void 0===e&&(e=!0),i(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return z().throwIfNotStatus(c.START),z().throwIfVideoNotOpened(),(n=z().videoChannel)&&t?T||g?[4,n.offscreen.load(t.transferControlToOffscreen(),e)]:[3,2]:(Y.error("videoChannel or el is miss"),[2,null]);case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return[2,i]}}))}))},t.prototype.unloadVideoRenderer=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return z().throwIfNotStatus(c.START),z().throwIfVideoNotOpened(),(e=z().videoChannel)&&t?T||g?[4,e.offscreen.unload(t)]:[3,2]:(Y.error("videoChannel or renderer is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.loadDataRenderer=function(t,e){return void 0===e&&(e=!0),i(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return z().throwIfNotStatus(c.START),z().throwIfDataNotOpened(),(n=z().dataChannel)&&t?T||g?[4,n.offscreen.load(t.transferControlToOffscreen(),e)]:[3,2]:(Y.error("dataChannel or el is miss"),[2,null]);case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return[2,i]}}))}))},t.prototype.unloadDataRenderer=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return z().throwIfNotStatus(c.START),z().throwIfDataNotOpened(),(e=z().dataChannel)&&t?T||g?[4,e.offscreen.unload(t)]:[3,2]:(Y.error("dataChannel or renderer is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.bindAudioChannelEvent=function(){z().throwIfNotStatus(c.START),z().throwIfAudioNotOpened();var t=z().audioChannel;t?t.onfocusing=function(t){if(z().voiceActiveSsrc.length&&t.length){if(z().voiceActiveSsrc[0]===t[0])return}else if(0===z().voiceActiveSsrc.length&&0===t.length)return;z().setVoiceActiveSsrc(t),z().emitter.emit(u.VOICE_ACTIVE_SSRC,{ssrc:t})}:Y.error("audioChannel is miss")},t.prototype.offAudioChannelEvent=function(){z().throwIfNotStatus(c.START),z().throwIfAudioNotOpened();var t=z().audioChannel;t?t.onfocusing=null:Y.error("audioChannel is miss")},t.prototype.setAudioPlayerVolume=function(t){z().throwIfNotStatus(c.START),z().throwIfAudioNotOpened();var e=z().audioPlayer;e?(t=t>=0&&t<1?t:t>=1&&t<=100?t/100:t,e.volume=t):Y.error("audioPlayer is miss")},t.prototype.getAudioSender=function(){return z().status===c.START&&z().audioChannelOpened&&z().audioSender||null},t.prototype.getVideoSender=function(){return z().status===c.START&&z().videoChannelOpened&&z().videoSender||null},t.prototype.getDataSender=function(){return z().status===c.START&&z().dataChannelOpened&&z().dataSender||null},t.prototype.getVoiceActiveSsrc=function(){return z().status===c.START&&z().audioChannelOpened&&z().voiceActiveSsrc||[]},t.prototype.getAudioChannelStats=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return z().status===c.START&&z().audioChannelOpened&&z().audioChannel?[4,z().audioChannel.getStats()]:[2,{}];case 1:return[2,t.sent()]}}))}))},t.prototype.createAudioStream=function(){return z().throwIfStatus(c.NULL),B().captureAudioStream()},t.prototype.closeAudioStream=function(){return z().throwIfStatus(c.NULL),B().closeAudioStream()},t.prototype.createVideoStream=function(){return z().throwIfStatus(c.NULL),B().captureVideoStream()},t.prototype.closeVideoStream=function(){return z().throwIfStatus(c.NULL),B().closeVideoStream()},t.prototype.createDataStream=function(){return z().throwIfNotStatus(c.START),B().captureDataStream()},t.prototype.closeDataStream=function(){return B().closeDataStream()},t.prototype.getAudioStream=function(){return B()?B().audioStream:null},t.prototype.getVideoStream=function(){return B()?B().videoStream:null},t.prototype.getDataStream=function(){return B()?B().dataStream:null},t.prototype.getAudioStreamStatus=function(){return B()?B().audioStreamStatus:null},t.prototype.getVideoStreamStatus=function(){return B()?B().videoStreamStatus:null},t.prototype.getDataStreamStatus=function(){return B()?B().dataStreamStatus:null},t.prototype.getActiveAudioInputDevice=function(){return B()?B().audioInputDevice:null},t.prototype.getActiveAudioOutputDevice=function(){return B()?B().audioOutputDevice:null},t.prototype.getActiveVideoInputDevice=function(){return B()?B().videoInputDevice:null},t.prototype.getMicVolume=function(){return B()&&z().status!==c.NULL?B().volumeAnalyser.volume:0},t.prototype.switchAudioInputDevice=function(t){z().throwIfStatus(c.NULL),t&&(B().audioInputDeviceId=t)},t.prototype.switchAudioOutputDevice=function(t){z().throwIfStatus(c.NULL),t&&(B().audioOutputDeviceId=t)},t.prototype.switchVideoInputDevice=function(t){z().throwIfStatus(c.NULL),t&&(B().videoInputDeviceId=t)},t.prototype.getAudioInputDevices=function(){return B()?B().audioInputDevices:[]},t.prototype.getAudioOutputDevices=function(){return B()?B().audioOutputDevices:[]},t.prototype.getVideoInputDevices=function(){return B()?B().videoInputDevices:[]},t.EVENT=u,t.STATUS=c,t.MEDIA_STATUS=d,t.MEDIA_STREAM_STATUS=h,t.MEDIA_STREAM_DETAIL=l,t}();export{K as default};
var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},n.apply(this,arguments)};function i(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{u(i.next(t))}catch(t){o(t)}}function s(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((i=i.apply(t,e||[])).next())}))}function r(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var o,a=function(){function t(){this.events=new Map}return t.prototype.emit=function(t,e){var n=this.events.get(t);n&&n.slice().map((function(t){"function"==typeof t&&t(e)}))},t.prototype.off=function(t,e){var n=this.events.get(t);n&&(e?n.splice(n.indexOf(e)>>>0,1):this.events.set(t,[]))},t.prototype.on=function(t,e){var n=this.events.get(t);n?n.push(e):this.events.set(t,[e])},t}(),s=function(t){function n(e){var n=t.call(this)||this;return n.stream=null,n._enable=!1,n.interval=100,n.timer=null,n.stream=e,n}return e(n,t),n.prototype.analyse=function(){},n.prototype.start=function(){var t=this;this.stream&&(this.timer&&(clearInterval(this.timer),this.timer=null),this.analyse(),this.timer=setInterval((function(){return t.analyse()}),this.interval))},n.prototype.stop=function(){this.timer&&(clearInterval(this.timer),this.timer=null)},n.prototype.destroy=function(){this.stop()},n}(a);!function(t){t.AUDIO_STATUS_CHANGED="audioStatusChanged",t.VIDEO_STATUS_CHANGED="videoStatusChanged"}(o||(o={}));var u,c,d,h,l,p=function(t){function n(e){var n=t.call(this,e)||this;return n._status={active:!1,hasStream:!1,track:!1},n.interval=3e3,n}return e(n,t),Object.defineProperty(n.prototype,"status",{get:function(){return this._status},set:function(t){var e=this._status;e.active===t.active&&e.hasStream===t.hasStream&&e.track===t.track||(this._status=t,this.emit(o.AUDIO_STATUS_CHANGED,{status:this._status}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.stream){var t=this.stream.getAudioTracks();this.status.active=void 0===this.stream.active?Boolean(t[0]):this.stream.active,void 0!==this.stream.active&&void 0!==this.stream.id?this.status.hasStream=!0:this.status.hasStream=!1,(this.status.active||this.status.hasStream)&&(this.status.track=this.checkAvariable(t))}else this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.streamInactive=function(){this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.checkAvariable=function(t){return void 0===t&&(t=[]),t.some((function(t){return!("readyState"in t&&"live"!==t.readyState||"muted"in t&&!0===t.muted)}))},n.prototype.destroy=function(){this.stream&&this.stream.removeEventListener("inactive",this.streamInactive),t.prototype.destroy.call(this)},n}(s),v=function(t){function n(e){var n=t.call(this,e)||this;return n._status={active:!1,hasStream:!1,track:!1},n.interval=3e3,n}return e(n,t),Object.defineProperty(n.prototype,"status",{get:function(){return this._status},set:function(t){var e=this._status;e.active===t.active&&e.hasStream===t.hasStream&&e.track===t.track||(this._status=t,this.emit(o.VIDEO_STATUS_CHANGED,{status:this._status}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.stream){var t=this.stream.getVideoTracks();this.status.active=void 0===this.stream.active?Boolean(t[0]):this.stream.active,void 0!==this.stream.active&&void 0!==this.stream.id?this.status.hasStream=!0:this.status.hasStream=!1,(this.status.active||this.status.hasStream)&&(this.status.track=this.checkAvariable(t))}else this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.streamInactive=function(){this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.checkAvariable=function(t){return void 0===t&&(t=[]),t.some((function(t){return!("readyState"in t&&"live"!==t.readyState||"muted"in t&&!0===t.muted)}))},n.prototype.destroy=function(){this.stream&&this.stream.removeEventListener("inactive",this.streamInactive),t.prototype.destroy.call(this)},n}(s),f=function(t){function n(e){var n=t.call(this,e)||this;return n.volume=0,n.context=null,n.contextAnalyser=null,n.streamSource=null,n}return e(n,t),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.context&&this.contextAnalyser&&this.streamSource){var t=this.contextAnalyser.frequencyBinCount,e=new Uint8Array(t);this.contextAnalyser.getByteFrequencyData(e);var n=e.reduce((function(t,e){return t+e}),0);this.volume=n/t}else this.volume=0},n.prototype.start=function(){this.createContextAnalyser(),this.createStreamSource(),this.streamSource&&t.prototype.start.call(this)},n.prototype.stop=function(){this.streamSource&&(this.streamSource.disconnect(),this.streamSource=null),this.volume=0,t.prototype.stop.call(this)},n.prototype.createContextAnalyser=function(){if((!this.context||!this.contextAnalyser)&&(window.AudioContext||window.webkitAudioContext)){var t=window.AudioContext||window.webkitAudioContext;this.context=new t,this.contextAnalyser=this.context.createAnalyser(),this.contextAnalyser.fftSize=1024,this.contextAnalyser.smoothingTimeConstant=.5}},n.prototype.createStreamSource=function(){if(this.streamSource&&(this.streamSource.disconnect(),this.streamSource=null),this.context&&this.stream&&this.stream.getAudioTracks().length>0){if(this.streamSource=this.context.createMediaStreamSource(this.stream),!this.contextAnalyser)return;this.streamSource.connect(this.contextAnalyser),"suspended"===this.context.state&&this.context.resume()}},n.prototype.destroy=function(){this.contextAnalyser&&(this.contextAnalyser.disconnect(),this.contextAnalyser=null),this.context&&(this.context=null),t.prototype.destroy.call(this)},n}(s);!function(t){t.STREAM_STATUS="streamStatus",t.CHANNEL_REFRESH="channelRefresh",t.CHANNEL_BUSY="channelBusy",t.AUDIO_CHANNEL_OPENED="audioChannelOpened",t.VIDEO_CHANNEL_OPENED="videoChannelOpened",t.DATA_CHANNEL_OPENED="dataChannelOpened",t.MESSAGE_CHANNEL_OPENED="messageChannelOpened",t.AUDIO_STREAM="audioStream",t.VIDEO_STREAM="videoStream",t.DATA_STREAM="dataStream",t.AUDIO_INPUT_DEVICES_UPDATED="audioInputDevicesUpdated",t.AUDIO_OUTPUT_DEVICES_UPDATED="audioOutputDevicesUpdated",t.VIDEO_INPUT_DEVICES_UPDATED="videoInputDevicesUpdated",t.AUDIO_INPUT_DEVICE_CHANGED="audioInputDeviceChanged",t.AUDIO_OUTPUT_DEVICE_CHANGED="audioOutputDeviceChanged",t.VIDEO_INPUT_DEVICE_CHANGED="videoInputDeviceChanged",t.AUDIO_STREAM_STATUS="audioStreamStatus",t.VIDEO_STREAM_STATUS="videoStreamStatus",t.DATA_STREAM_STATUS="dataStreamStatus",t.VOICE_ACTIVE_SSRC="voiceActiveSsrc"}(u||(u={})),function(t){t.NULL="null",t.INIT="initialized",t.START="started",t.STOP="stopped"}(c||(c={})),function(t){t.Null="null",t.INIT="initialized"}(d||(d={})),function(t){t.NULL="null",t.CAPTURING="capturing",t.FAILED="failed"}(h||(h={})),function(t){t.NO_DEVICE="No Device",t.PERMISSION_DENIED="Permission denied",t.COULD_NOT_START_VIDEO_SOURCE="Could not start video source",t.PERMISSION_DENIED_BY_SYSTEM="Permission denied by system",t.OTHER_EXCEPTIONS="Other exceptions"}(l||(l={}));var S,m=function(t,e){var n=e.match(t);return n&&n.length>0&&n[1]||""},I=/version\/(\d+(\.?_?\d+)+)/i,D=[{test:[/\sedg\//i],describe:function(t){var e={name:"Microsoft Edge"},n=m(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/edg([ea]|ios)/i],describe:function(t){var e={name:"Microsoft Edge"},n=function(t,e){var n=e.match(t);return n&&n.length>1&&n[2]||""}(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/firefox|iceweasel|fxios/i],describe:function(t){var e={name:"Firefox"},n=m(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/chromium/i],describe:function(t){var e={name:"Chromium"},n=m(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||m(I,t);return n&&(e.version=n),e}},{test:[/chrome|crios|crmo/i],describe:function(t){var e={name:"Chrome"},n=m(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/safari|applewebkit/i],describe:function(t){var e={name:"Safari"},n=m(I,t);return n&&(e.version=n),e}}],y=D.find((function(t){if(t.test instanceof Array)return t.test.some((function(t){return t.test(navigator.userAgent)}));throw new Error("Browser's test function is not valid")}));y&&(S=y.describe(navigator.userAgent));var A=S&&"Safari"===S.name,E=S&&"Firefox"===S.name,T=S&&"Chrome"===S.name,g=S&&"Microsoft Edge"===S.name,_=function(){function t(t){var e=t.namespace,n=t.debug;this.initialized=!0,this.isDebugging=n,this.backend=b(),this.namespace=e,this.useColors=this.backend.useColors,this.color=this.selectColor(e)}return t.prototype.logger=function(t){var e=this;t[0]=this.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");var n=0;return t[0]=t[0].replace(/%([a-zA-Z%])/g,(function(i,r){if("%%"===i)return i;n++;var o=e.backend.formatters[r];"function"==typeof o&&(i=o(t[n]),t.splice(n,1),n--);return i})),this.backend.formatArgs(t,this)},t.prototype.coerce=function(t){return t instanceof Error?t.stack||t.message:t},t.prototype.selectColor=function(t){var e=Array.from(t).reduce((function(t,e){return t=(t<<5)-t+e.charCodeAt(0),t|=0}),0);return this.backend.colors[Math.abs(e)%this.backend.colors.length]},t.prototype.switchDebug=function(t){this.isDebugging=t},t.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];t=this.logger(t),this.backend.log.apply(this,t)},t.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.isDebugging&&(t=this.logger(t),this.backend.debug.apply(this,t))},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.backend.warn.apply(this,t)},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.backend.error.apply(this,t)},t}(),b=function(){var t={colors:["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],formatters:{j:function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: ".concat(t.message)}}},log:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,t)},debug:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.debug&&Function.prototype.apply.call(console.debug,console,t)},warn:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.warn&&Function.prototype.apply.call(console.warn,console,t)},error:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.error&&Function.prototype.apply.call(console.error,console,t)},formatArgs:function(t,e){var n=e.useColors,i=e.namespace,r=e.color;if(t[0]="".concat((n?"%c":"")+i+(n?" %c":" ")+t[0]+(n?"%c ":" "),"+").concat(function(t){var e=Math.abs(t);if(e>=N)return"".concat(Math.round(t/N),"d");if(e>=w)return"".concat(Math.round(t/w),"h");if(e>=O)return"".concat(Math.round(t/O),"m");if(e>=C)return"".concat(Math.round(t/C),"s");return"".concat(t,"ms")}(0)),!n)return[];var o="color: ".concat(r);t.splice(1,0,o,"color: inherit");var a=0,s=0;return t[0].replace(/%[a-zA-Z%]/g,(function(t){"%%"!==t&&(a++,"%c"===t&&(s=a))})),t.splice(s,0,o),t},useColors:U()};return t},C=1e3,O=60*C,w=60*O,N=24*w;var U=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.webkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},R=function(t){return t.close=t.stop=function(){!function(t){if(t)try{t.getTracks?t.getTracks().forEach((function(t){return t.stop()})):(t.getAudioTracks().forEach((function(t){return t.stop()})),t.getVideoTracks().forEach((function(t){return t.stop()})))}catch(e){"function"!=typeof t.stop&&"object"!=typeof t.stop||t.stop()}}(this)},t.pause=function(){this.getTracks().forEach((function(t){return t.enabled=!1}))},t.play=function(){this.getTracks().forEach((function(t){return t.enabled=!0}))},t.muteAudio=function(t){void 0===t&&(t=!0),this.getAudioTracks().forEach((function(e){return e.enabled=!t}))},t.muteVideo=function(t){void 0===t&&(t=!0),this.getVideoTracks().forEach((function(e){return e.enabled=!t}))},t},P=function(t){return i(void 0,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return navigator.mediaDevices.getUserMedia?[4,navigator.mediaDevices.getUserMedia(t)]:[3,2];case 1:case 3:return e=n.sent(),[3,5];case 2:return navigator.getUserMedia?[4,new Promise((function(e,n){navigator.getUserMedia(t,e,n)}))]:[3,4];case 4:throw new Error("Not Supported");case 5:return[2,R(e)]}}))}))},L=function(t){return i(void 0,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return navigator.mediaDevices.getDisplayMedia?[4,navigator.mediaDevices.getDisplayMedia(t)]:[3,2];case 1:case 3:return e=n.sent(),[3,5];case 2:return navigator.getDisplayMedia?[4,new Promise((function(e,n){navigator.getDisplayMedia(t,e,n)}))]:[3,4];case 4:throw new Error("Not Supported");case 5:return[2,R(e)]}}))}))},V=new _({namespace:"STREAM:Media",debug:!1}),M=function(t){function a(e){var n=e.debug,i=t.call(this)||this;return i.status=d.Null,i.deviceList=[],i.audioQueue=Promise.resolve(null),i.videoQueue=Promise.resolve(null),i.dataQueue=Promise.resolve(null),i._audioStream=null,i._videoStream=null,i._displayStream=null,i._audioInputDevice=null,i._audioOutputDevice=null,i._videoInputDevice=null,i._audioInputDeviceId="",i._audioOutputDeviceId="",i._videoInputDeviceId="",i._audioInputDevices=[],i._audioOutputDevices=[],i._videoInputDevices=[],i._audioStreamStatus={status:h.NULL},i._videoStreamStatus={status:h.NULL},i._dataStreamStatus={status:h.NULL},i.onDataStreamInactive=i.dataStreamInactive.bind(i),V.switchDebug(n),i.volumeAnalyser=new f(i.audioStream),i.audioAnalyser=new p(i.audioStream),i.videoAnalyser=new v(i.videoStream),i.setup(),i}return e(a,t),a.createInstance=function(t){return this.instance||(this.instance=new a(t)),this.instance},Object.defineProperty(a.prototype,"audioInputDevices",{get:function(){return this._audioInputDevices||[]},set:function(t){this.checkDeviceList(t,this._audioInputDevices)||(this._audioInputDevices=t,this.status===d.INIT&&this.emit(u.AUDIO_INPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDevices",{get:function(){return this._audioOutputDevices||[]},set:function(t){this.checkDeviceList(t,this._audioOutputDevices)||(this._audioOutputDevices=t,this.status===d.INIT&&this.emit(u.AUDIO_OUTPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDevices",{get:function(){return this._videoInputDevices||[]},set:function(t){this.checkDeviceList(t,this._videoInputDevices)||(this._videoInputDevices=t,this.status===d.INIT&&this.emit(u.VIDEO_INPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioInputDeviceId",{get:function(){return this._audioInputDeviceId||""},set:function(t){if(!this._audioInputDeviceId||this._audioInputDeviceId!==t){var e=this.audioInputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.audioInputDevice=i,this._audioInputDeviceId=i?i.deviceId:"",this.audioStreamStatus.status!==h.NULL&&this.captureAudioStream()}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDeviceId",{get:function(){return this._audioOutputDeviceId||""},set:function(t){if(!this._audioOutputDeviceId||this._audioOutputDeviceId!==t){var e=this.audioOutputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.audioOutputDevice=i,this._audioOutputDeviceId=i?i.deviceId:""}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDeviceId",{get:function(){return this._videoInputDeviceId||""},set:function(t){if(!this._videoInputDeviceId||this._videoInputDeviceId!==t){var e=this.videoInputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.videoInputDevice=i,this._videoInputDeviceId=i?i.deviceId:"",this.videoStreamStatus.status!==h.NULL&&this.captureVideoStream()}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioInputDevice",{get:function(){return this._audioInputDevice},set:function(t){var e=this._audioInputDevice&&!this.isSameDevice(this._audioInputDevice,t),n=!this._audioInputDevice&&!!t;(n||e)&&(this._audioInputDevice=t,!n&&e&&this.emit(u.AUDIO_INPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDevice",{get:function(){return this._audioOutputDevice},set:function(t){var e=this._audioOutputDevice&&!this.isSameDevice(this._audioOutputDevice,t),n=!this._audioOutputDevice&&!!t;(n||e)&&(this._audioOutputDevice=t,!n&&e&&this.emit(u.AUDIO_OUTPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDevice",{get:function(){return this._videoInputDevice},set:function(t){var e=this._videoInputDevice&&!this.isSameDevice(this._videoInputDevice,t),n=!this._videoInputDevice&&!!t;(n||e)&&(this._videoInputDevice=t,!n&&e&&this.emit(u.VIDEO_INPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"supportNativeShare",{get:function(){return navigator.getDisplayMedia||navigator.mediaDevices.getDisplayMedia},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioStream",{get:function(){return this._audioStream},set:function(t){this._audioStream!==t&&(this._audioStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoStream",{get:function(){return this._videoStream},set:function(t){this._videoStream!==t&&(this._videoStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"dataStream",{get:function(){return this._displayStream},set:function(t){this._displayStream!==t&&(this._displayStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioStreamStatus",{get:function(){return this._audioStreamStatus},set:function(t){var e=this._audioStreamStatus;e.status===t.status&&e.detail===t.detail||(this._audioStreamStatus=t,this.emit(u.AUDIO_STREAM_STATUS,this._audioStreamStatus))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoStreamStatus",{get:function(){return this._videoStreamStatus},set:function(t){var e=this._videoStreamStatus;e.status===t.status&&e.detail===t.detail||(this._videoStreamStatus=t,this.emit(u.VIDEO_STREAM_STATUS,this._videoStreamStatus))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"dataStreamStatus",{get:function(){return this._dataStreamStatus},set:function(t){var e=this._dataStreamStatus;e.status===t.status&&e.detail===t.detail||(this._dataStreamStatus=t,this.emit(u.DATA_STREAM_STATUS,this._dataStreamStatus))},enumerable:!1,configurable:!0}),a.prototype.setup=function(){var t=this;this.audioAnalyser.on(o.AUDIO_STATUS_CHANGED,(function(e){var n=e.status;V.debug("".concat(o.AUDIO_STATUS_CHANGED," ").concat(JSON.stringify(n))),!n.hasStream||n.track&&n.active||(t.audioStreamStatus={status:h.FAILED,detail:l.OTHER_EXCEPTIONS})})),this.videoAnalyser.on(o.VIDEO_STATUS_CHANGED,(function(e){var n=e.status;V.debug("".concat(o.VIDEO_STATUS_CHANGED," ").concat(JSON.stringify(n))),!n.hasStream||n.track&&n.active||(t.videoStreamStatus={status:h.FAILED,detail:l.OTHER_EXCEPTIONS})}))},a.prototype.cleanup=function(){this.deviceList=[],this.audioInputDevices=[],this.audioInputDeviceId="",this.audioOutputDevices=[],this.audioOutputDeviceId="",this.videoInputDevices=[],this.videoInputDeviceId="",this.volumeAnalyser.destroy(),this.audioAnalyser.destroy(),this.videoAnalyser.destroy()},a.prototype.init=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return this.throwIfStatus(d.INIT),navigator.mediaDevices&&(e=this,navigator.mediaDevices.ondevicechange=function(){e.detectDevice()}),[4,this.detectDevice(t)];case 1:return n.sent(),this.status=d.INIT,[2]}}))}))},a.prototype.destroy=function(){try{this.closeAudioStream(),this.closeVideoStream(),this.closeDataStream(),this.cleanup()}catch(t){V.error(t)}this.status=d.Null},a.prototype.detectDevice=function(t){return i(this,void 0,void 0,(function(){var e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:return navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices?[4,this.enumerateDevices().catch((function(t){return V.error("enumerate devices error: ",t)}))]:(V.error("mediaDevices or enumerateDevices is miss"),[2]);case 1:return e=r.sent(),this.deviceList=e&&e.map((function(t){return t.toJSON()}))||[],V.debug("deviceList: ".concat(JSON.stringify(this.deviceList))),i=(n=this).audioInputDevice,o=n.audioOutputDevice,a=n.videoInputDevice,this.audioInputDevices=this.deviceList.filter((function(t){return"audioinput"===t.kind}))||[],this.audioInputDeviceId=this.checkDevice({deviceList:this.audioInputDevices,device:i,deviceId:t&&t.audioInputDeviceId||""}),this.audioOutputDevices=this.deviceList.filter((function(t){return"audiooutput"===t.kind}))||[],this.audioOutputDeviceId=this.checkDevice({deviceList:this.audioOutputDevices,device:o,deviceId:t&&t.audioOutputDeviceId||""}),this.videoInputDevices=this.deviceList.filter((function(t){return"videoinput"===t.kind}))||[],this.videoInputDeviceId=this.checkDevice({deviceList:this.videoInputDevices,device:a,deviceId:t&&t.videoInputDeviceId||""}),[2]}}))}))},a.prototype.enumerateDevices=function(){return new Promise((function(t,e){navigator.mediaDevices.enumerateDevices().then((function(e){t(e)})).catch((function(t){e(t)}))}))},a.prototype.genAudioConstraints=function(t){var e={audio:!1,video:!1},n=this.audioInputDevice,i=n||{deviceId:"",groupId:""},r=i.deviceId,o=i.groupId;return e.audio=!!n&&(t&&E?{deviceId:{exact:r},groupId:{exact:o}}:{deviceId:r,groupId:o}),e.audio&&!A&&Object.assign(e.audio,k),e},a.prototype.genVideoConstraints=function(){var t={audio:!1,video:!1},e=this.videoInputDevice,n=e||{deviceId:"",groupId:""},i=n.deviceId,r=n.groupId;return t.video=!!e&&(E?{deviceId:{exact:i},groupId:{exact:r}}:{deviceId:i,groupId:r}),t.video&&Object.assign(t.video,x),t},a.prototype.genDisplayConstraints=function(t){var e,i=t.quality;return this.supportNativeShare?e={video:n({},i)}:e},a.prototype.createAudioStream=function(t){return i(this,void 0,void 0,(function(){var e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:if(e=this.genAudioConstraints(t),V.debug("audio constraints: ".concat(JSON.stringify(e))),n=this.audioStreamStatus,!e.audio)return[2,{stream:null,audioStreamStatus:n={status:h.FAILED,detail:l.NO_DEVICE}}];i=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,P(e)];case 2:return i=r.sent(),[3,4];case 3:return a=r.sent(),V.debug("getUserMedia error: ".concat(a)),o=a,[3,4];case 4:return i?n={status:h.CAPTURING}:(o=o||new Error("Stream is null"),n={status:h.FAILED,detail:H.get(o.message)||l.OTHER_EXCEPTIONS}),[2,{stream:i,audioStreamStatus:n}]}}))}))},a.prototype.createVideoStream=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:if(t=this.genVideoConstraints(),V.debug("video constraints: ".concat(JSON.stringify(t))),e=this.videoStreamStatus,!t.video)return[2,{stream:null,videoStreamStatus:e={status:h.FAILED,detail:l.NO_DEVICE}}];n=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,P(t)];case 2:return n=r.sent(),[3,4];case 3:return o=r.sent(),V.debug("getUserMedia error: ".concat(o)),i=o,[3,4];case 4:return n?e={status:h.CAPTURING}:(i=i||new Error("Stream is null"),e={status:h.FAILED,detail:G.get(i.message)||l.OTHER_EXCEPTIONS}),[2,{stream:n,videoStreamStatus:e}]}}))}))},a.prototype.createDataStream=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:t=this.genDisplayConstraints({quality:j}),V.debug("data constraints: ".concat(JSON.stringify(t))),e=null,i=this.dataStreamStatus,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,L(t)];case 2:return e=r.sent(),[3,4];case 3:return o=r.sent(),V.debug("getDisplayMedia error: ".concat(o)),n=o,[3,4];case 4:return e?i={status:h.CAPTURING}:(n=n||new Error("Stream is null"),i={status:h.FAILED,detail:F.get(n.message)||l.OTHER_EXCEPTIONS}),[2,{stream:e,dataStreamStatus:i}]}}))}))},a.prototype.closeAudioStream=function(){this.audioStream&&this.audioStream.close(),this.audioStream=null,this.switchAudioAnalyserEnable({enable:!1}),this.setAudioAnalyserStream(this.audioStream),this.audioStreamStatus={status:h.NULL},this.emit(u.AUDIO_STREAM,{stream:this.audioStream})},a.prototype.closeVideoStream=function(){this.videoStream&&this.videoStream.close(),this.videoStream=null,this.switchVideoAnalyserEnable({enable:!1}),this.setVideoAnalyserStream(this.videoStream),this.videoStreamStatus={status:h.NULL},this.emit(u.VIDEO_STREAM,{stream:this.videoStream})},a.prototype.closeDataStream=function(){var t=this;this.dataStream&&(this.dataStream.removeEventListener("inactive",this.onDataStreamInactive),(this.dataStream.getVideoTracks()||[]).forEach((function(e){e.removeEventListener("ended",t.onDataStreamInactive)})),this.dataStream.close());this.dataStream=null,this.dataStreamStatus={status:h.NULL},this.emit(u.DATA_STREAM,{stream:this.dataStream})},a.prototype.captureAudioStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.audioQueue=this.audioQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return this.switchAudioAnalyserEnable({enable:!1}),t=!(this.audioStreamStatus.status!==h.CAPTURING||!this.audioStream),[4,this.createAudioStream(t)];case 1:return e=r.sent(),n=e.stream,i=e.audioStreamStatus,this.audioStreamStatus.status===h.CAPTURING&&this.audioStream&&(this.audioStream.close(),this.audioStream=null),this.status!==d.INIT?(n&&n.close(),this.emit(u.AUDIO_STREAM,{stream:this.audioStream}),[2,Promise.resolve(this.audioStream)]):(this.audioStream=n,this.audioStreamStatus=i,this.emit(u.AUDIO_STREAM,{stream:this.audioStream}),o=!0,n||i.status!==h.FAILED||(o=!1),this.setAudioAnalyserStream(n),this.switchAudioAnalyserEnable({enable:o}),[2,Promise.resolve(this.audioStream)])}}))}))}))},a.prototype.captureVideoStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.videoQueue=this.videoQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i;return r(this,(function(r){switch(r.label){case 0:return this.switchVideoAnalyserEnable({enable:!1}),[4,this.createVideoStream()];case 1:return t=r.sent(),e=t.stream,n=t.videoStreamStatus,this.videoStreamStatus.status===h.CAPTURING&&this.videoStream&&(this.videoStream.close(),this.videoStream=null),this.status!==d.INIT?(e&&e.close(),this.emit(u.VIDEO_STREAM,{stream:this.videoStream}),[2,Promise.resolve(this.videoStream)]):(this.videoStream=e,this.videoStreamStatus=n,this.emit(u.VIDEO_STREAM,{stream:this.videoStream}),i=!0,e||n.status!==h.FAILED||(i=!1),this.setVideoAnalyserStream(e),this.switchVideoAnalyserEnable({enable:i}),[2,Promise.resolve(this.videoStream)])}}))}))}))},a.prototype.captureDataStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.dataQueue=this.dataQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i=this;return r(this,(function(r){switch(r.label){case 0:return[4,this.createDataStream()];case 1:return t=r.sent(),e=t.stream,n=t.dataStreamStatus,this.dataStreamStatus.status!==h.NULL||e?(this.dataStreamStatus.status===h.CAPTURING&&this.dataStream&&!e||(this.dataStreamStatus.status===h.CAPTURING&&this.dataStream&&(this.dataStream.removeEventListener("inactive",this.onDataStreamInactive),(this.dataStream.getVideoTracks()||[]).forEach((function(t){t.removeEventListener("ended",i.onDataStreamInactive)})),this.dataStream.close(),this.dataStream=null),e&&e.addEventListener("inactive",this.onDataStreamInactive),E&&e&&(e.getVideoTracks()||[]).forEach((function(t){t.addEventListener("ended",i.onDataStreamInactive)})),this.dataStream=e,this.dataStreamStatus=n,this.emit(u.DATA_STREAM,{stream:this.dataStream})),[2,Promise.resolve(this.dataStream)]):[2,Promise.resolve(this.dataStream)]}}))}))}))},a.prototype.setAudioAnalyserStream=function(t){this.volumeAnalyser.stream=t,this.audioAnalyser.stream=t},a.prototype.setVideoAnalyserStream=function(t){this.videoAnalyser.stream=t},a.prototype.switchAudioAnalyserEnable=function(t){var e=t.enable,n=void 0!==e&&e;this.volumeAnalyser.enable=n,this.audioAnalyser.enable=n},a.prototype.switchVideoAnalyserEnable=function(t){var e=t.enable,n=void 0!==e&&e;this.videoAnalyser.enable=n},a.prototype.dataStreamInactive=function(){this.dataStream&&(this.dataStream.close(),this.dataStream=null,this.dataStreamStatus={status:h.NULL},this.emit(u.DATA_STREAM,{stream:this.dataStream}))},a.prototype.checkDevice=function(t){var e=this,n=t.deviceList,i=t.device,r=t.deviceId;return(i=(i=r?n.find((function(t){return t.deviceId===r}))||null:i&&n.find((function(t){return e.isSameDevice(t,i)}))||null)||(n[0]||null))&&i.deviceId?i.deviceId:""},a.prototype.checkDeviceList=function(t,e){if(!t||!e||t.length!==e.length)return!1;for(var n=!0,i=0;i<t.length;i++){var r=t[i],o=e[i];if(!this.isSameDevice(r,o)){n=!1;break}}return n},a.prototype.isSameDevice=function(t,e,n){if(void 0===n&&(n=!1),!t||!e)return!1;var i=t.deviceId===e.deviceId&&t.label===e.label&&t.kind===e.kind;return n?t.groupId===e.groupId&&i:i},a.prototype.throwIfStatus=function(t,e){if(this.status===t)throw new Error(e||"Invalid State")},a.prototype.throwIfNotStatus=function(t,e){if(this.status!==t)throw new Error(e||"Invalid State")},a}(a),k={autoGainControl:!0,echoCancellation:!0,latency:0,noiseSuppression:!0},x={aspectRatio:16/9,frameRate:30,width:640,height:360},j={width:1920,height:1080,frameRate:5},H=new Map([["No Device",l.NO_DEVICE],["Permission denied",l.PERMISSION_DENIED],["Permission dismissed",l.PERMISSION_DENIED],["Could not start video source",l.OTHER_EXCEPTIONS],["The request is not allowed by the user agent or the platform in the current context.",l.PERMISSION_DENIED],["Failed to allocate videosource",l.OTHER_EXCEPTIONS],["Stream is null",l.OTHER_EXCEPTIONS]]),G=new Map([["No Device",l.NO_DEVICE],["Permission denied",l.PERMISSION_DENIED],["Permission dismissed",l.PERMISSION_DENIED],["Could not start video source",l.COULD_NOT_START_VIDEO_SOURCE],["The request is not allowed by the user agent or the platform in the current context.",l.PERMISSION_DENIED],["Failed to allocate videosource",l.COULD_NOT_START_VIDEO_SOURCE],["Stream is null",l.OTHER_EXCEPTIONS]]),F=new Map([["Permission denied by system",l.PERMISSION_DENIED_BY_SYSTEM],["The object can not be found here.",l.PERMISSION_DENIED_BY_SYSTEM],["The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.",l.PERMISSION_DENIED_BY_SYSTEM]]),B=function(){return M.instance},X=new _({namespace:"STREAM:Store",debug:!1}),J=function(){function t(t){var e=this,n=t.debug;this.status=c.NULL,this.remoteControlStream=null,this.videoSender=null,this.audioSender=null,this.dataSender=null,this.audioReceiver=null,this.voiceActiveSsrc=[],this.audioPlayer=null,this.audioChannelOpened=!1,this.videoChannelOpened=!1,this.dataChannelOpened=!1,this.messageChannelOpened=!1,this.api={getMss:function(t){var n=e.baseURL;return"function"!=typeof fetch?Promise.reject():fetch(function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(n,"/webapp/front/getMss"),{headers:{"content-type":"application/json"},method:"POST",body:JSON.stringify(t)}).then((function(t){return i(e,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,t.json()];case 1:return[2,e.sent()]}}))}))}))}},this.baseURL="https://meetings.ylyun.com",this.videoSDKLibDir="",X.switchDebug(n),this.emitter=new a}return t.createInstance=function(e){return this.instance||(this.instance=new t(e)),this.instance},t.prototype.setApi=function(t){this.api=t},t.prototype.setBaseUrl=function(t){this.baseURL=t},t.prototype.setVideoSDKLibDir=function(t){this.videoSDKLibDir=t},t.prototype.setMediaEndpoint=function(t){this.mediaEndpoint=t},t.prototype.setMediaEngine=function(t){this.mediaEngine=t},t.prototype.setAudioChannel=function(t){this.audioChannel=t},t.prototype.setVideoChannel=function(t){this.videoChannel=t},t.prototype.setDataChannel=function(t){this.dataChannel=t},t.prototype.setMessageChannel=function(t){this.messageChannel=t},t.prototype.setRemoteControlStream=function(t){this.remoteControlStream=t},t.prototype.setVideoSender=function(t){this.videoSender=t},t.prototype.setAudioSender=function(t){this.audioSender=t},t.prototype.setDataSender=function(t){this.dataSender=t},t.prototype.setAudioReceiver=function(t){this.audioReceiver=t},t.prototype.setAudioPlayer=function(t){this.audioPlayer=t},t.prototype.setVoiceActiveSsrc=function(t){this.voiceActiveSsrc=t},t.prototype.throwIfAudioNotOpened=function(t){if(!this.audioChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfVideoNotOpened=function(t){if(!this.videoChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfDataNotOpened=function(t){if(!this.dataChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfMessageNotOpened=function(t){if(!this.messageChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfStatus=function(t,e){if(this.status===t)throw new Error(e||"Invalid State")},t.prototype.throwIfNotStatus=function(t,e){if(this.status!==t)throw new Error(e||"Invalid State")},t.prototype.loadLibRTCFiles=function(){var t=this.videoSDKLibDir;return Promise.all([this.createScriptTag({src:"".concat(t,"/libsfu.prod.js"),id:"ylink-sdk-stream-libsfu"}),this.createScriptTag({src:"".concat(t,"/librtc.global.prod.js"),id:"ylink-sdk-stream-librtc"})])},t.prototype.getLibRTCContext=function(){var t=window.LIBRTC.SFUTransportType,e=this.mediaEndpoint,n=this.mediaEngine;return e&&n?{mediaEndpoint:e,mediaEngine:n,SFUTransportType:t}:{SFUTransportType:t}},t.prototype.createScriptTag=function(t){var e=t.src,n=t.id;return new Promise((function(t,i){!function(t){if(t){var e=document.querySelector("#".concat(t));if(e){var n=e.parentElement;n&&n.removeChild(e)}}}(n);var r=document.createElement("script");r.type="text/javascript",r.src=e,r.id=n,r.onload=function(){t(r)},r.onerror=function(t){i(t)},document.head.appendChild(r)}))},t.prototype.cleanup=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o,a,s,u;return r(this,(function(r){switch(r.label){case 0:e=(t=this).videoChannel,n=t.audioChannel,i=t.messageChannel,o=t.dataChannel,a=t.mediaEndpoint,s=t.remoteControlStream,r.label=1;case 1:return r.trys.push([1,12,,13]),n?[4,n.close()]:[3,3];case 2:r.sent(),r.label=3;case 3:return e?[4,e.close()]:[3,5];case 4:r.sent(),r.label=5;case 5:return o?[4,o.close()]:[3,7];case 6:r.sent(),r.label=7;case 7:return s&&i?[4,i.closeStream(s)]:[3,9];case 8:r.sent(),r.label=9;case 9:return i?[4,i.close()]:[3,11];case 10:r.sent(),r.label=11;case 11:return a&&(a.stop(),a.destroy()),[3,13];case 12:return u=r.sent(),X.error(u),[3,13];case 13:return this.mediaEndpoint=null,this.mediaEngine=null,this.videoChannel=null,this.audioChannel=null,this.dataChannel=null,this.messageChannel=null,this.videoSender=null,this.audioSender=null,this.dataSender=null,this.audioReceiver=null,this.audioPlayer=null,this.audioChannelOpened=!1,this.videoChannelOpened=!1,this.dataChannelOpened=!1,this.messageChannelOpened=!1,[2]}}))}))},t}(),z=function(){return J.instance},Y=new _({namespace:"STREAM:Store",debug:!1}),K=function(){function t(t){var e,n=t.baseURL,i=t.videoSDKLibDir,r=t.debug;n=n||"https://meetings.ylyun.com",i=i||"",r=r||!1,Y.switchDebug(r),e={debug:r},J.createInstance(e),function(t){M.createInstance(t)}({debug:r}),z().setBaseUrl(n),z().setVideoSDKLibDir(i),this.setup()}return t.prototype.setup=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){return B().on(u.AUDIO_STREAM,(function(t){z().emitter.emit(u.AUDIO_STREAM,t)})),B().on(u.VIDEO_STREAM,(function(t){z().emitter.emit(u.VIDEO_STREAM,t)})),B().on(u.DATA_STREAM,(function(t){z().emitter.emit(u.DATA_STREAM,t)})),B().on(u.AUDIO_INPUT_DEVICES_UPDATED,(function(t){z().emitter.emit(u.AUDIO_INPUT_DEVICES_UPDATED,t)})),B().on(u.AUDIO_OUTPUT_DEVICES_UPDATED,(function(t){z().emitter.emit(u.AUDIO_OUTPUT_DEVICES_UPDATED,t)})),B().on(u.VIDEO_INPUT_DEVICES_UPDATED,(function(t){z().emitter.emit(u.VIDEO_INPUT_DEVICES_UPDATED,t)})),B().on(u.AUDIO_INPUT_DEVICE_CHANGED,(function(t){z().emitter.emit(u.AUDIO_INPUT_DEVICE_CHANGED,t)})),B().on(u.AUDIO_OUTPUT_DEVICE_CHANGED,(function(t){z().emitter.emit(u.AUDIO_OUTPUT_DEVICE_CHANGED,t)})),B().on(u.VIDEO_INPUT_DEVICE_CHANGED,(function(t){z().emitter.emit(u.VIDEO_INPUT_DEVICE_CHANGED,t)})),B().on(u.AUDIO_STREAM_STATUS,(function(t){z().emitter.emit(u.AUDIO_STREAM_STATUS,t)})),B().on(u.VIDEO_STREAM_STATUS,(function(t){z().emitter.emit(u.VIDEO_STREAM_STATUS,t)})),B().on(u.DATA_STREAM_STATUS,(function(t){z().emitter.emit(u.DATA_STREAM_STATUS,t)})),[2]}))}))},t.prototype.cleanup=function(){},t.prototype.on=function(t,e){return z().emitter.on(t,e)},t.prototype.off=function(t,e){return z().emitter.off(t,e)},t.prototype.init=function(t){return i(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:if(window.ActiveXObject||"ActiveXObject"in window)throw new Error("Not compatible with this browser yet, please use other browsers instead.");return[4,B().init(t)];case 1:return e.sent(),z().status=c.INIT,z().emitter.emit(u.STREAM_STATUS,{status:z().status}),[2]}}))}))},t.prototype.start=function(t){return i(this,void 0,void 0,(function(){var e,n,o,a,s,d,h,l,p,v,f,S=this;return r(this,(function(m){switch(m.label){case 0:return z().throwIfStatus(c.NULL),z().throwIfStatus(c.START),[4,z().loadLibRTCFiles().catch((function(t){Y.error(t)}))];case 1:return m.sent(),e=window.LIBRTC,n=e.NativeMediaEndpoint,o=e.NativeMediaEngine,a=t.mediaContent,s=t.user,d=t.meetingID,h=t.ctrlID,l=t.meetingNum,p=t.account,[4,(v=new o).init()];case 2:return m.sent(),(f=new n).onrefresh=function(){return i(S,void 0,void 0,(function(){var t,e,n;return r(this,(function(i){switch(i.label){case 0:return z().emitter.emit(u.CHANNEL_REFRESH),[4,z().api.getMss({accessMCs:a.accessMCs,topMC:a.topMC,confId:d,ccid:s.userID,userType:"audience"===s.role?"Broadcast":"Interactive"}).catch((function(t){Y.error(t)}))];case 1:return t=i.sent(),Y.debug("response ".concat(JSON.stringify(t))),t&&t.data&&t.data.MssInfo?(e=t.data.MssInfo.map((function(t){return t.ExtranetlUri})).flat(),n=t.data.MssInfo.map((function(t){return t.IntranetUri})).flat(),[2,e.concat(n).filter((function(t){return t.startsWith("ws")||t.startsWith("wss")})).map((function(t){var e=z().baseURL,n=/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)?function(t){if(!t)return"";var e=/^([a-z][a-z\d+\-.]*:)?\/\/(\S+)/.exec(t);return!e||e.length<3?"":e[2]}(e):e,i="wss://".concat(n),r=window.btoa(t.replace(/\w+:\/\//,""));return"".concat(i,"/webapp/socket/").concat(r)}))]):(Y.error("getMss response error ",t),[2,[]])}}))}))},[4,f.init()];case 3:return m.sent(),[4,f.start({meeting_number:l||"",user_account:p||"",confid:d,ccid:s.userID,role:1,encrypt:a.crypto,token:h})];case 4:return m.sent(),z().setMediaEndpoint(f),z().setMediaEngine(v),z().status=c.START,z().emitter.emit(u.STREAM_STATUS,{status:z().status}),[2]}}))}))},t.prototype.stop=function(){z().throwIfNotStatus(c.START),z().cleanup(),B().dataStreamStatus.status!==h.NULL&&B().closeDataStream(),z().status=c.STOP,z().emitter.emit(u.STREAM_STATUS,{status:z().status})},t.prototype.destroy=function(){z().status===c.START&&this.stop(),this.cleanup(),z().status!==c.NULL&&(B().destroy(),z().status=c.NULL,z().emitter.emit(u.STREAM_STATUS,{status:z().status}))},t.prototype.getStatus=function(){return z().status},t.prototype.getBaseUrl=function(){return z().baseURL},t.prototype.getChannelStatus=function(){return{audioChannelOpened:z().audioChannelOpened,videoChannelOpened:z().videoChannelOpened,dataChannelOpened:z().dataChannelOpened,messageChannelOpened:z().messageChannelOpened}},t.prototype.setBaseUrl=function(t){z().throwIfStatus(c.START),t&&z().baseURL!==t&&z().setBaseUrl(t)},t.prototype.setVideoSDKLibDir=function(t){z().throwIfStatus(c.START),t&&z().videoSDKLibDir!==t&&z().setVideoSDKLibDir(t)},t.prototype.createAudioChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return z().throwIfNotStatus(c.START),t=z().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.audio.createChannel(n.createTransport(i.kAudio)),z().setAudioChannel(o),o.onopen=function(){Y.debug("audioChannel onopen()"),z().audioChannelOpened=!0,z().emitter.emit(u.AUDIO_CHANNEL_OPENED)},[4,o.open()];case 1:return r.sent(),[2]}}))}))},t.prototype.closeAudioChannel=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return(t=z().audioChannel)?[4,t.close()]:(Y.error("audioChannel is miss"),[2]);case 1:return e.sent(),z().setAudioChannel(null),z().setAudioSender(null),z().setAudioReceiver(null),[2]}}))}))},t.prototype.createVideoChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return z().throwIfNotStatus(c.START),t=z().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createChannel(n.createTransport(i.kVideo)),z().setVideoChannel(o),o.onopen=function(){Y.debug("videoChannel onopen()"),z().videoChannelOpened=!0,z().emitter.emit(u.VIDEO_CHANNEL_OPENED)},[4,o.open()];case 1:return r.sent(),[2]}}))}))},t.prototype.createDataChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return z().throwIfNotStatus(c.START),t=z().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createChannel(n.createTransport(i.kData)),z().setDataChannel(o),o.onopen=function(){Y.debug("dataChannel onopen()")},[4,o.open()];case 1:return r.sent(),z().dataChannelOpened=!0,z().emitter.emit(u.DATA_CHANNEL_OPENED),[2]}}))}))},t.prototype.createMessageChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:z().throwIfNotStatus(c.START),t=z().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createDataChannel(n.createTransport(i.kMessage)),z().setMessageChannel(o),o.onopen=function(){Y.debug("messageChannel onopen()")},r.label=1;case 1:return r.trys.push([1,3,,4]),[4,o.open()];case 2:return r.sent(),[3,4];case 3:return a=r.sent(),console.error(a),[3,4];case 4:return z().messageChannelOpened=!0,z().emitter.emit(u.MESSAGE_CHANNEL_OPENED),[2]}}))}))},t.prototype.closeMessageChannel=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return(t=z().messageChannel)?[4,t.close()]:(Y.error("messageChannel is miss"),[2]);case 1:return e.sent(),[2]}}))}))},t.prototype.closeMessageStream=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return(e=z().messageChannel)?t?[4,e.closeStream(t)]:[3,2]:(Y.error("messageChannel is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.setupRemoteControl=function(t){var e=t.element,n=t.remote;return i(this,void 0,void 0,(function(){var t,i;return r(this,(function(r){switch(r.label){case 0:return z().throwIfNotStatus(c.START),z().throwIfMessageNotOpened(),e.setAttribute("tabIndex","-1"),e.style.outline="0",t=window.LIBRTC,[4,z().messageChannel.createStream(t.DataType.kRemoteControl)];case 1:return i=r.sent(),z().setRemoteControlStream(i),[2,t.setupRemoteControl(i,e,n)]}}))}))},t.prototype.getRemoteControlStream=function(){return z().remoteControlStream},t.prototype.createAudioSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return z().throwIfNotStatus(c.START),z().throwIfAudioNotOpened(),(t=z().audioChannel)?(e=z().audioSender?z().audioSender:t.createSender(),z().setAudioSender(e),[2,e]):(Y.error("audioChannel is miss"),[2,null])}))}))},t.prototype.removeAudioSender=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){if(z().throwIfNotStatus(c.START),z().throwIfAudioNotOpened(),!(t=z().audioSender))return Y.error("audioSender is miss"),[2];try{t.stop(),z().audioChannel&&z().audioChannel.removeSender(t.ssrc)}catch(t){Y.error("audioChannel removeSender() error: ",t)}return[2]}))}))},t.prototype.createVideoSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return z().throwIfNotStatus(c.START),z().throwIfVideoNotOpened(),(t=z().videoChannel)?(e=z().videoSender?z().videoSender:t.createSender(),z().setVideoSender(e),e.onbusy=function(){Y.debug("onbusy"),z().emitter.emit(u.CHANNEL_BUSY);var t=z().audioChannel;t&&t.ans(!1)},[2,e]):(Y.error("videoChannel is miss"),[2,null])}))}))},t.prototype.removeVideoSender=function(){z().throwIfNotStatus(c.START),z().throwIfVideoNotOpened();var t=z().videoSender;if(t)try{t.stop(),z().videoChannel&&z().videoChannel.removeSender(t.ssrc)}catch(t){Y.error("videoChannel removeSender() error: ",t)}else Y.error("videoSender is miss")},t.prototype.createDataSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return z().throwIfNotStatus(c.START),z().throwIfDataNotOpened(),(t=z().dataChannel)?(e=z().dataSender?z().dataSender:t.createSender(),z().setDataSender(e),[2,e]):(Y.error("dataChannel is miss"),[2,null])}))}))},t.prototype.removeDataSender=function(){z().throwIfNotStatus(c.START),z().throwIfDataNotOpened();var t=z().dataSender;t?(t.stop(),z().dataChannel&&z().dataChannel.removeSender(t.ssrc),z().setDataSender(null)):Y.error("dataSender is miss")},t.prototype.createAudioReceiver=function(t){z().throwIfNotStatus(c.START),z().throwIfAudioNotOpened();var e=z().audioChannel;if(!e)return Y.error("audioChannel is miss"),null;var n=e.createReceiver();return z().setAudioReceiver(n),t?(n.setSink(t),z().setAudioPlayer(t),e.audioElement&&(e.audioElement.srcObject=null),n):(Y.error("audioPlayer is miss"),null)},t.prototype.createVideoReceiver=function(t){z().throwIfNotStatus(c.START),z().throwIfVideoNotOpened();var e=t.ccid;if(Y.debug("createVideoReceiver ccid: ",e),!e)return Y.error("params is missing or params error"),null;var n=z().videoChannel;return n?n.createReceiver(e):(Y.error("videoChannel is miss"),null)},t.prototype.createDataReceiver=function(t){z().throwIfNotStatus(c.START),z().throwIfDataNotOpened();var e=t.ccid;if(Y.debug("createDataReceiver ccid: ",e),!e)return Y.error("params is missing or params error"),null;var n=z().dataChannel;return n?n.createReceiver(e):(Y.error("dataChannel is miss"),null)},t.prototype.removeVideoReceiver=function(t){return z().throwIfNotStatus(c.START),z().throwIfVideoNotOpened(),t?(t.stop(),z().videoChannel&&z().videoChannel.removeReceiver(t.ssrc),null):t},t.prototype.removeDataReceiver=function(t){return z().throwIfNotStatus(c.START),z().throwIfDataNotOpened(),t?(t.stop(),z().dataChannel&&z().dataChannel.removeReceiver(t.ssrc),null):t},t.prototype.loadVideoRenderer=function(t,e){return void 0===e&&(e=!0),i(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return z().throwIfNotStatus(c.START),z().throwIfVideoNotOpened(),(n=z().videoChannel)&&t?T||g?[4,n.offscreen.load(t.transferControlToOffscreen(),e)]:[3,2]:(Y.error("videoChannel or el is miss"),[2,null]);case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return[2,i]}}))}))},t.prototype.unloadVideoRenderer=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return z().throwIfNotStatus(c.START),z().throwIfVideoNotOpened(),(e=z().videoChannel)&&t?T||g?[4,e.offscreen.unload(t)]:[3,2]:(Y.error("videoChannel or renderer is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.loadDataRenderer=function(t,e){return void 0===e&&(e=!0),i(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return z().throwIfNotStatus(c.START),z().throwIfDataNotOpened(),(n=z().dataChannel)&&t?T||g?[4,n.offscreen.load(t.transferControlToOffscreen(),e)]:[3,2]:(Y.error("dataChannel or el is miss"),[2,null]);case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return[2,i]}}))}))},t.prototype.unloadDataRenderer=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return z().throwIfNotStatus(c.START),z().throwIfDataNotOpened(),(e=z().dataChannel)&&t?T||g?[4,e.offscreen.unload(t)]:[3,2]:(Y.error("dataChannel or renderer is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.bindAudioChannelEvent=function(){z().throwIfNotStatus(c.START),z().throwIfAudioNotOpened();var t=z().audioChannel;t?t.onfocusing=function(t){if(z().voiceActiveSsrc.length&&t.length){if(z().voiceActiveSsrc[0]===t[0])return}else if(0===z().voiceActiveSsrc.length&&0===t.length)return;z().setVoiceActiveSsrc(t),z().emitter.emit(u.VOICE_ACTIVE_SSRC,{ssrc:t})}:Y.error("audioChannel is miss")},t.prototype.offAudioChannelEvent=function(){z().throwIfNotStatus(c.START),z().throwIfAudioNotOpened();var t=z().audioChannel;t?t.onfocusing=null:Y.error("audioChannel is miss")},t.prototype.setAudioPlayerVolume=function(t){z().throwIfNotStatus(c.START),z().throwIfAudioNotOpened();var e=z().audioPlayer;e?(t=t>=0&&t<1?t:t>=1&&t<=100?t/100:t,e.volume=t):Y.error("audioPlayer is miss")},t.prototype.getAudioSender=function(){return z().status===c.START&&z().audioChannelOpened&&z().audioSender||null},t.prototype.getVideoSender=function(){return z().status===c.START&&z().videoChannelOpened&&z().videoSender||null},t.prototype.getDataSender=function(){return z().status===c.START&&z().dataChannelOpened&&z().dataSender||null},t.prototype.getVoiceActiveSsrc=function(){return z().status===c.START&&z().audioChannelOpened&&z().voiceActiveSsrc||[]},t.prototype.getAudioChannelStats=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return z().status===c.START&&z().audioChannelOpened&&z().audioChannel?[4,z().audioChannel.getStats()]:[2,{}];case 1:return[2,t.sent()]}}))}))},t.prototype.createAudioStream=function(){return z().throwIfStatus(c.NULL),B().captureAudioStream()},t.prototype.closeAudioStream=function(){return z().throwIfStatus(c.NULL),B().closeAudioStream()},t.prototype.createVideoStream=function(){return z().throwIfStatus(c.NULL),B().captureVideoStream()},t.prototype.closeVideoStream=function(){return z().throwIfStatus(c.NULL),B().closeVideoStream()},t.prototype.createDataStream=function(){return z().throwIfNotStatus(c.START),B().captureDataStream()},t.prototype.closeDataStream=function(){return B().closeDataStream()},t.prototype.getAudioStream=function(){return B()?B().audioStream:null},t.prototype.getVideoStream=function(){return B()?B().videoStream:null},t.prototype.getDataStream=function(){return B()?B().dataStream:null},t.prototype.getAudioStreamStatus=function(){return B()?B().audioStreamStatus:null},t.prototype.getVideoStreamStatus=function(){return B()?B().videoStreamStatus:null},t.prototype.getDataStreamStatus=function(){return B()?B().dataStreamStatus:null},t.prototype.getActiveAudioInputDevice=function(){return B()?B().audioInputDevice:null},t.prototype.getActiveAudioOutputDevice=function(){return B()?B().audioOutputDevice:null},t.prototype.getActiveVideoInputDevice=function(){return B()?B().videoInputDevice:null},t.prototype.getMicVolume=function(){return B()&&z().status!==c.NULL?B().volumeAnalyser.volume:0},t.prototype.switchAudioInputDevice=function(t){z().throwIfStatus(c.NULL),t&&(B().audioInputDeviceId=t)},t.prototype.switchAudioOutputDevice=function(t){z().throwIfStatus(c.NULL),t&&(B().audioOutputDeviceId=t)},t.prototype.switchVideoInputDevice=function(t){z().throwIfStatus(c.NULL),t&&(B().videoInputDeviceId=t)},t.prototype.getAudioInputDevices=function(){return B()?B().audioInputDevices:[]},t.prototype.getAudioOutputDevices=function(){return B()?B().audioOutputDevices:[]},t.prototype.getVideoInputDevices=function(){return B()?B().videoInputDevices:[]},t.EVENT=u,t.STATUS=c,t.MEDIA_STATUS=d,t.MEDIA_STREAM_STATUS=h,t.MEDIA_STREAM_DETAIL=l,t}();export{K as default};

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Stream=e()}(this,(function(){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},n.apply(this,arguments)};function i(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{u(i.next(t))}catch(t){o(t)}}function s(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((i=i.apply(t,e||[])).next())}))}function r(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var o,a=function(){function t(){this.events=new Map}return t.prototype.emit=function(t,e){var n=this.events.get(t);n&&n.slice().map((function(t){"function"==typeof t&&t(e)}))},t.prototype.off=function(t,e){var n=this.events.get(t);n&&(e?n.splice(n.indexOf(e)>>>0,1):this.events.set(t,[]))},t.prototype.on=function(t,e){var n=this.events.get(t);n?n.push(e):this.events.set(t,[e])},t}(),s=function(t){function n(e){var n=t.call(this)||this;return n.stream=null,n._enable=!1,n.interval=100,n.timer=null,n.stream=e,n}return e(n,t),n.prototype.analyse=function(){},n.prototype.start=function(){var t=this;this.stream&&(this.timer&&(clearInterval(this.timer),this.timer=null),this.analyse(),this.timer=setInterval((function(){return t.analyse()}),this.interval))},n.prototype.stop=function(){this.timer&&(clearInterval(this.timer),this.timer=null)},n.prototype.destroy=function(){this.stop()},n}(a);!function(t){t.AUDIO_STATUS_CHANGED="audioStatusChanged",t.VIDEO_STATUS_CHANGED="videoStatusChanged"}(o||(o={}));var u,c,d,h,l,p=function(t){function n(e){var n=t.call(this,e)||this;return n._status={active:!1,hasStream:!1,track:!1},n.interval=3e3,n}return e(n,t),Object.defineProperty(n.prototype,"status",{get:function(){return this._status},set:function(t){var e=this._status;e.active===t.active&&e.hasStream===t.hasStream&&e.track===t.track||(this._status=t,this.emit(o.AUDIO_STATUS_CHANGED,{status:this._status}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.stream){var t=this.stream.getAudioTracks();this.status.active=void 0===this.stream.active?Boolean(t[0]):this.stream.active,void 0!==this.stream.active&&void 0!==this.stream.id?this.status.hasStream=!0:this.status.hasStream=!1,(this.status.active||this.status.hasStream)&&(this.status.track=this.checkAvariable(t))}else this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.streamInactive=function(){this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.checkAvariable=function(t){return void 0===t&&(t=[]),t.some((function(t){return!("readyState"in t&&"live"!==t.readyState||"muted"in t&&!0===t.muted)}))},n.prototype.destroy=function(){this.stream&&this.stream.removeEventListener("inactive",this.streamInactive),t.prototype.destroy.call(this)},n}(s),v=function(t){function n(e){var n=t.call(this,e)||this;return n._status={active:!1,hasStream:!1,track:!1},n.interval=3e3,n}return e(n,t),Object.defineProperty(n.prototype,"status",{get:function(){return this._status},set:function(t){var e=this._status;e.active===t.active&&e.hasStream===t.hasStream&&e.track===t.track||(this._status=t,this.emit(o.VIDEO_STATUS_CHANGED,{status:this._status}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.stream){var t=this.stream.getVideoTracks();this.status.active=void 0===this.stream.active?Boolean(t[0]):this.stream.active,void 0!==this.stream.active&&void 0!==this.stream.id?this.status.hasStream=!0:this.status.hasStream=!1,(this.status.active||this.status.hasStream)&&(this.status.track=this.checkAvariable(t))}else this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.streamInactive=function(){this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.checkAvariable=function(t){return void 0===t&&(t=[]),t.some((function(t){return!("readyState"in t&&"live"!==t.readyState||"muted"in t&&!0===t.muted)}))},n.prototype.destroy=function(){this.stream&&this.stream.removeEventListener("inactive",this.streamInactive),t.prototype.destroy.call(this)},n}(s),f=function(t){function n(e){var n=t.call(this,e)||this;return n.volume=0,n.context=null,n.contextAnalyser=null,n.streamSource=null,n}return e(n,t),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.context&&this.contextAnalyser&&this.streamSource){var t=this.contextAnalyser.frequencyBinCount,e=new Uint8Array(t);this.contextAnalyser.getByteFrequencyData(e);var n=e.reduce((function(t,e){return t+e}),0);this.volume=n/t}else this.volume=0},n.prototype.start=function(){this.createContextAnalyser(),this.createStreamSource(),this.streamSource&&t.prototype.start.call(this)},n.prototype.stop=function(){this.streamSource&&(this.streamSource.disconnect(),this.streamSource=null),this.volume=0,t.prototype.stop.call(this)},n.prototype.createContextAnalyser=function(){if((!this.context||!this.contextAnalyser)&&(window.AudioContext||window.webkitAudioContext)){var t=window.AudioContext||window.webkitAudioContext;this.context=new t,this.contextAnalyser=this.context.createAnalyser(),this.contextAnalyser.fftSize=1024,this.contextAnalyser.smoothingTimeConstant=.5}},n.prototype.createStreamSource=function(){if(this.streamSource&&(this.streamSource.disconnect(),this.streamSource=null),this.context&&this.stream&&this.stream.getAudioTracks().length>0){if(this.streamSource=this.context.createMediaStreamSource(this.stream),!this.contextAnalyser)return;this.streamSource.connect(this.contextAnalyser),"suspended"===this.context.state&&this.context.resume()}},n.prototype.destroy=function(){this.contextAnalyser&&(this.contextAnalyser.disconnect(),this.contextAnalyser=null),this.context&&(this.context=null),t.prototype.destroy.call(this)},n}(s);!function(t){t.STREAM_STATUS="streamStatus",t.CHANNEL_REFRESH="channelRefresh",t.CHANNEL_BUSY="channelBusy",t.AUDIO_CHANNEL_OPENED="audioChannelOpened",t.VIDEO_CHANNEL_OPENED="videoChannelOpened",t.DATA_CHANNEL_OPENED="dataChannelOpened",t.MESSAGE_CHANNEL_OPENED="messageChannelOpened",t.AUDIO_STREAM="audioStream",t.VIDEO_STREAM="videoStream",t.DATA_STREAM="dataStream",t.AUDIO_INPUT_DEVICES_UPDATED="audioInputDevicesUpdated",t.AUDIO_OUTPUT_DEVICES_UPDATED="audioOutputDevicesUpdated",t.VIDEO_INPUT_DEVICES_UPDATED="videoInputDevicesUpdated",t.AUDIO_INPUT_DEVICE_CHANGED="audioInputDeviceChanged",t.AUDIO_OUTPUT_DEVICE_CHANGED="audioOutputDeviceChanged",t.VIDEO_INPUT_DEVICE_CHANGED="videoInputDeviceChanged",t.AUDIO_STREAM_STATUS="audioStreamStatus",t.VIDEO_STREAM_STATUS="videoStreamStatus",t.DATA_STREAM_STATUS="dataStreamStatus",t.VOICE_ACTIVE_SSRC="voiceActiveSsrc"}(u||(u={})),function(t){t.NULL="null",t.INIT="initialized",t.START="started",t.STOP="stopped"}(c||(c={})),function(t){t.Null="null",t.INIT="initialized"}(d||(d={})),function(t){t.NULL="null",t.CAPTURING="capturing",t.FAILED="failed"}(h||(h={})),function(t){t.NO_DEVICE="No Device",t.PERMISSION_DENIED="Permission denied",t.COULD_NOT_START_VIDEO_SOURCE="Could not start video source",t.PERMISSION_DENIED_BY_SYSTEM="Permission denied by system",t.OTHER_EXCEPTIONS="Other exceptions"}(l||(l={}));var S,m=function(t,e){var n=e.match(t);return n&&n.length>0&&n[1]||""},I=/version\/(\d+(\.?_?\d+)+)/i,D=[{test:[/\sedg\//i],describe:function(t){var e={name:"Microsoft Edge"},n=m(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/edg([ea]|ios)/i],describe:function(t){var e={name:"Microsoft Edge"},n=function(t,e){var n=e.match(t);return n&&n.length>1&&n[2]||""}(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/firefox|iceweasel|fxios/i],describe:function(t){var e={name:"Firefox"},n=m(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/chromium/i],describe:function(t){var e={name:"Chromium"},n=m(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||m(I,t);return n&&(e.version=n),e}},{test:[/chrome|crios|crmo/i],describe:function(t){var e={name:"Chrome"},n=m(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/safari|applewebkit/i],describe:function(t){var e={name:"Safari"},n=m(I,t);return n&&(e.version=n),e}}],y=D.find((function(t){if(t.test instanceof Array)return t.test.some((function(t){return t.test(navigator.userAgent)}));throw new Error("Browser's test function is not valid")}));y&&(S=y.describe(navigator.userAgent));var A=S&&"Safari"===S.name,E=S&&"Firefox"===S.name,T=S&&"Chrome"===S.name,g=S&&"Microsoft Edge"===S.name,_=function(){function t(t){var e=t.namespace,n=t.debug;this.initialized=!0,this.isDebugging=n,this.backend=C(),this.namespace=e,this.useColors=this.backend.useColors,this.color=this.selectColor(e)}return t.prototype.logger=function(t){var e=this;t[0]=this.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");var n=0;return t[0]=t[0].replace(/%([a-zA-Z%])/g,(function(i,r){if("%%"===i)return i;n++;var o=e.backend.formatters[r];"function"==typeof o&&(i=o(t[n]),t.splice(n,1),n--);return i})),this.backend.formatArgs(t,this)},t.prototype.coerce=function(t){return t instanceof Error?t.stack||t.message:t},t.prototype.selectColor=function(t){var e=Array.from(t).reduce((function(t,e){return t=(t<<5)-t+e.charCodeAt(0),t|=0}),0);return this.backend.colors[Math.abs(e)%this.backend.colors.length]},t.prototype.switchDebug=function(t){this.isDebugging=t},t.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];t=this.logger(t),this.backend.log.apply(this,t)},t.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.isDebugging&&(t=this.logger(t),this.backend.debug.apply(this,t))},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.backend.warn.apply(this,t)},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.backend.error.apply(this,t)},t}(),b=_,C=function(){var t={colors:["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],formatters:{j:function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: ".concat(t.message)}}},log:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,t)},debug:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.debug&&Function.prototype.apply.call(console.debug,console,t)},warn:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.warn&&Function.prototype.apply.call(console.warn,console,t)},error:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.error&&Function.prototype.apply.call(console.error,console,t)},formatArgs:function(t,e){var n=e.useColors,i=e.namespace,r=e.color;if(t[0]="".concat((n?"%c":"")+i+(n?" %c":" ")+t[0]+(n?"%c ":" "),"+").concat(function(t){var e=Math.abs(t);if(e>=U)return"".concat(Math.round(t/U),"d");if(e>=N)return"".concat(Math.round(t/N),"h");if(e>=w)return"".concat(Math.round(t/w),"m");if(e>=O)return"".concat(Math.round(t/O),"s");return"".concat(t,"ms")}(0)),!n)return[];var o="color: ".concat(r);t.splice(1,0,o,"color: inherit");var a=0,s=0;return t[0].replace(/%[a-zA-Z%]/g,(function(t){"%%"!==t&&(a++,"%c"===t&&(s=a))})),t.splice(s,0,o),t},useColors:R()};return t},O=1e3,w=60*O,N=60*w,U=24*N;var R=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.webkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},P=function(t){return t.close=t.stop=function(){!function(t){if(t)try{t.getTracks?t.getTracks().forEach((function(t){return t.stop()})):(t.getAudioTracks().forEach((function(t){return t.stop()})),t.getVideoTracks().forEach((function(t){return t.stop()})))}catch(e){"function"!=typeof t.stop&&"object"!=typeof t.stop||t.stop()}}(this)},t.pause=function(){this.getTracks().forEach((function(t){return t.enabled=!1}))},t.play=function(){this.getTracks().forEach((function(t){return t.enabled=!0}))},t.muteAudio=function(t){void 0===t&&(t=!0),this.getAudioTracks().forEach((function(e){return e.enabled=!t}))},t.muteVideo=function(t){void 0===t&&(t=!0),this.getVideoTracks().forEach((function(e){return e.enabled=!t}))},t},L=function(t){return i(void 0,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return navigator.mediaDevices.getUserMedia?[4,navigator.mediaDevices.getUserMedia(t)]:[3,2];case 1:case 3:return e=n.sent(),[3,5];case 2:return navigator.getUserMedia?[4,new Promise((function(e,n){navigator.getUserMedia(t,e,n)}))]:[3,4];case 4:throw new Error("Not Supported");case 5:return[2,P(e)]}}))}))},V=function(t){return i(void 0,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return navigator.mediaDevices.getDisplayMedia?[4,navigator.mediaDevices.getDisplayMedia(t)]:[3,2];case 1:case 3:return e=n.sent(),[3,5];case 2:return navigator.getDisplayMedia?[4,new Promise((function(e,n){navigator.getDisplayMedia(t,e,n)}))]:[3,4];case 4:throw new Error("Not Supported");case 5:return[2,P(e)]}}))}))},M=new b({namespace:"STREAM:Media",debug:!1}),k=function(t){function a(e){var n=e.debug,i=t.call(this)||this;return i.status=d.Null,i.deviceList=[],i.audioQueue=Promise.resolve(null),i.videoQueue=Promise.resolve(null),i.dataQueue=Promise.resolve(null),i._audioStream=null,i._videoStream=null,i._displayStream=null,i._audioInputDevice=null,i._audioOutputDevice=null,i._videoInputDevice=null,i._audioInputDeviceId="",i._audioOutputDeviceId="",i._videoInputDeviceId="",i._audioInputDevices=[],i._audioOutputDevices=[],i._videoInputDevices=[],i._audioStreamStatus={status:h.NULL},i._videoStreamStatus={status:h.NULL},i._dataStreamStatus={status:h.NULL},i.onDataStreamInactive=i.dataStreamInactive.bind(i),M.switchDebug(n),i.volumeAnalyser=new f(i.audioStream),i.audioAnalyser=new p(i.audioStream),i.videoAnalyser=new v(i.videoStream),i.setup(),i}return e(a,t),a.createInstance=function(t){return this.instance||(this.instance=new a(t)),this.instance},Object.defineProperty(a.prototype,"audioInputDevices",{get:function(){return this._audioInputDevices||[]},set:function(t){this.checkDeviceList(t,this._audioInputDevices)||(this._audioInputDevices=t,this.status===d.INIT&&this.emit(u.AUDIO_INPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDevices",{get:function(){return this._audioOutputDevices||[]},set:function(t){this.checkDeviceList(t,this._audioOutputDevices)||(this._audioOutputDevices=t,this.status===d.INIT&&this.emit(u.AUDIO_OUTPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDevices",{get:function(){return this._videoInputDevices||[]},set:function(t){this.checkDeviceList(t,this._videoInputDevices)||(this._videoInputDevices=t,this.status===d.INIT&&this.emit(u.VIDEO_INPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioInputDeviceId",{get:function(){return this._audioInputDeviceId||""},set:function(t){if(!this._audioInputDeviceId||this._audioInputDeviceId!==t){var e=this.audioInputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.audioInputDevice=i,this._audioInputDeviceId=i?i.deviceId:"",this.audioStreamStatus.status!==h.NULL&&this.captureAudioStream()}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDeviceId",{get:function(){return this._audioOutputDeviceId||""},set:function(t){if(!this._audioOutputDeviceId||this._audioOutputDeviceId!==t){var e=this.audioOutputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.audioOutputDevice=i,this._audioOutputDeviceId=i?i.deviceId:""}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDeviceId",{get:function(){return this._videoInputDeviceId||""},set:function(t){if(!this._videoInputDeviceId||this._videoInputDeviceId!==t){var e=this.videoInputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.videoInputDevice=i,this._videoInputDeviceId=i?i.deviceId:"",this.videoStreamStatus.status!==h.NULL&&this.captureVideoStream()}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioInputDevice",{get:function(){return this._audioInputDevice},set:function(t){var e=this._audioInputDevice&&!this.isSameDevice(this._audioInputDevice,t),n=!this._audioInputDevice&&!!t;(n||e)&&(this._audioInputDevice=t,!n&&e&&this.emit(u.AUDIO_INPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDevice",{get:function(){return this._audioOutputDevice},set:function(t){var e=this._audioOutputDevice&&!this.isSameDevice(this._audioOutputDevice,t),n=!this._audioOutputDevice&&!!t;(n||e)&&(this._audioOutputDevice=t,!n&&e&&this.emit(u.AUDIO_OUTPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDevice",{get:function(){return this._videoInputDevice},set:function(t){var e=this._videoInputDevice&&!this.isSameDevice(this._videoInputDevice,t),n=!this._videoInputDevice&&!!t;(n||e)&&(this._videoInputDevice=t,!n&&e&&this.emit(u.VIDEO_INPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"supportNativeShare",{get:function(){return navigator.getDisplayMedia||navigator.mediaDevices.getDisplayMedia},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioStream",{get:function(){return this._audioStream},set:function(t){this._audioStream!==t&&(this._audioStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoStream",{get:function(){return this._videoStream},set:function(t){this._videoStream!==t&&(this._videoStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"dataStream",{get:function(){return this._displayStream},set:function(t){this._displayStream!==t&&(this._displayStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioStreamStatus",{get:function(){return this._audioStreamStatus},set:function(t){var e=this._audioStreamStatus;e.status===t.status&&e.detail===t.detail||(this._audioStreamStatus=t,this.emit(u.AUDIO_STREAM_STATUS,this._audioStreamStatus))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoStreamStatus",{get:function(){return this._videoStreamStatus},set:function(t){var e=this._videoStreamStatus;e.status===t.status&&e.detail===t.detail||(this._videoStreamStatus=t,this.emit(u.VIDEO_STREAM_STATUS,this._videoStreamStatus))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"dataStreamStatus",{get:function(){return this._dataStreamStatus},set:function(t){var e=this._dataStreamStatus;e.status===t.status&&e.detail===t.detail||(this._dataStreamStatus=t,this.emit(u.DATA_STREAM_STATUS,this._dataStreamStatus))},enumerable:!1,configurable:!0}),a.prototype.setup=function(){var t=this;this.audioAnalyser.on(o.AUDIO_STATUS_CHANGED,(function(e){var n=e.status;M.debug("".concat(o.AUDIO_STATUS_CHANGED," ").concat(JSON.stringify(n))),!n.hasStream||n.track&&n.active||(t.audioStreamStatus={status:h.FAILED,detail:l.OTHER_EXCEPTIONS})})),this.videoAnalyser.on(o.VIDEO_STATUS_CHANGED,(function(e){var n=e.status;M.debug("".concat(o.VIDEO_STATUS_CHANGED," ").concat(JSON.stringify(n))),!n.hasStream||n.track&&n.active||(t.videoStreamStatus={status:h.FAILED,detail:l.OTHER_EXCEPTIONS})}))},a.prototype.cleanup=function(){this.deviceList=[],this.audioInputDevices=[],this.audioInputDeviceId="",this.audioOutputDevices=[],this.audioOutputDeviceId="",this.videoInputDevices=[],this.videoInputDeviceId="",this.volumeAnalyser.destroy(),this.audioAnalyser.destroy(),this.videoAnalyser.destroy()},a.prototype.init=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return this.throwIfStatus(d.INIT),navigator.mediaDevices&&(e=this,navigator.mediaDevices.ondevicechange=function(){e.detectDevice()}),[4,this.detectDevice(t)];case 1:return n.sent(),this.status=d.INIT,[2]}}))}))},a.prototype.destroy=function(){try{this.closeAudioStream(),this.closeVideoStream(),this.closeDataStream(),this.cleanup()}catch(t){M.error(t)}this.status=d.Null},a.prototype.detectDevice=function(t){return i(this,void 0,void 0,(function(){var e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:return navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices?[4,this.enumerateDevices().catch((function(t){return M.error("enumerate devices error: ",t)}))]:(M.error("mediaDevices or enumerateDevices is miss"),[2]);case 1:return e=r.sent(),this.deviceList=e&&e.map((function(t){return t.toJSON()}))||[],M.debug("deviceList: ".concat(JSON.stringify(this.deviceList))),i=(n=this).audioInputDevice,o=n.audioOutputDevice,a=n.videoInputDevice,this.audioInputDevices=this.deviceList.filter((function(t){return"audioinput"===t.kind}))||[],this.audioInputDeviceId=this.checkDevice({deviceList:this.audioInputDevices,device:i,deviceId:t&&t.audioInputDeviceId||""}),this.audioOutputDevices=this.deviceList.filter((function(t){return"audiooutput"===t.kind}))||[],this.audioOutputDeviceId=this.checkDevice({deviceList:this.audioOutputDevices,device:o,deviceId:t&&t.audioOutputDeviceId||""}),this.videoInputDevices=this.deviceList.filter((function(t){return"videoinput"===t.kind}))||[],this.videoInputDeviceId=this.checkDevice({deviceList:this.videoInputDevices,device:a,deviceId:t&&t.videoInputDeviceId||""}),[2]}}))}))},a.prototype.enumerateDevices=function(){return new Promise((function(t,e){navigator.mediaDevices.enumerateDevices().then((function(e){t(e)})).catch((function(t){e(t)}))}))},a.prototype.genAudioConstraints=function(t){var e={audio:!1,video:!1},n=this.audioInputDevice,i=n||{deviceId:"",groupId:""},r=i.deviceId,o=i.groupId;return e.audio=!!n&&(t&&E?{deviceId:{exact:r},groupId:{exact:o}}:{deviceId:r,groupId:o}),e.audio&&!A&&Object.assign(e.audio,x),e},a.prototype.genVideoConstraints=function(){var t={audio:!1,video:!1},e=this.videoInputDevice,n=e||{deviceId:"",groupId:""},i=n.deviceId,r=n.groupId;return t.video=!!e&&(E?{deviceId:{exact:i},groupId:{exact:r}}:{deviceId:i,groupId:r}),t.video&&Object.assign(t.video,j),t},a.prototype.genDisplayConstraints=function(t){var e,i=t.quality;return this.supportNativeShare?e={video:n({},i)}:e},a.prototype.createAudioStream=function(t){return i(this,void 0,void 0,(function(){var e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:if(e=this.genAudioConstraints(t),M.debug("audio constraints: ".concat(JSON.stringify(e))),n=this.audioStreamStatus,!e.audio)return[2,{stream:null,audioStreamStatus:n={status:h.FAILED,detail:l.NO_DEVICE}}];i=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,L(e)];case 2:return i=r.sent(),[3,4];case 3:return a=r.sent(),M.debug("getUserMedia error: ".concat(a)),o=a,[3,4];case 4:return i?n={status:h.CAPTURING}:(o=o||new Error("Stream is null"),n={status:h.FAILED,detail:G.get(o.message)||l.OTHER_EXCEPTIONS}),[2,{stream:i,audioStreamStatus:n}]}}))}))},a.prototype.createVideoStream=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:if(t=this.genVideoConstraints(),M.debug("video constraints: ".concat(JSON.stringify(t))),e=this.videoStreamStatus,!t.video)return[2,{stream:null,videoStreamStatus:e={status:h.FAILED,detail:l.NO_DEVICE}}];n=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,L(t)];case 2:return n=r.sent(),[3,4];case 3:return o=r.sent(),M.debug("getUserMedia error: ".concat(o)),i=o,[3,4];case 4:return n?e={status:h.CAPTURING}:(i=i||new Error("Stream is null"),e={status:h.FAILED,detail:F.get(i.message)||l.OTHER_EXCEPTIONS}),[2,{stream:n,videoStreamStatus:e}]}}))}))},a.prototype.createDataStream=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:t=this.genDisplayConstraints({quality:H}),M.debug("data constraints: ".concat(JSON.stringify(t))),e=null,i=this.dataStreamStatus,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,V(t)];case 2:return e=r.sent(),[3,4];case 3:return o=r.sent(),M.debug("getDisplayMedia error: ".concat(o)),n=o,[3,4];case 4:return e?i={status:h.CAPTURING}:(n=n||new Error("Stream is null"),i={status:h.FAILED,detail:B.get(n.message)||l.OTHER_EXCEPTIONS}),[2,{stream:e,dataStreamStatus:i}]}}))}))},a.prototype.closeAudioStream=function(){this.audioStream&&this.audioStream.close(),this.audioStream=null,this.switchAudioAnalyserEnable({enable:!1}),this.setAudioAnalyserStream(this.audioStream),this.audioStreamStatus={status:h.NULL},this.emit(u.AUDIO_STREAM,{stream:this.audioStream})},a.prototype.closeVideoStream=function(){this.videoStream&&this.videoStream.close(),this.videoStream=null,this.switchVideoAnalyserEnable({enable:!1}),this.setVideoAnalyserStream(this.videoStream),this.videoStreamStatus={status:h.NULL},this.emit(u.VIDEO_STREAM,{stream:this.videoStream})},a.prototype.closeDataStream=function(){var t=this;this.dataStream&&(this.dataStream.removeEventListener("inactive",this.onDataStreamInactive),(this.dataStream.getVideoTracks()||[]).forEach((function(e){e.removeEventListener("ended",t.onDataStreamInactive)})),this.dataStream.close());this.dataStream=null,this.dataStreamStatus={status:h.NULL},this.emit(u.DATA_STREAM,{stream:this.dataStream})},a.prototype.captureAudioStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.audioQueue=this.audioQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return this.switchAudioAnalyserEnable({enable:!1}),t=!(this.audioStreamStatus.status!==h.CAPTURING||!this.audioStream),[4,this.createAudioStream(t)];case 1:return e=r.sent(),n=e.stream,i=e.audioStreamStatus,this.audioStreamStatus.status===h.CAPTURING&&this.audioStream&&(this.audioStream.close(),this.audioStream=null),this.status!==d.INIT?(n&&n.close(),this.emit(u.AUDIO_STREAM,{stream:this.audioStream}),[2,Promise.resolve(this.audioStream)]):(this.audioStream=n,this.audioStreamStatus=i,this.emit(u.AUDIO_STREAM,{stream:this.audioStream}),o=!0,n||i.status!==h.FAILED||(o=!1),this.setAudioAnalyserStream(n),this.switchAudioAnalyserEnable({enable:o}),[2,Promise.resolve(this.audioStream)])}}))}))}))},a.prototype.captureVideoStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.videoQueue=this.videoQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i;return r(this,(function(r){switch(r.label){case 0:return this.switchVideoAnalyserEnable({enable:!1}),[4,this.createVideoStream()];case 1:return t=r.sent(),e=t.stream,n=t.videoStreamStatus,this.videoStreamStatus.status===h.CAPTURING&&this.videoStream&&(this.videoStream.close(),this.videoStream=null),this.status!==d.INIT?(e&&e.close(),this.emit(u.VIDEO_STREAM,{stream:this.videoStream}),[2,Promise.resolve(this.videoStream)]):(this.videoStream=e,this.videoStreamStatus=n,this.emit(u.VIDEO_STREAM,{stream:this.videoStream}),i=!0,e||n.status!==h.FAILED||(i=!1),this.setVideoAnalyserStream(e),this.switchVideoAnalyserEnable({enable:i}),[2,Promise.resolve(this.videoStream)])}}))}))}))},a.prototype.captureDataStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.dataQueue=this.dataQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i=this;return r(this,(function(r){switch(r.label){case 0:return[4,this.createDataStream()];case 1:return t=r.sent(),e=t.stream,n=t.dataStreamStatus,this.dataStreamStatus.status!==h.NULL||e?(this.dataStreamStatus.status===h.CAPTURING&&this.dataStream&&!e||(this.dataStreamStatus.status===h.CAPTURING&&this.dataStream&&(this.dataStream.removeEventListener("inactive",this.onDataStreamInactive),(this.dataStream.getVideoTracks()||[]).forEach((function(t){t.removeEventListener("ended",i.onDataStreamInactive)})),this.dataStream.close(),this.dataStream=null),e&&e.addEventListener("inactive",this.onDataStreamInactive),E&&e&&(e.getVideoTracks()||[]).forEach((function(t){t.addEventListener("ended",i.onDataStreamInactive)})),this.dataStream=e,this.dataStreamStatus=n,this.emit(u.DATA_STREAM,{stream:this.dataStream})),[2,Promise.resolve(this.dataStream)]):[2,Promise.resolve(this.dataStream)]}}))}))}))},a.prototype.setAudioAnalyserStream=function(t){this.volumeAnalyser.stream=t,this.audioAnalyser.stream=t},a.prototype.setVideoAnalyserStream=function(t){this.videoAnalyser.stream=t},a.prototype.switchAudioAnalyserEnable=function(t){var e=t.enable,n=void 0!==e&&e;this.volumeAnalyser.enable=n,this.audioAnalyser.enable=n},a.prototype.switchVideoAnalyserEnable=function(t){var e=t.enable,n=void 0!==e&&e;this.videoAnalyser.enable=n},a.prototype.dataStreamInactive=function(){this.dataStream&&(this.dataStream.close(),this.dataStream=null,this.dataStreamStatus={status:h.NULL},this.emit(u.DATA_STREAM,{stream:this.dataStream}))},a.prototype.checkDevice=function(t){var e=this,n=t.deviceList,i=t.device,r=t.deviceId;return(i=(i=r?n.find((function(t){return t.deviceId===r}))||null:i&&n.find((function(t){return e.isSameDevice(t,i)}))||null)||(n[0]||null))&&i.deviceId?i.deviceId:""},a.prototype.checkDeviceList=function(t,e){if(!t||!e||t.length!==e.length)return!1;for(var n=!0,i=0;i<t.length;i++){var r=t[i],o=e[i];if(!this.isSameDevice(r,o)){n=!1;break}}return n},a.prototype.isSameDevice=function(t,e,n){if(void 0===n&&(n=!1),!t||!e)return!1;var i=t.deviceId===e.deviceId&&t.label===e.label&&t.kind===e.kind;return n?t.groupId===e.groupId&&i:i},a.prototype.throwIfStatus=function(t,e){if(this.status===t)throw new Error(e||"Invalid State")},a.prototype.throwIfNotStatus=function(t,e){if(this.status!==t)throw new Error(e||"Invalid State")},a}(a),x={autoGainControl:!0,echoCancellation:!0,latency:0,noiseSuppression:!0},j={aspectRatio:16/9,frameRate:30,width:640,height:360},H={width:1920,height:1080,frameRate:5},G=new Map([["No Device",l.NO_DEVICE],["Permission denied",l.PERMISSION_DENIED],["Permission dismissed",l.PERMISSION_DENIED],["Could not start video source",l.OTHER_EXCEPTIONS],["The request is not allowed by the user agent or the platform in the current context.",l.PERMISSION_DENIED],["Failed to allocate videosource",l.OTHER_EXCEPTIONS],["Stream is null",l.OTHER_EXCEPTIONS]]),F=new Map([["No Device",l.NO_DEVICE],["Permission denied",l.PERMISSION_DENIED],["Permission dismissed",l.PERMISSION_DENIED],["Could not start video source",l.COULD_NOT_START_VIDEO_SOURCE],["The request is not allowed by the user agent or the platform in the current context.",l.PERMISSION_DENIED],["Failed to allocate videosource",l.COULD_NOT_START_VIDEO_SOURCE],["Stream is null",l.OTHER_EXCEPTIONS]]),B=new Map([["Permission denied by system",l.PERMISSION_DENIED_BY_SYSTEM],["The object can not be found here.",l.PERMISSION_DENIED_BY_SYSTEM],["The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.",l.PERMISSION_DENIED_BY_SYSTEM]]),X=function(){return k.instance},J=new b({namespace:"STREAM:Store",debug:!1}),z=function(){function t(t){var e=this,n=t.debug;this.status=c.NULL,this.remoteControlStream=null,this.videoSender=null,this.audioSender=null,this.dataSender=null,this.audioReceiver=null,this.voiceActiveSsrc=[],this.audioPlayer=null,this.audioChannelOpened=!1,this.videoChannelOpened=!1,this.dataChannelOpened=!1,this.messageChannelOpened=!1,this.api={getMss:function(t){var n=e.baseURL;return"function"!=typeof fetch?Promise.reject():fetch(function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(n,"/webapp/front/getMss"),{headers:{"content-type":"application/json"},method:"POST",body:JSON.stringify(t)}).then((function(t){return i(e,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,t.json()];case 1:return[2,e.sent()]}}))}))}))}},this.baseURL="https://meetings.ylyun.com",this.videoSDKLibDir="",J.switchDebug(n),this.emitter=new a}return t.createInstance=function(e){return this.instance||(this.instance=new t(e)),this.instance},t.prototype.setApi=function(t){this.api=t},t.prototype.setBaseUrl=function(t){this.baseURL=t},t.prototype.setVideoSDKLibDir=function(t){this.videoSDKLibDir=t},t.prototype.setMediaEndpoint=function(t){this.mediaEndpoint=t},t.prototype.setMediaEngine=function(t){this.mediaEngine=t},t.prototype.setAudioChannel=function(t){this.audioChannel=t},t.prototype.setVideoChannel=function(t){this.videoChannel=t},t.prototype.setDataChannel=function(t){this.dataChannel=t},t.prototype.setMessageChannel=function(t){this.messageChannel=t},t.prototype.setRemoteControlStream=function(t){this.remoteControlStream=t},t.prototype.setVideoSender=function(t){this.videoSender=t},t.prototype.setAudioSender=function(t){this.audioSender=t},t.prototype.setDataSender=function(t){this.dataSender=t},t.prototype.setAudioReceiver=function(t){this.audioReceiver=t},t.prototype.setAudioPlayer=function(t){this.audioPlayer=t},t.prototype.setVoiceActiveSsrc=function(t){this.voiceActiveSsrc=t},t.prototype.throwIfAudioNotOpened=function(t){if(!this.audioChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfVideoNotOpened=function(t){if(!this.videoChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfDataNotOpened=function(t){if(!this.dataChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfMessageNotOpened=function(t){if(!this.messageChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfStatus=function(t,e){if(this.status===t)throw new Error(e||"Invalid State")},t.prototype.throwIfNotStatus=function(t,e){if(this.status!==t)throw new Error(e||"Invalid State")},t.prototype.loadLibRTCFiles=function(){var t=this.videoSDKLibDir;return Promise.all([this.createScriptTag({src:"".concat(t,"/libsfu.prod.js")}),this.createScriptTag({src:"".concat(t,"/librtc.global.prod.js")})])},t.prototype.getLibRTCContext=function(){var t=window.LIBRTC.SFUTransportType,e=this.mediaEndpoint,n=this.mediaEngine;return e&&n?{mediaEndpoint:e,mediaEngine:n,SFUTransportType:t}:{SFUTransportType:t}},t.prototype.createScriptTag=function(t){var e=t.src;return new Promise((function(t,n){var i=document.createElement("script");i.type="text/javascript",i.src=e,i.onload=function(){t(i)},i.onerror=function(t){n(t)},document.head.appendChild(i)}))},t.prototype.cleanup=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o,a,s,u;return r(this,(function(r){switch(r.label){case 0:e=(t=this).videoChannel,n=t.audioChannel,i=t.messageChannel,o=t.dataChannel,a=t.mediaEndpoint,s=t.remoteControlStream,r.label=1;case 1:return r.trys.push([1,12,,13]),n?[4,n.close()]:[3,3];case 2:r.sent(),r.label=3;case 3:return e?[4,e.close()]:[3,5];case 4:r.sent(),r.label=5;case 5:return o?[4,o.close()]:[3,7];case 6:r.sent(),r.label=7;case 7:return s&&i?[4,i.closeStream(s)]:[3,9];case 8:r.sent(),r.label=9;case 9:return i?[4,i.close()]:[3,11];case 10:r.sent(),r.label=11;case 11:return a&&(a.stop(),a.destroy()),[3,13];case 12:return u=r.sent(),J.error(u),[3,13];case 13:return this.mediaEndpoint=null,this.mediaEngine=null,this.videoChannel=null,this.audioChannel=null,this.dataChannel=null,this.messageChannel=null,this.videoSender=null,this.audioSender=null,this.dataSender=null,this.audioReceiver=null,this.audioPlayer=null,this.audioChannelOpened=!1,this.videoChannelOpened=!1,this.dataChannelOpened=!1,this.messageChannelOpened=!1,[2]}}))}))},t}(),Y=function(){return z.instance},K=new b({namespace:"STREAM:Store",debug:!1});return function(){function t(t){var e,n=t.baseURL,i=t.videoSDKLibDir,r=t.debug;n=n||"https://meetings.ylyun.com",i=i||"",r=r||!1,K.switchDebug(r),e={debug:r},z.createInstance(e),function(t){k.createInstance(t)}({debug:r}),Y().setBaseUrl(n),Y().setVideoSDKLibDir(i),this.setup()}return t.prototype.setup=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){return X().on(u.AUDIO_STREAM,(function(t){Y().emitter.emit(u.AUDIO_STREAM,t)})),X().on(u.VIDEO_STREAM,(function(t){Y().emitter.emit(u.VIDEO_STREAM,t)})),X().on(u.DATA_STREAM,(function(t){Y().emitter.emit(u.DATA_STREAM,t)})),X().on(u.AUDIO_INPUT_DEVICES_UPDATED,(function(t){Y().emitter.emit(u.AUDIO_INPUT_DEVICES_UPDATED,t)})),X().on(u.AUDIO_OUTPUT_DEVICES_UPDATED,(function(t){Y().emitter.emit(u.AUDIO_OUTPUT_DEVICES_UPDATED,t)})),X().on(u.VIDEO_INPUT_DEVICES_UPDATED,(function(t){Y().emitter.emit(u.VIDEO_INPUT_DEVICES_UPDATED,t)})),X().on(u.AUDIO_INPUT_DEVICE_CHANGED,(function(t){Y().emitter.emit(u.AUDIO_INPUT_DEVICE_CHANGED,t)})),X().on(u.AUDIO_OUTPUT_DEVICE_CHANGED,(function(t){Y().emitter.emit(u.AUDIO_OUTPUT_DEVICE_CHANGED,t)})),X().on(u.VIDEO_INPUT_DEVICE_CHANGED,(function(t){Y().emitter.emit(u.VIDEO_INPUT_DEVICE_CHANGED,t)})),X().on(u.AUDIO_STREAM_STATUS,(function(t){Y().emitter.emit(u.AUDIO_STREAM_STATUS,t)})),X().on(u.VIDEO_STREAM_STATUS,(function(t){Y().emitter.emit(u.VIDEO_STREAM_STATUS,t)})),X().on(u.DATA_STREAM_STATUS,(function(t){Y().emitter.emit(u.DATA_STREAM_STATUS,t)})),[2]}))}))},t.prototype.cleanup=function(){},t.prototype.on=function(t,e){return Y().emitter.on(t,e)},t.prototype.off=function(t,e){return Y().emitter.off(t,e)},t.prototype.init=function(t){return i(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:if(window.ActiveXObject||"ActiveXObject"in window)throw new Error("Not compatible with this browser yet, please use other browsers instead.");return[4,X().init(t)];case 1:return e.sent(),Y().status=c.INIT,Y().emitter.emit(u.STREAM_STATUS,{status:Y().status}),[2]}}))}))},t.prototype.start=function(t){return i(this,void 0,void 0,(function(){var e,n,o,a,s,d,h,l,p,v,f,S=this;return r(this,(function(m){switch(m.label){case 0:return Y().throwIfStatus(c.NULL),Y().throwIfStatus(c.START),[4,Y().loadLibRTCFiles().catch((function(t){K.error(t)}))];case 1:return m.sent(),e=window.LIBRTC,n=e.NativeMediaEndpoint,o=e.NativeMediaEngine,a=t.mediaContent,s=t.user,d=t.meetingID,h=t.ctrlID,l=t.meetingNum,p=t.account,[4,(v=new o).init()];case 2:return m.sent(),(f=new n).onrefresh=function(){return i(S,void 0,void 0,(function(){var t,e,n;return r(this,(function(i){switch(i.label){case 0:return Y().emitter.emit(u.CHANNEL_REFRESH),[4,Y().api.getMss({accessMCs:a.accessMCs,topMC:a.topMC,confId:d,ccid:s.userID,userType:"audience"===s.role?"Broadcast":"Interactive"}).catch((function(t){K.error(t)}))];case 1:return t=i.sent(),K.debug("response ".concat(JSON.stringify(t))),t&&t.data&&t.data.MssInfo?(e=t.data.MssInfo.map((function(t){return t.ExtranetlUri})).flat(),n=t.data.MssInfo.map((function(t){return t.IntranetUri})).flat(),[2,e.concat(n).filter((function(t){return t.startsWith("ws")||t.startsWith("wss")})).map((function(t){var e=Y().baseURL,n=/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)?function(t){if(!t)return"";var e=/^([a-z][a-z\d+\-.]*:)?\/\/(\S+)/.exec(t);return!e||e.length<3?"":e[2]}(e):e,i="wss://".concat(n),r=window.btoa(t.replace(/\w+:\/\//,""));return"".concat(i,"/webapp/socket/").concat(r)}))]):(K.error("getMss response error ",t),[2,[]])}}))}))},[4,f.init()];case 3:return m.sent(),[4,f.start({meeting_number:l||"",user_account:p||"",confid:d,ccid:s.userID,role:1,encrypt:a.crypto,token:h})];case 4:return m.sent(),Y().setMediaEndpoint(f),Y().setMediaEngine(v),Y().status=c.START,Y().emitter.emit(u.STREAM_STATUS,{status:Y().status}),[2]}}))}))},t.prototype.stop=function(){Y().throwIfNotStatus(c.START),Y().cleanup(),X().dataStreamStatus.status!==h.NULL&&X().closeDataStream(),Y().status=c.STOP,Y().emitter.emit(u.STREAM_STATUS,{status:Y().status})},t.prototype.destroy=function(){Y().status===c.START&&this.stop(),this.cleanup(),Y().status!==c.NULL&&(X().destroy(),Y().status=c.NULL,Y().emitter.emit(u.STREAM_STATUS,{status:Y().status}))},t.prototype.getStatus=function(){return Y().status},t.prototype.getBaseUrl=function(){return Y().baseURL},t.prototype.getChannelStatus=function(){return{audioChannelOpened:Y().audioChannelOpened,videoChannelOpened:Y().videoChannelOpened,dataChannelOpened:Y().dataChannelOpened,messageChannelOpened:Y().messageChannelOpened}},t.prototype.setBaseUrl=function(t){Y().throwIfStatus(c.START),t&&Y().baseURL!==t&&Y().setBaseUrl(t)},t.prototype.setVideoSDKLibDir=function(t){Y().throwIfStatus(c.START),t&&Y().videoSDKLibDir!==t&&Y().setVideoSDKLibDir(t)},t.prototype.createAudioChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),t=Y().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.audio.createChannel(n.createTransport(i.kAudio)),Y().setAudioChannel(o),o.onopen=function(){K.debug("audioChannel onopen()"),Y().audioChannelOpened=!0,Y().emitter.emit(u.AUDIO_CHANNEL_OPENED)},[4,o.open()];case 1:return r.sent(),[2]}}))}))},t.prototype.closeAudioChannel=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return(t=Y().audioChannel)?[4,t.close()]:(K.error("audioChannel is miss"),[2]);case 1:return e.sent(),Y().setAudioChannel(null),Y().setAudioSender(null),Y().setAudioReceiver(null),[2]}}))}))},t.prototype.createVideoChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),t=Y().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createChannel(n.createTransport(i.kVideo)),Y().setVideoChannel(o),o.onopen=function(){K.debug("videoChannel onopen()"),Y().videoChannelOpened=!0,Y().emitter.emit(u.VIDEO_CHANNEL_OPENED)},[4,o.open()];case 1:return r.sent(),[2]}}))}))},t.prototype.createDataChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),t=Y().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createChannel(n.createTransport(i.kData)),Y().setDataChannel(o),o.onopen=function(){K.debug("dataChannel onopen()")},[4,o.open()];case 1:return r.sent(),Y().dataChannelOpened=!0,Y().emitter.emit(u.DATA_CHANNEL_OPENED),[2]}}))}))},t.prototype.createMessageChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:Y().throwIfNotStatus(c.START),t=Y().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createDataChannel(n.createTransport(i.kMessage)),Y().setMessageChannel(o),o.onopen=function(){K.debug("messageChannel onopen()")},r.label=1;case 1:return r.trys.push([1,3,,4]),[4,o.open()];case 2:return r.sent(),[3,4];case 3:return a=r.sent(),console.error(a),[3,4];case 4:return Y().messageChannelOpened=!0,Y().emitter.emit(u.MESSAGE_CHANNEL_OPENED),[2]}}))}))},t.prototype.closeMessageChannel=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return(t=Y().messageChannel)?[4,t.close()]:(K.error("messageChannel is miss"),[2]);case 1:return e.sent(),[2]}}))}))},t.prototype.closeMessageStream=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return(e=Y().messageChannel)?t?[4,e.closeStream(t)]:[3,2]:(K.error("messageChannel is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.setupRemoteControl=function(t){var e=t.element,n=t.remote;return i(this,void 0,void 0,(function(){var t,i;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfMessageNotOpened(),e.setAttribute("tabIndex","-1"),e.style.outline="0",t=window.LIBRTC,[4,Y().messageChannel.createStream(t.DataType.kRemoteControl)];case 1:return i=r.sent(),Y().setRemoteControlStream(i),[2,t.setupRemoteControl(i,e,n)]}}))}))},t.prototype.getRemoteControlStream=function(){return Y().remoteControlStream},t.prototype.createAudioSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened(),(t=Y().audioChannel)?(e=Y().audioSender?Y().audioSender:t.createSender(),Y().setAudioSender(e),[2,e]):(K.error("audioChannel is miss"),[2,null])}))}))},t.prototype.removeAudioSender=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){if(Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened(),!(t=Y().audioSender))return K.error("audioSender is miss"),[2];try{t.stop(),Y().audioChannel&&Y().audioChannel.removeSender(t.ssrc)}catch(t){K.error("audioChannel removeSender() error: ",t)}return[2]}))}))},t.prototype.createVideoSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened(),(t=Y().videoChannel)?(e=Y().videoSender?Y().videoSender:t.createSender(),Y().setVideoSender(e),e.onbusy=function(){K.debug("onbusy"),Y().emitter.emit(u.CHANNEL_BUSY);var t=Y().audioChannel;t&&t.ans(!1)},[2,e]):(K.error("videoChannel is miss"),[2,null])}))}))},t.prototype.removeVideoSender=function(){Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened();var t=Y().videoSender;if(t)try{t.stop(),Y().videoChannel&&Y().videoChannel.removeSender(t.ssrc)}catch(t){K.error("videoChannel removeSender() error: ",t)}else K.error("videoSender is miss")},t.prototype.createDataSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened(),(t=Y().dataChannel)?(e=Y().dataSender?Y().dataSender:t.createSender(),Y().setDataSender(e),[2,e]):(K.error("dataChannel is miss"),[2,null])}))}))},t.prototype.removeDataSender=function(){Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened();var t=Y().dataSender;t?(t.stop(),Y().dataChannel&&Y().dataChannel.removeSender(t.ssrc),Y().setDataSender(null)):K.error("dataSender is miss")},t.prototype.createAudioReceiver=function(t){Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened();var e=Y().audioChannel;if(!e)return K.error("audioChannel is miss"),null;var n=e.createReceiver();return Y().setAudioReceiver(n),t?(n.setSink(t),Y().setAudioPlayer(t),e.audioElement&&(e.audioElement.srcObject=null),n):(K.error("audioPlayer is miss"),null)},t.prototype.createVideoReceiver=function(t){Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened();var e=t.ccid;if(K.debug("createVideoReceiver ccid: ",e),!e)return K.error("params is missing or params error"),null;var n=Y().videoChannel;return n?n.createReceiver(e):(K.error("videoChannel is miss"),null)},t.prototype.createDataReceiver=function(t){Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened();var e=t.ccid;if(K.debug("createDataReceiver ccid: ",e),!e)return K.error("params is missing or params error"),null;var n=Y().dataChannel;return n?n.createReceiver(e):(K.error("dataChannel is miss"),null)},t.prototype.removeVideoReceiver=function(t){return Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened(),t?(t.stop(),Y().videoChannel&&Y().videoChannel.removeReceiver(t.ssrc),null):t},t.prototype.removeDataReceiver=function(t){return Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened(),t?(t.stop(),Y().dataChannel&&Y().dataChannel.removeReceiver(t.ssrc),null):t},t.prototype.loadVideoRenderer=function(t,e){return void 0===e&&(e=!0),i(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened(),(n=Y().videoChannel)&&t?T||g?[4,n.offscreen.load(t.transferControlToOffscreen(),e)]:[3,2]:(K.error("videoChannel or el is miss"),[2,null]);case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return[2,i]}}))}))},t.prototype.unloadVideoRenderer=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened(),(e=Y().videoChannel)&&t?T||g?[4,e.offscreen.unload(t)]:[3,2]:(K.error("videoChannel or renderer is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.loadDataRenderer=function(t,e){return void 0===e&&(e=!0),i(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened(),(n=Y().dataChannel)&&t?T||g?[4,n.offscreen.load(t.transferControlToOffscreen(),e)]:[3,2]:(K.error("dataChannel or el is miss"),[2,null]);case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return[2,i]}}))}))},t.prototype.unloadDataRenderer=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened(),(e=Y().dataChannel)&&t?T||g?[4,e.offscreen.unload(t)]:[3,2]:(K.error("dataChannel or renderer is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.bindAudioChannelEvent=function(){Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened();var t=Y().audioChannel;t?t.onfocusing=function(t){if(Y().voiceActiveSsrc.length&&t.length){if(Y().voiceActiveSsrc[0]===t[0])return}else if(0===Y().voiceActiveSsrc.length&&0===t.length)return;Y().setVoiceActiveSsrc(t),Y().emitter.emit(u.VOICE_ACTIVE_SSRC,{ssrc:t})}:K.error("audioChannel is miss")},t.prototype.offAudioChannelEvent=function(){Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened();var t=Y().audioChannel;t?t.onfocusing=null:K.error("audioChannel is miss")},t.prototype.setAudioPlayerVolume=function(t){Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened();var e=Y().audioPlayer;e?(t=t>=0&&t<1?t:t>=1&&t<=100?t/100:t,e.volume=t):K.error("audioPlayer is miss")},t.prototype.getAudioSender=function(){return Y().status===c.START&&Y().audioChannelOpened&&Y().audioSender||null},t.prototype.getVideoSender=function(){return Y().status===c.START&&Y().videoChannelOpened&&Y().videoSender||null},t.prototype.getDataSender=function(){return Y().status===c.START&&Y().dataChannelOpened&&Y().dataSender||null},t.prototype.getVoiceActiveSsrc=function(){return Y().status===c.START&&Y().audioChannelOpened&&Y().voiceActiveSsrc||[]},t.prototype.getAudioChannelStats=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return Y().status===c.START&&Y().audioChannelOpened&&Y().audioChannel?[4,Y().audioChannel.getStats()]:[2,{}];case 1:return[2,t.sent()]}}))}))},t.prototype.createAudioStream=function(){return Y().throwIfStatus(c.NULL),X().captureAudioStream()},t.prototype.closeAudioStream=function(){return Y().throwIfStatus(c.NULL),X().closeAudioStream()},t.prototype.createVideoStream=function(){return Y().throwIfStatus(c.NULL),X().captureVideoStream()},t.prototype.closeVideoStream=function(){return Y().throwIfStatus(c.NULL),X().closeVideoStream()},t.prototype.createDataStream=function(){return Y().throwIfNotStatus(c.START),X().captureDataStream()},t.prototype.closeDataStream=function(){return X().closeDataStream()},t.prototype.getAudioStream=function(){return X()?X().audioStream:null},t.prototype.getVideoStream=function(){return X()?X().videoStream:null},t.prototype.getDataStream=function(){return X()?X().dataStream:null},t.prototype.getAudioStreamStatus=function(){return X()?X().audioStreamStatus:null},t.prototype.getVideoStreamStatus=function(){return X()?X().videoStreamStatus:null},t.prototype.getDataStreamStatus=function(){return X()?X().dataStreamStatus:null},t.prototype.getActiveAudioInputDevice=function(){return X()?X().audioInputDevice:null},t.prototype.getActiveAudioOutputDevice=function(){return X()?X().audioOutputDevice:null},t.prototype.getActiveVideoInputDevice=function(){return X()?X().videoInputDevice:null},t.prototype.getMicVolume=function(){return X()&&Y().status!==c.NULL?X().volumeAnalyser.volume:0},t.prototype.switchAudioInputDevice=function(t){Y().throwIfStatus(c.NULL),t&&(X().audioInputDeviceId=t)},t.prototype.switchAudioOutputDevice=function(t){Y().throwIfStatus(c.NULL),t&&(X().audioOutputDeviceId=t)},t.prototype.switchVideoInputDevice=function(t){Y().throwIfStatus(c.NULL),t&&(X().videoInputDeviceId=t)},t.prototype.getAudioInputDevices=function(){return X()?X().audioInputDevices:[]},t.prototype.getAudioOutputDevices=function(){return X()?X().audioOutputDevices:[]},t.prototype.getVideoInputDevices=function(){return X()?X().videoInputDevices:[]},t.EVENT=u,t.STATUS=c,t.MEDIA_STATUS=d,t.MEDIA_STREAM_STATUS=h,t.MEDIA_STREAM_DETAIL=l,t}()}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Stream=e()}(this,(function(){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},n.apply(this,arguments)};function i(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{u(i.next(t))}catch(t){o(t)}}function s(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((i=i.apply(t,e||[])).next())}))}function r(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var o,a=function(){function t(){this.events=new Map}return t.prototype.emit=function(t,e){var n=this.events.get(t);n&&n.slice().map((function(t){"function"==typeof t&&t(e)}))},t.prototype.off=function(t,e){var n=this.events.get(t);n&&(e?n.splice(n.indexOf(e)>>>0,1):this.events.set(t,[]))},t.prototype.on=function(t,e){var n=this.events.get(t);n?n.push(e):this.events.set(t,[e])},t}(),s=function(t){function n(e){var n=t.call(this)||this;return n.stream=null,n._enable=!1,n.interval=100,n.timer=null,n.stream=e,n}return e(n,t),n.prototype.analyse=function(){},n.prototype.start=function(){var t=this;this.stream&&(this.timer&&(clearInterval(this.timer),this.timer=null),this.analyse(),this.timer=setInterval((function(){return t.analyse()}),this.interval))},n.prototype.stop=function(){this.timer&&(clearInterval(this.timer),this.timer=null)},n.prototype.destroy=function(){this.stop()},n}(a);!function(t){t.AUDIO_STATUS_CHANGED="audioStatusChanged",t.VIDEO_STATUS_CHANGED="videoStatusChanged"}(o||(o={}));var u,c,d,h,l,p=function(t){function n(e){var n=t.call(this,e)||this;return n._status={active:!1,hasStream:!1,track:!1},n.interval=3e3,n}return e(n,t),Object.defineProperty(n.prototype,"status",{get:function(){return this._status},set:function(t){var e=this._status;e.active===t.active&&e.hasStream===t.hasStream&&e.track===t.track||(this._status=t,this.emit(o.AUDIO_STATUS_CHANGED,{status:this._status}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.stream){var t=this.stream.getAudioTracks();this.status.active=void 0===this.stream.active?Boolean(t[0]):this.stream.active,void 0!==this.stream.active&&void 0!==this.stream.id?this.status.hasStream=!0:this.status.hasStream=!1,(this.status.active||this.status.hasStream)&&(this.status.track=this.checkAvariable(t))}else this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.streamInactive=function(){this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.checkAvariable=function(t){return void 0===t&&(t=[]),t.some((function(t){return!("readyState"in t&&"live"!==t.readyState||"muted"in t&&!0===t.muted)}))},n.prototype.destroy=function(){this.stream&&this.stream.removeEventListener("inactive",this.streamInactive),t.prototype.destroy.call(this)},n}(s),v=function(t){function n(e){var n=t.call(this,e)||this;return n._status={active:!1,hasStream:!1,track:!1},n.interval=3e3,n}return e(n,t),Object.defineProperty(n.prototype,"status",{get:function(){return this._status},set:function(t){var e=this._status;e.active===t.active&&e.hasStream===t.hasStream&&e.track===t.track||(this._status=t,this.emit(o.VIDEO_STATUS_CHANGED,{status:this._status}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.stream){var t=this.stream.getVideoTracks();this.status.active=void 0===this.stream.active?Boolean(t[0]):this.stream.active,void 0!==this.stream.active&&void 0!==this.stream.id?this.status.hasStream=!0:this.status.hasStream=!1,(this.status.active||this.status.hasStream)&&(this.status.track=this.checkAvariable(t))}else this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.streamInactive=function(){this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.checkAvariable=function(t){return void 0===t&&(t=[]),t.some((function(t){return!("readyState"in t&&"live"!==t.readyState||"muted"in t&&!0===t.muted)}))},n.prototype.destroy=function(){this.stream&&this.stream.removeEventListener("inactive",this.streamInactive),t.prototype.destroy.call(this)},n}(s),f=function(t){function n(e){var n=t.call(this,e)||this;return n.volume=0,n.context=null,n.contextAnalyser=null,n.streamSource=null,n}return e(n,t),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.context&&this.contextAnalyser&&this.streamSource){var t=this.contextAnalyser.frequencyBinCount,e=new Uint8Array(t);this.contextAnalyser.getByteFrequencyData(e);var n=e.reduce((function(t,e){return t+e}),0);this.volume=n/t}else this.volume=0},n.prototype.start=function(){this.createContextAnalyser(),this.createStreamSource(),this.streamSource&&t.prototype.start.call(this)},n.prototype.stop=function(){this.streamSource&&(this.streamSource.disconnect(),this.streamSource=null),this.volume=0,t.prototype.stop.call(this)},n.prototype.createContextAnalyser=function(){if((!this.context||!this.contextAnalyser)&&(window.AudioContext||window.webkitAudioContext)){var t=window.AudioContext||window.webkitAudioContext;this.context=new t,this.contextAnalyser=this.context.createAnalyser(),this.contextAnalyser.fftSize=1024,this.contextAnalyser.smoothingTimeConstant=.5}},n.prototype.createStreamSource=function(){if(this.streamSource&&(this.streamSource.disconnect(),this.streamSource=null),this.context&&this.stream&&this.stream.getAudioTracks().length>0){if(this.streamSource=this.context.createMediaStreamSource(this.stream),!this.contextAnalyser)return;this.streamSource.connect(this.contextAnalyser),"suspended"===this.context.state&&this.context.resume()}},n.prototype.destroy=function(){this.contextAnalyser&&(this.contextAnalyser.disconnect(),this.contextAnalyser=null),this.context&&(this.context=null),t.prototype.destroy.call(this)},n}(s);!function(t){t.STREAM_STATUS="streamStatus",t.CHANNEL_REFRESH="channelRefresh",t.CHANNEL_BUSY="channelBusy",t.AUDIO_CHANNEL_OPENED="audioChannelOpened",t.VIDEO_CHANNEL_OPENED="videoChannelOpened",t.DATA_CHANNEL_OPENED="dataChannelOpened",t.MESSAGE_CHANNEL_OPENED="messageChannelOpened",t.AUDIO_STREAM="audioStream",t.VIDEO_STREAM="videoStream",t.DATA_STREAM="dataStream",t.AUDIO_INPUT_DEVICES_UPDATED="audioInputDevicesUpdated",t.AUDIO_OUTPUT_DEVICES_UPDATED="audioOutputDevicesUpdated",t.VIDEO_INPUT_DEVICES_UPDATED="videoInputDevicesUpdated",t.AUDIO_INPUT_DEVICE_CHANGED="audioInputDeviceChanged",t.AUDIO_OUTPUT_DEVICE_CHANGED="audioOutputDeviceChanged",t.VIDEO_INPUT_DEVICE_CHANGED="videoInputDeviceChanged",t.AUDIO_STREAM_STATUS="audioStreamStatus",t.VIDEO_STREAM_STATUS="videoStreamStatus",t.DATA_STREAM_STATUS="dataStreamStatus",t.VOICE_ACTIVE_SSRC="voiceActiveSsrc"}(u||(u={})),function(t){t.NULL="null",t.INIT="initialized",t.START="started",t.STOP="stopped"}(c||(c={})),function(t){t.Null="null",t.INIT="initialized"}(d||(d={})),function(t){t.NULL="null",t.CAPTURING="capturing",t.FAILED="failed"}(h||(h={})),function(t){t.NO_DEVICE="No Device",t.PERMISSION_DENIED="Permission denied",t.COULD_NOT_START_VIDEO_SOURCE="Could not start video source",t.PERMISSION_DENIED_BY_SYSTEM="Permission denied by system",t.OTHER_EXCEPTIONS="Other exceptions"}(l||(l={}));var S,m=function(t,e){var n=e.match(t);return n&&n.length>0&&n[1]||""},I=/version\/(\d+(\.?_?\d+)+)/i,D=[{test:[/\sedg\//i],describe:function(t){var e={name:"Microsoft Edge"},n=m(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/edg([ea]|ios)/i],describe:function(t){var e={name:"Microsoft Edge"},n=function(t,e){var n=e.match(t);return n&&n.length>1&&n[2]||""}(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/firefox|iceweasel|fxios/i],describe:function(t){var e={name:"Firefox"},n=m(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/chromium/i],describe:function(t){var e={name:"Chromium"},n=m(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||m(I,t);return n&&(e.version=n),e}},{test:[/chrome|crios|crmo/i],describe:function(t){var e={name:"Chrome"},n=m(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/safari|applewebkit/i],describe:function(t){var e={name:"Safari"},n=m(I,t);return n&&(e.version=n),e}}],y=D.find((function(t){if(t.test instanceof Array)return t.test.some((function(t){return t.test(navigator.userAgent)}));throw new Error("Browser's test function is not valid")}));y&&(S=y.describe(navigator.userAgent));var A=S&&"Safari"===S.name,E=S&&"Firefox"===S.name,T=S&&"Chrome"===S.name,g=S&&"Microsoft Edge"===S.name,_=function(){function t(t){var e=t.namespace,n=t.debug;this.initialized=!0,this.isDebugging=n,this.backend=C(),this.namespace=e,this.useColors=this.backend.useColors,this.color=this.selectColor(e)}return t.prototype.logger=function(t){var e=this;t[0]=this.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");var n=0;return t[0]=t[0].replace(/%([a-zA-Z%])/g,(function(i,r){if("%%"===i)return i;n++;var o=e.backend.formatters[r];"function"==typeof o&&(i=o(t[n]),t.splice(n,1),n--);return i})),this.backend.formatArgs(t,this)},t.prototype.coerce=function(t){return t instanceof Error?t.stack||t.message:t},t.prototype.selectColor=function(t){var e=Array.from(t).reduce((function(t,e){return t=(t<<5)-t+e.charCodeAt(0),t|=0}),0);return this.backend.colors[Math.abs(e)%this.backend.colors.length]},t.prototype.switchDebug=function(t){this.isDebugging=t},t.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];t=this.logger(t),this.backend.log.apply(this,t)},t.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.isDebugging&&(t=this.logger(t),this.backend.debug.apply(this,t))},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.backend.warn.apply(this,t)},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.backend.error.apply(this,t)},t}(),b=_,C=function(){var t={colors:["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],formatters:{j:function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: ".concat(t.message)}}},log:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,t)},debug:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.debug&&Function.prototype.apply.call(console.debug,console,t)},warn:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.warn&&Function.prototype.apply.call(console.warn,console,t)},error:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.error&&Function.prototype.apply.call(console.error,console,t)},formatArgs:function(t,e){var n=e.useColors,i=e.namespace,r=e.color;if(t[0]="".concat((n?"%c":"")+i+(n?" %c":" ")+t[0]+(n?"%c ":" "),"+").concat(function(t){var e=Math.abs(t);if(e>=U)return"".concat(Math.round(t/U),"d");if(e>=N)return"".concat(Math.round(t/N),"h");if(e>=w)return"".concat(Math.round(t/w),"m");if(e>=O)return"".concat(Math.round(t/O),"s");return"".concat(t,"ms")}(0)),!n)return[];var o="color: ".concat(r);t.splice(1,0,o,"color: inherit");var a=0,s=0;return t[0].replace(/%[a-zA-Z%]/g,(function(t){"%%"!==t&&(a++,"%c"===t&&(s=a))})),t.splice(s,0,o),t},useColors:R()};return t},O=1e3,w=60*O,N=60*w,U=24*N;var R=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.webkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},P=function(t){return t.close=t.stop=function(){!function(t){if(t)try{t.getTracks?t.getTracks().forEach((function(t){return t.stop()})):(t.getAudioTracks().forEach((function(t){return t.stop()})),t.getVideoTracks().forEach((function(t){return t.stop()})))}catch(e){"function"!=typeof t.stop&&"object"!=typeof t.stop||t.stop()}}(this)},t.pause=function(){this.getTracks().forEach((function(t){return t.enabled=!1}))},t.play=function(){this.getTracks().forEach((function(t){return t.enabled=!0}))},t.muteAudio=function(t){void 0===t&&(t=!0),this.getAudioTracks().forEach((function(e){return e.enabled=!t}))},t.muteVideo=function(t){void 0===t&&(t=!0),this.getVideoTracks().forEach((function(e){return e.enabled=!t}))},t},L=function(t){return i(void 0,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return navigator.mediaDevices.getUserMedia?[4,navigator.mediaDevices.getUserMedia(t)]:[3,2];case 1:case 3:return e=n.sent(),[3,5];case 2:return navigator.getUserMedia?[4,new Promise((function(e,n){navigator.getUserMedia(t,e,n)}))]:[3,4];case 4:throw new Error("Not Supported");case 5:return[2,P(e)]}}))}))},V=function(t){return i(void 0,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return navigator.mediaDevices.getDisplayMedia?[4,navigator.mediaDevices.getDisplayMedia(t)]:[3,2];case 1:case 3:return e=n.sent(),[3,5];case 2:return navigator.getDisplayMedia?[4,new Promise((function(e,n){navigator.getDisplayMedia(t,e,n)}))]:[3,4];case 4:throw new Error("Not Supported");case 5:return[2,P(e)]}}))}))},M=new b({namespace:"STREAM:Media",debug:!1}),k=function(t){function a(e){var n=e.debug,i=t.call(this)||this;return i.status=d.Null,i.deviceList=[],i.audioQueue=Promise.resolve(null),i.videoQueue=Promise.resolve(null),i.dataQueue=Promise.resolve(null),i._audioStream=null,i._videoStream=null,i._displayStream=null,i._audioInputDevice=null,i._audioOutputDevice=null,i._videoInputDevice=null,i._audioInputDeviceId="",i._audioOutputDeviceId="",i._videoInputDeviceId="",i._audioInputDevices=[],i._audioOutputDevices=[],i._videoInputDevices=[],i._audioStreamStatus={status:h.NULL},i._videoStreamStatus={status:h.NULL},i._dataStreamStatus={status:h.NULL},i.onDataStreamInactive=i.dataStreamInactive.bind(i),M.switchDebug(n),i.volumeAnalyser=new f(i.audioStream),i.audioAnalyser=new p(i.audioStream),i.videoAnalyser=new v(i.videoStream),i.setup(),i}return e(a,t),a.createInstance=function(t){return this.instance||(this.instance=new a(t)),this.instance},Object.defineProperty(a.prototype,"audioInputDevices",{get:function(){return this._audioInputDevices||[]},set:function(t){this.checkDeviceList(t,this._audioInputDevices)||(this._audioInputDevices=t,this.status===d.INIT&&this.emit(u.AUDIO_INPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDevices",{get:function(){return this._audioOutputDevices||[]},set:function(t){this.checkDeviceList(t,this._audioOutputDevices)||(this._audioOutputDevices=t,this.status===d.INIT&&this.emit(u.AUDIO_OUTPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDevices",{get:function(){return this._videoInputDevices||[]},set:function(t){this.checkDeviceList(t,this._videoInputDevices)||(this._videoInputDevices=t,this.status===d.INIT&&this.emit(u.VIDEO_INPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioInputDeviceId",{get:function(){return this._audioInputDeviceId||""},set:function(t){if(!this._audioInputDeviceId||this._audioInputDeviceId!==t){var e=this.audioInputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.audioInputDevice=i,this._audioInputDeviceId=i?i.deviceId:"",this.audioStreamStatus.status!==h.NULL&&this.captureAudioStream()}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDeviceId",{get:function(){return this._audioOutputDeviceId||""},set:function(t){if(!this._audioOutputDeviceId||this._audioOutputDeviceId!==t){var e=this.audioOutputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.audioOutputDevice=i,this._audioOutputDeviceId=i?i.deviceId:""}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDeviceId",{get:function(){return this._videoInputDeviceId||""},set:function(t){if(!this._videoInputDeviceId||this._videoInputDeviceId!==t){var e=this.videoInputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.videoInputDevice=i,this._videoInputDeviceId=i?i.deviceId:"",this.videoStreamStatus.status!==h.NULL&&this.captureVideoStream()}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioInputDevice",{get:function(){return this._audioInputDevice},set:function(t){var e=this._audioInputDevice&&!this.isSameDevice(this._audioInputDevice,t),n=!this._audioInputDevice&&!!t;(n||e)&&(this._audioInputDevice=t,!n&&e&&this.emit(u.AUDIO_INPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDevice",{get:function(){return this._audioOutputDevice},set:function(t){var e=this._audioOutputDevice&&!this.isSameDevice(this._audioOutputDevice,t),n=!this._audioOutputDevice&&!!t;(n||e)&&(this._audioOutputDevice=t,!n&&e&&this.emit(u.AUDIO_OUTPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDevice",{get:function(){return this._videoInputDevice},set:function(t){var e=this._videoInputDevice&&!this.isSameDevice(this._videoInputDevice,t),n=!this._videoInputDevice&&!!t;(n||e)&&(this._videoInputDevice=t,!n&&e&&this.emit(u.VIDEO_INPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"supportNativeShare",{get:function(){return navigator.getDisplayMedia||navigator.mediaDevices.getDisplayMedia},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioStream",{get:function(){return this._audioStream},set:function(t){this._audioStream!==t&&(this._audioStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoStream",{get:function(){return this._videoStream},set:function(t){this._videoStream!==t&&(this._videoStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"dataStream",{get:function(){return this._displayStream},set:function(t){this._displayStream!==t&&(this._displayStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioStreamStatus",{get:function(){return this._audioStreamStatus},set:function(t){var e=this._audioStreamStatus;e.status===t.status&&e.detail===t.detail||(this._audioStreamStatus=t,this.emit(u.AUDIO_STREAM_STATUS,this._audioStreamStatus))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoStreamStatus",{get:function(){return this._videoStreamStatus},set:function(t){var e=this._videoStreamStatus;e.status===t.status&&e.detail===t.detail||(this._videoStreamStatus=t,this.emit(u.VIDEO_STREAM_STATUS,this._videoStreamStatus))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"dataStreamStatus",{get:function(){return this._dataStreamStatus},set:function(t){var e=this._dataStreamStatus;e.status===t.status&&e.detail===t.detail||(this._dataStreamStatus=t,this.emit(u.DATA_STREAM_STATUS,this._dataStreamStatus))},enumerable:!1,configurable:!0}),a.prototype.setup=function(){var t=this;this.audioAnalyser.on(o.AUDIO_STATUS_CHANGED,(function(e){var n=e.status;M.debug("".concat(o.AUDIO_STATUS_CHANGED," ").concat(JSON.stringify(n))),!n.hasStream||n.track&&n.active||(t.audioStreamStatus={status:h.FAILED,detail:l.OTHER_EXCEPTIONS})})),this.videoAnalyser.on(o.VIDEO_STATUS_CHANGED,(function(e){var n=e.status;M.debug("".concat(o.VIDEO_STATUS_CHANGED," ").concat(JSON.stringify(n))),!n.hasStream||n.track&&n.active||(t.videoStreamStatus={status:h.FAILED,detail:l.OTHER_EXCEPTIONS})}))},a.prototype.cleanup=function(){this.deviceList=[],this.audioInputDevices=[],this.audioInputDeviceId="",this.audioOutputDevices=[],this.audioOutputDeviceId="",this.videoInputDevices=[],this.videoInputDeviceId="",this.volumeAnalyser.destroy(),this.audioAnalyser.destroy(),this.videoAnalyser.destroy()},a.prototype.init=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return this.throwIfStatus(d.INIT),navigator.mediaDevices&&(e=this,navigator.mediaDevices.ondevicechange=function(){e.detectDevice()}),[4,this.detectDevice(t)];case 1:return n.sent(),this.status=d.INIT,[2]}}))}))},a.prototype.destroy=function(){try{this.closeAudioStream(),this.closeVideoStream(),this.closeDataStream(),this.cleanup()}catch(t){M.error(t)}this.status=d.Null},a.prototype.detectDevice=function(t){return i(this,void 0,void 0,(function(){var e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:return navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices?[4,this.enumerateDevices().catch((function(t){return M.error("enumerate devices error: ",t)}))]:(M.error("mediaDevices or enumerateDevices is miss"),[2]);case 1:return e=r.sent(),this.deviceList=e&&e.map((function(t){return t.toJSON()}))||[],M.debug("deviceList: ".concat(JSON.stringify(this.deviceList))),i=(n=this).audioInputDevice,o=n.audioOutputDevice,a=n.videoInputDevice,this.audioInputDevices=this.deviceList.filter((function(t){return"audioinput"===t.kind}))||[],this.audioInputDeviceId=this.checkDevice({deviceList:this.audioInputDevices,device:i,deviceId:t&&t.audioInputDeviceId||""}),this.audioOutputDevices=this.deviceList.filter((function(t){return"audiooutput"===t.kind}))||[],this.audioOutputDeviceId=this.checkDevice({deviceList:this.audioOutputDevices,device:o,deviceId:t&&t.audioOutputDeviceId||""}),this.videoInputDevices=this.deviceList.filter((function(t){return"videoinput"===t.kind}))||[],this.videoInputDeviceId=this.checkDevice({deviceList:this.videoInputDevices,device:a,deviceId:t&&t.videoInputDeviceId||""}),[2]}}))}))},a.prototype.enumerateDevices=function(){return new Promise((function(t,e){navigator.mediaDevices.enumerateDevices().then((function(e){t(e)})).catch((function(t){e(t)}))}))},a.prototype.genAudioConstraints=function(t){var e={audio:!1,video:!1},n=this.audioInputDevice,i=n||{deviceId:"",groupId:""},r=i.deviceId,o=i.groupId;return e.audio=!!n&&(t&&E?{deviceId:{exact:r},groupId:{exact:o}}:{deviceId:r,groupId:o}),e.audio&&!A&&Object.assign(e.audio,x),e},a.prototype.genVideoConstraints=function(){var t={audio:!1,video:!1},e=this.videoInputDevice,n=e||{deviceId:"",groupId:""},i=n.deviceId,r=n.groupId;return t.video=!!e&&(E?{deviceId:{exact:i},groupId:{exact:r}}:{deviceId:i,groupId:r}),t.video&&Object.assign(t.video,j),t},a.prototype.genDisplayConstraints=function(t){var e,i=t.quality;return this.supportNativeShare?e={video:n({},i)}:e},a.prototype.createAudioStream=function(t){return i(this,void 0,void 0,(function(){var e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:if(e=this.genAudioConstraints(t),M.debug("audio constraints: ".concat(JSON.stringify(e))),n=this.audioStreamStatus,!e.audio)return[2,{stream:null,audioStreamStatus:n={status:h.FAILED,detail:l.NO_DEVICE}}];i=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,L(e)];case 2:return i=r.sent(),[3,4];case 3:return a=r.sent(),M.debug("getUserMedia error: ".concat(a)),o=a,[3,4];case 4:return i?n={status:h.CAPTURING}:(o=o||new Error("Stream is null"),n={status:h.FAILED,detail:G.get(o.message)||l.OTHER_EXCEPTIONS}),[2,{stream:i,audioStreamStatus:n}]}}))}))},a.prototype.createVideoStream=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:if(t=this.genVideoConstraints(),M.debug("video constraints: ".concat(JSON.stringify(t))),e=this.videoStreamStatus,!t.video)return[2,{stream:null,videoStreamStatus:e={status:h.FAILED,detail:l.NO_DEVICE}}];n=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,L(t)];case 2:return n=r.sent(),[3,4];case 3:return o=r.sent(),M.debug("getUserMedia error: ".concat(o)),i=o,[3,4];case 4:return n?e={status:h.CAPTURING}:(i=i||new Error("Stream is null"),e={status:h.FAILED,detail:F.get(i.message)||l.OTHER_EXCEPTIONS}),[2,{stream:n,videoStreamStatus:e}]}}))}))},a.prototype.createDataStream=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:t=this.genDisplayConstraints({quality:H}),M.debug("data constraints: ".concat(JSON.stringify(t))),e=null,i=this.dataStreamStatus,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,V(t)];case 2:return e=r.sent(),[3,4];case 3:return o=r.sent(),M.debug("getDisplayMedia error: ".concat(o)),n=o,[3,4];case 4:return e?i={status:h.CAPTURING}:(n=n||new Error("Stream is null"),i={status:h.FAILED,detail:B.get(n.message)||l.OTHER_EXCEPTIONS}),[2,{stream:e,dataStreamStatus:i}]}}))}))},a.prototype.closeAudioStream=function(){this.audioStream&&this.audioStream.close(),this.audioStream=null,this.switchAudioAnalyserEnable({enable:!1}),this.setAudioAnalyserStream(this.audioStream),this.audioStreamStatus={status:h.NULL},this.emit(u.AUDIO_STREAM,{stream:this.audioStream})},a.prototype.closeVideoStream=function(){this.videoStream&&this.videoStream.close(),this.videoStream=null,this.switchVideoAnalyserEnable({enable:!1}),this.setVideoAnalyserStream(this.videoStream),this.videoStreamStatus={status:h.NULL},this.emit(u.VIDEO_STREAM,{stream:this.videoStream})},a.prototype.closeDataStream=function(){var t=this;this.dataStream&&(this.dataStream.removeEventListener("inactive",this.onDataStreamInactive),(this.dataStream.getVideoTracks()||[]).forEach((function(e){e.removeEventListener("ended",t.onDataStreamInactive)})),this.dataStream.close());this.dataStream=null,this.dataStreamStatus={status:h.NULL},this.emit(u.DATA_STREAM,{stream:this.dataStream})},a.prototype.captureAudioStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.audioQueue=this.audioQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return this.switchAudioAnalyserEnable({enable:!1}),t=!(this.audioStreamStatus.status!==h.CAPTURING||!this.audioStream),[4,this.createAudioStream(t)];case 1:return e=r.sent(),n=e.stream,i=e.audioStreamStatus,this.audioStreamStatus.status===h.CAPTURING&&this.audioStream&&(this.audioStream.close(),this.audioStream=null),this.status!==d.INIT?(n&&n.close(),this.emit(u.AUDIO_STREAM,{stream:this.audioStream}),[2,Promise.resolve(this.audioStream)]):(this.audioStream=n,this.audioStreamStatus=i,this.emit(u.AUDIO_STREAM,{stream:this.audioStream}),o=!0,n||i.status!==h.FAILED||(o=!1),this.setAudioAnalyserStream(n),this.switchAudioAnalyserEnable({enable:o}),[2,Promise.resolve(this.audioStream)])}}))}))}))},a.prototype.captureVideoStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.videoQueue=this.videoQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i;return r(this,(function(r){switch(r.label){case 0:return this.switchVideoAnalyserEnable({enable:!1}),[4,this.createVideoStream()];case 1:return t=r.sent(),e=t.stream,n=t.videoStreamStatus,this.videoStreamStatus.status===h.CAPTURING&&this.videoStream&&(this.videoStream.close(),this.videoStream=null),this.status!==d.INIT?(e&&e.close(),this.emit(u.VIDEO_STREAM,{stream:this.videoStream}),[2,Promise.resolve(this.videoStream)]):(this.videoStream=e,this.videoStreamStatus=n,this.emit(u.VIDEO_STREAM,{stream:this.videoStream}),i=!0,e||n.status!==h.FAILED||(i=!1),this.setVideoAnalyserStream(e),this.switchVideoAnalyserEnable({enable:i}),[2,Promise.resolve(this.videoStream)])}}))}))}))},a.prototype.captureDataStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.dataQueue=this.dataQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i=this;return r(this,(function(r){switch(r.label){case 0:return[4,this.createDataStream()];case 1:return t=r.sent(),e=t.stream,n=t.dataStreamStatus,this.dataStreamStatus.status!==h.NULL||e?(this.dataStreamStatus.status===h.CAPTURING&&this.dataStream&&!e||(this.dataStreamStatus.status===h.CAPTURING&&this.dataStream&&(this.dataStream.removeEventListener("inactive",this.onDataStreamInactive),(this.dataStream.getVideoTracks()||[]).forEach((function(t){t.removeEventListener("ended",i.onDataStreamInactive)})),this.dataStream.close(),this.dataStream=null),e&&e.addEventListener("inactive",this.onDataStreamInactive),E&&e&&(e.getVideoTracks()||[]).forEach((function(t){t.addEventListener("ended",i.onDataStreamInactive)})),this.dataStream=e,this.dataStreamStatus=n,this.emit(u.DATA_STREAM,{stream:this.dataStream})),[2,Promise.resolve(this.dataStream)]):[2,Promise.resolve(this.dataStream)]}}))}))}))},a.prototype.setAudioAnalyserStream=function(t){this.volumeAnalyser.stream=t,this.audioAnalyser.stream=t},a.prototype.setVideoAnalyserStream=function(t){this.videoAnalyser.stream=t},a.prototype.switchAudioAnalyserEnable=function(t){var e=t.enable,n=void 0!==e&&e;this.volumeAnalyser.enable=n,this.audioAnalyser.enable=n},a.prototype.switchVideoAnalyserEnable=function(t){var e=t.enable,n=void 0!==e&&e;this.videoAnalyser.enable=n},a.prototype.dataStreamInactive=function(){this.dataStream&&(this.dataStream.close(),this.dataStream=null,this.dataStreamStatus={status:h.NULL},this.emit(u.DATA_STREAM,{stream:this.dataStream}))},a.prototype.checkDevice=function(t){var e=this,n=t.deviceList,i=t.device,r=t.deviceId;return(i=(i=r?n.find((function(t){return t.deviceId===r}))||null:i&&n.find((function(t){return e.isSameDevice(t,i)}))||null)||(n[0]||null))&&i.deviceId?i.deviceId:""},a.prototype.checkDeviceList=function(t,e){if(!t||!e||t.length!==e.length)return!1;for(var n=!0,i=0;i<t.length;i++){var r=t[i],o=e[i];if(!this.isSameDevice(r,o)){n=!1;break}}return n},a.prototype.isSameDevice=function(t,e,n){if(void 0===n&&(n=!1),!t||!e)return!1;var i=t.deviceId===e.deviceId&&t.label===e.label&&t.kind===e.kind;return n?t.groupId===e.groupId&&i:i},a.prototype.throwIfStatus=function(t,e){if(this.status===t)throw new Error(e||"Invalid State")},a.prototype.throwIfNotStatus=function(t,e){if(this.status!==t)throw new Error(e||"Invalid State")},a}(a),x={autoGainControl:!0,echoCancellation:!0,latency:0,noiseSuppression:!0},j={aspectRatio:16/9,frameRate:30,width:640,height:360},H={width:1920,height:1080,frameRate:5},G=new Map([["No Device",l.NO_DEVICE],["Permission denied",l.PERMISSION_DENIED],["Permission dismissed",l.PERMISSION_DENIED],["Could not start video source",l.OTHER_EXCEPTIONS],["The request is not allowed by the user agent or the platform in the current context.",l.PERMISSION_DENIED],["Failed to allocate videosource",l.OTHER_EXCEPTIONS],["Stream is null",l.OTHER_EXCEPTIONS]]),F=new Map([["No Device",l.NO_DEVICE],["Permission denied",l.PERMISSION_DENIED],["Permission dismissed",l.PERMISSION_DENIED],["Could not start video source",l.COULD_NOT_START_VIDEO_SOURCE],["The request is not allowed by the user agent or the platform in the current context.",l.PERMISSION_DENIED],["Failed to allocate videosource",l.COULD_NOT_START_VIDEO_SOURCE],["Stream is null",l.OTHER_EXCEPTIONS]]),B=new Map([["Permission denied by system",l.PERMISSION_DENIED_BY_SYSTEM],["The object can not be found here.",l.PERMISSION_DENIED_BY_SYSTEM],["The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.",l.PERMISSION_DENIED_BY_SYSTEM]]),X=function(){return k.instance},J=new b({namespace:"STREAM:Store",debug:!1}),z=function(){function t(t){var e=this,n=t.debug;this.status=c.NULL,this.remoteControlStream=null,this.videoSender=null,this.audioSender=null,this.dataSender=null,this.audioReceiver=null,this.voiceActiveSsrc=[],this.audioPlayer=null,this.audioChannelOpened=!1,this.videoChannelOpened=!1,this.dataChannelOpened=!1,this.messageChannelOpened=!1,this.api={getMss:function(t){var n=e.baseURL;return"function"!=typeof fetch?Promise.reject():fetch(function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(n,"/webapp/front/getMss"),{headers:{"content-type":"application/json"},method:"POST",body:JSON.stringify(t)}).then((function(t){return i(e,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,t.json()];case 1:return[2,e.sent()]}}))}))}))}},this.baseURL="https://meetings.ylyun.com",this.videoSDKLibDir="",J.switchDebug(n),this.emitter=new a}return t.createInstance=function(e){return this.instance||(this.instance=new t(e)),this.instance},t.prototype.setApi=function(t){this.api=t},t.prototype.setBaseUrl=function(t){this.baseURL=t},t.prototype.setVideoSDKLibDir=function(t){this.videoSDKLibDir=t},t.prototype.setMediaEndpoint=function(t){this.mediaEndpoint=t},t.prototype.setMediaEngine=function(t){this.mediaEngine=t},t.prototype.setAudioChannel=function(t){this.audioChannel=t},t.prototype.setVideoChannel=function(t){this.videoChannel=t},t.prototype.setDataChannel=function(t){this.dataChannel=t},t.prototype.setMessageChannel=function(t){this.messageChannel=t},t.prototype.setRemoteControlStream=function(t){this.remoteControlStream=t},t.prototype.setVideoSender=function(t){this.videoSender=t},t.prototype.setAudioSender=function(t){this.audioSender=t},t.prototype.setDataSender=function(t){this.dataSender=t},t.prototype.setAudioReceiver=function(t){this.audioReceiver=t},t.prototype.setAudioPlayer=function(t){this.audioPlayer=t},t.prototype.setVoiceActiveSsrc=function(t){this.voiceActiveSsrc=t},t.prototype.throwIfAudioNotOpened=function(t){if(!this.audioChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfVideoNotOpened=function(t){if(!this.videoChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfDataNotOpened=function(t){if(!this.dataChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfMessageNotOpened=function(t){if(!this.messageChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfStatus=function(t,e){if(this.status===t)throw new Error(e||"Invalid State")},t.prototype.throwIfNotStatus=function(t,e){if(this.status!==t)throw new Error(e||"Invalid State")},t.prototype.loadLibRTCFiles=function(){var t=this.videoSDKLibDir;return Promise.all([this.createScriptTag({src:"".concat(t,"/libsfu.prod.js"),id:"ylink-sdk-stream-libsfu"}),this.createScriptTag({src:"".concat(t,"/librtc.global.prod.js"),id:"ylink-sdk-stream-librtc"})])},t.prototype.getLibRTCContext=function(){var t=window.LIBRTC.SFUTransportType,e=this.mediaEndpoint,n=this.mediaEngine;return e&&n?{mediaEndpoint:e,mediaEngine:n,SFUTransportType:t}:{SFUTransportType:t}},t.prototype.createScriptTag=function(t){var e=t.src,n=t.id;return new Promise((function(t,i){!function(t){if(t){var e=document.querySelector("#".concat(t));if(e){var n=e.parentElement;n&&n.removeChild(e)}}}(n);var r=document.createElement("script");r.type="text/javascript",r.src=e,r.id=n,r.onload=function(){t(r)},r.onerror=function(t){i(t)},document.head.appendChild(r)}))},t.prototype.cleanup=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o,a,s,u;return r(this,(function(r){switch(r.label){case 0:e=(t=this).videoChannel,n=t.audioChannel,i=t.messageChannel,o=t.dataChannel,a=t.mediaEndpoint,s=t.remoteControlStream,r.label=1;case 1:return r.trys.push([1,12,,13]),n?[4,n.close()]:[3,3];case 2:r.sent(),r.label=3;case 3:return e?[4,e.close()]:[3,5];case 4:r.sent(),r.label=5;case 5:return o?[4,o.close()]:[3,7];case 6:r.sent(),r.label=7;case 7:return s&&i?[4,i.closeStream(s)]:[3,9];case 8:r.sent(),r.label=9;case 9:return i?[4,i.close()]:[3,11];case 10:r.sent(),r.label=11;case 11:return a&&(a.stop(),a.destroy()),[3,13];case 12:return u=r.sent(),J.error(u),[3,13];case 13:return this.mediaEndpoint=null,this.mediaEngine=null,this.videoChannel=null,this.audioChannel=null,this.dataChannel=null,this.messageChannel=null,this.videoSender=null,this.audioSender=null,this.dataSender=null,this.audioReceiver=null,this.audioPlayer=null,this.audioChannelOpened=!1,this.videoChannelOpened=!1,this.dataChannelOpened=!1,this.messageChannelOpened=!1,[2]}}))}))},t}(),Y=function(){return z.instance},K=new b({namespace:"STREAM:Store",debug:!1});return function(){function t(t){var e,n=t.baseURL,i=t.videoSDKLibDir,r=t.debug;n=n||"https://meetings.ylyun.com",i=i||"",r=r||!1,K.switchDebug(r),e={debug:r},z.createInstance(e),function(t){k.createInstance(t)}({debug:r}),Y().setBaseUrl(n),Y().setVideoSDKLibDir(i),this.setup()}return t.prototype.setup=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){return X().on(u.AUDIO_STREAM,(function(t){Y().emitter.emit(u.AUDIO_STREAM,t)})),X().on(u.VIDEO_STREAM,(function(t){Y().emitter.emit(u.VIDEO_STREAM,t)})),X().on(u.DATA_STREAM,(function(t){Y().emitter.emit(u.DATA_STREAM,t)})),X().on(u.AUDIO_INPUT_DEVICES_UPDATED,(function(t){Y().emitter.emit(u.AUDIO_INPUT_DEVICES_UPDATED,t)})),X().on(u.AUDIO_OUTPUT_DEVICES_UPDATED,(function(t){Y().emitter.emit(u.AUDIO_OUTPUT_DEVICES_UPDATED,t)})),X().on(u.VIDEO_INPUT_DEVICES_UPDATED,(function(t){Y().emitter.emit(u.VIDEO_INPUT_DEVICES_UPDATED,t)})),X().on(u.AUDIO_INPUT_DEVICE_CHANGED,(function(t){Y().emitter.emit(u.AUDIO_INPUT_DEVICE_CHANGED,t)})),X().on(u.AUDIO_OUTPUT_DEVICE_CHANGED,(function(t){Y().emitter.emit(u.AUDIO_OUTPUT_DEVICE_CHANGED,t)})),X().on(u.VIDEO_INPUT_DEVICE_CHANGED,(function(t){Y().emitter.emit(u.VIDEO_INPUT_DEVICE_CHANGED,t)})),X().on(u.AUDIO_STREAM_STATUS,(function(t){Y().emitter.emit(u.AUDIO_STREAM_STATUS,t)})),X().on(u.VIDEO_STREAM_STATUS,(function(t){Y().emitter.emit(u.VIDEO_STREAM_STATUS,t)})),X().on(u.DATA_STREAM_STATUS,(function(t){Y().emitter.emit(u.DATA_STREAM_STATUS,t)})),[2]}))}))},t.prototype.cleanup=function(){},t.prototype.on=function(t,e){return Y().emitter.on(t,e)},t.prototype.off=function(t,e){return Y().emitter.off(t,e)},t.prototype.init=function(t){return i(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:if(window.ActiveXObject||"ActiveXObject"in window)throw new Error("Not compatible with this browser yet, please use other browsers instead.");return[4,X().init(t)];case 1:return e.sent(),Y().status=c.INIT,Y().emitter.emit(u.STREAM_STATUS,{status:Y().status}),[2]}}))}))},t.prototype.start=function(t){return i(this,void 0,void 0,(function(){var e,n,o,a,s,d,h,l,p,v,f,S=this;return r(this,(function(m){switch(m.label){case 0:return Y().throwIfStatus(c.NULL),Y().throwIfStatus(c.START),[4,Y().loadLibRTCFiles().catch((function(t){K.error(t)}))];case 1:return m.sent(),e=window.LIBRTC,n=e.NativeMediaEndpoint,o=e.NativeMediaEngine,a=t.mediaContent,s=t.user,d=t.meetingID,h=t.ctrlID,l=t.meetingNum,p=t.account,[4,(v=new o).init()];case 2:return m.sent(),(f=new n).onrefresh=function(){return i(S,void 0,void 0,(function(){var t,e,n;return r(this,(function(i){switch(i.label){case 0:return Y().emitter.emit(u.CHANNEL_REFRESH),[4,Y().api.getMss({accessMCs:a.accessMCs,topMC:a.topMC,confId:d,ccid:s.userID,userType:"audience"===s.role?"Broadcast":"Interactive"}).catch((function(t){K.error(t)}))];case 1:return t=i.sent(),K.debug("response ".concat(JSON.stringify(t))),t&&t.data&&t.data.MssInfo?(e=t.data.MssInfo.map((function(t){return t.ExtranetlUri})).flat(),n=t.data.MssInfo.map((function(t){return t.IntranetUri})).flat(),[2,e.concat(n).filter((function(t){return t.startsWith("ws")||t.startsWith("wss")})).map((function(t){var e=Y().baseURL,n=/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)?function(t){if(!t)return"";var e=/^([a-z][a-z\d+\-.]*:)?\/\/(\S+)/.exec(t);return!e||e.length<3?"":e[2]}(e):e,i="wss://".concat(n),r=window.btoa(t.replace(/\w+:\/\//,""));return"".concat(i,"/webapp/socket/").concat(r)}))]):(K.error("getMss response error ",t),[2,[]])}}))}))},[4,f.init()];case 3:return m.sent(),[4,f.start({meeting_number:l||"",user_account:p||"",confid:d,ccid:s.userID,role:1,encrypt:a.crypto,token:h})];case 4:return m.sent(),Y().setMediaEndpoint(f),Y().setMediaEngine(v),Y().status=c.START,Y().emitter.emit(u.STREAM_STATUS,{status:Y().status}),[2]}}))}))},t.prototype.stop=function(){Y().throwIfNotStatus(c.START),Y().cleanup(),X().dataStreamStatus.status!==h.NULL&&X().closeDataStream(),Y().status=c.STOP,Y().emitter.emit(u.STREAM_STATUS,{status:Y().status})},t.prototype.destroy=function(){Y().status===c.START&&this.stop(),this.cleanup(),Y().status!==c.NULL&&(X().destroy(),Y().status=c.NULL,Y().emitter.emit(u.STREAM_STATUS,{status:Y().status}))},t.prototype.getStatus=function(){return Y().status},t.prototype.getBaseUrl=function(){return Y().baseURL},t.prototype.getChannelStatus=function(){return{audioChannelOpened:Y().audioChannelOpened,videoChannelOpened:Y().videoChannelOpened,dataChannelOpened:Y().dataChannelOpened,messageChannelOpened:Y().messageChannelOpened}},t.prototype.setBaseUrl=function(t){Y().throwIfStatus(c.START),t&&Y().baseURL!==t&&Y().setBaseUrl(t)},t.prototype.setVideoSDKLibDir=function(t){Y().throwIfStatus(c.START),t&&Y().videoSDKLibDir!==t&&Y().setVideoSDKLibDir(t)},t.prototype.createAudioChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),t=Y().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.audio.createChannel(n.createTransport(i.kAudio)),Y().setAudioChannel(o),o.onopen=function(){K.debug("audioChannel onopen()"),Y().audioChannelOpened=!0,Y().emitter.emit(u.AUDIO_CHANNEL_OPENED)},[4,o.open()];case 1:return r.sent(),[2]}}))}))},t.prototype.closeAudioChannel=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return(t=Y().audioChannel)?[4,t.close()]:(K.error("audioChannel is miss"),[2]);case 1:return e.sent(),Y().setAudioChannel(null),Y().setAudioSender(null),Y().setAudioReceiver(null),[2]}}))}))},t.prototype.createVideoChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),t=Y().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createChannel(n.createTransport(i.kVideo)),Y().setVideoChannel(o),o.onopen=function(){K.debug("videoChannel onopen()"),Y().videoChannelOpened=!0,Y().emitter.emit(u.VIDEO_CHANNEL_OPENED)},[4,o.open()];case 1:return r.sent(),[2]}}))}))},t.prototype.createDataChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),t=Y().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createChannel(n.createTransport(i.kData)),Y().setDataChannel(o),o.onopen=function(){K.debug("dataChannel onopen()")},[4,o.open()];case 1:return r.sent(),Y().dataChannelOpened=!0,Y().emitter.emit(u.DATA_CHANNEL_OPENED),[2]}}))}))},t.prototype.createMessageChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:Y().throwIfNotStatus(c.START),t=Y().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createDataChannel(n.createTransport(i.kMessage)),Y().setMessageChannel(o),o.onopen=function(){K.debug("messageChannel onopen()")},r.label=1;case 1:return r.trys.push([1,3,,4]),[4,o.open()];case 2:return r.sent(),[3,4];case 3:return a=r.sent(),console.error(a),[3,4];case 4:return Y().messageChannelOpened=!0,Y().emitter.emit(u.MESSAGE_CHANNEL_OPENED),[2]}}))}))},t.prototype.closeMessageChannel=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return(t=Y().messageChannel)?[4,t.close()]:(K.error("messageChannel is miss"),[2]);case 1:return e.sent(),[2]}}))}))},t.prototype.closeMessageStream=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return(e=Y().messageChannel)?t?[4,e.closeStream(t)]:[3,2]:(K.error("messageChannel is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.setupRemoteControl=function(t){var e=t.element,n=t.remote;return i(this,void 0,void 0,(function(){var t,i;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfMessageNotOpened(),e.setAttribute("tabIndex","-1"),e.style.outline="0",t=window.LIBRTC,[4,Y().messageChannel.createStream(t.DataType.kRemoteControl)];case 1:return i=r.sent(),Y().setRemoteControlStream(i),[2,t.setupRemoteControl(i,e,n)]}}))}))},t.prototype.getRemoteControlStream=function(){return Y().remoteControlStream},t.prototype.createAudioSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened(),(t=Y().audioChannel)?(e=Y().audioSender?Y().audioSender:t.createSender(),Y().setAudioSender(e),[2,e]):(K.error("audioChannel is miss"),[2,null])}))}))},t.prototype.removeAudioSender=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){if(Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened(),!(t=Y().audioSender))return K.error("audioSender is miss"),[2];try{t.stop(),Y().audioChannel&&Y().audioChannel.removeSender(t.ssrc)}catch(t){K.error("audioChannel removeSender() error: ",t)}return[2]}))}))},t.prototype.createVideoSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened(),(t=Y().videoChannel)?(e=Y().videoSender?Y().videoSender:t.createSender(),Y().setVideoSender(e),e.onbusy=function(){K.debug("onbusy"),Y().emitter.emit(u.CHANNEL_BUSY);var t=Y().audioChannel;t&&t.ans(!1)},[2,e]):(K.error("videoChannel is miss"),[2,null])}))}))},t.prototype.removeVideoSender=function(){Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened();var t=Y().videoSender;if(t)try{t.stop(),Y().videoChannel&&Y().videoChannel.removeSender(t.ssrc)}catch(t){K.error("videoChannel removeSender() error: ",t)}else K.error("videoSender is miss")},t.prototype.createDataSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened(),(t=Y().dataChannel)?(e=Y().dataSender?Y().dataSender:t.createSender(),Y().setDataSender(e),[2,e]):(K.error("dataChannel is miss"),[2,null])}))}))},t.prototype.removeDataSender=function(){Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened();var t=Y().dataSender;t?(t.stop(),Y().dataChannel&&Y().dataChannel.removeSender(t.ssrc),Y().setDataSender(null)):K.error("dataSender is miss")},t.prototype.createAudioReceiver=function(t){Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened();var e=Y().audioChannel;if(!e)return K.error("audioChannel is miss"),null;var n=e.createReceiver();return Y().setAudioReceiver(n),t?(n.setSink(t),Y().setAudioPlayer(t),e.audioElement&&(e.audioElement.srcObject=null),n):(K.error("audioPlayer is miss"),null)},t.prototype.createVideoReceiver=function(t){Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened();var e=t.ccid;if(K.debug("createVideoReceiver ccid: ",e),!e)return K.error("params is missing or params error"),null;var n=Y().videoChannel;return n?n.createReceiver(e):(K.error("videoChannel is miss"),null)},t.prototype.createDataReceiver=function(t){Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened();var e=t.ccid;if(K.debug("createDataReceiver ccid: ",e),!e)return K.error("params is missing or params error"),null;var n=Y().dataChannel;return n?n.createReceiver(e):(K.error("dataChannel is miss"),null)},t.prototype.removeVideoReceiver=function(t){return Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened(),t?(t.stop(),Y().videoChannel&&Y().videoChannel.removeReceiver(t.ssrc),null):t},t.prototype.removeDataReceiver=function(t){return Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened(),t?(t.stop(),Y().dataChannel&&Y().dataChannel.removeReceiver(t.ssrc),null):t},t.prototype.loadVideoRenderer=function(t,e){return void 0===e&&(e=!0),i(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened(),(n=Y().videoChannel)&&t?T||g?[4,n.offscreen.load(t.transferControlToOffscreen(),e)]:[3,2]:(K.error("videoChannel or el is miss"),[2,null]);case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return[2,i]}}))}))},t.prototype.unloadVideoRenderer=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened(),(e=Y().videoChannel)&&t?T||g?[4,e.offscreen.unload(t)]:[3,2]:(K.error("videoChannel or renderer is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.loadDataRenderer=function(t,e){return void 0===e&&(e=!0),i(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened(),(n=Y().dataChannel)&&t?T||g?[4,n.offscreen.load(t.transferControlToOffscreen(),e)]:[3,2]:(K.error("dataChannel or el is miss"),[2,null]);case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return[2,i]}}))}))},t.prototype.unloadDataRenderer=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened(),(e=Y().dataChannel)&&t?T||g?[4,e.offscreen.unload(t)]:[3,2]:(K.error("dataChannel or renderer is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.bindAudioChannelEvent=function(){Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened();var t=Y().audioChannel;t?t.onfocusing=function(t){if(Y().voiceActiveSsrc.length&&t.length){if(Y().voiceActiveSsrc[0]===t[0])return}else if(0===Y().voiceActiveSsrc.length&&0===t.length)return;Y().setVoiceActiveSsrc(t),Y().emitter.emit(u.VOICE_ACTIVE_SSRC,{ssrc:t})}:K.error("audioChannel is miss")},t.prototype.offAudioChannelEvent=function(){Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened();var t=Y().audioChannel;t?t.onfocusing=null:K.error("audioChannel is miss")},t.prototype.setAudioPlayerVolume=function(t){Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened();var e=Y().audioPlayer;e?(t=t>=0&&t<1?t:t>=1&&t<=100?t/100:t,e.volume=t):K.error("audioPlayer is miss")},t.prototype.getAudioSender=function(){return Y().status===c.START&&Y().audioChannelOpened&&Y().audioSender||null},t.prototype.getVideoSender=function(){return Y().status===c.START&&Y().videoChannelOpened&&Y().videoSender||null},t.prototype.getDataSender=function(){return Y().status===c.START&&Y().dataChannelOpened&&Y().dataSender||null},t.prototype.getVoiceActiveSsrc=function(){return Y().status===c.START&&Y().audioChannelOpened&&Y().voiceActiveSsrc||[]},t.prototype.getAudioChannelStats=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return Y().status===c.START&&Y().audioChannelOpened&&Y().audioChannel?[4,Y().audioChannel.getStats()]:[2,{}];case 1:return[2,t.sent()]}}))}))},t.prototype.createAudioStream=function(){return Y().throwIfStatus(c.NULL),X().captureAudioStream()},t.prototype.closeAudioStream=function(){return Y().throwIfStatus(c.NULL),X().closeAudioStream()},t.prototype.createVideoStream=function(){return Y().throwIfStatus(c.NULL),X().captureVideoStream()},t.prototype.closeVideoStream=function(){return Y().throwIfStatus(c.NULL),X().closeVideoStream()},t.prototype.createDataStream=function(){return Y().throwIfNotStatus(c.START),X().captureDataStream()},t.prototype.closeDataStream=function(){return X().closeDataStream()},t.prototype.getAudioStream=function(){return X()?X().audioStream:null},t.prototype.getVideoStream=function(){return X()?X().videoStream:null},t.prototype.getDataStream=function(){return X()?X().dataStream:null},t.prototype.getAudioStreamStatus=function(){return X()?X().audioStreamStatus:null},t.prototype.getVideoStreamStatus=function(){return X()?X().videoStreamStatus:null},t.prototype.getDataStreamStatus=function(){return X()?X().dataStreamStatus:null},t.prototype.getActiveAudioInputDevice=function(){return X()?X().audioInputDevice:null},t.prototype.getActiveAudioOutputDevice=function(){return X()?X().audioOutputDevice:null},t.prototype.getActiveVideoInputDevice=function(){return X()?X().videoInputDevice:null},t.prototype.getMicVolume=function(){return X()&&Y().status!==c.NULL?X().volumeAnalyser.volume:0},t.prototype.switchAudioInputDevice=function(t){Y().throwIfStatus(c.NULL),t&&(X().audioInputDeviceId=t)},t.prototype.switchAudioOutputDevice=function(t){Y().throwIfStatus(c.NULL),t&&(X().audioOutputDeviceId=t)},t.prototype.switchVideoInputDevice=function(t){Y().throwIfStatus(c.NULL),t&&(X().videoInputDeviceId=t)},t.prototype.getAudioInputDevices=function(){return X()?X().audioInputDevices:[]},t.prototype.getAudioOutputDevices=function(){return X()?X().audioOutputDevices:[]},t.prototype.getVideoInputDevices=function(){return X()?X().videoInputDevices:[]},t.EVENT=u,t.STATUS=c,t.MEDIA_STATUS=d,t.MEDIA_STREAM_STATUS=h,t.MEDIA_STREAM_DETAIL=l,t}()}));
{
"name": "@ylink-sdk/stream",
"version": "0.1.11-beta.0",
"version": "0.1.11",
"main": "dist/ylink-sdk-stream.umd.js",

@@ -5,0 +5,0 @@ "module": "dist/ylink-sdk-stream.es.js",

# @ylink-sdk/stream
@ylink-sdk/stream
基础库-媒体-wasm
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc