UNPKG

@stormstreaming/stormlibrary

Version:

A JavaScript library containing core web video player functionality for embedding live-video streams on a website. Part of StormStreaming Suite.

14 lines 150 kB
/* * StormStreaming JavaScript Library * Copyright © 2021-2025 Web-Anatomy s.c. All rights reserved. * contact@stormstreaming.com * https://stormstreaming.com * * Version: 5.0.4 * Version: 2/4/2026, 1:57:23 PM * * LEGAL NOTICE: * This software is subject to the terms and conditions defined in * separate license conditions ('LICENSE.txt') * */class StormServerItem{constructor(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:443,a=!(3<arguments.length&&void 0!==arguments[3])||arguments[3];this.host=e,this.application=t,this.port=i,this.isSSL=a,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}}var SecurityType,ProtocolType,ScalingType,SizeCalculationType,LogType;(e=>{e[e.NONE=0]="NONE",e[e.TOKEN=1]="TOKEN"})(SecurityType=SecurityType||{});class SecurityData{constructor(e){this._securityMethod=SecurityType.NONE,this.parse(e)}parse(e){this._securityConfig=e,this._securityConfig?((e=null!=(e=this._securityConfig.type)?e:null)&&(this._securityMethod="token"===e?SecurityType.TOKEN:SecurityType.NONE),this._token=null!=(e=this._securityConfig.token)?e:null,this._secret=null!=(e=this._securityConfig.secret)?e:null):this._securityMethod=SecurityType.NONE}get securityType(){return this._securityMethod}set securityType(e){this._securityMethod="token"===e?SecurityType.TOKEN:SecurityType.NONE}get token(){return this._token}get secret(){return this._secret}set token(e){this._token=e}print(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(SecurityData.PRINT_ON_STARTUP||e){let e="";switch(this._securityMethod){case SecurityType.NONE:e="none";break;case SecurityType.TOKEN:e="token"}t.info(this,"Security Method: "+e)}}}SecurityData.PRINT_ON_STARTUP=!0;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(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 a=null!=(a=this._streamConfig.serverList[i].port)?a:StreamData.DEFAULT_CONNECTION_PORT,s=null!=(s=this._streamConfig.serverList[i].ssl)?s:StreamData.IS_SSL_BY_DEFAULT;this._serverList.push(new StormServerItem(e,t,a,s))}this._streamKey=null!=(e=this._streamConfig.streamKey)?e:this._streamKey,this._securityData=new SecurityData(null!=(e=this._streamConfig.security)?e:null)}getServerList(){return this._serverList}getSourceList(){return this._sourceList}get streamKey(){return this._streamKey}set streamKey(e){this._streamKey=e}getSecurityData(){return this._securityData}set serverList(e){this._serverList=e}set sourceList(e){this._sourceList=e}clearSourceList(){this._sourceList=new Array}clearServerList(){this._serverList=new Array}print(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[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),this._securityData.print(t)}}}StreamData.PRINT_ON_STARTUP=!0,StreamData.DEFAULT_CONNECTION_PORT=443,StreamData.IS_SSL_BY_DEFAULT=!0,(e=>{e.RTMP="RTMP",e.RTSP="RTSP",e.WEBRTC="WebRTC",e.HLS="HLS",e.STORM="Storm"})(ProtocolType=ProtocolType||{});let BufferData$1=class{constructor(e){this.PRINT_ON_STARTUP=!0,this._minValue=.2,this._maxValue=2,this._startValue=.5,this._targetValue=.7,this.parse(e)}parse(e){this._bufferConfig=e,this._bufferConfig&&(this._minValue=null!=(e=this._bufferConfig.minValue)?e:this._minValue,this._maxValue=null!=(e=this._bufferConfig.maxValue)?e:this._maxValue,this._startValue=null!=(e=this._bufferConfig.startValue)?e:this._startValue,this._targetValue=null!=(e=this._bufferConfig.targetValue)?e:this._targetValue)}get minValue(){return this._minValue}get maxValue(){return this._maxValue}get startValue(){return this._startValue}get targetValue(){return this._targetValue}set minValue(e){this._minValue=e}set maxValue(e){this._maxValue=e}set targetValue(e){this._targetValue=e}set startValue(e){this._startValue=e}print(e){(this.PRINT_ON_STARTUP||1<arguments.length&&void 0!==arguments[1]&&arguments[1])&&e.info(this,"BufferConfig :: minValue: "+this.minValue+" | maxValue: "+this.maxValue+" | startValue: "+this.startValue+" | targetValue: "+this.targetValue)}};(e=>{e.FILL="fill",e.LETTER_BOX="letterbox",e.CROP="crop",e.ORIGINAL="original"})(ScalingType=ScalingType||{}),(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(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)}}(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._playbackController=!1,this._qualityController=!1,this._stageController=!1,this._playerUnit=!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,this._playbackController=null!=(e=null==(e=this._debugConfig)?void 0:e.playbackController)?e:this._playbackController,this._qualityController=null!=(e=null==(e=this._debugConfig)?void 0:e.qualityController)?e:this._qualityController,this._stageController=null!=(e=null==(e=this._debugConfig)?void 0:e.stageController)?e:this._stageController,this._playerUnit=null!=(e=null==(e=this._debugConfig)?void 0:e.playerUnit)?e:this._playerUnit)}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: ".concat(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}get playbackControllerDebug(){return this._playbackController}get qualityControllerDebug(){return this._qualityController}get stageControllerDebug(){return this._stageController}get playerUnitDebug(){return this._playerUnit}print(e){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[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){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[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){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1];(StorageData.PRINT_ON_STARTUP||t)&&e.info(this,"Storage :: startVolume: "+this._enabled+" | prefix: "+this._prefix)}}StorageData.PRINT_ON_STARTUP=!0,exports.QualityControlMode=void 0,(e=>{e.PASSIVE="PASSIVE",e.RESOLUTION_AWARE="RESOLUTION_AWARE",e.UNKNOWN="UNKNOWN",e.HIGHEST_QUALITY="HIGHEST_QUALITY",e.LOWEST_QUALITY="LOWEST_QUALITY"})(exports.QualityControlMode||(exports.QualityControlMode={}));class QualityData{constructor(e){this.PRINT_ON_STARTUP=!0,this._qualityControlMode=exports.QualityControlMode.PASSIVE,this._initialUpgradeTimeout=30,this._maxUpgradeTimeout=3600,this.parse(e)}parse(e){this._qualityConfig=e,this._qualityConfig&&(this._qualityControlMode=null!=(e=this._qualityConfig.controlMode)?e:this._qualityControlMode,this._initialUpgradeTimeout=null!=(e=this._qualityConfig.initialUpgradeTimeout)?e:this._initialUpgradeTimeout,this._maxUpgradeTimeout=null!=(e=this._qualityConfig.maxUpgradeTimeout)?e:this._maxUpgradeTimeout)}get qualityControlMode(){return this._qualityControlMode}set qualityControlMode(e){this._qualityControlMode=e}get initialUpgradeTimeout(){return this._initialUpgradeTimeout}set initialUpgradeTimeout(e){this._initialUpgradeTimeout=e}get maxUpgradeTimeout(){return this._maxUpgradeTimeout}set maxUpgradeTimeout(e){this._maxUpgradeTimeout=e}print(e){(this.PRINT_ON_STARTUP||1<arguments.length&&void 0!==arguments[1]&&arguments[1])&&e.info(this,"QualityControl :: mode: "+this.qualityControlMode+" | initialUpgradeTime: "+this._initialUpgradeTimeout+" | maxUpgradeTime: "+this._maxUpgradeTimeout)}}class SettingsData{constructor(e){this._restartOnError=!0,this._reconnectTime=1,this._autoStart=!1,this._autoConnect=!0,this.startOnDOMReady=!1,this.iOSOnDomReadyFix=!0,this._enabledProtocols=new Array(ProtocolType.STORM,ProtocolType.RTMP,ProtocolType.HLS,ProtocolType.WEBRTC),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,null!=(e=this._settingsConfig.enabledProtocols)&&e.length&&(this._enabledProtocols=this._settingsConfig.enabledProtocols.map(e=>{switch(e.toLowerCase()){case"storm":return ProtocolType.STORM;case"hls":return ProtocolType.HLS;case"webrtc":return ProtocolType.WEBRTC;case"rtmp":return ProtocolType.RTMP;case"rtsp":return ProtocolType.RTSP;default:throw new Error('Unknown protocol "'.concat(e,'". Please check your config!'))}})),this._bufferData=new BufferData$1(null!=(e=this._settingsConfig.buffer)?e:null),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),this._qualityData=new QualityData(null!=(e=this._settingsConfig.quality)?e:null)}get enabledProtocols(){return this._enabledProtocols}set enabledProtocols(e){this._enabledProtocols=e}getBufferData(){return this._bufferData}getAudioData(){return this._audioData}getVideoData(){return this._videoData}getStorageData(){return this._storageData}getQualityData(){return this._qualityData}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){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(SettingsData.PRINT_ON_STARTUP||t){let t="";for(let e=0;e<this._enabledProtocols.length;e++)switch(this._enabledProtocols[e]){case ProtocolType.STORM:t+="STORM, ";break;case ProtocolType.RTMP:t+="RTMP, ";break;case ProtocolType.RTSP:t+="RTSP, ";break;case ProtocolType.HLS:t+="HLS, ";break;case ProtocolType.WEBRTC:t+="WebRTC, "}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: "+t),this._bufferData.print(e),this._qualityData.print(e),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){(this.PRINT_ON_STARTUP||1<arguments.length&&void 0!==arguments[1]&&arguments[1])&&(this.streamData.print(e),this.settingsData.print(e))}}class EventDispatcher{constructor(){this.DEBUG_OUTPUT=!1,this._isRemoved=!1,this._listeners={}}addEventListener(t,i){var e=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];this._listeners[t]||(this._listeners[t]=[]);let a=!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){a=!0;break}return this._logger.success(this,"Registering a new event: "+t),!a&&(this._listeners[t].push([t,i,e]),!0)}removeEventListener(t,i){let a=!1;if(null!=this._listeners[t]&&0<this._listeners[t].length)for(let e=0;e<this._listeners[t].length;e++){var s=this._listeners[t][e];if(i){if(s[1]==i){if(1!=s[2])break;a=!0,this._listeners[t].splice(e,1);break}}else a=!0,1==s[2]&&this._listeners[t].splice(e,1)}return this._logger.success(this,"Removing listener: "+t),a}removeAllEventListeners(){for(var e in this._logger.success(this,"Removing all listeners!"),this._listeners){var 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 formatTime(e){var t=Math.floor(e/3600),i=Math.floor(e%3600/60),e=e%60,i=(i<10?"0":"")+i,e=(e<10?"0":"")+e;return"".concat((t<10?"0":"")+t,":").concat(i,":").concat(e)}static generateUniqueString(t){let i="";var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s=a.length;for(let e=0;e<t;e++)i+=a.charAt(Math.floor(Math.random()*s));return i}static fibonacci(t){let i=0,a=1,s;if(t<=0)return 0;for(let e=2;e<=t;e++)s=i+a,i=a,a=s;return a}}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.libraryInstanceID=-1,this.playerInstanceID=-1,this.debugConfig=e,this._stormPlayer=t,this.libraryInstanceID=this._stormPlayer.getLibraryID();e=this.colorOrder.length<t.getLibraryID()?this.colorOrder.length-1:t.getLibraryID();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,a=NumberUtilities.addLeadingZero(i.getHours()),s=NumberUtilities.addLeadingZero(i.getMinutes()),i=NumberUtilities.addLeadingZero(i.getSeconds());let r=String(this.libraryInstanceID);0<=this.playerInstanceID&&(r+="|"+this.playerInstanceID);a="[Storm-ID:"+r+"] ["+a+":"+s+":"+i+"] :: "+t;return this.logMemory.push(a),a}writeToContainer(e,t){var i,a=this.debugConfig.containerID;a&&(a=document.getElementById(a),(i=document.createElement("span")).innerText=e,i.style.color=t,a.appendChild(i))}decoratedLog(e,t){var i=["0️⃣","1️⃣","2️⃣","3️⃣","4️⃣","5️⃣","6️⃣","7️⃣","8️⃣","9️⃣","🔟"],a=this._stormPlayer.getLibraryID(),i=0<=a&&a<i.length?i[a]:"[".concat(a,"]"),a={"dark-blue":"#4c9fee","dark-green":"#4bcb64","dark-orange":"#daa33a","dark-red":"#f86464","dark-pink":"#f864e8","dark-yellow":"#e1f864"}[t];a&&(t="background: black; color: ".concat(a,"; border: 1px solid ").concat(a,"; padding: 5px 5px 5px 0px"),console.log("%c ▶️".concat(i," ").concat(e),t))}setPlayerID(e){this.playerInstanceID=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 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 a=new RegExp("(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([\\.\\_\\d]+)");e=a.exec(navigator.userAgent)[1];break;case"iOS":a=new RegExp("OS (\\d+)_(\\d+)_?(\\d+)?");e=(e=a.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),a=parseInt(navigator.appVersion,10),s,r,n;return-1!=(r=e.indexOf("Opera"))?(t="Opera",i=e.substring(r+6),-1!=(r=e.indexOf("Version"))&&(i=e.substring(r+8))):-1!=(r=e.indexOf("MSIE"))?(t="Microsoft Internet Explorer",i=e.substring(r+5)):"Netscape"==t&&-1!=e.indexOf("Trident/")?(t="Microsoft Internet Explorer",i=e.substring(r+5),-1!=(r=e.indexOf("rv:"))&&(i=e.substring(r+3))):-1!=(r=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(r+7)):-1!=(r=e.indexOf("Safari"))?(t="Safari",i=e.substring(r+7),-1!=(r=e.indexOf("Version"))&&(i=e.substring(r+8)),-1!=e.indexOf("CriOS")&&(t="Chrome"),-1!=e.indexOf("FxiOS")&&(t="Firefox")):-1!=(r=e.indexOf("Firefox"))?(t="Firefox",i=e.substring(r+8)):(s=e.lastIndexOf(" ")+1)<(r=e.lastIndexOf("/"))&&(t=e.substring(s,r),i=e.substring(r+1),t.toLowerCase()==t.toUpperCase())&&(t=navigator.appName),-1!=(n=(i=-1!=(n=(i=-1!=(n=i.indexOf(";"))?i.substring(0,n):i).indexOf(" "))?i.substring(0,n):i).indexOf(")"))&&(i=i.substring(0,n)),a=parseInt(""+i,10),isNaN(a)&&(i=""+parseFloat(navigator.appVersion),a=parseInt(navigator.appVersion,10)),{name:t,fullVersion:i,version:a}}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 a=i[t];if(new RegExp(a.code).test(navigator.userAgent)){e=a.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){e=e||document.createElement("video");return Boolean(e.canPlayType("application/vnd.apple.mpegURL")||e.canPlayType("audio/mpegurl"))}static hasWebCodecsSupport(){return"undefined"!=typeof VideoDecoder&&"undefined"!=typeof AudioDecoder}static hasMSESupport(){var e=window.MediaSource||window.WebKitMediaSource;return!(!e||"function"!=typeof e.isTypeSupported)}static hasMMSSupport(){return!!window.ManagedMediaSource}static getSupportedVideoCodecs(){var e=[],t={h264:'video/mp4; codecs="avc1.42E01E"',"h264-high":'video/mp4; codecs="avc1.64001E"',hevc:'video/mp4; codecs="hev1.1.6.L93.B0"',av1:'video/mp4; codecs="av01.0.01M.08"',vp9:'video/webm; codecs="vp09.00.10.08"',vp8:'video/webm; codecs="vp8"'};if("undefined"!=typeof MediaSource&&MediaSource.isTypeSupported)for(var i in t)t.hasOwnProperty(i)&&MediaSource.isTypeSupported(t[i])&&e.push(i);return e}static getSupportedAudioCodecs(){var e=[],t={aac:'audio/mp4; codecs="mp4a.40.2"',"aac-he":'audio/mp4; codecs="mp4a.40.5"',opus:'audio/webm; codecs="opus"',mp3:"audio/mpeg"};if("undefined"!=typeof MediaSource&&MediaSource.isTypeSupported)for(var i in t)t.hasOwnProperty(i)&&MediaSource.isTypeSupported(t[i])&&e.push(i);return e}static isSSL(){return"https:"===location.protocol}}exports.PlaybackState=void 0,(e=>{e.INITIALIZED="INITIALIZED",e.PLAYING="PLAYING",e.BUFFERING="BUFFERING",e.PAUSED="PAUSED",e.STOPPED="STOPPED",e.UNKNOWN="UNKNOWN",e.ERROR="ERROR"})(exports.PlaybackState||(exports.PlaybackState={}));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(a,i,e){var s,r,n,o,l,h,u=0,g=!1,d=!1,t=!0;if("function"!=typeof a)throw new TypeError(FUNC_ERROR_TEXT);function c(e){var t=s,i=r;return s=r=void 0,u=e,o=a.apply(i,t)}function _(e){var t=e-h;return void 0===h||i<=t||t<0||d&&n<=e-u}function m(){var e,t=now();if(_(t))return p(t);l=setTimeout(m,(e=i-((t=t)-h),d?nativeMin(e,n-(t-u)):e))}function p(e){return l=void 0,t&&s?c(e):(s=r=void 0,o)}function S(){var e=now(),t=_(e);if(s=arguments,r=this,h=e,t){if(void 0===l)return u=e=h,l=setTimeout(m,i),g?c(e):o;if(d)return l=setTimeout(m,i),c(h)}return void 0===l&&(l=setTimeout(m,i)),o}return i=toNumber(i)||0,isObject(e)&&(g=!!e.leading,d="maxWait"in e,n=d?nativeMax(toNumber(e.maxWait)||0,i):n,t="trailing"in e?!!e.trailing:t),S.cancel=function(){void 0!==l&&clearTimeout(l),s=h=r=l=void(u=0)},S.flush=function(){return void 0===l?o:p(now())},S}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 TaskType,PlayerType,Stability,Trend,ConnectionState,lodash_debounce=debounce,debounce$1=getDefaultExportFromCjs(debounce);class ScreenElement{constructor(e){this.LOG_ACTIVITY=!0,this._volume=100,this._serviceMuted=!1,this._isMuted=!1,this._browserForcedMute=!1,this._posterCanvas=null,this._posters=[],this._debug=!1,this.onForceMute=()=>{this._browserForcedMute=!0,this.dispatchVolumeEvent("browser")},this.onPlaybackInitiate=()=>{var e=null==(e=this._main.getStorageManager())?void 0:e.getField("volume"),t=null==(t=this._main.getStorageManager())?void 0:t.getField("muted");null!=e&&(e=Number(e))!==this._volume&&(this._volume=e,this._videoElement.volume=e/100),null!=t&&(e="true"===t)!==this._isMuted&&(this._isMuted=e,this._videoElement.muted=this.getIfMuted())},this._main=e,this._logger=e.getLogger(),this._videoElement=document.createElement("video"),this._debug=null!=(e=null==(e=this._main.getConfigManager())?void 0:e.getSettingsData().getDebugData().stageControllerDebug)?e:this._debug,this._main.addEventListener("playbackForceMute",this.onForceMute,!1),this._main.addEventListener("playbackInitiate",this.onPlaybackInitiate,!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"))&&(i="true"==this._main.getStorageManager().getField("muted")),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._videoElement.onpause=e=>{var t,i;this._logger.info(this,"VideoElement :: onpause: "+(null==(t=this._main.getPlaybackController())?void 0:t.getPlaybackState())+" "+(null==(t=this._main.getNetworkController())?void 0:t.getConnection().isConnectionActive())),(null==(t=this._main.getPlaybackController())?void 0:t.getPlaybackState())===exports.PlaybackState.PLAYING&&(t=this._main.getStageController().getContainer(),i=document.body.contains(t),t&&i?this._videoElement.play().then(()=>{var e;null!=(e=null==(e=this._main.getStageController())?void 0:e.getScreenElement())&&e.deleteBlackBackground(),null!=(e=null==(e=this._main.getPlaybackController())?void 0:e.getPlayer())&&e.setPreparingToStart(!1),this._debug&&this._logger.decoratedLog("Playback Start","dark-green")}).catch(e=>{var t;null!=(t=null==(t=this._main.getPlaybackController())?void 0:t.getPlayer())&&t.setPreparingToStart(!1),this._logger.warning(this,"Error on Play(): "+e.name+" :: "+JSON.stringify(e)),"NotAllowedError"===e.name?(null!=(t=this._main.getPlaybackController())&&t.setPlaybackState(exports.PlaybackState.BUFFERING),this._browserForcedMute=!0,this._videoElement.muted=!0,this._main.dispatchEvent("playbackForceMute",{ref:this._main})):console.warn(e)}):(this._debug&&this._logger.decoratedLog("Paused due to not being part of DOM tree","dark-yellow"),this._main.dispatchEvent("playbackForcePause",{ref:this._main})))},this._videoElement.ontimeupdate=function(e){},this._videoElement.onended=e=>{this._logger.info(this,"VideoElement :: onended")},this._videoElement.onplay=()=>{var e;null!=(e=null==(e=this._main)?void 0:e.getPlaybackController())&&e.setPlaybackState(exports.PlaybackState.PLAYING)}}setVolume(e){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],i=t&&this.getIfMuted()&&0<e,a=t&&0==e;this._volume=e,this._videoElement.volume=e/100,t&&this._main.getStorageManager().saveField("volume",String(e)),i?this.setMuted(!1):a?this.setMuted(!0):this.dispatchVolumeEvent(t?"user":"service")}getVolume(){return this._volume}setMuted(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"user";"user"===t?((this._isMuted=e)||(this._serviceMuted=!1,this._browserForcedMute=!1),this._main.getStorageManager().saveField("muted",String(e))):this._serviceMuted=e,this._videoElement.muted=this.getIfMuted(),this.dispatchVolumeEvent(t)}getIfMuted(){return this._isMuted||this._serviceMuted||this._browserForcedMute}dispatchVolumeEvent(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"user";this._main.dispatchEvent("volumeChange",{ref:this._main,volume:this._volume,muted:this.getIfMuted(),invokedBy:e})}getVideoElement(){return this._videoElement}createBlackBackground(){this._videoElement&&(this._videoElement.style.backgroundColor="black")}deleteBlackBackground(){this._videoElement&&setTimeout(()=>{this._videoElement.style.backgroundColor=""},100)}}class DomUtilities{static calculateDimensionsWithMargins(e){var t=window.getComputedStyle(e),e=e.getBoundingClientRect(),i=parseFloat(t.paddingLeft),a=parseFloat(t.paddingRight),s=parseFloat(t.paddingTop),r=parseFloat(t.paddingBottom),n=parseFloat(t.borderLeftWidth),o=parseFloat(t.borderRightWidth),l=parseFloat(t.borderTopWidth),t=parseFloat(t.borderBottomWidth);return{width:e.width-i-a-n-o,height:e.height-s-r-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._debug=!1,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=()=>{null!=this._parentElement&&(this.onUpdateSize(),this._main.dispatchEvent("resizeUpdate",{ref:this._main,width:this._tempContainerWidth,height:this._tempContainerHeight}))},this.onUpdateSize=()=>{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=e,this._logger=e.getLogger(),this._logger.info(this,"Creating new StageController"),this._debug=null!=(e=null==(e=this._main.getConfigManager())?void 0:e.getSettingsData().getDebugData().stageControllerDebug)?e:this._debug,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","stormLibrary_"+this._main.getLibraryID()),this._videoContainer.style.overflow="hidden",this._videoContainer.style.position="relative",this._videoContainer.classList.add("stormLibrary"),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()}),this._main.addEventListener("streamMetadataUpdate",e=>{this._videoWidth=e.metadata.videoWidth,this._videoHeight=e.metadata.videoHeight,this.onUpdateSize()},!1),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),this._main.addEventListener("playbackInitiate",e=>{null!=this._videoContainer&&this._videoContainer.setAttribute("streamKey",e.streamKey)},!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"string"==typeof e?(this._logger.info(this,"Attaching container to ID: "+e),i=document.getElementById(e)):e instanceof HTMLElement&&(this._logger.info(this,"Attaching container to HTMLElement: "+e),i=e),i===this._parentElement?(this._debug&&this._logger.decoratedLog("Attaching Failed (container is the same)","dark-pink"),this._logger.warning(this,"attachToParent :: container is the same"),!1):(i&&this._videoContainer?(this._debug&&this._logger.decoratedLog("Attach To Parent: "+e+" (success)","dark-pink"),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):(this._debug&&this._logger.decoratedLog("Attach To Parent: "+e+" (failure - container not found)","dark-pink"),this._logger.warning(this,'attachToParent :: container "'+e+'"+ was not found')),t)}detachFromParent(){this._debug&&this._logger.decoratedLog("Detach From Parent","dark-pink");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,a=this._main.getConfigManager().getSettingsData().getVideoData().videoHeightValue,s=this._main.getConfigManager().getSettingsData().getVideoData().aspectRatio;let r=0,n=0;var o=Number(s.split(":")[0]),l=Number(s.split(":")[1]);"none"==s?(e?r=i:null!=this._parentElement&&(r=this._tempContainerWidth*i/100),t?n=a:null!=this._parentElement&&0==(n=this._tempContainerHeight*a/100)&&0!=this._videoHeight&&0!=this._videoWidth&&(n=this._videoHeight*r/this._videoWidth)):(e?r=i:null!=this._parentElement&&(r=this._tempContainerWidth*i/100),n=r*l/o),this._containerWidth=Math.ceil(r),this._containerHeight=Math.ceil(n),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,a=0;switch(this._scalingMode){case ScalingType.FILL:i=this._containerWidth,a=this._containerHeight;break;case ScalingType.CROP:i=this._containerWidth,(a=this._videoHeight*this._containerWidth/this._videoWidth)>=this._containerHeight?(e=0,t=(a-this._containerHeight)/2*-1):(a=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,(!((a=this._videoHeight*this._containerWidth/this._videoWidth)<=this._containerHeight)||(e=0,t=(a-this._containerHeight)/2*-1,a>this._containerHeight))&&(a=this._containerHeight,i=this._videoWidth*this._