@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 • 111 kB
JavaScript
/*
* StormStreaming JavaScript Library
* Copyright © 2021-2024 Web-Anatomy s.c. All rights reserved.
* contact@stormstreaming.com
* https://stormstreaming.com
*
* Version: 4.3.0
* Version: 7/23/2024, 12:24:38 PM
*
* LEGAL NOTICE:
* This software is subject to the terms and conditions defined in
* separate license conditions ('LICENSE.txt')
*
*/var stormLibrary=function(){"use strict";var i,h,r,l,o,s,e;(w=i=i||{})[w.STREAMER=0]="STREAMER",w[w.PLAYER=1]="PLAYER";class n{constructor(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:443,s=!(3<arguments.length&&void 0!==arguments[3])||arguments[3];this.host=e,this.application=t,this.port=i,this.isSSL=s,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}}(w=h=h||{})[w.NONE=0]="NONE",w[w.TOKEN=1]="TOKEN";class a{constructor(e){this.PRINT_ON_STARTUP=!0,this.securityMethod=h.NONE,this.token="",this.parse(e)}parse(e){null!=e?(void 0!==e.type&&null!==e.type&&("token"===e.type?this.securityMethod=h.TOKEN:this.securityMethod=h.NONE),void 0!==e.token&&null!==e.token&&(this.token=e.token)):this.securityMethod=h.NONE}setConfig(e){this.parse=e}getSecurityMethod(){return this.securityMethod}setSecurityMethod(e){this.securityMethod="token"===e?h.TOKEN:h.NONE}getToken(){return this.token}setToken(e){this.token=e}print(t){if(this.PRINT_ON_STARTUP||1<arguments.length&&void 0!==arguments[1]&&arguments[1]){let e="";switch(this.securityMethod){case h.NONE:e="none";break;case h.TOKEN:e="token"}t.info(this,"Security Method: "+e)}}}class t{constructor(e,t){this.type=e,this.streamInfo=t}getType(){return this.type}getStreamInfo(){return this.streamInfo}}(w=r=r||{}).RTMP="RTMP",w.RTSP="RTSP",w.WEBRTC="WebRTC",w.HLS="HLS",w.WEB_SOCKETS="WebSockets",w.MPEG_DASH="MpegDash",w.STORM="Storm";class C extends t{constructor(e,t,i){super(r.STORM,t),this.streamKey=e,this.defaultSource=i}getStreamKey(){return this.streamKey}isDefaultSource(){return this.defaultSource}toString(){return"type: Storm | streamKey: "+this.streamKey+" | streamInfo: "+this.streamInfo.toString()}}class b extends t{constructor(e,t,i){super(r.WEBRTC,t),this.streamKey=e,this.defaultSource=i}getStreamKey(){return this.streamKey}isDefaultSource(){return this.defaultSource}toString(){return"type: WebRTC | streamKey: "+this.streamKey}}class S extends t{constructor(e,t,i,s,o,n){super(r.RTMP,o),this.host=e,this.application=t,this.streamKey=i,this.port=s,this.defaultSource=n}getHost(){return this.host}getPort(){return this.port}getApplicationName(){return this.application}getStreamKey(){return this.streamKey}isDefaultSource(){return this.defaultSource}toString(){return"type: RTMP | url: "+this.host+" | port: "+this.port}}(w=l=l||{})[w.EMBEDDED=0]="EMBEDDED",w[w.GATEWAY=1]="GATEWAY";class y{constructor(e){this.bitrate=0,null!=e&&(this.label="sd",void 0!==e.label&&null!==e.label&&(this.label=e.label),void 0!==e.width&&null!==e.width&&(this.width=e.width),void 0!==e.height&&null!==e.height&&(this.height=e.height),void 0!==e.fps&&null!==e.fps&&(this.fps=e.fps),void 0!==e.bitrate)&&null!==e.bitrate&&(this.bitrate=e.bitrate)}getLabel(){return this.label}getWidth(){return this.width}getHeight(){return this.height}getFPS(){return this.fps}getBitrate(){return this.bitrate}toString(){return"label: "+this.label+" | width: "+this.width+" | height: "+this.height+" | bitrate: "+this.bitrate}}class B{constructor(e,t,i){this.streamName=e,this.applicationName=t,this.host=i}getStreamName(){return this.streamName}getApplicationName(){return this.applicationName}getHost(){return this.host}getType(){return r.WEBRTC}}class U extends t{constructor(e,t,i,s,o,n){super(r.RTSP,o),this.host=e,this.application=t,this.streamKey=i,this.port=s,this.defaultSource=n}getHost(){return this.host}getPort(){return this.port}getApplicationName(){return this.application}getStreamKey(){return this.streamKey}isDefaultSource(){return this.defaultSource}toString(){return"type: RTMP | url: "+this.host+" | port: "+this.port}}class W{constructor(e,t,i){this.PRINT_ON_STARTUP=!0,this.DEFAULT_STORM_PORT=443,this.IS_SSL_BY_DEFAULT=!0,this.serverList=new Array,this.sourceList=new Array,this.roleType=t,this.configurationType=i,this.parse(e,t)}parse(e,t){if(this.streamConfig=e,void 0===this.streamConfig||null===this.streamConfig)throw new Error("Stream configuration is missing. Please check stream config!");if(this.configurationType==l.EMBEDDED){if(t==i.PLAYER){if(void 0===this.streamConfig.serverList||null===this.streamConfig.serverList)throw new Error("Server list configuration is missing. Please check stream config!");if(0===this.streamConfig.serverList.length)throw new Error("Server list configuration is empty. Please check stream config!");for(let o=0;o<this.streamConfig.serverList.length;o++){let e,t,i=this.DEFAULT_STORM_PORT,s=this.IS_SSL_BY_DEFAULT;if(void 0===this.streamConfig.serverList[o].host||null===this.streamConfig.serverList[o].host)throw new Error('Error while parsing server object ("host" filed is missing). Please check player config!');if(e=this.streamConfig.serverList[o].host,void 0===this.streamConfig.serverList[o].application||null===this.streamConfig.serverList[o].application)throw new Error('Error while parsing server object ("application" filed is missing). Please check player config!');t=this.streamConfig.serverList[o].application,void 0!==this.streamConfig.serverList[o].port&&null!==this.streamConfig.serverList[o].port&&(i=this.streamConfig.serverList[o].port),void 0!==this.streamConfig.serverList[o].ssl&&null!==this.streamConfig.serverList[o].ssl&&(s=this.streamConfig.serverList[o].ssl),this.serverList.push(new n(e,t,i,s))}if(void 0===this.streamConfig.sourceList||null===this.streamConfig.sourceList)throw new Error("Source list configuration is missing. Please check player config!");if(0===this.streamConfig.sourceList.length)throw new Error("Source list configuration is missing. Please check player config!");for(let p=0;p<this.streamConfig.sourceList.length;p++){let f="none",m=!1;if(void 0===this.streamConfig.sourceList[p].protocol||null===this.streamConfig.sourceList[p].protocol)throw new Error('Error while parsing source object ("protocol" filed is missing). Please check player config!');switch(f=this.streamConfig.sourceList[p].protocol,void 0!==this.streamConfig.sourceList[p].default&&null!==this.streamConfig.sourceList[p].default&&(m=this.streamConfig.sourceList[p].default),f.toLowerCase()){case"storm":let e="",t=null;if(void 0===this.streamConfig.sourceList[p].streamKey||null===this.streamConfig.sourceList[p].streamKey)throw new Error('Missing "streamKey" parameter in stream source element');e=this.streamConfig.sourceList[p].streamKey,t=void 0!==this.streamConfig.sourceList[p].streamInfo&&null!==this.streamConfig.sourceList[p].streamInfo?this.streamConfig.sourceList[p].streamInfo:{label:"",width:0,height:0,fps:0,bitrate:0},this.sourceList.push(new C(e,new y(t),m));break;case"rtmp":let i="",s="",o="",n=1935,r=null;if(void 0===this.streamConfig.sourceList[p].host||null===this.streamConfig.sourceList[p].host)throw new Error('Missing "host" parameter in stream source element');if(i=this.streamConfig.sourceList[p].host,void 0===this.streamConfig.sourceList[p].application||null===this.streamConfig.sourceList[p].application)throw new Error('Missing "application" parameter in stream source element');if(s=this.streamConfig.sourceList[p].application,void 0===this.streamConfig.sourceList[p].streamKey||null===this.streamConfig.sourceList[p].streamKey)throw new Error('Missing "streamName" parameter in stream source element');o=this.streamConfig.sourceList[p].streamKey,void 0!==this.streamConfig.sourceList[p].port&&null!==this.streamConfig.sourceList[p].port&&(n=this.streamConfig.sourceList[p].port),r=void 0!==this.streamConfig.sourceList[p].streamInfo&&null!==this.streamConfig.sourceList[p].streamInfo?this.streamConfig.sourceList[p].streamInfo:{label:"",width:0,height:0,fps:0,bitrate:0},this.sourceList.push(new S(i,s,o,n,new y(r),m));break;case"rtsp":let a="",h="",l="",g=1935,c=null;if(void 0===this.streamConfig.sourceList[p].host||null===this.streamConfig.sourceList[p].host)throw new Error('Missing "host" parameter in stream source element');if(a=this.streamConfig.sourceList[p].host,void 0===this.streamConfig.sourceList[p].application||null===this.streamConfig.sourceList[p].application)throw new Error('Missing "application" parameter in stream source element');if(h=this.streamConfig.sourceList[p].application,void 0===this.streamConfig.sourceList[p].streamKey||null===this.streamConfig.sourceList[p].streamKey)throw new Error('Missing "streamName" parameter in stream source element');l=this.streamConfig.sourceList[p].streamKey,void 0!==this.streamConfig.sourceList[p].port&&null!==this.streamConfig.sourceList[p].port&&(g=this.streamConfig.sourceList[p].port),c=void 0!==this.streamConfig.sourceList[p].streamInfo&&null!==this.streamConfig.sourceList[p].streamInfo?this.streamConfig.sourceList[p].streamInfo:{label:"",width:0,height:0,fps:0,bitrate:0},this.sourceList.push(new U(a,h,l,g,new y(c),m));break;case"webrtc":let d="",u=null;if(void 0===this.streamConfig.sourceList[p].streamKey||null===this.streamConfig.serverList[p].streamKey)throw new Error('Missing "streamName" parameter in stream source element');d=this.streamConfig.sourceList[p].streamKey,u=void 0!==this.streamConfig.sourceList[p].streamInfo&&null!==this.streamConfig.serverList[p].streamInfo?this.streamConfig.sourceList[p].streamKey:{label:"",width:0,height:0,fps:0,bitrate:0},this.sourceList.push(new b(d,new y(u),m));break;default:throw new Error("Error while parsing source object (unknown protocol). Please check player config!")}}}if(t==i.STREAMER){if(void 0===this.streamConfig.publishData||null===this.streamConfig.publishData)throw new Error("Stream data configuration is missing. Please check player config!");if(void 0===this.streamConfig.publishData.protocol||null===this.streamConfig.publishData.protocol)throw new Error('Missing "protocol" field in stream data element. Please check player config!');if("webrtc"!==this.streamConfig.publishData.protocol.toLowerCase())throw new Error('Unknown "protocol" field in stream data element. Please check player config!');{let e,t,i;if(void 0===this.streamConfig.publishData.streamName||null===this.streamConfig.publishData.streamName)throw new Error("Stream data configuration is missing. Please check streamer config!");if(e=this.streamConfig.publishData.streamName,void 0===this.streamConfig.publishData.application||null===this.streamConfig.publishData.application)throw new Error("Stream data configuration is missing. Please check streamer config!");if(t=this.streamConfig.publishData.application,void 0===this.streamConfig.publishData.host||null===this.streamConfig.publishData.host)throw new Error("Stream data configuration is missing. Please check streamer config!");i=this.streamConfig.publishData.host,this.publishData=new B(e,t,i)}}}else{if(this.configurationType!=l.GATEWAY)throw new Error("Unknown configurationType was defined in stream config!");if(void 0===this.streamConfig.serverList||null===this.streamConfig.serverList)throw new Error("Gateway server list configuration is missing. Please check player config!");if(0===this.streamConfig.serverList.length)throw new Error("Gateway server list configuration is empty. Please check player config!");for(let o=0;o<this.streamConfig.serverList.length;o++){let e,t,i=this.DEFAULT_STORM_PORT,s=this.IS_SSL_BY_DEFAULT;if(void 0===this.streamConfig.serverList[o].host||null===this.streamConfig.serverList[o].host)throw new Error('Error while parsing server object ("host" filed is missing). Please check player config!');if(e=this.streamConfig.serverList[o].host,void 0===this.streamConfig.serverList[o].application||null===this.streamConfig.serverList[o].application)throw new Error('Error while parsing server object ("application" filed is missing). Please check player config!');t=this.streamConfig.serverList[o].application,void 0!==this.streamConfig.serverList[o].port&&null!==this.streamConfig.serverList[o].port&&(i=this.streamConfig.serverList[o].port),void 0!==this.streamConfig.serverList[o].ssl&&null!==this.streamConfig.serverList[o].ssl&&(s=this.streamConfig.serverList[o].ssl),this.serverList.push(new n(e,t,i,s))}if(void 0===this.streamConfig.streamKey||null===this.streamConfig.streamKey)throw new Error("StreamKey for gateway was not defined! Please check stream config!");this.streamKey=this.streamConfig.streamKey}void 0!==this.streamConfig.security&&null!==this.streamConfig.security?this.securityConfig=new a(this.streamConfig.security):this.securityConfig=new a(null)}getServerList(){return this.serverList}getSourceList(){return this.sourceList}getGatewayStreamKey(){return this.streamKey}getType(e){return e instanceof C?"StormSourceItem":e instanceof S?"RTMPSourceItem":"Object"}addSourceStream(e){let c;switch(this.getType(e)){case"StormSourceItem":case"RTMPSourceItem":c=e;break;case"Object":var d=e;let l="none",g=!1;if(void 0===d.protocol||null===d.protocol)throw new Error('Error while parsing source object ("protocol" filed is missing). Please check player config!');switch(l=d.protocol,void 0!==d.default&&null!==d.default&&(g=d.default),l.toLowerCase()){case"storm":let e="",t=null;if(void 0===d.streamKey||null===d.streamKey)throw new Error('Missing "streamKey" parameter in stream source element');e=d.streamKey,t=void 0!==d.streamInfo&&null!==d.streamInfo?d.streamInfo:{label:"",width:0,height:0,fps:0,bitrate:0},c=new C(e,new y(t),g),this.sourceList.push(c);break;case"rtmp":let i="",s="",o="",n=1935,r=null;if(void 0===d.host||null===d.host)throw new Error('Missing "host" parameter in stream source element');if(i=d.host,void 0===d.application||null===d.application)throw new Error('Missing "application" parameter in stream source element');if(s=d.application,void 0===d.streamKey||null===d.streamKey)throw new Error('Missing "streamName" parameter in stream source element');o=d.streamKey,void 0!==d.port&&null!==d.port&&(n=d.port),r=void 0!==d.streamInfo&&null!==d.streamInfo?d.streamInfo:{label:"",width:0,height:0,fps:0,bitrate:0},c=new S(i,s,o,n,new y(r),g),this.sourceList.push(c);break;case"webrtc":let a="",h=null;if(void 0===d.streamKey||null===d.streamKey)throw new Error('Missing "streamName" parameter in stream source element');a=d.streamKey,h=void 0!==d.streamInfo&&null!==d.streamInfo?d.streamKey:{label:"",width:0,height:0,fps:0,bitrate:0},c=new b(a,new y(h),g),this.sourceList.push(new b(a,new y(h),g));break;default:throw new Error("Error while parsing source object (unknown protocol). Please check player config!")}break;default:throw new Error("Incompatible type")}return c}getSecurityConfig(){return this.securityConfig}getPublishData(){return this.publishData}getConfigurationType(){return this.configurationType}setServerList(e){this.serverList=e}clearSourceList(){this.sourceList=new Array}setSourceList(e){this.sourceList=e}getRole(){return this.roleType}print(t){if(this.PRINT_ON_STARTUP||1<arguments.length&&void 0!==arguments[1]&&arguments[1]){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,"Stream List:");for(let e=0;e<this.sourceList.length;e++)t.info(this,"=> ["+e+"] "+this.sourceList[e].toString());this.securityConfig.print(t)}}}class g{constructor(e){this.PRINT_ON_STARTUP=!0,this.minValue=.1,this.maxValue=2,this.startValue=.15,this.targetValue=.1,this.parse(e)}parse(e){this.bufferConfig=e,void 0!==this.bufferConfig&&null!==this.bufferConfig&&(void 0!==this.bufferConfig.minValue&&null!==this.bufferConfig.minValue&&(this.minValue=this.bufferConfig.minValue),void 0!==this.bufferConfig.maxValue&&null!==this.bufferConfig.maxValue&&(this.maxValue=this.bufferConfig.maxValue),void 0!==this.bufferConfig.startValue&&null!==this.bufferConfig.startValue&&(this.startValue=this.bufferConfig.startValue),void 0!==this.bufferConfig.targetValue)&&null!==this.bufferConfig.targetValue&&(this.targetValue=this.bufferConfig.targetValue)}getMinValue(){return this.minValue}getMaxValue(){return this.maxValue}getStartValue(){return this.startValue}getTargetValue(){return this.targetValue}setMinValue(e){this.minValue=e}setMaxValue(e){this.maxValue=e}setTargetValue(e){this.targetValue=e}setStartValue(e){this.startValue=e}setConfig(e){this.bufferConfig=e}print(e){(this.PRINT_ON_STARTUP||1<arguments.length&&void 0!==arguments[1]&&arguments[1])&&e.info(this,"minValue: "+this.minValue+" | maxValue: "+this.maxValue+" | startValue: "+this.startValue+" | targetValue: "+this.targetValue)}}class c{constructor(e){this.PRINT_ON_STARTUP=!0,this.storageEnabled=!0,this.prefix="",this.parse(e)}parse(e){this.storageConfig=e,void 0!==this.storageConfig&&null!==this.storageConfig&&(void 0!==this.storageConfig.enabled&&null!==this.storageConfig.enabled&&(this.storageEnabled=this.storageConfig.enabled),void 0!==this.storageConfig.prefix)&&null!==this.storageConfig.prefix&&(this.prefix=this.storageConfig.prefix)}isStorageEnabled(){return this.storageEnabled}setStorageEnabled(e){this.storageEnabled=e}getPrefix(){return this.prefix}setPrefix(e){this.prefix=e}setConfig(e){this.storageConfig=e}print(e){(this.PRINT_ON_STARTUP||1<arguments.length&&void 0!==arguments[1]&&arguments[1])&&(e.info(this,"StorageConfig:: enabled: "+this.storageEnabled),e.info(this,'StorageConfig:: prefix: "'+this.prefix+'"'))}}(w=o=o||{})[w.FILL=0]="FILL",w[w.LETTER_BOX=1]="LETTER_BOX",w[w.CROP=2]="CROP",w[w.ORIGINAL=3]="ORIGINAL";class d{constructor(e){this.scalingMode=o.LETTER_BOX,this.aspectRatio="none",this.videoWidthValue=100,this.isVideoWidthInPixels=!1,this.wasVideoWidthProvided=!1,this.videoHeightValue=100,this.isVideoHeightInPixels=!1,this.wasVideoHeightProvided=!1,this.parse(e)}parse(e){if(this.videoConfig=e,void 0===this.videoConfig||null===this.videoConfig)throw new Error("Missing video configuration. Please check player config!");if(void 0!==this.videoConfig.aspectRatio&&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(void 0!==this.videoConfig.scalingMode&&null!==this.videoConfig.scalingMode)switch(this.videoConfig.scalingMode.toLowerCase()){case"fill":this.scalingMode=o.FILL;break;case"letterbox":this.scalingMode=o.LETTER_BOX;break;case"crop":this.scalingMode=o.CROP;break;case"original":this.scalingMode=o.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.containerID||null===this.videoConfig.containerID)throw new Error("No video object name was provided for this player. Please check player config!");if(this.containerID=this.videoConfig.containerID,null===document.getElementById(this.containerID))throw new Error('No video object with id "'+this.containerID+'" was found for this player. Please check player config!')}getScalingMode(){return this.scalingMode}setConfig(e){this.videoConfig=e}getContainerID(){return this.containerID}getVideoWidthValue(){return this.videoWidthValue}getIfVideoWidthInPixels(){return this.isVideoWidthInPixels}getIfVideoWidthWasProvided(){return this.wasVideoWidthProvided}getVideoHeightValue(){return this.videoHeightValue}getIfVideoHeightInPixels(){return this.isVideoHeightInPixels}getIfVideoHeightWasProvided(){return this.wasVideoHeightProvided}getAspectRatio(){return this.aspectRatio}setVideoWidthValue(e){this.videoWidthValue=e}setIfVideoWidthInPixels(e){this.isVideoWidthInPixels=e}setVideoHeightValue(e){this.videoHeightValue=e}setIfVideoHeightInPixels(e){this.isVideoHeightInPixels=e}setContainerID(e){this.containerID=e}setScalingMode(e){switch(e.toLowerCase()){case"fill":this.scalingMode=o.FILL;break;case"letterbox":this.scalingMode=o.LETTER_BOX;break;case"crop":this.scalingMode=o.CROP;break;case"original":this.scalingMode=o.ORIGINAL;break;default:throw new Error("Unknown video scaling mode. Please check player config!")}}print(e){let t="";switch(this.scalingMode){case o.FILL:t="fill";break;case o.LETTER_BOX:t="letterbox";break;case o.CROP:t="crop";break;case o.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)"))}}(w=s=s||{})[w.TRACE=0]="TRACE",w[w.INFO=1]="INFO",w[w.SUCCESS=2]="SUCCESS",w[w.WARNING=3]="WARNING",w[w.ERROR=4]="ERROR";class u{constructor(e){this.PRINT_ON_STARTUP=!0,this.consoleEnabled=!1,this.consoleLogTypes=[s.INFO,s.ERROR,s.SUCCESS,s.TRACE,s.WARNING],this.consoleMonoColor=!1,this.containerEnabled=!1,this.containerLogTypes=[s.INFO,s.ERROR,s.SUCCESS,s.TRACE,s.WARNING],this.containerMonoColor=!1,this.parse(e)}parse(e){if(this.debugConfig=e,void 0!==this.debugConfig&&null!==this.debugConfig){if(void 0!==this.debugConfig.console&&null!=this.debugConfig.console){var t=this.debugConfig.console;if(void 0!==t.enabled&&null!==t.enabled&&(this.consoleEnabled=t.enabled),void 0!==t.logTypes&&null!==t.logTypes&&0!==t.logTypes.length){this.consoleLogTypes=new Array;for(let e=0;e<t.logTypes.length;e++)switch(t.logTypes[e].toLowerCase()){case"info":this.consoleLogTypes.push(s.INFO);break;case"error":this.consoleLogTypes.push(s.ERROR);break;case"warning":this.consoleLogTypes.push(s.WARNING);break;case"success":this.consoleLogTypes.push(s.SUCCESS);break;case"trace":this.consoleLogTypes.push(s.TRACE)}}void 0!==t.monoColor&&null!==t.monoColor&&(this.consoleMonoColor=t.monoColor)}if(void 0!==this.debugConfig.container&&null!=this.debugConfig.container){var i=this.debugConfig.container;if(void 0!==i.enabled&&null!==i.enabled&&(this.containerEnabled=i.enabled),void 0!==i.logTypes&&null!==i.logTypes&&0!==i.logTypes.length){this.containerLogTypes=new Array;for(let e=0;e<i.logTypes.length;e++)switch(i.logTypes[e].toLowerCase()){case"info":this.containerLogTypes.push(s.INFO);break;case"error":this.containerLogTypes.push(s.ERROR);break;case"warning":this.containerLogTypes.push(s.WARNING);break;case"success":this.containerLogTypes.push(s.SUCCESS);break;case"trace":this.containerLogTypes.push(s.TRACE)}}void 0!==i.monoColor&&null!==i.monoColor&&(this.containerMonoColor=i.monoColor),void 0!==i.containerID&&null!==i.containerID&&(this.containerID=i.containerID)}}}isConsoleEnabled(){return this.consoleEnabled}setConsoleEnabled(e){this.consoleEnabled=e}getConsoleLogTypes(){return this.consoleLogTypes}setConsoleLogTypes(t){this.consoleLogTypes=new Array;for(let e=0;e<t.length;e++)switch(t[e].toLowerCase()){case"info":this.consoleLogTypes.push(s.INFO);break;case"error":this.consoleLogTypes.push(s.ERROR);break;case"warning":this.consoleLogTypes.push(s.WARNING);break;case"success":this.consoleLogTypes.push(s.SUCCESS);break;case"trace":this.consoleLogTypes.push(s.TRACE)}}isContainerEnabled(){return this.containerEnabled}setContainerEnabled(e){this.consoleEnabled=e}isConsoleMonoColor(){return this.consoleMonoColor}setConsoleMonoColor(e){this.consoleMonoColor=e}getContainerLogTypes(){return this.containerLogTypes}setContainerLogTypes(t){this.containerLogTypes=new Array;for(let e=0;e<t.length;e++)switch(t[e].toLowerCase()){case"info":this.containerLogTypes.push(s.INFO);break;case"error":this.containerLogTypes.push(s.ERROR);break;case"warning":this.containerLogTypes.push(s.WARNING);break;case"success":this.containerLogTypes.push(s.SUCCESS);break;case"trace":this.containerLogTypes.push(s.TRACE)}}getContainerID(){return this.containerID}setContainerID(e){this.containerID=e}isContainerMonoColor(){return this.containerMonoColor}setContainerMonoColor(e){this.containerMonoColor=e}setConfig(e){this.debugConfig=e}print(e){if(this.PRINT_ON_STARTUP||1<arguments.length&&void 0!==arguments[1]&&arguments[1]){let t="";for(let e=0;e<this.consoleLogTypes.length;e++)switch(this.consoleLogTypes[e]){case s.TRACE:t+="TRACE, ";break;case s.SUCCESS:t+="SUCCESS, ";break;case s.WARNING:t+="WARNING, ";break;case s.INFO:t+="INFO, ";break;case s.ERROR:t+="ERROR, "}e.info(this,"Console:: enabled: "+this.consoleEnabled),e.info(this,"Console:: logTypes: "+t),e.info(this,"Console:: monoColor: "+this.consoleMonoColor);let i="";for(let e=0;e<this.containerLogTypes.length;e++)switch(this.containerLogTypes[e]){case s.TRACE:i+="TRACE, ";break;case s.SUCCESS:i+="SUCCESS, ";break;case s.WARNING:i+="WARNING, ";break;case s.INFO:i+="INFO, ";break;case s.ERROR:i+="ERROR, "}e.info(this,"Container:: enabled: "+this.containerEnabled),e.info(this,"Container:: logTypes: "+i),e.info(this,"Container:: containerID: "+this.containerID),e.info(this,"Container:: monoColor: "+this.consoleMonoColor)}}}class f{constructor(e){this.PRINT_ON_STARTUP=!0,this.startVolume=100,this.maxVolume=100,this.rememberValue=!0,this.parse(e)}parse(e){this.volumeConfig=e,void 0!==this.volumeConfig&&null!==this.volumeConfig&&(void 0!==this.volumeConfig.startVolume&&null!==this.volumeConfig.startVolume&&(this.startVolume=this.volumeConfig.startVolume),void 0!==this.volumeConfig.maxVolume&&null!==this.volumeConfig.maxVolume&&(this.maxVolume=this.volumeConfig.maxVolume),void 0!==this.volumeConfig.rememberValue)&&null!==this.volumeConfig.rememberValue&&(this.rememberValue=this.volumeConfig.rememberValue)}getStartVolume(){return this.startVolume}setStartVolume(e){this.startVolume=e}getMaxVolume(){return this.maxVolume}setMaxVolume(e){this.maxVolume=e}isRememberValue(){return this.rememberValue}setRememberValue(e){this.rememberValue=e}setConfig(e){this.volumeConfig=e}print(e){(this.PRINT_ON_STARTUP||1<arguments.length&&void 0!==arguments[1]&&arguments[1])&&e.info(this,"Audio :: startVolume: "+this.startVolume+" | maxVolume: "+this.maxVolume+" | rememberValue: "+this.rememberValue)}}class m{constructor(e){this.PRINT_ON_STARTUP=!0,this.restartOnError=!1,this.reconnectTime=3,this.autoStart=!1,this.autoConnect=!0,this.startOnDOMReady=!1,this.iOSOnDomReadyFix=!0,this.enabledProtocols=new Array(r.STORM,r.RTMP,r.HLS),this.restartOnFocus=!0,this.parse(e)}parse(e){if(this.settingsConfig=e,void 0!==this.settingsConfig.autoConnect&&null!==this.settingsConfig.autoConnect&&(this.autoConnect=this.settingsConfig.autoConnect),void 0!==this.settingsConfig.autoStart&&null!==this.settingsConfig.autoStart&&(this.autoStart=this.settingsConfig.autoStart),void 0!==this.settingsConfig.restartOnFocus&&null!==this.settingsConfig.restartOnFocus&&(this.restartOnFocus=this.settingsConfig.restartOnFocus),void 0!==this.settingsConfig.restartOnError&&null!==this.settingsConfig.restartOnError&&(this.restartOnError=this.settingsConfig.restartOnError),void 0!==this.settingsConfig.reconnectTime&&null!==this.settingsConfig.reconnectTime&&(this.reconnectTime=this.settingsConfig.reconnectTime),void 0!==this.settingsConfig.enabledProtocols&&null!==this.settingsConfig.enabledProtocols){var t=this.settingsConfig.enabledProtocols;if(0===t.length)throw new Error('Missing "enabledProtocols" field. Please check your player config!');this.enabledProtocols=new Array;for(let e=0;e<t.length;e++)switch(t[e].toLowerCase()){case"storm":this.enabledProtocols.push(r.STORM);break;case"hls":this.enabledProtocols.push(r.HLS);break;case"webrtc":this.enabledProtocols.push(r.WEBRTC);break;default:throw new Error('Unknown protocol "'+t[e]+'". Please check your player config!')}}void 0!==this.settingsConfig.buffer&&null!==this.settingsConfig.buffer?this.bufferConfig=new g(this.settingsConfig.buffer):this.bufferConfig=new g(null),void 0!==this.settingsConfig.storage&&null!==this.settingsConfig.storage?this.storageConfig=new c(this.settingsConfig.storage):this.storageConfig=new c(null),void 0!==this.settingsConfig.video&&null!==this.settingsConfig.video?this.videoConfig=new d(this.settingsConfig.video):this.videoConfig=new d(null),void 0!==this.settingsConfig.audio&&null!==this.settingsConfig.audio?this.audioConfig=new f(this.settingsConfig.volume):this.audioConfig=new f(null),void 0!==this.settingsConfig.debug&&null!==this.settingsConfig.debug?this.debugConfig=new u(this.settingsConfig.debug):this.debugConfig=new u(null)}getEnabledProtocols(){return this.enabledProtocols}getIfProtocolEnabled(e){return 0<=this.enabledProtocols.indexOf(e)}getBufferConfig(){return this.bufferConfig}getAudioConfig(){return this.audioConfig}getVideoConfig(){return this.videoConfig}getIfRestartOnError(){return this.restartOnError}getReconnectTime(){return this.reconnectTime}getIfAutoStart(){return this.autoStart}setAutoStart(e){this.autoStart=e}getIfAutoConnect(){return this.autoConnect}getIfRestartOnFocus(){return this.restartOnFocus}getDebugConfig(){return this.debugConfig}getStorageConfig(){return this.storageConfig}setConfig(e){this.settingsConfig=e}getIfStartOnDOMReadyEnabled(){return this.startOnDOMReady}getIfIOSOnDomStartFixEnabled(){return this.iOSOnDomReadyFix}print(e){if(this.PRINT_ON_STARTUP||1<arguments.length&&void 0!==arguments[1]&&arguments[1]){let t="";for(let e=0;e<this.enabledProtocols.length;e++)switch(this.enabledProtocols[e]){case r.WEB_SOCKETS:t+="WebSockets, ";break;case r.HLS:t+="HLS, ";break;case r.WEBRTC:t+="WebRTC, "}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.bufferConfig.print(e),this.videoConfig.print(e),this.audioConfig.print(e),this.storageConfig.print(e),this.debugConfig.print(e)}}}class p{constructor(e){this.PRINT_ON_STARTUP=!0,this.roleType=i.PLAYER,this.demoMode=!1,this.parse(e)}parse(e){if(this.config=e,void 0!==this.config.role&&null!==this.config.role)switch(this.config.role.toLowerCase()){case"player":this.roleType=i.PLAYER;break;case"streamer":this.roleType=i.STREAMER;break;default:throw new Error('Unknown config role:"'+this.config.role+'"')}if(void 0!==this.config.configurationType&&null!==this.config.configurationType)switch(this.config.configurationType.toLowerCase()){case"embedded":this.configurationType=l.EMBEDDED;break;case"gateway":this.configurationType=l.GATEWAY;break;default:throw new Error('Unknown config type:"'+this.configurationType+'"')}else this.configurationType=l.GATEWAY;if(void 0===this.config.stream||null===this.config.stream)throw new Error("No stream field was provided. Please check your player config!");this.stream=new W(this.config.stream,this.roleType,this.configurationType),void 0!==this.config.settings&&null!==this.config.settings?this.settings=new m(this.config.settings):this.settings=new m(null),void 0!==this.config.demoMode&&null!==this.config.demoMode&&(this.demoMode=this.config.demoMode)}getConfigurationType(){return this.configurationType}getRole(){return this.roleType}getStream(){return this.stream}getSettings(){return this.settings}setConfig(e){this.config=e}getIfDemoMode(){return this.demoMode}print(e){(this.PRINT_ON_STARTUP||1<arguments.length&&void 0!==arguments[1]&&arguments[1])&&(this.stream.print(e),this.settings.print(e))}}class v{static addLeadingZero(e){return e<10?"0"+e:String(e)}static generateUniqueString(t){let i="";var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=s.length;for(let e=0;e<t;e++)i+=s.charAt(Math.floor(Math.random()*o));return i}}class E{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.isConsoleEnabled()&&0<=this.debugConfig.getConsoleLogTypes().indexOf(s.INFO)&&(t=this.debugConfig.isConsoleMonoColor()?this.monoColor:E.INFO_COLOR,console.log("%c "+e,"color: "+t)),this.debugConfig.isContainerEnabled()&&0<=this.debugConfig.getContainerLogTypes().indexOf(s.INFO)&&(t=this.debugConfig.isContainerMonoColor()?this.monoColor:E.INFO_COLOR,this.writeToContainer(e,t))}warning(e,t){e=this.logData(e,t);this.debugConfig.isConsoleEnabled()&&0<=this.debugConfig.getConsoleLogTypes().indexOf(s.WARNING)&&(t=this.debugConfig.isConsoleMonoColor()?this.monoColor:E.WARNING_COLOR,console.log("%c "+e,"color: "+t)),this.debugConfig.isContainerEnabled()&&0<=this.debugConfig.getContainerLogTypes().indexOf(s.WARNING)&&(t=this.debugConfig.isContainerMonoColor()?this.monoColor:E.WARNING_COLOR,this.writeToContainer(e,t))}error(e,t){e=this.logData(e,t);this.debugConfig.isConsoleEnabled()&&0<=this.debugConfig.getConsoleLogTypes().indexOf(s.ERROR)&&(t=this.debugConfig.isConsoleMonoColor()?this.monoColor:E.ERROR_COLOR,console.log("%c "+e,"color: "+t)),this.debugConfig.isContainerEnabled()&&0<=this.debugConfig.getContainerLogTypes().indexOf(s.ERROR)&&(t=this.debugConfig.isContainerMonoColor()?this.monoColor:E.ERROR_COLOR,this.writeToContainer(e,t))}success(e,t){e=this.logData(e,t);this.debugConfig.isConsoleEnabled()&&0<=this.debugConfig.getConsoleLogTypes().indexOf(s.SUCCESS)&&(t=this.debugConfig.isConsoleMonoColor()?this.monoColor:E.SUCCESS_COLOR,console.log("%c "+e,"color: "+t)),this.debugConfig.isContainerEnabled()&&0<=this.debugConfig.getContainerLogTypes().indexOf(s.SUCCESS)&&(t=this.debugConfig.isContainerMonoColor()?this.monoColor:E.SUCCESS_COLOR,this.writeToContainer(e,t))}trace(e,t){e=this.logData(e,t);this.debugConfig.isConsoleEnabled()&&0<=this.debugConfig.getConsoleLogTypes().indexOf(s.TRACE)&&(t=this.debugConfig.isConsoleMonoColor()?this.monoColor:E.TRACE_COLOR,console.log("%c "+e,"color: "+t)),this.debugConfig.isContainerEnabled()&&0<=this.debugConfig.getContainerLogTypes().indexOf(s.TRACE)&&(t=this.debugConfig.isContainerMonoColor()?this.monoColor:E.TRACE_COLOR,this.writeToContainer(e,t))}logData(e,t){var i=new Date,s=v.addLeadingZero(i.getHours()),o=v.addLeadingZero(i.getMinutes()),i=v.addLeadingZero(i.getSeconds());let n=String(this.libraryInstanceID);0<=this.playerInstanceID&&(n+="|"+this.playerInstanceID);s="(Storm) [ID:"+n+"] ["+s+":"+o+":"+i+"] :: "+t;return this.logMemory.push(s),s}writeToContainer(e,t){var i=this.debugConfig.getContainerID(),i=document.getElementById(i),s=document.createElement("span");s.innerText=e,s.style.color=t,i.appendChild(s)}setPlayerID(e){this.playerInstanceID=e}getAllLogs(){return this.logMemory}}E.INFO_COLOR="blue",E.WARNING_COLOR="orange",E.ERROR_COLOR="red",E.SUCCESS_COLOR="green",E.TRACE_COLOR="black";class F{constructor(){this.bandwidthCapabilities=0}setBandwidthCapabilities(e){this.bandwidthCapabilities=e}getBandwidthCapabilities(){return this.bandwidthCapabilities}}(w=e=e||{}).NOT_INITIALIZED="notInitialized",w.INITIALIZED="initialized",w.STARTED="started",w.BUFFERING="buffering",w.PLAYING="playing",w.PAUSED="paused",w.STOPPED="stopped",w.DISCONNECTED="disconnected",w.DESTROYED="destroyed";var w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function x(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function I(){return Y.Date.now()}var k=NaN,H="[object Symbol]",_=/^\s+|\s+$/g,z=/^[-+]0x[0-9a-f]+$/i,j=/^0b[01]+$/i,K=/^0o[0-7]+$/i,G=parseInt,w="object"==typeof w&&w&&w.Object===Object&&w,L="object"==typeof self&&self&&self.Object===Object&&self,Y=w||L||Function("return this")(),Z=Object.prototype.toString,q=Math.max,X=Math.min;function P(e){var t=typeof e;return e&&("object"==t||"function"==t)}function T(e){if("number"==typeof e)return e;if("symbol"==typeof(i=e)||!!(t=i)&&"object"==typeof t&&Z.call(i)==H)return k;var t;if("string"!=typeof(e=P(e)?P(t="function"==typeof e.valueOf?e.valueOf():e)?t+"":t:e))return 0===e?e:+e;e=e.replace(_,"");var i=j.test(e);return i||K.test(e)?G(e.slice(2),i?2:8):z.test(e)?k:+e}var O,R,N,Q=x(function(s,i,e){var o,n,r,a,h,l,g=0,c=!1,d=!1,t=!0;if("function"!=typeof s)throw new TypeError("Expected a function");function u(e){var t=o,i=n;return o=n=void 0,g=e,a=s.apply(i,t)}function f(e){var t=e-l;return void 0===l||i<=t||t<0||d&&r<=e-g}function m(){var e,t=I();if(f(t))return p(t);h=setTimeout(m,(e=i-((t=t)-l),d?X(e,r-(t-g)):e))}function p(e){return h=void 0,t&&o?u(e):(o=n=void 0,a)}function C(){var e=I(),t=f(e);if(o=arguments,n=this,l=e,t){if(void 0===h)return g=e=l,h=setTimeout(m,i),c?u(e):a;if(d)return h=setTimeout(m,i),u(l)}return void 0===h&&(h=setTimeout(m,i)),a}return i=T(i)||0,P(e)&&(c=!!e.leading,d="maxWait"in e,r=d?q(T(e.maxWait)||0,i):r,t="trailing"in e?!!e.trailing:t),C.cancel=function(){void 0!==h&&clearTimeout(h),o=l=n=h=void(g=0)},C.flush=function(){return void 0===h?a:p(I())},C});class J{constructor(e){this.LOG_ACTIVITY=!0,this.videoWidth=0,this.videoHeight=0,this.wasUnmuted=!1,this.isMuted=!1,this.currentVolume=100,this.forceMute=!1,this.isInFullScreenMode=!1,this.hadPlayed=!1,this.onResize=()=>{var e,t;null!=this.parentContainer&&(this.tempContainerWidth=this.parentContainer.getBoundingClientRect().width,this.tempContainerHeight=this.parentContainer.getBoundingClientRect().height,e=this.main.getConfigManager().getSettings().getVideoConfig().getIfVideoWidthInPixels(),t=this.main.getConfigManager().getSettings().getVideoConfig().getIfVideoHeightInPixels(),e&&t||(this.resizeVideo(),this.scaleVideo()))},this.main=e,this.containerID=e.getConfigManager().getSettings().getVideoConfig().getContainerID(),this.logger=e.getLogger(),this.initialize()}initialize(){const e=this;if(null==document.getElementById(this.containerID))throw new Error("No parent element for the storm library was defined!");if(this.parentContainer=document.getElementById(this.containerID),this.videoContainer=document.createElement("div"),null==this.parentContainer)throw new Error("No parent element for the storm library was defined!");this.parentContainer.appendChild(this.videoContainer),this.videoElement=document.createElement("video"),this.videoContainer.appendChild(this.videoElement),this.isInFullScreenMode=!1,this.videoContainer.setAttribute("id","stormLibrary_"+this.main.getLibraryID()),this.videoContainer.style.overflow="hidden",this.videoContainer.style.position="relative",this.videoContainer.classList.add("stormLibrary"),this.videoElement.style.objectFit="fill",this.resizeObserver=new ResizeObserver(Q(()=>this.onResize(),250,{leading:!1,trailing:!0})),this.parentContainer.addEventListener("transitionend",()=>{this.onResize()}),this.configureVideoElement(),this.attachEvents(),this.resizeVideo(),this.scaleVideo(),this.resizeObserver.observe(this.parentContainer),this.main.addEventListener("metadataReceived",e=>{this.videoWidth=e.metadata.getVideoWidth(),this.videoHeight=e.metadata.getVideoHeight(),this.scaleVideo()}),document.addEventListener("fullscreenchange",function(){e.onFullScreenChange()},!1),document.addEventListener("webkitfullscreenchange",function(){e.onFullScreenChange()},!1),document.addEventListener("mozfullscreenchange",function(){e.onFullScreenChange()},!1),document.addEventListener("webkitendfullscreen",function(){e.onFullScreenChange()},!1),this.videoElement.addEventListener("webkitendfullscreen",function(){e.onFullScreenChange()},!1)}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}))}configureVideoElement(){var e=this.main.getConfigManager().getSettings().getIfAutoStart(),t=this.main.getConfigManager().getSettings().getAudioConfig().getStartVolume();this.main.getStorageManager().getField("playerVolume")?this.currentVolume=Number(this.main.getStorageManager().getField("playerVolume")):this.currentVolume=t,e&&!this.wasUnmuted&&(this.isMuted=!0,this.forceMute=!0),this.videoElement.setAttribute("playsinline","playsinline"),this.videoElement.setAttribute("webkit-playsinline","webkit-playsinline"),this.videoElement.muted=this.isMuted,this.videoElement.volume=this.currentVolume/100,this.main.dispatchEvent("videoElementCreate",{ref:this.main,videoElement:this.videoElement})}attachEvents(){let s=this;this.videoElement.onload=function(){},e.PLAYING,this.videoElement.onerror=function(e){},this.videoElement.onvolumechange=function(e){s.dispatchVolumeEvent()},this.videoElement.ontimeupdate=function(e){var t=s.videoElement.videoWidth,i=s.videoElement.videoHeight;0==t||0==i||t===s.videoWidth&&i===s.videoHeight||(s.videoWidth=t,s.videoHeight=i,s.scaleVideo())},this.videoElement.onended=function(e){}}resizeVideo(){var e=this.main.getConfigManager().getSettings().getVideoConfig().getIfVideoWidthInPixels(),t=this.main.getConfigManager().getSettings().getVideoConfig().getIfVideoHeightInPixels(),i=this.main.getConfigManager().getSettings().getVideoConfig().getVideoWidthValue(),s=this.main.getConfigManager().getSettings().getVideoConfig().getVideoHeightValue(),o=this.main.getConfigManager().getSettings().getVideoConfig().getAspectRatio();let n=0,r=0;var a=Number(o.split(":")[0]),h=Number(o.split(":")[1]);"none"==o?(e?n=i:null!=this.parentContainer&&(n=this.tempContainerWidth*i/100),t?r=s:null!=this.parentContainer&&(r=this.tempContainerHeight*s/100)):(e?n=i:null!=this.parentContainer&&(n=this.tempContainerWidth*i/100),r=n*h/a),this.containerWidth=n,this.containerHeight=r,null!==this.videoContainer&&(this.videoContainer.style.width=n+"px",this.videoContainer.style.height=r+"px")}scaleVideo(){if(this.scalingMode=this.main.getConfigManager().getSettings().getVideoConfig().getScalingMode(),null!==this.videoElement){let e=0,t=0,i=0,s=0;switch(this.scalingMode){case o.FILL:i=this.containerWidth,s=this.containerHeight;break;case o.CROP:i=this.containerWidth,(s=this.videoHeight*this.containerWidth/this.videoWidth)>=this.containerHeight?(e=0,t=(s-this.containerHeight)/2*-1):(s=this.containerHeight,i=this.videoWidth*this.containerHeight/this.videoHeight,t=0,e=(i-this.containerWidth)/2*-1);break;case o.LETTER_BOX:i=this.containerWidth,(!((s=this.videoHeight*this.containerWidth/this.videoWidth)<=this.containerHeight)||(e=0,t=(s-this.containerHeight)/2*-1,s>this.containerHeight))&&(s=this.containerHeight,i=this.videoWidth*this.containerHeight/this.videoHeight,t=0,e=(i-this.containerWidth)/2*-1);break;case o.ORIGINAL:i=this.videoWidth,s=this.videoHeight,e=(this.videoWidth-this.containerWidth)/-2,t=(this.videoHeight-this.containerHeight)/-2}this.videoElement.style.left=Math.floor(e)+"px",this.videoElement.style.top=Math.floor(t)+"px",this.videoElement.style.width=Math.ceil(i)+"px",this.videoElement.style.height=Math.ceil(s)+"px",this.videoElement.style.position="absolute"}}dispatchVolumeEvent(){var e=this.forceMute?"browser":"user",t={volume:100*this.videoElement.volume,isMuted:this.videoElement.muted,type:e};this.LOG_ACTIVITY&&this.logger.info(this,"VideoContainer :: Event: onVolumeChange: "+JSON.stringify(t)),this.main.dispatchEvent("volumeChange",{ref:this.main,mode:"mse",volume:100*this.videoElement.volume,muted:this.videoElement.muted,invokedBy:e})}play(){let t=this;this.videoElement.play().then(e=>function(){}).catch(function(e){"NotAllowedError"===e.name&&(t.videoElement.muted=!0,t.forceMute=!0,t.videoElement.setAttribute("playsinline","playsinline"),t.videoElement.setAttribute("webkit-playsinline","webkit-playsinline"),t.wasUnmuted=!1,t.isMuted=!0,t.dispatchVolumeEvent(),t.player)&&t.player.restart()})}mute(){this.isMuted=!0,null!==this.videoElement&&(this.videoElement.muted=this.isMuted)}unmute(){var e;this.wasUnmuted=!0,this.isMuted=!1,this.forceMute=!1,null!==this.videoElement&&(e=this.videoElement.paused,this.videoElement.muted=!1,e!=this.videoElement.paused?this.main.dispatchEvent("interactionRequired",{ref:this.main,mode:"mse"}):this.main.dispatchEvent("videoUnmuted",{ref:this.main}))}setVolume(e){this.isMuted=!1,this.wasUnmuted=!0,this.forceMute=!1,this.currentVolume=e,null!==this.videoElement&&(this.videoElement.volume=e/100),this.main.getStorageManager().saveField("playerVolume",String(e))}getVolume(){return null!==this.videoElement?100*this.videoElement.volume:100}getVideoObject(){return this.videoElement}destroy(){this.LOG_ACTIVITY&&this.logger.info(this,"VideoContainer :: src nulling...");try{this.resizeObserver.disconnect(),this.videoElement.remove(),this.videoContainer.remove()}catch(e){}}setScalingMode(e){switch(e.toLowerCase()){case"fill":this.scalingMode=o.FILL;break;case"crop":this.scalingMode=o.CROP;break;case"letterbox":this.scalingMode=o.LETTER_BOX;break;case"original":this.scalingMode=o.ORIGINAL}this.scaleVideo()}getScalingMode(){let e="";switch(this.scalingMode){case o.FILL:e="fill";break;case o.CROP:e="crop";break;case o.LETTER_BOX:e="letterbox";break;case o.ORIGINAL:e="original"}return e}makeScreenshot(){var e=document.createElement("canvas"),t=e.getContext("2d");let i="";return e.width=this.videoWidth,e.height=this.videoHeight,null!==t&&(t.drawImage(this.videoElement,0,0,this.videoWidth,this.videoHeight),i=e.toDataURL("image/png")),i}setSize(e,t){if("number"==typeof e)this.main.getConfigManager().getSettings().getVideoConfig().setVideoWidthValue(e),this.main.getConfigManager().getSettings().getVideoConfig().setIfVideoWidthInPixels(!0);else{if("string"!=typeof e)throw new Error('Unknown value for parameter "width" - it must be a number or a string! ');e.toLowerCase().endsWith("px")?(this.main.getConfigManager().getSettings().getVideoConfig().setVideoWidthValue(parseInt(e)),this.main.getConfigManager().getSettings().getVideoConfig().setIfVideoWidthInPixels(!0)):e.toLowerCase().endsWith("%")&&(this.main.getConfigManager().getSettings().getVideoConfig().setVideoWidthValue(parseInt(e)),this.main.getConfigManager().getSettings().getVideoConfig().setIfVideoWidthInPixels(!1))}if("number"==typeof t)this.main.getConfigManager().getSettings().getVideoConfig().setVideoHeightValue(t),this.main.getConfigManager().getSettings().getVideoConfig().setIfVideoHeightInPixels(!0);else{if("string"!=typeof t)throw new Error('Unknown value for parameter "width" - it must be a number or a string! ');t.toLowerCase().endsWith("px")?(this.main.getConfigManager().getSettings().getVideoConfig().setVideoHeightValue(parseInt(t)),this.main.getConfigManager().getSettings().getVideoConfig().setIfVideoHeightInPixels(!0)):t.toLowerCase().endsWith("%")&&(this.main.getConfigManager().getSettings().getVideoConfig().setVideoHeightValue(parseInt(t)),this.main.getConfigManager().getSettings().getVideoConfig().setIfVideoHeightInPixels(!1))}this.resizeVideo(),this.scaleVideo()}setWidth(e){if("number"==typeof e)this.main.getConfigManager().getSettings().getVideoConfig().setVideoWidthValue(e),this.main.getConfigManager().getSettings().getVideoConfig().setIfVideoWidthInPixels(!0);else{if("string"!=typeof e)throw new Error('Unknown value for parameter "width" - it must be a number or a string! ');e.toLowerCase().endsWith("px")?(this.main.getConfigManager().getSettings().getVideoConfig().setVideoWidthValue(parseInt(e)),this.main.getConfigManager().getSettings().getVideoConfig().setIfVideoWidthInPixels(!0)):e.toLowerCase().endsWith("%")&&(this.main.getConfigManager().getSettings().getVideoConfig().setVideoWidthValue(parseInt(e)),this.main.getConfigManager().getSettings().getVideoConfig().setIfVideoWidthInPixels(!1))}this.resizeVideo(),this.scaleVideo()}setHeight(e){if("number"==typeof e)this.main.getConfigManager().getSettings().getVideoConfig().setVideoHeightValue(e),this.main.getConfigManager().getSettings().getVideoConfig().setIfVideoHeightInPixels(!0);else{if("string"!=typeof e)throw new Error('Unknown value for parameter "width" - it must be a number or a string! ');e.toLowerCase().endsWith("px")?(this.main.getConfigManager().getSettings().getVideoConfig().setVideoHeightValue(parseInt(e)),this.main.getConfigManager().getSettings().getVideoConfig().setIfVideoHeightInPixels(!0)):e.toLowerCase().endsWith("%")&&(this.main.getConfig