@stormstreaming/stormstreamer 0.9.0-beta.1 ā 0.9.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/amd/index.js +32 -22
- package/dist/cjs/index.js +3 -3
- package/dist/esm/index.js +3 -3
- package/dist/iife/index.js +3 -3
- package/dist/types/StormStreamer.d.ts +4 -2
- package/dist/types/events/StormStreamerEvent.d.ts +4 -0
- package/dist/types/playback/PlaybackController.d.ts +1 -0
- package/dist/umd/index.js +3 -3
- package/package.json +1 -1
package/dist/amd/index.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* contact@stormstreaming.com
|
|
5
5
|
* https://stormstreaming.com
|
|
6
6
|
*
|
|
7
|
-
* Version: 0.9.0-beta.
|
|
8
|
-
* Version: 11/29/2024,
|
|
7
|
+
* Version: 0.9.0-beta.2
|
|
8
|
+
* Version: 11/29/2024, 6:55:47 PM
|
|
9
9
|
*
|
|
10
10
|
* LEGAL NOTICE:
|
|
11
11
|
* This software is subject to the terms and conditions defined in
|
|
@@ -2603,7 +2603,6 @@
|
|
|
2603
2603
|
this.setPublishState(exports.PublishState.INITIALIZED);
|
|
2604
2604
|
if (this._cameraList == null || this._microphoneList == null) this.grabDevices();
|
|
2605
2605
|
const videoElement = this._main.getStageController().getScreenElement().getVideoElement();
|
|
2606
|
-
videoElement.muted = true;
|
|
2607
2606
|
videoElement.srcObject = stream;
|
|
2608
2607
|
videoElement.autoplay = true;
|
|
2609
2608
|
videoElement.playsInline = true;
|
|
@@ -2687,7 +2686,7 @@
|
|
|
2687
2686
|
case "connected":
|
|
2688
2687
|
this._logger.info(this, "WebRTCStreamer :: Event: onStreamerConnected");
|
|
2689
2688
|
this.setPublishState(exports.PublishState.PUBLISHED);
|
|
2690
|
-
|
|
2689
|
+
this.muteMicrophone(this._isMicrophoneMuted);
|
|
2691
2690
|
break;
|
|
2692
2691
|
case "disconnected":
|
|
2693
2692
|
this._logger.info(this, "WebRTCStreamer :: Event: onStreamerDisconnected");
|
|
@@ -2725,7 +2724,7 @@
|
|
|
2725
2724
|
ref: this._main
|
|
2726
2725
|
});
|
|
2727
2726
|
} else if (this._microphoneList.getSize() == 0) {
|
|
2728
|
-
this._main.dispatchEvent("
|
|
2727
|
+
this._main.dispatchEvent("noMicrophoneFound", {
|
|
2729
2728
|
ref: this._main
|
|
2730
2729
|
});
|
|
2731
2730
|
} else {
|
|
@@ -2797,21 +2796,24 @@
|
|
|
2797
2796
|
return this._selectedMicrophone;
|
|
2798
2797
|
}
|
|
2799
2798
|
muteMicrophone(microphoneState) {
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
} else {
|
|
2805
|
-
this._logger.success(this, "WebRTCStreamer :: Muting microphone");
|
|
2806
|
-
}
|
|
2807
|
-
for (let i = 0; i < this._stream.getAudioTracks().length; i++) this._stream.getAudioTracks()[i].enabled = microphoneState;
|
|
2808
|
-
this._isMicrophoneMuted = !microphoneState;
|
|
2799
|
+
this._isMicrophoneMuted = microphoneState;
|
|
2800
|
+
if (this._stream != null) {
|
|
2801
|
+
if (microphoneState) {
|
|
2802
|
+
this._logger.success(this, "WebRTCStreamer1 :: Unmuting microphone");
|
|
2809
2803
|
} else {
|
|
2810
|
-
this._logger.
|
|
2804
|
+
this._logger.success(this, "WebRTCStreamer1 :: Muting microphone");
|
|
2805
|
+
}
|
|
2806
|
+
if (this._stream.getAudioTracks() != null) {
|
|
2807
|
+
for (let i = 0; i < this._stream.getAudioTracks().length; i++) this._stream.getAudioTracks()[i].enabled = microphoneState;
|
|
2811
2808
|
}
|
|
2809
|
+
this._isMicrophoneMuted = !microphoneState;
|
|
2812
2810
|
} else {
|
|
2813
|
-
this._logger.warning(this, "WebRTCStreamer ::
|
|
2811
|
+
this._logger.warning(this, "WebRTCStreamer :: Stream object not present!");
|
|
2814
2812
|
}
|
|
2813
|
+
this._main.dispatchEvent("microphoneStateChange", {
|
|
2814
|
+
ref: this._main,
|
|
2815
|
+
isMuted: this._isMicrophoneMuted
|
|
2816
|
+
});
|
|
2815
2817
|
}
|
|
2816
2818
|
isMicrophoneMuted() {
|
|
2817
2819
|
return this._isMicrophoneMuted;
|
|
@@ -2846,10 +2848,13 @@
|
|
|
2846
2848
|
});
|
|
2847
2849
|
}
|
|
2848
2850
|
getCameraList() {
|
|
2849
|
-
return this._cameraList.getArray();
|
|
2851
|
+
return this._cameraList != null ? this._cameraList.getArray() : [];
|
|
2850
2852
|
}
|
|
2851
2853
|
getMicrophoneList() {
|
|
2852
|
-
return this._microphoneList.getArray();
|
|
2854
|
+
return this._microphoneList != null ? this._microphoneList.getArray() : [];
|
|
2855
|
+
}
|
|
2856
|
+
getPublishState() {
|
|
2857
|
+
return this._publishState;
|
|
2853
2858
|
}
|
|
2854
2859
|
getPlayer() {
|
|
2855
2860
|
return this._selectedPlayer;
|
|
@@ -3164,8 +3169,8 @@
|
|
|
3164
3169
|
constructor(streamConfig, autoInitialize = false) {
|
|
3165
3170
|
super();
|
|
3166
3171
|
this.DEV_MODE = true;
|
|
3167
|
-
this.STREAMER_VERSION = "0.9.0-beta.
|
|
3168
|
-
this.COMPILE_DATE = "11/29/2024,
|
|
3172
|
+
this.STREAMER_VERSION = "0.9.0-beta.2";
|
|
3173
|
+
this.COMPILE_DATE = "11/29/2024, 6:55:45 PM";
|
|
3169
3174
|
this.STREAMER_BRANCH = "Experimental";
|
|
3170
3175
|
this.STREAMER_PROTOCOL_VERSION = 1;
|
|
3171
3176
|
this._initialized = false;
|
|
@@ -3285,11 +3290,11 @@
|
|
|
3285
3290
|
}
|
|
3286
3291
|
getCameraList() {
|
|
3287
3292
|
var _a, _b;
|
|
3288
|
-
return (_b = (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.getCameraList()) !== null && _b !== void 0 ? _b :
|
|
3293
|
+
return (_b = (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.getCameraList()) !== null && _b !== void 0 ? _b : [];
|
|
3289
3294
|
}
|
|
3290
3295
|
getMicrophoneList() {
|
|
3291
3296
|
var _a, _b;
|
|
3292
|
-
return (_b = (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.getMicrophoneList()) !== null && _b !== void 0 ? _b :
|
|
3297
|
+
return (_b = (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.getMicrophoneList()) !== null && _b !== void 0 ? _b : [];
|
|
3293
3298
|
}
|
|
3294
3299
|
setCamera(cameraID) {
|
|
3295
3300
|
var _a;
|
|
@@ -3313,6 +3318,10 @@
|
|
|
3313
3318
|
var _a, _b;
|
|
3314
3319
|
return (_b = (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.isMicrophoneMuted()) !== null && _b !== void 0 ? _b : false;
|
|
3315
3320
|
}
|
|
3321
|
+
getPublishState() {
|
|
3322
|
+
var _a, _b;
|
|
3323
|
+
return (_b = (_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.getPublishState()) !== null && _b !== void 0 ? _b : exports.PublishState.NOT_INITIALIZED;
|
|
3324
|
+
}
|
|
3316
3325
|
publish(streamKey) {
|
|
3317
3326
|
var _a;
|
|
3318
3327
|
(_a = this._playbackController) === null || _a === void 0 ? void 0 : _a.publish(streamKey);
|
|
@@ -3447,6 +3456,7 @@
|
|
|
3447
3456
|
destroy() {
|
|
3448
3457
|
var _a, _b, _c;
|
|
3449
3458
|
this._logger.warning(this, "Destroying library instance, bye, bye!");
|
|
3459
|
+
if (this.DEV_MODE && 'StormStreamerArray' in window) window.StormStreamerArray[this._streamerID] = null;
|
|
3450
3460
|
this._initialized = false;
|
|
3451
3461
|
this._isRemoved = true;
|
|
3452
3462
|
(_a = this._networkController) === null || _a === void 0 ? void 0 : _a.getConnection().destroy();
|
package/dist/cjs/index.js
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* contact@stormstreaming.com
|
|
5
5
|
* https://stormstreaming.com
|
|
6
6
|
*
|
|
7
|
-
* Version: 0.9.0-beta.
|
|
8
|
-
* Version: 11/29/2024,
|
|
7
|
+
* Version: 0.9.0-beta.2
|
|
8
|
+
* Version: 11/29/2024, 6:55:47 PM
|
|
9
9
|
*
|
|
10
10
|
* LEGAL NOTICE:
|
|
11
11
|
* This software is subject to the terms and conditions defined in
|
|
12
12
|
* separate license conditions ('LICENSE.txt')
|
|
13
13
|
*
|
|
14
|
-
*/"use strict";class StormServerItem{constructor(e,t,i=443,n=!0){this.host=e,this.application=t,this.port=i,this.isSSL=n,this.hasFaild=!1}getHost(){return this.host}getApplication(){return this.application}getPort(){return this.port}getIfSSL(){return this.isSSL}getIfFaild(){return this.hasFaild}setAsFaild(e){this.hasFaild=e}getData(){return{serverURL:this.getHost(),application:this.getHost(),serverPort:this.getPort(),isSSL:this.getIfSSL()}}toString(){return"host: "+this.host+" | application: "+this.application+" | port: "+this.port+" | isSSL: "+this.isSSL}}class StreamData{constructor(e){this._serverList=new Array,this._sourceList=new Array,this._streamKey=null,this.parse(e)}parse(e){if(this._streamConfig=e,!this._streamConfig)throw new Error("Stream configuration is missing. Please check stream config!");if(void 0===this._streamConfig.serverList||null===this._streamConfig.serverList)throw new Error("StormLibrary: Server list configuration is missing. Please check the config!");if(0===this._streamConfig.serverList.length)throw new Error("StormLibrary: Server list configuration is empty. Please check the config!");for(let i=0;i<this._streamConfig.serverList.length;i++){let e,t;if(null==this._streamConfig.serverList[i].host)throw new Error('Error while parsing server object ("host" field is missing). Please check player config!');if(e=this._streamConfig.serverList[i].host,null==this._streamConfig.serverList[i].application)throw new Error('Error while parsing server object ("application" field is missing). Please check player config!');t=this._streamConfig.serverList[i].application;var n=null!=(n=this._streamConfig.serverList[i].port)?n:StreamData.DEFAULT_CONNECTION_PORT,o=null!=(o=this._streamConfig.serverList[i].ssl)?o:StreamData.IS_SSL_BY_DEFAULT;this._serverList.push(new StormServerItem(e,t,n,o))}this._streamKey=null!=(e=this._streamConfig.streamKey)?e:this._streamKey}getServerList(){return this._serverList}getSourceList(){return this._sourceList}get streamKey(){return this._streamKey}set streamKey(e){this._streamKey=e}set serverList(e){this._serverList=e}set sourceList(e){this._sourceList=e}clearSourceList(){this._sourceList=new Array}clearServerList(){this._serverList=new Array}print(t,e=!1){if(StreamData.PRINT_ON_STARTUP||e){t.info(this,"Server List:");for(let e=0;e<this._serverList.length;e++)t.info(this,"=> ["+e+"] "+this._serverList[e].toString());t.info(this,"StreamKey: "+this._streamKey)}}}var ScalingType,SizeCalculationType,LogType;StreamData.PRINT_ON_STARTUP=!0,StreamData.DEFAULT_CONNECTION_PORT=443,StreamData.IS_SSL_BY_DEFAULT=!0,function(e){e.FILL="fill",e.LETTER_BOX="letterbox",e.CROP="crop",e.ORIGINAL="original"}(ScalingType=ScalingType||{}),function(e){e.CLIENT_DIMENSIONS="clientDimensions",e.BOUNDING_BOX="boundingBox",e.FULL_BOX="fullBox"}(SizeCalculationType=SizeCalculationType||{});class VideoData{constructor(e){this._scalingMode=ScalingType.LETTER_BOX,this._aspectRatio="none",this._videoWidthValue=100,this._isVideoWidthInPixels=!1,this._wasVideoWidthProvided=!1,this._videoHeightValue=100,this._isVideoHeightInPixels=!1,this._wasVideoHeightProvided=!1,this._resizeDebounce=250,this._parentSizeCalculationMethod=SizeCalculationType.CLIENT_DIMENSIONS,this.parse(e)}parse(e){if(this.videoConfig=e,null==this.videoConfig)throw new Error("Missing video configuration. Please check player config!");if(null!=this.videoConfig.aspectRatio){var e=new RegExp("^[0-9]*\\.?[0-9]+:[0-9]*\\.?[0-9]+$"),t=this.videoConfig.aspectRatio;if(!e.test(t))throw new Error('Parameter "aspectRatio" - must match "number:number" pattern ');this._aspectRatio=t,this._aspectRatio=this.videoConfig.aspectRatio}if(null!=this.videoConfig.scalingMode)switch(this.videoConfig.scalingMode.toLowerCase()){case"fill":this._scalingMode=ScalingType.FILL;break;case"letterbox":this._scalingMode=ScalingType.LETTER_BOX;break;case"crop":this._scalingMode=ScalingType.CROP;break;case"original":this._scalingMode=ScalingType.ORIGINAL;break;default:throw new Error("Unknown video scaling mode. Please check player config!")}if(void 0!==this.videoConfig.width){if(null===this.videoConfig.width)throw new Error('Parameter "width" cannot be empty');if("number"==typeof this.videoConfig.width)this._videoWidthValue=this.videoConfig.width,this._isVideoWidthInPixels=!0;else{if("string"!=typeof this.videoConfig.width)throw new Error('Unknown type for parameter "width" - it must be a number or a string! ');this.videoConfig.width.toLowerCase().endsWith("px")?(this._videoWidthValue=parseInt(this.videoConfig.width),this._isVideoWidthInPixels=!0):this.videoConfig.width.toLowerCase().endsWith("%")&&(this._videoWidthValue=parseInt(this.videoConfig.width),this._isVideoWidthInPixels=!1)}this._wasVideoWidthProvided=!0}if(void 0!==this.videoConfig.height){if(null===this.videoConfig.height)throw new Error('Parameter "height" cannot be empty');if("number"==typeof this.videoConfig.height)this._videoHeightValue=this.videoConfig.height,this._isVideoHeightInPixels=!0;else{if("string"!=typeof this.videoConfig.height)throw new Error('Unknown type for parameter "height" - it must be a number or a string!');this.videoConfig.height.toLowerCase().endsWith("px")?(this._videoHeightValue=parseInt(this.videoConfig.height),this._isVideoHeightInPixels=!0):this.videoConfig.height.toLowerCase().endsWith("%")&&(this._videoHeightValue=parseInt(this.videoConfig.height),this._isVideoHeightInPixels=!1)}this._wasVideoHeightProvided=!0}if(void 0!==this.videoConfig.sizeCalculationMethod&&null!==this.videoConfig.sizeCalculationMethod)switch(this.videoConfig.sizeCalculationMethod){case"clientDimensions":this._parentSizeCalculationMethod=SizeCalculationType.CLIENT_DIMENSIONS;break;case"boundingBox":this._parentSizeCalculationMethod=SizeCalculationType.BOUNDING_BOX;break;case"fullBox":this._parentSizeCalculationMethod=SizeCalculationType.FULL_BOX}this._containerID=null!=(e=this.videoConfig.containerID)?e:null,this._resizeDebounce=null!=(t=this.videoConfig.resizeDebounce)?t:this._resizeDebounce}get scalingMode(){return this._scalingMode}get containerID(){return this._containerID}get videoWidthValue(){return this._videoWidthValue}get videoWidthInPixels(){return this._isVideoWidthInPixels}get videoWidthProvided(){return this._wasVideoWidthProvided}get videoHeightValue(){return this._videoHeightValue}get videoHeightInPixels(){return this._isVideoHeightInPixels}get videoHeightProvided(){return this._wasVideoHeightProvided}get aspectRatio(){return this._aspectRatio}get resizeDebounce(){return this._resizeDebounce}set resizeDebounce(e){this._resizeDebounce=e}set videoWidthValue(e){this._videoWidthValue=e}set videoWidthInPixels(e){this._isVideoWidthInPixels=e}set videoHeightValue(e){this._videoHeightValue=e}set videoHeightInPixels(e){this._isVideoHeightInPixels=e}set containerID(e){this._containerID=e}set scalingMode(e){switch(e.toLowerCase()){case"fill":this._scalingMode=ScalingType.FILL;break;case"letterbox":this._scalingMode=ScalingType.LETTER_BOX;break;case"crop":this._scalingMode=ScalingType.CROP;break;case"original":this._scalingMode=ScalingType.ORIGINAL;break;default:throw new Error("Unknown video scaling mode. Please check player config!")}}get parentSizeCalculationMethod(){return this._parentSizeCalculationMethod}print(e){let t="";switch(this._scalingMode){case ScalingType.FILL:t="fill";break;case ScalingType.LETTER_BOX:t="letterbox";break;case ScalingType.CROP:t="crop";break;case ScalingType.ORIGINAL:t="original"}e.info(this,"VideoConfig :: containerID: "+this._containerID),e.info(this,"VideoConfig :: scalingMode: "+t),e.info(this,"VideoConfig :: width: "+this._videoWidthValue+(this._isVideoWidthInPixels?"px":"%")+(this._wasVideoWidthProvided?" (provided)":" (default)")),e.info(this,"VideoConfig :: height: "+this._videoHeightValue+(this._isVideoHeightInPixels?"px":"%")+(this._wasVideoHeightProvided?" (provided)":" (default)")),e.info(this,"VideoConfig :: aspectRatio: "+this._aspectRatio)}}!function(e){e[e.TRACE=0]="TRACE",e[e.INFO=1]="INFO",e[e.SUCCESS=2]="SUCCESS",e[e.WARNING=3]="WARNING",e[e.ERROR=4]="ERROR"}(LogType=LogType||{});class DebugData{constructor(e){this._consoleLogEnabled=!1,this._enabledConsoleTypes=[LogType.INFO,LogType.ERROR,LogType.SUCCESS,LogType.TRACE,LogType.WARNING],this._consoleMonoColor=!1,this._containerLogEnabled=!1,this._enabledContainerTypes=[LogType.INFO,LogType.ERROR,LogType.SUCCESS,LogType.TRACE,LogType.WARNING],this._containerLogMonoColor=!1,this.parse(e)}parse(e){this._debugConfig=e,this._debugConfig&&(this._consoleLogEnabled=null!=(e=null==(e=null==(e=this._debugConfig)?void 0:e.console)?void 0:e.enabled)?e:this._consoleLogEnabled,this._consoleMonoColor=null!=(e=null==(e=null==(e=this._debugConfig)?void 0:e.console)?void 0:e.monoColor)?e:this._consoleMonoColor,this._enabledConsoleTypes=null!=(e=this.parseLogTypes(null==(e=null==(e=this._debugConfig)?void 0:e.console)?void 0:e.logTypes))?e:this._enabledConsoleTypes,this._containerLogEnabled=null!=(e=null==(e=null==(e=this._debugConfig)?void 0:e.container)?void 0:e.enabled)?e:this._containerLogEnabled,this._containerLogMonoColor=null!=(e=null==(e=null==(e=this._debugConfig)?void 0:e.container)?void 0:e.monoColor)?e:this._containerLogMonoColor,this._enabledContainerTypes=null!=(e=this.parseLogTypes(null==(e=null==(e=this._debugConfig)?void 0:e.container)?void 0:e.logTypes))?e:this._enabledContainerTypes,this._containerID=null!=(e=null==(e=null==(e=this._debugConfig)?void 0:e.container)?void 0:e.containerID)?e:this._containerID)}parseLogTypes(e){return null==e?void 0:e.map(e=>{switch(e.toLowerCase()){case"info":return LogType.INFO;case"error":return LogType.ERROR;case"warning":return LogType.WARNING;case"success":return LogType.SUCCESS;case"trace":return LogType.TRACE;default:throw new Error("Unsupported log type: "+e)}})}get consoleLogEnabled(){return this._consoleLogEnabled}set consoleLogEnabled(e){this._consoleLogEnabled=e}get enabledConsoleTypes(){return this._enabledConsoleTypes}set enabledConsoleTypes(t){this._enabledConsoleTypes=new Array;for(let e=0;e<t.length;e++)switch(t[e].toLowerCase()){case"info":this._enabledConsoleTypes.push(LogType.INFO);break;case"error":this._enabledConsoleTypes.push(LogType.ERROR);break;case"warning":this._enabledConsoleTypes.push(LogType.WARNING);break;case"success":this._enabledConsoleTypes.push(LogType.SUCCESS);break;case"trace":this._enabledConsoleTypes.push(LogType.TRACE)}}get containerLogEnabled(){return this._containerLogEnabled}set containerLogEnabled(e){this._consoleLogEnabled=e}get consoleLogMonoColor(){return this._consoleMonoColor}set consoleLogMonoColor(e){this._consoleMonoColor=e}get enabledContainerTypes(){return this._enabledContainerTypes}set enabledContainerTypes(t){this._enabledContainerTypes=new Array;for(let e=0;e<t.length;e++)switch(t[e].toLowerCase()){case"info":this._enabledContainerTypes.push(LogType.INFO);break;case"error":this._enabledContainerTypes.push(LogType.ERROR);break;case"warning":this._enabledContainerTypes.push(LogType.WARNING);break;case"success":this._enabledContainerTypes.push(LogType.SUCCESS);break;case"trace":this._enabledContainerTypes.push(LogType.TRACE)}}get containerID(){return this._containerID}set containerID(e){this._containerID=e}get containerLogMonoColor(){return this._containerLogMonoColor}set containerLogMonoColor(e){this._containerLogMonoColor=e}print(e,t=!1){if(DebugData.PRINT_ON_STARTUP||t){let t="";for(let e=0;e<this._enabledConsoleTypes.length;e++)switch(this._enabledConsoleTypes[e]){case LogType.TRACE:t+="TRACE, ";break;case LogType.SUCCESS:t+="SUCCESS, ";break;case LogType.WARNING:t+="WARNING, ";break;case LogType.INFO:t+="INFO, ";break;case LogType.ERROR:t+="ERROR, "}e.info(this,"Console:: enabled: "+this._consoleLogEnabled),e.info(this,"Console:: logTypes: "+t),e.info(this,"Console:: monoColor: "+this._consoleMonoColor);let i="";for(let e=0;e<this._enabledContainerTypes.length;e++)switch(this._enabledContainerTypes[e]){case LogType.TRACE:i+="TRACE, ";break;case LogType.SUCCESS:i+="SUCCESS, ";break;case LogType.WARNING:i+="WARNING, ";break;case LogType.INFO:i+="INFO, ";break;case LogType.ERROR:i+="ERROR, "}e.info(this,"Container:: enabled: "+this._containerLogEnabled),e.info(this,"Container:: logTypes: "+i),e.info(this,"Container:: containerID: "+this._containerID),e.info(this,"Container:: monoColor: "+this._consoleMonoColor)}}}DebugData.PRINT_ON_STARTUP=!0;class AudioData{constructor(e){this._startVolume=100,this._isMuted=!1,this.parse(e)}parse(e){this._audioConfig=e,this._audioConfig&&(this._startVolume=null!=(e=null==(e=this._audioConfig)?void 0:e.startVolume)?e:this._startVolume,this._isMuted=null!=(e=null==(e=this._audioConfig)?void 0:e.muted)?e:this._isMuted)}get startVolume(){return this._startVolume}set startVolume(e){this._startVolume=e}get muted(){return this._isMuted}set muted(e){this._isMuted=e}print(e,t=!1){(AudioData.PRINT_ON_STARTUP||t)&&e.info(this,"Audio :: startVolume: "+this._startVolume+" | isMuted: "+this._isMuted)}}AudioData.PRINT_ON_STARTUP=!0;class StorageData{constructor(e){this._enabled=!0,this._prefix="storm",this.parse(e)}parse(e){this._storageConfig=e,this._enabled=null!=(e=null==(e=this._storageConfig)?void 0:e.enabled)?e:this._enabled,this._prefix=null!=(e=null==(e=this._storageConfig)?void 0:e.prefix)?e:this._prefix}get enabled(){return this._enabled}set enabled(e){this._enabled=e}get prefix(){return this._prefix}set prefix(e){this._prefix=e}print(e,t=!1){(StorageData.PRINT_ON_STARTUP||t)&&e.info(this,"Storage :: startVolume: "+this._enabled+" | prefix: "+this._prefix)}}StorageData.PRINT_ON_STARTUP=!0;class SettingsData{constructor(e){this._restartOnError=!0,this._reconnectTime=1,this._autoStart=!1,this._autoConnect=!0,this.startOnDOMReady=!1,this.iOSOnDomReadyFix=!0,this._restartOnFocus=!0,this.parse(e)}parse(e){this._settingsConfig=e,this._autoConnect=null!=(e=this._settingsConfig.autoConnect)?e:this._autoConnect,this._autoStart=null!=(e=this._settingsConfig.autoStart)?e:this._autoStart,this._restartOnFocus=null!=(e=this._settingsConfig.restartOnFocus)?e:this._restartOnFocus,this._restartOnError=null!=(e=this._settingsConfig.restartOnError)?e:this._restartOnError,this._reconnectTime=null!=(e=this._settingsConfig.reconnectTime)?e:this._reconnectTime,this._videoData=new VideoData(null!=(e=this._settingsConfig.video)?e:null),this._audioData=new AudioData(null!=(e=this._settingsConfig.audio)?e:null),this._storageData=new StorageData(null!=(e=this._settingsConfig.storage)?e:null),this._debugData=new DebugData(null!=(e=this._settingsConfig.debug)?e:null)}getAudioData(){return this._audioData}getVideoData(){return this._videoData}getStorageData(){return this._storageData}getIfRestartOnError(){return this._restartOnError}getReconnectTime(){return this._reconnectTime}get autoStart(){return this._autoStart}set autoStart(e){this._autoStart=e}get autoConnect(){return this._autoConnect}get restartOnFocus(){return this._restartOnFocus}getDebugData(){return this._debugData}getIfStartOnDOMReadyEnabled(){return this.startOnDOMReady}getIfIOSOnDomStartFixEnabled(){return this.iOSOnDomReadyFix}print(e,t=!1){(SettingsData.PRINT_ON_STARTUP||t)&&(e.info(this,"SettingsConfig :: autoConnect: "+this._autoConnect),e.info(this,"SettingsConfig :: autoStart: "+this._autoStart),e.info(this,"SettingsConfig :: restartOnError: "+this._restartOnError),e.info(this,"SettingsConfig :: reconnectTime: "+this._reconnectTime),e.info(this,"SettingsConfig :: enabledProtocols: "),this._videoData.print(e),this._audioData.print(e),this._debugData.print(e),this._debugData.print(e))}}SettingsData.PRINT_ON_STARTUP=!0;class ConfigManager{constructor(e){this.PRINT_ON_STARTUP=!0,this.demoMode=!1,this.parse(e)}parse(e){if(this.configTemplate=e,null==this.configTemplate.stream)throw new Error("No stream field was provided. Please check your player config!");this.streamData=new StreamData(this.configTemplate.stream),this.settingsData=new SettingsData(null!=(e=this.configTemplate.settings)?e:null),this.demoMode=null!=(e=this.configTemplate.demoMode)&&e}getStreamData(){return this.streamData}getSettingsData(){return this.settingsData}getIfDemoMode(){return this.demoMode}print(e,t=!1){(this.PRINT_ON_STARTUP||t)&&(this.streamData.print(e),this.settingsData.print(e))}}class EventDispatcher{constructor(){this._isRemoved=!1,this._listeners={}}addEventListener(t,i,e=!0){this._listeners[t]||(this._listeners[t]=[]);let n=!1;if(null!=this._listeners[t]&&0<this._listeners[t].length)for(let e=0;e<this._listeners[t].length;e++)if(this._listeners[t][e][1]==i){n=!0;break}return this._logger.success(this,"Registering a new event: "+t),!n&&(this._listeners[t].push([t,i,e]),!0)}removeEventListener(t,i){let n=!1;if(null!=this._listeners[t]&&0<this._listeners[t].length)for(let e=0;e<this._listeners[t].length;e++){var o=this._listeners[t][e];if(i){if(o[1]==i){if(1!=o[2])break;n=!0,this._listeners[t].splice(e,1);break}}else n=!0,1==o[2]&&this._listeners[t].splice(e,1)}return this._logger.success(this,"Removing listener: "+t),n}removeAllEventListeners(){this._logger.success(this,"Removing all listeners!");for(const i in this._listeners){var e=i,t=this._listeners[e];if(t&&0<t.length)for(let e=t.length-1;0<=e;e--)!0===t[e][2]&&t.splice(e,1)}}dispatchEvent(t,i){if(!this._isRemoved&&null!=this._listeners[t]&&0<this._listeners[t].length)for(let e=0;e<this._listeners[t].length;e++)this._listeners[t][e][1].call(this,i)}}class NumberUtilities{static addLeadingZero(e){return e<10?"0"+e:String(e)}static isNear(e,t,i){return Math.abs(e-t)<=i}static generateUniqueString(t){let i="";var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=n.length;for(let e=0;e<t;e++)i+=n.charAt(Math.floor(Math.random()*o));return i}}NumberUtilities.parseValue=e=>{var t;return"string"==typeof e?(t=e.toLowerCase().endsWith("px"),{value:parseInt(e,10),isPixels:t}):{value:e,isPixels:!0}};class Logger{constructor(e,t){this.colorOrder=["red","green","blue","orange","black","violet"],this._logMemory=[],this._streamerInstanceID=-1,this._debugConfig=e,this._stormStreamer=t,this._streamerInstanceID=this._stormStreamer.getStreamerID();e=this.colorOrder.length<t.getStreamerID()?this.colorOrder.length-1:t.getStreamerID();this._monoColor=this.colorOrder[e]}info(e,t){e=this.logData(e,t);this._debugConfig.consoleLogEnabled&&0<=this._debugConfig.enabledConsoleTypes.indexOf(LogType.INFO)&&(t=this._debugConfig.consoleLogMonoColor?this._monoColor:Logger.INFO_COLOR,console.log("%c "+e,"color: "+t)),this._debugConfig.containerLogEnabled&&0<=this._debugConfig.enabledContainerTypes.indexOf(LogType.INFO)&&(t=this._debugConfig.containerLogMonoColor?this._monoColor:Logger.INFO_COLOR,this.writeToContainer(e,t))}warning(e,t){e=this.logData(e,t);this._debugConfig.consoleLogEnabled&&0<=this._debugConfig.enabledConsoleTypes.indexOf(LogType.WARNING)&&(t=this._debugConfig.consoleLogMonoColor?this._monoColor:Logger.WARNING_COLOR,console.log("%c "+e,"color: "+t)),this._debugConfig.containerLogEnabled&&0<=this._debugConfig.enabledContainerTypes.indexOf(LogType.WARNING)&&(t=this._debugConfig.containerLogMonoColor?this._monoColor:Logger.WARNING_COLOR,this.writeToContainer(e,t))}error(e,t){e=this.logData(e,t);this._debugConfig.consoleLogEnabled&&0<=this._debugConfig.enabledConsoleTypes.indexOf(LogType.ERROR)&&(t=this._debugConfig.consoleLogMonoColor?this._monoColor:Logger.ERROR_COLOR,console.log("%c "+e,"color: "+t)),this._debugConfig.containerLogEnabled&&0<=this._debugConfig.enabledContainerTypes.indexOf(LogType.ERROR)&&(t=this._debugConfig.containerLogMonoColor?this._monoColor:Logger.ERROR_COLOR,this.writeToContainer(e,t))}success(e,t){e=this.logData(e,t);this._debugConfig.consoleLogEnabled&&0<=this._debugConfig.enabledConsoleTypes.indexOf(LogType.SUCCESS)&&(t=this._debugConfig.consoleLogMonoColor?this._monoColor:Logger.SUCCESS_COLOR,console.log("%c "+e,"color: "+t)),this._debugConfig.containerLogEnabled&&0<=this._debugConfig.enabledContainerTypes.indexOf(LogType.SUCCESS)&&(t=this._debugConfig.containerLogMonoColor?this._monoColor:Logger.SUCCESS_COLOR,this.writeToContainer(e,t))}trace(e,t){e=this.logData(e,t);this._debugConfig.consoleLogEnabled&&0<=this._debugConfig.enabledConsoleTypes.indexOf(LogType.TRACE)&&(t=this._debugConfig.consoleLogMonoColor?this._monoColor:Logger.TRACE_COLOR,console.log("%c "+e,"color: "+t)),this._debugConfig.containerLogEnabled&&0<=this._debugConfig.enabledContainerTypes.indexOf(LogType.TRACE)&&(t=this._debugConfig.containerLogMonoColor?this._monoColor:Logger.TRACE_COLOR,this.writeToContainer(e,t))}logData(e,t){var i=new Date,n=NumberUtilities.addLeadingZero(i.getHours()),o=NumberUtilities.addLeadingZero(i.getMinutes()),i=NumberUtilities.addLeadingZero(i.getSeconds());let s=String(this._streamerInstanceID);0<=this._streamerInstanceID&&(s+="|"+this._streamerInstanceID);n="[Storm-ID:"+s+"] ["+n+":"+o+":"+i+"] :: "+t;return this._logMemory.push(n),n}writeToContainer(e,t){var i,n=this._debugConfig.containerID;n&&(n=document.getElementById(n),(i=document.createElement("span")).innerText=e,i.style.color=t,n.appendChild(i))}setPlayerID(e){this._streamerInstanceID=e}getAllLogs(){return this._logMemory}}Logger.INFO_COLOR="blue",Logger.WARNING_COLOR="orange",Logger.ERROR_COLOR="red",Logger.SUCCESS_COLOR="green",Logger.TRACE_COLOR="black";class ClientUser{constructor(){this.bandwidthCapabilities=0}setBandwidthCapabilities(e){this.bandwidthCapabilities=e}getBandwidthCapabilities(){return this.bandwidthCapabilities}}class UserCapabilities{static hasWebSocketsSupport(){return null!=window.WebSocket}static isMobile(){return new RegExp("Mobile|mini|Fennec|Android|iP(ad|od|hone)").test(navigator.userAgent)}static isCookieEnabled(){let e=!!navigator.cookieEnabled;return"undefined"!=typeof navigator.cookieEnabled||e||(document.cookie="testcookie",e=-1!=document.cookie.indexOf("testcookie")),e}static getOSVersion(){let e="Unknown version",t=UserCapabilities.getOS();if(null!=t){var i;switch(new RegExp("Windows").test(t)&&(i=new RegExp("Windows (.*)"),e=null!=i.exec(t)[1]?i.exec(t)[1]:e,t="Windows"),t){case"Mac OS":case"Mac OS X":case"Android":var n=new RegExp("(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([\\.\\_\\d]+)");e=n.exec(navigator.userAgent)[1];break;case"iOS":n=new RegExp("OS (\\d+)_(\\d+)_?(\\d+)?");e=(e=n.exec(navigator.userAgent))[1]+"."+e[2]+"."+(0|e[3])}}return e}static getBrowserName(){return UserCapabilities.getFullBrowser().name}static getBrowserVersion(){return UserCapabilities.getFullBrowser().version}static getFullBrowser(){var e=navigator.userAgent;let t=navigator.appName,i=""+parseFloat(navigator.appVersion),n=parseInt(navigator.appVersion,10),o,s,r;return-1!=(s=e.indexOf("Opera"))?(t="Opera",i=e.substring(s+6),-1!=(s=e.indexOf("Version"))&&(i=e.substring(s+8))):-1!=(s=e.indexOf("MSIE"))?(t="Microsoft Internet Explorer",i=e.substring(s+5)):"Netscape"==t&&-1!=e.indexOf("Trident/")?(t="Microsoft Internet Explorer",i=e.substring(s+5),-1!=(s=e.indexOf("rv:"))&&(i=e.substring(s+3))):-1!=(s=e.indexOf("Chrome"))?(t="Chrome",(-1<e.indexOf("FBAV")||-1<e.indexOf("FBAN"))&&(t="Facebook"),-1<e.indexOf("OPR")&&(t="Opera"),-1<e.indexOf("SamsungBrowser")&&(t="Samsung"),i=e.substring(s+7)):-1!=(s=e.indexOf("Safari"))?(t="Safari",i=e.substring(s+7),-1!=(s=e.indexOf("Version"))&&(i=e.substring(s+8)),-1!=e.indexOf("CriOS")&&(t="Chrome"),-1!=e.indexOf("FxiOS")&&(t="Firefox")):-1!=(s=e.indexOf("Firefox"))?(t="Firefox",i=e.substring(s+8)):(o=e.lastIndexOf(" ")+1)<(s=e.lastIndexOf("/"))&&(t=e.substring(o,s),i=e.substring(s+1),t.toLowerCase()==t.toUpperCase())&&(t=navigator.appName),-1!=(r=(i=-1!=(r=(i=-1!=(r=i.indexOf(";"))?i.substring(0,r):i).indexOf(" "))?i.substring(0,r):i).indexOf(")"))&&(i=i.substring(0,r)),n=parseInt(""+i,10),isNaN(n)&&(i=""+parseFloat(navigator.appVersion),n=parseInt(navigator.appVersion,10)),{name:t,fullVersion:i,version:n}}static getOS(){let e="Unknown OS";var t,i=[{os:"Windows 10",code:"(Windows 10.0|Windows NT 10.0)"},{os:"Windows 8.1",code:"(Windows 8.1|Windows NT 6.3)"},{os:"Windows 8",code:"(Windows 8|Windows NT 6.2)"},{os:"Windows 7",code:"(Windows 7|Windows NT 6.1)"},{os:"Windows Vista",code:"Windows NT 6.0"},{os:"Windows Server 2003",code:"Windows NT 5.2"},{os:"Windows XP",code:"(Windows NT 5.1|Windows XP)"},{os:"Windows 2000",code:"(Windows NT 5.0|Windows 2000)"},{os:"Windows ME",code:"(Win 9x 4.90|Windows ME)"},{os:"Windows 98",code:"(Windows 98|Win98)"},{os:"Windows 95",code:"(Windows 95|Win95|Windows_95)"},{os:"Windows NT 4.0",code:"(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)"},{os:"Windows CE",code:"Windows CE"},{os:"Windows 3.11",code:"Win16"},{os:"Android",code:"Android"},{os:"Open BSD",code:"OpenBSD"},{os:"Sun OS",code:"SunOS"},{os:"Chrome OS",code:"CrOS"},{os:"Linux",code:"(Linux|X11(?!.*CrOS))"},{os:"iOS",code:"(iPhone|iPad|iPod)"},{os:"Mac OS X",code:"Mac OS X"},{os:"Mac OS",code:"(Mac OS|MacPPC|MacIntel|Mac_PowerPC|Macintosh)"},{os:"QNX",code:"QNX"},{os:"UNIX",code:"UNIX"},{os:"BeOS",code:"BeOS"},{os:"OS/2",code:"OS\\/2"},{os:"Search Bot",code:"(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\\/Teoma|ia_archiver)"}];for(t in i){var n=i[t];if(new RegExp(n.code).test(navigator.userAgent)){e=n.os;break}}return e}static hasWebRTCSupport(){let t=!1;try{navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||window.RTCPeerConnection;t=!0}catch(e){t=!1}return t}static hasHLSSupport(e){return null!==e&&Boolean(e.canPlayType("application/vnd.apple.mpegURL")||e.canPlayType("audio/mpegurl"))}static hasMSESupport(){var e=window.MediaSource=window.MediaSource||window.WebKitMediaSource;return window.SourceBuffer=window.SourceBuffer||window.WebKitSourceBuffer,e&&"function"==typeof e.isTypeSupported}static hasMMSSupport(){return window.ManagedMediaSource}static isSSL(){return"https:"===location.protocol}}class StorageManager{constructor(e){var t;this.LOG_ACTIVITY=!1,this.isEnabled=!0,this.prefix="",this.logger=e.getLogger(),this.isEnabled=null!=(t=null==(t=null==(t=e.getConfigManager())?void 0:t.getSettingsData())?void 0:t.getStorageData().enabled)?t:this.isEnabled,this.prefix=null!=(t=null==(e=null==(t=e.getConfigManager())?void 0:t.getSettingsData())?void 0:e.getStorageData().prefix)?t:this.prefix,this.LOG_ACTIVITY&&this.logger.info(this,"Creating new StorageManager")}saveField(e,t){1==this.isEnabled&&(this.LOG_ACTIVITY&&this.logger.info(this,"Saving data: "+e+" | "+t),localStorage.setItem(this.prefix+e,t))}getField(e){var t;return 1==this.isEnabled?(t=localStorage.getItem(this.prefix+e),this.LOG_ACTIVITY&&this.logger.info(this,"Grabbing data: "+e+" | "+t),t):null}}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var FUNC_ERROR_TEXT="Expected a function",NAN=NaN,symbolTag="[object Symbol]",reTrim=/^\s+|\s+$/g,reIsBadHex=/^[-+]0x[0-9a-f]+$/i,reIsBinary=/^0b[01]+$/i,reIsOctal=/^0o[0-7]+$/i,freeParseInt=parseInt,freeGlobal="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")(),objectProto=Object.prototype,objectToString=objectProto.toString,nativeMax=Math.max,nativeMin=Math.min,now=function(){return root.Date.now()};function debounce(n,i,e){var o,s,r,a,l,h,c=0,g=!1,d=!1,t=!0;if("function"!=typeof n)throw new TypeError(FUNC_ERROR_TEXT);function u(e){var t=o,i=s;return o=s=void 0,c=e,a=n.apply(i,t)}function _(e){var t=e-h;return void 0===h||i<=t||t<0||d&&r<=e-c}function p(){var e,t=now();if(_(t))return m(t);l=setTimeout(p,(e=i-((t=t)-h),d?nativeMin(e,r-(t-c)):e))}function m(e){return l=void 0,t&&o?u(e):(o=s=void 0,a)}function C(){var e=now(),t=_(e);if(o=arguments,s=this,h=e,t){if(void 0===l)return c=e=h,l=setTimeout(p,i),g?u(e):a;if(d)return l=setTimeout(p,i),u(h)}return void 0===l&&(l=setTimeout(p,i)),a}return i=toNumber(i)||0,isObject(e)&&(g=!!e.leading,d="maxWait"in e,r=d?nativeMax(toNumber(e.maxWait)||0,i):r,t="trailing"in e?!!e.trailing:t),C.cancel=function(){void 0!==l&&clearTimeout(l),o=h=s=l=void(c=0)},C.flush=function(){return void 0===l?a:m(now())},C}function isObject(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function isObjectLike(e){return!!e&&"object"==typeof e}function isSymbol(e){return"symbol"==typeof e||isObjectLike(e)&&objectToString.call(e)==symbolTag}function toNumber(e){if("number"==typeof e)return e;if(isSymbol(e))return NAN;if("string"!=typeof(e=isObject(e)?isObject(t="function"==typeof e.valueOf?e.valueOf():e)?t+"":t:e))return 0===e?e:+e;e=e.replace(reTrim,"");var t=reIsBinary.test(e);return t||reIsOctal.test(e)?freeParseInt(e.slice(2),t?2:8):reIsBadHex.test(e)?NAN:+e}var InputType,ConnectionState,lodash_debounce=debounce,debounce$1=getDefaultExportFromCjs(debounce);class ScreenElement{constructor(e){this.LOG_ACTIVITY=!0,this._volume=100,this._isMuted=!1,this._isMutedByBrowser=!1,this.onForceMute=()=>{this._isMuted=!0,this._isMutedByBrowser=!0,this.dispatchVolumeEvent()},this._main=e,this._logger=e.getLogger(),this._videoElement=document.createElement("video"),this._main.addEventListener("playbackForceMute",this.onForceMute,!1);let t=null!=(e=null==(e=this._main.getConfigManager())?void 0:e.getSettingsData().getAudioData().startVolume)?e:100,i=null!=(e=null==(e=this._main.getConfigManager())?void 0:e.getSettingsData().getAudioData().muted)&&e;null!=(null==(e=this._main.getStorageManager())?void 0:e.getField("volume"))&&(t=Number(this._main.getStorageManager().getField("volume"))),null!=(null==(e=this._main.getStorageManager())?void 0:e.getField("muted"))&&"true"==this._main.getStorageManager().getField("muted")&&(i=!0,this._isMutedByBrowser=!0),this._volume=t,this._isMuted=i,this.LOG_ACTIVITY&&this._logger.info(this,"VideoElement :: Start Volume: "+this._volume+" | Muted: "+this._isMuted),this._videoElement.volume=this._volume/100,this._videoElement.muted=this._isMuted,this._videoElement.setAttribute("playsinline","playsinline"),this._videoElement.setAttribute("webkit-playsinline","webkit-playsinline"),this._main.dispatchEvent("videoElementCreate",{ref:this._main,videoElement:this._videoElement}),this.initialize()}initialize(){this._videoElement.onload=function(e){},this._videoElement.onstalled=e=>{this._logger.info(this,"VideoElement :: onstalled")},this._videoElement.onerror=e=>{this._logger.info(this,"VideoElement :: onerror :: "+JSON.stringify(e))},this._videoElement.onvolumechange=()=>{this.dispatchVolumeEvent()},this._videoElement.onpause=()=>{},this._videoElement.ontimeupdate=function(e){},this._videoElement.onended=e=>{this._logger.info(this,"VideoElement :: onended")},this._videoElement.onplay=()=>{}}setVolume(e){this._isMuted&&0<e&&this.setMuted(!1),this._volume=e,this._videoElement.volume=e/100,this._main.getStorageManager().saveField("volume",String(e)),0==e&&this.setMuted(!0)}getVolume(){return this._volume}setMuted(e){this._isMuted=e,this._videoElement.muted=e,this._isMutedByBrowser=!1,this._main.getStorageManager().saveField("muted",String(e)),0!=this.getVolume()||e||this.setVolume(100)}getIfMuted(){return this._isMuted}dispatchVolumeEvent(){var e=this._isMutedByBrowser?"browser":"user",t={volume:this._volume,isMuted:this._isMuted,type:e};this.LOG_ACTIVITY&&this._logger.info(this,"ScreenElement :: Event: onVolumeChange: "+JSON.stringify(t)),this._main.dispatchEvent("volumeChange",{ref:this._main,volume:this._volume,muted:this._isMuted,invokedBy:e})}getVideoElement(){return this._videoElement}}class DomUtilities{static calculateDimensionsWithMargins(e){var t=window.getComputedStyle(e),e=e.getBoundingClientRect(),i=parseFloat(t.paddingLeft),n=parseFloat(t.paddingRight),o=parseFloat(t.paddingTop),s=parseFloat(t.paddingBottom),r=parseFloat(t.borderLeftWidth),a=parseFloat(t.borderRightWidth),l=parseFloat(t.borderTopWidth),t=parseFloat(t.borderBottomWidth);return{width:e.width-i-n-r-a,height:e.height-o-s-l-t}}}class StageController{constructor(e){this._containerWidth=0,this._tempContainerWidth=0,this._containerHeight=0,this._tempContainerHeight=0,this._videoWidth=0,this._videoHeight=0,this._scalingMode=ScalingType.FILL,this.isInFullScreenMode=!1,this._autoResizeEnabled=!0,this.onFullScreenChange=()=>{null==document.fullscreenElement?(this.isInFullScreenMode=!1,this._logger.info(this,"The library has exited FullScreen mode!"),this._main.dispatchEvent("fullScreenExit",{ref:this._main})):(this.isInFullScreenMode=!0,this._logger.info(this,"The library has entered FullScreen mode!"),this._main.dispatchEvent("fullScreenEnter",{ref:this._main}))},this.onResize=()=>{if(null!=this._parentElement){var e=this._main.getConfigManager().getSettingsData().getVideoData().parentSizeCalculationMethod;switch(this._videoContainer.style.display="none",e){case SizeCalculationType.CLIENT_DIMENSIONS:this._tempContainerWidth=this._parentElement.clientWidth,this._tempContainerHeight=this._parentElement.clientHeight;break;case SizeCalculationType.BOUNDING_BOX:this._tempContainerWidth=this._parentElement.getBoundingClientRect().width,this._tempContainerHeight=this._parentElement.getBoundingClientRect().height;break;case SizeCalculationType.FULL_BOX:this._tempContainerWidth=DomUtilities.calculateDimensionsWithMargins(this._parentElement).width,this._tempContainerHeight=DomUtilities.calculateDimensionsWithMargins(this._parentElement).height}this._logger.info(this,"onResize called: "+this._tempContainerWidth+"x"+this._tempContainerHeight+" ("+e+")"),this.resizeVideoContainer(),this.scaleVideo(),this._videoContainer.style.display="block",this._main.dispatchEvent("resizeUpdate",{ref:this._main,width:this._tempContainerWidth,height:this._tempContainerHeight})}},this._main=e,this._logger=e.getLogger(),this._logger.info(this,"Creating new StageController"),this.initialize()}initialize(){var e=null!=(e=null==(e=null==(e=null==(e=this._main.getConfigManager())?void 0:e.getSettingsData())?void 0:e.getVideoData())?void 0:e.containerID)?e:null,t=(this._scalingMode=null!=(t=null==(t=this._main.getConfigManager())?void 0:t.getSettingsData().getVideoData().scalingMode)?t:ScalingType.FILL,this._videoContainer=document.createElement("div"),this._videoContainer.setAttribute("id","stormStreamer_"+this._main.getStreamerID()),this._videoContainer.style.overflow="hidden",this._videoContainer.style.position="relative",this._videoContainer.classList.add("stormStreamer"),this._screenElement=new ScreenElement(this._main),this._videoContainer.appendChild(this._screenElement.getVideoElement()),this._main.getConfigManager().getSettingsData().getVideoData().resizeDebounce);this._resizeObserver=0<t?new ResizeObserver(debounce$1(()=>()=>{this._autoResizeEnabled&&this.onResize()},t,{leading:!1,trailing:!0})):new ResizeObserver(()=>{this._autoResizeEnabled&&this.onResize()}),document.addEventListener("fullscreenchange",this.onFullScreenChange,!1),document.addEventListener("webkitfullscreenchange",this.onFullScreenChange,!1),document.addEventListener("mozfullscreenchange",this.onFullScreenChange,!1),document.addEventListener("webkitendfullscreen",this.onFullScreenChange,!1),this._screenElement.getVideoElement().addEventListener("webkitendfullscreen",this.onFullScreenChange,!1),e?this.attachToParent(e):this._logger.warning(this,'Could not create HTMLObject for the library - "containerID" was not provided')}attachToParent(e){let t=!1,i=null;return console.log("xxxxxxxxx",e),"string"==typeof e?(this._logger.info(this,"Attaching container to ID: "+e),i=document.getElementById(e),console.log(">>",document.getElementById(e))):e instanceof HTMLElement&&(this._logger.info(this,"Attaching container to HTMLElement: "+e),i=e),i===this._parentElement?(this._logger.warning(this,"attachToParent :: container is the same"),!1):(i&&this._videoContainer?(this._parentElement=i,this._parentElement.appendChild(this._videoContainer),this._resizeObserver.observe(this._parentElement),this._parentElement.addEventListener("transitionend",()=>{this.onResize()}),this._main.dispatchEvent("containerChange",{ref:this._main,container:this._parentElement}),this.onResize(),t=!0):(console.log("tempParentElement",i),console.log("this._videoContainer",this._videoContainer),this._logger.warning(this,"attachToParent :: container was not found")),t)}detachFromParent(){let e=!1;return null!=this._parentElement&&null!=this._videoContainer?(this._logger.info(this,"Detaching from parent: "+this._videoContainer),this._parentElement.removeChild(this._videoContainer),this._resizeObserver&&(this._resizeObserver.unobserve(this._parentElement),this._resizeObserver.disconnect()),this._autoResizeEnabled&&this._parentElement.removeEventListener("transitionend",this.onResize),this._main.dispatchEvent("containerChange",{ref:this._main,container:null}),e=!0):this._logger.info(this,"Failed detaching from parent!"),this._parentElement=null,e}resizeVideoContainer(){var e=this._main.getConfigManager().getSettingsData().getVideoData().videoWidthInPixels,t=this._main.getConfigManager().getSettingsData().getVideoData().videoHeightInPixels,i=this._main.getConfigManager().getSettingsData().getVideoData().videoWidthValue,n=this._main.getConfigManager().getSettingsData().getVideoData().videoHeightValue,o=this._main.getConfigManager().getSettingsData().getVideoData().aspectRatio;let s=0,r=0;var a=Number(o.split(":")[0]),l=Number(o.split(":")[1]);"none"==o?(e?s=i:null!=this._parentElement&&(s=this._tempContainerWidth*i/100),t?r=n:null!=this._parentElement&&0==(r=this._tempContainerHeight*n/100)&&0!=this._videoHeight&&0!=this._videoWidth&&(r=this._videoHeight*s/this._videoWidth)):(e?s=i:null!=this._parentElement&&(s=this._tempContainerWidth*i/100),r=s*l/a),this._containerWidth=Math.ceil(s),this._containerHeight=Math.ceil(r),this._videoWidth=this._containerWidth,this._videoHeight=this._containerHeight,null!==this._videoContainer&&(this._videoContainer.style.width=this._containerWidth+"px",this._videoContainer.style.height=this._containerHeight+"px")}scaleVideo(){if(null!==this._screenElement){let e=0,t=0,i=0,n=0;switch(this._scalingMode){case ScalingType.FILL:i=this._containerWidth,n=this._containerHeight;break;case ScalingType.CROP:i=this._containerWidth,(n=this._videoHeight*this._containerWidth/this._videoWidth)>=this._containerHeight?(e=0,t=(n-this._containerHeight)/2*-1):(n=this._containerHeight,i=this._videoWidth*this._containerHeight/this._videoHeight,t=0,e=(i-this._containerWidth)/2*-1);break;case ScalingType.LETTER_BOX:i=this._containerWidth,(!((n=this._videoHeight*this._containerWidth/this._videoWidth)<=this._containerHeight)||(e=0,t=(n-this._containerHeight)/2*-1,n>this._containerHeight))&&(n=this._containerHeight,i=this._videoWidth*this._containerHeight/this._videoHeight,t=0,e=(i-this._containerWidth)/2*-1);break;case ScalingType.ORIGINAL:i=this._videoWidth,n=this._videoHeight,e=(this._videoWidth-this._containerWidth)/-2,t=(this._videoHeight-this._containerHeight)/-2}this._screenElement.getVideoElement().style.left=Math.floor(e)+"px",this._screenElement.getVideoElement().style.top=Math.floor(t)+"px",this._screenElement.getVideoElement().style.width=Math.ceil(i)+"px",this._screenElement.getVideoElement().style.height=Math.ceil(n)+"px",this._screenElement.getVideoElement().style.position="absolute",this._screenElement.getVideoElement().style.objectFit="fill"}}enterFullScreen(){var e;null!=(e=this._screenElement)&&e.getVideoElement().webkitEnterFullScreen?null!=(e=this._screenElement)&&e.getVideoElement().webkitEnterFullScreen():null!=(e=this._screenElement)&&e.getVideoElement().requestFullscreen()}exitFullScreen(){var e;null!=(e=this._screenElement)&&e.getVideoElement().webkitExitFullscreen?document.webkitExitFullscreen():document.exitFullscreen()}isFullScreenMode(){return this.isInFullScreenMode}setDimension(e,t){var i="width"===e?"videoWidth":"videoHeight";let n,o;if("number"==typeof t)o=t,n=!0;else{if("string"!=typeof t)throw new Error(`Unknown value for parameter "${e}" - it must be a number or a string!`);o=parseInt(t),n=t.toLowerCase().endsWith("px")}this._main.getConfigManager().getSettingsData().getVideoData()[i+"Value"]=o,this._main.getConfigManager().getSettingsData().getVideoData()[i+"InPixels"]=n,this.resizeVideoContainer(),this.scaleVideo()}setSize(e,t){this.setDimension("width",e),this.setDimension("height",t)}setWidth(e){this.setDimension("width",e)}setHeight(e){this.setDimension("height",e)}getParentElement(){return this._parentElement}setScalingMode(e){switch(e.toLowerCase()){case"fill":this._scalingMode=ScalingType.FILL;break;case"crop":this._scalingMode=ScalingType.CROP;break;case"letterbox":this._scalingMode=ScalingType.LETTER_BOX;break;case"original":this._scalingMode=ScalingType.ORIGINAL}this.scaleVideo()}getContainerWidth(){return this._containerWidth}getContainerHeight(){return this._containerHeight}getScalingModeAsString(){let e="";switch(this._scalingMode){case ScalingType.FILL:e="fill";break;case ScalingType.CROP:e="crop";break;case ScalingType.LETTER_BOX:e="letterbox";break;case ScalingType.ORIGINAL:e="original"}return e}getScalingMode(){return this._scalingMode}getScreenElement(){return this._screenElement}getContainer(){return this._videoContainer}destroy(){this.detachFromParent()}}StageController.LOG_ACTIVITY=!0;class MungeSDP{constructor(){}addAudio(e,t){let i="",n="",o=!1;for(const s of e.split(/\r\n/))s.length<=0||(0===s.indexOf("m=audio")?i="audio":0===s.indexOf("m=video")&&(i="video"),n=n+s+"\r\n","audio"!==i)||0!=="a=rtcp-mux".localeCompare(s)||o||(n+=t,o=!0);return n}addVideo(e,t){e=e.split(/\r\n/);let i="",n=!1,o=!1;for(const r of e)r.length<=0||(r.includes("a=rtcp-rsize")&&(o=!0),r.includes("a=rtcp-mux"));let s=!1;for(const a of e)a.startsWith("m=video")&&(s=!0),i=i+a+"\r\n",s&&(0==="a=rtcp-rsize".localeCompare(a)&&!n&&o&&(i+=t,n=!0),0==="a=rtcp-mux".localeCompare(a)&&n&&!o&&(i+=t,n=!0),0!=="a=rtcp-mux".localeCompare(a)||n||o||(n=!0));return i}deliverCheckLine(e,t){for(const n in MungeSDP.SDPOutput){var i=MungeSDP.SDPOutput[n];if(i.includes(e)){if(e.includes("VP9")||e.includes("VP8")){let e="";for(const o of i.split(/\r\n/))e=e+o+"\r\n";return t.includes("audio")&&(MungeSDP.audioIndex=parseInt(n)),t.includes("video")&&(MungeSDP.videoIndex=parseInt(n)),e}return t.includes("audio")&&(MungeSDP.audioIndex=parseInt(n)),t.includes("video")&&(MungeSDP.videoIndex=parseInt(n)),i}}return""}checkLine(t){if(t.startsWith("a=rtpmap")||t.startsWith("a=rtcp-fb")||t.startsWith("a=fmtp")){var i=t.split(":");if(1<i.length){i=i[1].split(" ");if(!isNaN(parseInt(i[0]))&&!i[1].startsWith("http")&&!i[1].startsWith("ur")){let e=MungeSDP.SDPOutput[i[0]];return e=e||"",e+=t+"\r\n",MungeSDP.SDPOutput[i[0]]=e,!1}}}return!0}getrtpMapID(e){var t=new RegExp("a=rtpmap:(\\d+) (\\w+)/(\\d+)"),e=e.match(t);return e&&3<=e.length?e:null}mungeSDPPublish(e,t){MungeSDP.SDPOutput={},MungeSDP.videoChoice="42e01f",MungeSDP.audioChoice="opus",MungeSDP.videoIndex=-1,MungeSDP.audioIndex=-1;e=e.split(/\r\n/);let i="header",n=!1,o="";null!=t.videoCodec&&""!==t.videoCodec&&(MungeSDP.videoChoice=t.videoCodec),null!=t.audioCodec&&""!==t.audioCodec&&(MungeSDP.audioChoice=t.audioCodec);for(const a of e)a.length<=0||this.checkLine(a)&&(o=o+a+"\r\n");o=this.addAudio(o,this.deliverCheckLine(MungeSDP.audioChoice,"audio"));var s,r,e=(o=this.addVideo(o,this.deliverCheckLine(MungeSDP.videoChoice,"video"))).split(/\r\n/);o="";for(const l of e)if(!(l.length<=0)){let e;if(0===l.indexOf("m=audio")&&-1!==MungeSDP.audioIndex)e=l.split(" "),o+=e[0]+" "+e[1]+" "+e[2]+" "+MungeSDP.audioIndex+"\r\n",i="audio",n=!1;else if(0===l.indexOf("m=video")&&-1!==MungeSDP.videoIndex)e=l.split(" "),o+=e[0]+" "+e[1]+" "+e[2]+" "+MungeSDP.videoIndex+"\r\n",i="video",n=!1;else{if(o+=l,0===l.indexOf("a=rtpmap")&&(i="bandwidth",n=!1),"chrome"!==UserCapabilities.getBrowserName().toLowerCase()&&"safari"!==UserCapabilities.getBrowserName().toLowerCase()||0!==l.indexOf("a=mid:")&&0!==l.indexOf("a=rtpmap")||n||(0==="audio".localeCompare(i)?(void 0!==t.audioBitrate&&""!==t.audioBitrate&&(o=(o+="\r\nb=CT:"+t.audioBitrate)+"\r\nb=AS:"+t.audioBitrate),n=!0):0==="video".localeCompare(i)?(void 0!==t.videoBitrate&&""!==t.videoBitrate&&(o=(o+="\r\nb=CT:"+t.videoBitrate)+"\r\nb=AS:"+t.videoBitrate,void 0!==t.videoFrameRate)&&(o+="\r\na=framerate:"+t.videoFrameRate),n=!0):"chrome"===UserCapabilities.getBrowserName().toLowerCase()&&0==="bandwidth".localeCompare(i)&&null!==(r=this.getrtpMapID(l))&&(s=r[2].toLowerCase(),0!=="vp9".localeCompare(s)&&0!=="vp8".localeCompare(s)&&0!=="h264".localeCompare(s)&&0!=="red".localeCompare(s)&&0!=="ulpfec".localeCompare(s)&&0!=="rtx".localeCompare(s)||void 0!==t.videoBitrate&&(o+="\r\na=fmtp:"+r[1]+" x-google-min-bitrate="+t.videoBitrate+";x-google-max-bitrate="+t.videoBitrate),0!=="opus".localeCompare(s)&&0!=="isac".localeCompare(s)&&0!=="g722".localeCompare(s)&&0!=="pcmu".localeCompare(s)&&0!=="pcma".localeCompare(s)&&0!=="cn".localeCompare(s)||void 0!==t.audioBitrate&&(o+="\r\na=fmtp:"+r[1]+" x-google-min-bitrate="+t.audioBitrate+";x-google-max-bitrate="+t.audioBitrate))),"firefox"===UserCapabilities.getBrowserName().toLowerCase()&&0===l.indexOf("c=IN")){if(0==="audio".localeCompare(i)){""!==t.audioBitrate&&"string"==typeof t.audioBitrate&&(s=parseInt(t.audioBitrate),o=(o+="\r\nb=TIAS:"+(1e3*s*.95-16e3)+"\r\n")+"b=AS:"+s+"\r\nb=CT:"+s+"\r\n");continue}if(0==="video".localeCompare(i)){""!==t.videoBitrate&&"string"==typeof t.videoBitrate&&(r=parseInt(t.videoBitrate),o=(o+="\r\nb=TIAS:"+1e3*(1e3*r*.95-16e3)+"\r\n")+"b=AS:"+r+"\r\nb=CT:"+r+"\r\n");continue}}o+="\r\n"}}return o}mungeSDPPlay(e){let n="";for(const r of e.split(/\r\n/))if(0!==r.length){if(r.includes("profile-level-id")){var o=r.substr(r.indexOf("profile-level-id")+17,6);let e=Number("0x"+o.substr(0,2)),t=Number("0x"+o.substr(2,2)),i=Number("0x"+o.substr(4,2));66<e&&(e=66,t=224,i=31),0===t&&(t=224);var s=("00"+e.toString(16)).slice(-2).toLowerCase()+("00"+t.toString(16)).slice(-2).toLowerCase()+("00"+i.toString(16)).slice(-2).toLowerCase();n+=r.replace(o,s)}else n+=r;n+="\r\n"}return n}}MungeSDP.SDPOutput={},function(e){e[e.VIDEO_INPUT=0]="VIDEO_INPUT",e[e.AUDIO_INPUT=1]="AUDIO_INPUT"}(InputType=InputType||{});class InputDevice{constructor(e,t){if(this._groupID="",this._isSelected=!1,null==e)throw new Error("no input device");if(void 0===e.deviceId||null===e.deviceId)throw new Error("no deviceID");if(this._id=e.deviceId,void 0===e.kind||null===e.kind)throw new Error("no device kind");switch(e.kind){case"videoinput":this._inputType=InputType.VIDEO_INPUT;break;case"audioinput":this._inputType=InputType.AUDIO_INPUT;break;default:throw new Error("incorrect kind")}null!==e.label&&""!==e.label?this._label=this.cleanLabel(e.label):this._label=this._inputType==InputType.VIDEO_INPUT?"Camera "+t:"Microphone "+t,void 0!==e.groupId&&null!==e.groupId&&(this._groupID=e.groupId)}cleanLabel(e){return e}getLabel(){return this._label}getID(){return this._id}getGroupID(){return this._groupID}getIfSelected(){return this._isSelected}setSelected(e){this._isSelected=e}}class InputDeviceList{constructor(){this._internalList=new Array}push(t){let i=!1;if(0<this._internalList.length){for(let e=0;e<this._internalList.length;e++)""!==this._internalList[e].getGroupID()&&this._internalList[e].getGroupID()==t.getGroupID()&&(i=!0,this._internalList[e]=t);return 0==i?this._internalList.push(t):this._internalList.length}return this._internalList.push(t)}get(e){return this._internalList[e]}getSize(){return this._internalList.length}getArray(){return this._internalList}}exports.PublishState=void 0,function(e){e.NOT_INITIALIZED="NOT_INITIALIZED",e.INITIALIZED="INITIALIZED",e.CONNECTING="CONNECTING",e.PUBLISHED="PUBLISHED",e.UNPUBLISHED="UNPUBLISHED",e.STOPPED="STOPPED",e.UNKNOWN="UNKNOWN",e.ERROR="ERROR"}(exports.PublishState||(exports.PublishState={}));class SoundMeter{constructor(e){this._instant=0,this._slow=0,this.clip=0,this._main=e}attach(e){this._stream=e,this.audioContext=new AudioContext,this.microphone=this.audioContext.createMediaStreamSource(e),this.processor=this.audioContext.createScriptProcessor(2048,1,1),this.microphone.connect(this.processor),this.processor.connect(this.audioContext.destination),this.processor.onaudioprocess=e=>{this.onAudioProcess(e)}}detach(){null!==this.microphone&&this.microphone.disconnect(),null!==this.processor&&this.processor.disconnect()}clear(){this._instant=0,this._slow=0,this.clip=0}onAudioProcess(e){var t=e.inputBuffer.getChannelData(0);let i,n=0,o=0;for(i=0;i<t.length;++i)n+=t[i]*t[i],.99<Math.abs(t[i])&&(o+=1);this._instant=Math.sqrt(n/t.length),this._slow=.05*this._instant+.95*this._slow,this.clip=o/t.length,this._main.dispatchEvent("soundMeter",{ref:this._main,high:this._instant,low:this._slow})}}class PlaybackController{constructor(e){this._isWindowActive=!0,this._peerConnectionConfig={iceServers:[]},this._isMicrophoneMuted=!1,this._constraints={video:{width:{min:"640",ideal:"1024",max:"1024"},height:{min:"360",ideal:"576",max:"576"},frameRate:{min:24,ideal:30,max:30}},audio:!0},this._publishState=exports.PublishState.NOT_INITIALIZED,this.onServerDisconnect=()=>{},this.onServerConnect=()=>{this._peerConnection=new RTCPeerConnection(this._peerConnectionConfig),this._peerConnection.onicecandidate=e=>{this.onIceCandidate(e)},this._peerConnection.onconnectionstatechange=e=>{this.onConnectionStateChange(e)},this._peerConnection.onnegotiationneeded=e=>{this._peerConnection.createOffer(e=>{this.onDescriptionSuccess(e)},e=>{this.onDescriptionError(e)}).catch(e=>{console.log(e)})};var e,t=this._stream.getTracks();for(e in t)this._peerConnection.addTrack(t[e],this._stream)},this.onDescriptionSuccess=t=>{var e;console.log("%cāµ š„ onDescriptionSuccess ","background: green; color: white;");const i={applicationName:null==(e=null==(e=this._main.getNetworkController())?void 0:e.getConnection().getCurrentServer())?void 0:e.getApplication(),streamName:null==(e=this._main.getConfigManager())?void 0:e.getStreamData().streamKey,sessionId:"[empty]"};t.sdp=this._mungeSDP.mungeSDPPublish(t.sdp,{audioBitrate:"64",videoBitrate:"1500",videoFrameRate:30,videoCodec:"42e01f",audioCodec:"opus"}),this._peerConnection.setLocalDescription(t).then(()=>{var e;null!=(e=this._main.getNetworkController())&&e.sendMessage('{"direction":"publish", "command":"sendOffer", "streamInfo":'+JSON.stringify(i)+', "sdp":'+JSON.stringify(t)+"}")}).catch(e=>{console.log(e)})},this.visibilityChange=()=>{"hidden"===document.visibilityState?this.onWindowBlur():"visible"===document.visibilityState&&this.onWindowFocus()},this.onWindowBlur=()=>{this._isWindowActive&&this._logger.warning(this,"Player window is no longer in focus!"),this._isWindowActive=!1},this.onWindowFocus=()=>{this._isWindowActive||this._logger.info(this,"Player window is focused again!"),this._isWindowActive=!0},this._main=e,this._logger=e.getLogger(),this._logger.info(this,"Creating new PlaybackController"),this._mungeSDP=new MungeSDP,this._soundMeter=new SoundMeter(this._main),this.initialize()}initialize(){var e;this._main.addEventListener("serverConnect",this.onServerConnect,!1),this._main.addEventListener("serverDisconnect",this.onServerDisconnect,!1),document.addEventListener("visibilitychange",this.visibilityChange),window.addEventListener("blur",this.onWindowBlur),window.addEventListener("focus",this.onWindowFocus),null!=(e=this._main.getConfigManager())&&e.getSettingsData().autoConnect?(this._logger.info(this,"Initializing NetworkController (autoConnect is true)"),null!=(e=this._main.getNetworkController())&&e.initialize()):this._logger.warning(this,"Warning - autoConnect is set to false, switching to standby mode!"),null!=(null==(e=this._main.getConfigManager())?void 0:e.getStreamData().streamKey)&&this.startWebRTC()}startWebRTC(){try{navigator.mediaDevices.getUserMedia?navigator.mediaDevices.getUserMedia(this._constraints).then(e=>{this.onUserMediaSuccess(e)}).catch(e=>{this.onUserMediaError(e)}):(this._logger.error(this,"WebRTCStreamer :: Browser does not support WebRTC"),this._main.dispatchEvent("compatibilityError",{ref:this._main,message:"WebRTC is not supported"}))}catch(e){this.onUserMediaError(e)}}publish(e){this._publishState==exports.PublishState.PUBLISHED&&this.closeStream(),this._main.getConfigManager().getStreamData().streamKey=e,this.startWebRTC()}unpublish(){this.closeStream()}onUserMediaSuccess(e){console.log("%cāµ š„ onUserMediaSuccess","background: green; color: white;"),this._logger.success(this,"WebRTCStreamer :: WebRTC UserMedia successfully retrieved"),this._stream=e,this._soundMeter.attach(this._stream),this.setPublishState(exports.PublishState.INITIALIZED),null!=this._cameraList&&null!=this._microphoneList||this.grabDevices();var t=this._main.getStageController().getScreenElement().getVideoElement();t.muted=!0,t.srcObject=e,t.autoplay=!0,t.playsInline=!0,t.disableRemotePlayback=!0,t.controls=!1,null!=(e=this._main.getNetworkController())&&e.start()}onUserMediaError(e){switch(console.log("%cāµ š„ onUserMediaError: "+JSON.stringify(e),"background: green; color: white;"),e.message){case"Permission denied":case"The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.":case"The request is not allowed by the user agent or the platform in the current context.":this._logger.warning(this,"WebRTCStreamer :: No permission to access camera & microphone"),this._main.dispatchEvent("inputDeviceDenied",{ref:this._main});break;case"The object can not be found here.":case"Requested device not found":this._logger.warning(this,"WebRTCStreamer :: Could not access camera or microphone"),this._main.dispatchEvent("inputDeviceError",{ref:this._main});break;default:this._logger.warning(this,"WebRTCStreamer :: Unsupported onUserMediaError: "+e.message)}}onSocketMessage(e){var t=JSON.parse(e);switch(Number(t.status)){case 200:console.log("%cāµ š„ onSocketMessage: 200","background: green; color: white;");var i=t.sdp,n=(void 0!==i&&this._peerConnection.setRemoteDescription(new RTCSessionDescription(i),()=>{},()=>{}),t.iceCandidates);if(void 0!==n)for(var o in n)this._peerConnection.addIceCandidate(new RTCIceCandidate(n[o]));break;case 503:console.log("%cāµ š„ onSocketMessage: 503","background: green; color: white;"),this._main.dispatchEvent("streamKeyInUse",{ref:this._main,streamKey:this._main.getConfigManager().getStreamData().streamKey}),this.setPublishState(exports.PublishState.ERROR)}}onConnectionStateChange(e){if(console.log("%cāµ š„ onConnectionStateChange: "+e.currentTarget.connectionState,"background: green; color: white;"),null!==e)switch(e.currentTarget.connectionState){case"connecting":this._logger.info(this,"WebRTCStreamer :: Event: onStreamerConnecting"),this.setPublishState(exports.PublishState.CONNECTING);break;case"connected":this._logger.info(this,"WebRTCStreamer :: Event: onStreamerConnected"),this.setPublishState(exports.PublishState.PUBLISHED),1==this._isMicrophoneMuted&&this.muteMicrophone(!1);break;case"disconnected":this._logger.info(this,"WebRTCStreamer :: Event: onStreamerDisconnected"),this.setPublishState(exports.PublishState.UNPUBLISHED);break;case"failed":this._logger.info(this,"WebRTCStreamer :: Event: onPlayerFailed"),this.setPublishState(exports.PublishState.ERROR);break;default:this._logger.info(this,"WebRTCStreamer :: Unsupported onConnectionStateChange: "+e.currentTarget.connectionState)}}grabDevices(){navigator.mediaDevices.enumerateDevices().then(t=>{this._cameraList=new InputDeviceList,this._microphoneList=new InputDeviceList;for(let e=0;e<t.length;e++)try{var i,n;"videoinput"===t[e].kind?(i=new InputDevice(t[e],e),this._cameraList.push(i)):"audioinput"===t[e].kind&&(n=new InputDevice(t[e],e),this._microphoneList.push(n))}catch(e){this._logger.error(this,"WebRTCStreamer :: Input Device Error: "+e)}if(0==this._cameraList.getSize())this._main.dispatchEvent("noCameraFound",{ref:this._main});else if(0==this._microphoneList.getSize())this._main.dispatchEvent("noCameraFound",{ref:this._main});else{this._logger.info(this,"Camera list:");for(let e=0;e<this._cameraList.getSize();e++)this._logger.info(this,"=> ["+e+"] InputDevice: "+this._cameraList.get(e).getLabel());this._logger.info(this,"Microphone list:");for(let e=0;e<this._microphoneList.getSize();e++)this._logger.info(this,"=> ["+e+"] InputDevice: "+this._microphoneList.get(e).getLabel());this._selectedCamera=this.pickCamera(),this._selectedMicrophone=this.pickMicrophone()}}).catch(()=>{this._main.dispatchEvent("inputDeviceError",{ref:this._main})})}selectCamera(t){var i;for(let e=0;e<this._cameraList.getSize();e++)if(this._cameraList.get(e).getID()==t){this._selectedCamera=this._cameraList.get(e),null!=(i=this._main.getStorageManager())&&i.saveField("cameraID",this._selectedCamera.getID());break}this.closeStream(),this._constraints.video.deviceId=this._selectedCamera.getID(),this.startWebRTC()}selectMicrophone(t){var i;for(let e=0;e<this._microphoneList.getSize();e++)if(this._microphoneList.get(e).getID()==t){this._selectedMicrophone=this._microphoneList.get(e),null!=(i=this._main.getStorageManager())&&i.saveField("microphoneID",this._selectedMicrophone.getID());break}this.closeStream(),this._constraints.audio={deviceId:this._selectedMicrophone.getID()},this.startWebRTC()}pickCamera(){for(let e=0;e<this._cameraList.getSize();e++)this._cameraList.get(e).setSelected(!1);var e=null!=(e=null==(e=this._main.getStorageManager())?void 0:e.getField("cameraID"))?e:null;return null==this._selectedCamera||null==e?this._selectedCamera=this._cameraList.get(0):this.selectCamera(e),this._selectedCamera.setSelected(!0),this._main.dispatchEvent("deviceListUpdate",{ref:this._main,cameraList:this._cameraList.getArray(),microphoneList:this._microphoneList.getArray()}),this._selectedCamera}pickMicrophone(){for(let e=0;e<this._microphoneList.getSize();e++)this._microphoneList.get(e).setSelected(!1);var e=null!=(e=null==(e=this._main.getStorageManager())?void 0:e.getField("microphoneID"))?e:null;return null==this._selectedMicrophone||null==e?this._selectedMicrophone=this._microphoneList.get(0):this.selectMicrophone(e),this._selectedMicrophone.setSelected(!0),this._main.dispatchEvent("deviceListUpdate",{ref:this._main,cameraList:this._cameraList.getArray(),microphoneList:this._microphoneList.getArray()}),this._selectedMicrophone}muteMicrophone(t){if(this._publishState==exports.PublishState.PUBLISHED)if(null!==this._stream){t?this._logger.success(this,"WebRTCStreamer :: Unmuting microphone"):this._logger.success(this,"WebRTCStreamer :: Muting microphone");for(let e=0;e<this._stream.getAudioTracks().length;e++)this._stream.getAudioTracks()[e].enabled=t;this._isMicrophoneMuted=!t}else this._logger.warning(this,"WebRTCStreamer :: Stream object not present!");else this._logger.warning(this,"WebRTCStreamer :: Not ready to change microphone")}isMicrophoneMuted(){return this._isMicrophoneMuted}onDescriptionError(e){this._logger.info(this,"WebRTCStreamer :: onDescriptionError: "+JSON.stringify(e))}onIceCandidate(e){e.candidate}closeStream(){this._stream&&this._stream.getTracks().forEach(function(e){e.stop()}),this._soundMeter.detach(),void 0!==this._peerConnection&&null!==this._peerConnection&&this._peerConnection.close(),this.setPublishState(exports.PublishState.UNPUBLISHED)}getCurrentCamera(){return this._selectedCamera}getCurrentMicrophone(){return this._selectedMicrophone}setPublishState(e){this._publishState=e,this._main.dispatchEvent("publishStateChange",{ref:this._main,state:this._publishState})}getCameraList(){return this._cameraList.getArray()}getMicrophoneList(){return this._microphoneList.getArray()}getPlayer(){return this._selectedPlayer}destroy(){var e;this.closeStream(),null!=(e=this._selectedPlayer)&&e.clear(),this._selectedPlayer=null,this._main.removeEventListener("serverConnect",this.onServerConnect),document.removeEventListener("visibilitychange",this.visibilityChange),window.removeEventListener("blur",this.onWindowBlur),window.removeEventListener("focus",this.onWindowFocus)}}!function(e){e[e.NOT_INITIALIZED=0]="NOT_INITIALIZED",e[e.STARTED=1]="STARTED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.CLOSED=4]="CLOSED",e[e.FAILED=5]="FAILED"}(ConnectionState=ConnectionState||{});class AbstractSocket{constructor(){this.CONNECTION_TIMEOUT=5,this.isBinary=!0,this._connectionState=ConnectionState.NOT_INITIALIZED,this._messageCount=0,this._disconnectedByUser=!1,this._isConnected=!1,this._sequenceNumber=-1}startConnection(){this._disconnectedByUser=!1,this._messageCount=0,this._isConnected=!1,this._disconnectedByUser=!1,this._connectionState=ConnectionState.CONNECTING,this.socket=new WebSocket(this.socketURL),this.isBinary&&(this.socket.binaryType="arraybuffer"),this.socket.onopen=e=>{clearTimeout(this._connectionTimeout),this._sequenceNumber++,this._connectionState=ConnectionState.CONNECTED,this.onSocketOpen(e)},this.socket.onmessage=e=>{this._messageCount++,this.onSocketMessage(e)},this.socket.onclose=e=>{clearTimeout(this._connectionTimeout),this._connectionState==ConnectionState.CONNECTED?(this._connectionState=ConnectionState.CLOSED,this.onSocketClose(e)):this._connectionState=ConnectionState.FAILED},this.socket.onerror=e=>{if(clearTimeout(this._connectionTimeout),this._connectionState==ConnectionState.CONNECTING&&this.onSocketError(e),this._connectionState==ConnectionState.CONNECTED)try{this.socket.close()}catch(e){}},this._connectionTimeout=setTimeout(()=>{try{this.socket.close()}catch(e){}this._connectionState==ConnectionState.CONNECTING&&(this._connectionState=ConnectionState.FAILED,this.onSocketError(new ErrorEvent("connectionTimeout")))},1e3*this.CONNECTION_TIMEOUT)}onSocketOpen(e){}onSocketClose(e){}onSocketMessage(e){}onSocketError(e){}onError(e){}sendData(e){if(this._connectionState==ConnectionState.CONNECTED&&null!==this.socket){if(null!=e)return void this.socket.send(e);this.onError("no data to send")}this.onError("socket not connected")}getConnectionState(){return this._connectionState}disconnect(e=!0){this._isConnected=!1,this._connectionState=ConnectionState.CLOSED,e&&(this._logger.warning(this,"Disconnected by user"),this._disconnectedByUser=e),null!=this.socket&&(this.socket.onopen=null,this.socket.onmessage=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.close())}destroy(){void 0!==this.socket&&null!==this.socket&&(this.socket.onopen=null,this.socket.onmessage=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.close()),this._connectionState=ConnectionState.CLOSED}getSocketURL(){return this.socketURL}}class WowzaConnection extends AbstractSocket{constructor(e,t){super(),this._logger=e.getLogger(),this._main=e,this._networkController=t,this.initialize()}initialize(){this._logger.info(this,"Starting new connection with a storm server"),this.pickServerFromList(this._main.getConfigManager().getStreamData().getServerList()),null!=this._currServer?(this.socketURL=this.createURL(this._currServer),this._logger.info(this,"Starting WebSocket connection with: "+this.socketURL),this._main.dispatchEvent("serverConnectionInitiate",{ref:this._main,serverURL:this.socketURL}),this._main.getConfigManager().getIfDemoMode()?(this._logger.warning(this,"Player is in demo mode, and will not connect with a server!"),this._main.dispatchEvent("authorizationComplete",{ref:this._main})):this.startConnection()):this._logger.error(this,"Connection with the server could not be initialized!")}onSocketOpen(e){this._logger.success(this,"Connection with the server has been established!"),this._main.dispatchEvent("serverConnect",{ref:this._main,serverURL:this.socketURL,sequenceNum:this._sequenceNumber}),this._isConnected=!0}onSocketError(e){this._isConnected=!1,this._disconnectedByUser||(this._logger.error(this,"Connection with the server failed"),this._main.dispatchEvent("serverConnectionError",{ref:this._main,serverURL:this.socketURL,restart:this._main.getConfigManager().getSettingsData().getIfRestartOnError(),sequenceNum:this._sequenceNumber}),0==this._isConnected&&(this._currServer.setAsFaild(!0),this.initiateReconnect()))}onSocketClose(e){this._isConnected=!1,this._disconnectedByUser?this._logger.warning(this,"Force disconnect from server!"):(this._logger.error(this,"Connection with the server has been closed"),this._main.dispatchEvent("serverDisconnect",{ref:this._main,serverURL:this.socketURL,restart:this._main.getConfigManager().getSettingsData().getIfRestartOnError(),sequenceNum:this._sequenceNumber}),this.initiateReconnect())}onSocketMessage(e){this._networkController.onMessage(e)}createURL(e){var t="";return(t+=e.getIfSSL()?"wss://":"ws://")+e.getHost()+(":"+e.getPort())+"/webrtc-session.json"}initiateReconnect(){var e=this._main.getConfigManager().getSettingsData().getIfRestartOnError();const t=this._main.getConfigManager().getSettingsData().getReconnectTime();this._disconnectedByUser||e&&(null!=this._reconnectTimer&&clearTimeout(this._reconnectTimer),this._reconnectTimer=setTimeout(()=>{this.pickServerFromList(this._main.getConfigManager().getStreamData().getServerList()),null!=this._currServer&&(this._logger.info(this,`Will reconnect to the server in ${t} seconds...`),this.socketURL=this.createURL(this._currServer),this._logger.info(this,"Starting WebSocket connection with: "+this.socketURL),this._main.dispatchEvent("serverConnectionInitiate",{ref:this._main,serverURL:this.socketURL}),this.startConnection())},1e3*t))}pickServerFromList(t){let i=null;for(let e=0;e<t.length;e++)if(!t[e].getIfFaild()){i=t[e];break}null==i?(this._logger.error(this,"All connections failed!"),this._main.dispatchEvent("allConnectionsFailed",{ref:this._main,mode:"none"}),this._currServer=null):this._currServer=i}isConnectionActive(){return this._isConnected}getCurrentServer(){return this._currServer}destroy(){super.destroy(),null!=this._reconnectTimer&&clearTimeout(this._reconnectTimer)}}class NetworkController{constructor(e){this._currentStreamKey="none",this._lastState="",this.onServerConnect=()=>{},this.onServerDisconnect=()=>{this._lastState="none"},this.onMessage=e=>{var t;null!=(t=this._main.getPlaybackController())&&t.onSocketMessage(e.data)},this._main=e,this._logger=e.getLogger(),this._main.addEventListener("serverConnect",this.onServerConnect,!1),this._main.addEventListener("serverDisconnect",this.onServerDisconnect,!1)}initialize(){null!=this._connection&&(this._connection.getConnectionState()==ConnectionState.CONNECTING||this._connection.getConnectionState()==ConnectionState.CONNECTED?this._logger.info(this,"Connection is alive, not doing anything!"):(this._logger.info(this,"Connection is dead, restarting!"),this._connection.startConnection()))}start(){this._connection=new WowzaConnection(this._main,this)}stop(){this._connection.disconnect(!0),this._lastState=""}sendMessage(e){this._connection.isConnectionActive()&&this._connection.sendData(e)}getConnection(){return this._connection}getCurrentStreamKey(){return this._currentStreamKey}}class StormStreamer extends EventDispatcher{constructor(e,t=!1){super(),this.DEV_MODE=!0,this.STREAMER_VERSION="0.9.0-beta.1",this.COMPILE_DATE="11/29/2024, 1:56:30 PM",this.STREAMER_BRANCH="Experimental",this.STREAMER_PROTOCOL_VERSION=1,this._initialized=!1,"undefined"!=typeof window&&window.document&&window.document.createElement?(!this.DEV_MODE||"StormStreamerArray"in window||(window.StormStreamerArray=[]),window.StormStreamerArray.push(this),this._streamerID=StormStreamer.NEXT_STREAMER_ID++,null!=e&&(this.setStreamConfig(e),t)&&this.initialize()):console.error('StormLibrary Creation Error - No "window" element in the provided context!')}initialize(){if(!this._isRemoved){if(null==this._configManager)throw Error("Stream Config was not provided for this library! A properly configured object must be provided through the constructor or via the setConfig method before using the initialize() method.");this._storageManager=new StorageManager(this),this._stageController=new StageController(this),this._networkController=new NetworkController(this),this._playbackController=new PlaybackController(this),this._clientUser=new ClientUser,this._initialized=!0,this.dispatchEvent("streamerReady",{ref:this})}}setStreamConfig(e){this._isRemoved||(e=JSON.parse(JSON.stringify(e)),null==this._configManager?(this._configManager=new ConfigManager(e),this._logger=new Logger(this._configManager.getSettingsData().getDebugData(),this),this._logger.info(this,"StreamerID: "+this._streamerID),this._logger.info(this,"Version: "+this.STREAMER_VERSION+" | Compile Date: "+this.COMPILE_DATE+" | Branch: "+this.STREAMER_BRANCH),this._logger.info(this,"UserCapabilities :: Browser: "+UserCapabilities.getBrowserName()+" "+UserCapabilities.getBrowserVersion()),this._logger.info(this,"UserCapabilities :: Operating System: "+UserCapabilities.getOS()+" "+UserCapabilities.getOSVersion()),this._logger.info(this,"UserCapabilities :: isMobile: "+UserCapabilities.isMobile()),this._logger.info(this,"UserCapabilities :: hasMSESupport: "+UserCapabilities.hasMSESupport()),this._logger.info(this,"UserCapabilities :: hasWebSocketSupport: "+UserCapabilities.hasWebSocketsSupport()),this._logger.info(this,"UserCapabilities :: hasWebRTCSupport: "+UserCapabilities.hasWebRTCSupport()),this._configManager.print(this._logger)):(this._logger.info(this,"StreamConfig has been overwritten, dispatching streamConfigChanged!"),this._configManager=new ConfigManager(e),this._configManager.print(this._logger),this.dispatchEvent("streamConfigChange",{ref:this,newConfig:this._configManager})))}stop(){}isConnected(){var e;return null!=(e=null==(e=this._networkController)?void 0:e.getConnection().isConnectionActive())&&e}attachToContainer(e){var t;return!!this._initialized&&null!=(t=null==(t=this._stageController)?void 0:t.attachToParent(e))&&t}detachFromContainer(){var e;return!!this._initialized&&null!=(e=null==(e=this._stageController)?void 0:e.detachFromParent())&&e}getContainer(){var e;return null!=(e=null==(e=this._stageController)?void 0:e.getParentElement())?e:null}mute(){null!=this._stageController&&null!=this._stageController.getScreenElement()?this._stageController.getScreenElement().setMuted(!0):this._configManager.getSettingsData().getAudioData().muted=!0}unmute(){null!=this._stageController&&null!=this._stageController.getScreenElement()?this._stageController.getScreenElement().setMuted(!1):this._configManager.getSettingsData().getAudioData().muted=!1}isMute(){var e;return null!=(e=null!=(e=null==(e=null==(e=this._stageController)?void 0:e.getScreenElement())?void 0:e.getIfMuted())?e:this._configManager.getSettingsData().getAudioData().muted)&&e}toggleMute(){var e=this.isMute();return e?this.unmute():this.mute(),!e}setVolume(e){var t;void 0===(null==(t=null==(t=this._stageController)?void 0:t.getScreenElement())?void 0:t.setVolume(e))&&(this._configManager.getSettingsData().getAudioData().startVolume=e)}getVolume(){var e;return null!=(e=null==(e=null==(e=this._stageController)?void 0:e.getScreenElement())?void 0:e.getVolume())?e:this._configManager.getSettingsData().getAudioData().startVolume}getCameraList(){var e;return null!=(e=null==(e=this._playbackController)?void 0:e.getCameraList())?e:null}getMicrophoneList(){var e;return null!=(e=null==(e=this._playbackController)?void 0:e.getMicrophoneList())?e:null}setCamera(e){var t;null!=(t=this._playbackController)&&t.selectCamera(e)}setMicrophone(e){var t;null!=(t=this._playbackController)&&t.selectMicrophone(e)}getCurrentCamera(){return this._playbackController.getCurrentCamera()}getCurrentMicrophone(){return this._playbackController.getCurrentMicrophone()}muteMicrophone(e){var t;null!=(t=this._playbackController)&&t.muteMicrophone(e)}isMicrophoneMuted(){var e;return null!=(e=null==(e=this._playbackController)?void 0:e.isMicrophoneMuted())&&e}publish(e){var t;null!=(t=this._playbackController)&&t.publish(e)}unpublish(){var e;null!=(e=this._playbackController)&&e.unpublish()}setSize(e,t){this._initialized?this._stageController.setSize(e,t):(e=NumberUtilities.parseValue(e),t=NumberUtilities.parseValue(t),this._configManager.getSettingsData().getVideoData().videoWidthValue=e.value,this._configManager.getSettingsData().getVideoData().videoWidthInPixels=e.isPixels,this._configManager.getSettingsData().getVideoData().videoHeightValue=t.value,this._configManager.getSettingsData().getVideoData().videoHeightInPixels=t.isPixels)}setWidth(e){this._initialized?this._stageController.setWidth(e):(e=NumberUtilities.parseValue(e),this._configManager.getSettingsData().getVideoData().videoWidthValue=e.value,this._configManager.getSettingsData().getVideoData().videoWidthInPixels=e.isPixels)}setHeight(e){this._initialized?this._stageController.setHeight(e):(e=NumberUtilities.parseValue(e),this._configManager.getSettingsData().getVideoData().videoHeightValue=e.value,this._configManager.getSettingsData().getVideoData().videoHeightInPixels=e.isPixels)}getWidth(){return this._initialized?this._stageController.getContainerWidth():this._configManager.getSettingsData().getVideoData().videoWidthInPixels?this._configManager.getSettingsData().getVideoData().videoWidthValue:0}getHeight(){return this._initialized?this._stageController.getContainerHeight():this._configManager.getSettingsData().getVideoData().videoHeightInPixels?this._configManager.getSettingsData().getVideoData().videoHeightValue:0}setScalingMode(e){this._stageController?this._stageController.setScalingMode(e):this._configManager.getSettingsData().getVideoData().scalingMode=e}getScalingMode(){return this._stageController?this._stageController.getScalingMode():this._configManager.getSettingsData().getVideoData().scalingMode}updateToSize(){this._initialized&&this._stageController.onResize()}makeScreenshot(){let i=document.createElement("canvas"),n=i.getContext("2d");return new Promise(t=>{var e;null!=this._stageController&&(i.width=this._stageController.getScreenElement().getVideoElement().videoWidth,i.height=this._stageController.getScreenElement().getVideoElement().videoHeight,e=this._stageController.getScreenElement().getVideoElement(),n)?(n.drawImage(e,0,0,i.width,i.height),i.toBlob(e=>{t(e)},"image/png")):t(null)})}enterFullScreen(){this._initialized&&this._stageController&&this._stageController.enterFullScreen()}exitFullScreen(){this._initialized&&this._stageController&&this._stageController.exitFullScreen()}isFullScreenMode(){return!(!this._initialized||!this._stageController)&&this._stageController.isFullScreenMode()}getStreamerID(){return this._streamerID}getLogger(){return this._logger}getConfigManager(){return this._configManager}getNetworkController(){return this._networkController}getPlaybackController(){return this._playbackController}getStageController(){return this._stageController}getVideoElement(){var e;return null!=(e=null==(e=null==(e=this._stageController)?void 0:e.getScreenElement())?void 0:e.getVideoElement())?e:null}isInitialized(){return this._initialized}getVersion(){return this.STREAMER_VERSION}getBranch(){return this.STREAMER_BRANCH}getStorageManager(){return this._storageManager}dispatchEvent(e,t){super.dispatchEvent(e,t)}destroy(){var e;this._logger.warning(this,"Destroying library instance, bye, bye!"),this._initialized=!1,this._isRemoved=!0,null!=(e=this._networkController)&&e.getConnection().destroy(),null!=(e=this._stageController)&&e.destroy(),null!=(e=this._playbackController)&&e.destroy(),this.removeAllEventListeners()}}function create(e){return new StormStreamer(e)}StormStreamer.NEXT_STREAMER_ID=0,exports.StormStreamer=StormStreamer,exports.create=create;
|
|
14
|
+
*/"use strict";class StormServerItem{constructor(e,t,i=443,n=!0){this.host=e,this.application=t,this.port=i,this.isSSL=n,this.hasFaild=!1}getHost(){return this.host}getApplication(){return this.application}getPort(){return this.port}getIfSSL(){return this.isSSL}getIfFaild(){return this.hasFaild}setAsFaild(e){this.hasFaild=e}getData(){return{serverURL:this.getHost(),application:this.getHost(),serverPort:this.getPort(),isSSL:this.getIfSSL()}}toString(){return"host: "+this.host+" | application: "+this.application+" | port: "+this.port+" | isSSL: "+this.isSSL}}class StreamData{constructor(e){this._serverList=new Array,this._sourceList=new Array,this._streamKey=null,this.parse(e)}parse(e){if(this._streamConfig=e,!this._streamConfig)throw new Error("Stream configuration is missing. Please check stream config!");if(void 0===this._streamConfig.serverList||null===this._streamConfig.serverList)throw new Error("StormLibrary: Server list configuration is missing. Please check the config!");if(0===this._streamConfig.serverList.length)throw new Error("StormLibrary: Server list configuration is empty. Please check the config!");for(let i=0;i<this._streamConfig.serverList.length;i++){let e,t;if(null==this._streamConfig.serverList[i].host)throw new Error('Error while parsing server object ("host" field is missing). Please check player config!');if(e=this._streamConfig.serverList[i].host,null==this._streamConfig.serverList[i].application)throw new Error('Error while parsing server object ("application" field is missing). Please check player config!');t=this._streamConfig.serverList[i].application;var n=null!=(n=this._streamConfig.serverList[i].port)?n:StreamData.DEFAULT_CONNECTION_PORT,o=null!=(o=this._streamConfig.serverList[i].ssl)?o:StreamData.IS_SSL_BY_DEFAULT;this._serverList.push(new StormServerItem(e,t,n,o))}this._streamKey=null!=(e=this._streamConfig.streamKey)?e:this._streamKey}getServerList(){return this._serverList}getSourceList(){return this._sourceList}get streamKey(){return this._streamKey}set streamKey(e){this._streamKey=e}set serverList(e){this._serverList=e}set sourceList(e){this._sourceList=e}clearSourceList(){this._sourceList=new Array}clearServerList(){this._serverList=new Array}print(t,e=!1){if(StreamData.PRINT_ON_STARTUP||e){t.info(this,"Server List:");for(let e=0;e<this._serverList.length;e++)t.info(this,"=> ["+e+"] "+this._serverList[e].toString());t.info(this,"StreamKey: "+this._streamKey)}}}var ScalingType,SizeCalculationType,LogType;StreamData.PRINT_ON_STARTUP=!0,StreamData.DEFAULT_CONNECTION_PORT=443,StreamData.IS_SSL_BY_DEFAULT=!0,function(e){e.FILL="fill",e.LETTER_BOX="letterbox",e.CROP="crop",e.ORIGINAL="original"}(ScalingType=ScalingType||{}),function(e){e.CLIENT_DIMENSIONS="clientDimensions",e.BOUNDING_BOX="boundingBox",e.FULL_BOX="fullBox"}(SizeCalculationType=SizeCalculationType||{});class VideoData{constructor(e){this._scalingMode=ScalingType.LETTER_BOX,this._aspectRatio="none",this._videoWidthValue=100,this._isVideoWidthInPixels=!1,this._wasVideoWidthProvided=!1,this._videoHeightValue=100,this._isVideoHeightInPixels=!1,this._wasVideoHeightProvided=!1,this._resizeDebounce=250,this._parentSizeCalculationMethod=SizeCalculationType.CLIENT_DIMENSIONS,this.parse(e)}parse(e){if(this.videoConfig=e,null==this.videoConfig)throw new Error("Missing video configuration. Please check player config!");if(null!=this.videoConfig.aspectRatio){var e=new RegExp("^[0-9]*\\.?[0-9]+:[0-9]*\\.?[0-9]+$"),t=this.videoConfig.aspectRatio;if(!e.test(t))throw new Error('Parameter "aspectRatio" - must match "number:number" pattern ');this._aspectRatio=t,this._aspectRatio=this.videoConfig.aspectRatio}if(null!=this.videoConfig.scalingMode)switch(this.videoConfig.scalingMode.toLowerCase()){case"fill":this._scalingMode=ScalingType.FILL;break;case"letterbox":this._scalingMode=ScalingType.LETTER_BOX;break;case"crop":this._scalingMode=ScalingType.CROP;break;case"original":this._scalingMode=ScalingType.ORIGINAL;break;default:throw new Error("Unknown video scaling mode. Please check player config!")}if(void 0!==this.videoConfig.width){if(null===this.videoConfig.width)throw new Error('Parameter "width" cannot be empty');if("number"==typeof this.videoConfig.width)this._videoWidthValue=this.videoConfig.width,this._isVideoWidthInPixels=!0;else{if("string"!=typeof this.videoConfig.width)throw new Error('Unknown type for parameter "width" - it must be a number or a string! ');this.videoConfig.width.toLowerCase().endsWith("px")?(this._videoWidthValue=parseInt(this.videoConfig.width),this._isVideoWidthInPixels=!0):this.videoConfig.width.toLowerCase().endsWith("%")&&(this._videoWidthValue=parseInt(this.videoConfig.width),this._isVideoWidthInPixels=!1)}this._wasVideoWidthProvided=!0}if(void 0!==this.videoConfig.height){if(null===this.videoConfig.height)throw new Error('Parameter "height" cannot be empty');if("number"==typeof this.videoConfig.height)this._videoHeightValue=this.videoConfig.height,this._isVideoHeightInPixels=!0;else{if("string"!=typeof this.videoConfig.height)throw new Error('Unknown type for parameter "height" - it must be a number or a string!');this.videoConfig.height.toLowerCase().endsWith("px")?(this._videoHeightValue=parseInt(this.videoConfig.height),this._isVideoHeightInPixels=!0):this.videoConfig.height.toLowerCase().endsWith("%")&&(this._videoHeightValue=parseInt(this.videoConfig.height),this._isVideoHeightInPixels=!1)}this._wasVideoHeightProvided=!0}if(void 0!==this.videoConfig.sizeCalculationMethod&&null!==this.videoConfig.sizeCalculationMethod)switch(this.videoConfig.sizeCalculationMethod){case"clientDimensions":this._parentSizeCalculationMethod=SizeCalculationType.CLIENT_DIMENSIONS;break;case"boundingBox":this._parentSizeCalculationMethod=SizeCalculationType.BOUNDING_BOX;break;case"fullBox":this._parentSizeCalculationMethod=SizeCalculationType.FULL_BOX}this._containerID=null!=(e=this.videoConfig.containerID)?e:null,this._resizeDebounce=null!=(t=this.videoConfig.resizeDebounce)?t:this._resizeDebounce}get scalingMode(){return this._scalingMode}get containerID(){return this._containerID}get videoWidthValue(){return this._videoWidthValue}get videoWidthInPixels(){return this._isVideoWidthInPixels}get videoWidthProvided(){return this._wasVideoWidthProvided}get videoHeightValue(){return this._videoHeightValue}get videoHeightInPixels(){return this._isVideoHeightInPixels}get videoHeightProvided(){return this._wasVideoHeightProvided}get aspectRatio(){return this._aspectRatio}get resizeDebounce(){return this._resizeDebounce}set resizeDebounce(e){this._resizeDebounce=e}set videoWidthValue(e){this._videoWidthValue=e}set videoWidthInPixels(e){this._isVideoWidthInPixels=e}set videoHeightValue(e){this._videoHeightValue=e}set videoHeightInPixels(e){this._isVideoHeightInPixels=e}set containerID(e){this._containerID=e}set scalingMode(e){switch(e.toLowerCase()){case"fill":this._scalingMode=ScalingType.FILL;break;case"letterbox":this._scalingMode=ScalingType.LETTER_BOX;break;case"crop":this._scalingMode=ScalingType.CROP;break;case"original":this._scalingMode=ScalingType.ORIGINAL;break;default:throw new Error("Unknown video scaling mode. Please check player config!")}}get parentSizeCalculationMethod(){return this._parentSizeCalculationMethod}print(e){let t="";switch(this._scalingMode){case ScalingType.FILL:t="fill";break;case ScalingType.LETTER_BOX:t="letterbox";break;case ScalingType.CROP:t="crop";break;case ScalingType.ORIGINAL:t="original"}e.info(this,"VideoConfig :: containerID: "+this._containerID),e.info(this,"VideoConfig :: scalingMode: "+t),e.info(this,"VideoConfig :: width: "+this._videoWidthValue+(this._isVideoWidthInPixels?"px":"%")+(this._wasVideoWidthProvided?" (provided)":" (default)")),e.info(this,"VideoConfig :: height: "+this._videoHeightValue+(this._isVideoHeightInPixels?"px":"%")+(this._wasVideoHeightProvided?" (provided)":" (default)")),e.info(this,"VideoConfig :: aspectRatio: "+this._aspectRatio)}}!function(e){e[e.TRACE=0]="TRACE",e[e.INFO=1]="INFO",e[e.SUCCESS=2]="SUCCESS",e[e.WARNING=3]="WARNING",e[e.ERROR=4]="ERROR"}(LogType=LogType||{});class DebugData{constructor(e){this._consoleLogEnabled=!1,this._enabledConsoleTypes=[LogType.INFO,LogType.ERROR,LogType.SUCCESS,LogType.TRACE,LogType.WARNING],this._consoleMonoColor=!1,this._containerLogEnabled=!1,this._enabledContainerTypes=[LogType.INFO,LogType.ERROR,LogType.SUCCESS,LogType.TRACE,LogType.WARNING],this._containerLogMonoColor=!1,this.parse(e)}parse(e){this._debugConfig=e,this._debugConfig&&(this._consoleLogEnabled=null!=(e=null==(e=null==(e=this._debugConfig)?void 0:e.console)?void 0:e.enabled)?e:this._consoleLogEnabled,this._consoleMonoColor=null!=(e=null==(e=null==(e=this._debugConfig)?void 0:e.console)?void 0:e.monoColor)?e:this._consoleMonoColor,this._enabledConsoleTypes=null!=(e=this.parseLogTypes(null==(e=null==(e=this._debugConfig)?void 0:e.console)?void 0:e.logTypes))?e:this._enabledConsoleTypes,this._containerLogEnabled=null!=(e=null==(e=null==(e=this._debugConfig)?void 0:e.container)?void 0:e.enabled)?e:this._containerLogEnabled,this._containerLogMonoColor=null!=(e=null==(e=null==(e=this._debugConfig)?void 0:e.container)?void 0:e.monoColor)?e:this._containerLogMonoColor,this._enabledContainerTypes=null!=(e=this.parseLogTypes(null==(e=null==(e=this._debugConfig)?void 0:e.container)?void 0:e.logTypes))?e:this._enabledContainerTypes,this._containerID=null!=(e=null==(e=null==(e=this._debugConfig)?void 0:e.container)?void 0:e.containerID)?e:this._containerID)}parseLogTypes(e){return null==e?void 0:e.map(e=>{switch(e.toLowerCase()){case"info":return LogType.INFO;case"error":return LogType.ERROR;case"warning":return LogType.WARNING;case"success":return LogType.SUCCESS;case"trace":return LogType.TRACE;default:throw new Error("Unsupported log type: "+e)}})}get consoleLogEnabled(){return this._consoleLogEnabled}set consoleLogEnabled(e){this._consoleLogEnabled=e}get enabledConsoleTypes(){return this._enabledConsoleTypes}set enabledConsoleTypes(t){this._enabledConsoleTypes=new Array;for(let e=0;e<t.length;e++)switch(t[e].toLowerCase()){case"info":this._enabledConsoleTypes.push(LogType.INFO);break;case"error":this._enabledConsoleTypes.push(LogType.ERROR);break;case"warning":this._enabledConsoleTypes.push(LogType.WARNING);break;case"success":this._enabledConsoleTypes.push(LogType.SUCCESS);break;case"trace":this._enabledConsoleTypes.push(LogType.TRACE)}}get containerLogEnabled(){return this._containerLogEnabled}set containerLogEnabled(e){this._consoleLogEnabled=e}get consoleLogMonoColor(){return this._consoleMonoColor}set consoleLogMonoColor(e){this._consoleMonoColor=e}get enabledContainerTypes(){return this._enabledContainerTypes}set enabledContainerTypes(t){this._enabledContainerTypes=new Array;for(let e=0;e<t.length;e++)switch(t[e].toLowerCase()){case"info":this._enabledContainerTypes.push(LogType.INFO);break;case"error":this._enabledContainerTypes.push(LogType.ERROR);break;case"warning":this._enabledContainerTypes.push(LogType.WARNING);break;case"success":this._enabledContainerTypes.push(LogType.SUCCESS);break;case"trace":this._enabledContainerTypes.push(LogType.TRACE)}}get containerID(){return this._containerID}set containerID(e){this._containerID=e}get containerLogMonoColor(){return this._containerLogMonoColor}set containerLogMonoColor(e){this._containerLogMonoColor=e}print(e,t=!1){if(DebugData.PRINT_ON_STARTUP||t){let t="";for(let e=0;e<this._enabledConsoleTypes.length;e++)switch(this._enabledConsoleTypes[e]){case LogType.TRACE:t+="TRACE, ";break;case LogType.SUCCESS:t+="SUCCESS, ";break;case LogType.WARNING:t+="WARNING, ";break;case LogType.INFO:t+="INFO, ";break;case LogType.ERROR:t+="ERROR, "}e.info(this,"Console:: enabled: "+this._consoleLogEnabled),e.info(this,"Console:: logTypes: "+t),e.info(this,"Console:: monoColor: "+this._consoleMonoColor);let i="";for(let e=0;e<this._enabledContainerTypes.length;e++)switch(this._enabledContainerTypes[e]){case LogType.TRACE:i+="TRACE, ";break;case LogType.SUCCESS:i+="SUCCESS, ";break;case LogType.WARNING:i+="WARNING, ";break;case LogType.INFO:i+="INFO, ";break;case LogType.ERROR:i+="ERROR, "}e.info(this,"Container:: enabled: "+this._containerLogEnabled),e.info(this,"Container:: logTypes: "+i),e.info(this,"Container:: containerID: "+this._containerID),e.info(this,"Container:: monoColor: "+this._consoleMonoColor)}}}DebugData.PRINT_ON_STARTUP=!0;class AudioData{constructor(e){this._startVolume=100,this._isMuted=!1,this.parse(e)}parse(e){this._audioConfig=e,this._audioConfig&&(this._startVolume=null!=(e=null==(e=this._audioConfig)?void 0:e.startVolume)?e:this._startVolume,this._isMuted=null!=(e=null==(e=this._audioConfig)?void 0:e.muted)?e:this._isMuted)}get startVolume(){return this._startVolume}set startVolume(e){this._startVolume=e}get muted(){return this._isMuted}set muted(e){this._isMuted=e}print(e,t=!1){(AudioData.PRINT_ON_STARTUP||t)&&e.info(this,"Audio :: startVolume: "+this._startVolume+" | isMuted: "+this._isMuted)}}AudioData.PRINT_ON_STARTUP=!0;class StorageData{constructor(e){this._enabled=!0,this._prefix="storm",this.parse(e)}parse(e){this._storageConfig=e,this._enabled=null!=(e=null==(e=this._storageConfig)?void 0:e.enabled)?e:this._enabled,this._prefix=null!=(e=null==(e=this._storageConfig)?void 0:e.prefix)?e:this._prefix}get enabled(){return this._enabled}set enabled(e){this._enabled=e}get prefix(){return this._prefix}set prefix(e){this._prefix=e}print(e,t=!1){(StorageData.PRINT_ON_STARTUP||t)&&e.info(this,"Storage :: startVolume: "+this._enabled+" | prefix: "+this._prefix)}}StorageData.PRINT_ON_STARTUP=!0;class SettingsData{constructor(e){this._restartOnError=!0,this._reconnectTime=1,this._autoStart=!1,this._autoConnect=!0,this.startOnDOMReady=!1,this.iOSOnDomReadyFix=!0,this._restartOnFocus=!0,this.parse(e)}parse(e){this._settingsConfig=e,this._autoConnect=null!=(e=this._settingsConfig.autoConnect)?e:this._autoConnect,this._autoStart=null!=(e=this._settingsConfig.autoStart)?e:this._autoStart,this._restartOnFocus=null!=(e=this._settingsConfig.restartOnFocus)?e:this._restartOnFocus,this._restartOnError=null!=(e=this._settingsConfig.restartOnError)?e:this._restartOnError,this._reconnectTime=null!=(e=this._settingsConfig.reconnectTime)?e:this._reconnectTime,this._videoData=new VideoData(null!=(e=this._settingsConfig.video)?e:null),this._audioData=new AudioData(null!=(e=this._settingsConfig.audio)?e:null),this._storageData=new StorageData(null!=(e=this._settingsConfig.storage)?e:null),this._debugData=new DebugData(null!=(e=this._settingsConfig.debug)?e:null)}getAudioData(){return this._audioData}getVideoData(){return this._videoData}getStorageData(){return this._storageData}getIfRestartOnError(){return this._restartOnError}getReconnectTime(){return this._reconnectTime}get autoStart(){return this._autoStart}set autoStart(e){this._autoStart=e}get autoConnect(){return this._autoConnect}get restartOnFocus(){return this._restartOnFocus}getDebugData(){return this._debugData}getIfStartOnDOMReadyEnabled(){return this.startOnDOMReady}getIfIOSOnDomStartFixEnabled(){return this.iOSOnDomReadyFix}print(e,t=!1){(SettingsData.PRINT_ON_STARTUP||t)&&(e.info(this,"SettingsConfig :: autoConnect: "+this._autoConnect),e.info(this,"SettingsConfig :: autoStart: "+this._autoStart),e.info(this,"SettingsConfig :: restartOnError: "+this._restartOnError),e.info(this,"SettingsConfig :: reconnectTime: "+this._reconnectTime),e.info(this,"SettingsConfig :: enabledProtocols: "),this._videoData.print(e),this._audioData.print(e),this._debugData.print(e),this._debugData.print(e))}}SettingsData.PRINT_ON_STARTUP=!0;class ConfigManager{constructor(e){this.PRINT_ON_STARTUP=!0,this.demoMode=!1,this.parse(e)}parse(e){if(this.configTemplate=e,null==this.configTemplate.stream)throw new Error("No stream field was provided. Please check your player config!");this.streamData=new StreamData(this.configTemplate.stream),this.settingsData=new SettingsData(null!=(e=this.configTemplate.settings)?e:null),this.demoMode=null!=(e=this.configTemplate.demoMode)&&e}getStreamData(){return this.streamData}getSettingsData(){return this.settingsData}getIfDemoMode(){return this.demoMode}print(e,t=!1){(this.PRINT_ON_STARTUP||t)&&(this.streamData.print(e),this.settingsData.print(e))}}class EventDispatcher{constructor(){this._isRemoved=!1,this._listeners={}}addEventListener(t,i,e=!0){this._listeners[t]||(this._listeners[t]=[]);let n=!1;if(null!=this._listeners[t]&&0<this._listeners[t].length)for(let e=0;e<this._listeners[t].length;e++)if(this._listeners[t][e][1]==i){n=!0;break}return this._logger.success(this,"Registering a new event: "+t),!n&&(this._listeners[t].push([t,i,e]),!0)}removeEventListener(t,i){let n=!1;if(null!=this._listeners[t]&&0<this._listeners[t].length)for(let e=0;e<this._listeners[t].length;e++){var o=this._listeners[t][e];if(i){if(o[1]==i){if(1!=o[2])break;n=!0,this._listeners[t].splice(e,1);break}}else n=!0,1==o[2]&&this._listeners[t].splice(e,1)}return this._logger.success(this,"Removing listener: "+t),n}removeAllEventListeners(){this._logger.success(this,"Removing all listeners!");for(const i in this._listeners){var e=i,t=this._listeners[e];if(t&&0<t.length)for(let e=t.length-1;0<=e;e--)!0===t[e][2]&&t.splice(e,1)}}dispatchEvent(t,i){if(!this._isRemoved&&null!=this._listeners[t]&&0<this._listeners[t].length)for(let e=0;e<this._listeners[t].length;e++)this._listeners[t][e][1].call(this,i)}}class NumberUtilities{static addLeadingZero(e){return e<10?"0"+e:String(e)}static isNear(e,t,i){return Math.abs(e-t)<=i}static generateUniqueString(t){let i="";var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=n.length;for(let e=0;e<t;e++)i+=n.charAt(Math.floor(Math.random()*o));return i}}NumberUtilities.parseValue=e=>{var t;return"string"==typeof e?(t=e.toLowerCase().endsWith("px"),{value:parseInt(e,10),isPixels:t}):{value:e,isPixels:!0}};class Logger{constructor(e,t){this.colorOrder=["red","green","blue","orange","black","violet"],this._logMemory=[],this._streamerInstanceID=-1,this._debugConfig=e,this._stormStreamer=t,this._streamerInstanceID=this._stormStreamer.getStreamerID();e=this.colorOrder.length<t.getStreamerID()?this.colorOrder.length-1:t.getStreamerID();this._monoColor=this.colorOrder[e]}info(e,t){e=this.logData(e,t);this._debugConfig.consoleLogEnabled&&0<=this._debugConfig.enabledConsoleTypes.indexOf(LogType.INFO)&&(t=this._debugConfig.consoleLogMonoColor?this._monoColor:Logger.INFO_COLOR,console.log("%c "+e,"color: "+t)),this._debugConfig.containerLogEnabled&&0<=this._debugConfig.enabledContainerTypes.indexOf(LogType.INFO)&&(t=this._debugConfig.containerLogMonoColor?this._monoColor:Logger.INFO_COLOR,this.writeToContainer(e,t))}warning(e,t){e=this.logData(e,t);this._debugConfig.consoleLogEnabled&&0<=this._debugConfig.enabledConsoleTypes.indexOf(LogType.WARNING)&&(t=this._debugConfig.consoleLogMonoColor?this._monoColor:Logger.WARNING_COLOR,console.log("%c "+e,"color: "+t)),this._debugConfig.containerLogEnabled&&0<=this._debugConfig.enabledContainerTypes.indexOf(LogType.WARNING)&&(t=this._debugConfig.containerLogMonoColor?this._monoColor:Logger.WARNING_COLOR,this.writeToContainer(e,t))}error(e,t){e=this.logData(e,t);this._debugConfig.consoleLogEnabled&&0<=this._debugConfig.enabledConsoleTypes.indexOf(LogType.ERROR)&&(t=this._debugConfig.consoleLogMonoColor?this._monoColor:Logger.ERROR_COLOR,console.log("%c "+e,"color: "+t)),this._debugConfig.containerLogEnabled&&0<=this._debugConfig.enabledContainerTypes.indexOf(LogType.ERROR)&&(t=this._debugConfig.containerLogMonoColor?this._monoColor:Logger.ERROR_COLOR,this.writeToContainer(e,t))}success(e,t){e=this.logData(e,t);this._debugConfig.consoleLogEnabled&&0<=this._debugConfig.enabledConsoleTypes.indexOf(LogType.SUCCESS)&&(t=this._debugConfig.consoleLogMonoColor?this._monoColor:Logger.SUCCESS_COLOR,console.log("%c "+e,"color: "+t)),this._debugConfig.containerLogEnabled&&0<=this._debugConfig.enabledContainerTypes.indexOf(LogType.SUCCESS)&&(t=this._debugConfig.containerLogMonoColor?this._monoColor:Logger.SUCCESS_COLOR,this.writeToContainer(e,t))}trace(e,t){e=this.logData(e,t);this._debugConfig.consoleLogEnabled&&0<=this._debugConfig.enabledConsoleTypes.indexOf(LogType.TRACE)&&(t=this._debugConfig.consoleLogMonoColor?this._monoColor:Logger.TRACE_COLOR,console.log("%c "+e,"color: "+t)),this._debugConfig.containerLogEnabled&&0<=this._debugConfig.enabledContainerTypes.indexOf(LogType.TRACE)&&(t=this._debugConfig.containerLogMonoColor?this._monoColor:Logger.TRACE_COLOR,this.writeToContainer(e,t))}logData(e,t){var i=new Date,n=NumberUtilities.addLeadingZero(i.getHours()),o=NumberUtilities.addLeadingZero(i.getMinutes()),i=NumberUtilities.addLeadingZero(i.getSeconds());let s=String(this._streamerInstanceID);0<=this._streamerInstanceID&&(s+="|"+this._streamerInstanceID);n="[Storm-ID:"+s+"] ["+n+":"+o+":"+i+"] :: "+t;return this._logMemory.push(n),n}writeToContainer(e,t){var i,n=this._debugConfig.containerID;n&&(n=document.getElementById(n),(i=document.createElement("span")).innerText=e,i.style.color=t,n.appendChild(i))}setPlayerID(e){this._streamerInstanceID=e}getAllLogs(){return this._logMemory}}Logger.INFO_COLOR="blue",Logger.WARNING_COLOR="orange",Logger.ERROR_COLOR="red",Logger.SUCCESS_COLOR="green",Logger.TRACE_COLOR="black";class ClientUser{constructor(){this.bandwidthCapabilities=0}setBandwidthCapabilities(e){this.bandwidthCapabilities=e}getBandwidthCapabilities(){return this.bandwidthCapabilities}}class UserCapabilities{static hasWebSocketsSupport(){return null!=window.WebSocket}static isMobile(){return new RegExp("Mobile|mini|Fennec|Android|iP(ad|od|hone)").test(navigator.userAgent)}static isCookieEnabled(){let e=!!navigator.cookieEnabled;return"undefined"!=typeof navigator.cookieEnabled||e||(document.cookie="testcookie",e=-1!=document.cookie.indexOf("testcookie")),e}static getOSVersion(){let e="Unknown version",t=UserCapabilities.getOS();if(null!=t){var i;switch(new RegExp("Windows").test(t)&&(i=new RegExp("Windows (.*)"),e=null!=i.exec(t)[1]?i.exec(t)[1]:e,t="Windows"),t){case"Mac OS":case"Mac OS X":case"Android":var n=new RegExp("(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([\\.\\_\\d]+)");e=n.exec(navigator.userAgent)[1];break;case"iOS":n=new RegExp("OS (\\d+)_(\\d+)_?(\\d+)?");e=(e=n.exec(navigator.userAgent))[1]+"."+e[2]+"."+(0|e[3])}}return e}static getBrowserName(){return UserCapabilities.getFullBrowser().name}static getBrowserVersion(){return UserCapabilities.getFullBrowser().version}static getFullBrowser(){var e=navigator.userAgent;let t=navigator.appName,i=""+parseFloat(navigator.appVersion),n=parseInt(navigator.appVersion,10),o,s,r;return-1!=(s=e.indexOf("Opera"))?(t="Opera",i=e.substring(s+6),-1!=(s=e.indexOf("Version"))&&(i=e.substring(s+8))):-1!=(s=e.indexOf("MSIE"))?(t="Microsoft Internet Explorer",i=e.substring(s+5)):"Netscape"==t&&-1!=e.indexOf("Trident/")?(t="Microsoft Internet Explorer",i=e.substring(s+5),-1!=(s=e.indexOf("rv:"))&&(i=e.substring(s+3))):-1!=(s=e.indexOf("Chrome"))?(t="Chrome",(-1<e.indexOf("FBAV")||-1<e.indexOf("FBAN"))&&(t="Facebook"),-1<e.indexOf("OPR")&&(t="Opera"),-1<e.indexOf("SamsungBrowser")&&(t="Samsung"),i=e.substring(s+7)):-1!=(s=e.indexOf("Safari"))?(t="Safari",i=e.substring(s+7),-1!=(s=e.indexOf("Version"))&&(i=e.substring(s+8)),-1!=e.indexOf("CriOS")&&(t="Chrome"),-1!=e.indexOf("FxiOS")&&(t="Firefox")):-1!=(s=e.indexOf("Firefox"))?(t="Firefox",i=e.substring(s+8)):(o=e.lastIndexOf(" ")+1)<(s=e.lastIndexOf("/"))&&(t=e.substring(o,s),i=e.substring(s+1),t.toLowerCase()==t.toUpperCase())&&(t=navigator.appName),-1!=(r=(i=-1!=(r=(i=-1!=(r=i.indexOf(";"))?i.substring(0,r):i).indexOf(" "))?i.substring(0,r):i).indexOf(")"))&&(i=i.substring(0,r)),n=parseInt(""+i,10),isNaN(n)&&(i=""+parseFloat(navigator.appVersion),n=parseInt(navigator.appVersion,10)),{name:t,fullVersion:i,version:n}}static getOS(){let e="Unknown OS";var t,i=[{os:"Windows 10",code:"(Windows 10.0|Windows NT 10.0)"},{os:"Windows 8.1",code:"(Windows 8.1|Windows NT 6.3)"},{os:"Windows 8",code:"(Windows 8|Windows NT 6.2)"},{os:"Windows 7",code:"(Windows 7|Windows NT 6.1)"},{os:"Windows Vista",code:"Windows NT 6.0"},{os:"Windows Server 2003",code:"Windows NT 5.2"},{os:"Windows XP",code:"(Windows NT 5.1|Windows XP)"},{os:"Windows 2000",code:"(Windows NT 5.0|Windows 2000)"},{os:"Windows ME",code:"(Win 9x 4.90|Windows ME)"},{os:"Windows 98",code:"(Windows 98|Win98)"},{os:"Windows 95",code:"(Windows 95|Win95|Windows_95)"},{os:"Windows NT 4.0",code:"(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)"},{os:"Windows CE",code:"Windows CE"},{os:"Windows 3.11",code:"Win16"},{os:"Android",code:"Android"},{os:"Open BSD",code:"OpenBSD"},{os:"Sun OS",code:"SunOS"},{os:"Chrome OS",code:"CrOS"},{os:"Linux",code:"(Linux|X11(?!.*CrOS))"},{os:"iOS",code:"(iPhone|iPad|iPod)"},{os:"Mac OS X",code:"Mac OS X"},{os:"Mac OS",code:"(Mac OS|MacPPC|MacIntel|Mac_PowerPC|Macintosh)"},{os:"QNX",code:"QNX"},{os:"UNIX",code:"UNIX"},{os:"BeOS",code:"BeOS"},{os:"OS/2",code:"OS\\/2"},{os:"Search Bot",code:"(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\\/Teoma|ia_archiver)"}];for(t in i){var n=i[t];if(new RegExp(n.code).test(navigator.userAgent)){e=n.os;break}}return e}static hasWebRTCSupport(){let t=!1;try{navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||window.RTCPeerConnection;t=!0}catch(e){t=!1}return t}static hasHLSSupport(e){return null!==e&&Boolean(e.canPlayType("application/vnd.apple.mpegURL")||e.canPlayType("audio/mpegurl"))}static hasMSESupport(){var e=window.MediaSource=window.MediaSource||window.WebKitMediaSource;return window.SourceBuffer=window.SourceBuffer||window.WebKitSourceBuffer,e&&"function"==typeof e.isTypeSupported}static hasMMSSupport(){return window.ManagedMediaSource}static isSSL(){return"https:"===location.protocol}}class StorageManager{constructor(e){var t;this.LOG_ACTIVITY=!1,this.isEnabled=!0,this.prefix="",this.logger=e.getLogger(),this.isEnabled=null!=(t=null==(t=null==(t=e.getConfigManager())?void 0:t.getSettingsData())?void 0:t.getStorageData().enabled)?t:this.isEnabled,this.prefix=null!=(t=null==(e=null==(t=e.getConfigManager())?void 0:t.getSettingsData())?void 0:e.getStorageData().prefix)?t:this.prefix,this.LOG_ACTIVITY&&this.logger.info(this,"Creating new StorageManager")}saveField(e,t){1==this.isEnabled&&(this.LOG_ACTIVITY&&this.logger.info(this,"Saving data: "+e+" | "+t),localStorage.setItem(this.prefix+e,t))}getField(e){var t;return 1==this.isEnabled?(t=localStorage.getItem(this.prefix+e),this.LOG_ACTIVITY&&this.logger.info(this,"Grabbing data: "+e+" | "+t),t):null}}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var FUNC_ERROR_TEXT="Expected a function",NAN=NaN,symbolTag="[object Symbol]",reTrim=/^\s+|\s+$/g,reIsBadHex=/^[-+]0x[0-9a-f]+$/i,reIsBinary=/^0b[01]+$/i,reIsOctal=/^0o[0-7]+$/i,freeParseInt=parseInt,freeGlobal="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")(),objectProto=Object.prototype,objectToString=objectProto.toString,nativeMax=Math.max,nativeMin=Math.min,now=function(){return root.Date.now()};function debounce(n,i,e){var o,s,r,a,l,h,c=0,g=!1,d=!1,t=!0;if("function"!=typeof n)throw new TypeError(FUNC_ERROR_TEXT);function u(e){var t=o,i=s;return o=s=void 0,c=e,a=n.apply(i,t)}function _(e){var t=e-h;return void 0===h||i<=t||t<0||d&&r<=e-c}function p(){var e,t=now();if(_(t))return m(t);l=setTimeout(p,(e=i-((t=t)-h),d?nativeMin(e,r-(t-c)):e))}function m(e){return l=void 0,t&&o?u(e):(o=s=void 0,a)}function C(){var e=now(),t=_(e);if(o=arguments,s=this,h=e,t){if(void 0===l)return c=e=h,l=setTimeout(p,i),g?u(e):a;if(d)return l=setTimeout(p,i),u(h)}return void 0===l&&(l=setTimeout(p,i)),a}return i=toNumber(i)||0,isObject(e)&&(g=!!e.leading,d="maxWait"in e,r=d?nativeMax(toNumber(e.maxWait)||0,i):r,t="trailing"in e?!!e.trailing:t),C.cancel=function(){void 0!==l&&clearTimeout(l),o=h=s=l=void(c=0)},C.flush=function(){return void 0===l?a:m(now())},C}function isObject(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function isObjectLike(e){return!!e&&"object"==typeof e}function isSymbol(e){return"symbol"==typeof e||isObjectLike(e)&&objectToString.call(e)==symbolTag}function toNumber(e){if("number"==typeof e)return e;if(isSymbol(e))return NAN;if("string"!=typeof(e=isObject(e)?isObject(t="function"==typeof e.valueOf?e.valueOf():e)?t+"":t:e))return 0===e?e:+e;e=e.replace(reTrim,"");var t=reIsBinary.test(e);return t||reIsOctal.test(e)?freeParseInt(e.slice(2),t?2:8):reIsBadHex.test(e)?NAN:+e}var InputType,ConnectionState,lodash_debounce=debounce,debounce$1=getDefaultExportFromCjs(debounce);class ScreenElement{constructor(e){this.LOG_ACTIVITY=!0,this._volume=100,this._isMuted=!1,this._isMutedByBrowser=!1,this.onForceMute=()=>{this._isMuted=!0,this._isMutedByBrowser=!0,this.dispatchVolumeEvent()},this._main=e,this._logger=e.getLogger(),this._videoElement=document.createElement("video"),this._main.addEventListener("playbackForceMute",this.onForceMute,!1);let t=null!=(e=null==(e=this._main.getConfigManager())?void 0:e.getSettingsData().getAudioData().startVolume)?e:100,i=null!=(e=null==(e=this._main.getConfigManager())?void 0:e.getSettingsData().getAudioData().muted)&&e;null!=(null==(e=this._main.getStorageManager())?void 0:e.getField("volume"))&&(t=Number(this._main.getStorageManager().getField("volume"))),null!=(null==(e=this._main.getStorageManager())?void 0:e.getField("muted"))&&"true"==this._main.getStorageManager().getField("muted")&&(i=!0,this._isMutedByBrowser=!0),this._volume=t,this._isMuted=i,this.LOG_ACTIVITY&&this._logger.info(this,"VideoElement :: Start Volume: "+this._volume+" | Muted: "+this._isMuted),this._videoElement.volume=this._volume/100,this._videoElement.muted=this._isMuted,this._videoElement.setAttribute("playsinline","playsinline"),this._videoElement.setAttribute("webkit-playsinline","webkit-playsinline"),this._main.dispatchEvent("videoElementCreate",{ref:this._main,videoElement:this._videoElement}),this.initialize()}initialize(){this._videoElement.onload=function(e){},this._videoElement.onstalled=e=>{this._logger.info(this,"VideoElement :: onstalled")},this._videoElement.onerror=e=>{this._logger.info(this,"VideoElement :: onerror :: "+JSON.stringify(e))},this._videoElement.onvolumechange=()=>{this.dispatchVolumeEvent()},this._videoElement.onpause=()=>{},this._videoElement.ontimeupdate=function(e){},this._videoElement.onended=e=>{this._logger.info(this,"VideoElement :: onended")},this._videoElement.onplay=()=>{}}setVolume(e){this._isMuted&&0<e&&this.setMuted(!1),this._volume=e,this._videoElement.volume=e/100,this._main.getStorageManager().saveField("volume",String(e)),0==e&&this.setMuted(!0)}getVolume(){return this._volume}setMuted(e){this._isMuted=e,this._videoElement.muted=e,this._isMutedByBrowser=!1,this._main.getStorageManager().saveField("muted",String(e)),0!=this.getVolume()||e||this.setVolume(100)}getIfMuted(){return this._isMuted}dispatchVolumeEvent(){var e=this._isMutedByBrowser?"browser":"user",t={volume:this._volume,isMuted:this._isMuted,type:e};this.LOG_ACTIVITY&&this._logger.info(this,"ScreenElement :: Event: onVolumeChange: "+JSON.stringify(t)),this._main.dispatchEvent("volumeChange",{ref:this._main,volume:this._volume,muted:this._isMuted,invokedBy:e})}getVideoElement(){return this._videoElement}}class DomUtilities{static calculateDimensionsWithMargins(e){var t=window.getComputedStyle(e),e=e.getBoundingClientRect(),i=parseFloat(t.paddingLeft),n=parseFloat(t.paddingRight),o=parseFloat(t.paddingTop),s=parseFloat(t.paddingBottom),r=parseFloat(t.borderLeftWidth),a=parseFloat(t.borderRightWidth),l=parseFloat(t.borderTopWidth),t=parseFloat(t.borderBottomWidth);return{width:e.width-i-n-r-a,height:e.height-o-s-l-t}}}class StageController{constructor(e){this._containerWidth=0,this._tempContainerWidth=0,this._containerHeight=0,this._tempContainerHeight=0,this._videoWidth=0,this._videoHeight=0,this._scalingMode=ScalingType.FILL,this.isInFullScreenMode=!1,this._autoResizeEnabled=!0,this.onFullScreenChange=()=>{null==document.fullscreenElement?(this.isInFullScreenMode=!1,this._logger.info(this,"The library has exited FullScreen mode!"),this._main.dispatchEvent("fullScreenExit",{ref:this._main})):(this.isInFullScreenMode=!0,this._logger.info(this,"The library has entered FullScreen mode!"),this._main.dispatchEvent("fullScreenEnter",{ref:this._main}))},this.onResize=()=>{if(null!=this._parentElement){var e=this._main.getConfigManager().getSettingsData().getVideoData().parentSizeCalculationMethod;switch(this._videoContainer.style.display="none",e){case SizeCalculationType.CLIENT_DIMENSIONS:this._tempContainerWidth=this._parentElement.clientWidth,this._tempContainerHeight=this._parentElement.clientHeight;break;case SizeCalculationType.BOUNDING_BOX:this._tempContainerWidth=this._parentElement.getBoundingClientRect().width,this._tempContainerHeight=this._parentElement.getBoundingClientRect().height;break;case SizeCalculationType.FULL_BOX:this._tempContainerWidth=DomUtilities.calculateDimensionsWithMargins(this._parentElement).width,this._tempContainerHeight=DomUtilities.calculateDimensionsWithMargins(this._parentElement).height}this._logger.info(this,"onResize called: "+this._tempContainerWidth+"x"+this._tempContainerHeight+" ("+e+")"),this.resizeVideoContainer(),this.scaleVideo(),this._videoContainer.style.display="block",this._main.dispatchEvent("resizeUpdate",{ref:this._main,width:this._tempContainerWidth,height:this._tempContainerHeight})}},this._main=e,this._logger=e.getLogger(),this._logger.info(this,"Creating new StageController"),this.initialize()}initialize(){var e=null!=(e=null==(e=null==(e=null==(e=this._main.getConfigManager())?void 0:e.getSettingsData())?void 0:e.getVideoData())?void 0:e.containerID)?e:null,t=(this._scalingMode=null!=(t=null==(t=this._main.getConfigManager())?void 0:t.getSettingsData().getVideoData().scalingMode)?t:ScalingType.FILL,this._videoContainer=document.createElement("div"),this._videoContainer.setAttribute("id","stormStreamer_"+this._main.getStreamerID()),this._videoContainer.style.overflow="hidden",this._videoContainer.style.position="relative",this._videoContainer.classList.add("stormStreamer"),this._screenElement=new ScreenElement(this._main),this._videoContainer.appendChild(this._screenElement.getVideoElement()),this._main.getConfigManager().getSettingsData().getVideoData().resizeDebounce);this._resizeObserver=0<t?new ResizeObserver(debounce$1(()=>()=>{this._autoResizeEnabled&&this.onResize()},t,{leading:!1,trailing:!0})):new ResizeObserver(()=>{this._autoResizeEnabled&&this.onResize()}),document.addEventListener("fullscreenchange",this.onFullScreenChange,!1),document.addEventListener("webkitfullscreenchange",this.onFullScreenChange,!1),document.addEventListener("mozfullscreenchange",this.onFullScreenChange,!1),document.addEventListener("webkitendfullscreen",this.onFullScreenChange,!1),this._screenElement.getVideoElement().addEventListener("webkitendfullscreen",this.onFullScreenChange,!1),e?this.attachToParent(e):this._logger.warning(this,'Could not create HTMLObject for the library - "containerID" was not provided')}attachToParent(e){let t=!1,i=null;return console.log("xxxxxxxxx",e),"string"==typeof e?(this._logger.info(this,"Attaching container to ID: "+e),i=document.getElementById(e),console.log(">>",document.getElementById(e))):e instanceof HTMLElement&&(this._logger.info(this,"Attaching container to HTMLElement: "+e),i=e),i===this._parentElement?(this._logger.warning(this,"attachToParent :: container is the same"),!1):(i&&this._videoContainer?(this._parentElement=i,this._parentElement.appendChild(this._videoContainer),this._resizeObserver.observe(this._parentElement),this._parentElement.addEventListener("transitionend",()=>{this.onResize()}),this._main.dispatchEvent("containerChange",{ref:this._main,container:this._parentElement}),this.onResize(),t=!0):(console.log("tempParentElement",i),console.log("this._videoContainer",this._videoContainer),this._logger.warning(this,"attachToParent :: container was not found")),t)}detachFromParent(){let e=!1;return null!=this._parentElement&&null!=this._videoContainer?(this._logger.info(this,"Detaching from parent: "+this._videoContainer),this._parentElement.removeChild(this._videoContainer),this._resizeObserver&&(this._resizeObserver.unobserve(this._parentElement),this._resizeObserver.disconnect()),this._autoResizeEnabled&&this._parentElement.removeEventListener("transitionend",this.onResize),this._main.dispatchEvent("containerChange",{ref:this._main,container:null}),e=!0):this._logger.info(this,"Failed detaching from parent!"),this._parentElement=null,e}resizeVideoContainer(){var e=this._main.getConfigManager().getSettingsData().getVideoData().videoWidthInPixels,t=this._main.getConfigManager().getSettingsData().getVideoData().videoHeightInPixels,i=this._main.getConfigManager().getSettingsData().getVideoData().videoWidthValue,n=this._main.getConfigManager().getSettingsData().getVideoData().videoHeightValue,o=this._main.getConfigManager().getSettingsData().getVideoData().aspectRatio;let s=0,r=0;var a=Number(o.split(":")[0]),l=Number(o.split(":")[1]);"none"==o?(e?s=i:null!=this._parentElement&&(s=this._tempContainerWidth*i/100),t?r=n:null!=this._parentElement&&0==(r=this._tempContainerHeight*n/100)&&0!=this._videoHeight&&0!=this._videoWidth&&(r=this._videoHeight*s/this._videoWidth)):(e?s=i:null!=this._parentElement&&(s=this._tempContainerWidth*i/100),r=s*l/a),this._containerWidth=Math.ceil(s),this._containerHeight=Math.ceil(r),this._videoWidth=this._containerWidth,this._videoHeight=this._containerHeight,null!==this._videoContainer&&(this._videoContainer.style.width=this._containerWidth+"px",this._videoContainer.style.height=this._containerHeight+"px")}scaleVideo(){if(null!==this._screenElement){let e=0,t=0,i=0,n=0;switch(this._scalingMode){case ScalingType.FILL:i=this._containerWidth,n=this._containerHeight;break;case ScalingType.CROP:i=this._containerWidth,(n=this._videoHeight*this._containerWidth/this._videoWidth)>=this._containerHeight?(e=0,t=(n-this._containerHeight)/2*-1):(n=this._containerHeight,i=this._videoWidth*this._containerHeight/this._videoHeight,t=0,e=(i-this._containerWidth)/2*-1);break;case ScalingType.LETTER_BOX:i=this._containerWidth,(!((n=this._videoHeight*this._containerWidth/this._videoWidth)<=this._containerHeight)||(e=0,t=(n-this._containerHeight)/2*-1,n>this._containerHeight))&&(n=this._containerHeight,i=this._videoWidth*this._containerHeight/this._videoHeight,t=0,e=(i-this._containerWidth)/2*-1);break;case ScalingType.ORIGINAL:i=this._videoWidth,n=this._videoHeight,e=(this._videoWidth-this._containerWidth)/-2,t=(this._videoHeight-this._containerHeight)/-2}this._screenElement.getVideoElement().style.left=Math.floor(e)+"px",this._screenElement.getVideoElement().style.top=Math.floor(t)+"px",this._screenElement.getVideoElement().style.width=Math.ceil(i)+"px",this._screenElement.getVideoElement().style.height=Math.ceil(n)+"px",this._screenElement.getVideoElement().style.position="absolute",this._screenElement.getVideoElement().style.objectFit="fill"}}enterFullScreen(){var e;null!=(e=this._screenElement)&&e.getVideoElement().webkitEnterFullScreen?null!=(e=this._screenElement)&&e.getVideoElement().webkitEnterFullScreen():null!=(e=this._screenElement)&&e.getVideoElement().requestFullscreen()}exitFullScreen(){var e;null!=(e=this._screenElement)&&e.getVideoElement().webkitExitFullscreen?document.webkitExitFullscreen():document.exitFullscreen()}isFullScreenMode(){return this.isInFullScreenMode}setDimension(e,t){var i="width"===e?"videoWidth":"videoHeight";let n,o;if("number"==typeof t)o=t,n=!0;else{if("string"!=typeof t)throw new Error(`Unknown value for parameter "${e}" - it must be a number or a string!`);o=parseInt(t),n=t.toLowerCase().endsWith("px")}this._main.getConfigManager().getSettingsData().getVideoData()[i+"Value"]=o,this._main.getConfigManager().getSettingsData().getVideoData()[i+"InPixels"]=n,this.resizeVideoContainer(),this.scaleVideo()}setSize(e,t){this.setDimension("width",e),this.setDimension("height",t)}setWidth(e){this.setDimension("width",e)}setHeight(e){this.setDimension("height",e)}getParentElement(){return this._parentElement}setScalingMode(e){switch(e.toLowerCase()){case"fill":this._scalingMode=ScalingType.FILL;break;case"crop":this._scalingMode=ScalingType.CROP;break;case"letterbox":this._scalingMode=ScalingType.LETTER_BOX;break;case"original":this._scalingMode=ScalingType.ORIGINAL}this.scaleVideo()}getContainerWidth(){return this._containerWidth}getContainerHeight(){return this._containerHeight}getScalingModeAsString(){let e="";switch(this._scalingMode){case ScalingType.FILL:e="fill";break;case ScalingType.CROP:e="crop";break;case ScalingType.LETTER_BOX:e="letterbox";break;case ScalingType.ORIGINAL:e="original"}return e}getScalingMode(){return this._scalingMode}getScreenElement(){return this._screenElement}getContainer(){return this._videoContainer}destroy(){this.detachFromParent()}}StageController.LOG_ACTIVITY=!0;class MungeSDP{constructor(){}addAudio(e,t){let i="",n="",o=!1;for(const s of e.split(/\r\n/))s.length<=0||(0===s.indexOf("m=audio")?i="audio":0===s.indexOf("m=video")&&(i="video"),n=n+s+"\r\n","audio"!==i)||0!=="a=rtcp-mux".localeCompare(s)||o||(n+=t,o=!0);return n}addVideo(e,t){e=e.split(/\r\n/);let i="",n=!1,o=!1;for(const r of e)r.length<=0||(r.includes("a=rtcp-rsize")&&(o=!0),r.includes("a=rtcp-mux"));let s=!1;for(const a of e)a.startsWith("m=video")&&(s=!0),i=i+a+"\r\n",s&&(0==="a=rtcp-rsize".localeCompare(a)&&!n&&o&&(i+=t,n=!0),0==="a=rtcp-mux".localeCompare(a)&&n&&!o&&(i+=t,n=!0),0!=="a=rtcp-mux".localeCompare(a)||n||o||(n=!0));return i}deliverCheckLine(e,t){for(const n in MungeSDP.SDPOutput){var i=MungeSDP.SDPOutput[n];if(i.includes(e)){if(e.includes("VP9")||e.includes("VP8")){let e="";for(const o of i.split(/\r\n/))e=e+o+"\r\n";return t.includes("audio")&&(MungeSDP.audioIndex=parseInt(n)),t.includes("video")&&(MungeSDP.videoIndex=parseInt(n)),e}return t.includes("audio")&&(MungeSDP.audioIndex=parseInt(n)),t.includes("video")&&(MungeSDP.videoIndex=parseInt(n)),i}}return""}checkLine(t){if(t.startsWith("a=rtpmap")||t.startsWith("a=rtcp-fb")||t.startsWith("a=fmtp")){var i=t.split(":");if(1<i.length){i=i[1].split(" ");if(!isNaN(parseInt(i[0]))&&!i[1].startsWith("http")&&!i[1].startsWith("ur")){let e=MungeSDP.SDPOutput[i[0]];return e=e||"",e+=t+"\r\n",MungeSDP.SDPOutput[i[0]]=e,!1}}}return!0}getrtpMapID(e){var t=new RegExp("a=rtpmap:(\\d+) (\\w+)/(\\d+)"),e=e.match(t);return e&&3<=e.length?e:null}mungeSDPPublish(e,t){MungeSDP.SDPOutput={},MungeSDP.videoChoice="42e01f",MungeSDP.audioChoice="opus",MungeSDP.videoIndex=-1,MungeSDP.audioIndex=-1;e=e.split(/\r\n/);let i="header",n=!1,o="";null!=t.videoCodec&&""!==t.videoCodec&&(MungeSDP.videoChoice=t.videoCodec),null!=t.audioCodec&&""!==t.audioCodec&&(MungeSDP.audioChoice=t.audioCodec);for(const a of e)a.length<=0||this.checkLine(a)&&(o=o+a+"\r\n");o=this.addAudio(o,this.deliverCheckLine(MungeSDP.audioChoice,"audio"));var s,r,e=(o=this.addVideo(o,this.deliverCheckLine(MungeSDP.videoChoice,"video"))).split(/\r\n/);o="";for(const l of e)if(!(l.length<=0)){let e;if(0===l.indexOf("m=audio")&&-1!==MungeSDP.audioIndex)e=l.split(" "),o+=e[0]+" "+e[1]+" "+e[2]+" "+MungeSDP.audioIndex+"\r\n",i="audio",n=!1;else if(0===l.indexOf("m=video")&&-1!==MungeSDP.videoIndex)e=l.split(" "),o+=e[0]+" "+e[1]+" "+e[2]+" "+MungeSDP.videoIndex+"\r\n",i="video",n=!1;else{if(o+=l,0===l.indexOf("a=rtpmap")&&(i="bandwidth",n=!1),"chrome"!==UserCapabilities.getBrowserName().toLowerCase()&&"safari"!==UserCapabilities.getBrowserName().toLowerCase()||0!==l.indexOf("a=mid:")&&0!==l.indexOf("a=rtpmap")||n||(0==="audio".localeCompare(i)?(void 0!==t.audioBitrate&&""!==t.audioBitrate&&(o=(o+="\r\nb=CT:"+t.audioBitrate)+"\r\nb=AS:"+t.audioBitrate),n=!0):0==="video".localeCompare(i)?(void 0!==t.videoBitrate&&""!==t.videoBitrate&&(o=(o+="\r\nb=CT:"+t.videoBitrate)+"\r\nb=AS:"+t.videoBitrate,void 0!==t.videoFrameRate)&&(o+="\r\na=framerate:"+t.videoFrameRate),n=!0):"chrome"===UserCapabilities.getBrowserName().toLowerCase()&&0==="bandwidth".localeCompare(i)&&null!==(r=this.getrtpMapID(l))&&(s=r[2].toLowerCase(),0!=="vp9".localeCompare(s)&&0!=="vp8".localeCompare(s)&&0!=="h264".localeCompare(s)&&0!=="red".localeCompare(s)&&0!=="ulpfec".localeCompare(s)&&0!=="rtx".localeCompare(s)||void 0!==t.videoBitrate&&(o+="\r\na=fmtp:"+r[1]+" x-google-min-bitrate="+t.videoBitrate+";x-google-max-bitrate="+t.videoBitrate),0!=="opus".localeCompare(s)&&0!=="isac".localeCompare(s)&&0!=="g722".localeCompare(s)&&0!=="pcmu".localeCompare(s)&&0!=="pcma".localeCompare(s)&&0!=="cn".localeCompare(s)||void 0!==t.audioBitrate&&(o+="\r\na=fmtp:"+r[1]+" x-google-min-bitrate="+t.audioBitrate+";x-google-max-bitrate="+t.audioBitrate))),"firefox"===UserCapabilities.getBrowserName().toLowerCase()&&0===l.indexOf("c=IN")){if(0==="audio".localeCompare(i)){""!==t.audioBitrate&&"string"==typeof t.audioBitrate&&(s=parseInt(t.audioBitrate),o=(o+="\r\nb=TIAS:"+(1e3*s*.95-16e3)+"\r\n")+"b=AS:"+s+"\r\nb=CT:"+s+"\r\n");continue}if(0==="video".localeCompare(i)){""!==t.videoBitrate&&"string"==typeof t.videoBitrate&&(r=parseInt(t.videoBitrate),o=(o+="\r\nb=TIAS:"+1e3*(1e3*r*.95-16e3)+"\r\n")+"b=AS:"+r+"\r\nb=CT:"+r+"\r\n");continue}}o+="\r\n"}}return o}mungeSDPPlay(e){let n="";for(const r of e.split(/\r\n/))if(0!==r.length){if(r.includes("profile-level-id")){var o=r.substr(r.indexOf("profile-level-id")+17,6);let e=Number("0x"+o.substr(0,2)),t=Number("0x"+o.substr(2,2)),i=Number("0x"+o.substr(4,2));66<e&&(e=66,t=224,i=31),0===t&&(t=224);var s=("00"+e.toString(16)).slice(-2).toLowerCase()+("00"+t.toString(16)).slice(-2).toLowerCase()+("00"+i.toString(16)).slice(-2).toLowerCase();n+=r.replace(o,s)}else n+=r;n+="\r\n"}return n}}MungeSDP.SDPOutput={},function(e){e[e.VIDEO_INPUT=0]="VIDEO_INPUT",e[e.AUDIO_INPUT=1]="AUDIO_INPUT"}(InputType=InputType||{});class InputDevice{constructor(e,t){if(this._groupID="",this._isSelected=!1,null==e)throw new Error("no input device");if(void 0===e.deviceId||null===e.deviceId)throw new Error("no deviceID");if(this._id=e.deviceId,void 0===e.kind||null===e.kind)throw new Error("no device kind");switch(e.kind){case"videoinput":this._inputType=InputType.VIDEO_INPUT;break;case"audioinput":this._inputType=InputType.AUDIO_INPUT;break;default:throw new Error("incorrect kind")}null!==e.label&&""!==e.label?this._label=this.cleanLabel(e.label):this._label=this._inputType==InputType.VIDEO_INPUT?"Camera "+t:"Microphone "+t,void 0!==e.groupId&&null!==e.groupId&&(this._groupID=e.groupId)}cleanLabel(e){return e}getLabel(){return this._label}getID(){return this._id}getGroupID(){return this._groupID}getIfSelected(){return this._isSelected}setSelected(e){this._isSelected=e}}class InputDeviceList{constructor(){this._internalList=new Array}push(t){let i=!1;if(0<this._internalList.length){for(let e=0;e<this._internalList.length;e++)""!==this._internalList[e].getGroupID()&&this._internalList[e].getGroupID()==t.getGroupID()&&(i=!0,this._internalList[e]=t);return 0==i?this._internalList.push(t):this._internalList.length}return this._internalList.push(t)}get(e){return this._internalList[e]}getSize(){return this._internalList.length}getArray(){return this._internalList}}exports.PublishState=void 0,function(e){e.NOT_INITIALIZED="NOT_INITIALIZED",e.INITIALIZED="INITIALIZED",e.CONNECTING="CONNECTING",e.PUBLISHED="PUBLISHED",e.UNPUBLISHED="UNPUBLISHED",e.STOPPED="STOPPED",e.UNKNOWN="UNKNOWN",e.ERROR="ERROR"}(exports.PublishState||(exports.PublishState={}));class SoundMeter{constructor(e){this._instant=0,this._slow=0,this.clip=0,this._main=e}attach(e){this._stream=e,this.audioContext=new AudioContext,this.microphone=this.audioContext.createMediaStreamSource(e),this.processor=this.audioContext.createScriptProcessor(2048,1,1),this.microphone.connect(this.processor),this.processor.connect(this.audioContext.destination),this.processor.onaudioprocess=e=>{this.onAudioProcess(e)}}detach(){null!==this.microphone&&this.microphone.disconnect(),null!==this.processor&&this.processor.disconnect()}clear(){this._instant=0,this._slow=0,this.clip=0}onAudioProcess(e){var t=e.inputBuffer.getChannelData(0);let i,n=0,o=0;for(i=0;i<t.length;++i)n+=t[i]*t[i],.99<Math.abs(t[i])&&(o+=1);this._instant=Math.sqrt(n/t.length),this._slow=.05*this._instant+.95*this._slow,this.clip=o/t.length,this._main.dispatchEvent("soundMeter",{ref:this._main,high:this._instant,low:this._slow})}}class PlaybackController{constructor(e){this._isWindowActive=!0,this._peerConnectionConfig={iceServers:[]},this._isMicrophoneMuted=!1,this._constraints={video:{width:{min:"640",ideal:"1024",max:"1024"},height:{min:"360",ideal:"576",max:"576"},frameRate:{min:24,ideal:30,max:30}},audio:!0},this._publishState=exports.PublishState.NOT_INITIALIZED,this.onServerDisconnect=()=>{},this.onServerConnect=()=>{this._peerConnection=new RTCPeerConnection(this._peerConnectionConfig),this._peerConnection.onicecandidate=e=>{this.onIceCandidate(e)},this._peerConnection.onconnectionstatechange=e=>{this.onConnectionStateChange(e)},this._peerConnection.onnegotiationneeded=e=>{this._peerConnection.createOffer(e=>{this.onDescriptionSuccess(e)},e=>{this.onDescriptionError(e)}).catch(e=>{console.log(e)})};var e,t=this._stream.getTracks();for(e in t)this._peerConnection.addTrack(t[e],this._stream)},this.onDescriptionSuccess=t=>{var e;console.log("%cāµ š„ onDescriptionSuccess ","background: green; color: white;");const i={applicationName:null==(e=null==(e=this._main.getNetworkController())?void 0:e.getConnection().getCurrentServer())?void 0:e.getApplication(),streamName:null==(e=this._main.getConfigManager())?void 0:e.getStreamData().streamKey,sessionId:"[empty]"};t.sdp=this._mungeSDP.mungeSDPPublish(t.sdp,{audioBitrate:"64",videoBitrate:"1500",videoFrameRate:30,videoCodec:"42e01f",audioCodec:"opus"}),this._peerConnection.setLocalDescription(t).then(()=>{var e;null!=(e=this._main.getNetworkController())&&e.sendMessage('{"direction":"publish", "command":"sendOffer", "streamInfo":'+JSON.stringify(i)+', "sdp":'+JSON.stringify(t)+"}")}).catch(e=>{console.log(e)})},this.visibilityChange=()=>{"hidden"===document.visibilityState?this.onWindowBlur():"visible"===document.visibilityState&&this.onWindowFocus()},this.onWindowBlur=()=>{this._isWindowActive&&this._logger.warning(this,"Player window is no longer in focus!"),this._isWindowActive=!1},this.onWindowFocus=()=>{this._isWindowActive||this._logger.info(this,"Player window is focused again!"),this._isWindowActive=!0},this._main=e,this._logger=e.getLogger(),this._logger.info(this,"Creating new PlaybackController"),this._mungeSDP=new MungeSDP,this._soundMeter=new SoundMeter(this._main),this.initialize()}initialize(){var e;this._main.addEventListener("serverConnect",this.onServerConnect,!1),this._main.addEventListener("serverDisconnect",this.onServerDisconnect,!1),document.addEventListener("visibilitychange",this.visibilityChange),window.addEventListener("blur",this.onWindowBlur),window.addEventListener("focus",this.onWindowFocus),null!=(e=this._main.getConfigManager())&&e.getSettingsData().autoConnect?(this._logger.info(this,"Initializing NetworkController (autoConnect is true)"),null!=(e=this._main.getNetworkController())&&e.initialize()):this._logger.warning(this,"Warning - autoConnect is set to false, switching to standby mode!"),null!=(null==(e=this._main.getConfigManager())?void 0:e.getStreamData().streamKey)&&this.startWebRTC()}startWebRTC(){try{navigator.mediaDevices.getUserMedia?navigator.mediaDevices.getUserMedia(this._constraints).then(e=>{this.onUserMediaSuccess(e)}).catch(e=>{this.onUserMediaError(e)}):(this._logger.error(this,"WebRTCStreamer :: Browser does not support WebRTC"),this._main.dispatchEvent("compatibilityError",{ref:this._main,message:"WebRTC is not supported"}))}catch(e){this.onUserMediaError(e)}}publish(e){this._publishState==exports.PublishState.PUBLISHED&&this.closeStream(),this._main.getConfigManager().getStreamData().streamKey=e,this.startWebRTC()}unpublish(){this.closeStream()}onUserMediaSuccess(e){console.log("%cāµ š„ onUserMediaSuccess","background: green; color: white;"),this._logger.success(this,"WebRTCStreamer :: WebRTC UserMedia successfully retrieved"),this._stream=e,this._soundMeter.attach(this._stream),this.setPublishState(exports.PublishState.INITIALIZED),null!=this._cameraList&&null!=this._microphoneList||this.grabDevices();var t=this._main.getStageController().getScreenElement().getVideoElement();t.srcObject=e,t.autoplay=!0,t.playsInline=!0,t.disableRemotePlayback=!0,t.controls=!1,null!=(e=this._main.getNetworkController())&&e.start()}onUserMediaError(e){switch(console.log("%cāµ š„ onUserMediaError: "+JSON.stringify(e),"background: green; color: white;"),e.message){case"Permission denied":case"The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.":case"The request is not allowed by the user agent or the platform in the current context.":this._logger.warning(this,"WebRTCStreamer :: No permission to access camera & microphone"),this._main.dispatchEvent("inputDeviceDenied",{ref:this._main});break;case"The object can not be found here.":case"Requested device not found":this._logger.warning(this,"WebRTCStreamer :: Could not access camera or microphone"),this._main.dispatchEvent("inputDeviceError",{ref:this._main});break;default:this._logger.warning(this,"WebRTCStreamer :: Unsupported onUserMediaError: "+e.message)}}onSocketMessage(e){var t=JSON.parse(e);switch(Number(t.status)){case 200:console.log("%cāµ š„ onSocketMessage: 200","background: green; color: white;");var i=t.sdp,n=(void 0!==i&&this._peerConnection.setRemoteDescription(new RTCSessionDescription(i),()=>{},()=>{}),t.iceCandidates);if(void 0!==n)for(var o in n)this._peerConnection.addIceCandidate(new RTCIceCandidate(n[o]));break;case 503:console.log("%cāµ š„ onSocketMessage: 503","background: green; color: white;"),this._main.dispatchEvent("streamKeyInUse",{ref:this._main,streamKey:this._main.getConfigManager().getStreamData().streamKey}),this.setPublishState(exports.PublishState.ERROR)}}onConnectionStateChange(e){if(console.log("%cāµ š„ onConnectionStateChange: "+e.currentTarget.connectionState,"background: green; color: white;"),null!==e)switch(e.currentTarget.connectionState){case"connecting":this._logger.info(this,"WebRTCStreamer :: Event: onStreamerConnecting"),this.setPublishState(exports.PublishState.CONNECTING);break;case"connected":this._logger.info(this,"WebRTCStreamer :: Event: onStreamerConnected"),this.setPublishState(exports.PublishState.PUBLISHED),this.muteMicrophone(this._isMicrophoneMuted);break;case"disconnected":this._logger.info(this,"WebRTCStreamer :: Event: onStreamerDisconnected"),this.setPublishState(exports.PublishState.UNPUBLISHED);break;case"failed":this._logger.info(this,"WebRTCStreamer :: Event: onPlayerFailed"),this.setPublishState(exports.PublishState.ERROR);break;default:this._logger.info(this,"WebRTCStreamer :: Unsupported onConnectionStateChange: "+e.currentTarget.connectionState)}}grabDevices(){navigator.mediaDevices.enumerateDevices().then(t=>{this._cameraList=new InputDeviceList,this._microphoneList=new InputDeviceList;for(let e=0;e<t.length;e++)try{var i,n;"videoinput"===t[e].kind?(i=new InputDevice(t[e],e),this._cameraList.push(i)):"audioinput"===t[e].kind&&(n=new InputDevice(t[e],e),this._microphoneList.push(n))}catch(e){this._logger.error(this,"WebRTCStreamer :: Input Device Error: "+e)}if(0==this._cameraList.getSize())this._main.dispatchEvent("noCameraFound",{ref:this._main});else if(0==this._microphoneList.getSize())this._main.dispatchEvent("noMicrophoneFound",{ref:this._main});else{this._logger.info(this,"Camera list:");for(let e=0;e<this._cameraList.getSize();e++)this._logger.info(this,"=> ["+e+"] InputDevice: "+this._cameraList.get(e).getLabel());this._logger.info(this,"Microphone list:");for(let e=0;e<this._microphoneList.getSize();e++)this._logger.info(this,"=> ["+e+"] InputDevice: "+this._microphoneList.get(e).getLabel());this._selectedCamera=this.pickCamera(),this._selectedMicrophone=this.pickMicrophone()}}).catch(()=>{this._main.dispatchEvent("inputDeviceError",{ref:this._main})})}selectCamera(t){var i;for(let e=0;e<this._cameraList.getSize();e++)if(this._cameraList.get(e).getID()==t){this._selectedCamera=this._cameraList.get(e),null!=(i=this._main.getStorageManager())&&i.saveField("cameraID",this._selectedCamera.getID());break}this.closeStream(),this._constraints.video.deviceId=this._selectedCamera.getID(),this.startWebRTC()}selectMicrophone(t){var i;for(let e=0;e<this._microphoneList.getSize();e++)if(this._microphoneList.get(e).getID()==t){this._selectedMicrophone=this._microphoneList.get(e),null!=(i=this._main.getStorageManager())&&i.saveField("microphoneID",this._selectedMicrophone.getID());break}this.closeStream(),this._constraints.audio={deviceId:this._selectedMicrophone.getID()},this.startWebRTC()}pickCamera(){for(let e=0;e<this._cameraList.getSize();e++)this._cameraList.get(e).setSelected(!1);var e=null!=(e=null==(e=this._main.getStorageManager())?void 0:e.getField("cameraID"))?e:null;return null==this._selectedCamera||null==e?this._selectedCamera=this._cameraList.get(0):this.selectCamera(e),this._selectedCamera.setSelected(!0),this._main.dispatchEvent("deviceListUpdate",{ref:this._main,cameraList:this._cameraList.getArray(),microphoneList:this._microphoneList.getArray()}),this._selectedCamera}pickMicrophone(){for(let e=0;e<this._microphoneList.getSize();e++)this._microphoneList.get(e).setSelected(!1);var e=null!=(e=null==(e=this._main.getStorageManager())?void 0:e.getField("microphoneID"))?e:null;return null==this._selectedMicrophone||null==e?this._selectedMicrophone=this._microphoneList.get(0):this.selectMicrophone(e),this._selectedMicrophone.setSelected(!0),this._main.dispatchEvent("deviceListUpdate",{ref:this._main,cameraList:this._cameraList.getArray(),microphoneList:this._microphoneList.getArray()}),this._selectedMicrophone}muteMicrophone(t){if(this._isMicrophoneMuted=t,null!=this._stream){if(t?this._logger.success(this,"WebRTCStreamer1 :: Unmuting microphone"):this._logger.success(this,"WebRTCStreamer1 :: Muting microphone"),null!=this._stream.getAudioTracks())for(let e=0;e<this._stream.getAudioTracks().length;e++)this._stream.getAudioTracks()[e].enabled=t;this._isMicrophoneMuted=!t}else this._logger.warning(this,"WebRTCStreamer :: Stream object not present!");this._main.dispatchEvent("microphoneStateChange",{ref:this._main,isMuted:this._isMicrophoneMuted})}isMicrophoneMuted(){return this._isMicrophoneMuted}onDescriptionError(e){this._logger.info(this,"WebRTCStreamer :: onDescriptionError: "+JSON.stringify(e))}onIceCandidate(e){e.candidate}closeStream(){this._stream&&this._stream.getTracks().forEach(function(e){e.stop()}),this._soundMeter.detach(),void 0!==this._peerConnection&&null!==this._peerConnection&&this._peerConnection.close(),this.setPublishState(exports.PublishState.UNPUBLISHED)}getCurrentCamera(){return this._selectedCamera}getCurrentMicrophone(){return this._selectedMicrophone}setPublishState(e){this._publishState=e,this._main.dispatchEvent("publishStateChange",{ref:this._main,state:this._publishState})}getCameraList(){return null!=this._cameraList?this._cameraList.getArray():[]}getMicrophoneList(){return null!=this._microphoneList?this._microphoneList.getArray():[]}getPublishState(){return this._publishState}getPlayer(){return this._selectedPlayer}destroy(){var e;this.closeStream(),null!=(e=this._selectedPlayer)&&e.clear(),this._selectedPlayer=null,this._main.removeEventListener("serverConnect",this.onServerConnect),document.removeEventListener("visibilitychange",this.visibilityChange),window.removeEventListener("blur",this.onWindowBlur),window.removeEventListener("focus",this.onWindowFocus)}}!function(e){e[e.NOT_INITIALIZED=0]="NOT_INITIALIZED",e[e.STARTED=1]="STARTED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.CLOSED=4]="CLOSED",e[e.FAILED=5]="FAILED"}(ConnectionState=ConnectionState||{});class AbstractSocket{constructor(){this.CONNECTION_TIMEOUT=5,this.isBinary=!0,this._connectionState=ConnectionState.NOT_INITIALIZED,this._messageCount=0,this._disconnectedByUser=!1,this._isConnected=!1,this._sequenceNumber=-1}startConnection(){this._disconnectedByUser=!1,this._messageCount=0,this._isConnected=!1,this._disconnectedByUser=!1,this._connectionState=ConnectionState.CONNECTING,this.socket=new WebSocket(this.socketURL),this.isBinary&&(this.socket.binaryType="arraybuffer"),this.socket.onopen=e=>{clearTimeout(this._connectionTimeout),this._sequenceNumber++,this._connectionState=ConnectionState.CONNECTED,this.onSocketOpen(e)},this.socket.onmessage=e=>{this._messageCount++,this.onSocketMessage(e)},this.socket.onclose=e=>{clearTimeout(this._connectionTimeout),this._connectionState==ConnectionState.CONNECTED?(this._connectionState=ConnectionState.CLOSED,this.onSocketClose(e)):this._connectionState=ConnectionState.FAILED},this.socket.onerror=e=>{if(clearTimeout(this._connectionTimeout),this._connectionState==ConnectionState.CONNECTING&&this.onSocketError(e),this._connectionState==ConnectionState.CONNECTED)try{this.socket.close()}catch(e){}},this._connectionTimeout=setTimeout(()=>{try{this.socket.close()}catch(e){}this._connectionState==ConnectionState.CONNECTING&&(this._connectionState=ConnectionState.FAILED,this.onSocketError(new ErrorEvent("connectionTimeout")))},1e3*this.CONNECTION_TIMEOUT)}onSocketOpen(e){}onSocketClose(e){}onSocketMessage(e){}onSocketError(e){}onError(e){}sendData(e){if(this._connectionState==ConnectionState.CONNECTED&&null!==this.socket){if(null!=e)return void this.socket.send(e);this.onError("no data to send")}this.onError("socket not connected")}getConnectionState(){return this._connectionState}disconnect(e=!0){this._isConnected=!1,this._connectionState=ConnectionState.CLOSED,e&&(this._logger.warning(this,"Disconnected by user"),this._disconnectedByUser=e),null!=this.socket&&(this.socket.onopen=null,this.socket.onmessage=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.close())}destroy(){void 0!==this.socket&&null!==this.socket&&(this.socket.onopen=null,this.socket.onmessage=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.close()),this._connectionState=ConnectionState.CLOSED}getSocketURL(){return this.socketURL}}class WowzaConnection extends AbstractSocket{constructor(e,t){super(),this._logger=e.getLogger(),this._main=e,this._networkController=t,this.initialize()}initialize(){this._logger.info(this,"Starting new connection with a storm server"),this.pickServerFromList(this._main.getConfigManager().getStreamData().getServerList()),null!=this._currServer?(this.socketURL=this.createURL(this._currServer),this._logger.info(this,"Starting WebSocket connection with: "+this.socketURL),this._main.dispatchEvent("serverConnectionInitiate",{ref:this._main,serverURL:this.socketURL}),this._main.getConfigManager().getIfDemoMode()?(this._logger.warning(this,"Player is in demo mode, and will not connect with a server!"),this._main.dispatchEvent("authorizationComplete",{ref:this._main})):this.startConnection()):this._logger.error(this,"Connection with the server could not be initialized!")}onSocketOpen(e){this._logger.success(this,"Connection with the server has been established!"),this._main.dispatchEvent("serverConnect",{ref:this._main,serverURL:this.socketURL,sequenceNum:this._sequenceNumber}),this._isConnected=!0}onSocketError(e){this._isConnected=!1,this._disconnectedByUser||(this._logger.error(this,"Connection with the server failed"),this._main.dispatchEvent("serverConnectionError",{ref:this._main,serverURL:this.socketURL,restart:this._main.getConfigManager().getSettingsData().getIfRestartOnError(),sequenceNum:this._sequenceNumber}),0==this._isConnected&&(this._currServer.setAsFaild(!0),this.initiateReconnect()))}onSocketClose(e){this._isConnected=!1,this._disconnectedByUser?this._logger.warning(this,"Force disconnect from server!"):(this._logger.error(this,"Connection with the server has been closed"),this._main.dispatchEvent("serverDisconnect",{ref:this._main,serverURL:this.socketURL,restart:this._main.getConfigManager().getSettingsData().getIfRestartOnError(),sequenceNum:this._sequenceNumber}),this.initiateReconnect())}onSocketMessage(e){this._networkController.onMessage(e)}createURL(e){var t="";return(t+=e.getIfSSL()?"wss://":"ws://")+e.getHost()+(":"+e.getPort())+"/webrtc-session.json"}initiateReconnect(){var e=this._main.getConfigManager().getSettingsData().getIfRestartOnError();const t=this._main.getConfigManager().getSettingsData().getReconnectTime();this._disconnectedByUser||e&&(null!=this._reconnectTimer&&clearTimeout(this._reconnectTimer),this._reconnectTimer=setTimeout(()=>{this.pickServerFromList(this._main.getConfigManager().getStreamData().getServerList()),null!=this._currServer&&(this._logger.info(this,`Will reconnect to the server in ${t} seconds...`),this.socketURL=this.createURL(this._currServer),this._logger.info(this,"Starting WebSocket connection with: "+this.socketURL),this._main.dispatchEvent("serverConnectionInitiate",{ref:this._main,serverURL:this.socketURL}),this.startConnection())},1e3*t))}pickServerFromList(t){let i=null;for(let e=0;e<t.length;e++)if(!t[e].getIfFaild()){i=t[e];break}null==i?(this._logger.error(this,"All connections failed!"),this._main.dispatchEvent("allConnectionsFailed",{ref:this._main,mode:"none"}),this._currServer=null):this._currServer=i}isConnectionActive(){return this._isConnected}getCurrentServer(){return this._currServer}destroy(){super.destroy(),null!=this._reconnectTimer&&clearTimeout(this._reconnectTimer)}}class NetworkController{constructor(e){this._currentStreamKey="none",this._lastState="",this.onServerConnect=()=>{},this.onServerDisconnect=()=>{this._lastState="none"},this.onMessage=e=>{var t;null!=(t=this._main.getPlaybackController())&&t.onSocketMessage(e.data)},this._main=e,this._logger=e.getLogger(),this._main.addEventListener("serverConnect",this.onServerConnect,!1),this._main.addEventListener("serverDisconnect",this.onServerDisconnect,!1)}initialize(){null!=this._connection&&(this._connection.getConnectionState()==ConnectionState.CONNECTING||this._connection.getConnectionState()==ConnectionState.CONNECTED?this._logger.info(this,"Connection is alive, not doing anything!"):(this._logger.info(this,"Connection is dead, restarting!"),this._connection.startConnection()))}start(){this._connection=new WowzaConnection(this._main,this)}stop(){this._connection.disconnect(!0),this._lastState=""}sendMessage(e){this._connection.isConnectionActive()&&this._connection.sendData(e)}getConnection(){return this._connection}getCurrentStreamKey(){return this._currentStreamKey}}class StormStreamer extends EventDispatcher{constructor(e,t=!1){super(),this.DEV_MODE=!0,this.STREAMER_VERSION="0.9.0-beta.2",this.COMPILE_DATE="11/29/2024, 6:55:45 PM",this.STREAMER_BRANCH="Experimental",this.STREAMER_PROTOCOL_VERSION=1,this._initialized=!1,"undefined"!=typeof window&&window.document&&window.document.createElement?(!this.DEV_MODE||"StormStreamerArray"in window||(window.StormStreamerArray=[]),window.StormStreamerArray.push(this),this._streamerID=StormStreamer.NEXT_STREAMER_ID++,null!=e&&(this.setStreamConfig(e),t)&&this.initialize()):console.error('StormLibrary Creation Error - No "window" element in the provided context!')}initialize(){if(!this._isRemoved){if(null==this._configManager)throw Error("Stream Config was not provided for this library! A properly configured object must be provided through the constructor or via the setConfig method before using the initialize() method.");this._storageManager=new StorageManager(this),this._stageController=new StageController(this),this._networkController=new NetworkController(this),this._playbackController=new PlaybackController(this),this._clientUser=new ClientUser,this._initialized=!0,this.dispatchEvent("streamerReady",{ref:this})}}setStreamConfig(e){this._isRemoved||(e=JSON.parse(JSON.stringify(e)),null==this._configManager?(this._configManager=new ConfigManager(e),this._logger=new Logger(this._configManager.getSettingsData().getDebugData(),this),this._logger.info(this,"StreamerID: "+this._streamerID),this._logger.info(this,"Version: "+this.STREAMER_VERSION+" | Compile Date: "+this.COMPILE_DATE+" | Branch: "+this.STREAMER_BRANCH),this._logger.info(this,"UserCapabilities :: Browser: "+UserCapabilities.getBrowserName()+" "+UserCapabilities.getBrowserVersion()),this._logger.info(this,"UserCapabilities :: Operating System: "+UserCapabilities.getOS()+" "+UserCapabilities.getOSVersion()),this._logger.info(this,"UserCapabilities :: isMobile: "+UserCapabilities.isMobile()),this._logger.info(this,"UserCapabilities :: hasMSESupport: "+UserCapabilities.hasMSESupport()),this._logger.info(this,"UserCapabilities :: hasWebSocketSupport: "+UserCapabilities.hasWebSocketsSupport()),this._logger.info(this,"UserCapabilities :: hasWebRTCSupport: "+UserCapabilities.hasWebRTCSupport()),this._configManager.print(this._logger)):(this._logger.info(this,"StreamConfig has been overwritten, dispatching streamConfigChanged!"),this._configManager=new ConfigManager(e),this._configManager.print(this._logger),this.dispatchEvent("streamConfigChange",{ref:this,newConfig:this._configManager})))}stop(){}isConnected(){var e;return null!=(e=null==(e=this._networkController)?void 0:e.getConnection().isConnectionActive())&&e}attachToContainer(e){var t;return!!this._initialized&&null!=(t=null==(t=this._stageController)?void 0:t.attachToParent(e))&&t}detachFromContainer(){var e;return!!this._initialized&&null!=(e=null==(e=this._stageController)?void 0:e.detachFromParent())&&e}getContainer(){var e;return null!=(e=null==(e=this._stageController)?void 0:e.getParentElement())?e:null}mute(){null!=this._stageController&&null!=this._stageController.getScreenElement()?this._stageController.getScreenElement().setMuted(!0):this._configManager.getSettingsData().getAudioData().muted=!0}unmute(){null!=this._stageController&&null!=this._stageController.getScreenElement()?this._stageController.getScreenElement().setMuted(!1):this._configManager.getSettingsData().getAudioData().muted=!1}isMute(){var e;return null!=(e=null!=(e=null==(e=null==(e=this._stageController)?void 0:e.getScreenElement())?void 0:e.getIfMuted())?e:this._configManager.getSettingsData().getAudioData().muted)&&e}toggleMute(){var e=this.isMute();return e?this.unmute():this.mute(),!e}setVolume(e){var t;void 0===(null==(t=null==(t=this._stageController)?void 0:t.getScreenElement())?void 0:t.setVolume(e))&&(this._configManager.getSettingsData().getAudioData().startVolume=e)}getVolume(){var e;return null!=(e=null==(e=null==(e=this._stageController)?void 0:e.getScreenElement())?void 0:e.getVolume())?e:this._configManager.getSettingsData().getAudioData().startVolume}getCameraList(){var e;return null!=(e=null==(e=this._playbackController)?void 0:e.getCameraList())?e:[]}getMicrophoneList(){var e;return null!=(e=null==(e=this._playbackController)?void 0:e.getMicrophoneList())?e:[]}setCamera(e){var t;null!=(t=this._playbackController)&&t.selectCamera(e)}setMicrophone(e){var t;null!=(t=this._playbackController)&&t.selectMicrophone(e)}getCurrentCamera(){return this._playbackController.getCurrentCamera()}getCurrentMicrophone(){return this._playbackController.getCurrentMicrophone()}muteMicrophone(e){var t;null!=(t=this._playbackController)&&t.muteMicrophone(e)}isMicrophoneMuted(){var e;return null!=(e=null==(e=this._playbackController)?void 0:e.isMicrophoneMuted())&&e}getPublishState(){var e;return null!=(e=null==(e=this._playbackController)?void 0:e.getPublishState())?e:exports.PublishState.NOT_INITIALIZED}publish(e){var t;null!=(t=this._playbackController)&&t.publish(e)}unpublish(){var e;null!=(e=this._playbackController)&&e.unpublish()}setSize(e,t){this._initialized?this._stageController.setSize(e,t):(e=NumberUtilities.parseValue(e),t=NumberUtilities.parseValue(t),this._configManager.getSettingsData().getVideoData().videoWidthValue=e.value,this._configManager.getSettingsData().getVideoData().videoWidthInPixels=e.isPixels,this._configManager.getSettingsData().getVideoData().videoHeightValue=t.value,this._configManager.getSettingsData().getVideoData().videoHeightInPixels=t.isPixels)}setWidth(e){this._initialized?this._stageController.setWidth(e):(e=NumberUtilities.parseValue(e),this._configManager.getSettingsData().getVideoData().videoWidthValue=e.value,this._configManager.getSettingsData().getVideoData().videoWidthInPixels=e.isPixels)}setHeight(e){this._initialized?this._stageController.setHeight(e):(e=NumberUtilities.parseValue(e),this._configManager.getSettingsData().getVideoData().videoHeightValue=e.value,this._configManager.getSettingsData().getVideoData().videoHeightInPixels=e.isPixels)}getWidth(){return this._initialized?this._stageController.getContainerWidth():this._configManager.getSettingsData().getVideoData().videoWidthInPixels?this._configManager.getSettingsData().getVideoData().videoWidthValue:0}getHeight(){return this._initialized?this._stageController.getContainerHeight():this._configManager.getSettingsData().getVideoData().videoHeightInPixels?this._configManager.getSettingsData().getVideoData().videoHeightValue:0}setScalingMode(e){this._stageController?this._stageController.setScalingMode(e):this._configManager.getSettingsData().getVideoData().scalingMode=e}getScalingMode(){return this._stageController?this._stageController.getScalingMode():this._configManager.getSettingsData().getVideoData().scalingMode}updateToSize(){this._initialized&&this._stageController.onResize()}makeScreenshot(){let i=document.createElement("canvas"),n=i.getContext("2d");return new Promise(t=>{var e;null!=this._stageController&&(i.width=this._stageController.getScreenElement().getVideoElement().videoWidth,i.height=this._stageController.getScreenElement().getVideoElement().videoHeight,e=this._stageController.getScreenElement().getVideoElement(),n)?(n.drawImage(e,0,0,i.width,i.height),i.toBlob(e=>{t(e)},"image/png")):t(null)})}enterFullScreen(){this._initialized&&this._stageController&&this._stageController.enterFullScreen()}exitFullScreen(){this._initialized&&this._stageController&&this._stageController.exitFullScreen()}isFullScreenMode(){return!(!this._initialized||!this._stageController)&&this._stageController.isFullScreenMode()}getStreamerID(){return this._streamerID}getLogger(){return this._logger}getConfigManager(){return this._configManager}getNetworkController(){return this._networkController}getPlaybackController(){return this._playbackController}getStageController(){return this._stageController}getVideoElement(){var e;return null!=(e=null==(e=null==(e=this._stageController)?void 0:e.getScreenElement())?void 0:e.getVideoElement())?e:null}isInitialized(){return this._initialized}getVersion(){return this.STREAMER_VERSION}getBranch(){return this.STREAMER_BRANCH}getStorageManager(){return this._storageManager}dispatchEvent(e,t){super.dispatchEvent(e,t)}destroy(){var e;this._logger.warning(this,"Destroying library instance, bye, bye!"),this.DEV_MODE&&"StormStreamerArray"in window&&(window.StormStreamerArray[this._streamerID]=null),this._initialized=!1,this._isRemoved=!0,null!=(e=this._networkController)&&e.getConnection().destroy(),null!=(e=this._stageController)&&e.destroy(),null!=(e=this._playbackController)&&e.destroy(),this.removeAllEventListeners()}}function create(e){return new StormStreamer(e)}StormStreamer.NEXT_STREAMER_ID=0,exports.StormStreamer=StormStreamer,exports.create=create;
|