elm-twitch/js/vd.js

563 lines
745 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

window.HELP_IMPROVE_VIDEOJS = false;(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory(require("global/window"),require("global/document")):typeof define==="function"&&define.amd?define(["global/window","global/document"],factory):(global=global||self,global.videojs=factory(global.window,global.document))})(this,function(window$1,document){window$1=window$1&&window$1.hasOwnProperty("default")?window$1["default"]:window$1;document=document&&document.hasOwnProperty("default")?document["default"]:document;var version="7.6.6";var history=[];var LogByTypeFactory=function LogByTypeFactory(name,log){return function(type,level,args){var lvl=log.levels[level];var lvlRegExp=new RegExp("^("+lvl+")$");if(type!=="log"){args.unshift(type.toUpperCase()+":")}args.unshift(name+":");if(history){history.push([].concat(args))}if(!window$1.console){return}var fn=window$1.console[type];if(!fn&&type==="debug"){fn=window$1.console.info||window$1.console.log}if(!fn||!lvl||!lvlRegExp.test(type)){return}fn[Array.isArray(args)?"apply":"call"](window$1.console,args)}};function createLogger(name){var level="info";var logByType;var log=function log(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}logByType("log",level,args)};logByType=LogByTypeFactory(name,log);log.createLogger=function(subname){return createLogger(name+": "+subname)};log.levels={all:"debug|log|warn|error",off:"",debug:"debug|log|warn|error",info:"log|warn|error",warn:"warn|error",error:"error",DEFAULT:level};log.level=function(lvl){if(typeof lvl==="string"){if(!log.levels.hasOwnProperty(lvl)){throw new Error('"'+lvl+'" in not a valid log level')}level=lvl}return level};log.history=function(){return history?[].concat(history):[]};log.history.filter=function(fname){return(history||[]).filter(function(historyItem){return new RegExp(".*"+fname+".*").test(historyItem[0])})};log.history.clear=function(){if(history){history.length=0}};log.history.disable=function(){if(history!==null){history.length=0;history=null}};log.history.enable=function(){if(history===null){history=[]}};log.error=function(){for(var _len2=arguments.length,args=new Array(_len2),_key2=0;_key2<_len2;_key2++){args[_key2]=arguments[_key2]}return logByType("error",level,args)};log.warn=function(){for(var _len3=arguments.length,args=new Array(_len3),_key3=0;_key3<_len3;_key3++){args[_key3]=arguments[_key3]}return logByType("warn",level,args)};log.debug=function(){for(var _len4=arguments.length,args=new Array(_len4),_key4=0;_key4<_len4;_key4++){args[_key4]=arguments[_key4]}return logByType("debug",level,args)};return log}var log=createLogger("VIDEOJS");var createLogger$1=log.createLogger;var toString=Object.prototype.toString;var keys=function keys(object){return isObject(object)?Object.keys(object):[]};function each(object,fn){keys(object).forEach(function(key){return fn(object[key],key)})}function reduce(object,fn,initial){if(initial===void 0){initial=0}return keys(object).reduce(function(accum,key){return fn(accum,object[key],key)},initial)}function assign(target){for(var _len=arguments.length,sources=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){sources[_key-1]=arguments[_key]}if(Object.assign){return Object.assign.apply(Object,[target].concat(sources))}sources.forEach(function(source){if(!source){return}each(source,function(value,key){target[key]=value})});return target}function isObject(value){return!!value&&typeof value==="object"}function isPlain(value){return isObject(value)&&toString.call(value)==="[object Object]"&&value.constructor===Object}function computedStyle(el,prop){if(!el||!prop){return""}if(typeof window$1.getComputedStyle==="function"){var computedStyleValue=window$1.getComputedStyle(el);return computedStyleValue?computedStyleValue.getPropertyValue(prop)||computedStyleValue[prop]:""}return""}function isNonBlankString(str){return typeof str==="string"&&/\S/.test(str)}function throwIfWhitespace(str){if(/\s/.test(str)){throw new Error("class has illegal whitespace characters")}}function classRegExp(className){return new RegExp("(^|\\s)"+className+"($|\\s)")}function isReal(){return document===window$1.document}function isEl(value){return isObject(value)&&value.nodeType===1}function isInFrame(){try{return window$1.parent!==window$1.self}catch(x){return true}}function createQuerier(method){return function(selector,context){if(!isNonBlankString(selector)){return document[method](null)}if(isNonBlankString(context)){context=document.querySelector(context)}var ctx=isEl(context)?context:document;return ctx[method]&&ctx[method](selector)}}function createEl(tagName,properties,attributes,content){if(tagName===void 0){tagName="div"}if(properties===void 0){properties={}}if(attributes===void 0){attributes={}}var el=document.createElement(tagName);Object.getOwnPropertyNames(properties).forEach(function(propName){var val=properties[propName];if(propName.indexOf("aria-")!==-1||propName==="role"||propName==="type"){log.warn("Setting attributes in the second argument of createEl()\n"+"has been deprecated. Use the third argument instead.\n"+("createEl(type, properties, attributes). Attempting to set "+propName+" to "+val+"."));el.setAttribute(propName,val)}else if(propName==="textContent"){textContent(el,val)}else{el[propName]=val}});Object.getOwnPropertyNames(attributes).forEach(function(attrName){el.setAttribute(attrName,attributes[attrName])});if(content){appendContent(el,content)}return el}function textContent(el,text){if(typeof el.textContent==="undefined"){el.innerText=text}else{el.textContent=text}return el}function prependTo(child,parent){if(parent.firstChild){parent.insertBefore(child,parent.firstChild)}else{parent.appendChild(child)}}function hasClass(element,classToCheck){throwIfWhitespace(classToCheck);if(element.classList){return element.classList.contains(classToCheck)}return classRegExp(classToCheck).test(element.className)}function addClass(element,classToAdd){if(element.classList){element.classList.add(classToAdd)}else if(!hasClass(element,classToAdd)){element.className=(element.className+" "+classToAdd).trim()}return element}function removeClass(element,classToRemove){if(element.classList){element.classList.remove(classToRemove)}else{throwIfWhitespace(classToRemove);element.className=element.className.split(/\s+/).filter(function(c){return c!==classToRemove}).join(" ")}return element}function toggleClass(element,classToToggle,predicate){var has=hasClass(element,classToToggle);if(typeof predicate==="function"){predicate=predicate(element,classToToggle)}if(typeof predicate!=="boolean"){predicate=!has}if(predicate===has){return}if(predicate){addClass(element,classToToggle)}else{removeClass(element,classToToggle)}return element}function setAttributes(el,attributes){Object.getOwnPropertyNames(attributes).forEach(function(attrName){var attrValue=attributes[attrName];if(attrValue===null||typeof attrValue==="undefined"||attrValue===false){el.removeAttribute(attrName)}else{el.setAttribute(attrName,attrValue===true?"":attrValue)}})}function getAttributes(tag){var obj={};var knownBooleans=","+"autoplay,controls,playsinline,loop,muted,default,defaultMuted"+",";if(tag&&tag.attributes&&tag.attributes.length>0){var attrs=tag.attributes;for(var i=attrs.length-1;i>=0;i--){var attrName=attrs[i].name;var attrVal=attrs[i].value;if(typeof tag[attrName]==="boolean"||knownBooleans.indexOf(","+attrName+",")!==-1){attrVal=attrVal!==null?true:false}obj[attrName]=attrVal}}return obj}function getAttribute(el,attribute){return el.getAttribute(attribute)}function setAttribute(el,attribute,value){el.setAttribute(attribute,value)}function removeAttribute(el,attribute){el.removeAttribute(attribute)}function blockTextSelection(){document.body.focus();document.onselectstart=function(){return false}}function unblockTextSelection(){document.onselectstart=function(){return true}}function getBoundingClientRect(el){if(el&&el.getBoundingClientRect&&el.parentNode){var rect=el.getBoundingClientRect();var result={};["bottom","height","left","right","top","width"].forEach(function(k){if(rect[k]!==undefined){result[k]=rect[k]}});if(!result.height){result.height=parseFloat(computedStyle(el,"height"))}if(!result.width){result.width=parseFloat(computedStyle(el,"width"))}return result}}function findPosition(el){var box;if(el.getBoundingClientRect&&el.parentNode){box=el.getBoundingClientRect()}if(!box){return{left:0,top:0}}var docEl=document.documentElement;var body=document.body;var clientLeft=docEl.clientLeft||body.clientLeft||0;var scrollLeft=window$1.pageXOffset||body.scrollLeft;var left=box.left+scrollLeft-clientLeft;var clientTop=docEl.clientTop||body.clientTop||0;var scrollTop=window$1.pageYOffset||body.scrollTop;var top=box.top+scrollTop-clientTop;return{left:Math.round(left),top:Math.round(top)}}function getPointerPosition(el,event){var position={};var box=findPosition(el);var boxW=el.offsetWidth;var boxH=el.offsetHeight;var boxY=box.top;var boxX=box.left;var pageY=event.pageY;var pageX=event.pageX;if(event.changedTouches){pageX=event.changedTouches[0].pageX;pageY=event.changedTouches[0].pageY}position.y=Math.max(0,Math.min(1,(boxY-pageY+boxH)/boxH));position.x=Math.max(0,Math.min(1,(pageX-boxX)/boxW));return position}function isTextNode(value){return isObject(value)&&value.nodeType===3}function emptyEl(el){while(el.firstChild){el.removeChild(el.firstChild)}return el}function normalizeContent(content){if(typeof content==="function"){content=content()}return(Array.isArray(content)?content:[content]).map(function(value){if(typeof value==="function"){value=value()}if(isEl(value)||isTextNode(value)){return value}if(typeof value==="string"&&/\S/.test(value)){return document.createTextNode(value)}}).filter(function(value){return value})}function appendContent(el,content){normalizeContent(content).forEach(function(node){return el.appendChild(node)});return el}function insertContent(el,content){return appendContent(emptyEl(el),content)}function isSingleLeftClick(event){if(event.button===undefined&&event.buttons===undefined){return true}if(event.button===0&&event.buttons===undefined){return true}if(event.type==="mouseup"&&event.button===0&&event.buttons===0){return true}if(event.button!==0||event.buttons!==1){return false}return true}var $=createQuerier("querySelector");var $$=createQuerier("querySelectorAll");var Dom=Object.freeze({isReal:isReal,isEl:isEl,isInFrame:isInFrame,createEl:createEl,textContent:textContent,prependTo:prependTo,hasClass:hasClass,addClass:addClass,removeClass:removeClass,toggleClass:toggleClass,setAttributes:setAttributes,getAttributes:getAttributes,getAttribute:getAttribute,setAttribute:setAttribute,removeAttribute:removeAttribute,blockTextSelection:blockTextSelection,unblockTextSelection:unblockTextSelection,getBoundingClientRect:getBoundingClientRect,findPosition:findPosition,getPointerPosition:getPointerPosition,isTextNode:isTextNode,emptyEl:emptyEl,normalizeContent:normalizeContent,appendContent:appendContent,insertContent:insertContent,isSingleLeftClick:isSingleLeftClick,$:$,$$:$$});var _windowLoaded=false;var videojs;var autoSetup=function autoSetup(){if(!isReal()||videojs.options.autoSetup===false){return}var vids=Array.prototype.slice.call(document.getElementsByTagName("video"));var audios=Array.prototype.slice.call(document.getElementsByTagName("audio"));var divs=Array.prototype.slice.call(document.getElementsByTagName("video-js"));var mediaEls=vids.concat(audios,divs);if(mediaEls&&mediaEls.length>0){for(var i=0,e=mediaEls.length;i<e;i++){var mediaEl=mediaEls[i];if(mediaEl&&mediaEl.getAttribute){if(mediaEl.player===undefined){var options=mediaEl.getAttribute("data-setup");if(options!==null){videojs(mediaEl)}}}else{autoSetupTimeout(1);break}}}else if(!_windowLoaded){autoSetupTimeout(1)}};function autoSetupTimeout(wait,vjs){if(vjs){videojs=vjs}window$1.setTimeout(autoSetup,wait)}function setWindowLoaded(){_windowLoaded=true;window$1.removeEventListener("load",setWindowLoaded)}if(isReal()){if(document.readyState==="complete"){setWindowLoaded()}else{window$1.addEventListener("load",setWindowLoaded)}}var createStyleElement=function createStyleElement(className){var style=document.createElement("style");style.className=className;return style};var setTextContent=function setTextContent(el,content){if(el.styleSheet){el.styleSheet.cssText=content}else{el.textContent=content}};var _initialGuid=3;var _guid=_initialGuid;function newGUID(){return _guid++}var FakeWeakMap;if(!window$1.WeakMap){FakeWeakMap=function(){function FakeWeakMap(){this.vdata="vdata"+Math.floor(window$1.performance&&window$1.performance.now()||Date.now());this.data={}}var _proto=FakeWeakMap.prototype;_proto.set=function set(key,value){var access=key[this.vdata]||newGUID();if(!key[this.vdata]){key[this.vdata]=access}this.data[access]=value;return this};_proto.get=function get(key){var access=key[this.vdata];if(access){return this.data[access]}log("We have no data for this element",key);return undefined};_proto.has=function has(key){var access=key[this.vdata];return access in this.data};_proto["delete"]=function _delete(key){var access=key[this.vdata];if(access){delete this.data[access];delete key[this.vdata]}};return FakeWeakMap}()}var DomData=window$1.WeakMap?new WeakMap:new FakeWeakMap;function _cleanUpEvents(elem,type){if(!DomData.has(elem)){return}var data=DomData.get(elem);if(data.handlers[type].length===0){delete data.handlers[type];if(elem.removeEventListener){elem.removeEventListener(type,data.dispatcher,false)}else if(elem.detachEvent){elem.detachEvent("on"+type,data.dispatcher)}}if(Object.getOwnPropertyNames(data.handlers).length<=0){delete data.handlers;delete data.dispatcher;delete data.disabled}if(Object.getOwnPropertyNames(data).length===0){DomData["delete"](elem)}}function _handleMultipleEvents(fn,elem,types,callback){types.forEach(function(type){fn(elem,type,callback)})}function fixEvent(event){function returnTrue(){return true}function returnFalse(){return false}if(!event||!event.isPropagationStopped){var old=event||window$1.event;event={};for(var key in old){if(key!=="layerX"&&key!=="layerY"&&key!=="keyLocation"&&key!=="webkitMovementX"&&key!=="webkitMovementY"){if(!(key==="returnValue"&&old.preventDefault)){event[key]=old[key]}}}if(!event.target){event.target=event.srcElement||document}if(!event.relatedTarget){event.relatedTarget=event.fromElement===event.target?event.toElement:event.fromElement}event.preventDefault=function(){if(old.preventDefault){old.preventDefault()}event.returnValue=false;old.returnValue=false;event.defaultPrevented=true};event.defaultPrevented=false;event.stopPropagation=function(){if(old.stopPropagation){old.stopPropagation()}event.cancelBubble=true;old.cancelBubble=true;event.isPropagationStopped=returnTrue};event.isPropagationStopped=returnFalse;event.stopImmediatePropagation=function(){if(old.stopImmediatePropagation){old.stopImmediatePropagation()}event.isImmediatePropagationStopped=returnTrue;event.stopPropagation()};event.isImmediatePropagationStopped=returnFalse;if(event.clientX!==null&&event.clientX!==undefined){var doc=document.documentElement;var body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc&&doc.clientLeft||body&&body.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc&&doc.clientTop||body&&body.clientTop||0)}event.which=event.charCode||event.keyCode;if(event.button!==null&&event.button!==undefined){event.button=event.button&1?0:event.button&4?1:event.button&2?2:0}}return event}var _supportsPassive=false;(function(){try{var opts=Object.defineProperty({},"passive",{get:function get(){_supportsPassive=true}});window$1.addEventListener("test",null,opts);window$1.removeEventListener("test",null,opts)}catch(e){}})();var passiveEvents=["touchstart","touchmove"];function on(elem,type,fn){if(Array.isArray(type)){return _handleMultipleEvents(on,elem,type,fn)}if(!DomData.has(elem)){DomData.set(elem,{})}var data=DomData.get(elem);if(!data.handlers){data.handlers={}}if(!data.handlers[type]){data.handlers[type]=[]}if(!fn.guid){fn.guid=newGUID()}data.handlers[type].push(fn);if(!data.dispatcher){data.disabled=false;data.dispatcher=function(event,hash){if(data.disabled){return}event=fixEvent(event);var handlers=data.handlers[event.type];if(handlers){var handlersCopy=handlers.slice(0);for(var m=0,n=handlersCopy.length;m<n;m++){if(event.isImmediatePropagationStopped()){break}else{try{handlersCopy[m].call(elem,event,hash)}catch(e){log.error(e)}}}}}}if(data.handlers[type].length===1){if(elem.addEventListener){var options=false;if(_supportsPassive&&passiveEvents.indexOf(type)>-1){options={passive:true}}elem.addEventListener(type,data.dispatcher,options)}else if(elem.attachEvent){elem.attachEvent("on"+type,data.dispatcher)}}}function off(elem,type,fn){if(!DomData.has(elem)){return}var data=DomData.get(elem);if(!data.handlers){return}if(Array.isArray(type)){return _handleMultipleEvents(off,elem,type,fn)}var removeType=function removeType(el,t){data.handlers[t]=[];_cleanUpEvents(el,t)};if(type===undefined){for(var t in data.handlers){if(Object.prototype.hasOwnProperty.call(data.handlers||{},t)){removeType(elem,t)}}return}var handlers=data.handlers[type];if(!handlers){return}if(!fn){removeType(elem,type);return}if(fn.guid){for(var n=0;n<handlers.length;n++){if(handlers[n].guid===fn.guid){handlers.splice(n--,1)}}}_cleanUpEvents(elem,type)}function trigger(elem,event,hash){var elemData=DomData.has(elem)?DomData.get(elem):{};var parent=elem.parentNode||elem.ownerDocument;if(typeof event==="string"){event={type:event,target:elem}}else if(!event.target){event.target=elem}event=fixEvent(event);if(elemData.dispatcher){elemData.dispatcher.call(elem,event,hash)}if(parent&&!event.isPropagationStopped()&&event.bubbles===true){trigger.call(null,parent,event,hash)}else if(!parent&&!event.defaultPrevented&&event.target&&event.target[event.type]){if(!DomData.has(event.target)){DomData.set(event.target,{})}var targetData=DomData.get(event.target);if(event.target[event.type]){targetData.disabled=true;if(typeof event.target[event.type]==="function"){event.target[event.type]()}targetData.disabled=false}}return!event.defaultPrevented}function one(elem,type,fn){if(Array.isArray(type)){return _handleMultipleEvents(one,elem,type,fn)}var func=function func(){off(elem,type,func);fn.apply(this,arguments)};func.guid=fn.guid=fn.guid||newGUID();on(elem,type,func)}function any(elem,type,fn){var func=function func(){off(elem,type,func);fn.apply(this,arguments)};func.guid=fn.guid=fn.guid||newGUID();on(elem,type,func)}var Events=Object.freeze({fixEvent:fixEvent,on:on,off:off,trigger:trigger,one:one,any:any});var UPDATE_REFRESH_INTERVAL=30;var bind=function bind(context,fn,uid){if(!fn.guid){fn.guid=newGUID()}var bound=fn.bind(context);bound.guid=uid?uid+"_"+fn.guid:fn.guid;return bound};var throttle=function throttle(fn,wait){var last=window$1.performance.now();var throttled=function throttled(){var now=window$1.performance.now();if(now-last>=wait){fn.apply(void 0,arguments);last=now}};return throttled};var debounce=function debounce(func,wait,immediate,context){if(context===void 0){context=window$1}var timeout;var cancel=function cancel(){context.clearTimeout(timeout);timeout=null};var debounced=function debounced(){var self=this;var args=arguments;var _later=function later(){timeout=null;_later=null;if(!immediate){func.apply(self,args)}};if(!timeout&&immediate){func.apply(self,args)}context.clearTimeout(timeout);timeout=context.setTimeout(_later,wait)};debounced.cancel=cancel;return debounced};var EventTarget=function EventTarget(){};EventTarget.prototype.allowedEvents_={};EventTarget.prototype.on=function(type,fn){var ael=this.addEventListener;this.addEventListener=function(){};on(this,type,fn);this.addEventListener=ael};EventTarget.prototype.addEventListener=EventTarget.prototype.on;EventTarget.prototype.off=function(type,fn){off(this,type,fn)};EventTarget.prototype.removeEventListener=EventTarget.prototype.off;EventTarget.prototype.one=function(type,fn){var ael=this.addEventListener;this.addEventListener=function(){};one(this,type,fn);this.addEventListener=ael};EventTarget.prototype.any=function(type,fn){var ael=this.addEventListener;this.addEventListener=function(){};any(this,type,fn);this.addEventListener=ael};EventTarget.prototype.trigger=function(event){var type=event.type||event;if(typeof event==="string"){event={type:type}}event=fixEvent(event);if(this.allowedEvents_[type]&&this["on"+type]){this["on"+type](event)}trigger(this,event)};EventTarget.prototype.dispatchEvent=EventTarget.prototype.trigger;var EVENT_MAP;EventTarget.prototype.queueTrigger=function(event){var _this=this;if(!EVENT_MAP){EVENT_MAP=new Map}var type=event.type||event;var map=EVENT_MAP.get(this);if(!map){map=new Map;EVENT_MAP.set(this,map)}var oldTimeout=map.get(type);map["delete"](type);window$1.clearTimeout(oldTimeout);var timeout=window$1.setTimeout(function(){if(map.size===0){map=null;EVENT_MAP["delete"](_this)}_this.trigger(event)},0);map.set(type,timeout)};var isEvented=function isEvented(object){return object instanceof EventTarget||!!object.eventBusEl_&&["on","one","off","trigger"].every(function(k){return typeof object[k]==="function"})};var addEventedCallback=function addEventedCallback(target,callback){if(isEvented(target)){callback()}else{if(!target.eventedCallbacks){target.eventedCallbacks=[]}target.eventedCallbacks.push(callback)}};var isValidEventType=function isValidEventType(type){return typeof type==="string"&&/\S/.test(type)||Array.isArray(type)&&!!type.length};var validateTarget=function validateTarget(target){if(!target.nodeName&&!isEvented(target)){throw new Error("Invalid target; must be a DOM node or evented object.")}};var validateEventType=function validateEventType(type){if(!isValidEventType(type)){throw new Error("Invalid event type; must be a non-empty string or array.")}};var validateListener=function validateListener(listener){if(typeof listener!=="function"){throw new Error("Invalid listener; must be a function.")}};var normalizeListenArgs=function normalizeListenArgs(self,args){var isTargetingSelf=args.length<3||args[0]===self||args[0]===self.eventBusEl_;var target;var type;var listener;if(isTargetingSelf){target=self.eventBusEl_;if(args.length>=3){args.shift()}type=args[0];listener=args[1]}else{target=args[0];type=args[1];listener=args[2]}validateTarget(target);validateEventType(type);validateListener(listener);listener=bind(self,listener);return{isTargetingSelf:isTargetingSelf,target:target,type:type,listener:listener}};var listen=function listen(target,method,type,listener){validateTarget(target);if(target.nodeName){Events[method](target,type,listener)}else{target[method](type,listener)}};var EventedMixin={on:function on(){var _this=this;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}var _normalizeListenArgs=normalizeListenArgs(this,args),isTargetingSelf=_normalizeListenArgs.isTargetingSelf,target=_normalizeListenArgs.target,type=_normalizeListenArgs.type,listener=_normalizeListenArgs.listener;listen(target,"on",type,listener);if(!isTargetingSelf){var removeListenerOnDispose=function removeListenerOnDispose(){return _this.off(target,type,listener)};removeListenerOnDispose.guid=listener.guid;var removeRemoverOnTargetDispose=function removeRemoverOnTargetDispose(){return _this.off("dispose",removeListenerOnDispose)};removeRemoverOnTargetDispose.guid=listener.guid;listen(this,"on","dispose",removeListenerOnDispose);listen(target,"on","dispose",removeRemoverOnTargetDispose)}},one:function one(){var _this2=this;for(var _len2=arguments.length,args=new Array(_len2),_key2=0;_key2<_len2;_key2++){args[_key2]=arguments[_key2]}var _normalizeListenArgs2=normalizeListenArgs(this,args),isTargetingSelf=_normalizeListenArgs2.isTargetingSelf,target=_normalizeListenArgs2.target,type=_normalizeListenArgs2.type,listener=_normalizeListenArgs2.listener;if(isTargetingSelf){listen(target,"one",type,listener)}else{var wrapper=function wrapper(){_this2.off(target,type,wrapper);for(var _len3=arguments.length,largs=new Array(_len3),_key3=0;_key3<_len3;_key3++){largs[_key3]=arguments[_key3]}listener.apply(null,largs)};wrapper.guid=listener.guid;listen(target,"one",type,wrapper)}},any:function any(){var _this3=this;for(var _len4=arguments.length,args=new Array(_len4),_key4=0;_key4<_len4;_key4++){args[_key4]=arguments[_key4]}var _normalizeListenArgs3=normalizeListenArgs(this,args),isTargetingSelf=_normalizeListenArgs3.isTargetingSelf,target=_normalizeListenArgs3.target,type=_normalizeListenArgs3.type,listener=_normalizeListenArgs3.listener;if(isTargetingSelf){listen(target,"any",type,listener)}else{var wrapper=function wrapper(){_this3.off(target,type,wrapper);for(var _len5=arguments.length,largs=new Array(_len5),_key5=0;_key5<_len5;_key5++){largs[_key5]=arguments[_key5]}listener.apply(null,largs)};wrapper.guid=listener.guid;listen(target,"any",type,wrapper)}},off:function off$1(targetOrType,typeOrListener,listener){if(!targetOrType||isValidEventType(targetOrType)){off(this.eventBusEl_,targetOrType,typeOrListener)}else{var target=targetOrType;var type=typeOrListener;validateTarget(target);validateEventType(type);validateListener(listener);listener=bind(this,listener);this.off("dispose",listener);if(target.nodeName){off(target,type,listener);off(target,"dispose",listener)}else if(isEvented(target)){target.off(type,listener);target.off("dispose",listener)}}},trigger:function trigger$1(event,hash){return trigger(this.eventBusEl_,event,hash)}};function evented(target,options){if(options===void 0){options={}}var _options=options,eventBusKey=_options.eventBusKey;if(eventBusKey){if(!target[eventBusKey].nodeName){throw new Error('The eventBusKey "'+eventBusKey+'" does not refer to an element.')}target.eventBusEl_=target[eventBusKey]}else{target.eventBusEl_=createEl("span",{className:"vjs-event-bus"})}assign(target,EventedMixin);if(target.eventedCallbacks){target.eventedCallbacks.forEach(function(callback){callback()})}target.on("dispose",function(){target.off();window$1.setTimeout(function(){target.eventBusEl_=null},0)});return target}var StatefulMixin={state:{},setState:function setState(stateUpdates){var _this=this;if(typeof stateUpdates==="function"){stateUpdates=stateUpdates()}var changes;each(stateUpdates,function(value,key){if(_this.state[key]!==value){changes=changes||{};changes[key]={from:_this.state[key],to:value}}_this.state[key]=value});if(changes&&isEvented(this)){this.trigger({changes:changes,type:"statechanged"})}return changes}};function stateful(target,defaultState){assign(target,StatefulMixin);target.state=assign({},target.state,defaultState);if(typeof target.handleStateChanged==="function"&&isEvented(target)){target.on("statechanged",target.handleStateChanged)}return target}var toLowerCase=function toLowerCase(string){if(typeof string!=="string"){return string}return string.replace(/./,function(w){return w.toLowerCase()})};var toTitleCase=function toTitleCase(string){if(typeof string!=="string"){return string}return string.replace(/./,function(w){return w.toUpperCase()})};var titleCaseEquals=function titleCaseEquals(str1,str2){return toTitleCase(str1)===toTitleCase(str2)};function mergeOptions(){var result={};for(var _len=arguments.length,sources=new Array(_len),_key=0;_key<_len;_key++){sources[_key]=arguments[_key]}sources.forEach(function(source){if(!source){return}each(source,function(value,key){if(!isPlain(value)){result[key]=value;return}if(!isPlain(result[key])){result[key]={}}result[key]=mergeOptions(result[key],value)})});return result}var Component=function(){function Component(player,options,ready){if(!player&&this.play){this.player_=player=this}else{this.player_=player}this.parentComponent_=null;this.options_=mergeOptions({},this.options_);options=this.options_=mergeOptions(this.options_,options);this.id_=options.id||options.el&&options.el.id;if(!this.id_){var id=player&&player.id&&player.id()||"no_player";this.id_=id+"_component_"+newGUID()}this.name_=options.name||null;if(options.el){this.el_=options.el}else if(options.createEl!==false){this.el_=this.createEl()}if(options.evented!==false){evented(this,{eventBusKey:this.el_?"el_":null})}stateful(this,this.constructor.defaultState);this.children_=[];this.childIndex_={};this.childNameIndex_={};var SetSham;if(!window$1.Set){SetSham=function(){function SetSham(){this.set_={}}var _proto2=SetSham.prototype;_proto2.has=function has(key){return key in this.set_};_proto2["delete"]=function _delete(key){var has=this.has(key);delete this.set_[key];return has};_proto2.add=function add(key){this.set_[key]=1;return this};_proto2.forEach=function forEach(callback,thisArg){for(var key in this.set_){callback.call(thisArg,key,key,this)}};return SetSham}()}this.setTimeoutIds_=window$1.Set?new Set:new SetSham;this.setIntervalIds_=window$1.Set?new Set:new SetSham;this.rafIds_=window$1.Set?new Set:new SetSham;this.clearingTimersOnDispose_=false;if(options.initChildren!==false){this.initChildren()}this.ready(ready);if(options.reportTouchActivity!==false){this.enableTouchActivity()}}var _proto=Component.prototype;_proto.dispose=function dispose(){this.trigger({type:"dispose",bubbles:false});if(this.children_){for(var i=this.children_.length-1;i>=0;i--){if(this.children_[i].dispose){this.children_[i].dispose()}}}this.children_=null;this.childIndex_=null;this.childNameIndex_=null;this.parentComponent_=null;if(this.el_){if(this.el_.parentNode){this.el_.parentNode.removeChild(this.el_)}if(DomData.has(this.el_)){DomData["delete"](this.el_)}this.el_=null}this.player_=null};_proto.player=function player(){return this.player_};_proto.options=function options(obj){if(!obj){return this.options_}this.options_=mergeOptions(this.options_,obj);return this.options_};_proto.el=function el(){return this.el_};_proto.createEl=function createEl$1(tagName,properties,attributes){return createEl(tagName,properties,attributes)};_proto.localize=function localize(string,tokens,defaultValue){if(defaultValue===void 0){defaultValue=string}var code=this.player_.language&&this.player_.language();var languages=this.player_.languages&&this.player_.languages();var language=languages&&languages[code];var primaryCode=code&&code.split("-")[0];var primaryLang=languages&&languages[primaryCode];var localizedString=defaultValue;if(language&&language[string]){localizedString=language[string]}else if(primaryLang&&primaryLang[string]){localizedString=primaryLang[string]}if(tokens){localizedString=localizedString.replace(/\{(\d+)\}/g,function(match,index){var value=tokens[index-1];var ret=value;if(typeof value==="undefined"){ret=match}return ret})}return localizedString};_proto.contentEl=function contentEl(){return this.contentEl_||this.el_};_proto.id=function id(){return this.id_};_proto.name=function name(){return this.name_};_proto.children=function children(){return this.children_};_proto.getChildById=function getChildById(id){return this.childIndex_[id]};_proto.getChild=function getChild(name){if(!name){return}return this.childNameIndex_[name]};_proto.addChild=function addChild(child,options,index){if(options===void 0){options={}}if(index===void 0){index=this.children_.length}var component;var componentName;if(typeof child==="string"){componentName=toTitleCase(child);var componentClassName=options.componentClass||componentName;options.name=componentName;var ComponentClass=Component.getComponent(componentClassName);if(!ComponentClass){throw new Error("Component "+componentClassName+" does not exist")}if(typeof ComponentClass!=="function"){return null}component=new ComponentClass(this.player_||this,options)}else{component=child}if(component.parentComponent_){component.parentComponent_.removeChild(component)}this.children_.splice(index,0,component);component.parentComponent_=this;if(typeof component.id==="function"){this.childIndex_[component.id()]=component}componentName=componentName||component.name&&toTitleCase(component.name());if(componentName){this.childNameIndex_[componentName]=component;this.childNameIndex_[toLowerCase(componentName)]=component}if(typeof component.el==="function"&&component.el()){var childNodes=this.contentEl().children;var refNode=childNodes[index]||null;this.contentEl().insertBefore(component.el(),refNode)}return component};_proto.removeChild=function removeChild(component){if(typeof component==="string"){component=this.getChild(component)}if(!component||!this.children_){return}var childFound=false;for(var i=this.children_.length-1;i>=0;i--){if(this.children_[i]===component){childFound=true;this.children_.splice(i,1);break}}if(!childFound){return}component.parentComponent_=null;this.childIndex_[component.id()]=null;this.childNameIndex_[toTitleCase(component.name())]=null;this.childNameIndex_[toLowerCase(component.name())]=null;var compEl=component.el();if(compEl&&compEl.parentNode===this.contentEl()){this.contentEl().removeChild(component.el())}};_proto.initChildren=function initChildren(){var _this=this;var children=this.options_.children;if(children){var parentOptions=this.options_;var handleAdd=function handleAdd(child){var name=child.name;var opts=child.opts;if(parentOptions[name]!==undefined){opts=parentOptions[name]}if(opts===false){return}if(opts===true){opts={}}opts.playerOptions=_this.options_.playerOptions;var newChild=_this.addChild(name,opts);if(newChild){_this[name]=newChild}};var workingChildren;var Tech=Component.getComponent("Tech");if(Array.isArray(children)){workingChildren=children}else{workingChildren=Object.keys(children)}workingChildren.concat(Object.keys(this.options_).filter(function(child){return!workingChildren.some(function(wchild){if(typeof wchild==="string"){return child===wchild}return child===wchild.name})})).map(function(child){var name;var opts;if(typeof child==="string"){name=child;opts=children[name]||_this.options_[name]||{}}else{name=child.name;opts=child}return{name:name,opts:opts}}).filter(function(child){var c=Component.getComponent(child.opts.componentClass||toTitleCase(child.name));return c&&!Tech.isTech(c)}).forEach(handleAdd)}};_proto.buildCSSClass=function buildCSSClass(){return""};_proto.ready=function ready(fn,sync){if(sync===void 0){sync=false}if(!fn){return}if(!this.isReady_){this.readyQueue_=this.readyQueue_||[];this.readyQueue_.push(fn);return}if(sync){fn.call(this)}else{this.setTimeout(fn,1)}};_proto.triggerReady=function triggerReady(){this.isReady_=true;this.setTimeout(function(){var readyQueue=this.readyQueue_;this.readyQueue_=[];if(readyQueue&&readyQueue.length>0){readyQueue.forEach(function(fn){fn.call(this)},this)}this.trigger("ready")},1)};_proto.$=function $$1(selector,context){return $(selector,context||this.contentEl())};_proto.$$=function $$$1(selector,context){return $$(selector,context||this.contentEl())};_proto.hasClass=function hasClass$1(classToCheck){return hasClass(this.el_,classToCheck)};_proto.addClass=function addClass$1(classToAdd){addClass(this.el_,classToAdd)};_proto.removeClass=function removeClass$1(classToRemove){removeClass(this.el_,classToRemove)};_proto.toggleClass=function toggleClass$1(classToToggle,predicate){toggleClass(this.el_,classToToggle,predicate)};_proto.show=function show(){this.removeClass("vjs-hidden")};_proto.hide=function hide(){this.addClass("vjs-hidden")};_proto.lockShowing=function lockShowing(){this.addClass("vjs-lock-showing")};_proto.unlockShowing=function unlockShowing(){this.removeClass("vjs-lock-showing")};_proto.getAttribute=function getAttribute$1(attribute){return getAttribute(this.el_,attribute)};_proto.setAttribute=function setAttribute$1(attribute,value){setAttribute(this.el_,attribute,value)};_proto.removeAttribute=function removeAttribute$1(attribute){removeAttribute(this.el_,attribute)};_proto.width=function width(num,skipListeners){return this.dimension("width",num,skipListeners)};_proto.height=function height(num,skipListeners){return this.dimension("height",num,skipListeners)};_proto.dimensions=function dimensions(width,height){this.width(width,true);this.height(height)};_proto.dimension=function dimension(widthOrHeight,num,skipListeners){if(num!==undefined){if(num===null||num!==num){num=0}if((""+num).indexOf("%")!==-1||(""+num).indexOf("px")!==-1){this.el_.style[widthOrHeight]=num}else if(num==="auto"){this.el_.style[widthOrHeight]=""}else{this.el_.style[widthOrHeight]=num+"px"}if(!skipListeners){this.trigger("componentresize")}return}if(!this.el_){return 0}var val=this.el_.style[widthOrHeight];var pxIndex=val.indexOf("px");if(pxIndex!==-1){return parseInt(val.slice(0,pxIndex),10)}return parseInt(this.el_["offset"+toTitleCase(widthOrHeight)],10)};_proto.currentDimension=function currentDimension(widthOrHeight){var computedWidthOrHeight=0;if(widthOrHeight!=="width"&&widthOrHeight!=="height"){throw new Error("currentDimension only accepts width or height value")}computedWidthOrHeight=computedStyle(this.el_,widthOrHeight);computedWidthOrHeight=parseFloat(computedWidthOrHeight);if(computedWidthOrHeight===0||isNaN(computedWidthOrHeight)){var rule="offset"+toTitleCase(widthOrHeight);computedWidthOrHeight=this.el_[rule]}return computedWidthOrHeight};_proto.currentDimensions=function currentDimensions(){return{width:this.currentDimension("width"),height:this.currentDimension("height")}};_proto.currentWidth=function currentWidth(){return this.currentDimension("width")};_proto.currentHeight=function currentHeight(){return this.currentDimension("height")};_proto.focus=function focus(){this.el_.focus()};_proto.blur=function blur(){this.el_.blur()};_proto.handleKeyDown=function handleKeyDown(event){if(this.player_){event.stopPropagation();this.player_.handleKeyDown(event)}};_proto.handleKeyPress=function handleKeyPress(event){this.handleKeyDown(event)};_proto.emitTapEvents=function emitTapEvents(){var touchStart=0;var firstTouch=null;var tapMovementThreshold=10;var touchTimeThreshold=200;var couldBeTap;this.on("touchstart",function(event){if(event.touches.length===1){firstTouch={pageX:event.touches[0].pageX,pageY:event.touches[0].pageY};touchStart=window$1.performance.now();couldBeTap=true}});this.on("touchmove",function(event){if(event.touches.length>1){couldBeTap=false}else if(firstTouch){var xdiff=event.touches[0].pageX-firstTouch.pageX;var ydiff=event.touches[0].pageY-firstTouch.pageY;var touchDistance=Math.sqrt(xdiff*xdiff+ydiff*ydiff);if(touchDistance>tapMovementThreshold){couldBeTap=false}}});var noTap=function noTap(){couldBeTap=false};this.on("touchleave",noTap);this.on("touchcancel",noTap);this.on("touchend",function(event){firstTouch=null;if(couldBeTap===true){var touchTime=window$1.performance.now()-touchStart;if(touchTime<touchTimeThreshold){event.preventDefault();this.trigger("tap")}}})};_proto.enableTouchActivity=function enableTouchActivity(){if(!this.player()||!this.player().reportUserActivity){return}var report=bind(this.player(),this.player().reportUserActivity);var touchHolding;this.on("touchstart",function(){report();this.clearInterval(touchHolding);touchHolding=this.setInterval(report,250)});var touchEnd=function touchEnd(event){report();this.clearInterval(touchHolding)};this.on("touchmove",report);this.on("touchend",touchEnd);this.on("touchcancel",touchEnd)};_proto.setTimeout=function setTimeout(fn,timeout){var _this2=this;var timeoutId;fn=bind(this,fn);this.clearTimersOnDispose_();timeoutId=window$1.setTimeout(function(){if(_this2.setTimeoutIds_.has(timeoutId)){_this2.setTimeoutIds_["delete"](timeoutId)}fn()},timeout);this.setTimeoutIds_.add(timeoutId);return timeoutId};_proto.clearTimeout=function clearTimeout(timeoutId){if(this.setTimeoutIds_.has(timeoutId)){this.setTimeoutIds_["delete"](timeoutId);window$1.clearTimeout(timeoutId)}return timeoutId};_proto.setInterval=function setInterval(fn,interval){fn=bind(this,fn);this.clearTimersOnDispose_();var intervalId=window$1.setInterval(fn,interval);this.setIntervalIds_.add(intervalId);return intervalId};_proto.clearInterval=function clearInterval(intervalId){if(this.setIntervalIds_.has(intervalId)){this.setIntervalIds_["delete"](intervalId);window$1.clearInterval(intervalId)}return intervalId};_proto.requestAnimationFrame=function requestAnimationFrame(fn){var _this3=this;if(!this.supportsRaf_){return this.setTimeout(fn,1e3/60)}this.clearTimersOnDispose_();var id;fn=bind(this,fn);id=window$1.requestAnimationFrame(function(){if(_this3.rafIds_.has(id)){_this3.rafIds_["delete"](id)}fn()});this.rafIds_.add(id);return id};_proto.cancelAnimationFrame=function cancelAnimationFrame(id){if(!this.supportsRaf_){return this.clearTimeout(id)}if(this.rafIds_.has(id)){this.rafIds_["delete"](id);window$1.cancelAnimationFrame(id)}return id};_proto.clearTimersOnDispose_=function clearTimersOnDispose_(){var _this4=this;if(this.clearingTimersOnDispose_){return}this.clearingTimersOnDispose_=true;this.one("dispose",function(){[["rafIds_","cancelAnimationFrame"],["setTimeoutIds_","clearTimeout"],["setIntervalIds_","clearInterval"]].forEach(function(_ref){var idName=_ref[0],cancelName=_ref[1];_this4[idName].forEach(_this4[cancelName],_this4)});_this4.clearingTimersOnDispose_=false})};Component.registerComponent=function registerComponent(name,ComponentToRegister){if(typeof name!=="string"||!name){throw new Error('Illegal component name, "'+name+'"; must be a non-empty string.')}var Tech=Component.getComponent("Tech");var isTech=Tech&&Tech.isTech(ComponentToRegister);var isComp=Component===ComponentToRegister||Component.prototype.isPrototypeOf(ComponentToRegister.prototype);if(isTech||!isComp){var reason;if(isTech){reason="techs must be registered using Tech.registerTech()"}else{reason="must be a Component subclass"}throw new Error('Illegal component, "'+name+'"; '+reason+".")}name=toTitleCase(name);if(!Component.components_){Component.components_={}}var Player=Component.getComponent("Player");if(name==="Player"&&Player&&Player.players){var players=Player.players;var playerNames=Object.keys(players);if(players&&playerNames.length>0&&playerNames.map(function(pname){return players[pname]}).every(Boolean)){throw new Error("Can not register Player component after player has been created.")}}Component.components_[name]=ComponentToRegister;Component.components_[toLowerCase(name)]=ComponentToRegister;return ComponentToRegister};Component.getComponent=function getComponent(name){if(!name||!Component.components_){return}return Component.components_[name]};return Component}();Component.prototype.supportsRaf_=typeof window$1.requestAnimationFrame==="function"&&typeof window$1.cancelAnimationFrame==="function";Component.registerComponent("Component",Component);function _inheritsLoose(subClass,superClass){subClass.prototype=Object.create(superClass.prototype);subClass.prototype.constructor=subClass;subClass.__proto__=superClass}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o};return _setPrototypeOf(o,p)}function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Date.prototype.toString.call(Reflect.construct(Date,[],function(){}));return true}catch(e){return false}}function _construct(Parent,args,Class){if(isNativeReflectConstruct()){_construct=Reflect.construct}else{_construct=function _construct(Parent,args,Class){var a=[null];a.push.apply(a,args);var Constructor=Function.bind.apply(Parent,a);var instance=new Constructor;if(Class)_setPrototypeOf(instance,Class.prototype);return instance}}return _construct.apply(null,arguments)}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}var USER_AGENT=window$1.navigator&&window$1.navigator.userAgent||"";var webkitVersionMap=/AppleWebKit\/([\d.]+)/i.exec(USER_AGENT);var appleWebkitVersion=webkitVersionMap?parseFloat(webkitVersionMap.pop()):null;var IS_IPAD=/iPad/i.test(USER_AGENT);var IS_IPHONE=/iPhone/i.test(USER_AGENT)&&!IS_IPAD;var IS_IPOD=/iPod/i.test(USER_AGENT);var IS_IOS=IS_IPHONE||IS_IPAD||IS_IPOD;var IOS_VERSION=function(){var match=USER_AGENT.match(/OS (\d+)_/i);if(match&&match[1]){return match[1]}return null}();var IS_ANDROID=/Android/i.test(USER_AGENT);var ANDROID_VERSION=function(){var match=USER_AGENT.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!match){return null}var major=match[1]&&parseFloat(match[1]);var minor=match[2]&&parseFloat(match[2]);if(major&&minor){return parseFloat(match[1]+"."+match[2])}else if(major){return major}return null}();var IS_NATIVE_ANDROID=IS_ANDROID&&ANDROID_VERSION<5&&appleWebkitVersion<537;var IS_FIREFOX=/Firefox/i.test(USER_AGENT);var IS_EDGE=/Edge/i.test(USER_AGENT);var IS_CHROME=!IS_EDGE&&(/Chrome/i.test(USER_AGENT)||/CriOS/i.test(USER_AGENT));var CHROME_VERSION=function(){var match=USER_AGENT.match(/(Chrome|CriOS)\/(\d+)/);if(match&&match[2]){return parseFloat(match[2])}return null}();var IE_VERSION=function(){var result=/MSIE\s(\d+)\.\d/.exec(USER_AGENT);var version=result&&parseFloat(result[1]);if(!version&&/Trident\/7.0/i.test(USER_AGENT)&&/rv:11.0/.test(USER_AGENT)){version=11}return version}();var IS_SAFARI=/Safari/i.test(USER_AGENT)&&!IS_CHROME&&!IS_ANDROID&&!IS_EDGE;var IS_ANY_SAFARI=(IS_SAFARI||IS_IOS)&&!IS_CHROME;var IS_WINDOWS=/Windows/i.test(USER_AGENT);var TOUCH_ENABLED=isReal()&&("ontouchstart"in window$1||window$1.navigator.maxTouchPoints||window$1.DocumentTouch&&window$1.document instanceof window$1.DocumentTouch);var browser=Object.freeze({IS_IPAD:IS_IPAD,IS_IPHONE:IS_IPHONE,IS_IPOD:IS_IPOD,IS_IOS:IS_IOS,IOS_VERSION:IOS_VERSION,IS_ANDROID:IS_ANDROID,ANDROID_VERSION:ANDROID_VERSION,IS_NATIVE_ANDROID:IS_NATIVE_ANDROID,IS_FIREFOX:IS_FIREFOX,IS_EDGE:IS_EDGE,IS_CHROME:IS_CHROME,CHROME_VERSION:CHROME_VERSION,IE_VERSION:IE_VERSION,IS_SAFARI:IS_SAFARI,IS_ANY_SAFARI:IS_ANY_SAFARI,IS_WINDOWS:IS_WINDOWS,TOUCH_ENABLED:TOUCH_ENABLED});function rangeCheck(fnName,index,maxIndex){if(typeof index!=="number"||index<0||index>maxIndex){throw new Error("Failed to execute '"+fnName+"' on 'TimeRanges': The index provided ("+index+") is non-numeric or out of bounds (0-"+maxIndex+").")}}function getRange(fnName,valueIndex,ranges,rangeIndex){rangeCheck(fnName,rangeIndex,ranges.length-1);return ranges[rangeIndex][valueIndex]}function createTimeRangesObj(ranges){if(ranges===undefined||ranges.length===0){return{length:0,start:function start(){throw new Error("This TimeRanges object is empty")},end:function end(){throw new Error("This TimeRanges object is empty")}}}return{length:ranges.length,start:getRange.bind(null,"start",0,ranges),end:getRange.bind(null,"end",1,ranges)}}function createTimeRanges(start,end){if(Array.isArray(start)){return createTimeRangesObj(start)}else if(start===undefined||end===undefined){return createTimeRangesObj()}return createTimeRangesObj([[start,end]])}function bufferedPercent(buffered,duration){var bufferedDuration=0;var start;var end;if(!duration){return 0}if(!buffered||!buffered.length){buffered=createTimeRanges(0,0)}for(var i=0;i<buffered.length;i++){start=buffered.start(i);end=buffered.end(i);if(end>duration){end=duration}bufferedDuration+=end-start}return bufferedDuration/duration}var FullscreenApi={prefixed:true};var apiMap=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror","fullscreen"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror","-moz-full-screen"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError","-ms-fullscreen"]];var specApi=apiMap[0];var browserApi;for(var i=0;i<apiMap.length;i++){if(apiMap[i][1]in document){browserApi=apiMap[i];break}}if(browserApi){for(var _i=0;_i<browserApi.length;_i++){FullscreenApi[specApi[_i]]=browserApi[_i]}FullscreenApi.prefixed=browserApi[0]!==specApi[0]}function MediaError(value){if(value instanceof MediaError){return value}if(typeof value==="number"){this.code=value}else if(typeof value==="string"){this.message=value}else if(isObject(value)){if(typeof value.code==="number"){this.code=value.code}assign(this,value)}if(!this.message){this.message=MediaError.defaultMessages[this.code]||""}}MediaError.prototype.code=0;MediaError.prototype.message="";MediaError.prototype.status=null;MediaError.errorTypes=["MEDIA_ERR_CUSTOM","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED","MEDIA_ERR_ENCRYPTED"];MediaError.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail part-way.",3:"The media playback was aborted due to a corruption problem or because the media used features your browser did not support.",4:"The media could not be loaded, either because the server or network failed or because the format is not supported.",5:"The media is encrypted and we do not have the keys to decrypt it."};for(var errNum=0;errNum<MediaError.errorTypes.length;errNum++){MediaError[MediaError.errorTypes[errNum]]=errNum;MediaError.prototype[MediaError.errorTypes[errNum]]=errNum}var tuple=SafeParseTuple;function SafeParseTuple(obj,reviver){var json;var error=null;try{json=JSON.parse(obj,reviver)}catch(err){error=err}return[error,json]}function isPromise(value){return value!==undefined&&value!==null&&typeof value.then==="function"}function silencePromise(value){if(isPromise(value)){value.then(null,function(e){})}}var trackToJson_=function trackToJson_(track){var ret=["kind","label","language","id","inBandMetadataTrackDispatchType","mode","src"].reduce(function(acc,prop,i){if(track[prop]){acc[prop]=track[prop]}return acc},{cues:track.cues&&Array.prototype.map.call(track.cues,function(cue){return{startTime:cue.startTime,endTime:cue.endTime,text:cue.text,id:cue.id}})});return ret};var textTracksToJson=function textTracksToJson(tech){var trackEls=tech.$$("track");var trackObjs=Array.prototype.map.call(trackEls,function(t){return t.track});var tracks=Array.prototype.map.call(trackEls,function(trackEl){var json=trackToJson_(trackEl.track);if(trackEl.src){json.src=trackEl.src}return json});return tracks.concat(Array.prototype.filter.call(tech.textTracks(),function(track){return trackObjs.indexOf(track)===-1}).map(trackToJson_))};var jsonToTextTracks=function jsonToTextTracks(json,tech){json.forEach(function(track){var addedTrack=tech.addRemoteTextTrack(track).track;if(!track.src&&track.cues){track.cues.forEach(function(cue){return addedTrack.addCue(cue)})}});return tech.textTracks()};var textTrackConverter={textTracksToJson:textTracksToJson,jsonToTextTracks:jsonToTextTracks,trackToJson_:trackToJson_};function createCommonjsModule(fn,module){return module={exports:{}},fn(module,module.exports),module.exports}var keycode=createCommonjsModule(function(module,exports){function keyCode(searchInput){if(searchInput&&"object"===typeof searchInput){var hasKeyCode=searchInput.which||searchInput.keyCode||searchInput.charCode;if(hasKeyCode)searchInput=hasKeyCode}if("number"===typeof searchInput)return names[searchInput];var search=String(searchInput);var foundNamedKey=codes[search.toLowerCase()];if(foundNamedKey)return foundNamedKey;var foundNamedKey=aliases[search.toLowerCase()];if(foundNamedKey)return foundNamedKey;if(search.length===1)return search.charCodeAt(0);return undefined}keyCode.isEventKey=function isEventKey(event,nameOrCode){if(event&&"object"===typeof event){var keyCode=event.which||event.keyCode||event.charCode;if(keyCode===null||keyCode===undefined){return false}if(typeof nameOrCode==="string"){var foundNamedKey=codes[nameOrCode.toLowerCase()];if(foundNamedKey){return foundNamedKey===keyCode}var foundNamedKey=aliases[nameOrCode.toLowerCase()];if(foundNamedKey){return foundNamedKey===keyCode}}else if(typeof nameOrCode==="number"){return nameOrCode===keyCode}return false}};exports=module.exports=keyCode;var codes=exports.code=exports.codes={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,"pause/break":19,"caps lock":20,esc:27,space:32,"page up":33,"page down":34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,delete:46,command:91,"left command":91,"right command":93,"numpad *":106,"numpad +":107,"numpad -":109,"numpad .":110,"numpad /":111,"num lock":144,"scroll lock":145,"my computer":182,"my calculator":183,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222};var aliases=exports.aliases={windows:91,"⇧":16,"⌥":18,"⌃":17,"⌘":91,ctl:17,control:17,option:18,pause:19,break:19,caps:20,return:13,escape:27,spc:32,spacebar:32,pgup:33,pgdn:34,ins:45,del:46,cmd:91};for(i=97;i<123;i++){codes[String.fromCharCode(i)]=i-32}for(var i=48;i<58;i++){codes[i-48]=i}for(i=1;i<13;i++){codes["f"+i]=i+111}for(i=0;i<10;i++){codes["numpad "+i]=i+96}var names=exports.names=exports.title={};for(i in codes){names[codes[i]]=i}for(var alias in aliases){codes[alias]=aliases[alias]}});var keycode_1=keycode.code;var keycode_2=keycode.codes;var keycode_3=keycode.aliases;var keycode_4=keycode.names;var keycode_5=keycode.title;var MODAL_CLASS_NAME="vjs-modal-dialog";var ModalDialog=function(_Component){_inheritsLoose(ModalDialog,_Component);function ModalDialog(player,options){var _this;_this=_Component.call(this,player,options)||this;_this.opened_=_this.hasBeenOpened_=_this.hasBeenFilled_=false;_this.closeable(!_this.options_.uncloseable);_this.content(_this.options_.content);_this.contentEl_=createEl("div",{className:MODAL_CLASS_NAME+"-content"},{role:"document"});_this.descEl_=createEl("p",{className:MODAL_CLASS_NAME+"-description vjs-control-text",id:_this.el().getAttribute("aria-describedby")});textContent(_this.descEl_,_this.description());_this.el_.appendChild(_this.descEl_);_this.el_.appendChild(_this.contentEl_);return _this}var _proto=ModalDialog.prototype;_proto.createEl=function createEl(){return _Component.prototype.createEl.call(this,"div",{className:this.buildCSSClass(),tabIndex:-1},{"aria-describedby":this.id()+"_description","aria-hidden":"true","aria-label":this.label(),role:"dialog"})};_proto.dispose=function dispose(){this.contentEl_=null;this.descEl_=null;this.previouslyActiveEl_=null;_Component.prototype.dispose.call(this)};_proto.buildCSSClass=function buildCSSClass(){return MODAL_CLASS_NAME+" vjs-hidden "+_Component.prototype.buildCSSClass.call(this)};_proto.label=function label(){return this.localize(this.options_.label||"Modal Window")};_proto.description=function description(){var desc=this.options_.description||this.localize("This is a modal window.");if(this.closeable()){desc+=" "+this.localize("This modal can be closed by pressing the Escape key or activating the close button.")}return desc};_proto.open=function open(){if(!this.opened_){var player=this.player();this.trigger("beforemodalopen");this.opened_=true;if(this.options_.fillAlways||!this.hasBeenOpened_&&!this.hasBeenFilled_){this.fill()}this.wasPlaying_=!player.paused();if(this.options_.pauseOnOpen&&this.wasPlaying_){player.pause()}this.on("keydown",this.handleKeyDown);this.hadControls_=player.controls();player.controls(false);this.show();this.conditionalFocus_();this.el().setAttribute("aria-hidden","false");this.trigger("modalopen");this.hasBeenOpened_=true}};_proto.opened=function opened(value){if(typeof value==="boolean"){this[value?"open":"close"]()}return this.opened_};_proto.close=function close(){if(!this.opened_){return}var player=this.player();this.trigger("beforemodalclose");this.opened_=false;if(this.wasPlaying_&&this.options_.pauseOnOpen){player.play()}this.off("keydown",this.handleKeyDown);if(this.hadControls_){player.controls(true)}this.hide();this.el().setAttribute("aria-hidden","true");this.trigger("modalclose");this.conditionalBlur_();if(this.options_.temporary){this.dispose()}};_proto.closeable=function closeable(value){if(typeof value==="boolean"){var closeable=this.closeable_=!!value;var close=this.getChild("closeButton");if(closeable&&!close){var temp=this.contentEl_;this.contentEl_=this.el_;close=this.addChild("closeButton",{controlText:"Close Modal Dialog"});this.contentEl_=temp;this.on(close,"close",this.close)}if(!closeable&&close){this.off(close,"close",this.close);this.removeChild(close);close.dispose()}}return this.closeable_};_proto.fill=function fill(){this.fillWith(this.content())};_proto.fillWith=function fillWith(content){var contentEl=this.contentEl();var parentEl=contentEl.parentNode;var nextSiblingEl=contentEl.nextSibling;this.trigger("beforemodalfill");this.hasBeenFilled_=true;parentEl.removeChild(contentEl);this.empty();insertContent(contentEl,content);this.trigger("modalfill");if(nextSiblingEl){parentEl.insertBefore(contentEl,nextSiblingEl)}else{parentEl.appendChild(contentEl)}var closeButton=this.getChild("closeButton");if(closeButton){parentEl.appendChild(closeButton.el_)}};_proto.empty=function empty(){this.trigger("beforemodalempty");emptyEl(this.contentEl());this.trigger("modalempty")};_proto.content=function content(value){if(typeof value!=="undefined"){this.content_=value}return this.content_};_proto.conditionalFocus_=function conditionalFocus_(){var activeEl=document.activeElement;var playerEl=this.player_.el_;this.previouslyActiveEl_=null;if(playerEl.contains(activeEl)||playerEl===activeEl){this.previouslyActiveEl_=activeEl;this.focus()}};_proto.conditionalBlur_=function conditionalBlur_(){if(this.previouslyActiveEl_){this.previouslyActiveEl_.focus();this.previouslyActiveEl_=null}};_proto.handleKeyDown=function handleKeyDown(event){event.stopPropagation();if(keycode.isEventKey(event,"Escape")&&this.closeable()){event.preventDefault();this.close();return}if(!keycode.isEventKey(event,"Tab")){return}var focusableEls=this.focusableEls_();var activeEl=this.el_.querySelector(":focus");var focusIndex;for(var i=0;i<focusableEls.length;i++){if(activeEl===focusableEls[i]){focusIndex=i;break}}if(document.activeElement===this.el_){focusIndex=0}if(event.shiftKey&&focusIndex===0){focusableEls[focusableEls.length-1].focus();event.preventDefault()}else if(!event.shiftKey&&focusIndex===focusableEls.length-1){focusableEls[0].focus();event.preventDefault()}};_proto.focusableEls_=function focusableEls_(){var allChildren=this.el_.querySelectorAll("*");return Array.prototype.filter.call(allChildren,function(child){return(child instanceof window$1.HTMLAnchorElement||child instanceof window$1.HTMLAreaElement)&&child.hasAttribute("href")||(child instanceof window$1.HTMLInputElement||child instanceof window$1.HTMLSelectElement||child instanceof window$1.HTMLTextAreaElement||child instanceof window$1.HTMLButtonElement)&&!child.hasAttribute("disabled")||child instanceof window$1.HTMLIFrameElement||child instanceof window$1.HTMLObjectElement||child instanceof window$1.HTMLEmbedElement||child.hasAttribute("tabindex")&&child.getAttribute("tabindex")!==-1||child.hasAttribute("contenteditable")})};return ModalDialog}(Component);ModalDialog.prototype.options_={pauseOnOpen:true,temporary:true};Component.registerComponent("ModalDialog",ModalDialog);var TrackList=function(_EventTarget){_inheritsLoose(TrackList,_EventTarget);function TrackList(tracks){var _this;if(tracks===void 0){tracks=[]}_this=_EventTarget.call(this)||this;_this.tracks_=[];Object.defineProperty(_assertThisInitialized(_this),"length",{get:function get(){return this.tracks_.length}});for(var i=0;i<tracks.length;i++){_this.addTrack(tracks[i])}return _this}var _proto=TrackList.prototype;_proto.addTrack=function addTrack(track){var index=this.tracks_.length;if(!(""+index in this)){Object.defineProperty(this,index,{get:function get(){return this.tracks_[index]}})}if(this.tracks_.indexOf(track)===-1){this.tracks_.push(track);this.trigger({track:track,type:"addtrack",target:this})}};_proto.removeTrack=function removeTrack(rtrack){var track;for(var i=0,l=this.length;i<l;i++){if(this[i]===rtrack){track=this[i];if(track.off){track.off()}this.tracks_.splice(i,1);break}}if(!track){return}this.trigger({track:track,type:"removetrack",target:this})};_proto.getTrackById=function getTrackById(id){var result=null;for(var i=0,l=this.length;i<l;i++){var track=this[i];if(track.id===id){result=track;break}}return result};return TrackList}(EventTarget);TrackList.prototype.allowedEvents_={change:"change",addtrack:"addtrack",removetrack:"removetrack"};for(var event in TrackList.prototype.allowedEvents_){TrackList.prototype["on"+event]=null}var disableOthers=function disableOthers(list,track){for(var i=0;i<list.length;i++){if(!Object.keys(list[i]).length||track.id===list[i].id){continue}list[i].enabled=false}};var AudioTrackList=function(_TrackList){_inheritsLoose(AudioTrackList,_TrackList);function AudioTrackList(tracks){var _this;if(tracks===void 0){tracks=[]}for(var i=tracks.length-1;i>=0;i--){if(tracks[i].enabled){disableOthers(tracks,tracks[i]);break}}_this=_TrackList.call(this,tracks)||this;_this.changing_=false;return _this}var _proto=AudioTrackList.prototype;_proto.addTrack=function addTrack(track){var _this2=this;if(track.enabled){disableOthers(this,track)}_TrackList.prototype.addTrack.call(this,track);if(!track.addEventListener){return}track.enabledChange_=function(){if(_this2.changing_){return}_this2.changing_=true;disableOthers(_this2,track);_this2.changing_=false;_this2.trigger("change")};track.addEventListener("enabledchange",track.enabledChange_)};_proto.removeTrack=function removeTrack(rtrack){_TrackList.prototype.removeTrack.call(this,rtrack);if(rtrack.removeEventListener&&rtrack.enabledChange_){rtrack.removeEventListener("enabledchange",rtrack.enabledChange_);rtrack.enabledChange_=null}};return AudioTrackList}(TrackList);var disableOthers$1=function disableOthers(list,track){for(var i=0;i<list.length;i++){if(!Object.keys(list[i]).length||track.id===list[i].id){continue}list[i].selected=false}};var VideoTrackList=function(_TrackList){_inheritsLoose(VideoTrackList,_TrackList);function VideoTrackList(tracks){var _this;if(tracks===void 0){tracks=[]}for(var i=tracks.length-1;i>=0;i--){if(tracks[i].selected){disableOthers$1(tracks,tracks[i]);break}}_this=_TrackList.call(this,tracks)||this;_this.changing_=false;Object.defineProperty(_assertThisInitialized(_this),"selectedIndex",{get:function get(){for(var _i=0;_i<this.length;_i++){if(this[_i].selected){return _i}}return-1},set:function set(){}});return _this}var _proto=VideoTrackList.prototype;_proto.addTrack=function addTrack(track){var _this2=this;if(track.selected){disableOthers$1(this,track)}_TrackList.prototype.addTrack.call(this,track);if(!track.addEventListener){return}track.selectedChange_=function(){if(_this2.changing_){return}_this2.changing_=true;disableOthers$1(_this2,track);_this2.changing_=false;_this2.trigger("change")};track.addEventListener("selectedchange",track.selectedChange_)};_proto.removeTrack=function removeTrack(rtrack){_TrackList.prototype.removeTrack.call(this,rtrack);if(rtrack.removeEventListener&&rtrack.selectedChange_){rtrack.removeEventListener("selectedchange",rtrack.selectedChange_);rtrack.selectedChange_=null}};return VideoTrackList}(TrackList);var TextTrackList=function(_TrackList){_inheritsLoose(TextTrackList,_TrackList);function TextTrackList(){return _TrackList.apply(this,arguments)||this}var _proto=TextTrackList.prototype;_proto.addTrack=function addTrack(track){var _this=this;_TrackList.prototype.addTrack.call(this,track);if(!this.queueChange_){this.queueChange_=function(){return _this.queueTrigger("change")}}if(!this.triggerSelectedlanguagechange){this.triggerSelectedlanguagechange_=function(){return _this.trigger("selectedlanguagechange")}}track.addEventListener("modechange",this.queueChange_);var nonLanguageTextTrackKind=["metadata","chapters"];if(nonLanguageTextTrackKind.indexOf(track.kind)===-1){track.addEventListener("modechange",this.triggerSelectedlanguagechange_)}};_proto.removeTrack=function removeTrack(rtrack){_TrackList.prototype.removeTrack.call(this,rtrack);if(rtrack.removeEventListener){if(this.queueChange_){rtrack.removeEventListener("modechange",this.queueChange_)}if(this.selectedlanguagechange_){rtrack.removeEventListener("modechange",this.triggerSelectedlanguagechange_)}}};return TextTrackList}(TrackList);var HtmlTrackElementList=function(){function HtmlTrackElementList(trackElements){if(trackElements===void 0){trackElements=[]}this.trackElements_=[];Object.defineProperty(this,"length",{get:function get(){return this.trackElements_.length}});for(var i=0,length=trackElements.length;i<length;i++){this.addTrackElement_(trackElements[i])}}var _proto=HtmlTrackElementList.prototype;_proto.addTrackElement_=function addTrackElement_(trackElement){var index=this.trackElements_.length;if(!(""+index in this)){Object.defineProperty(this,index,{get:function get(){return this.trackElements_[index]}})}if(this.trackElements_.indexOf(trackElement)===-1){this.trackElements_.push(trackElement)}};_proto.getTrackElementByTrack_=function getTrackElementByTrack_(track){var trackElement_;for(var i=0,length=this.trackElements_.length;i<length;i++){if(track===this.trackElements_[i].track){trackElement_=this.trackElements_[i];break}}return trackElement_};_proto.removeTrackElement_=function removeTrackElement_(trackElement){for(var i=0,length=this.trackElements_.length;i<length;i++){if(trackElement===this.trackElements_[i]){if(this.trackElements_[i].track&&typeof this.trackElements_[i].track.off==="function"){this.trackElements_[i].track.off()}if(typeof this.trackElements_[i].off==="function"){this.trackElements_[i].off()}this.trackElements_.splice(i,1);break}}};return HtmlTrackElementList}();var TextTrackCueList=function(){function TextTrackCueList(cues){TextTrackCueList.prototype.setCues_.call(this,cues);Object.defineProperty(this,"length",{get:function get(){return this.length_}})}var _proto=TextTrackCueList.prototype;_proto.setCues_=function setCues_(cues){var oldLength=this.length||0;var i=0;var l=cues.length;this.cues_=cues;this.length_=cues.length;var defineProp=function defineProp(index){if(!(""+index in this)){Object.defineProperty(this,""+index,{get:function get(){return this.cues_[index]}})}};if(oldLength<l){i=oldLength;for(;i<l;i++){defineProp.call(this,i)}}};_proto.getCueById=function getCueById(id){var result=null;for(var i=0,l=this.length;i<l;i++){var cue=this[i];if(cue.id===id){result=cue;break}}return result};return TextTrackCueList}();var VideoTrackKind={alternative:"alternative",captions:"captions",main:"main",sign:"sign",subtitles:"subtitles",commentary:"commentary"};var AudioTrackKind={alternative:"alternative",descriptions:"descriptions",main:"main","main-desc":"main-desc",translation:"translation",commentary:"commentary"};var TextTrackKind={subtitles:"subtitles",captions:"captions",descriptions:"descriptions",chapters:"chapters",metadata:"metadata"};var TextTrackMode={disabled:"disabled",hidden:"hidden",showing:"showing"};var Track=function(_EventTarget){_inheritsLoose(Track,_EventTarget);function Track(options){var _this;if(options===void 0){options={}}_this=_EventTarget.call(this)||this;var trackProps={id:options.id||"vjs_track_"+newGUID(),kind:options.kind||"",label:options.label||"",language:options.language||""};var _loop=function _loop(key){Object.defineProperty(_assertThisInitialized(_this),key,{get:function get(){return trackProps[key]},set:function set(){}})};for(var key in trackProps){_loop(key)}return _this}return Track}(EventTarget);var parseUrl=function parseUrl(url){var props=["protocol","hostname","port","pathname","search","hash","host"];var a=document.createElement("a");a.href=url;var addToBody=a.host===""&&a.protocol!=="file:";var div;if(addToBody){div=document.createElement("div");div.innerHTML='<a href="'+url+'"></a>';a=div.firstChild;div.setAttribute("style","display:none; position:absolute;");document.body.appendChild(div)}var details={};for(var i=0;i<props.length;i++){details[props[i]]=a[props[i]]}if(details.protocol==="http:"){details.host=details.host.replace(/:80$/,"")}if(details.protocol==="https:"){details.host=details.host.replace(/:443$/,"")}if(!details.protocol){details.protocol=window$1.location.protocol}if(addToBody){document.body.removeChild(div)}return details};var getAbsoluteURL=function getAbsoluteURL(url){if(!url.match(/^https?:\/\//)){var div=document.createElement("div");div.innerHTML='<a href="'+url+'">x</a>';url=div.firstChild.href}return url};var getFileExtension=function getFileExtension(path){if(typeof path==="string"){var splitPathRe=/^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/;var pathParts=splitPathRe.exec(path);if(pathParts){return pathParts.pop().toLowerCase()}}return""};var isCrossOrigin=function isCrossOrigin(url){var winLoc=window$1.location;var urlInfo=parseUrl(url);var srcProtocol=urlInfo.protocol===":"?winLoc.protocol:urlInfo.protocol;var crossOrigin=srcProtocol+urlInfo.host!==winLoc.protocol+winLoc.host;return crossOrigin};var Url=Object.freeze({parseUrl:parseUrl,getAbsoluteURL:getAbsoluteURL,getFileExtension:getFileExtension,isCrossOrigin:isCrossOrigin});var isFunction_1=isFunction;var toString$1=Object.prototype.toString;function isFunction(fn){var string=toString$1.call(fn);return string==="[object Function]"||typeof fn==="function"&&string!=="[object RegExp]"||typeof window!=="undefined"&&(fn===window.setTimeout||fn===window.alert||fn===window.confirm||fn===window.prompt)}var ERROR_MESSAGE="Function.prototype.bind called on incompatible ";var slice=Array.prototype.slice;var toStr=Object.prototype.toString;var funcType="[object Function]";var implementation=function bind(that){var target=this;if(typeof target!=="function"||toStr.call(target)!==funcType){throw new TypeError(ERROR_MESSAGE+target)}var args=slice.call(arguments,1);var bound;var binder=function binder(){if(this instanceof bound){var result=target.apply(this,args.concat(slice.call(arguments)));if(Object(result)===result){return result}return this}else{return target.apply(that,args.concat(slice.call(arguments)))}};var boundLength=Math.max(0,target.length-args.length);var boundArgs=[];for(var i=0;i<boundLength;i++){boundArgs.push("$"+i)}bound=Function("binder","return function ("+boundArgs.join(",")+"){ return binder.apply(this,arguments); }")(binder);if(target.prototype){var Empty=function Empty(){};Empty.prototype=target.prototype;bound.prototype=new Empty;Empty.prototype=null}return bound};var functionBind=Function.prototype.bind||implementation;var toStr$1=Object.prototype.toString;var isArguments=function isArguments(value){var str=toStr$1.call(value);var isArgs=str==="[object Arguments]";if(!isArgs){isArgs=str!=="[object Array]"&&value!==null&&typeof value==="object"&&typeof value.length==="number"&&value.length>=0&&toStr$1.call(value.callee)==="[object Function]"}return isArgs};var keysShim;if(!Object.keys){var has=Object.prototype.hasOwnProperty;var toStr$2=Object.prototype.toString;var isArgs=isArguments;var isEnumerable=Object.prototype.propertyIsEnumerable;var hasDontEnumBug=!isEnumerable.call({toString:null},"toString");var hasProtoEnumBug=isEnumerable.call(function(){},"prototype");var dontEnums=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"];var equalsConstructorPrototype=function equalsConstructorPrototype(o){var ctor=o.constructor;return ctor&&ctor.prototype===o};var excludedKeys={$applicationCache:true,$console:true,$external:true,$frame:true,$frameElement:true,$frames:true,$innerHeight:true,$innerWidth:true,$onmozfullscreenchange:true,$onmozfullscreenerror:true,$outerHeight:true,$outerWidth:true,$pageXOffset:true,$pageYOffset:true,$parent:true,$scrollLeft:true,$scrollTop:true,$scrollX:true,$scrollY:true,$self:true,$webkitIndexedDB:true,$webkitStorageInfo:true,$window:true};var hasAutomationEqualityBug=function(){if(typeof window==="undefined"){return false}for(var k in window){try{if(!excludedKeys["$"+k]&&has.call(window,k)&&window[k]!==null&&typeof window[k]==="object"){try{equalsConstructorPrototype(window[k])}catch(e){return true}}}catch(e){return true}}return false}();var equalsConstructorPrototypeIfNotBuggy=function equalsConstructorPrototypeIfNotBuggy(o){if(typeof window==="undefined"||!hasAutomationEqualityBug){return equalsConstructorPrototype(o)}try{return equalsConstructorPrototype(o)}catch(e){return false}};keysShim=function keys(object){var isObject=object!==null&&typeof object==="object";var isFunction=toStr$2.call(object)==="[object Function]";var isArguments=isArgs(object);var isString=isObject&&toStr$2.call(object)==="[object String]";var theKeys=[];if(!isObject&&!isFunction&&!isArguments){throw new TypeError("Object.keys called on a non-object")}var skipProto=hasProtoEnumBug&&isFunction;if(isString&&object.length>0&&!has.call(object,0)){for(var i=0;i<object.length;++i){theKeys.push(String(i))}}if(isArguments&&object.length>0){for(var j=0;j<object.length;++j){theKeys.push(String(j))}}else{for(var name in object){if(!(skipProto&&name==="prototype")&&has.call(object,name)){theKeys.push(String(name))}}}if(hasDontEnumBug){var skipConstructor=equalsConstructorPrototypeIfNotBuggy(object);for(var k=0;k<dontEnums.length;++k){if(!(skipConstructor&&dontEnums[k]==="constructor")&&has.call(object,dontEnums[k])){theKeys.push(dontEnums[k])}}}return theKeys}}var implementation$1=keysShim;var slice$1=Array.prototype.slice;var origKeys=Object.keys;var keysShim$1=origKeys?function keys(o){return origKeys(o)}:implementation$1;var originalKeys=Object.keys;keysShim$1.shim=function shimObjectKeys(){if(Object.keys){var keysWorksWithArguments=function(){var args=Object.keys(arguments);return args&&args.length===arguments.length}(1,2);if(!keysWorksWithArguments){Object.keys=function keys(object){if(isArguments(object)){return originalKeys(slice$1.call(object))}return originalKeys(object)}}}else{Object.keys=keysShim$1}return Object.keys||keysShim$1};var objectKeys=keysShim$1;var hasSymbols=typeof Symbol==="function"&&typeof Symbol("foo")==="symbol";var toStr$3=Object.prototype.toString;var concat=Array.prototype.concat;var origDefineProperty=Object.defineProperty;var isFunction$1=function isFunction(fn){return typeof fn==="function"&&toStr$3.call(fn)==="[object Function]"};var arePropertyDescriptorsSupported=function arePropertyDescriptorsSupported(){var obj={};try{origDefineProperty(obj,"x",{enumerable:false,value:obj});for(var _ in obj){return false}return obj.x===obj}catch(e){return false}};var supportsDescriptors=origDefineProperty&&arePropertyDescriptorsSupported();var defineProperty=function defineProperty(object,name,value,predicate){if(name in object&&(!isFunction$1(predicate)||!predicate())){return}if(supportsDescriptors){origDefineProperty(object,name,{configurable:true,enumerable:false,value:value,writable:true})}else{object[name]=value}};var defineProperties=function defineProperties(object,map){var predicates=arguments.length>2?arguments[2]:{};var props=objectKeys(map);if(hasSymbols){props=concat.call(props,Object.getOwnPropertySymbols(map))}for(var i=0;i<props.length;i+=1){defineProperty(object,props[i],map[props[i]],predicates[props[i]])}};defineProperties.supportsDescriptors=!!supportsDescriptors;var defineProperties_1=defineProperties;var undefined$1;var ThrowTypeError=Object.getOwnPropertyDescriptor?function(){return Object.getOwnPropertyDescriptor(arguments,"callee").get}():function(){throw new TypeError};var hasSymbols$1=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol";var getProto=Object.getPrototypeOf||function(x){return x.__proto__};var generatorFunction=undefined$1;var asyncFunction=undefined$1;var asyncGenFunction=undefined$1;var TypedArray=typeof Uint8Array==="undefined"?undefined$1:getProto(Uint8Array);var INTRINSICS={"$ %Array%":Array,"$ %ArrayBuffer%":typeof ArrayBuffer==="undefined"?undefined$1:ArrayBuffer,"$ %ArrayBufferPrototype%":typeof ArrayBuffer==="undefined"?undefined$1:ArrayBuffer.prototype,"$ %ArrayIteratorPrototype%":hasSymbols$1?getProto([][Symbol.iterator]()):undefined$1,"$ %ArrayPrototype%":Array.prototype,"$ %ArrayProto_entries%":Array.prototype.entries,"$ %ArrayProto_forEach%":Array.prototype.forEach,"$ %ArrayProto_keys%":Array.prototype.keys,"$ %ArrayProto_values%":Array.prototype.values,"$ %AsyncFromSyncIteratorPrototype%":undefined$1,"$ %AsyncFunction%":asyncFunction,"$ %AsyncFunctionPrototype%":undefined$1,"$ %AsyncGenerator%":undefined$1,"$ %AsyncGeneratorFunction%":asyncGenFunction,"$ %AsyncGeneratorPrototype%":undefined$1,"$ %AsyncIteratorPrototype%":undefined$1,"$ %Atomics%":typeof Atomics==="undefined"?undefined$1:Atomics,"$ %Boolean%":Boolean,"$ %BooleanPrototype%":Boolean.prototype,"$ %DataView%":typeof DataView==="undefined"?undefined$1:DataView,"$ %DataViewPrototype%":typeof DataView==="undefined"?undefined$1:DataView.prototype,"$ %Date%":Date,"$ %DatePrototype%":Date.prototype,"$ %decodeURI%":decodeURI,"$ %decodeURIComponent%":decodeURIComponent,"$ %encodeURI%":encodeURI,"$ %encodeURIComponent%":encodeURIComponent,"$ %Error%":Error,"$ %ErrorPrototype%":Error.prototype,"$ %eval%":eval,"$ %EvalError%":EvalError,"$ %EvalErrorPrototype%":EvalError.prototype,"$ %Float32Array%":typeof Float32Array==="undefined"?undefined$1:Float32Array,"$ %Float32ArrayPrototype%":typeof Float32Array==="undefined"?undefined$1:Float32Array.prototype,"$ %Float64Array%":typeof Float64Array==="undefined"?undefined$1:Float64Array,"$ %Float64ArrayPrototype%":typeof Float64Array==="undefined"?undefined$1:Float64Array.prototype,"$ %Function%":Function,"$ %FunctionPrototype%":Function.prototype,"$ %Generator%":undefined$1,"$ %GeneratorFunction%":generatorFunction,"$ %GeneratorPrototype%":undefined$1,"$ %Int8Array%":typeof Int8Array==="undefined"?undefined$1:Int8Array,"$ %Int8ArrayPrototype%":typeof Int8Array==="undefined"?undefined$1:Int8Array.prototype,"$ %Int16Array%":typeof Int16Array==="undefined"?undefined$1:Int16Array,"$ %Int16ArrayPrototype%":typeof Int16Array==="undefined"?undefined$1:Int8Array.prototype,"$ %Int32Array%":typeof Int32Array==="undefined"?undefined$1:Int32Array,"$ %Int32ArrayPrototype%":typeof Int32Array==="undefined"?undefined$1:Int32Array.prototype,"$ %isFinite%":isFinite,"$ %isNaN%":isNaN,"$ %IteratorPrototype%":hasSymbols$1?getProto(getProto([][Symbol.iterator]())):undefined$1,"$ %JSON%":JSON,"$ %JSONParse%":JSON.parse,"$ %Map%":typeof Map==="undefined"?undefined$1:Map,"$ %MapIteratorPrototype%":typeof Map==="undefined"||!hasSymbols$1?undefined$1:getProto((new Map)[Symbol.iterator]()),"$ %MapPrototype%":typeof Map==="undefined"?undefined$1:Map.prototype,"$ %Math%":Math,"$ %Number%":Number,"$ %NumberPrototype%":Number.prototype,"$ %Object%":Object,"$ %ObjectPrototype%":Object.prototype,"$ %ObjProto_toString%":Object.prototype.toString,"$ %ObjProto_valueOf%":Object.prototype.valueOf,"$ %parseFloat%":parseFloat,"$ %parseInt%":parseInt,"$ %Promise%":typeof Promise==="undefined"?undefined$1:Promise,"$ %PromisePrototype%":typeof Promise==="undefined"?undefined$1:Promise.prototype,"$ %PromiseProto_then%":typeof Promise==="undefined"?undefined$1:Promise.prototype.then,"$ %Promise_all%":typeof Promise==="undefined"?undefined$1:Promise.all,"$ %Promise_reject%":typeof Promise==="undefined"?undefined$1:Promise.reject,"$ %Promise_resolve%":typeof Promise==="undefined"?undefined$1:Promise.resolve,"$ %Proxy%":typeof Proxy==="undefined"?undefined$1:Proxy,"$ %RangeError%":RangeError,"$ %RangeErrorPrototype%":RangeError.prototype,"$ %ReferenceError%":ReferenceError,"$ %ReferenceErrorPrototype%":ReferenceError.prototype,"$ %Reflect%":typeof Reflect==="undefined"?undefined$1:Reflect,"$ %RegExp%":RegExp,"$ %RegExpPrototype%":RegExp.prototype,"$ %Set%":typeof Set==="undefined"?undefined$1:Set,"$ %SetIteratorPrototype%":typeof Set==="undefined"||!hasSymbols$1?undefined$1:getProto((new Set)[Symbol.iterator]()),"$ %SetPrototype%":typeof Set==="undefined"?undefined$1:Set.prototype,"$ %SharedArrayBuffer%":typeof SharedArrayBuffer==="undefined"?undefined$1:SharedArrayBuffer,"$ %SharedArrayBufferPrototype%":typeof SharedArrayBuffer==="undefined"?undefined$1:SharedArrayBuffer.prototype,"$ %String%":String,"$ %StringIteratorPrototype%":hasSymbols$1?getProto(""[Symbol.iterator]()):undefined$1,"$ %StringPrototype%":String.prototype,"$ %Symbol%":hasSymbols$1?Symbol:undefined$1,"$ %SymbolPrototype%":hasSymbols$1?Symbol.prototype:undefined$1,"$ %SyntaxError%":SyntaxError,"$ %SyntaxErrorPrototype%":SyntaxError.prototype,"$ %ThrowTypeError%":ThrowTypeError,"$ %TypedArray%":TypedArray,"$ %TypedArrayPrototype%":TypedArray?TypedArray.prototype:undefined$1,"$ %TypeError%":TypeError,"$ %TypeErrorPrototype%":TypeError.prototype,"$ %Uint8Array%":typeof Uint8Array==="undefined"?undefined$1:Uint8Array,"$ %Uint8ArrayPrototype%":typeof Uint8Array==="undefined"?undefined$1:Uint8Array.prototype,"$ %Uint8ClampedArray%":typeof Uint8ClampedArray==="undefined"?undefined$1:Uint8ClampedArray,"$ %Uint8ClampedArrayPrototype%":typeof Uint8ClampedArray==="undefined"?undefined$1:Uint8ClampedArray.prototype,"$ %Uint16Array%":typeof Uint16Array==="undefined"?undefined$1:Uint16Array,"$ %Uint16ArrayPrototype%":typeof Uint16Array==="undefined"?undefined$1:Uint16Array.prototype,"$ %Uint32Array%":typeof Uint32Array==="undefined"?undefined$1:Uint32Array,"$ %Uint32ArrayPrototype%":typeof Uint32Array==="undefined"?undefined$1:Uint32Array.prototype,"$ %URIError%":URIError,"$ %URIErrorPrototype%":URIError.prototype,"$ %WeakMap%":typeof WeakMap==="undefined"?undefined$1:WeakMap,"$ %WeakMapPrototype%":typeof WeakMap==="undefined"?undefined$1:WeakMap.prototype,"$ %WeakSet%":typeof WeakSet==="undefined"?undefined$1:WeakSet,"$ %WeakSetPrototype%":typeof WeakSet==="undefined"?undefined$1:WeakSet.prototype};var GetIntrinsic=function GetIntrinsic(name,allowMissing){if(arguments.length>1&&typeof allowMissing!=="boolean"){throw new TypeError('"allowMissing" argument must be a boolean')}var key="$ "+name;if(!(key in INTRINSICS)){throw new SyntaxError("intrinsic "+name+" does not exist!")}if(typeof INTRINSICS[key]==="undefined"&&!allowMissing){throw new TypeError("intrinsic "+name+" exists, but is not available. Please file an issue!")}return INTRINSICS[key]};var src=functionBind.call(Function.call,Object.prototype.hasOwnProperty);var $TypeError=GetIntrinsic("%TypeError%");var $SyntaxError=GetIntrinsic("%SyntaxError%");var predicates={"Property Descriptor":function isPropertyDescriptor(ES,Desc){if(ES.Type(Desc)!=="Object"){return false}var allowed={"[[Configurable]]":true,"[[Enumerable]]":true,"[[Get]]":true,"[[Set]]":true,"[[Value]]":true,"[[Writable]]":true};for(var key in Desc){if(src(Desc,key)&&!allowed[key]){return false}}var isData=src(Desc,"[[Value]]");var IsAccessor=src(Desc,"[[Get]]")||src(Desc,"[[Set]]");if(isData&&IsAccessor){throw new $TypeError("Property Descriptors may not be both accessor and data descriptors")}return true}};var assertRecord=function assertRecord(ES,recordType,argumentName,value){var predicate=predicates[recordType];if(typeof predicate!=="function"){throw new $SyntaxError("unknown record type: "+recordType)}if(!predicate(ES,value)){throw new $TypeError(argumentName+" must be a "+recordType)}console.log(predicate(ES,value),value)};var _isNaN=Number.isNaN||function isNaN(a){return a!==a};var $isNaN=Number.isNaN||function(a){return a!==a};var _isFinite=Number.isFinite||function(x){return typeof x==="number"&&!$isNaN(x)&&x!==Infinity&&x!==-Infinity};var sign=function sign(number){return number>=0?1:-1};var mod=function mod(number,modulo){var remain=number%modulo;return Math.floor(remain>=0?remain:remain+modulo)};var fnToStr=Function.prototype.toString;var constructorRegex=/^\s*class\b/;var isES6ClassFn=function isES6ClassFunction(value){try{var fnStr=fnToStr.call(value);return constructorRegex.test(fnStr)}catch(e){return false}};var tryFunctionObject=function tryFunctionToStr(value){try{if(isES6ClassFn(value)){return false}fnToStr.call(value);return true}catch(e){return false}};var toStr$4=Object.prototype.toString;var fnClass="[object Function]";var genClass="[object GeneratorFunction]";var hasToStringTag=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var isCallable=function isCallable(value){if(!value){return false}if(typeof value!=="function"&&typeof value!=="object"){return false}if(typeof value==="function"&&!value.prototype){return true}if(hasToStringTag){return tryFunctionObject(value)}if(isES6ClassFn(value)){return false}var strClass=toStr$4.call(value);return strClass===fnClass||strClass===genClass};var isPrimitive=function isPrimitive(value){return value===null||typeof value!=="function"&&typeof value!=="object"};var toStr$5=Object.prototype.toString;var ES5internalSlots={"[[DefaultValue]]":function DefaultValue(O){var actualHint;if(arguments.length>1){actualHint=arguments[1]}else{actualHint=toStr$5.call(O)==="[object Date]"?String:Number}if(actualHint===String||actualHint===Number){var methods=actualHint===String?["toString","valueOf"]:["valueOf","toString"];var value,i;for(i=0;i<methods.length;++i){if(isCallable(O[methods[i]])){value=O[methods[i]]();if(isPrimitive(value)){return value}}}throw new TypeError("No default value")}throw new TypeError("invalid [[DefaultValue]] hint supplied")}};var es5=function ToPrimitive(input){if(isPrimitive(input)){return input}if(arguments.length>1){return ES5internalSlots["[[DefaultValue]]"](input,arguments[1])}return ES5internalSlots["[[DefaultValue]]"](input)};var $Object=GetIntrinsic("%Object%");var $TypeError$1=GetIntrinsic("%TypeError%");var $String=GetIntrinsic("%String%");var ES5={ToPrimitive:es5,ToBoolean:function ToBoolean(value){return!!value},ToNumber:function ToNumber(value){return+value},ToInteger:function ToInteger(value){var number=this.ToNumber(value);if(_isNaN(number)){return 0}if(number===0||!_isFinite(number)){return number}return sign(number)*Math.floor(Math.abs(number))},ToInt32:function ToInt32(x){return this.ToNumber(x)>>0},ToUint32:function ToUint32(x){return this.ToNumber(x)>>>0},ToUint16:function ToUint16(value){var number=this.ToNumber(value);if(_isNaN(number)||number===0||!_isFinite(number)){return 0}var posInt=sign(number)*Math.floor(Math.abs(number));return mod(posInt,65536)},ToString:function ToString(value){return $String(value)},ToObject:function ToObject(value){this.CheckObjectCoercible(value);return $Object(value)},CheckObjectCoercible:function CheckObjectCoercible(value,optMessage){if(value==null){throw new $TypeError$1(optMessage||"Cannot call method on "+value)}return value},IsCallable:isCallable,SameValue:function SameValue(x,y){if(x===y){if(x===0){return 1/x===1/y}return true}return _isNaN(x)&&_isNaN(y)},Type:function Type(x){if(x===null){return"Null"}if(typeof x==="undefined"){return"Undefined"}if(typeof x==="function"||typeof x==="object"){return"Object"}if(typeof x==="number"){return"Number"}if(typeof x==="boolean"){return"Boolean"}if(typeof x==="string"){return"String"}},IsPropertyDescriptor:function IsPropertyDescriptor(Desc){if(this.Type(Desc)!=="Object"){return false}var allowed={"[[Configurable]]":true,"[[Enumerable]]":true,"[[Get]]":true,"[[Set]]":true,"[[Value]]":true,"[[Writable]]":true};for(var key in Desc){if(src(Desc,key)&&!allowed[key]){return false}}var isData=src(Desc,"[[Value]]");var IsAccessor=src(Desc,"[[Get]]")||src(Desc,"[[Set]]");if(isData&&IsAccessor){throw new $TypeError$1("Property Descriptors may not be both accessor and data descriptors")}return true},IsAccessorDescriptor:function IsAccessorDescriptor(Desc){if(typeof Desc==="undefined"){return false}assertRecord(this,"Property Descriptor","Desc",Desc);if(!src(Desc,"[[Get]]")&&!src(Desc,"[[Set]]")){return false}return true},IsDataDescriptor:function IsDataDescriptor(Desc){if(typeof Desc==="undefined"){return false}assertRecord(this,"Property Descriptor","Desc",Desc);if(!src(Desc,"[[Value]]")&&!src(Desc,"[[Writable]]")){return false}return true},IsGenericDescriptor:function IsGenericDescriptor(Desc){if(typeof Desc==="undefined"){return false}assertRecord(this,"Property Descriptor","Desc",Desc);if(!this.IsAccessorDescriptor(Desc)&&!this.IsDataDescriptor(Desc)){return true}return false},FromPropertyDescriptor:function FromPropertyDescriptor(Desc){if(typeof Desc==="undefined"){return Desc}assertRecord(this,"Property Descriptor","Desc",Desc);if(this.IsDataDescriptor(Desc)){return{value:Desc["[[Value]]"],writable:!!Desc["[[Writable]]"],enumerable:!!Desc["[[Enumerable]]"],configurable:!!Desc["[[Configurable]]"]}}else if(this.IsAccessorDescriptor(Desc)){return{get:Desc["[[Get]]"],set:Desc["[[Set]]"],enumerable:!!Desc["[[Enumerable]]"],configurable:!!Desc["[[Configurable]]"]}}else{throw new $TypeError$1("FromPropertyDescriptor must be called with a fully populated Property Descriptor")}},ToPropertyDescriptor:function ToPropertyDescriptor(Obj){if(this.Type(Obj)!=="Object"){throw new $TypeError$1("ToPropertyDescriptor requires an object")}var desc={};if(src(Obj,"enumerable")){desc["[[Enumerable]]"]=this.ToBoolean(Obj.enumerable)}if(src(Obj,"configurable")){desc["[[Configurable]]"]=this.ToBoolean(Obj.configurable)}if(src(Obj,"value")){desc["[[Value]]"]=Obj.value}if(src(Obj,"writable")){desc["[[Writable]]"]=this.ToBoolean(Obj.writable)}if(src(Obj,"get")){var getter=Obj.get;if(typeof getter!=="undefined"&&!this.IsCallable(getter)){throw new TypeError("getter must be a function")}desc["[[Get]]"]=getter}if(src(Obj,"set")){var setter=Obj.set;if(typeof setter!=="undefined"&&!this.IsCallable(setter)){throw new $TypeError$1("setter must be a function")}desc["[[Set]]"]=setter}if((src(desc,"[[Get]]")||src(desc,"[[Set]]"))&&(src(desc,"[[Value]]")||src(desc,"[[Writable]]"))){throw new $TypeError$1("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute")}return desc}};var es5$1=ES5;var replace=functionBind.call(Function.call,String.prototype.replace);var leftWhitespace=/^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/;var rightWhitespace=/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/;var implementation$2=function trim(){var S=es5$1.ToString(es5$1.CheckObjectCoercible(this));return replace(replace(S,leftWhitespace,""),rightWhitespace,"")};var zeroWidthSpace="";var polyfill=function getPolyfill(){if(String.prototype.trim&&zeroWidthSpace.trim()===zeroWidthSpace){return String.prototype.trim}return implementation$2};var shim=function shimStringTrim(){var polyfill$1=polyfill();defineProperties_1(String.prototype,{trim:polyfill$1},{trim:function testTrim(){return String.prototype.trim!==polyfill$1}});return polyfill$1};var boundTrim=functionBind.call(Function.call,polyfill());defineProperties_1(boundTrim,{getPolyfill:polyfill,implementation:implementation$2,shim:shim});var string_prototype_trim=boundTrim;var toStr$6=Object.prototype.toString;var hasOwnProperty=Object.prototype.hasOwnProperty;var forEachArray=function forEachArray(array,iterator,receiver){for(var i=0,len=array.length;i<len;i++){if(hasOwnProperty.call(array,i)){if(receiver==null){iterator(array[i],i,array)}else{iterator.call(receiver,array[i],i,array)}}}};var forEachString=function forEachString(string,iterator,receiver){for(var i=0,len=string.length;i<len;i++){if(receiver==null){iterator(string.charAt(i),i,string)}else{iterator.call(receiver,string.charAt(i),i,string)}}};var forEachObject=function forEachObject(object,iterator,receiver){for(var k in object){if(hasOwnProperty.call(object,k)){if(receiver==null){iterator(object[k],k,object)}else{iterator.call(receiver,object[k],k,object)}}}};var forEach=function forEach(list,iterator,thisArg){if(!isCallable(iterator)){throw new TypeError("iterator must be a function")}var receiver;if(arguments.length>=3){receiver=thisArg}if(toStr$6.call(list)==="[object Array]"){forEachArray(list,iterator,receiver)}else if(typeof list==="string"){forEachString(list,iterator,receiver)}else{forEachObject(list,iterator,receiver)}};var forEach_1=forEach;var isArray=function isArray(arg){return Object.prototype.toString.call(arg)==="[object Array]"};var parseHeaders=function parseHeaders(headers){if(!headers)return{};var result={};forEach_1(string_prototype_trim(headers).split("\n"),function(row){var index=row.indexOf(":"),key=string_prototype_trim(row.slice(0,index)).toLowerCase(),value=string_prototype_trim(row.slice(index+1));if(typeof result[key]==="undefined"){result[key]=value}else if(isArray(result[key])){result[key].push(value)}else{result[key]=[result[key],value]}});return result};var immutable=extend;var hasOwnProperty$1=Object.prototype.hasOwnProperty;function extend(){var target={};for(var i=0;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(hasOwnProperty$1.call(source,key)){target[key]=source[key]}}}return target}var xhr=createXHR;createXHR.XMLHttpRequest=window$1.XMLHttpRequest||noop;createXHR.XDomainRequest="withCredentials"in new createXHR.XMLHttpRequest?createXHR.XMLHttpRequest:window$1.XDomainRequest;forEachArray$1(["get","put","post","patch","head","delete"],function(method){createXHR[method==="delete"?"del":method]=function(uri,options,callback){options=initParams(uri,options,callback);options.method=method.toUpperCase();return _createXHR(options)}});function forEachArray$1(array,iterator){for(var i=0;i<array.length;i++){iterator(array[i])}}function isEmpty(obj){for(var i in obj){if(obj.hasOwnProperty(i))return false}return true}function initParams(uri,options,callback){var params=uri;if(isFunction_1(options)){callback=options;if(typeof uri==="string"){params={uri:uri}}}else{params=immutable(options,{uri:uri})}params.callback=callback;return params}function createXHR(uri,options,callback){options=initParams(uri,options,callback);return _createXHR(options)}function _createXHR(options){if(typeof options.callback==="undefined"){throw new Error("callback argument missing")}var called=false;var callback=function cbOnce(err,response,body){if(!called){called=true;options.callback(err,response,body)}};function readystatechange(){if(xhr.readyState===4){setTimeout(loadFunc,0)}}function getBody(){var body=undefined;if(xhr.response){body=xhr.response}else{body=xhr.responseText||getXml(xhr)}if(isJson){try{body=JSON.parse(body)}catch(e){}}return body}function errorFunc(evt){clearTimeout(timeoutTimer);if(!(evt instanceof Error)){evt=new Error(""+(evt||"Unknown XMLHttpRequest Error"))}evt.statusCode=0;return callback(evt,failureResponse)}function loadFunc(){if(aborted)return;var status;clearTimeout(timeoutTimer);if(options.useXDR&&xhr.status===undefined){status=200}else{status=xhr.status===1223?204:xhr.status}var response=failureResponse;var err=null;if(status!==0){response={body:getBody(),statusCode:status,method:method,headers:{},url:uri,rawRequest:xhr};if(xhr.getAllResponseHeaders){response.headers=parseHeaders(xhr.getAllResponseHeaders())}}else{err=new Error("Internal XMLHttpRequest Error")}return callback(err,response,response.body)}var xhr=options.xhr||null;if(!xhr){if(options.cors||options.useXDR){xhr=new createXHR.XDomainRequest}else{xhr=new createXHR.XMLHttpRequest}}var key;var aborted;var uri=xhr.url=options.uri||options.url;var method=xhr.method=options.method||"GET";var body=options.body||options.data;var headers=xhr.headers=options.headers||{};var sync=!!options.sync;var isJson=false;var timeoutTimer;var failureResponse={body:undefined,headers:{},statusCode:0,method:method,url:uri,rawRequest:xhr};if("json"in options&&options.json!==false){isJson=true;headers["accept"]||headers["Accept"]||(headers["Accept"]="application/json");if(method!=="GET"&&method!=="HEAD"){headers["content-type"]||headers["Content-Type"]||(headers["Content-Type"]="application/json");body=JSON.stringify(options.json===true?body:options.json)}}xhr.onreadystatechange=readystatechange;xhr.onload=loadFunc;xhr.onerror=errorFunc;xhr.onprogress=function(){};xhr.onabort=function(){aborted=true};xhr.ontimeout=errorFunc;xhr.open(method,uri,!sync,options.username,options.password);if(!sync){xhr.withCredentials=!!options.withCredentials}if(!sync&&options.timeout>0){timeoutTimer=setTimeout(function(){if(aborted)return;aborted=true;xhr.abort("timeout");var e=new Error("XMLHttpRequest timeout");e.code="ETIMEDOUT";errorFunc(e)},options.timeout)}if(xhr.setRequestHeader){for(key in headers){if(headers.hasOwnProperty(key)){xhr.setRequestHeader(key,headers[key])}}}else if(options.headers&&!isEmpty(options.headers)){throw new Error("Headers cannot be set on an XDomainRequest object")}if("responseType"in options){xhr.responseType=options.responseType}if("beforeSend"in options&&typeof options.beforeSend==="function"){options.beforeSend(xhr)}xhr.send(body||null);return xhr}function getXml(xhr){if(xhr.responseType==="document"){return xhr.responseXML}var firefoxBugTakenEffect=xhr.responseXML&&xhr.responseXML.documentElement.nodeName==="parsererror";if(xhr.responseType===""&&!firefoxBugTakenEffect){return xhr.responseXML}return null}function noop(){}var parseCues=function parseCues(srcContent,track){var parser=new window$1.WebVTT.Parser(window$1,window$1.vttjs,window$1.WebVTT.StringDecoder());var errors=[];parser.oncue=function(cue){track.addCue(cue)};parser.onparsingerror=function(error){errors.push(error)};parser.onflush=function(){track.trigger({type:"loadeddata",target:track})};parser.parse(srcContent);if(errors.length>0){if(window$1.console&&window$1.console.groupCollapsed){window$1.console.groupCollapsed("Text Track parsing errors for "+track.src)}errors.forEach(function(error){return log.error(error)});if(window$1.console&&window$1.console.groupEnd){window$1.console.groupEnd()}}parser.flush()};var loadTrack=function loadTrack(src,track){var opts={uri:src};var crossOrigin=isCrossOrigin(src);if(crossOrigin){opts.cors=crossOrigin}xhr(opts,bind(this,function(err,response,responseBody){if(err){return log.error(err,response)}track.loaded_=true;if(typeof window$1.WebVTT!=="function"){if(track.tech_){track.tech_.any(["vttjsloaded","vttjserror"],function(event){if(event.type==="vttjserror"){log.error("vttjs failed to load, stopping trying to process "+track.src);return}return parseCues(responseBody,track)})}}else{parseCues(responseBody,track)}}))};var TextTrack=function(_Track){_inheritsLoose(TextTrack,_Track);function TextTrack(options){var _this;if(options===void 0){options={}}if(!options.tech){throw new Error("A tech was not provided.")}var settings=mergeOptions(options,{kind:TextTrackKind[options.kind]||"subtitles",language:options.language||options.srclang||""});var mode=TextTrackMode[settings.mode]||"disabled";var default_=settings["default"];if(settings.kind==="metadata"||settings.kind==="chapters"){mode="hidden"}_this=_Track.call(this,settings)||this;_this.tech_=settings.tech;_this.cues_=[];_this.activeCues_=[];var cues=new TextTrackCueList(_this.cues_);var activeCues=new TextTrackCueList(_this.activeCues_);var changed=false;var timeupdateHandler=bind(_assertThisInitialized(_this),function(){this.activeCues=this.activeCues;if(changed){this.trigger("cuechange");changed=false}});if(mode!=="disabled"){_this.tech_.ready(function(){_this.tech_.on("timeupdate",timeupdateHandler)},true)}Object.defineProperties(_assertThisInitialized(_this),{default:{get:function get(){return default_},set:function set(){}},mode:{get:function get(){return mode},set:function set(newMode){var _this2=this;if(!TextTrackMode[newMode]){return}mode=newMode;if(mode!=="disabled"){this.tech_.ready(function(){_this2.tech_.on("timeupdate",timeupdateHandler)},true)}else{this.tech_.off("timeupdate",timeupdateHandler)}this.trigger("modechange")}},cues:{get:function get(){if(!this.loaded_){return null}return cues},set:function set(){}},activeCues:{get:function get(){if(!this.loaded_){return null}if(this.cues.length===0){return activeCues}var ct=this.tech_.currentTime();var active=[];for(var i=0,l=this.cues.length;i<l;i++){var cue=this.cues[i];if(cue.startTime<=ct&&cue.endTime>=ct){active.push(cue)}else if(cue.startTime===cue.endTime&&cue.startTime<=ct&&cue.startTime+.5>=ct){active.push(cue)}}changed=false;if(active.length!==this.activeCues_.length){changed=true}else{for(var _i=0;_i<active.length;_i++){if(this.activeCues_.indexOf(active[_i])===-1){changed=true}}}this.activeCues_=active;activeCues.setCues_(this.activeCues_);return activeCues},set:function set(){}}});if(settings.src){_this.src=settings.src;loadTrack(settings.src,_assertThisInitialized(_this))}else{_this.loaded_=true}return _this}var _proto=TextTrack.prototype;_proto.addCue=function addCue(originalCue){var cue=originalCue;if(window$1.vttjs&&!(originalCue instanceof window$1.vttjs.VTTCue)){cue=new window$1.vttjs.VTTCue(originalCue.startTime,originalCue.endTime,originalCue.text);for(var prop in originalCue){if(!(prop in cue)){cue[prop]=originalCue[prop]}}cue.id=originalCue.id;cue.originalCue_=originalCue}var tracks=this.tech_.textTracks();for(var i=0;i<tracks.length;i++){if(tracks[i]!==this){tracks[i].removeCue(cue)}}this.cues_.push(cue);this.cues.setCues_(this.cues_)};_proto.removeCue=function removeCue(_removeCue){var i=this.cues_.length;while(i--){var cue=this.cues_[i];if(cue===_removeCue||cue.originalCue_&&cue.originalCue_===_removeCue){this.cues_.splice(i,1);this.cues.setCues_(this.cues_);break}}};return TextTrack}(Track);TextTrack.prototype.allowedEvents_={cuechange:"cuechange"};var AudioTrack=function(_Track){_inheritsLoose(AudioTrack,_Track);function AudioTrack(options){var _this;if(options===void 0){options={}}var settings=mergeOptions(options,{kind:AudioTrackKind[options.kind]||""});_this=_Track.call(this,settings)||this;var enabled=false;Object.defineProperty(_assertThisInitialized(_this),"enabled",{get:function get(){return enabled},set:function set(newEnabled){if(typeof newEnabled!=="boolean"||newEnabled===enabled){return}enabled=newEnabled;this.trigger("enabledchange")}});if(settings.enabled){_this.enabled=settings.enabled}_this.loaded_=true;return _this}return AudioTrack}(Track);var VideoTrack=function(_Track){_inheritsLoose(VideoTrack,_Track);function VideoTrack(options){var _this;if(options===void 0){options={}}var settings=mergeOptions(options,{kind:VideoTrackKind[options.kind]||""});_this=_Track.call(this,settings)||this;var selected=false;Object.defineProperty(_assertThisInitialized(_this),"selected",{get:function get(){return selected},set:function set(newSelected){if(typeof newSelected!=="boolean"||newSelected===selected){return}selected=newSelected;this.trigger("selectedchange")}});if(settings.selected){_this.selected=settings.selected}return _this}return VideoTrack}(Track);var NONE=0;var LOADING=1;var LOADED=2;var ERROR=3;var HTMLTrackElement=function(_EventTarget){_inheritsLoose(HTMLTrackElement,_EventTarget);function HTMLTrackElement(options){var _this;if(options===void 0){options={}}_this=_EventTarget.call(this)||this;var readyState;var track=new TextTrack(options);_this.kind=track.kind;_this.src=track.src;_this.srclang=track.language;_this.label=track.label;_this["default"]=track["default"];Object.defineProperties(_assertThisInitialized(_this),{readyState:{get:function get(){return readyState}},track:{get:function get(){return track}}});readyState=NONE;track.addEventListener("loadeddata",function(){readyState=LOADED;_this.trigger({type:"load",target:_assertThisInitialized(_this)})});return _this}return HTMLTrackElement}(EventTarget);HTMLTrackElement.prototype.allowedEvents_={load:"load"};HTMLTrackElement.NONE=NONE;HTMLTrackElement.LOADING=LOADING;HTMLTrackElement.LOADED=LOADED;HTMLTrackElement.ERROR=ERROR;var NORMAL={audio:{ListClass:AudioTrackList,TrackClass:AudioTrack,capitalName:"Audio"},video:{ListClass:VideoTrackList,TrackClass:VideoTrack,capitalName:"Video"},text:{ListClass:TextTrackList,TrackClass:TextTrack,capitalName:"Text"}};Object.keys(NORMAL).forEach(function(type){NORMAL[type].getterName=type+"Tracks";NORMAL[type].privateName=type+"Tracks_"});var REMOTE={remoteText:{ListClass:TextTrackList,TrackClass:TextTrack,capitalName:"RemoteText",getterName:"remoteTextTracks",privateName:"remoteTextTracks_"},remoteTextEl:{ListClass:HtmlTrackElementList,TrackClass:HTMLTrackElement,capitalName:"RemoteTextTrackEls",getterName:"remoteTextTrackEls",privateName:"remoteTextTrackEls_"}};var ALL=mergeOptions(NORMAL,REMOTE);REMOTE.names=Object.keys(REMOTE);NORMAL.names=Object.keys(NORMAL);ALL.names=[].concat(REMOTE.names).concat(NORMAL.names);var _objCreate=Object.create||function(){function F(){}return function(o){if(arguments.length!==1){throw new Error("Object.create shim only accepts one parameter.")}F.prototype=o;return new F}}();function ParsingError(errorData,message){this.name="ParsingError";this.code=errorData.code;this.message=message||errorData.message}ParsingError.prototype=_objCreate(Error.prototype);ParsingError.prototype.constructor=ParsingError;ParsingError.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}};function parseTimeStamp(input){function computeSeconds(h,m,s,f){return(h|0)*3600+(m|0)*60+(s|0)+(f|0)/1e3}var m=input.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);if(!m){return null}if(m[3]){return computeSeconds(m[1],m[2],m[3].replace(":",""),m[4])}else if(m[1]>59){return computeSeconds(m[1],m[2],0,m[4])}else{return computeSeconds(0,m[1],m[2],m[4])}}function Settings(){this.values=_objCreate(null)}Settings.prototype={set:function set(k,v){if(!this.get(k)&&v!==""){this.values[k]=v}},get:function get(k,dflt,defaultKey){if(defaultKey){return this.has(k)?this.values[k]:dflt[defaultKey]}return this.has(k)?this.values[k]:dflt},has:function has(k){return k in this.values},alt:function alt(k,v,a){for(var n=0;n<a.length;++n){if(v===a[n]){this.set(k,v);break}}},integer:function integer(k,v){if(/^-?\d+$/.test(v)){this.set(k,parseInt(v,10))}},percent:function percent(k,v){var m;if(m=v.match(/^([\d]{1,3})(\.[\d]*)?%$/)){v=parseFloat(v);if(v>=0&&v<=100){this.set(k,v);return true}}return false}};function parseOptions(input,callback,keyValueDelim,groupDelim){var groups=groupDelim?input.split(groupDelim):[input];for(var i in groups){if(typeof groups[i]!=="string"){continue}var kv=groups[i].split(keyValueDelim);if(kv.length!==2){continue}var k=kv[0];var v=kv[1];callback(k,v)}}function parseCue(input,cue,regionList){var oInput=input;function consumeTimeStamp(){var ts=parseTimeStamp(input);if(ts===null){throw new ParsingError(ParsingError.Errors.BadTimeStamp,"Malformed timestamp: "+oInput)}input=input.replace(/^[^\sa-zA-Z-]+/,"");return ts}function consumeCueSettings(input,cue){var settings=new Settings;parseOptions(input,function(k,v){switch(k){case"region":for(var i=regionList.length-1;i>=0;i--){if(regionList[i].id===v){settings.set(k,regionList[i].region);break}}break;case"vertical":settings.alt(k,v,["rl","lr"]);break;case"line":var vals=v.split(","),vals0=vals[0];settings.integer(k,vals0);settings.percent(k,vals0)?settings.set("snapToLines",false):null;settings.alt(k,vals0,["auto"]);if(vals.length===2){settings.alt("lineAlign",vals[1],["start","middle","end"])}break;case"position":vals=v.split(",");settings.percent(k,vals[0]);if(vals.length===2){settings.alt("positionAlign",vals[1],["start","middle","end"])}break;case"size":settings.percent(k,v);break;case"align":settings.alt(k,v,["start","middle","end","left","right"]);break}},/:/,/\s/);cue.region=settings.get("region",null);cue.vertical=settings.get("vertical","");cue.line=settings.get("line","auto");cue.lineAlign=settings.get("lineAlign","start");cue.snapToLines=settings.get("snapToLines",true);cue.size=settings.get("size",100);cue.align=settings.get("align","middle");cue.position=settings.get("position",{start:0,left:0,middle:50,end:100,right:100},cue.align);cue.positionAlign=settings.get("positionAlign",{start:"start",left:"start",middle:"middle",end:"end",right:"end"},cue.align)}function skipWhitespace(){input=input.replace(/^\s+/,"")}skipWhitespace();cue.startTime=consumeTimeStamp();skipWhitespace();if(input.substr(0,3)!=="--\x3e"){throw new ParsingError(ParsingError.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '--\x3e'): "+oInput)}input=input.substr(3);skipWhitespace();cue.endTime=consumeTimeStamp();skipWhitespace();consumeCueSettings(input,cue)}var ESCAPE={"&amp;":"&","&lt;":"<","&gt;":">","&lrm;":"","&rlm;":"","&nbsp;":" "};var TAG_NAME={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"};var TAG_ANNOTATION={v:"title",lang:"lang"};var NEEDS_PARENT={rt:"ruby"};function parseContent(window,input){function nextToken(){if(!input){return null}function consume(result){input=input.substr(result.length);return result}var m=input.match(/^([^<]*)(<[^>]*>?)?/);return consume(m[1]?m[1]:m[2])}function unescape1(e){return ESCAPE[e]}function unescape(s){while(m=s.match(/&(amp|lt|gt|lrm|rlm|nbsp);/)){s=s.replace(m[0],unescape1)}return s}function shouldAdd(current,element){return!NEEDS_PARENT[element.localName]||NEEDS_PARENT[element.localName]===current.localName}function createElement(type,annotation){var tagName=TAG_NAME[type];if(!tagName){return null}var element=window.document.createElement(tagName);element.localName=tagName;var name=TAG_ANNOTATION[type];if(name&&annotation){element[name]=annotation.trim()}return element}var rootDiv=window.document.createElement("div"),current=rootDiv,t,tagStack=[];while((t=nextToken())!==null){if(t[0]==="<"){if(t[1]==="/"){if(tagStack.length&&tagStack[tagStack.length-1]===t.substr(2).replace(">","")){tagStack.pop();current=current.parentNode}continue}var ts=parseTimeStamp(t.substr(1,t.length-2));var node;if(ts){node=window.document.createProcessingInstruction("timestamp",ts);current.appendChild(node);continue}var m=t.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!m){continue}node=createElement(m[1],m[3]);if(!node){continue}if(!shouldAdd(current,node)){continue}if(m[2]){node.className=m[2].substr(1).replace("."," ")}tagStack.push(m[1]);current.appendChild(node);current=node;continue}current.appendChild(window.document.createTextNode(unescape(t)))}return rootDiv}var strongRTLRanges=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function isStrongRTLChar(charCode){for(var i=0;i<strongRTLRanges.length;i++){var currentRange=strongRTLRanges[i];if(charCode>=currentRange[0]&&charCode<=currentRange[1]){return true}}return false}function determineBidi(cueDiv){var nodeStack=[],text="",charCode;if(!cueDiv||!cueDiv.childNodes){return"ltr"}function pushNodes(nodeStack,node){for(var i=node.childNodes.length-1;i>=0;i--){nodeStack.push(node.childNodes[i])}}function nextTextNode(nodeStack){if(!nodeStack||!nodeStack.length){return null}var node=nodeStack.pop(),text=node.textContent||node.innerText;if(text){var m=text.match(/^.*(\n|\r)/);if(m){nodeStack.length=0;return m[0]}return text}if(node.tagName==="ruby"){return nextTextNode(nodeStack)}if(node.childNodes){pushNodes(nodeStack,node);return nextTextNode(nodeStack)}}pushNodes(nodeStack,cueDiv);while(text=nextTextNode(nodeStack)){for(var i=0;i<text.length;i++){charCode=text.charCodeAt(i);if(isStrongRTLChar(charCode)){return"rtl"}}}return"ltr"}function computeLinePos(cue){if(typeof cue.line==="number"&&(cue.snapToLines||cue.line>=0&&cue.line<=100)){return cue.line}if(!cue.track||!cue.track.textTrackList||!cue.track.textTrackList.mediaElement){return-1}var track=cue.track,trackList=track.textTrackList,count=0;for(var i=0;i<trackList.length&&trackList[i]!==track;i++){if(trackList[i].mode==="showing"){count++}}return++count*-1}function StyleBox(){}StyleBox.prototype.applyStyles=function(styles,div){div=div||this.div;for(var prop in styles){if(styles.hasOwnProperty(prop)){div.style[prop]=styles[prop]}}};StyleBox.prototype.formatStyle=function(val,unit){return val===0?0:val+unit};function CueStyleBox(window,cue,styleOptions){StyleBox.call(this);this.cue=cue;this.cueDiv=parseContent(window,cue.text);var styles={color:"rgba(255, 255, 255, 1)",backgroundColor:"rgba(0, 0, 0, 0.8)",position:"relative",left:0,right:0,top:0,bottom:0,display:"inline",writingMode:cue.vertical===""?"horizontal-tb":cue.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"};this.applyStyles(styles,this.cueDiv);this.div=window.document.createElement("div");styles={direction:determineBidi(this.cueDiv),writingMode:cue.vertical===""?"horizontal-tb":cue.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:cue.align==="middle"?"center":cue.align,font:styleOptions.font,whiteSpace:"pre-line",position:"absolute"};this.applyStyles(styles);this.div.appendChild(this.cueDiv);var textPos=0;switch(cue.positionAlign){case"start":textPos=cue.position;break;case"middle":textPos=cue.position-cue.size/2;break;case"end":textPos=cue.position-cue.size;break}if(cue.vertical===""){this.applyStyles({left:this.formatStyle(textPos,"%"),width:this.formatStyle(cue.size,"%")})}else{this.applyStyles({top:this.formatStyle(textPos,"%"),height:this.formatStyle(cue.size,"%")})}this.move=function(box){this.applyStyles({top:this.formatStyle(box.top,"px"),bottom:this.formatStyle(box.bottom,"px"),left:this.formatStyle(box.left,"px"),right:this.formatStyle(box.right,"px"),height:this.formatStyle(box.height,"px"),width:this.formatStyle(box.width,"px")})}}CueStyleBox.prototype=_objCreate(StyleBox.prototype);CueStyleBox.prototype.constructor=CueStyleBox;function BoxPosition(obj){var lh,height,width,top;if(obj.div){height=obj.div.offsetHeight;width=obj.div.offsetWidth;top=obj.div.offsetTop;var rects=(rects=obj.div.childNodes)&&(rects=rects[0])&&rects.getClientRects&&rects.getClientRects();obj=obj.div.getBoundingClientRect();lh=rects?Math.max(rects[0]&&rects[0].height||0,obj.height/rects.length):0}this.left=obj.left;this.right=obj.right;this.top=obj.top||top;this.height=obj.height||height;this.bottom=obj.bottom||top+(obj.height||height);this.width=obj.width||width;this.lineHeight=lh!==undefined?lh:obj.lineHeight}BoxPosition.prototype.move=function(axis,toMove){toMove=toMove!==undefined?toMove:this.lineHeight;switch(axis){case"+x":this.left+=toMove;this.right+=toMove;break;case"-x":this.left-=toMove;this.right-=toMove;break;case"+y":this.top+=toMove;this.bottom+=toMove;break;case"-y":this.top-=toMove;this.bottom-=toMove;break}};BoxPosition.prototype.overlaps=function(b2){return this.left<b2.right&&this.right>b2.left&&this.top<b2.bottom&&this.bottom>b2.top};BoxPosition.prototype.overlapsAny=function(boxes){for(var i=0;i<boxes.length;i++){if(this.overlaps(boxes[i])){return true}}return false};BoxPosition.prototype.within=function(container){return this.top>=container.top&&this.bottom<=container.bottom&&this.left>=container.left&&this.right<=container.right};BoxPosition.prototype.overlapsOppositeAxis=function(container,axis){switch(axis){case"+x":return this.left<container.left;case"-x":return this.right>container.right;case"+y":return this.top<container.top;case"-y":return this.bottom>container.bottom}};BoxPosition.prototype.intersectPercentage=function(b2){var x=Math.max(0,Math.min(this.right,b2.right)-Math.max(this.left,b2.left)),y=Math.max(0,Math.min(this.bottom,b2.bottom)-Math.max(this.top,b2.top)),intersectArea=x*y;return intersectArea/(this.height*this.width)};BoxPosition.prototype.toCSSCompatValues=function(reference){return{top:this.top-reference.top,bottom:reference.bottom-this.bottom,left:this.left-reference.left,right:reference.right-this.right,height:this.height,width:this.width}};BoxPosition.getSimpleBoxPosition=function(obj){var height=obj.div?obj.div.offsetHeight:obj.tagName?obj.offsetHeight:0;var width=obj.div?obj.div.offsetWidth:obj.tagName?obj.offsetWidth:0;var top=obj.div?obj.div.offsetTop:obj.tagName?obj.offsetTop:0;obj=obj.div?obj.div.getBoundingClientRect():obj.tagName?obj.getBoundingClientRect():obj;var ret={left:obj.left,right:obj.right,top:obj.top||top,height:obj.height||height,bottom:obj.bottom||top+(obj.height||height),width:obj.width||width};return ret};function moveBoxToLinePosition(window,styleBox,containerBox,boxPositions){function findBestPosition(b,axis){var bestPosition,specifiedPosition=new BoxPosition(b),percentage=1;for(var i=0;i<axis.length;i++){while(b.overlapsOppositeAxis(containerBox,axis[i])||b.within(containerBox)&&b.overlapsAny(boxPositions)){b.move(axis[i])}if(b.within(containerBox)){return b}var p=b.intersectPercentage(containerBox);if(percentage>p){bestPosition=new BoxPosition(b);percentage=p}b=new BoxPosition(specifiedPosition)}return bestPosition||specifiedPosition}var boxPosition=new BoxPosition(styleBox),cue=styleBox.cue,linePos=computeLinePos(cue),axis=[];if(cue.snapToLines){var size;switch(cue.vertical){case"":axis=["+y","-y"];size="height";break;case"rl":axis=["+x","-x"];size="width";break;case"lr":axis=["-x","+x"];size="width";break}var step=boxPosition.lineHeight,position=step*Math.round(linePos),maxPosition=containerBox[size]+step,initialAxis=axis[0];if(Math.abs(position)>maxPosition){position=position<0?-1:1;position*=Math.ceil(maxPosition/step)*step}if(linePos<0){position+=cue.vertical===""?containerBox.height:containerBox.width;axis=axis.reverse()}boxPosition.move(initialAxis,position)}else{var calculatedPercentage=boxPosition.lineHeight/containerBox.height*100;switch(cue.lineAlign){case"middle":linePos-=calculatedPercentage/2;break;case"end":linePos-=calculatedPercentage;break}switch(cue.vertical){case"":styleBox.applyStyles({top:styleBox.formatStyle(linePos,"%")});break;case"rl":styleBox.applyStyles({left:styleBox.formatStyle(linePos,"%")});break;case"lr":styleBox.applyStyles({right:styleBox.formatStyle(linePos,"%")});break}axis=["+y","-x","+x","-y"];boxPosition=new BoxPosition(styleBox)}var bestPosition=findBestPosition(boxPosition,axis);styleBox.move(bestPosition.toCSSCompatValues(containerBox))}function WebVTT$1(){}WebVTT$1.StringDecoder=function(){return{decode:function decode(data){if(!data){return""}if(typeof data!=="string"){throw new Error("Error - expected string data.")}return decodeURIComponent(encodeURIComponent(data))}}};WebVTT$1.convertCueToDOMTree=function(window,cuetext){if(!window||!cuetext){return null}return parseContent(window,cuetext)};var FONT_SIZE_PERCENT=.05;var FONT_STYLE="sans-serif";var CUE_BACKGROUND_PADDING="1.5%";WebVTT$1.processCues=function(window,cues,overlay){if(!window||!cues||!overlay){return null}while(overlay.firstChild){overlay.removeChild(overlay.firstChild)}var paddedOverlay=window.document.createElement("div");paddedOverlay.style.position="absolute";paddedOverlay.style.left="0";paddedOverlay.style.right="0";paddedOverlay.style.top="0";paddedOverlay.style.bottom="0";paddedOverlay.style.margin=CUE_BACKGROUND_PADDING;overlay.appendChild(paddedOverlay);function shouldCompute(cues){for(var i=0;i<cues.length;i++){if(cues[i].hasBeenReset||!cues[i].displayState){return true}}return false}if(!shouldCompute(cues)){for(var i=0;i<cues.length;i++){paddedOverlay.appendChild(cues[i].displayState)}return}var boxPositions=[],containerBox=BoxPosition.getSimpleBoxPosition(paddedOverlay),fontSize=Math.round(containerBox.height*FONT_SIZE_PERCENT*100)/100;var styleOptions={font:fontSize+"px "+FONT_STYLE};(function(){var styleBox,cue;for(var i=0;i<cues.length;i++){cue=cues[i];styleBox=new CueStyleBox(window,cue,styleOptions);paddedOverlay.appendChild(styleBox.div);moveBoxToLinePosition(window,styleBox,containerBox,boxPositions);cue.displayState=styleBox.div;boxPositions.push(BoxPosition.getSimpleBoxPosition(styleBox))}})()};WebVTT$1.Parser=function(window,vttjs,decoder){if(!decoder){decoder=vttjs;vttjs={}}if(!vttjs){vttjs={}}this.window=window;this.vttjs=vttjs;this.state="INITIAL";this.buffer="";this.decoder=decoder||new TextDecoder("utf8");this.regionList=[]};WebVTT$1.Parser.prototype={reportOrThrowError:function reportOrThrowError(e){if(e instanceof ParsingError){this.onparsingerror&&this.onparsingerror(e)}else{throw e}},parse:function parse(data){var self=this;if(data){self.buffer+=self.decoder.decode(data,{stream:true})}function collectNextLine(){var buffer=self.buffer;var pos=0;while(pos<buffer.length&&buffer[pos]!=="\r"&&buffer[pos]!=="\n"){++pos}var line=buffer.substr(0,pos);if(buffer[pos]==="\r"){++pos}if(buffer[pos]==="\n"){++pos}self.buffer=buffer.substr(pos);return line}function parseRegion(input){var settings=new Settings;parseOptions(input,function(k,v){switch(k){case"id":settings.set(k,v);break;case"width":settings.percent(k,v);break;case"lines":settings.integer(k,v);break;case"regionanchor":case"viewportanchor":var xy=v.split(",");if(xy.length!==2){break}var anchor=new Settings;anchor.percent("x",xy[0]);anchor.percent("y",xy[1]);if(!anchor.has("x")||!anchor.has("y")){break}settings.set(k+"X",anchor.get("x"));settings.set(k+"Y",anchor.get("y"));break;case"scroll":settings.alt(k,v,["up"]);break}},/=/,/\s/);if(settings.has("id")){var region=new(self.vttjs.VTTRegion||self.window.VTTRegion);region.width=settings.get("width",100);region.lines=settings.get("lines",3);region.regionAnchorX=settings.get("regionanchorX",0);region.regionAnchorY=settings.get("regionanchorY",100);region.viewportAnchorX=settings.get("viewportanchorX",0);region.viewportAnchorY=settings.get("viewportanchorY",100);region.scroll=settings.get("scroll","");self.onregion&&self.onregion(region);self.regionList.push({id:settings.get("id"),region:region})}}function parseTimestampMap(input){var settings=new Settings;parseOptions(input,function(k,v){switch(k){case"MPEGT":settings.integer(k+"S",v);break;case"LOCA":settings.set(k+"L",parseTimeStamp(v));break}},/[^\d]:/,/,/);self.ontimestampmap&&self.ontimestampmap({MPEGTS:settings.get("MPEGTS"),LOCAL:settings.get("LOCAL")})}function parseHeader(input){if(input.match(/X-TIMESTAMP-MAP/)){parseOptions(input,function(k,v){switch(k){case"X-TIMESTAMP-MAP":parseTimestampMap(v);break}},/=/)}else{parseOptions(input,function(k,v){switch(k){case"Region":parseRegion(v);break}},/:/)}}try{var line;if(self.state==="INITIAL"){if(!/\r\n|\n/.test(self.buffer)){return this}line=collectNextLine();var m=line.match(/^WEBVTT([ \t].*)?$/);if(!m||!m[0]){throw new ParsingError(ParsingError.Errors.BadSignature)}self.state="HEADER"}var alreadyCollectedLine=false;while(self.buffer){if(!/\r\n|\n/.test(self.buffer)){return this}if(!alreadyCollectedLine){line=collectNextLine()}else{alreadyCollectedLine=false}switch(self.state){case"HEADER":if(/:/.test(line)){parseHeader(line)}else if(!line){self.state="ID"}continue;case"NOTE":if(!line){self.state="ID"}continue;case"ID":if(/^NOTE($|[ \t])/.test(line)){self.state="NOTE";break}if(!line){continue}self.cue=new(self.vttjs.VTTCue||self.window.VTTCue)(0,0,"");self.state="CUE";if(line.indexOf("--\x3e")===-1){self.cue.id=line;continue}case"CUE":try{parseCue(line,self.cue,self.regionList)}catch(e){self.reportOrThrowError(e);self.cue=null;self.state="BADCUE";continue}self.state="CUETEXT";continue;case"CUETEXT":var hasSubstring=line.indexOf("--\x3e")!==-1;if(!line||hasSubstring&&(alreadyCollectedLine=true)){self.oncue&&self.oncue(self.cue);self.cue=null;self.state="ID";continue}if(self.cue.text){self.cue.text+="\n"}self.cue.text+=line;continue;case"BADCUE":if(!line){self.state="ID"}continue}}}catch(e){self.reportOrThrowError(e);if(self.state==="CUETEXT"&&self.cue&&self.oncue){self.oncue(self.cue)}self.cue=null;self.state=self.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},flush:function flush(){var self=this;try{self.buffer+=self.decoder.decode();if(self.cue||self.state==="HEADER"){self.buffer+="\n\n";self.parse()}if(self.state==="INITIAL"){throw new ParsingError(ParsingError.Errors.BadSignature)}}catch(e){self.reportOrThrowError(e)}self.onflush&&self.onflush();return this}};var vtt=WebVTT$1;var autoKeyword="auto";var directionSetting={"":1,lr:1,rl:1};var alignSetting={start:1,middle:1,end:1,left:1,right:1};function findDirectionSetting(value){if(typeof value!=="string"){return false}var dir=directionSetting[value.toLowerCase()];return dir?value.toLowerCase():false}function findAlignSetting(value){if(typeof value!=="string"){return false}var align=alignSetting[value.toLowerCase()];return align?value.toLowerCase():false}function VTTCue(startTime,endTime,text){this.hasBeenReset=false;var _id="";var _pauseOnExit=false;var _startTime=startTime;var _endTime=endTime;var _text=text;var _region=null;var _vertical="";var _snapToLines=true;var _line="auto";var _lineAlign="start";var _position=50;var _positionAlign="middle";var _size=50;var _align="middle";Object.defineProperties(this,{id:{enumerable:true,get:function get(){return _id},set:function set(value){_id=""+value}},pauseOnExit:{enumerable:true,get:function get(){return _pauseOnExit},set:function set(value){_pauseOnExit=!!value}},startTime:{enumerable:true,get:function get(){return _startTime},set:function set(value){if(typeof value!=="number"){throw new TypeError("Start time must be set to a number.")}_startTime=value;this.hasBeenReset=true}},endTime:{enumerable:true,get:function get(){return _endTime},set:function set(value){if(typeof value!=="number"){throw new TypeError("End time must be set to a number.")}_endTime=value;this.hasBeenReset=true}},text:{enumerable:true,get:function get(){return _text},set:function set(value){_text=""+value;this.hasBeenReset=true}},region:{enumerable:true,get:function get(){return _region},set:function set(value){_region=value;this.hasBeenReset=true}},vertical:{enumerable:true,get:function get(){return _vertical},set:function set(value){var setting=findDirectionSetting(value);if(setting===false){throw new SyntaxError("An invalid or illegal string was specified.")}_vertical=setting;this.hasBeenReset=true}},snapToLines:{enumerable:true,get:function get(){return _snapToLines},set:function set(value){_snapToLines=!!value;this.hasBeenReset=true}},line:{enumerable:true,get:function get(){return _line},set:function set(value){if(typeof value!=="number"&&value!==autoKeyword){throw new SyntaxError("An invalid number or illegal string was specified.")}_line=value;this.hasBeenReset=true}},lineAlign:{enumerable:true,get:function get(){return _lineAlign},set:function set(value){var setting=findAlignSetting(value);if(!setting){throw new SyntaxError("An invalid or illegal string was specified.")}_lineAlign=setting;this.hasBeenReset=true}},position:{enumerable:true,get:function get(){return _position},set:function set(value){if(value<0||value>100){throw new Error("Position must be between 0 and 100.")}_position=value;this.hasBeenReset=true}},positionAlign:{enumerable:true,get:function get(){return _positionAlign},set:function set(value){var setting=findAlignSetting(value);if(!setting){throw new SyntaxError("An invalid or illegal string was specified.")}_positionAlign=setting;this.hasBeenReset=true}},size:{enumerable:true,get:function get(){return _size},set:function set(value){if(value<0||value>100){throw new Error("Size must be between 0 and 100.")}_size=value;this.hasBeenReset=true}},align:{enumerable:true,get:function get(){return _align},set:function set(value){var setting=findAlignSetting(value);if(!setting){throw new SyntaxError("An invalid or illegal string was specified.")}_align=setting;this.hasBeenReset=true}}});this.displayState=undefined}VTTCue.prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)};var vttcue=VTTCue;var scrollSetting={"":true,up:true};function findScrollSetting(value){if(typeof value!=="string"){return false}var scroll=scrollSetting[value.toLowerCase()];return scroll?value.toLowerCase():false}function isValidPercentValue(value){return typeof value==="number"&&value>=0&&value<=100}function VTTRegion(){var _width=100;var _lines=3;var _regionAnchorX=0;var _regionAnchorY=100;var _viewportAnchorX=0;var _viewportAnchorY=100;var _scroll="";Object.defineProperties(this,{width:{enumerable:true,get:function get(){return _width},set:function set(value){if(!isValidPercentValue(value)){throw new Error("Width must be between 0 and 100.")}_width=value}},lines:{enumerable:true,get:function get(){return _lines},set:function set(value){if(typeof value!=="number"){throw new TypeError("Lines must be set to a number.")}_lines=value}},regionAnchorY:{enumerable:true,get:function get(){return _regionAnchorY},set:function set(value){if(!isValidPercentValue(value)){throw new Error("RegionAnchorX must be between 0 and 100.")}_regionAnchorY=value}},regionAnchorX:{enumerable:true,get:function get(){return _regionAnchorX},set:function set(value){if(!isValidPercentValue(value)){throw new Error("RegionAnchorY must be between 0 and 100.")}_regionAnchorX=value}},viewportAnchorY:{enumerable:true,get:function get(){return _viewportAnchorY},set:function set(value){if(!isValidPercentValue(value)){throw new Error("ViewportAnchorY must be between 0 and 100.")}_viewportAnchorY=value}},viewportAnchorX:{enumerable:true,get:function get(){return _viewportAnchorX},set:function set(value){if(!isValidPercentValue(value)){throw new Error("ViewportAnchorX must be between 0 and 100.")}_viewportAnchorX=value}},scroll:{enumerable:true,get:function get(){return _scroll},set:function set(value){var setting=findScrollSetting(value);if(setting===false){throw new SyntaxError("An invalid or illegal string was specified.")}_scroll=setting}}})}var vttregion=VTTRegion;var browserIndex=createCommonjsModule(function(module){var vttjs=module.exports={WebVTT:vtt,VTTCue:vttcue,VTTRegion:vttregion};window$1.vttjs=vttjs;window$1.WebVTT=vttjs.WebVTT;var cueShim=vttjs.VTTCue;var regionShim=vttjs.VTTRegion;var nativeVTTCue=window$1.VTTCue;var nativeVTTRegion=window$1.VTTRegion;vttjs.shim=function(){window$1.VTTCue=cueShim;window$1.VTTRegion=regionShim};vttjs.restore=function(){window$1.VTTCue=nativeVTTCue;window$1.VTTRegion=nativeVTTRegion};if(!window$1.VTTCue){vttjs.shim()}});var browserIndex_1=browserIndex.WebVTT;var browserIndex_2=browserIndex.VTTCue;var browserIndex_3=browserIndex.VTTRegion;function createTrackHelper(self,kind,label,language,options){if(options===void 0){options={}}var tracks=self.textTracks();options.kind=kind;if(label){options.label=label}if(language){options.language=language}options.tech=self;var track=new ALL.text.TrackClass(options);tracks.addTrack(track);return track}var Tech=function(_Component){_inheritsLoose(Tech,_Component);function Tech(options,ready){var _this;if(options===void 0){options={}}if(ready===void 0){ready=function ready(){}}options.reportTouchActivity=false;_this=_Component.call(this,null,options,ready)||this;_this.hasStarted_=false;_this.on("playing",function(){this.hasStarted_=true});_this.on("loadstart",function(){this.hasStarted_=false});ALL.names.forEach(function(name){var props=ALL[name];if(options&&options[props.getterName]){_this[props.privateName]=options[props.getterName]}});if(!_this.featuresProgressEvents){_this.manualProgressOn()}if(!_this.featuresTimeupdateEvents){_this.manualTimeUpdatesOn()}["Text","Audio","Video"].forEach(function(track){if(options["native"+track+"Tracks"]===false){_this["featuresNative"+track+"Tracks"]=false}});if(options.nativeCaptions===false||options.nativeTextTracks===false){_this.featuresNativeTextTracks=false}else if(options.nativeCaptions===true||options.nativeTextTracks===true){_this.featuresNativeTextTracks=true}if(!_this.featuresNativeTextTracks){_this.emulateTextTracks()}_this.autoRemoteTextTracks_=new ALL.text.ListClass;_this.initTrackListeners();if(!options.nativeControlsForTouch){_this.emitTapEvents()}if(_this.constructor){_this.name_=_this.constructor.name||"Unknown Tech"}return _this}var _proto=Tech.prototype;_proto.triggerSourceset=function triggerSourceset(src){var _this2=this;if(!this.isReady_){this.one("ready",function(){return _this2.setTimeout(function(){return _this2.triggerSourceset(src)},1)})}this.trigger({src:src,type:"sourceset"})};_proto.manualProgressOn=function manualProgressOn(){this.on("durationchange",this.onDurationChange);this.manualProgress=true;this.one("ready",this.trackProgress)};_proto.manualProgressOff=function manualProgressOff(){this.manualProgress=false;this.stopTrackingProgress();this.off("durationchange",this.onDurationChange)};_proto.trackProgress=function trackProgress(event){this.stopTrackingProgress();this.progressInterval=this.setInterval(bind(this,function(){var numBufferedPercent=this.bufferedPercent();if(this.bufferedPercent_!==numBufferedPercent){this.trigger("progress")}this.bufferedPercent_=numBufferedPercent;if(numBufferedPercent===1){this.stopTrackingProgress()}}),500)};_proto.onDurationChange=function onDurationChange(event){this.duration_=this.duration()};_proto.buffered=function buffered(){return createTimeRanges(0,0)};_proto.bufferedPercent=function bufferedPercent$1(){return bufferedPercent(this.buffered(),this.duration_)};_proto.stopTrackingProgress=function stopTrackingProgress(){this.clearInterval(this.progressInterval)};_proto.manualTimeUpdatesOn=function manualTimeUpdatesOn(){this.manualTimeUpdates=true;this.on("play",this.trackCurrentTime);this.on("pause",this.stopTrackingCurrentTime)};_proto.manualTimeUpdatesOff=function manualTimeUpdatesOff(){this.manualTimeUpdates=false;this.stopTrackingCurrentTime();this.off("play",this.trackCurrentTime);this.off("pause",this.stopTrackingCurrentTime)};_proto.trackCurrentTime=function trackCurrentTime(){if(this.currentTimeInterval){this.stopTrackingCurrentTime()}this.currentTimeInterval=this.setInterval(function(){this.trigger({type:"timeupdate",target:this,manuallyTriggered:true})},250)};_proto.stopTrackingCurrentTime=function stopTrackingCurrentTime(){this.clearInterval(this.currentTimeInterval);this.trigger({type:"timeupdate",target:this,manuallyTriggered:true})};_proto.dispose=function dispose(){this.clearTracks(NORMAL.names);if(this.manualProgress){this.manualProgressOff()}if(this.manualTimeUpdates){this.manualTimeUpdatesOff()}_Component.prototype.dispose.call(this)};_proto.clearTracks=function clearTracks(types){var _this3=this;types=[].concat(types);types.forEach(function(type){var list=_this3[type+"Tracks"]()||[];var i=list.length;while(i--){var track=list[i];if(type==="text"){_this3.removeRemoteTextTrack(track)}list.removeTrack(track)}})};_proto.cleanupAutoTextTracks=function cleanupAutoTextTracks(){var list=this.autoRemoteTextTracks_||[];var i=list.length;while(i--){var track=list[i];this.removeRemoteTextTrack(track)}};_proto.reset=function reset(){};_proto.error=function error(err){if(err!==undefined){this.error_=new MediaError(err);this.trigger("error")}return this.error_};_proto.played=function played(){if(this.hasStarted_){return createTimeRanges(0,0)}return createTimeRanges()};_proto.setCurrentTime=function setCurrentTime(){if(this.manualTimeUpdates){this.trigger({type:"timeupdate",target:this,manuallyTriggered:true})}};_proto.initTrackListeners=function initTrackListeners(){var _this4=this;NORMAL.names.forEach(function(name){var props=NORMAL[name];var trackListChanges=function trackListChanges(){_this4.trigger(name+"trackchange")};var tracks=_this4[props.getterName]();tracks.addEventListener("removetrack",trackListChanges);tracks.addEventListener("addtrack",trackListChanges);_this4.on("dispose",function(){tracks.removeEventListener("removetrack",trackListChanges);tracks.removeEventListener("addtrack",trackListChanges)})})};_proto.addWebVttScript_=function addWebVttScript_(){var _this5=this;if(window$1.WebVTT){return}if(document.body.contains(this.el())){if(!this.options_["vtt.js"]&&isPlain(browserIndex)&&Object.keys(browserIndex).length>0){this.trigger("vttjsloaded");return}var script=document.createElement("script");script.src=this.options_["vtt.js"]||"https://vjs.zencdn.net/vttjs/0.14.1/vtt.min.js";script.onload=function(){_this5.trigger("vttjsloaded")};script.onerror=function(){_this5.trigger("vttjserror")};this.on("dispose",function(){script.onload=null;script.onerror=null});window$1.WebVTT=true;this.el().parentNode.appendChild(script)}else{this.ready(this.addWebVttScript_)}};_proto.emulateTextTracks=function emulateTextTracks(){var _this6=this;var tracks=this.textTracks();var remoteTracks=this.remoteTextTracks();var handleAddTrack=function handleAddTrack(e){return tracks.addTrack(e.track)};var handleRemoveTrack=function handleRemoveTrack(e){return tracks.removeTrack(e.track)};remoteTracks.on("addtrack",handleAddTrack);remoteTracks.on("removetrack",handleRemoveTrack);this.addWebVttScript_();var updateDisplay=function updateDisplay(){return _this6.trigger("texttrackchange")};var textTracksChanges=function textTracksChanges(){updateDisplay();for(var i=0;i<tracks.length;i++){var track=tracks[i];track.removeEventListener("cuechange",updateDisplay);if(track.mode==="showing"){track.addEventListener("cuechange",updateDisplay)}}};textTracksChanges();tracks.addEventListener("change",textTracksChanges);tracks.addEventListener("addtrack",textTracksChanges);tracks.addEventListener("removetrack",textTracksChanges);this.on("dispose",function(){remoteTracks.off("addtrack",handleAddTrack);remoteTracks.off("removetrack",handleRemoveTrack);tracks.removeEventListener("change",textTracksChanges);tracks.removeEventListener("addtrack",textTracksChanges);tracks.removeEventListener("removetrack",textTracksChanges);for(var i=0;i<tracks.length;i++){var track=tracks[i];track.removeEventListener("cuechange",updateDisplay)}})};_proto.addTextTrack=function addTextTrack(kind,label,language){if(!kind){throw new Error("TextTrack kind is required but was not provided")}return createTrackHelper(this,kind,label,language)};_proto.createRemoteTextTrack=function createRemoteTextTrack(options){var track=mergeOptions(options,{tech:this});return new REMOTE.remoteTextEl.TrackClass(track)};_proto.addRemoteTextTrack=function addRemoteTextTrack(options,manualCleanup){var _this7=this;if(options===void 0){options={}}var htmlTrackElement=this.createRemoteTextTrack(options);if(manualCleanup!==true&&manualCleanup!==false){log.warn('Calling addRemoteTextTrack without explicitly setting the "manualCleanup" parameter to `true` is deprecated and default to `false` in future version of video.js');manualCleanup=true}this.remoteTextTrackEls().addTrackElement_(htmlTrackElement);this.remoteTextTracks().addTrack(htmlTrackElement.track);if(manualCleanup!==true){this.ready(function(){return _this7.autoRemoteTextTracks_.addTrack(htmlTrackElement.track)})}return htmlTrackElement};_proto.removeRemoteTextTrack=function removeRemoteTextTrack(track){var trackElement=this.remoteTextTrackEls().getTrackElementByTrack_(track);this.remoteTextTrackEls().removeTrackElement_(trackElement);this.remoteTextTracks().removeTrack(track);this.autoRemoteTextTracks_.removeTrack(track)};_proto.getVideoPlaybackQuality=function getVideoPlaybackQuality(){return{}};_proto.requestPictureInPicture=function requestPictureInPicture(){var PromiseClass=this.options_.Promise||window$1.Promise;if(PromiseClass){return PromiseClass.reject()}};_proto.setPoster=function setPoster(){};_proto.playsinline=function playsinline(){};_proto.setPlaysinline=function setPlaysinline(){};_proto.overrideNativeAudioTracks=function overrideNativeAudioTracks(){};_proto.overrideNativeVideoTracks=function overrideNativeVideoTracks(){};_proto.canPlayType=function canPlayType(){return""};Tech.canPlayType=function canPlayType(){return""};Tech.canPlaySource=function canPlaySource(srcObj,options){return Tech.canPlayType(srcObj.type)};Tech.isTech=function isTech(component){return component.prototype instanceof Tech||component instanceof Tech||component===Tech};Tech.registerTech=function registerTech(name,tech){if(!Tech.techs_){Tech.techs_={}}if(!Tech.isTech(tech)){throw new Error("Tech "+name+" must be a Tech")}if(!Tech.canPlayType){throw new Error("Techs must have a static canPlayType method on them")}if(!Tech.canPlaySource){throw new Error("Techs must have a static canPlaySource method on them")}name=toTitleCase(name);Tech.techs_[name]=tech;Tech.techs_[toLowerCase(name)]=tech;if(name!=="Tech"){Tech.defaultTechOrder_.push(name)}return tech};Tech.getTech=function getTech(name){if(!name){return}if(Tech.techs_&&Tech.techs_[name]){return Tech.techs_[name]}name=toTitleCase(name);if(window$1&&window$1.videojs&&window$1.videojs[name]){log.warn("The "+name+" tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)");return window$1.videojs[name]}};return Tech}(Component);ALL.names.forEach(function(name){var props=ALL[name];Tech.prototype[props.getterName]=function(){this[props.privateName]=this[props.privateName]||new props.ListClass;return this[props.privateName]}});Tech.prototype.featuresVolumeControl=true;Tech.prototype.featuresMuteControl=true;Tech.prototype.featuresFullscreenResize=false;Tech.prototype.featuresPlaybackRate=false;Tech.prototype.featuresProgressEvents=false;Tech.prototype.featuresSourceset=false;Tech.prototype.featuresTimeupdateEvents=false;Tech.prototype.featuresNativeTextTracks=false;Tech.withSourceHandlers=function(_Tech){_Tech.registerSourceHandler=function(handler,index){var handlers=_Tech.sourceHandlers;if(!handlers){handlers=_Tech.sourceHandlers=[]}if(index===undefined){index=handlers.length}handlers.splice(index,0,handler)};_Tech.canPlayType=function(type){var handlers=_Tech.sourceHandlers||[];var can;for(var i=0;i<handlers.length;i++){can=handlers[i].canPlayType(type);if(can){return can}}return""};_Tech.selectSourceHandler=function(source,options){var handlers=_Tech.sourceHandlers||[];var can;for(var i=0;i<handlers.length;i++){can=handlers[i].canHandleSource(source,options);if(can){return handlers[i]}}return null};_Tech.canPlaySource=function(srcObj,options){var sh=_Tech.selectSourceHandler(srcObj,options);if(sh){return sh.canHandleSource(srcObj,options)}return""};var deferrable=["seekable","seeking","duration"];deferrable.forEach(function(fnName){var originalFn=this[fnName];if(typeof originalFn!=="function"){return}this[fnName]=function(){if(this.sourceHandler_&&this.sourceHandler_[fnName]){return this.sourceHandler_[fnName].apply(this.sourceHandler_,arguments)}return originalFn.apply(this,arguments)}},_Tech.prototype);_Tech.prototype.setSource=function(source){var sh=_Tech.selectSourceHandler(source,this.options_);if(!sh){if(_Tech.nativeSourceHandler){sh=_Tech.nativeSourceHandler}else{log.error("No source handler found for the current source.")}}this.disposeSourceHandler();this.off("dispose",this.disposeSourceHandler);if(sh!==_Tech.nativeSourceHandler){this.currentSource_=source}this.sourceHandler_=sh.handleSource(source,this,this.options_);this.one("dispose",this.disposeSourceHandler)};_Tech.prototype.disposeSourceHandler=function(){if(this.currentSource_){this.clearTracks(["audio","video"]);this.currentSource_=null}this.cleanupAutoTextTracks();if(this.sourceHandler_){if(this.sourceHandler_.dispose){this.sourceHandler_.dispose()}this.sourceHandler_=null}}};Component.registerComponent("Tech",Tech);Tech.registerTech("Tech",Tech);Tech.defaultTechOrder_=[];var middlewares={};var middlewareInstances={};var TERMINATOR={};function use(type,middleware){middlewares[type]=middlewares[type]||[];middlewares[type].push(middleware)}function setSource(player,src,next){player.setTimeout(function(){return setSourceHelper(src,middlewares[src.type],next,player)},1)}function setTech(middleware,tech){middleware.forEach(function(mw){return mw.setTech&&mw.setTech(tech)})}function get(middleware,tech,method){return middleware.reduceRight(middlewareIterator(method),tech[method]())}function set(middleware,tech,method,arg){return tech[method](middleware.reduce(middlewareIterator(method),arg))}function mediate(middleware,tech,method,arg){if(arg===void 0){arg=null}var callMethod="call"+toTitleCase(method);var middlewareValue=middleware.reduce(middlewareIterator(callMethod),arg);var terminated=middlewareValue===TERMINATOR;var returnValue=terminated?null:tech[method](middlewareValue);executeRight(middleware,method,returnValue,terminated);return returnValue}var allowedGetters={buffered:1,currentTime:1,duration:1,seekable:1,played:1,paused:1,volume:1};var allowedSetters={setCurrentTime:1,setVolume:1};var allowedMediators={play:1,pause:1};function middlewareIterator(method){return function(value,mw){if(value===TERMINATOR){return TERMINATOR}if(mw[method]){return mw[method](value)}return value}}function executeRight(mws,method,value,terminated){for(var i=mws.length-1;i>=0;i--){var mw=mws[i];if(mw[method]){mw[method](terminated,value)}}}function clearCacheForPlayer(player){middlewareInstances[player.id()]=null}function getOrCreateFactory(player,mwFactory){var mws=middlewareInstances[player.id()];var mw=null;if(mws===undefined||mws===null){mw=mwFactory(player);middlewareInstances[player.id()]=[[mwFactory,mw]];return mw}for(var i=0;i<mws.length;i++){var _mws$i=mws[i],mwf=_mws$i[0],mwi=_mws$i[1];if(mwf!==mwFactory){continue}mw=mwi}if(mw===null){mw=mwFactory(player);mws.push([mwFactory,mw])}return mw}function setSourceHelper(src,middleware,next,player,acc,lastRun){if(src===void 0){src={}}if(middleware===void 0){middleware=[]}if(acc===void 0){acc=[]}if(lastRun===void 0){lastRun=false}var _middleware=middleware,mwFactory=_middleware[0],mwrest=_middleware.slice(1);if(typeof mwFactory==="string"){setSourceHelper(src,middlewares[mwFactory],next,player,acc,lastRun)}else if(mwFactory){var mw=getOrCreateFactory(player,mwFactory);if(!mw.setSource){acc.push(mw);return setSourceHelper(src,mwrest,next,player,acc,lastRun)}mw.setSource(assign({},src),function(err,_src){if(err){return setSourceHelper(src,mwrest,next,player,acc,lastRun)}acc.push(mw);setSourceHelper(_src,src.type===_src.type?mwrest:middlewares[_src.type],next,player,acc,lastRun)})}else if(mwrest.length){setSourceHelper(src,mwrest,next,player,acc,lastRun)}else if(lastRun){next(src,acc)}else{setSourceHelper(src,middlewares["*"],next,player,acc,true)}}var MimetypesKind={opus:"video/ogg",ogv:"video/ogg",mp4:"video/mp4",mov:"video/mp4",m4v:"video/mp4",mkv:"video/x-matroska",m4a:"audio/mp4",mp3:"audio/mpeg",aac:"audio/aac",oga:"audio/ogg",m3u8:"application/x-mpegURL",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",png:"image/png",svg:"image/svg+xml",webp:"image/webp"};var getMimetype=function getMimetype(src){if(src===void 0){src=""}var ext=getFileExtension(src);var mimetype=MimetypesKind[ext.toLowerCase()];return mimetype||""};var findMimetype=function findMimetype(player,src){if(!src){return""}if(player.cache_.source.src===src&&player.cache_.source.type){return player.cache_.source.type}var matchingSources=player.cache_.sources.filter(function(s){return s.src===src});if(matchingSources.length){return matchingSources[0].type}var sources=player.$$("source");for(var i=0;i<sources.length;i++){var s=sources[i];if(s.type&&s.src&&s.src===src){return s.type}}return getMimetype(src)};var filterSource=function filterSource(src){if(Array.isArray(src)){var newsrc=[];src.forEach(function(srcobj){srcobj=filterSource(srcobj);if(Array.isArray(srcobj)){newsrc=newsrc.concat(srcobj)}else if(isObject(srcobj)){newsrc.push(srcobj)}});src=newsrc}else if(typeof src==="string"&&src.trim()){src=[fixSource({src:src})]}else if(isObject(src)&&typeof src.src==="string"&&src.src&&src.src.trim()){src=[fixSource(src)]}else{src=[]}return src};function fixSource(src){if(!src.type){var mimetype=getMimetype(src.src);if(mimetype){src.type=mimetype}}return src}var MediaLoader=function(_Component){_inheritsLoose(MediaLoader,_Component);function MediaLoader(player,options,ready){var _this;var options_=mergeOptions({createEl:false},options);_this=_Component.call(this,player,options_,ready)||this;if(!options.playerOptions.sources||options.playerOptions.sources.length===0){for(var i=0,j=options.playerOptions.techOrder;i<j.length;i++){var techName=toTitleCase(j[i]);var tech=Tech.getTech(techName);if(!techName){tech=Component.getComponent(techName)}if(tech&&tech.isSupported()){player.loadTech_(techName);break}}}else{player.src(options.playerOptions.sources)}return _this}return MediaLoader}(Component);Component.registerComponent("MediaLoader",MediaLoader);var ClickableComponent=function(_Component){_inheritsLoose(ClickableComponent,_Component);function ClickableComponent(player,options){var _this;_this=_Component.call(this,player,options)||this;_this.emitTapEvents();_this.enable();return _this}var _proto=ClickableComponent.prototype;_proto.createEl=function createEl(tag,props,attributes){if(tag===void 0){tag="div"}if(props===void 0){props={}}if(attributes===void 0){attributes={}}props=assign({innerHTML:'<span aria-hidden="true" class="vjs-icon-placeholder"></span>',className:this.buildCSSClass(),tabIndex:0},props);if(tag==="button"){log.error("Creating a ClickableComponent with an HTML element of "+tag+" is not supported; use a Button instead.")}attributes=assign({role:"button"},attributes);this.tabIndex_=props.tabIndex;var el=_Component.prototype.createEl.call(this,tag,props,attributes);this.createControlTextEl(el);return el};_proto.dispose=function dispose(){this.controlTextEl_=null;_Component.prototype.dispose.call(this)};_proto.createControlTextEl=function createControlTextEl(el){this.controlTextEl_=createEl("span",{className:"vjs-control-text"},{"aria-live":"polite"});if(el){el.appendChild(this.controlTextEl_)}this.controlText(this.controlText_,el);return this.controlTextEl_};_proto.controlText=function controlText(text,el){if(el===void 0){el=this.el()}if(text===undefined){return this.controlText_||"Need Text"}var localizedText=this.localize(text);this.controlText_=text;textContent(this.controlTextEl_,localizedText);if(!this.nonIconControl){el.setAttribute("title",localizedText)}};_proto.buildCSSClass=function buildCSSClass(){return"vjs-control vjs-button "+_Component.prototype.buildCSSClass.call(this)};_proto.enable=function enable(){if(!this.enabled_){this.enabled_=true;this.removeClass("vjs-disabled");this.el_.setAttribute("aria-disabled","false");if(typeof this.tabIndex_!=="undefined"){this.el_.setAttribute("tabIndex",this.tabIndex_)}this.on(["tap","click"],this.handleClick);this.on("keydown",this.handleKeyDown)}};_proto.disable=function disable(){this.enabled_=false;this.addClass("vjs-disabled");this.el_.setAttribute("aria-disabled","true");if(typeof this.tabIndex_!=="undefined"){this.el_.removeAttribute("tabIndex")}this.off("mouseover",this.handleMouseOver);this.off("mouseout",this.handleMouseOut);this.off(["tap","click"],this.handleClick);this.off("keydown",this.handleKeyDown)};_proto.handleClick=function handleClick(event){};_proto.handleKeyDown=function handleKeyDown(event){if(keycode.isEventKey(event,"Space")||keycode.isEventKey(event,"Enter")){event.preventDefault();event.stopPropagation();this.trigger("click")}else{_Component.prototype.handleKeyDown.call(this,event)}};return ClickableComponent}(Component);Component.registerComponent("ClickableComponent",ClickableComponent);var PosterImage=function(_ClickableComponent){_inheritsLoose(PosterImage,_ClickableComponent);function PosterImage(player,options){var _this;_this=_ClickableComponent.call(this,player,options)||this;_this.update();player.on("posterchange",bind(_assertThisInitialized(_this),_this.update));return _this}var _proto=PosterImage.prototype;_proto.dispose=function dispose(){this.player().off("posterchange",this.update);_ClickableComponent.prototype.dispose.call(this)};_proto.createEl=function createEl$1(){var el=createEl("div",{className:"vjs-poster",tabIndex:-1});return el};_proto.update=function update(event){var url=this.player().poster();this.setSrc(url);if(url){this.show()}else{this.hide()}};_proto.setSrc=function setSrc(url){var backgroundImage="";if(url){backgroundImage='url("'+url+'")'}this.el_.style.backgroundImage=backgroundImage};_proto.handleClick=function handleClick(event){if(!this.player_.controls()){return}if(this.player_.tech(true)){this.player_.tech(true).focus()}if(this.player_.paused()){silencePromise(this.player_.play())}else{this.player_.pause()}};return PosterImage}(ClickableComponent);Component.registerComponent("PosterImage",PosterImage);var darkGray="#222";var lightGray="#ccc";var fontMap={monospace:"monospace",sansSerif:"sans-serif",serif:"serif",monospaceSansSerif:'"Andale Mono", "Lucida Console", monospace',monospaceSerif:'"Courier New", monospace',proportionalSansSerif:"sans-serif",proportionalSerif:"serif",casual:'"Comic Sans MS", Impact, fantasy',script:'"Monotype Corsiva", cursive',smallcaps:'"Andale Mono", "Lucida Console", monospace, sans-serif'};function constructColor(color,opacity){var hex;if(color.length===4){hex=color[1]+color[1]+color[2]+color[2]+color[3]+color[3]}else if(color.length===7){hex=color.slice(1)}else{throw new Error("Invalid color code provided, "+color+"; must be formatted as e.g. #f0e or #f604e2.")}return"rgba("+parseInt(hex.slice(0,2),16)+","+parseInt(hex.slice(2,4),16)+","+parseInt(hex.slice(4,6),16)+","+opacity+")"}function tryUpdateStyle(el,style,rule){try{el.style[style]=rule}catch(e){return}}var TextTrackDisplay=function(_Component){_inheritsLoose(TextTrackDisplay,_Component);function TextTrackDisplay(player,options,ready){var _this;_this=_Component.call(this,player,options,ready)||this;var updateDisplayHandler=bind(_assertThisInitialized(_this),_this.updateDisplay);player.on("loadstart",bind(_assertThisInitialized(_this),_this.toggleDisplay));player.on("texttrackchange",updateDisplayHandler);player.on("loadedmetadata",bind(_assertThisInitialized(_this),_this.preselectTrack));player.ready(bind(_assertThisInitialized(_this),function(){if(player.tech_&&player.tech_.featuresNativeTextTracks){this.hide();return}player.on("fullscreenchange",updateDisplayHandler);player.on("playerresize",updateDisplayHandler);window$1.addEventListener("orientationchange",updateDisplayHandler);player.on("dispose",function(){return window$1.removeEventListener("orientationchange",updateDisplayHandler)});var tracks=this.options_.playerOptions.tracks||[];for(var i=0;i<tracks.length;i++){this.player_.addRemoteTextTrack(tracks[i],true)}this.preselectTrack()}));return _this}var _proto=TextTrackDisplay.prototype;_proto.preselectTrack=function preselectTrack(){var modes={captions:1,subtitles:1};var trackList=this.player_.textTracks();var userPref=this.player_.cache_.selectedLanguage;var firstDesc;var firstCaptions;var preferredTrack;for(var i=0;i<trackList.length;i++){var track=trackList[i];if(userPref&&userPref.enabled&&userPref.language&&userPref.language===track.language&&track.kind in modes){if(track.kind===userPref.kind){preferredTrack=track}else if(!preferredTrack){preferredTrack=track}}else if(userPref&&!userPref.enabled){preferredTrack=null;firstDesc=null;firstCaptions=null}else if(track["default"]){if(track.kind==="descriptions"&&!firstDesc){firstDesc=track}else if(track.kind in modes&&!firstCaptions){firstCaptions=track}}}if(preferredTrack){preferredTrack.mode="showing"}else if(firstCaptions){firstCaptions.mode="showing"}else if(firstDesc){firstDesc.mode="showing"}};_proto.toggleDisplay=function toggleDisplay(){if(this.player_.tech_&&this.player_.tech_.featuresNativeTextTracks){this.hide()}else{this.show()}};_proto.createEl=function createEl(){return _Component.prototype.createEl.call(this,"div",{className:"vjs-text-track-display"},{"aria-live":"off","aria-atomic":"true"})};_proto.clearDisplay=function clearDisplay(){if(typeof window$1.WebVTT==="function"){window$1.WebVTT.processCues(window$1,[],this.el_)}};_proto.updateDisplay=function updateDisplay(){var tracks=this.player_.textTracks();var allowMultipleShowingTracks=this.options_.allowMultipleShowingTracks;this.clearDisplay();if(allowMultipleShowingTracks){var showingTracks=[];for(var _i=0;_i<tracks.length;++_i){var track=tracks[_i];if(track.mode!=="showing"){continue}showingTracks.push(track)}this.updateForTrack(showingTracks);return}var descriptionsTrack=null;var captionsSubtitlesTrack=null;var i=tracks.length;while(i--){var _track=tracks[i];if(_track.mode==="showing"){if(_track.kind==="descriptions"){descriptionsTrack=_track}else{captionsSubtitlesTrack=_track}}}if(captionsSubtitlesTrack){if(this.getAttribute("aria-live")!=="off"){this.setAttribute("aria-live","off")}this.updateForTrack(captionsSubtitlesTrack)}else if(descriptionsTrack){if(this.getAttribute("aria-live")!=="assertive"){this.setAttribute("aria-live","assertive")}this.updateForTrack(descriptionsTrack)}};_proto.updateDisplayState=function updateDisplayState(track){var overrides=this.player_.textTrackSettings.getValues();var cues=track.activeCues;var i=cues.length;while(i--){var cue=cues[i];if(!cue){continue}var cueDiv=cue.displayState;if(overrides.color){cueDiv.firstChild.style.color=overrides.color}if(overrides.textOpacity){tryUpdateStyle(cueDiv.firstChild,"color",constructColor(overrides.color||"#fff",overrides.textOpacity))}if(overrides.backgroundColor){cueDiv.firstChild.style.backgroundColor=overrides.backgroundColor}if(overrides.backgroundOpacity){tryUpdateStyle(cueDiv.firstChild,"backgroundColor",constructColor(overrides.backgroundColor||"#000",overrides.backgroundOpacity))}if(overrides.windowColor){if(overrides.windowOpacity){tryUpdateStyle(cueDiv,"backgroundColor",constructColor(overrides.windowColor,overrides.windowOpacity))}else{cueDiv.style.backgroundColor=overrides.windowColor}}if(overrides.edgeStyle){if(overrides.edgeStyle==="dropshadow"){cueDiv.firstChild.style.textShadow="2px 2px 3px "+darkGray+", 2px 2px 4px "+darkGray+", 2px 2px 5px "+darkGray}else if(overrides.edgeStyle==="raised"){cueDiv.firstChild.style.textShadow="1px 1px "+darkGray+", 2px 2px "+darkGray+", 3px 3px "+darkGray}else if(overrides.edgeStyle==="depressed"){cueDiv.firstChild.style.textShadow="1px 1px "+lightGray+", 0 1px "+lightGray+", -1px -1px "+darkGray+", 0 -1px "+darkGray}else if(overrides.edgeStyle==="uniform"){cueDiv.firstChild.style.textShadow="0 0 4px "+darkGray+", 0 0 4px "+darkGray+", 0 0 4px "+darkGray+", 0 0 4px "+darkGray}}if(overrides.fontPercent&&overrides.fontPercent!==1){var fontSize=window$1.parseFloat(cueDiv.style.fontSize);cueDiv.style.fontSize=fontSize*overrides.fontPercent+"px";cueDiv.style.height="auto";cueDiv.style.top="auto";cueDiv.style.bottom="2px"}if(overrides.fontFamily&&overrides.fontFamily!=="default"){if(overrides.fontFamily==="small-caps"){cueDiv.firstChild.style.fontVariant="small-caps"}else{cueDiv.firstChild.style.fontFamily=fontMap[overrides.fontFamily]}}}};_proto.updateForTrack=function updateForTrack(tracks){if(!Array.isArray(tracks)){tracks=[tracks]}if(typeof window$1.WebVTT!=="function"||tracks.every(function(track){return!track.activeCues})){return}var cues=[];for(var i=0;i<tracks.length;++i){var track=tracks[i];for(var j=0;j<track.activeCues.length;++j){cues.push(track.activeCues[j])}}window$1.WebVTT.processCues(window$1,cues,this.el_);for(var _i2=0;_i2<tracks.length;++_i2){var _track2=tracks[_i2];for(var _j=0;_j<_track2.activeCues.length;++_j){var cueEl=_track2.activeCues[_j].displayState;addClass(cueEl,"vjs-text-track-cue");addClass(cueEl,"vjs-text-track-cue-"+(_track2.language?_track2.language:_i2))}if(this.player_.textTrackSettings){this.updateDisplayState(_track2)}}};return TextTrackDisplay}(Component);Component.registerComponent("TextTrackDisplay",TextTrackDisplay);var LoadingSpinner=function(_Component){_inheritsLoose(LoadingSpinner,_Component);function LoadingSpinner(){return _Component.apply(this,arguments)||this}var _proto=LoadingSpinner.prototype;_proto.createEl=function createEl$1(){var isAudio=this.player_.isAudio();var playerType=this.localize(isAudio?"Audio Player":"Video Player");var controlText=createEl("span",{className:"vjs-control-text",innerHTML:this.localize("{1} is loading.",[playerType])});var el=_Component.prototype.createEl.call(this,"div",{className:"vjs-loading-spinner",dir:"ltr"});el.appendChild(controlText);return el};return LoadingSpinner}(Component);Component.registerComponent("LoadingSpinner",LoadingSpinner);var Button=function(_ClickableComponent){_inheritsLoose(Button,_ClickableComponent);function Button(){return _ClickableComponent.apply(this,arguments)||this}var _proto=Button.prototype;_proto.createEl=function createEl(tag,props,attributes){if(props===void 0){props={}}if(attributes===void 0){attributes={}}tag="button";props=assign({innerHTML:'<span aria-hidden="true" class="vjs-icon-placeholder"></span>',className:this.buildCSSClass()},props);attributes=assign({type:"button"},attributes);var el=Component.prototype.createEl.call(this,tag,props,attributes);this.createControlTextEl(el);return el};_proto.addChild=function addChild(child,options){if(options===void 0){options={}}var className=this.constructor.name;log.warn("Adding an actionable (user controllable) child to a Button ("+className+") is not supported; use a ClickableComponent instead.");return Component.prototype.addChild.call(this,child,options)};_proto.enable=function enable(){_ClickableComponent.prototype.enable.call(this);this.el_.removeAttribute("disabled")};_proto.disable=function disable(){_ClickableComponent.prototype.disable.call(this);this.el_.setAttribute("disabled","disabled")};_proto.handleKeyDown=function handleKeyDown(event){if(keycode.isEventKey(event,"Space")||keycode.isEventKey(event,"Enter")){event.stopPropagation();return}_ClickableComponent.prototype.handleKeyDown.call(this,event)};return Button}(ClickableComponent);Component.registerComponent("Button",Button);var BigPlayButton=function(_Button){_inheritsLoose(BigPlayButton,_Button);function BigPlayButton(player,options){var _this;_this=_Button.call(this,player,options)||this;_this.mouseused_=false;_this.on("mousedown",_this.handleMouseDown);return _this}var _proto=BigPlayButton.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-big-play-button"};_proto.handleClick=function handleClick(event){var playPromise=this.player_.play();if(this.mouseused_&&event.clientX&&event.clientY){silencePromise(playPromise);if(this.player_.tech(true)){this.player_.tech(true).focus()}return}var cb=this.player_.getChild("controlBar");var playToggle=cb&&cb.getChild("playToggle");if(!playToggle){this.player_.tech(true).focus();return}var playFocus=function playFocus(){return playToggle.focus()};if(isPromise(playPromise)){playPromise.then(playFocus,function(){})}else{this.setTimeout(playFocus,1)}};_proto.handleKeyDown=function handleKeyDown(event){this.mouseused_=false;_Button.prototype.handleKeyDown.call(this,event)};_proto.handleMouseDown=function handleMouseDown(event){this.mouseused_=true};return BigPlayButton}(Button);BigPlayButton.prototype.controlText_="Play Video";Component.registerComponent("BigPlayButton",BigPlayButton);var CloseButton=function(_Button){_inheritsLoose(CloseButton,_Button);function CloseButton(player,options){var _this;_this=_Button.call(this,player,options)||this;_this.controlText(options&&options.controlText||_this.localize("Close"));return _this}var _proto=CloseButton.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-close-button "+_Button.prototype.buildCSSClass.call(this)};_proto.handleClick=function handleClick(event){this.trigger({type:"close",bubbles:false})};_proto.handleKeyDown=function handleKeyDown(event){if(keycode.isEventKey(event,"Esc")){event.preventDefault();event.stopPropagation();this.trigger("click")}else{_Button.prototype.handleKeyDown.call(this,event)}};return CloseButton}(Button);Component.registerComponent("CloseButton",CloseButton);var PlayToggle=function(_Button){_inheritsLoose(PlayToggle,_Button);function PlayToggle(player,options){var _this;if(options===void 0){options={}}_this=_Button.call(this,player,options)||this;options.replay=options.replay===undefined||options.replay;_this.on(player,"play",_this.handlePlay);_this.on(player,"pause",_this.handlePause);if(options.replay){_this.on(player,"ended",_this.handleEnded)}return _this}var _proto=PlayToggle.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-play-control "+_Button.prototype.buildCSSClass.call(this)};_proto.handleClick=function handleClick(event){if(this.player_.paused()){this.player_.play()}else{this.player_.pause()}};_proto.handleSeeked=function handleSeeked(event){this.removeClass("vjs-ended");if(this.player_.paused()){this.handlePause(event)}else{this.handlePlay(event)}};_proto.handlePlay=function handlePlay(event){this.removeClass("vjs-ended");this.removeClass("vjs-paused");this.addClass("vjs-playing");this.controlText("Pause")};_proto.handlePause=function handlePause(event){this.removeClass("vjs-playing");this.addClass("vjs-paused");this.controlText("Play")};_proto.handleEnded=function handleEnded(event){this.removeClass("vjs-playing");this.addClass("vjs-ended");this.controlText("Replay");this.one(this.player_,"seeked",this.handleSeeked)};return PlayToggle}(Button);PlayToggle.prototype.controlText_="Play";Component.registerComponent("PlayToggle",PlayToggle);var defaultImplementation=function defaultImplementation(seconds,guide){seconds=seconds<0?0:seconds;var s=Math.floor(seconds%60);var m=Math.floor(seconds/60%60);var h=Math.floor(seconds/3600);var gm=Math.floor(guide/60%60);var gh=Math.floor(guide/3600);if(isNaN(seconds)||seconds===Infinity){h=m=s="-"}h=h>0||gh>0?h+":":"";m=((h||gm>=10)&&m<10?"0"+m:m)+":";s=s<10?"0"+s:s;return h+m+s};var implementation$3=defaultImplementation;function setFormatTime(customImplementation){implementation$3=customImplementation}function resetFormatTime(){implementation$3=defaultImplementation}function formatTime(seconds,guide){if(guide===void 0){guide=seconds}return implementation$3(seconds,guide)}var TimeDisplay=function(_Component){_inheritsLoose(TimeDisplay,_Component);function TimeDisplay(player,options){var _this;_this=_Component.call(this,player,options)||this;_this.throttledUpdateContent=throttle(bind(_assertThisInitialized(_this),_this.updateContent),UPDATE_REFRESH_INTERVAL);_this.on(player,"timeupdate",_this.throttledUpdateContent);return _this}var _proto=TimeDisplay.prototype;_proto.createEl=function createEl$1(){var className=this.buildCSSClass();var el=_Component.prototype.createEl.call(this,"div",{className:className+" vjs-time-control vjs-control",innerHTML:'<span class="vjs-control-text" role="presentation">'+this.localize(this.labelText_)+" </span>"});this.contentEl_=createEl("span",{className:className+"-display"},{"aria-live":"off",role:"presentation"});this.updateTextNode_();el.appendChild(this.contentEl_);return el};_proto.dispose=function dispose(){this.contentEl_=null;this.textNode_=null;_Component.prototype.dispose.call(this)};_proto.updateTextNode_=function updateTextNode_(){if(!this.contentEl_){return}while(this.contentEl_.firstChild){this.contentEl_.removeChild(this.contentEl_.firstChild)}this.textNode_=document.createTextNode(this.formattedTime_||this.formatTime_(0));this.contentEl_.appendChild(this.textNode_)};_proto.formatTime_=function formatTime_(time){return formatTime(time)};_proto.updateFormattedTime_=function updateFormattedTime_(time){var formattedTime=this.formatTime_(time);if(formattedTime===this.formattedTime_){return}this.formattedTime_=formattedTime;this.requestAnimationFrame(this.updateTextNode_)};_proto.updateContent=function updateContent(event){};return TimeDisplay}(Component);TimeDisplay.prototype.labelText_="Time";TimeDisplay.prototype.controlText_="Time";Component.registerComponent("TimeDisplay",TimeDisplay);var CurrentTimeDisplay=function(_TimeDisplay){_inheritsLoose(CurrentTimeDisplay,_TimeDisplay);function CurrentTimeDisplay(player,options){var _this;_this=_TimeDisplay.call(this,player,options)||this;_this.on(player,"ended",_this.handleEnded);return _this}var _proto=CurrentTimeDisplay.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-current-time"};_proto.updateContent=function updateContent(event){var time=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime();this.updateFormattedTime_(time)};_proto.handleEnded=function handleEnded(event){if(!this.player_.duration()){return}this.updateFormattedTime_(this.player_.duration())};return CurrentTimeDisplay}(TimeDisplay);CurrentTimeDisplay.prototype.labelText_="Current Time";CurrentTimeDisplay.prototype.controlText_="Current Time";Component.registerComponent("CurrentTimeDisplay",CurrentTimeDisplay);var DurationDisplay=function(_TimeDisplay){_inheritsLoose(DurationDisplay,_TimeDisplay);function DurationDisplay(player,options){var _this;_this=_TimeDisplay.call(this,player,options)||this;_this.on(player,"durationchange",_this.updateContent);_this.on(player,"loadstart",_this.updateContent);_this.on(player,"loadedmetadata",_this.throttledUpdateContent);return _this}var _proto=DurationDisplay.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-duration"};_proto.updateContent=function updateContent(event){var duration=this.player_.duration();if(this.duration_!==duration){this.duration_=duration;this.updateFormattedTime_(duration)}};return DurationDisplay}(TimeDisplay);DurationDisplay.prototype.labelText_="Duration";DurationDisplay.prototype.controlText_="Duration";Component.registerComponent("DurationDisplay",DurationDisplay);var TimeDivider=function(_Component){_inheritsLoose(TimeDivider,_Component);function TimeDivider(){return _Component.apply(this,arguments)||this}var _proto=TimeDivider.prototype;_proto.createEl=function createEl(){return _Component.prototype.createEl.call(this,"div",{className:"vjs-time-control vjs-time-divider",innerHTML:"<div><span>/</span></div>"},{"aria-hidden":true})};return TimeDivider}(Component);Component.registerComponent("TimeDivider",TimeDivider);var RemainingTimeDisplay=function(_TimeDisplay){_inheritsLoose(RemainingTimeDisplay,_TimeDisplay);function RemainingTimeDisplay(player,options){var _this;_this=_TimeDisplay.call(this,player,options)||this;_this.on(player,"durationchange",_this.throttledUpdateContent);_this.on(player,"ended",_this.handleEnded);return _this}var _proto=RemainingTimeDisplay.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-remaining-time"};_proto.createEl=function createEl$1(){var el=_TimeDisplay.prototype.createEl.call(this);el.insertBefore(createEl("span",{},{"aria-hidden":true},"-"),this.contentEl_);return el};_proto.updateContent=function updateContent(event){if(typeof this.player_.duration()!=="number"){return}if(this.player_.remainingTimeDisplay){this.updateFormattedTime_(this.player_.remainingTimeDisplay())}else{this.updateFormattedTime_(this.player_.remainingTime())}};_proto.handleEnded=function handleEnded(event){if(!this.player_.duration()){return}this.updateFormattedTime_(0)};return RemainingTimeDisplay}(TimeDisplay);RemainingTimeDisplay.prototype.labelText_="Remaining Time";RemainingTimeDisplay.prototype.controlText_="Remaining Time";Component.registerComponent("RemainingTimeDisplay",RemainingTimeDisplay);var LiveDisplay=function(_Component){_inheritsLoose(LiveDisplay,_Component);function LiveDisplay(player,options){var _this;_this=_Component.call(this,player,options)||this;_this.updateShowing();_this.on(_this.player(),"durationchange",_this.updateShowing);return _this}var _proto=LiveDisplay.prototype;_proto.createEl=function createEl$1(){var el=_Component.prototype.createEl.call(this,"div",{className:"vjs-live-control vjs-control"});this.contentEl_=createEl("div",{className:"vjs-live-display",innerHTML:'<span class="vjs-control-text">'+this.localize("Stream Type")+" </span>"+this.localize("LIVE")},{"aria-live":"off"});el.appendChild(this.contentEl_);return el};_proto.dispose=function dispose(){this.contentEl_=null;_Component.prototype.dispose.call(this)};_proto.updateShowing=function updateShowing(event){if(this.player().duration()===Infinity){this.show()}else{this.hide()}};return LiveDisplay}(Component);Component.registerComponent("LiveDisplay",LiveDisplay);var SeekToLive=function(_Button){_inheritsLoose(SeekToLive,_Button);function SeekToLive(player,options){var _this;_this=_Button.call(this,player,options)||this;_this.updateLiveEdgeStatus();if(_this.player_.liveTracker){_this.on(_this.player_.liveTracker,"liveedgechange",_this.updateLiveEdgeStatus)}return _this}var _proto=SeekToLive.prototype;_proto.createEl=function createEl$1(){var el=_Button.prototype.createEl.call(this,"button",{className:"vjs-seek-to-live-control vjs-control"});this.textEl_=createEl("span",{className:"vjs-seek-to-live-text",innerHTML:this.localize("LIVE")},{"aria-hidden":"true"});el.appendChild(this.textEl_);return el};_proto.updateLiveEdgeStatus=function updateLiveEdgeStatus(e){if(!this.player_.liveTracker||this.player_.liveTracker.atLiveEdge()){this.setAttribute("aria-disabled",true);this.addClass("vjs-at-live-edge");this.controlText("Seek to live, currently playing live")}else{this.setAttribute("aria-disabled",false);this.removeClass("vjs-at-live-edge");this.controlText("Seek to live, currently behind live")}};_proto.handleClick=function handleClick(){this.player_.liveTracker.seekToLiveEdge()};_proto.dispose=function dispose(){if(this.player_.liveTracker){this.off(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatus)}this.textEl_=null;_Button.prototype.dispose.call(this)};return SeekToLive}(Button);SeekToLive.prototype.controlText_="Seek to live, currently playing live";Component.registerComponent("SeekToLive",SeekToLive);var Slider=function(_Component){_inheritsLoose(Slider,_Component);function Slider(player,options){var _this;_this=_Component.call(this,player,options)||this;_this.bar=_this.getChild(_this.options_.barName);_this.vertical(!!_this.options_.vertical);_this.enable();return _this}var _proto=Slider.prototype;_proto.enabled=function enabled(){return this.enabled_};_proto.enable=function enable(){if(this.enabled()){return}this.on("mousedown",this.handleMouseDown);this.on("touchstart",this.handleMouseDown);this.on("keydown",this.handleKeyDown);this.on("click",this.handleClick);this.on(this.player_,"controlsvisible",this.update);if(this.playerEvent){this.on(this.player_,this.playerEvent,this.update)}this.removeClass("disabled");this.setAttribute("tabindex",0);this.enabled_=true};_proto.disable=function disable(){if(!this.enabled()){return}var doc=this.bar.el_.ownerDocument;this.off("mousedown",this.handleMouseDown);this.off("touchstart",this.handleMouseDown);this.off("keydown",this.handleKeyDown);this.off("click",this.handleClick);this.off(this.player_,"controlsvisible",this.update);this.off(doc,"mousemove",this.handleMouseMove);this.off(doc,"mouseup",this.handleMouseUp);this.off(doc,"touchmove",this.handleMouseMove);this.off(doc,"touchend",this.handleMouseUp);this.removeAttribute("tabindex");this.addClass("disabled");if(this.playerEvent){this.off(this.player_,this.playerEvent,this.update)}this.enabled_=false};_proto.createEl=function createEl(type,props,attributes){if(props===void 0){props={}}if(attributes===void 0){attributes={}}props.className=props.className+" vjs-slider";props=assign({tabIndex:0},props);attributes=assign({role:"slider","aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0},attributes);return _Component.prototype.createEl.call(this,type,props,attributes)};_proto.handleMouseDown=function handleMouseDown(event){var doc=this.bar.el_.ownerDocument;if(event.type==="mousedown"){event.preventDefault()}if(event.type==="touchstart"&&!IS_CHROME){event.preventDefault()}blockTextSelection();this.addClass("vjs-sliding");this.trigger("slideractive");this.on(doc,"mousemove",this.handleMouseMove);this.on(doc,"mouseup",this.handleMouseUp);this.on(doc,"touchmove",this.handleMouseMove);this.on(doc,"touchend",this.handleMouseUp);this.handleMouseMove(event)};_proto.handleMouseMove=function handleMouseMove(event){};_proto.handleMouseUp=function handleMouseUp(){var doc=this.bar.el_.ownerDocument;unblockTextSelection();this.removeClass("vjs-sliding");this.trigger("sliderinactive");this.off(doc,"mousemove",this.handleMouseMove);this.off(doc,"mouseup",this.handleMouseUp);this.off(doc,"touchmove",this.handleMouseMove);this.off(doc,"touchend",this.handleMouseUp);this.update()};_proto.update=function update(){if(!this.el_){return}var progress=this.getPercent();var bar=this.bar;if(!bar){return}if(typeof progress!=="number"||progress!==progress||progress<0||progress===Infinity){progress=0}var percentage=(progress*100).toFixed(2)+"%";var style=bar.el().style;var sizeKey=this.vertical()?"height":"width";if(style[sizeKey]!==percentage){style[sizeKey]=percentage}return progress};_proto.calculateDistance=function calculateDistance(event){var position=getPointerPosition(this.el_,event);if(this.vertical()){return position.y}return position.x};_proto.handleKeyDown=function handleKeyDown(event){if(keycode.isEventKey(event,"Left")||keycode.isEventKey(event,"Down")){event.preventDefault();event.stopPropagation();this.stepBack()}else if(keycode.isEventKey(event,"Right")||keycode.isEventKey(event,"Up")){event.preventDefault();event.stopPropagation();this.stepForward()}else{_Component.prototype.handleKeyDown.call(this,event)}};_proto.handleClick=function handleClick(event){event.stopPropagation();event.preventDefault()};_proto.vertical=function vertical(bool){if(bool===undefined){return this.vertical_||false}this.vertical_=!!bool;if(this.vertical_){this.addClass("vjs-slider-vertical")}else{this.addClass("vjs-slider-horizontal")}};return Slider}(Component);Component.registerComponent("Slider",Slider);var LoadProgressBar=function(_Component){_inheritsLoose(LoadProgressBar,_Component);function LoadProgressBar(player,options){var _this;_this=_Component.call(this,player,options)||this;_this.partEls_=[];_this.on(player,"progress",_this.update);return _this}var _proto=LoadProgressBar.prototype;_proto.createEl=function createEl(){return _Component.prototype.createEl.call(this,"div",{className:"vjs-load-progress",innerHTML:'<span class="vjs-control-text"><span>'+this.localize("Loaded")+'</span>: <span class="vjs-control-text-loaded-percentage">0%</span></span>'})};_proto.dispose=function dispose(){this.partEls_=null;_Component.prototype.dispose.call(this)};_proto.update=function update(event){var liveTracker=this.player_.liveTracker;var buffered=this.player_.buffered();var duration=liveTracker&&liveTracker.isLive()?liveTracker.seekableEnd():this.player_.duration();var bufferedEnd=this.player_.bufferedEnd();var children=this.partEls_;var controlTextPercentage=this.$(".vjs-control-text-loaded-percentage");var percentify=function percentify(time,end,rounded){var percent=time/end||0;percent=(percent>=1?1:percent)*100;if(rounded){percent=percent.toFixed(2)}return percent+"%"};this.el_.style.width=percentify(bufferedEnd,duration);textContent(controlTextPercentage,percentify(bufferedEnd,duration,true));for(var i=0;i<buffered.length;i++){var start=buffered.start(i);var end=buffered.end(i);var part=children[i];if(!part){part=this.el_.appendChild(createEl());children[i]=part}part.style.left=percentify(start,bufferedEnd);part.style.width=percentify(end-start,bufferedEnd)}for(var _i=children.length;_i>buffered.length;_i--){this.el_.removeChild(children[_i-1])}children.length=buffered.length};return LoadProgressBar}(Component);Component.registerComponent("LoadProgressBar",LoadProgressBar);var TimeTooltip=function(_Component){_inheritsLoose(TimeTooltip,_Component);function TimeTooltip(player,options){var _this;_this=_Component.call(this,player,options)||this;_this.update=throttle(bind(_assertThisInitialized(_this),_this.update),UPDATE_REFRESH_INTERVAL);return _this}var _proto=TimeTooltip.prototype;_proto.createEl=function createEl(){return _Component.prototype.createEl.call(this,"div",{className:"vjs-time-tooltip"},{"aria-hidden":"true"})};_proto.update=function update(seekBarRect,seekBarPoint,content){var tooltipRect=getBoundingClientRect(this.el_);var playerRect=getBoundingClientRect(this.player_.el());var seekBarPointPx=seekBarRect.width*seekBarPoint;if(!playerRect||!tooltipRect){return}var spaceLeftOfPoint=seekBarRect.left-playerRect.left+seekBarPointPx;var spaceRightOfPoint=seekBarRect.width-seekBarPointPx+(playerRect.right-seekBarRect.right);var pullTooltipBy=tooltipRect.width/2;if(spaceLeftOfPoint<pullTooltipBy){pullTooltipBy+=pullTooltipBy-spaceLeftOfPoint}else if(spaceRightOfPoint<pullTooltipBy){pullTooltipBy=spaceRightOfPoint}if(pullTooltipBy<0){pullTooltipBy=0}else if(pullTooltipBy>tooltipRect.width){pullTooltipBy=tooltipRect.width}this.el_.style.right="-"+pullTooltipBy+"px";this.write(content)};_proto.write=function write(content){textContent(this.el_,content)};_proto.updateTime=function updateTime(seekBarRect,seekBarPoint,time,cb){var _this2=this;if(this.rafId_){this.cancelAnimationFrame(this.rafId_)}this.rafId_=this.requestAnimationFrame(function(){var content;var duration=_this2.player_.duration();if(_this2.player_.liveTracker&&_this2.player_.liveTracker.isLive()){var liveWindow=_this2.player_.liveTracker.liveWindow();var secondsBehind=liveWindow-seekBarPoint*liveWindow;content=(secondsBehind<1?"":"-")+formatTime(secondsBehind,liveWindow)}else{content=formatTime(time,duration)}_this2.update(seekBarRect,seekBarPoint,content);if(cb){cb()}})};return TimeTooltip}(Component);Component.registerComponent("TimeTooltip",TimeTooltip);var PlayProgressBar=function(_Component){_inheritsLoose(PlayProgressBar,_Component);function PlayProgressBar(player,options){var _this;_this=_Component.call(this,player,options)||this;_this.update=throttle(bind(_assertThisInitialized(_this),_this.update),UPDATE_REFRESH_INTERVAL);return _this}var _proto=PlayProgressBar.prototype;_proto.createEl=function createEl(){return _Component.prototype.createEl.call(this,"div",{className:"vjs-play-progress vjs-slider-bar"},{"aria-hidden":"true"})};_proto.update=function update(seekBarRect,seekBarPoint){var timeTooltip=this.getChild("timeTooltip");if(!timeTooltip){return}var time=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime();timeTooltip.updateTime(seekBarRect,seekBarPoint,time)};return PlayProgressBar}(Component);PlayProgressBar.prototype.options_={children:[]};if(!IS_IOS&&!IS_ANDROID){PlayProgressBar.prototype.options_.children.push("timeTooltip")}Component.registerComponent("PlayProgressBar",PlayProgressBar);var MouseTimeDisplay=function(_Component){_inheritsLoose(MouseTimeDisplay,_Component);function MouseTimeDisplay(player,options){var _this;_this=_Component.call(this,player,options)||this;_this.update=throttle(bind(_assertThisInitialized(_this),_this.update),UPDATE_REFRESH_INTERVAL);return _this}var _proto=MouseTimeDisplay.prototype;_proto.createEl=function createEl(){return _Component.prototype.createEl.call(this,"div",{className:"vjs-mouse-display"})};_proto.update=function update(seekBarRect,seekBarPoint){var _this2=this;var time=seekBarPoint*this.player_.duration();this.getChild("timeTooltip").updateTime(seekBarRect,seekBarPoint,time,function(){_this2.el_.style.left=seekBarRect.width*seekBarPoint+"px"})};return MouseTimeDisplay}(Component);MouseTimeDisplay.prototype.options_={children:["timeTooltip"]};Component.registerComponent("MouseTimeDisplay",MouseTimeDisplay);var STEP_SECONDS=5;var PAGE_KEY_MULTIPLIER=12;var UPDATE_REFRESH_INTERVAL$1=30;var SeekBar=function(_Slider){_inheritsLoose(SeekBar,_Slider);function SeekBar(player,options){var _this;_this=_Slider.call(this,player,options)||this;_this.setEventHandlers_();return _this}var _proto=SeekBar.prototype;_proto.setEventHandlers_=function setEventHandlers_(){this.update=throttle(bind(this,this.update),UPDATE_REFRESH_INTERVAL$1);this.on(this.player_,"timeupdate",this.update);this.on(this.player_,"ended",this.handleEnded);this.on(this.player_,"durationchange",this.update);if(this.player_.liveTracker){this.on(this.player_.liveTracker,"liveedgechange",this.update)}this.updateInterval=null;this.on(this.player_,["playing"],this.enableInterval_);this.on(this.player_,["ended","pause","waiting"],this.disableInterval_);if("hidden"in document&&"visibilityState"in document){this.on(document,"visibilitychange",this.toggleVisibility_)}};_proto.toggleVisibility_=function toggleVisibility_(e){if(document.hidden){this.disableInterval_(e)}else{this.enableInterval_();this.requestAnimationFrame(this.update)}};_proto.enableInterval_=function enableInterval_(){var _this2=this;this.clearInterval(this.updateInterval);this.updateInterval=this.setInterval(function(){_this2.requestAnimationFrame(_this2.update)},UPDATE_REFRESH_INTERVAL$1)};_proto.disableInterval_=function disableInterval_(e){if(this.player_.liveTracker&&this.player_.liveTracker.isLive()&&e.type!=="ended"){return}this.clearInterval(this.updateInterval)};_proto.createEl=function createEl(){return _Slider.prototype.createEl.call(this,"div",{className:"vjs-progress-holder"},{"aria-label":this.localize("Progress Bar")})};_proto.update_=function update_(currentTime,percent){var liveTracker=this.player_.liveTracker;var duration=this.player_.duration();if(liveTracker&&liveTracker.isLive()){duration=this.player_.liveTracker.liveCurrentTime()}this.el_.setAttribute("aria-valuenow",(percent*100).toFixed(2));this.el_.setAttribute("aria-valuetext",this.localize("progress bar timing: currentTime={1} duration={2}",[formatTime(currentTime,duration),formatTime(duration,duration)],"{1} of {2}"));if(this.bar){this.bar.update(getBoundingClientRect(this.el_),percent)}};_proto.update=function update(event){if(this.el().offsetParent===null){return}var percent=_Slider.prototype.update.call(this);this.update_(this.getCurrentTime_(),percent);return percent};_proto.getCurrentTime_=function getCurrentTime_(){return this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime()};_proto.handleEnded=function handleEnded(event){this.update_(this.player_.duration(),1)};_proto.getPercent=function getPercent(){var currentTime=this.getCurrentTime_();var percent;var liveTracker=this.player_.liveTracker;if(liveTracker&&liveTracker.isLive()){percent=(currentTime-liveTracker.seekableStart())/liveTracker.liveWindow();if(liveTracker.atLiveEdge()){percent=1}}else{percent=currentTime/this.player_.duration()}return percent>=1?1:percent||0};_proto.handleMouseDown=function handleMouseDown(event){if(!isSingleLeftClick(event)){return}event.stopPropagation();this.player_.scrubbing(true);this.videoWasPlaying=!this.player_.paused();this.player_.pause();_Slider.prototype.handleMouseDown.call(this,event)};_proto.handleMouseMove=function handleMouseMove(event){if(!isSingleLeftClick(event)){return}var newTime;var distance=this.calculateDistance(event);var liveTracker=this.player_.liveTracker;if(!liveTracker||!liveTracker.isLive()){newTime=distance*this.player_.duration();if(newTime===this.player_.duration()){newTime=newTime-.1}}else{var seekableStart=liveTracker.seekableStart();var seekableEnd=liveTracker.liveCurrentTime();newTime=seekableStart+distance*liveTracker.liveWindow();if(newTime>=seekableEnd){newTime=seekableEnd}if(newTime<=seekableStart){newTime=seekableStart+.1}if(newTime===Infinity){return}}this.player_.currentTime(newTime)};_proto.enable=function enable(){_Slider.prototype.enable.call(this);var mouseTimeDisplay=this.getChild("mouseTimeDisplay");if(!mouseTimeDisplay){return}mouseTimeDisplay.show()};_proto.disable=function disable(){_Slider.prototype.disable.call(this);var mouseTimeDisplay=this.getChild("mouseTimeDisplay");if(!mouseTimeDisplay){return}mouseTimeDisplay.hide()};_proto.handleMouseUp=function handleMouseUp(event){_Slider.prototype.handleMouseUp.call(this,event);if(event){event.stopPropagation()}this.player_.scrubbing(false);this.player_.trigger({type:"timeupdate",target:this,manuallyTriggered:true});if(this.videoWasPlaying){silencePromise(this.player_.play())}};_proto.stepForward=function stepForward(){this.player_.currentTime(this.player_.currentTime()+STEP_SECONDS)};_proto.stepBack=function stepBack(){this.player_.currentTime(this.player_.currentTime()-STEP_SECONDS)};_proto.handleAction=function handleAction(event){if(this.player_.paused()){this.player_.play()}else{this.player_.pause()}};_proto.handleKeyDown=function handleKeyDown(event){if(keycode.isEventKey(event,"Space")||keycode.isEventKey(event,"Enter")){event.preventDefault();event.stopPropagation();this.handleAction(event)}else if(keycode.isEventKey(event,"Home")){event.preventDefault();event.stopPropagation();this.player_.currentTime(0)}else if(keycode.isEventKey(event,"End")){event.preventDefault();event.stopPropagation();this.player_.currentTime(this.player_.duration())}else if(/^[0-9]$/.test(keycode(event))){event.preventDefault();event.stopPropagation();var gotoFraction=(keycode.codes[keycode(event)]-keycode.codes["0"])*10/100;this.player_.currentTime(this.player_.duration()*gotoFraction)}else if(keycode.isEventKey(event,"PgDn")){event.preventDefault();event.stopPropagation();this.player_.currentTime(this.player_.currentTime()-STEP_SECONDS*PAGE_KEY_MULTIPLIER)}else if(keycode.isEventKey(event,"PgUp")){event.preventDefault();event.stopPropagation();this.player_.currentTime(this.player_.currentTime()+STEP_SECONDS*PAGE_KEY_MULTIPLIER)}else{_Slider.prototype.handleKeyDown.call(this,event)}};return SeekBar}(Slider);SeekBar.prototype.options_={children:["loadProgressBar","playProgressBar"],barName:"playProgressBar"};if(!IS_IOS&&!IS_ANDROID){SeekBar.prototype.options_.children.splice(1,0,"mouseTimeDisplay")}Component.registerComponent("SeekBar",SeekBar);var ProgressControl=function(_Component){_inheritsLoose(ProgressControl,_Component);function ProgressControl(player,options){var _this;_this=_Component.call(this,player,options)||this;_this.handleMouseMove=throttle(bind(_assertThisInitialized(_this),_this.handleMouseMove),UPDATE_REFRESH_INTERVAL);_this.throttledHandleMouseSeek=throttle(bind(_assertThisInitialized(_this),_this.handleMouseSeek),UPDATE_REFRESH_INTERVAL);_this.enable();return _this}var _proto=ProgressControl.prototype;_proto.createEl=function createEl(){return _Component.prototype.createEl.call(this,"div",{className:"vjs-progress-control vjs-control"})};_proto.handleMouseMove=function handleMouseMove(event){var seekBar=this.getChild("seekBar");if(seekBar){var mouseTimeDisplay=seekBar.getChild("mouseTimeDisplay");var seekBarEl=seekBar.el();var seekBarRect=getBoundingClientRect(seekBarEl);var seekBarPoint=getPointerPosition(seekBarEl,event).x;if(seekBarPoint>1){seekBarPoint=1}else if(seekBarPoint<0){seekBarPoint=0}if(mouseTimeDisplay){mouseTimeDisplay.update(seekBarRect,seekBarPoint)}}};_proto.handleMouseSeek=function handleMouseSeek(event){var seekBar=this.getChild("seekBar");if(seekBar){seekBar.handleMouseMove(event)}};_proto.enabled=function enabled(){return this.enabled_};_proto.disable=function disable(){this.children().forEach(function(child){return child.disable&&child.disable()});if(!this.enabled()){return}this.off(["mousedown","touchstart"],this.handleMouseDown);this.off(this.el_,"mousemove",this.handleMouseMove);this.handleMouseUp();this.addClass("disabled");this.enabled_=false};_proto.enable=function enable(){this.children().forEach(function(child){return child.enable&&child.enable()});if(this.enabled()){return}this.on(["mousedown","touchstart"],this.handleMouseDown);this.on(this.el_,"mousemove",this.handleMouseMove);this.removeClass("disabled");this.enabled_=true};_proto.handleMouseDown=function handleMouseDown(event){var doc=this.el_.ownerDocument;var seekBar=this.getChild("seekBar");if(seekBar){seekBar.handleMouseDown(event)}this.on(doc,"mousemove",this.throttledHandleMouseSeek);this.on(doc,"touchmove",this.throttledHandleMouseSeek);this.on(doc,"mouseup",this.handleMouseUp);this.on(doc,"touchend",this.handleMouseUp)};_proto.handleMouseUp=function handleMouseUp(event){var doc=this.el_.ownerDocument;var seekBar=this.getChild("seekBar");if(seekBar){seekBar.handleMouseUp(event)}this.off(doc,"mousemove",this.throttledHandleMouseSeek);this.off(doc,"touchmove",this.throttledHandleMouseSeek);this.off(doc,"mouseup",this.handleMouseUp);this.off(doc,"touchend",this.handleMouseUp)};return ProgressControl}(Component);ProgressControl.prototype.options_={children:["seekBar"]};Component.registerComponent("ProgressControl",ProgressControl);var PictureInPictureToggle=function(_Button){_inheritsLoose(PictureInPictureToggle,_Button);function PictureInPictureToggle(player,options){var _this;_this=_Button.call(this,player,options)||this;_this.on(player,["enterpictureinpicture","leavepictureinpicture"],_this.handlePictureInPictureChange);if(!document.pictureInPictureEnabled){_this.disable()}return _this}var _proto=PictureInPictureToggle.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-picture-in-picture-control "+_Button.prototype.buildCSSClass.call(this)};_proto.handlePictureInPictureChange=function handlePictureInPictureChange(event){if(this.player_.isInPictureInPicture()){this.controlText("Exit Picture-in-Picture")}else{this.controlText("Picture-in-Picture")}};_proto.handleClick=function handleClick(event){if(!this.player_.isInPictureInPicture()){this.player_.requestPictureInPicture()}else{this.player_.exitPictureInPicture()}};return PictureInPictureToggle}(Button);PictureInPictureToggle.prototype.controlText_="Picture-in-Picture";Component.registerComponent("PictureInPictureToggle",PictureInPictureToggle);var FullscreenToggle=function(_Button){_inheritsLoose(FullscreenToggle,_Button);function FullscreenToggle(player,options){var _this;_this=_Button.call(this,player,options)||this;_this.on(player,"fullscreenchange",_this.handleFullscreenChange);if(document[player.fsApi_.fullscreenEnabled]===false){_this.disable()}return _this}var _proto=FullscreenToggle.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-fullscreen-control "+_Button.prototype.buildCSSClass.call(this)};_proto.handleFullscreenChange=function handleFullscreenChange(event){if(this.player_.isFullscreen()){this.controlText("Non-Fullscreen")}else{this.controlText("Fullscreen")}};_proto.handleClick=function handleClick(event){if(!this.player_.isFullscreen()){this.player_.requestFullscreen()}else{this.player_.exitFullscreen()}};return FullscreenToggle}(Button);FullscreenToggle.prototype.controlText_="Fullscreen";Component.registerComponent("FullscreenToggle",FullscreenToggle);var checkVolumeSupport=function checkVolumeSupport(self,player){if(player.tech_&&!player.tech_.featuresVolumeControl){self.addClass("vjs-hidden")}self.on(player,"loadstart",function(){if(!player.tech_.featuresVolumeControl){self.addClass("vjs-hidden")}else{self.removeClass("vjs-hidden")}})};var VolumeLevel=function(_Component){_inheritsLoose(VolumeLevel,_Component);function VolumeLevel(){return _Component.apply(this,arguments)||this}var _proto=VolumeLevel.prototype;_proto.createEl=function createEl(){return _Component.prototype.createEl.call(this,"div",{className:"vjs-volume-level",innerHTML:'<span class="vjs-control-text"></span>'})};return VolumeLevel}(Component);Component.registerComponent("VolumeLevel",VolumeLevel);var VolumeBar=function(_Slider){_inheritsLoose(VolumeBar,_Slider);function VolumeBar(player,options){var _this;_this=_Slider.call(this,player,options)||this;_this.on("slideractive",_this.updateLastVolume_);_this.on(player,"volumechange",_this.updateARIAAttributes);player.ready(function(){return _this.updateARIAAttributes()});return _this}var _proto=VolumeBar.prototype;_proto.createEl=function createEl(){return _Slider.prototype.createEl.call(this,"div",{className:"vjs-volume-bar vjs-slider-bar"},{"aria-label":this.localize("Volume Level"),"aria-live":"polite"})};_proto.handleMouseDown=function handleMouseDown(event){if(!isSingleLeftClick(event)){return}_Slider.prototype.handleMouseDown.call(this,event)};_proto.handleMouseMove=function handleMouseMove(event){if(!isSingleLeftClick(event)){return}this.checkMuted();this.player_.volume(this.calculateDistance(event))};_proto.checkMuted=function checkMuted(){if(this.player_.muted()){this.player_.muted(false)}};_proto.getPercent=function getPercent(){if(this.player_.muted()){return 0}return this.player_.volume()};_proto.stepForward=function stepForward(){this.checkMuted();this.player_.volume(this.player_.volume()+.1)};_proto.stepBack=function stepBack(){this.checkMuted();this.player_.volume(this.player_.volume()-.1)};_proto.updateARIAAttributes=function updateARIAAttributes(event){var ariaValue=this.player_.muted()?0:this.volumeAsPercentage_();this.el_.setAttribute("aria-valuenow",ariaValue);this.el_.setAttribute("aria-valuetext",ariaValue+"%")};_proto.volumeAsPercentage_=function volumeAsPercentage_(){return Math.round(this.player_.volume()*100)};_proto.updateLastVolume_=function updateLastVolume_(){var _this2=this;var volumeBeforeDrag=this.player_.volume();this.one("sliderinactive",function(){if(_this2.player_.volume()===0){_this2.player_.lastVolume_(volumeBeforeDrag)}})};return VolumeBar}(Slider);VolumeBar.prototype.options_={children:["volumeLevel"],barName:"volumeLevel"};VolumeBar.prototype.playerEvent="volumechange";Component.registerComponent("VolumeBar",VolumeBar);var VolumeControl=function(_Component){_inheritsLoose(VolumeControl,_Component);function VolumeControl(player,options){var _this;if(options===void 0){options={}}options.vertical=options.vertical||false;if(typeof options.volumeBar==="undefined"||isPlain(options.volumeBar)){options.volumeBar=options.volumeBar||{};options.volumeBar.vertical=options.vertical}_this=_Component.call(this,player,options)||this;checkVolumeSupport(_assertThisInitialized(_this),player);_this.throttledHandleMouseMove=throttle(bind(_assertThisInitialized(_this),_this.handleMouseMove),UPDATE_REFRESH_INTERVAL);_this.on("mousedown",_this.handleMouseDown);_this.on("touchstart",_this.handleMouseDown);_this.on(_this.volumeBar,["focus","slideractive"],function(){_this.volumeBar.addClass("vjs-slider-active");_this.addClass("vjs-slider-active");_this.trigger("slideractive")});_this.on(_this.volumeBar,["blur","sliderinactive"],function(){_this.volumeBar.removeClass("vjs-slider-active");_this.removeClass("vjs-slider-active");_this.trigger("sliderinactive")});return _this}var _proto=VolumeControl.prototype;_proto.createEl=function createEl(){var orientationClass="vjs-volume-horizontal";if(this.options_.vertical){orientationClass="vjs-volume-vertical"}return _Component.prototype.createEl.call(this,"div",{className:"vjs-volume-control vjs-control "+orientationClass})};_proto.handleMouseDown=function handleMouseDown(event){var doc=this.el_.ownerDocument;this.on(doc,"mousemove",this.throttledHandleMouseMove);this.on(doc,"touchmove",this.throttledHandleMouseMove);this.on(doc,"mouseup",this.handleMouseUp);this.on(doc,"touchend",this.handleMouseUp)};_proto.handleMouseUp=function handleMouseUp(event){var doc=this.el_.ownerDocument;this.off(doc,"mousemove",this.throttledHandleMouseMove);this.off(doc,"touchmove",this.throttledHandleMouseMove);this.off(doc,"mouseup",this.handleMouseUp);this.off(doc,"touchend",this.handleMouseUp)};_proto.handleMouseMove=function handleMouseMove(event){this.volumeBar.handleMouseMove(event)};return VolumeControl}(Component);VolumeControl.prototype.options_={children:["volumeBar"]};Component.registerComponent("VolumeControl",VolumeControl);var checkMuteSupport=function checkMuteSupport(self,player){if(player.tech_&&!player.tech_.featuresMuteControl){self.addClass("vjs-hidden")}self.on(player,"loadstart",function(){if(!player.tech_.featuresMuteControl){self.addClass("vjs-hidden")}else{self.removeClass("vjs-hidden")}})};var MuteToggle=function(_Button){_inheritsLoose(MuteToggle,_Button);function MuteToggle(player,options){var _this;_this=_Button.call(this,player,options)||this;checkMuteSupport(_assertThisInitialized(_this),player);_this.on(player,["loadstart","volumechange"],_this.update);return _this}var _proto=MuteToggle.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-mute-control "+_Button.prototype.buildCSSClass.call(this)};_proto.handleClick=function handleClick(event){var vol=this.player_.volume();var lastVolume=this.player_.lastVolume_();if(vol===0){var volumeToSet=lastVolume<.1?.1:lastVolume;this.player_.volume(volumeToSet);this.player_.muted(false)}else{this.player_.muted(this.player_.muted()?false:true)}};_proto.update=function update(event){this.updateIcon_();this.updateControlText_()};_proto.updateIcon_=function updateIcon_(){var vol=this.player_.volume();var level=3;if(IS_IOS&&this.player_.tech_&&this.player_.tech_.el_){this.player_.muted(this.player_.tech_.el_.muted)}if(vol===0||this.player_.muted()){level=0}else if(vol<.33){level=1}else if(vol<.67){level=2}for(var i=0;i<4;i++){removeClass(this.el_,"vjs-vol-"+i)}addClass(this.el_,"vjs-vol-"+level)};_proto.updateControlText_=function updateControlText_(){var soundOff=this.player_.muted()||this.player_.volume()===0;var text=soundOff?"Unmute":"Mute";if(this.controlText()!==text){this.controlText(text)}};return MuteToggle}(Button);MuteToggle.prototype.controlText_="Mute";Component.registerComponent("MuteToggle",MuteToggle);var VolumePanel=function(_Component){_inheritsLoose(VolumePanel,_Component);function VolumePanel(player,options){var _this;if(options===void 0){options={}}if(typeof options.inline!=="undefined"){options.inline=options.inline}else{options.inline=true}if(typeof options.volumeControl==="undefined"||isPlain(options.volumeControl)){options.volumeControl=options.volumeControl||{};options.volumeControl.vertical=!options.inline}_this=_Component.call(this,player,options)||this;_this.on(player,["loadstart"],_this.volumePanelState_);_this.on(_this.muteToggle,"keyup",_this.handleKeyPress);_this.on(_this.volumeControl,"keyup",_this.handleVolumeControlKeyUp);_this.on("keydown",_this.handleKeyPress);_this.on("mouseover",_this.handleMouseOver);_this.on("mouseout",_this.handleMouseOut);_this.on(_this.volumeControl,["slideractive"],_this.sliderActive_);_this.on(_this.volumeControl,["sliderinactive"],_this.sliderInactive_);return _this}var _proto=VolumePanel.prototype;_proto.sliderActive_=function sliderActive_(){this.addClass("vjs-slider-active")};_proto.sliderInactive_=function sliderInactive_(){this.removeClass("vjs-slider-active")};_proto.volumePanelState_=function volumePanelState_(){if(this.volumeControl.hasClass("vjs-hidden")&&this.muteToggle.hasClass("vjs-hidden")){this.addClass("vjs-hidden")}if(this.volumeControl.hasClass("vjs-hidden")&&!this.muteToggle.hasClass("vjs-hidden")){this.addClass("vjs-mute-toggle-only")}};_proto.createEl=function createEl(){var orientationClass="vjs-volume-panel-horizontal";if(!this.options_.inline){orientationClass="vjs-volume-panel-vertical"}return _Component.prototype.createEl.call(this,"div",{className:"vjs-volume-panel vjs-control "+orientationClass})};_proto.dispose=function dispose(){this.handleMouseOut();_Component.prototype.dispose.call(this)};_proto.handleVolumeControlKeyUp=function handleVolumeControlKeyUp(event){if(keycode.isEventKey(event,"Esc")){this.muteToggle.focus()}};_proto.handleMouseOver=function handleMouseOver(event){this.addClass("vjs-hover");on(document,"keyup",bind(this,this.handleKeyPress))};_proto.handleMouseOut=function handleMouseOut(event){this.removeClass("vjs-hover");off(document,"keyup",bind(this,this.handleKeyPress))};_proto.handleKeyPress=function handleKeyPress(event){if(keycode.isEventKey(event,"Esc")){this.handleMouseOut()}};return VolumePanel}(Component);VolumePanel.prototype.options_={children:["muteToggle","volumeControl"]};Component.registerComponent("VolumePanel",VolumePanel);var Menu=function(_Component){_inheritsLoose(Menu,_Component);function Menu(player,options){var _this;_this=_Component.call(this,player,options)||this;if(options){_this.menuButton_=options.menuButton}_this.focusedChild_=-1;_this.on("keydown",_this.handleKeyDown);_this.boundHandleBlur_=bind(_assertThisInitialized(_this),_this.handleBlur);_this.boundHandleTapClick_=bind(_assertThisInitialized(_this),_this.handleTapClick);return _this}var _proto=Menu.prototype;_proto.addEventListenerForItem=function addEventListenerForItem(component){if(!(component instanceof Component)){return}this.on(component,"blur",this.boundHandleBlur_);this.on(component,["tap","click"],this.boundHandleTapClick_)};_proto.removeEventListenerForItem=function removeEventListenerForItem(component){if(!(component instanceof Component)){return}this.off(component,"blur",this.boundHandleBlur_);this.off(component,["tap","click"],this.boundHandleTapClick_)};_proto.removeChild=function removeChild(component){if(typeof component==="string"){component=this.getChild(component)}this.removeEventListenerForItem(component);_Component.prototype.removeChild.call(this,component)};_proto.addItem=function addItem(component){var childComponent=this.addChild(component);if(childComponent){this.addEventListenerForItem(childComponent)}};_proto.createEl=function createEl$1(){var contentElType=this.options_.contentElType||"ul";this.contentEl_=createEl(contentElType,{className:"vjs-menu-content"});this.contentEl_.setAttribute("role","menu");var el=_Component.prototype.createEl.call(this,"div",{append:this.contentEl_,className:"vjs-menu"});el.appendChild(this.contentEl_);on(el,"click",function(event){event.preventDefault();event.stopImmediatePropagation()});return el};_proto.dispose=function dispose(){this.contentEl_=null;this.boundHandleBlur_=null;this.boundHandleTapClick_=null;_Component.prototype.dispose.call(this)};_proto.handleBlur=function handleBlur(event){var relatedTarget=event.relatedTarget||document.activeElement;if(!this.children().some(function(element){return element.el()===relatedTarget})){var btn=this.menuButton_;if(btn&&btn.buttonPressed_&&relatedTarget!==btn.el().firstChild){btn.unpressButton()}}};_proto.handleTapClick=function handleTapClick(event){if(this.menuButton_){this.menuButton_.unpressButton();var childComponents=this.children();if(!Array.isArray(childComponents)){return}var foundComponent=childComponents.filter(function(component){return component.el()===event.target})[0];if(!foundComponent){return}if(foundComponent.name()!=="CaptionSettingsMenuItem"){this.menuButton_.focus()}}};_proto.handleKeyDown=function handleKeyDown(event){if(keycode.isEventKey(event,"Left")||keycode.isEventKey(event,"Down")){event.preventDefault();event.stopPropagation();this.stepForward()}else if(keycode.isEventKey(event,"Right")||keycode.isEventKey(event,"Up")){event.preventDefault();event.stopPropagation();this.stepBack()}};_proto.stepForward=function stepForward(){var stepChild=0;if(this.focusedChild_!==undefined){stepChild=this.focusedChild_+1}this.focus(stepChild)};_proto.stepBack=function stepBack(){var stepChild=0;if(this.focusedChild_!==undefined){stepChild=this.focusedChild_-1}this.focus(stepChild)};_proto.focus=function focus(item){if(item===void 0){item=0}var children=this.children().slice();var haveTitle=children.length&&children[0].className&&/vjs-menu-title/.test(children[0].className);if(haveTitle){children.shift()}if(children.length>0){if(item<0){item=0}else if(item>=children.length){item=children.length-1}this.focusedChild_=item;children[item].el_.focus()}};return Menu}(Component);Component.registerComponent("Menu",Menu);var MenuButton=function(_Component){_inheritsLoose(MenuButton,_Component);function MenuButton(player,options){var _this;if(options===void 0){options={}}_this=_Component.call(this,player,options)||this;_this.menuButton_=new Button(player,options);_this.menuButton_.controlText(_this.controlText_);_this.menuButton_.el_.setAttribute("aria-haspopup","true");var buttonClass=Button.prototype.buildCSSClass();_this.menuButton_.el_.className=_this.buildCSSClass()+" "+buttonClass;_this.menuButton_.removeClass("vjs-control");_this.addChild(_this.menuButton_);_this.update();_this.enabled_=true;_this.on(_this.menuButton_,"tap",_this.handleClick);_this.on(_this.menuButton_,"click",_this.handleClick);_this.on(_this.menuButton_,"keydown",_this.handleKeyDown);_this.on(_this.menuButton_,"mouseenter",function(){_this.addClass("vjs-hover");_this.menu.show();on(document,"keyup",bind(_assertThisInitialized(_this),_this.handleMenuKeyUp))});_this.on("mouseleave",_this.handleMouseLeave);_this.on("keydown",_this.handleSubmenuKeyDown);return _this}var _proto=MenuButton.prototype;_proto.update=function update(){var menu=this.createMenu();if(this.menu){this.menu.dispose();this.removeChild(this.menu)}this.menu=menu;this.addChild(menu);this.buttonPressed_=false;this.menuButton_.el_.setAttribute("aria-expanded","false");if(this.items&&this.items.length<=this.hideThreshold_){this.hide()}else{this.show()}};_proto.createMenu=function createMenu(){var menu=new Menu(this.player_,{menuButton:this});this.hideThreshold_=0;if(this.options_.title){var titleEl=createEl("li",{className:"vjs-menu-title",innerHTML:toTitleCase(this.options_.title),tabIndex:-1});this.hideThreshold_+=1;var titleComponent=new Component(this.player_,{el:titleEl});menu.addItem(titleComponent)}this.items=this.createItems();if(this.items){for(var i=0;i<this.items.length;i++){menu.addItem(this.items[i])}}return menu};_proto.createItems=function createItems(){};_proto.createEl=function createEl(){return _Component.prototype.createEl.call(this,"div",{className:this.buildWrapperCSSClass()},{})};_proto.buildWrapperCSSClass=function buildWrapperCSSClass(){var menuButtonClass="vjs-menu-button";if(this.options_.inline===true){menuButtonClass+="-inline"}else{menuButtonClass+="-popup"}var buttonClass=Button.prototype.buildCSSClass();return"vjs-menu-button "+menuButtonClass+" "+buttonClass+" "+_Component.prototype.buildCSSClass.call(this)};_proto.buildCSSClass=function buildCSSClass(){var menuButtonClass="vjs-menu-button";if(this.options_.inline===true){menuButtonClass+="-inline"}else{menuButtonClass+="-popup"}return"vjs-menu-button "+menuButtonClass+" "+_Component.prototype.buildCSSClass.call(this)};_proto.controlText=function controlText(text,el){if(el===void 0){el=this.menuButton_.el()}return this.menuButton_.controlText(text,el)};_proto.dispose=function dispose(){this.handleMouseLeave();_Component.prototype.dispose.call(this)};_proto.handleClick=function handleClick(event){if(this.buttonPressed_){this.unpressButton()}else{this.pressButton()}};_proto.handleMouseLeave=function handleMouseLeave(event){this.removeClass("vjs-hover");off(document,"keyup",bind(this,this.handleMenuKeyUp))};_proto.focus=function focus(){this.menuButton_.focus()};_proto.blur=function blur(){this.menuButton_.blur()};_proto.handleKeyDown=function handleKeyDown(event){if(keycode.isEventKey(event,"Esc")||keycode.isEventKey(event,"Tab")){if(this.buttonPressed_){this.unpressButton()}if(!keycode.isEventKey(event,"Tab")){event.preventDefault();this.menuButton_.focus()}}else if(keycode.isEventKey(event,"Up")||keycode.isEventKey(event,"Down")){if(!this.buttonPressed_){event.preventDefault();this.pressButton()}}};_proto.handleMenuKeyUp=function handleMenuKeyUp(event){if(keycode.isEventKey(event,"Esc")||keycode.isEventKey(event,"Tab")){this.removeClass("vjs-hover")}};_proto.handleSubmenuKeyPress=function handleSubmenuKeyPress(event){this.handleSubmenuKeyDown(event)};_proto.handleSubmenuKeyDown=function handleSubmenuKeyDown(event){if(keycode.isEventKey(event,"Esc")||keycode.isEventKey(event,"Tab")){if(this.buttonPressed_){this.unpressButton()}if(!keycode.isEventKey(event,"Tab")){event.preventDefault();this.menuButton_.focus()}}};_proto.pressButton=function pressButton(){if(this.enabled_){this.buttonPressed_=true;this.menu.show();this.menu.lockShowing();this.menuButton_.el_.setAttribute("aria-expanded","true");if(IS_IOS&&isInFrame()){return}this.menu.focus()}};_proto.unpressButton=function unpressButton(){if(this.enabled_){this.buttonPressed_=false;this.menu.unlockShowing();this.menu.hide();this.menuButton_.el_.setAttribute("aria-expanded","false")}};_proto.disable=function disable(){this.unpressButton();this.enabled_=false;this.addClass("vjs-disabled");this.menuButton_.disable()};_proto.enable=function enable(){this.enabled_=true;this.removeClass("vjs-disabled");this.menuButton_.enable()};return MenuButton}(Component);Component.registerComponent("MenuButton",MenuButton);var TrackButton=function(_MenuButton){_inheritsLoose(TrackButton,_MenuButton);function TrackButton(player,options){var _this;var tracks=options.tracks;_this=_MenuButton.call(this,player,options)||this;if(_this.items.length<=1){_this.hide()}if(!tracks){return _assertThisInitialized(_this)}var updateHandler=bind(_assertThisInitialized(_this),_this.update);tracks.addEventListener("removetrack",updateHandler);tracks.addEventListener("addtrack",updateHandler);_this.player_.on("ready",updateHandler);_this.player_.on("dispose",function(){tracks.removeEventListener("removetrack",updateHandler);tracks.removeEventListener("addtrack",updateHandler)});return _this}return TrackButton}(MenuButton);Component.registerComponent("TrackButton",TrackButton);var MenuKeys=["Tab","Esc","Up","Down","Right","Left"];var MenuItem=function(_ClickableComponent){_inheritsLoose(MenuItem,_ClickableComponent);function MenuItem(player,options){var _this;_this=_ClickableComponent.call(this,player,options)||this;_this.selectable=options.selectable;_this.isSelected_=options.selected||false;_this.multiSelectable=options.multiSelectable;_this.selected(_this.isSelected_);if(_this.selectable){if(_this.multiSelectable){_this.el_.setAttribute("role","menuitemcheckbox")}else{_this.el_.setAttribute("role","menuitemradio")}}else{_this.el_.setAttribute("role","menuitem")}return _this}var _proto=MenuItem.prototype;_proto.createEl=function createEl(type,props,attrs){this.nonIconControl=true;return _ClickableComponent.prototype.createEl.call(this,"li",assign({className:"vjs-menu-item",innerHTML:'<span class="vjs-menu-item-text">'+this.localize(this.options_.label)+"</span>",tabIndex:-1},props),attrs)};_proto.handleKeyDown=function handleKeyDown(event){if(!MenuKeys.some(function(key){return keycode.isEventKey(event,key)})){_ClickableComponent.prototype.handleKeyDown.call(this,event)}};_proto.handleClick=function handleClick(event){this.selected(true)};_proto.selected=function selected(_selected){if(this.selectable){if(_selected){this.addClass("vjs-selected");this.el_.setAttribute("aria-checked","true");this.controlText(", selected");this.isSelected_=true}else{this.removeClass("vjs-selected");this.el_.setAttribute("aria-checked","false");this.controlText("");this.isSelected_=false}}};return MenuItem}(ClickableComponent);Component.registerComponent("MenuItem",MenuItem);var TextTrackMenuItem=function(_MenuItem){_inheritsLoose(TextTrackMenuItem,_MenuItem);function TextTrackMenuItem(player,options){var _this;var track=options.track;var tracks=player.textTracks();options.label=track.label||track.language||"Unknown";options.selected=track.mode==="showing";_this=_MenuItem.call(this,player,options)||this;_this.track=track;_this.kinds=(options.kinds||[options.kind||_this.track.kind]).filter(Boolean);var changeHandler=function changeHandler(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}_this.handleTracksChange.apply(_assertThisInitialized(_this),args)};var selectedLanguageChangeHandler=function selectedLanguageChangeHandler(){for(var _len2=arguments.length,args=new Array(_len2),_key2=0;_key2<_len2;_key2++){args[_key2]=arguments[_key2]}_this.handleSelectedLanguageChange.apply(_assertThisInitialized(_this),args)};player.on(["loadstart","texttrackchange"],changeHandler);tracks.addEventListener("change",changeHandler);tracks.addEventListener("selectedlanguagechange",selectedLanguageChangeHandler);_this.on("dispose",function(){player.off(["loadstart","texttrackchange"],changeHandler);tracks.removeEventListener("change",changeHandler);tracks.removeEventListener("selectedlanguagechange",selectedLanguageChangeHandler)});if(tracks.onchange===undefined){var event;_this.on(["tap","click"],function(){if(typeof window$1.Event!=="object"){try{event=new window$1.Event("change")}catch(err){}}if(!event){event=document.createEvent("Event");event.initEvent("change",true,true)}tracks.dispatchEvent(event)})}_this.handleTracksChange();return _this}var _proto=TextTrackMenuItem.prototype;_proto.handleClick=function handleClick(event){var referenceTrack=this.track;var tracks=this.player_.textTracks();_MenuItem.prototype.handleClick.call(this,event);if(!tracks){return}for(var i=0;i<tracks.length;i++){var track=tracks[i];if(this.kinds.indexOf(track.kind)===-1){continue}if(track===referenceTrack){if(track.mode!=="showing"){track.mode="showing"}}else if(track.mode!=="disabled"){track.mode="disabled"}}};_proto.handleTracksChange=function handleTracksChange(event){var shouldBeSelected=this.track.mode==="showing";if(shouldBeSelected!==this.isSelected_){this.selected(shouldBeSelected)}};_proto.handleSelectedLanguageChange=function handleSelectedLanguageChange(event){if(this.track.mode==="showing"){var selectedLanguage=this.player_.cache_.selectedLanguage;if(selectedLanguage&&selectedLanguage.enabled&&selectedLanguage.language===this.track.language&&selectedLanguage.kind!==this.track.kind){return}this.player_.cache_.selectedLanguage={enabled:true,language:this.track.language,kind:this.track.kind}}};_proto.dispose=function dispose(){this.track=null;_MenuItem.prototype.dispose.call(this)};return TextTrackMenuItem}(MenuItem);Component.registerComponent("TextTrackMenuItem",TextTrackMenuItem);var OffTextTrackMenuItem=function(_TextTrackMenuItem){_inheritsLoose(OffTextTrackMenuItem,_TextTrackMenuItem);function OffTextTrackMenuItem(player,options){options.track={player:player,kind:options.kind,kinds:options.kinds,default:false,mode:"disabled"};if(!options.kinds){options.kinds=[options.kind]}if(options.label){options.track.label=options.label}else{options.track.label=options.kinds.join(" and ")+" off"}options.selectable=true;options.multiSelectable=false;return _TextTrackMenuItem.call(this,player,options)||this}var _proto=OffTextTrackMenuItem.prototype;_proto.handleTracksChange=function handleTracksChange(event){var tracks=this.player().textTracks();var shouldBeSelected=true;for(var i=0,l=tracks.length;i<l;i++){var track=tracks[i];if(this.options_.kinds.indexOf(track.kind)>-1&&track.mode==="showing"){shouldBeSelected=false;break}}if(shouldBeSelected!==this.isSelected_){this.selected(shouldBeSelected)}};_proto.handleSelectedLanguageChange=function handleSelectedLanguageChange(event){var tracks=this.player().textTracks();var allHidden=true;for(var i=0,l=tracks.length;i<l;i++){var track=tracks[i];if(["captions","descriptions","subtitles"].indexOf(track.kind)>-1&&track.mode==="showing"){allHidden=false;break}}if(allHidden){this.player_.cache_.selectedLanguage={enabled:false}}};return OffTextTrackMenuItem}(TextTrackMenuItem);Component.registerComponent("OffTextTrackMenuItem",OffTextTrackMenuItem);var TextTrackButton=function(_TrackButton){_inheritsLoose(TextTrackButton,_TrackButton);function TextTrackButton(player,options){if(options===void 0){options={}}options.tracks=player.textTracks();return _TrackButton.call(this,player,options)||this}var _proto=TextTrackButton.prototype;_proto.createItems=function createItems(items,TrackMenuItem){if(items===void 0){items=[]}if(TrackMenuItem===void 0){TrackMenuItem=TextTrackMenuItem}var label;if(this.label_){label=this.label_+" off"}items.push(new OffTextTrackMenuItem(this.player_,{kinds:this.kinds_,kind:this.kind_,label:label}));this.hideThreshold_+=1;var tracks=this.player_.textTracks();if(!Array.isArray(this.kinds_)){this.kinds_=[this.kind_]}for(var i=0;i<tracks.length;i++){var track=tracks[i];if(this.kinds_.indexOf(track.kind)>-1){var item=new TrackMenuItem(this.player_,{track:track,kinds:this.kinds_,kind:this.kind_,selectable:true,multiSelectable:false});item.addClass("vjs-"+track.kind+"-menu-item");items.push(item)}}return items};return TextTrackButton}(TrackButton);Component.registerComponent("TextTrackButton",TextTrackButton);var ChaptersTrackMenuItem=function(_MenuItem){_inheritsLoose(ChaptersTrackMenuItem,_MenuItem);function ChaptersTrackMenuItem(player,options){var _this;var track=options.track;var cue=options.cue;var currentTime=player.currentTime();options.selectable=true;options.multiSelectable=false;options.label=cue.text;options.selected=cue.startTime<=currentTime&&currentTime<cue.endTime;_this=_MenuItem.call(this,player,options)||this;_this.track=track;_this.cue=cue;track.addEventListener("cuechange",bind(_assertThisInitialized(_this),_this.update));return _this}var _proto=ChaptersTrackMenuItem.prototype;_proto.handleClick=function handleClick(event){_MenuItem.prototype.handleClick.call(this);this.player_.currentTime(this.cue.startTime);this.update(this.cue.startTime)};_proto.update=function update(event){var cue=this.cue;var currentTime=this.player_.currentTime();this.selected(cue.startTime<=currentTime&&currentTime<cue.endTime)};return ChaptersTrackMenuItem}(MenuItem);Component.registerComponent("ChaptersTrackMenuItem",ChaptersTrackMenuItem);var ChaptersButton=function(_TextTrackButton){_inheritsLoose(ChaptersButton,_TextTrackButton);function ChaptersButton(player,options,ready){return _TextTrackButton.call(this,player,options,ready)||this}var _proto=ChaptersButton.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-chapters-button "+_TextTrackButton.prototype.buildCSSClass.call(this)};_proto.buildWrapperCSSClass=function buildWrapperCSSClass(){return"vjs-chapters-button "+_TextTrackButton.prototype.buildWrapperCSSClass.call(this)};_proto.update=function update(event){if(!this.track_||event&&(event.type==="addtrack"||event.type==="removetrack")){this.setTrack(this.findChaptersTrack())}_TextTrackButton.prototype.update.call(this)};_proto.setTrack=function setTrack(track){if(this.track_===track){return}if(!this.updateHandler_){this.updateHandler_=this.update.bind(this)}if(this.track_){var remoteTextTrackEl=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);if(remoteTextTrackEl){remoteTextTrackEl.removeEventListener("load",this.updateHandler_)}this.track_=null}this.track_=track;if(this.track_){this.track_.mode="hidden";var _remoteTextTrackEl=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);if(_remoteTextTrackEl){_remoteTextTrackEl.addEventListener("load",this.updateHandler_)}}};_proto.findChaptersTrack=function findChaptersTrack(){var tracks=this.player_.textTracks()||[];for(var i=tracks.length-1;i>=0;i--){var track=tracks[i];if(track.kind===this.kind_){return track}}};_proto.getMenuCaption=function getMenuCaption(){if(this.track_&&this.track_.label){return this.track_.label}return this.localize(toTitleCase(this.kind_))};_proto.createMenu=function createMenu(){this.options_.title=this.getMenuCaption();return _TextTrackButton.prototype.createMenu.call(this)};_proto.createItems=function createItems(){var items=[];if(!this.track_){return items}var cues=this.track_.cues;if(!cues){return items}for(var i=0,l=cues.length;i<l;i++){var cue=cues[i];var mi=new ChaptersTrackMenuItem(this.player_,{track:this.track_,cue:cue});items.push(mi)}return items};return ChaptersButton}(TextTrackButton);ChaptersButton.prototype.kind_="chapters";ChaptersButton.prototype.controlText_="Chapters";Component.registerComponent("ChaptersButton",ChaptersButton);var DescriptionsButton=function(_TextTrackButton){_inheritsLoose(DescriptionsButton,_TextTrackButton);function DescriptionsButton(player,options,ready){var _this;_this=_TextTrackButton.call(this,player,options,ready)||this;var tracks=player.textTracks();var changeHandler=bind(_assertThisInitialized(_this),_this.handleTracksChange);tracks.addEventListener("change",changeHandler);_this.on("dispose",function(){tracks.removeEventListener("change",changeHandler)});return _this}var _proto=DescriptionsButton.prototype;_proto.handleTracksChange=function handleTracksChange(event){var tracks=this.player().textTracks();var disabled=false;for(var i=0,l=tracks.length;i<l;i++){var track=tracks[i];if(track.kind!==this.kind_&&track.mode==="showing"){disabled=true;break}}if(disabled){this.disable()}else{this.enable()}};_proto.buildCSSClass=function buildCSSClass(){return"vjs-descriptions-button "+_TextTrackButton.prototype.buildCSSClass.call(this)};_proto.buildWrapperCSSClass=function buildWrapperCSSClass(){return"vjs-descriptions-button "+_TextTrackButton.prototype.buildWrapperCSSClass.call(this)};return DescriptionsButton}(TextTrackButton);DescriptionsButton.prototype.kind_="descriptions";DescriptionsButton.prototype.controlText_="Descriptions";Component.registerComponent("DescriptionsButton",DescriptionsButton);var SubtitlesButton=function(_TextTrackButton){_inheritsLoose(SubtitlesButton,_TextTrackButton);function SubtitlesButton(player,options,ready){return _TextTrackButton.call(this,player,options,ready)||this}var _proto=SubtitlesButton.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-subtitles-button "+_TextTrackButton.prototype.buildCSSClass.call(this)};_proto.buildWrapperCSSClass=function buildWrapperCSSClass(){return"vjs-subtitles-button "+_TextTrackButton.prototype.buildWrapperCSSClass.call(this)};return SubtitlesButton}(TextTrackButton);SubtitlesButton.prototype.kind_="subtitles";SubtitlesButton.prototype.controlText_="Subtitles";Component.registerComponent("SubtitlesButton",SubtitlesButton);var CaptionSettingsMenuItem=function(_TextTrackMenuItem){_inheritsLoose(CaptionSettingsMenuItem,_TextTrackMenuItem);function CaptionSettingsMenuItem(player,options){var _this;options.track={player:player,kind:options.kind,label:options.kind+" settings",selectable:false,default:false,mode:"disabled"};options.selectable=false;options.name="CaptionSettingsMenuItem";_this=_TextTrackMenuItem.call(this,player,options)||this;_this.addClass("vjs-texttrack-settings");_this.controlText(", opens "+options.kind+" settings dialog");return _this}var _proto=CaptionSettingsMenuItem.prototype;_proto.handleClick=function handleClick(event){this.player().getChild("textTrackSettings").open()};return CaptionSettingsMenuItem}(TextTrackMenuItem);Component.registerComponent("CaptionSettingsMenuItem",CaptionSettingsMenuItem);var CaptionsButton=function(_TextTrackButton){_inheritsLoose(CaptionsButton,_TextTrackButton);function CaptionsButton(player,options,ready){return _TextTrackButton.call(this,player,options,ready)||this}var _proto=CaptionsButton.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-captions-button "+_TextTrackButton.prototype.buildCSSClass.call(this)};_proto.buildWrapperCSSClass=function buildWrapperCSSClass(){return"vjs-captions-button "+_TextTrackButton.prototype.buildWrapperCSSClass.call(this)};_proto.createItems=function createItems(){var items=[];if(!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings")){items.push(new CaptionSettingsMenuItem(this.player_,{kind:this.kind_}));this.hideThreshold_+=1}return _TextTrackButton.prototype.createItems.call(this,items)};return CaptionsButton}(TextTrackButton);CaptionsButton.prototype.kind_="captions";CaptionsButton.prototype.controlText_="Captions";Component.registerComponent("CaptionsButton",CaptionsButton);var SubsCapsMenuItem=function(_TextTrackMenuItem){_inheritsLoose(SubsCapsMenuItem,_TextTrackMenuItem);function SubsCapsMenuItem(){return _TextTrackMenuItem.apply(this,arguments)||this}var _proto=SubsCapsMenuItem.prototype;_proto.createEl=function createEl(type,props,attrs){var innerHTML='<span class="vjs-menu-item-text">'+this.localize(this.options_.label);if(this.options_.track.kind==="captions"){innerHTML+='\n <span aria-hidden="true" class="vjs-icon-placeholder"></span>\n <span class="vjs-control-text"> '+this.localize("Captions")+"</span>\n "}innerHTML+="</span>";var el=_TextTrackMenuItem.prototype.createEl.call(this,type,assign({innerHTML:innerHTML},props),attrs);return el};return SubsCapsMenuItem}(TextTrackMenuItem);Component.registerComponent("SubsCapsMenuItem",SubsCapsMenuItem);var SubsCapsButton=function(_TextTrackButton){_inheritsLoose(SubsCapsButton,_TextTrackButton);function SubsCapsButton(player,options){var _this;if(options===void 0){options={}}_this=_TextTrackButton.call(this,player,options)||this;_this.label_="subtitles";if(["en","en-us","en-ca","fr-ca"].indexOf(_this.player_.language_)>-1){_this.label_="captions"}_this.menuButton_.controlText(toTitleCase(_this.label_));return _this}var _proto=SubsCapsButton.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-subs-caps-button "+_TextTrackButton.prototype.buildCSSClass.call(this)};_proto.buildWrapperCSSClass=function buildWrapperCSSClass(){return"vjs-subs-caps-button "+_TextTrackButton.prototype.buildWrapperCSSClass.call(this)};_proto.createItems=function createItems(){var items=[];if(!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings")){items.push(new CaptionSettingsMenuItem(this.player_,{kind:this.label_}));this.hideThreshold_+=1}items=_TextTrackButton.prototype.createItems.call(this,items,SubsCapsMenuItem);return items};return SubsCapsButton}(TextTrackButton);SubsCapsButton.prototype.kinds_=["captions","subtitles"];SubsCapsButton.prototype.controlText_="Subtitles";Component.registerComponent("SubsCapsButton",SubsCapsButton);var AudioTrackMenuItem=function(_MenuItem){_inheritsLoose(AudioTrackMenuItem,_MenuItem);function AudioTrackMenuItem(player,options){var _this;var track=options.track;var tracks=player.audioTracks();options.label=track.label||track.language||"Unknown";options.selected=track.enabled;_this=_MenuItem.call(this,player,options)||this;_this.track=track;_this.addClass("vjs-"+track.kind+"-menu-item");var changeHandler=function changeHandler(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}_this.handleTracksChange.apply(_assertThisInitialized(_this),args)};tracks.addEventListener("change",changeHandler);_this.on("dispose",function(){tracks.removeEventListener("change",changeHandler)});return _this}var _proto=AudioTrackMenuItem.prototype;_proto.createEl=function createEl(type,props,attrs){var innerHTML='<span class="vjs-menu-item-text">'+this.localize(this.options_.label);if(this.options_.track.kind==="main-desc"){innerHTML+='\n <span aria-hidden="true" class="vjs-icon-placeholder"></span>\n <span class="vjs-control-text"> '+this.localize("Descriptions")+"</span>\n "}innerHTML+="</span>";var el=_MenuItem.prototype.createEl.call(this,type,assign({innerHTML:innerHTML},props),attrs);return el};_proto.handleClick=function handleClick(event){var tracks=this.player_.audioTracks();_MenuItem.prototype.handleClick.call(this,event);for(var i=0;i<tracks.length;i++){var track=tracks[i];track.enabled=track===this.track}};_proto.handleTracksChange=function handleTracksChange(event){this.selected(this.track.enabled)};return AudioTrackMenuItem}(MenuItem);Component.registerComponent("AudioTrackMenuItem",AudioTrackMenuItem);var AudioTrackButton=function(_TrackButton){_inheritsLoose(AudioTrackButton,_TrackButton);function AudioTrackButton(player,options){if(options===void 0){options={}}options.tracks=player.audioTracks();return _TrackButton.call(this,player,options)||this}var _proto=AudioTrackButton.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-audio-button "+_TrackButton.prototype.buildCSSClass.call(this)};_proto.buildWrapperCSSClass=function buildWrapperCSSClass(){return"vjs-audio-button "+_TrackButton.prototype.buildWrapperCSSClass.call(this)};_proto.createItems=function createItems(items){if(items===void 0){items=[]}this.hideThreshold_=1;var tracks=this.player_.audioTracks();for(var i=0;i<tracks.length;i++){var track=tracks[i];items.push(new AudioTrackMenuItem(this.player_,{track:track,selectable:true,multiSelectable:false}))}return items};return AudioTrackButton}(TrackButton);AudioTrackButton.prototype.controlText_="Audio Track";Component.registerComponent("AudioTrackButton",AudioTrackButton);var PlaybackRateMenuItem=function(_MenuItem){_inheritsLoose(PlaybackRateMenuItem,_MenuItem);function PlaybackRateMenuItem(player,options){var _this;var label=options.rate;var rate=parseFloat(label,10);options.label=label;options.selected=rate===1;options.selectable=true;options.multiSelectable=false;_this=_MenuItem.call(this,player,options)||this;_this.label=label;_this.rate=rate;_this.on(player,"ratechange",_this.update);return _this}var _proto=PlaybackRateMenuItem.prototype;_proto.handleClick=function handleClick(event){_MenuItem.prototype.handleClick.call(this);this.player().playbackRate(this.rate)};_proto.update=function update(event){this.selected(this.player().playbackRate()===this.rate)};return PlaybackRateMenuItem}(MenuItem);PlaybackRateMenuItem.prototype.contentElType="button";Component.registerComponent("PlaybackRateMenuItem",PlaybackRateMenuItem);var PlaybackRateMenuButton=function(_MenuButton){_inheritsLoose(PlaybackRateMenuButton,_MenuButton);function PlaybackRateMenuButton(player,options){var _this;_this=_MenuButton.call(this,player,options)||this;_this.updateVisibility();_this.updateLabel();_this.on(player,"loadstart",_this.updateVisibility);_this.on(player,"ratechange",_this.updateLabel);return _this}var _proto=PlaybackRateMenuButton.prototype;_proto.createEl=function createEl$1(){var el=_MenuButton.prototype.createEl.call(this);this.labelEl_=createEl("div",{className:"vjs-playback-rate-value",innerHTML:"1x"});el.appendChild(this.labelEl_);return el};_proto.dispose=function dispose(){this.labelEl_=null;_MenuButton.prototype.dispose.call(this)};_proto.buildCSSClass=function buildCSSClass(){return"vjs-playback-rate "+_MenuButton.prototype.buildCSSClass.call(this)};_proto.buildWrapperCSSClass=function buildWrapperCSSClass(){return"vjs-playback-rate "+_MenuButton.prototype.buildWrapperCSSClass.call(this)};_proto.createMenu=function createMenu(){var menu=new Menu(this.player());var rates=this.playbackRates();if(rates){for(var i=rates.length-1;i>=0;i--){menu.addChild(new PlaybackRateMenuItem(this.player(),{rate:rates[i]+"x"}))}}return menu};_proto.updateARIAAttributes=function updateARIAAttributes(){this.el().setAttribute("aria-valuenow",this.player().playbackRate())};_proto.handleClick=function handleClick(event){var currentRate=this.player().playbackRate();var rates=this.playbackRates();var newRate=rates[0];for(var i=0;i<rates.length;i++){if(rates[i]>currentRate){newRate=rates[i];break}}this.player().playbackRate(newRate)};_proto.playbackRates=function playbackRates(){return this.options_.playbackRates||this.options_.playerOptions&&this.options_.playerOptions.playbackRates};_proto.playbackRateSupported=function playbackRateSupported(){return this.player().tech_&&this.player().tech_.featuresPlaybackRate&&this.playbackRates()&&this.playbackRates().length>0};_proto.updateVisibility=function updateVisibility(event){if(this.playbackRateSupported()){this.removeClass("vjs-hidden")}else{this.addClass("vjs-hidden")}};_proto.updateLabel=function updateLabel(event){if(this.playbackRateSupported()){this.labelEl_.innerHTML=this.player().playbackRate()+"x"}};return PlaybackRateMenuButton}(MenuButton);PlaybackRateMenuButton.prototype.controlText_="Playback Rate";Component.registerComponent("PlaybackRateMenuButton",PlaybackRateMenuButton);var Spacer=function(_Component){_inheritsLoose(Spacer,_Component);function Spacer(){return _Component.apply(this,arguments)||this}var _proto=Spacer.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-spacer "+_Component.prototype.buildCSSClass.call(this)};_proto.createEl=function createEl(){return _Component.prototype.createEl.call(this,"div",{className:this.buildCSSClass()})};return Spacer}(Component);Component.registerComponent("Spacer",Spacer);var CustomControlSpacer=function(_Spacer){_inheritsLoose(CustomControlSpacer,_Spacer);function CustomControlSpacer(){return _Spacer.apply(this,arguments)||this}var _proto=CustomControlSpacer.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-custom-control-spacer "+_Spacer.prototype.buildCSSClass.call(this)};_proto.createEl=function createEl(){var el=_Spacer.prototype.createEl.call(this,{className:this.buildCSSClass()});el.innerHTML=" ";return el};return CustomControlSpacer}(Spacer);Component.registerComponent("CustomControlSpacer",CustomControlSpacer);var ControlBar=function(_Component){_inheritsLoose(ControlBar,_Component);function ControlBar(){return _Component.apply(this,arguments)||this}var _proto=ControlBar.prototype;_proto.createEl=function createEl(){return _Component.prototype.createEl.call(this,"div",{className:"vjs-control-bar",dir:"ltr"})};return ControlBar}(Component);ControlBar.prototype.options_={children:["playToggle","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","liveDisplay","seekToLive","remainingTimeDisplay","customControlSpacer","playbackRateMenuButton","chaptersButton","descriptionsButton","subsCapsButton","audioTrackButton","fullscreenToggle"]};if("exitPictureInPicture"in document){ControlBar.prototype.options_.children.splice(ControlBar.prototype.options_.children.length-1,0,"pictureInPictureToggle")}Component.registerComponent("ControlBar",ControlBar);var ErrorDisplay=function(_ModalDialog){_inheritsLoose(ErrorDisplay,_ModalDialog);function ErrorDisplay(player,options){var _this;_this=_ModalDialog.call(this,player,options)||this;_this.on(player,"error",_this.open);return _this}var _proto=ErrorDisplay.prototype;_proto.buildCSSClass=function buildCSSClass(){return"vjs-error-display "+_ModalDialog.prototype.buildCSSClass.call(this)};_proto.content=function content(){var error=this.player().error();return error?this.localize(error.message):""};return ErrorDisplay}(ModalDialog);ErrorDisplay.prototype.options_=mergeOptions(ModalDialog.prototype.options_,{pauseOnOpen:false,fillAlways:true,temporary:false,uncloseable:true});Component.registerComponent("ErrorDisplay",ErrorDisplay);var LOCAL_STORAGE_KEY="vjs-text-track-settings";var COLOR_BLACK=["#000","Black"];var COLOR_BLUE=["#00F","Blue"];var COLOR_CYAN=["#0FF","Cyan"];var COLOR_GREEN=["#0F0","Green"];var COLOR_MAGENTA=["#F0F","Magenta"];var COLOR_RED=["#F00","Red"];var COLOR_WHITE=["#FFF","White"];var COLOR_YELLOW=["#FF0","Yellow"];var OPACITY_OPAQUE=["1","Opaque"];var OPACITY_SEMI=["0.5","Semi-Transparent"];var OPACITY_TRANS=["0","Transparent"];var selectConfigs={backgroundColor:{selector:".vjs-bg-color > select",id:"captions-background-color-%s",label:"Color",options:[COLOR_BLACK,COLOR_WHITE,COLOR_RED,COLOR_GREEN,COLOR_BLUE,COLOR_YELLOW,COLOR_MAGENTA,COLOR_CYAN]},backgroundOpacity:{selector:".vjs-bg-opacity > select",id:"captions-background-opacity-%s",label:"Transparency",options:[OPACITY_OPAQUE,OPACITY_SEMI,OPACITY_TRANS]},color:{selector:".vjs-fg-color > select",id:"captions-foreground-color-%s",label:"Color",options:[COLOR_WHITE,COLOR_BLACK,COLOR_RED,COLOR_GREEN,COLOR_BLUE,COLOR_YELLOW,COLOR_MAGENTA,COLOR_CYAN]},edgeStyle:{selector:".vjs-edge-style > select",id:"%s",label:"Text Edge Style",options:[["none","None"],["raised","Raised"],["depressed","Depressed"],["uniform","Uniform"],["dropshadow","Dropshadow"]]},fontFamily:{selector:".vjs-font-family > select",id:"captions-font-family-%s",label:"Font Family",options:[["proportionalSansSerif","Proportional Sans-Serif"],["monospaceSansSerif","Monospace Sans-Serif"],["proportionalSerif","Proportional Serif"],["monospaceSerif","Monospace Serif"],["casual","Casual"],["script","Script"],["small-caps","Small Caps"]]},fontPercent:{selector:".vjs-font-percent > select",id:"captions-font-size-%s",label:"Font Size",options:[["0.50","50%"],["0.75","75%"],["1.00","100%"],["1.25","125%"],["1.50","150%"],["1.75","175%"],["2.00","200%"],["3.00","300%"],["4.00","400%"]],default:2,parser:function parser(v){return v==="1.00"?null:Number(v)}},textOpacity:{selector:".vjs-text-opacity > select",id:"captions-foreground-opacity-%s",label:"Transparency",options:[OPACITY_OPAQUE,OPACITY_SEMI]},windowColor:{selector:".vjs-window-color > select",id:"captions-window-color-%s",label:"Color"},windowOpacity:{selector:".vjs-window-opacity > select",id:"captions-window-opacity-%s",label:"Transparency",options:[OPACITY_TRANS,OPACITY_SEMI,OPACITY_OPAQUE]}};selectConfigs.windowColor.options=selectConfigs.backgroundColor.options;function parseOptionValue(value,parser){if(parser){value=parser(value)}if(value&&value!=="none"){return value}}function getSelectedOptionValue(el,parser){var value=el.options[el.options.selectedIndex].value;return parseOptionValue(value,parser)}function setSelectedOption(el,value,parser){if(!value){return}for(var i=0;i<el.options.length;i++){if(parseOptionValue(el.options[i].value,parser)===value){el.selectedIndex=i;break}}}var TextTrackSettings=function(_ModalDialog){_inheritsLoose(TextTrackSettings,_ModalDialog);function TextTrackSettings(player,options){var _this;options.temporary=false;_this=_ModalDialog.call(this,player,options)||this;_this.updateDisplay=bind(_assertThisInitialized(_this),_this.updateDisplay);_this.fill();_this.hasBeenOpened_=_this.hasBeenFilled_=true;_this.endDialog=createEl("p",{className:"vjs-control-text",textContent:_this.localize("End of dialog window.")});_this.el().appendChild(_this.endDialog);_this.setDefaults();if(options.persistTextTrackSettings===undefined){_this.options_.persistTextTrackSettings=_this.options_.playerOptions.persistTextTrackSettings}_this.on(_this.$(".vjs-done-button"),"click",function(){_this.saveSettings();_this.close()});_this.on(_this.$(".vjs-default-button"),"click",function(){_this.setDefaults();_this.updateDisplay()});each(selectConfigs,function(config){_this.on(_this.$(config.selector),"change",_this.updateDisplay)});if(_this.options_.persistTextTrackSettings){_this.restoreSettings()}return _this}var _proto=TextTrackSettings.prototype;_proto.dispose=function dispose(){this.endDialog=null;_ModalDialog.prototype.dispose.call(this)};_proto.createElSelect_=function createElSelect_(key,legendId,type){var _this2=this;if(legendId===void 0){legendId=""}if(type===void 0){type="label"}var config=selectConfigs[key];var id=config.id.replace("%s",this.id_);var selectLabelledbyIds=[legendId,id].join(" ").trim();return["<"+type+' id="'+id+'" class="'+(type==="label"?"vjs-label":"")+'">',this.localize(config.label),"</"+type+">",'<select aria-labelledby="'+selectLabelledbyIds+'">'].concat(config.options.map(function(o){var optionId=id+"-"+o[1].replace(/\W+/g,"");return['<option id="'+optionId+'" value="'+o[0]+'" ','aria-labelledby="'+selectLabelledbyIds+" "+optionId+'">',_this2.localize(o[1]),"</option>"].join("")})).concat("</select>").join("")};_proto.createElFgColor_=function createElFgColor_(){var legendId="captions-text-legend-"+this.id_;return['<fieldset class="vjs-fg-color vjs-track-setting">','<legend id="'+legendId+'">',this.localize("Text"),"</legend>",this.createElSelect_("color",legendId),'<span class="vjs-text-opacity vjs-opacity">',this.createElSelect_("textOpacity",legendId),"</span>","</fieldset>"].join("")};_proto.createElBgColor_=function createElBgColor_(){var legendId="captions-background-"+this.id_;return['<fieldset class="vjs-bg-color vjs-track-setting">','<legend id="'+legendId+'">',this.localize("Background"),"</legend>",this.createElSelect_("backgroundColor",legendId),'<span class="vjs-bg-opacity vjs-opacity">',this.createElSelect_("backgroundOpacity",legendId),"</span>","</fieldset>"].join("")};_proto.createElWinColor_=function createElWinColor_(){var legendId="captions-window-"+this.id_;return['<fieldset class="vjs-window-color vjs-track-setting">','<legend id="'+legendId+'">',this.localize("Window"),"</legend>",this.createElSelect_("windowColor",legendId),'<span class="vjs-window-opacity vjs-opacity">',this.createElSelect_("windowOpacity",legendId),"</span>","</fieldset>"].join("")};_proto.createElColors_=function createElColors_(){return createEl("div",{className:"vjs-track-settings-colors",innerHTML:[this.createElFgColor_(),this.createElBgColor_(),this.createElWinColor_()].join("")})};_proto.createElFont_=function createElFont_(){return createEl("div",{className:"vjs-track-settings-font",innerHTML:['<fieldset class="vjs-font-percent vjs-track-setting">',this.createElSelect_("fontPercent","","legend"),"</fieldset>",'<fieldset class="vjs-edge-style vjs-track-setting">',this.createElSelect_("edgeStyle","","legend"),"</fieldset>",'<fieldset class="vjs-font-family vjs-track-setting">',this.createElSelect_("fontFamily","","legend"),"</fieldset>"].join("")})};_proto.createElControls_=function createElControls_(){var defaultsDescription=this.localize("restore all settings to the default values");return createEl("div",{className:"vjs-track-settings-controls",innerHTML:['<button type="button" class="vjs-default-button" title="'+defaultsDescription+'">',this.localize("Reset"),'<span class="vjs-control-text"> '+defaultsDescription+"</span>","</button>",'<button type="button" class="vjs-done-button">'+this.localize("Done")+"</button>"].join("")})};_proto.content=function content(){return[this.createElColors_(),this.createElFont_(),this.createElControls_()]};_proto.label=function label(){return this.localize("Caption Settings Dialog")};_proto.description=function description(){return this.localize("Beginning of dialog window. Escape will cancel and close the window.")};_proto.buildCSSClass=function buildCSSClass(){return _ModalDialog.prototype.buildCSSClass.call(this)+" vjs-text-track-settings"};_proto.getValues=function getValues(){var _this3=this;return reduce(selectConfigs,function(accum,config,key){var value=getSelectedOptionValue(_this3.$(config.selector),config.parser);if(value!==undefined){accum[key]=value}return accum},{})};_proto.setValues=function setValues(values){var _this4=this;each(selectConfigs,function(config,key){setSelectedOption(_this4.$(config.selector),values[key],config.parser)})};_proto.setDefaults=function setDefaults(){var _this5=this;each(selectConfigs,function(config){var index=config.hasOwnProperty("default")?config["default"]:0;_this5.$(config.selector).selectedIndex=index})};_proto.restoreSettings=function restoreSettings(){var values;try{values=JSON.parse(window$1.localStorage.getItem(LOCAL_STORAGE_KEY))}catch(err){log.warn(err)}if(values){this.setValues(values)}};_proto.saveSettings=function saveSettings(){if(!this.options_.persistTextTrackSettings){return}var values=this.getValues();try{if(Object.keys(values).length){window$1.localStorage.setItem(LOCAL_STORAGE_KEY,JSON.stringify(values))}else{window$1.localStorage.removeItem(LOCAL_STORAGE_KEY)}}catch(err){log.warn(err)}};_proto.updateDisplay=function updateDisplay(){var ttDisplay=this.player_.getChild("textTrackDisplay");if(ttDisplay){ttDisplay.updateDisplay()}};_proto.conditionalBlur_=function conditionalBlur_(){this.previouslyActiveEl_=null;var cb=this.player_.controlBar;var subsCapsBtn=cb&&cb.subsCapsButton;var ccBtn=cb&&cb.captionsButton;if(subsCapsBtn){subsCapsBtn.focus()}else if(ccBtn){ccBtn.focus()}};return TextTrackSettings}(ModalDialog);Component.registerComponent("TextTrackSettings",TextTrackSettings);var ResizeManager=function(_Component){_inheritsLoose(ResizeManager,_Component);function ResizeManager(player,options){var _this;var RESIZE_OBSERVER_AVAILABLE=options.ResizeObserver||window$1.ResizeObserver;if(options.ResizeObserver===null){RESIZE_OBSERVER_AVAILABLE=false}var options_=mergeOptions({createEl:!RESIZE_OBSERVER_AVAILABLE,reportTouchActivity:false},options);_this=_Component.call(this,player,options_)||this;_this.ResizeObserver=options.ResizeObserver||window$1.ResizeObserver;_this.loadListener_=null;_this.resizeObserver_=null;_this.debouncedHandler_=debounce(function(){_this.resizeHandler()},100,false,_assertThisInitialized(_this));if(RESIZE_OBSERVER_AVAILABLE){_this.resizeObserver_=new _this.ResizeObserver(_this.debouncedHandler_);_this.resizeObserver_.observe(player.el())}else{_this.loadListener_=function(){if(!_this.el_||!_this.el_.contentWindow){return}var debouncedHandler_=_this.debouncedHandler_;var unloadListener_=_this.unloadListener_=function(){off(this,"resize",debouncedHandler_);off(this,"unload",unloadListener_);unloadListener_=null};on(_this.el_.contentWindow,"unload",unloadListener_);on(_this.el_.contentWindow,"resize",debouncedHandler_)};_this.one("load",_this.loadListener_)}return _this}var _proto=ResizeManager.prototype;_proto.createEl=function createEl(){return _Component.prototype.createEl.call(this,"iframe",{className:"vjs-resize-manager",tabIndex:-1},{"aria-hidden":"true"})};_proto.resizeHandler=function resizeHandler(){if(!this.player_||!this.player_.trigger){return}this.player_.trigger("playerresize")};_proto.dispose=function dispose(){if(this.debouncedHandler_){this.debouncedHandler_.cancel()}if(this.resizeObserver_){if(this.player_.el()){this.resizeObserver_.unobserve(this.player_.el())}this.resizeObserver_.disconnect()}if(this.loadListener_){this.off("load",this.loadListener_)}if(this.el_&&this.el_.contentWindow&&this.unloadListener_){this.unloadListener_.call(this.el_.contentWindow)}this.ResizeObserver=null;this.resizeObserver=null;this.debouncedHandler_=null;this.loadListener_=null;_Component.prototype.dispose.call(this)};return ResizeManager}(Component);Component.registerComponent("ResizeManager",ResizeManager);var median=function median(arr){var mid=Math.floor(arr.length/2);var sortedList=[].concat(arr).sort(function(a,b){return a-b});return arr.length%2!==0?sortedList[mid]:(sortedList[mid-1]+sortedList[mid])/2};var LiveTracker=function(_Component){_inheritsLoose(LiveTracker,_Component);function LiveTracker(player,options){var _this;var options_=mergeOptions({createEl:false},options);_this=_Component.call(this,player,options_)||this;_this.reset_();_this.on(_this.player_,"durationchange",_this.handleDurationchange);if(IE_VERSION&&"hidden"in document&&"visibilityState"in document){_this.on(document,"visibilitychange",_this.handleVisibilityChange)}return _this}var _proto=LiveTracker.prototype;_proto.handleVisibilityChange=function handleVisibilityChange(){if(this.player_.duration()!==Infinity){return}if(document.hidden){this.stopTracking()}else{this.startTracking()}};_proto.isBehind_=function isBehind_(){if(!this.timeupdateSeen_){return false}var liveCurrentTime=this.liveCurrentTime();var currentTime=this.player_.currentTime();var liveEdgeWindow=this.seekableIncrement_*2+.07;return liveCurrentTime!==Infinity&&liveCurrentTime-liveEdgeWindow>=currentTime};_proto.trackLive_=function trackLive_(){this.pastSeekEnd_=this.pastSeekEnd_;var seekable=this.player_.seekable();if(!seekable||!seekable.length){return}var newSeekEnd=this.seekableEnd();if(newSeekEnd!==this.lastSeekEnd_){if(this.lastSeekEnd_){this.seekableIncrementList_=this.seekableIncrementList_.slice(-11);this.seekableIncrementList_.push(Math.abs(newSeekEnd-this.lastSeekEnd_));if(this.seekableIncrementList_.length>3){this.seekableIncrement_=median(this.seekableIncrementList_)}}this.pastSeekEnd_=0;this.lastSeekEnd_=newSeekEnd;this.trigger("seekableendchange")}this.pastSeekEnd_=this.pastSeekEnd()+.03;if(this.isBehind_()!==this.behindLiveEdge()){this.behindLiveEdge_=this.isBehind_();this.trigger("liveedgechange")}};_proto.handleDurationchange=function handleDurationchange(){if(this.player_.duration()===Infinity){this.startTracking()}else{this.stopTracking()}};_proto.startTracking=function startTracking(){var _this2=this;if(this.isTracking()){return}if(!this.timeupdateSeen_){this.timeupdateSeen_=this.player_.hasStarted()}this.trackingInterval_=this.setInterval(this.trackLive_,30);this.trackLive_();this.on(this.player_,"play",this.trackLive_);this.on(this.player_,"pause",this.trackLive_);if(!this.timeupdateSeen_){this.one(this.player_,"play",this.handlePlay);this.handleTimeupdate=function(){_this2.timeupdateSeen_=true;_this2.handleTimeupdate=null};this.one(this.player_,"timeupdate",this.handleTimeupdate)}};_proto.handlePlay=function handlePlay(){this.one(this.player_,"timeupdate",this.seekToLiveEdge)};_proto.reset_=function reset_(){this.pastSeekEnd_=0;this.lastSeekEnd_=null;this.behindLiveEdge_=null;this.timeupdateSeen_=false;this.clearInterval(this.trackingInterval_);this.trackingInterval_=null;this.seekableIncrement_=12;this.seekableIncrementList_=[];this.off(this.player_,"play",this.trackLive_);this.off(this.player_,"pause",this.trackLive_);this.off(this.player_,"play",this.handlePlay);this.off(this.player_,"timeupdate",this.seekToLiveEdge);if(this.handleTimeupdate){this.off(this.player_,"timeupdate",this.handleTimeupdate);this.handleTimeupdate=null}};_proto.stopTracking=function stopTracking(){if(!this.isTracking()){return}this.reset_()};_proto.seekableEnd=function seekableEnd(){var seekable=this.player_.seekable();var seekableEnds=[];var i=seekable?seekable.length:0;while(i--){seekableEnds.push(seekable.end(i))}return seekableEnds.length?seekableEnds.sort()[seekableEnds.length-1]:Infinity};_proto.seekableStart=function seekableStart(){var seekable=this.player_.seekable();var seekableStarts=[];var i=seekable?seekable.length:0;while(i--){seekableStarts.push(seekable.start(i))}return seekableStarts.length?seekableStarts.sort()[0]:0};_proto.liveWindow=function liveWindow(){var liveCurrentTime=this.liveCurrentTime();if(liveCurrentTime===Infinity){return Infinity}return liveCurrentTime-this.seekableStart()};_proto.isLive=function isLive(){return this.isTracking()};_proto.atLiveEdge=function atLiveEdge(){return!this.behindLiveEdge()};_proto.liveCurrentTime=function liveCurrentTime(){return this.pastSeekEnd()+this.seekableEnd()};_proto.pastSeekEnd=function pastSeekEnd(){return this.pastSeekEnd_};_proto.behindLiveEdge=function behindLiveEdge(){return this.behindLiveEdge_};_proto.isTracking=function isTracking(){return typeof this.trackingInterval_==="number"};_proto.seekToLiveEdge=function seekToLiveEdge(){if(this.atLiveEdge()){return}this.player_.currentTime(this.liveCurrentTime());if(this.player_.paused()){this.player_.play()}};_proto.dispose=function dispose(){this.stopTracking();_Component.prototype.dispose.call(this)};return LiveTracker}(Component);Component.registerComponent("LiveTracker",LiveTracker);var sourcesetLoad=function sourcesetLoad(tech){var el=tech.el();if(el.hasAttribute("src")){tech.triggerSourceset(el.src);return true}var sources=tech.$$("source");var srcUrls=[];var src="";if(!sources.length){return false}for(var i=0;i<sources.length;i++){var url=sources[i].src;if(url&&srcUrls.indexOf(url)===-1){srcUrls.push(url)}}if(!srcUrls.length){return false}if(srcUrls.length===1){src=srcUrls[0]}tech.triggerSourceset(src);return true};var innerHTMLDescriptorPolyfill=Object.defineProperty({},"innerHTML",{get:function get(){return this.cloneNode(true).innerHTML},set:function set(v){var dummy=document.createElement(this.nodeName.toLowerCase());dummy.innerHTML=v;var docFrag=document.createDocumentFragment();while(dummy.childNodes.length){docFrag.appendChild(dummy.childNodes[0])}this.innerText="";window$1.Element.prototype.appendChild.call(this,docFrag);return this.innerHTML}});var getDescriptor=function getDescriptor(priority,prop){var descriptor={};for(var i=0;i<priority.length;i++){descriptor=Object.getOwnPropertyDescriptor(priority[i],prop);if(descriptor&&descriptor.set&&descriptor.get){break}}descriptor.enumerable=true;descriptor.configurable=true;return descriptor};var getInnerHTMLDescriptor=function getInnerHTMLDescriptor(tech){return getDescriptor([tech.el(),window$1.HTMLMediaElement.prototype,window$1.Element.prototype,innerHTMLDescriptorPolyfill],"innerHTML")};var firstSourceWatch=function firstSourceWatch(tech){var el=tech.el();if(el.resetSourceWatch_){return}var old={};var innerDescriptor=getInnerHTMLDescriptor(tech);var appendWrapper=function appendWrapper(appendFn){return function(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}var retval=appendFn.apply(el,args);sourcesetLoad(tech);return retval}};["append","appendChild","insertAdjacentHTML"].forEach(function(k){if(!el[k]){return}old[k]=el[k];el[k]=appendWrapper(old[k])});Object.defineProperty(el,"innerHTML",mergeOptions(innerDescriptor,{set:appendWrapper(innerDescriptor.set)}));el.resetSourceWatch_=function(){el.resetSourceWatch_=null;Object.keys(old).forEach(function(k){el[k]=old[k]});Object.defineProperty(el,"innerHTML",innerDescriptor)};tech.one("sourceset",el.resetSourceWatch_)};var srcDescriptorPolyfill=Object.defineProperty({},"src",{get:function get(){if(this.hasAttribute("src")){return getAbsoluteURL(window$1.Element.prototype.getAttribute.call(this,"src"))}return""},set:function set(v){window$1.Element.prototype.setAttribute.call(this,"src",v);return v}});var getSrcDescriptor=function getSrcDescriptor(tech){return getDescriptor([tech.el(),window$1.HTMLMediaElement.prototype,srcDescriptorPolyfill],"src")};var setupSourceset=function setupSourceset(tech){if(!tech.featuresSourceset){return}var el=tech.el();if(el.resetSourceset_){return}var srcDescriptor=getSrcDescriptor(tech);var oldSetAttribute=el.setAttribute;var oldLoad=el.load;Object.defineProperty(el,"src",mergeOptions(srcDescriptor,{set:function set(v){var retval=srcDescriptor.set.call(el,v);tech.triggerSourceset(el.src);return retval}}));el.setAttribute=function(n,v){var retval=oldSetAttribute.call(el,n,v);if(/src/i.test(n)){tech.triggerSourceset(el.src)}return retval};el.load=function(){var retval=oldLoad.call(el);if(!sourcesetLoad(tech)){tech.triggerSourceset("");firstSourceWatch(tech)}return retval};if(el.currentSrc){tech.triggerSourceset(el.currentSrc)}else if(!sourcesetLoad(tech)){firstSourceWatch(tech)}el.resetSourceset_=function(){el.resetSourceset_=null;el.load=oldLoad;el.setAttribute=oldSetAttribute;Object.defineProperty(el,"src",srcDescriptor);if(el.resetSourceWatch_){el.resetSourceWatch_()}}};var Html5=function(_Tech){_inheritsLoose(Html5,_Tech);function Html5(options,ready){var _this;_this=_Tech.call(this,options,ready)||this;var source=options.source;var crossoriginTracks=false;if(source&&(_this.el_.currentSrc!==source.src||options.tag&&options.tag.initNetworkState_===3)){_this.setSource(source)}else{_this.handleLateInit_(_this.el_)}if(options.enableSourceset){_this.setupSourcesetHandling_()}if(_this.el_.hasChildNodes()){var nodes=_this.el_.childNodes;var nodesLength=nodes.length;var removeNodes=[];while(nodesLength--){var node=nodes[nodesLength];var nodeName=node.nodeName.toLowerCase();if(nodeName==="track"){if(!_this.featuresNativeTextTracks){removeNodes.push(node)}else{_this.remoteTextTrackEls().addTrackElement_(node);_this.remoteTextTracks().addTrack(node.track);_this.textTracks().addTrack(node.track);if(!crossoriginTracks&&!_this.el_.hasAttribute("crossorigin")&&isCrossOrigin(node.src)){crossoriginTracks=true}}}}for(var i=0;i<removeNodes.length;i++){_this.el_.removeChild(removeNodes[i])}}_this.proxyNativeTracks_();if(_this.featuresNativeTextTracks&&crossoriginTracks){log.warn("Text Tracks are being loaded from another origin but the crossorigin attribute isn't used.\n"+"This may prevent text tracks from loading.")}_this.restoreMetadataTracksInIOSNativePlayer_();if((TOUCH_ENABLED||IS_IPHONE||IS_NATIVE_ANDROID)&&options.nativeControlsForTouch===true){_this.setControls(true)}_this.proxyWebkitFullscreen_();_this.triggerReady();return _this}var _proto=Html5.prototype;_proto.dispose=function dispose(){if(this.el_&&this.el_.resetSourceset_){this.el_.resetSourceset_()}Html5.disposeMediaElement(this.el_);this.options_=null;_Tech.prototype.dispose.call(this)};_proto.setupSourcesetHandling_=function setupSourcesetHandling_(){setupSourceset(this)};_proto.restoreMetadataTracksInIOSNativePlayer_=function restoreMetadataTracksInIOSNativePlayer_(){var textTracks=this.textTracks();var metadataTracksPreFullscreenState;var takeMetadataTrackSnapshot=function takeMetadataTrackSnapshot(){metadataTracksPreFullscreenState=[];for(var i=0;i<textTracks.length;i++){var track=textTracks[i];if(track.kind==="metadata"){metadataTracksPreFullscreenState.push({track:track,storedMode:track.mode})}}};takeMetadataTrackSnapshot();textTracks.addEventListener("change",takeMetadataTrackSnapshot);this.on("dispose",function(){return textTracks.removeEventListener("change",takeMetadataTrackSnapshot)});var restoreTrackMode=function restoreTrackMode(){for(var i=0;i<metadataTracksPreFullscreenState.length;i++){var storedTrack=metadataTracksPreFullscreenState[i];if(storedTrack.track.mode==="disabled"&&storedTrack.track.mode!==storedTrack.storedMode){storedTrack.track.mode=storedTrack.storedMode}}textTracks.removeEventListener("change",restoreTrackMode)};this.on("webkitbeginfullscreen",function(){textTracks.removeEventListener("change",takeMetadataTrackSnapshot);textTracks.removeEventListener("change",restoreTrackMode);textTracks.addEventListener("change",restoreTrackMode)});this.on("webkitendfullscreen",function(){textTracks.removeEventListener("change",takeMetadataTrackSnapshot);textTracks.addEventListener("change",takeMetadataTrackSnapshot);textTracks.removeEventListener("change",restoreTrackMode)})};_proto.overrideNative_=function overrideNative_(type,override){var _this2=this;if(override!==this["featuresNative"+type+"Tracks"]){return}var lowerCaseType=type.toLowerCase();if(this[lowerCaseType+"TracksListeners_"]){Object.keys(this[lowerCaseType+"TracksListeners_"]).forEach(function(eventName){var elTracks=_this2.el()[lowerCaseType+"Tracks"];elTracks.removeEventListener(eventName,_this2[lowerCaseType+"TracksListeners_"][eventName])})}this["featuresNative"+type+"Tracks"]=!override;this[lowerCaseType+"TracksListeners_"]=null;this.proxyNativeTracksForType_(lowerCaseType)};_proto.overrideNativeAudioTracks=function overrideNativeAudioTracks(override){this.overrideNative_("Audio",override)};_proto.overrideNativeVideoTracks=function overrideNativeVideoTracks(override){this.overrideNative_("Video",override)};_proto.proxyNativeTracksForType_=function proxyNativeTracksForType_(name){var _this3=this;var props=NORMAL[name];var elTracks=this.el()[props.getterName];var techTracks=this[props.getterName]();if(!this["featuresNative"+props.capitalName+"Tracks"]||!elTracks||!elTracks.addEventListener){return}var listeners={change:function change(e){techTracks.trigger({type:"change",target:techTracks,currentTarget:techTracks,srcElement:techTracks})},addtrack:function addtrack(e){techTracks.addTrack(e.track)},removetrack:function removetrack(e){techTracks.removeTrack(e.track)}};var removeOldTracks=function removeOldTracks(){var removeTracks=[];for(var i=0;i<techTracks.length;i++){var found=false;for(var j=0;j<elTracks.length;j++){if(elTracks[j]===techTracks[i]){found=true;break}}if(!found){removeTracks.push(techTracks[i])}}while(removeTracks.length){techTracks.removeTrack(removeTracks.shift())}};this[props.getterName+"Listeners_"]=listeners;Object.keys(listeners).forEach(function(eventName){var listener=listeners[eventName];elTracks.addEventListener(eventName,listener);_this3.on("dispose",function(e){return elTracks.removeEventListener(eventName,listener)})});this.on("loadstart",removeOldTracks);this.on("dispose",function(e){return _this3.off("loadstart",removeOldTracks)})};_proto.proxyNativeTracks_=function proxyNativeTracks_(){var _this4=this;NORMAL.names.forEach(function(name){_this4.proxyNativeTracksForType_(name)})};_proto.createEl=function createEl(){var el=this.options_.tag;if(!el||!(this.options_.playerElIngest||this.movingMediaElementInDOM)){if(el){var clone=el.cloneNode(true);if(el.parentNode){el.parentNode.insertBefore(clone,el)}Html5.disposeMediaElement(el);el=clone}else{el=document.createElement("video");var tagAttributes=this.options_.tag&&getAttributes(this.options_.tag);var attributes=mergeOptions({},tagAttributes);if(!TOUCH_ENABLED||this.options_.nativeControlsForTouch!==true){delete attributes.controls}setAttributes(el,assign(attributes,{id:this.options_.techId,class:"vjs-tech"}))}el.playerId=this.options_.playerId}if(typeof this.options_.preload!=="undefined"){setAttribute(el,"preload",this.options_.preload)}var settingsAttrs=["loop","muted","playsinline","autoplay"];for(var i=0;i<settingsAttrs.length;i++){var attr=settingsAttrs[i];var value=this.options_[attr];if(typeof value!=="undefined"){if(value){setAttribute(el,attr,attr)}else{removeAttribute(el,attr)}el[attr]=value}}return el};_proto.handleLateInit_=function handleLateInit_(el){if(el.networkState===0||el.networkState===3){return}if(el.readyState===0){var loadstartFired=false;var setLoadstartFired=function setLoadstartFired(){loadstartFired=true};this.on("loadstart",setLoadstartFired);var triggerLoadstart=function triggerLoadstart(){if(!loadstartFired){this.trigger("loadstart")}};this.on("loadedmetadata",triggerLoadstart);this.ready(function(){this.off("loadstart",setLoadstartFired);this.off("loadedmetadata",triggerLoadstart);if(!loadstartFired){this.trigger("loadstart")}});return}var eventsToTrigger=["loadstart"];eventsToTrigger.push("loadedmetadata");if(el.readyState>=2){eventsToTrigger.push("loadeddata")}if(el.readyState>=3){eventsToTrigger.push("canplay")}if(el.readyState>=4){eventsToTrigger.push("canplaythrough")}this.ready(function(){eventsToTrigger.forEach(function(type){this.trigger(type)},this)})};_proto.setCurrentTime=function setCurrentTime(seconds){try{this.el_.currentTime=seconds}catch(e){log(e,"Video is not ready. (Video.js)")}};_proto.duration=function duration(){var _this5=this;if(this.el_.duration===Infinity&&IS_ANDROID&&IS_CHROME&&this.el_.currentTime===0){var checkProgress=function checkProgress(){if(_this5.el_.currentTime>0){if(_this5.el_.duration===Infinity){_this5.trigger("durationchange")}_this5.off("timeupdate",checkProgress)}};this.on("timeupdate",checkProgress);return NaN}return this.el_.duration||NaN};_proto.width=function width(){return this.el_.offsetWidth};_proto.height=function height(){return this.el_.offsetHeight};_proto.proxyWebkitFullscreen_=function proxyWebkitFullscreen_(){var _this6=this;if(!("webkitDisplayingFullscreen"in this.el_)){return}var endFn=function endFn(){this.trigger("fullscreenchange",{isFullscreen:false})};var beginFn=function beginFn(){if("webkitPresentationMode"in this.el_&&this.el_.webkitPresentationMode!=="picture-in-picture"){this.one("webkitendfullscreen",endFn);this.trigger("fullscreenchange",{isFullscreen:true})}};this.on("webkitbeginfullscreen",beginFn);this.on("dispose",function(){_this6.off("webkitbeginfullscreen",beginFn);_this6.off("webkitendfullscreen",endFn)})};_proto.supportsFullScreen=function supportsFullScreen(){if(typeof this.el_.webkitEnterFullScreen==="function"){var userAgent=window$1.navigator&&window$1.navigator.userAgent||"";if(/Android/.test(userAgent)||!/Chrome|Mac OS X 10.5/.test(userAgent)){return true}}return false};_proto.enterFullScreen=function enterFullScreen(){var video=this.el_;if(video.paused&&video.networkState<=video.HAVE_METADATA){this.el_.play();this.setTimeout(function(){video.pause();video.webkitEnterFullScreen()},0)}else{video.webkitEnterFullScreen()}};_proto.exitFullScreen=function exitFullScreen(){this.el_.webkitExitFullScreen()};_proto.requestPictureInPicture=function requestPictureInPicture(){return this.el_.requestPictureInPicture()};_proto.src=function src(_src){if(_src===undefined){return this.el_.src}this.setSrc(_src)};_proto.reset=function reset(){Html5.resetMediaElement(this.el_)};_proto.currentSrc=function currentSrc(){if(this.currentSource_){return this.currentSource_.src}return this.el_.currentSrc};_proto.setControls=function setControls(val){this.el_.controls=!!val};_proto.addTextTrack=function addTextTrack(kind,label,language){if(!this.featuresNativeTextTracks){return _Tech.prototype.addTextTrack.call(this,kind,label,language)}return this.el_.addTextTrack(kind,label,language)};_proto.createRemoteTextTrack=function createRemoteTextTrack(options){if(!this.featuresNativeTextTracks){return _Tech.prototype.createRemoteTextTrack.call(this,options)}var htmlTrackElement=document.createElement("track");if(options.kind){htmlTrackElement.kind=options.kind}if(options.label){htmlTrackElement.label=options.label}if(options.language||options.srclang){htmlTrackElement.srclang=options.language||options.srclang}if(options["default"]){htmlTrackElement["default"]=options["default"]}if(options.id){htmlTrackElement.id=options.id}if(options.src){htmlTrackElement.src=options.src}return htmlTrackElement};_proto.addRemoteTextTrack=function addRemoteTextTrack(options,manualCleanup){var htmlTrackElement=_Tech.prototype.addRemoteTextTrack.call(this,options,manualCleanup);if(this.featuresNativeTextTracks){this.el().appendChild(htmlTrackElement)}return htmlTrackElement};_proto.removeRemoteTextTrack=function removeRemoteTextTrack(track){_Tech.prototype.removeRemoteTextTrack.call(this,track);if(this.featuresNativeTextTracks){var tracks=this.$$("track");var i=tracks.length;while(i--){if(track===tracks[i]||track===tracks[i].track){this.el().removeChild(tracks[i])}}}};_proto.getVideoPlaybackQuality=function getVideoPlaybackQuality(){if(typeof this.el().getVideoPlaybackQuality==="function"){return this.el().getVideoPlaybackQuality()}var videoPlaybackQuality={};if(typeof this.el().webkitDroppedFrameCount!=="undefined"&&typeof this.el().webkitDecodedFrameCount!=="undefined"){videoPlaybackQuality.droppedVideoFrames=this.el().webkitDroppedFrameCount;videoPlaybackQuality.totalVideoFrames=this.el().webkitDecodedFrameCount}if(window$1.performance&&typeof window$1.performance.now==="function"){videoPlaybackQuality.creationTime=window$1.performance.now()}else if(window$1.performance&&window$1.performance.timing&&typeof window$1.performance.timing.navigationStart==="number"){videoPlaybackQuality.creationTime=window$1.Date.now()-window$1.performance.timing.navigationStart}return videoPlaybackQuality};return Html5}(Tech);if(isReal()){Html5.TEST_VID=document.createElement("video");var track=document.createElement("track");track.kind="captions";track.srclang="en";track.label="English";Html5.TEST_VID.appendChild(track)}Html5.isSupported=function(){try{Html5.TEST_VID.volume=.5}catch(e){return false}return!!(Html5.TEST_VID&&Html5.TEST_VID.canPlayType)};Html5.canPlayType=function(type){return Html5.TEST_VID.canPlayType(type)};Html5.canPlaySource=function(srcObj,options){return Html5.canPlayType(srcObj.type)};Html5.canControlVolume=function(){try{var volume=Html5.TEST_VID.volume;Html5.TEST_VID.volume=volume/2+.1;return volume!==Html5.TEST_VID.volume}catch(e){return false}};Html5.canMuteVolume=function(){try{var muted=Html5.TEST_VID.muted;Html5.TEST_VID.muted=!muted;if(Html5.TEST_VID.muted){setAttribute(Html5.TEST_VID,"muted","muted")}else{removeAttribute(Html5.TEST_VID,"muted","muted")}return muted!==Html5.TEST_VID.muted}catch(e){return false}};Html5.canControlPlaybackRate=function(){if(IS_ANDROID&&IS_CHROME&&CHROME_VERSION<58){return false}try{var playbackRate=Html5.TEST_VID.playbackRate;Html5.TEST_VID.playbackRate=playbackRate/2+.1;return playbackRate!==Html5.TEST_VID.playbackRate}catch(e){return false}};Html5.canOverrideAttributes=function(){try{var noop=function noop(){};Object.defineProperty(document.createElement("video"),"src",{get:noop,set:noop});Object.defineProperty(document.createElement("audio"),"src",{get:noop,set:noop});Object.defineProperty(document.createElement("video"),"innerHTML",{get:noop,set:noop});Object.defineProperty(document.createElement("audio"),"innerHTML",{get:noop,set:noop})}catch(e){return false}return true};Html5.supportsNativeTextTracks=function(){return IS_ANY_SAFARI||IS_IOS&&IS_CHROME};Html5.supportsNativeVideoTracks=function(){return!!(Html5.TEST_VID&&Html5.TEST_VID.videoTracks)};Html5.supportsNativeAudioTracks=function(){return!!(Html5.TEST_VID&&Html5.TEST_VID.audioTracks)};Html5.Events=["loadstart","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","progress","play","pause","ratechange","resize","volumechange"];Html5.prototype.featuresVolumeControl=Html5.canControlVolume();Html5.prototype.featuresMuteControl=Html5.canMuteVolume();Html5.prototype.featuresPlaybackRate=Html5.canControlPlaybackRate();Html5.prototype.featuresSourceset=Html5.canOverrideAttributes();Html5.prototype.movingMediaElementInDOM=!IS_IOS;Html5.prototype.featuresFullscreenResize=true;Html5.prototype.featuresProgressEvents=true;Html5.prototype.featuresTimeupdateEvents=true;Html5.prototype.featuresNativeTextTracks=Html5.supportsNativeTextTracks();Html5.prototype.featuresNativeVideoTracks=Html5.supportsNativeVideoTracks();Html5.prototype.featuresNativeAudioTracks=Html5.supportsNativeAudioTracks();var canPlayType=Html5.TEST_VID&&Html5.TEST_VID.constructor.prototype.canPlayType;var mpegurlRE=/^application\/(?:x-|vnd\.apple\.)mpegurl/i;Html5.patchCanPlayType=function(){if(ANDROID_VERSION>=4&&!IS_FIREFOX&&!IS_CHROME){Html5.TEST_VID.constructor.prototype.canPlayType=function(type){if(type&&mpegurlRE.test(type)){return"maybe"}return canPlayType.call(this,type)}}};Html5.unpatchCanPlayType=function(){var r=Html5.TEST_VID.constructor.prototype.canPlayType;Html5.TEST_VID.constructor.prototype.canPlayType=canPlayType;return r};Html5.patchCanPlayType();Html5.disposeMediaElement=function(el){if(!el){return}if(el.parentNode){el.parentNode.removeChild(el)}while(el.hasChildNodes()){el.removeChild(el.firstChild)}el.removeAttribute("src");if(typeof el.load==="function"){(function(){try{el.load()}catch(e){}})()}};Html5.resetMediaElement=function(el){if(!el){return}var sources=el.querySelectorAll("source");var i=sources.length;while(i--){el.removeChild(sources[i])}el.removeAttribute("src");if(typeof el.load==="function"){(function(){try{el.load()}catch(e){}})()}};["muted","defaultMuted","autoplay","controls","loop","playsinline"].forEach(function(prop){Html5.prototype[prop]=function(){return this.el_[prop]||this.el_.hasAttribute(prop)}});["muted","defaultMuted","autoplay","loop","playsinline"].forEach(function(prop){Html5.prototype["set"+toTitleCase(prop)]=function(v){this.el_[prop]=v;if(v){this.el_.setAttribute(prop,prop)}else{this.el_.removeAttribute(prop)}}});["paused","currentTime","buffered","volume","poster","preload","error","seeking","seekable","ended","playbackRate","defaultPlaybackRate","played","networkState","readyState","videoWidth","videoHeight"].forEach(function(prop){Html5.prototype[prop]=function(){return this.el_[prop]}});["volume","src","poster","preload","playbackRate","defaultPlaybackRate"].forEach(function(prop){Html5.prototype["set"+toTitleCase(prop)]=function(v){this.el_[prop]=v}});["pause","load","play"].forEach(function(prop){Html5.prototype[prop]=function(){return this.el_[prop]()}});Tech.withSourceHandlers(Html5);Html5.nativeSourceHandler={};Html5.nativeSourceHandler.canPlayType=function(type){try{return Html5.TEST_VID.canPlayType(type)}catch(e){return""}};Html5.nativeSourceHandler.canHandleSource=function(source,options){if(source.type){return Html5.nativeSourceHandler.canPlayType(source.type)}else if(source.src){var ext=getFileExtension(source.src);return Html5.nativeSourceHandler.canPlayType("video/"+ext)}return""};Html5.nativeSourceHandler.handleSource=function(source,tech,options){tech.setSrc(source.src)};Html5.nativeSourceHandler.dispose=function(){};Html5.registerSourceHandler(Html5.nativeSourceHandler);Tech.registerTech("Html5",Html5);var TECH_EVENTS_RETRIGGER=["progress","abort","suspend","emptied","stalled","loadedmetadata","loadeddata","timeupdate","resize","volumechange","texttrackchange"];var TECH_EVENTS_QUEUE={canplay:"CanPlay",canplaythrough:"CanPlayThrough",playing:"Playing",seeked:"Seeked"};var BREAKPOINT_ORDER=["tiny","xsmall","small","medium","large","xlarge","huge"];var BREAKPOINT_CLASSES={};BREAKPOINT_ORDER.forEach(function(k){var v=k.charAt(0)==="x"?"x-"+k.substring(1):k;BREAKPOINT_CLASSES[k]="vjs-layout-"+v});var DEFAULT_BREAKPOINTS={tiny:210,xsmall:320,small:425,medium:768,large:1440,xlarge:2560,huge:Infinity};var Player=function(_Component){_inheritsLoose(Player,_Component);function Player(tag,options,ready){var _this;tag.id=tag.id||options.id||"vjs_video_"+newGUID();options=assign(Player.getTagSettings(tag),options);options.initChildren=false;options.createEl=false;options.evented=false;options.reportTouchActivity=false;if(!options.language){if(typeof tag.closest==="function"){var closest=tag.closest("[lang]");if(closest&&closest.getAttribute){options.language=closest.getAttribute("lang")}}else{var element=tag;while(element&&element.nodeType===1){if(getAttributes(element).hasOwnProperty("lang")){options.language=element.getAttribute("lang");break}element=element.parentNode}}}_this=_Component.call(this,null,options,ready)||this;_this.boundDocumentFullscreenChange_=bind(_assertThisInitialized(_this),_this.documentFullscreenChange_);_this.boundFullWindowOnEscKey_=bind(_assertThisInitialized(_this),_this.fullWindowOnEscKey);_this.log=createLogger$1(_this.id_);_this.fsApi_=FullscreenApi;_this.isPosterFromTech_=false;_this.queuedCallbacks_=[];_this.isReady_=false;_this.hasStarted_=false;_this.userActive_=false;if(!_this.options_||!_this.options_.techOrder||!_this.options_.techOrder.length){throw new Error("No techOrder specified. Did you overwrite "+"videojs.options instead of just changing the "+"properties you want to override?")}_this.tag=tag;_this.tagAttributes=tag&&getAttributes(tag);_this.language(_this.options_.language);if(options.languages){var languagesToLower={};Object.getOwnPropertyNames(options.languages).forEach(function(name){languagesToLower[name.toLowerCase()]=options.languages[name]});_this.languages_=languagesToLower}else{_this.languages_=Player.prototype.options_.languages}_this.resetCache_();_this.poster_=options.poster||"";_this.controls_=!!options.controls;tag.controls=false;tag.removeAttribute("controls");_this.changingSrc_=false;_this.playCallbacks_=[];_this.playTerminatedQueue_=[];if(tag.hasAttribute("autoplay")){_this.autoplay(true)}else{_this.autoplay(_this.options_.autoplay)}if(options.plugins){Object.keys(options.plugins).forEach(function(name){if(typeof _this[name]!=="function"){throw new Error('plugin "'+name+'" does not exist')}})}_this.scrubbing_=false;_this.el_=_this.createEl();evented(_assertThisInitialized(_this),{eventBusKey:"el_"});if(_this.fluid_){_this.on("playerreset",_this.updateStyleEl_)}var playerOptionsCopy=mergeOptions(_this.options_);if(options.plugins){Object.keys(options.plugins).forEach(function(name){_this[name](options.plugins[name])})}_this.options_.playerOptions=playerOptionsCopy;_this.middleware_=[];_this.initChildren();_this.isAudio(tag.nodeName.toLowerCase()==="audio");if(_this.controls()){_this.addClass("vjs-controls-enabled")}else{_this.addClass("vjs-controls-disabled")}_this.el_.setAttribute("role","region");if(_this.isAudio()){_this.el_.setAttribute("aria-label",_this.localize("Audio Player"))}else{_this.el_.setAttribute("aria-label",_this.localize("Video Player"))}if(_this.isAudio()){_this.addClass("vjs-audio")}if(_this.flexNotSupported_()){_this.addClass("vjs-no-flex")}if(TOUCH_ENABLED){_this.addClass("vjs-touch-enabled")}if(!IS_IOS){_this.addClass("vjs-workinghover")}Player.players[_this.id_]=_assertThisInitialized(_this);var majorVersion=version.split(".")[0];_this.addClass("vjs-v"+majorVersion);_this.userActive(true);_this.reportUserActivity();_this.one("play",_this.listenForUserActivity_);_this.on("stageclick",_this.handleStageClick_);_this.on("keydown",_this.handleKeyDown);_this.breakpoints(_this.options_.breakpoints);_this.responsive(_this.options_.responsive);return _this}var _proto=Player.prototype;_proto.dispose=function dispose(){var _this2=this;this.trigger("dispose");this.off("dispose");off(document,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_);off(document,"keydown",this.boundFullWindowOnEscKey_);if(this.styleEl_&&this.styleEl_.parentNode){this.styleEl_.parentNode.removeChild(this.styleEl_);this.styleEl_=null}Player.players[this.id_]=null;if(this.tag&&this.tag.player){this.tag.player=null}if(this.el_&&this.el_.player){this.el_.player=null}if(this.tech_){this.tech_.dispose();this.isPosterFromTech_=false;this.poster_=""}if(this.playerElIngest_){this.playerElIngest_=null}if(this.tag){this.tag=null}clearCacheForPlayer(this);ALL.names.forEach(function(name){var props=ALL[name];var list=_this2[props.getterName]();if(list&&list.off){list.off()}});_Component.prototype.dispose.call(this)};_proto.createEl=function createEl(){var tag=this.tag;var el;var playerElIngest=this.playerElIngest_=tag.parentNode&&tag.parentNode.hasAttribute&&tag.parentNode.hasAttribute("data-vjs-player");var divEmbed=this.tag.tagName.toLowerCase()==="video-js";if(playerElIngest){el=this.el_=tag.parentNode}else if(!divEmbed){el=this.el_=_Component.prototype.createEl.call(this,"div")}var attrs=getAttributes(tag);if(divEmbed){el=this.el_=tag;tag=this.tag=document.createElement("video");while(el.children.length){tag.appendChild(el.firstChild)}if(!hasClass(el,"video-js")){addClass(el,"video-js")}el.appendChild(tag);playerElIngest=this.playerElIngest_=el;Object.keys(el).forEach(function(k){try{tag[k]=el[k]}catch(e){}})}tag.setAttribute("tabindex","-1");attrs.tabindex="-1";if(IE_VERSION||IS_CHROME&&IS_WINDOWS){tag.setAttribute("role","application");attrs.role="application"}tag.removeAttribute("width");tag.removeAttribute("height");if("width"in attrs){delete attrs.width}if("height"in attrs){delete attrs.height}Object.getOwnPropertyNames(attrs).forEach(function(attr){if(!(divEmbed&&attr==="class")){el.setAttribute(attr,attrs[attr])}if(divEmbed){tag.setAttribute(attr,attrs[attr])}});tag.playerId=tag.id;tag.id+="_html5_api";tag.className="vjs-tech";tag.player=el.player=this;this.addClass("vjs-paused");if(window$1.VIDEOJS_NO_DYNAMIC_STYLE!==true){this.styleEl_=createStyleElement("vjs-styles-dimensions");var defaultsStyleEl=$(".vjs-styles-defaults");var head=$("head");head.insertBefore(this.styleEl_,defaultsStyleEl?defaultsStyleEl.nextSibling:head.firstChild)}this.fill_=false;this.fluid_=false;this.width(this.options_.width);this.height(this.options_.height);this.fill(this.options_.fill);this.fluid(this.options_.fluid);this.aspectRatio(this.options_.aspectRatio);var links=tag.getElementsByTagName("a");for(var i=0;i<links.length;i++){var linkEl=links.item(i);addClass(linkEl,"vjs-hidden");linkEl.setAttribute("hidden","hidden")}tag.initNetworkState_=tag.networkState;if(tag.parentNode&&!playerElIngest){tag.parentNode.insertBefore(el,tag)}prependTo(tag,el);this.children_.unshift(tag);this.el_.setAttribute("lang",this.language_);this.el_=el;return el};_proto.width=function width(value){return this.dimension("width",value)};_proto.height=function height(value){return this.dimension("height",value)};_proto.dimension=function dimension(_dimension,value){var privDimension=_dimension+"_";if(value===undefined){return this[privDimension]||0}if(value===""){this[privDimension]=undefined;this.updateStyleEl_();return}var parsedVal=parseFloat(value);if(isNaN(parsedVal)){log.error('Improper value "'+value+'" supplied for for '+_dimension);return}this[privDimension]=parsedVal;this.updateStyleEl_()};_proto.fluid=function fluid(bool){if(bool===undefined){return!!this.fluid_}this.fluid_=!!bool;if(isEvented(this)){this.off("playerreset",this.updateStyleEl_)}if(bool){this.addClass("vjs-fluid");this.fill(false);addEventedCallback(function(){this.on("playerreset",this.updateStyleEl_)})}else{this.removeClass("vjs-fluid")}this.updateStyleEl_()};_proto.fill=function fill(bool){if(bool===undefined){return!!this.fill_}this.fill_=!!bool;if(bool){this.addClass("vjs-fill");this.fluid(false)}else{this.removeClass("vjs-fill")}};_proto.aspectRatio=function aspectRatio(ratio){if(ratio===undefined){return this.aspectRatio_}if(!/^\d+\:\d+$/.test(ratio)){throw new Error("Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.")}this.aspectRatio_=ratio;this.fluid(true);this.updateStyleEl_()};_proto.updateStyleEl_=function updateStyleEl_(){if(window$1.VIDEOJS_NO_DYNAMIC_STYLE===true){var _width=typeof this.width_==="number"?this.width_:this.options_.width;var _height=typeof this.height_==="number"?this.height_:this.options_.height;var techEl=this.tech_&&this.tech_.el();if(techEl){if(_width>=0){techEl.width=_width}if(_height>=0){techEl.height=_height}}return}var width;var height;var aspectRatio;var idClass;if(this.aspectRatio_!==undefined&&this.aspectRatio_!=="auto"){aspectRatio=this.aspectRatio_}else if(this.videoWidth()>0){aspectRatio=this.videoWidth()+":"+this.videoHeight()}else{aspectRatio="16:9"}var ratioParts=aspectRatio.split(":");var ratioMultiplier=ratioParts[1]/ratioParts[0];if(this.width_!==undefined){width=this.width_}else if(this.height_!==undefined){width=this.height_/ratioMultiplier}else{width=this.videoWidth()||300}if(this.height_!==undefined){height=this.height_}else{height=width*ratioMultiplier}if(/^[^a-zA-Z]/.test(this.id())){idClass="dimensions-"+this.id()}else{idClass=this.id()+"-dimensions"}this.addClass(idClass);setTextContent(this.styleEl_,"\n ."+idClass+" {\n width: "+width+"px;\n height: "+height+"px;\n }\n\n ."+idClass+".vjs-fluid {\n padding-top: "+ratioMultiplier*100+"%;\n }\n ")};_proto.loadTech_=function loadTech_(techName,source){var _this3=this;if(this.tech_){this.unloadTech_()}var titleTechName=toTitleCase(techName);var camelTechName=techName.charAt(0).toLowerCase()+techName.slice(1);if(titleTechName!=="Html5"&&this.tag){Tech.getTech("Html5").disposeMediaElement(this.tag);this.tag.player=null;this.tag=null}this.techName_=titleTechName;this.isReady_=false;var autoplay=typeof this.autoplay()==="string"?false:this.autoplay();var techOptions={source:source,autoplay:autoplay,nativeControlsForTouch:this.options_.nativeControlsForTouch,playerId:this.id(),techId:this.id()+"_"+camelTechName+"_api",playsinline:this.options_.playsinline,preload:this.options_.preload,loop:this.options_.loop,muted:this.options_.muted,poster:this.poster(),language:this.language(),playerElIngest:this.playerElIngest_||false,"vtt.js":this.options_["vtt.js"],canOverridePoster:!!this.options_.techCanOverridePoster,enableSourceset:this.options_.enableSourceset,Promise:this.options_.Promise};ALL.names.forEach(function(name){var props=ALL[name];techOptions[props.getterName]=_this3[props.privateName]});assign(techOptions,this.options_[titleTechName]);assign(techOptions,this.options_[camelTechName]);assign(techOptions,this.options_[techName.toLowerCase()]);if(this.tag){techOptions.tag=this.tag}if(source&&source.src===this.cache_.src&&this.cache_.currentTime>0){techOptions.startTime=this.cache_.currentTime}var TechClass=Tech.getTech(techName);if(!TechClass){throw new Error("No Tech named '"+titleTechName+"' exists! '"+titleTechName+"' should be registered using videojs.registerTech()'")}this.tech_=new TechClass(techOptions);this.tech_.ready(bind(this,this.handleTechReady_),true);textTrackConverter.jsonToTextTracks(this.textTracksJson_||[],this.tech_);TECH_EVENTS_RETRIGGER.forEach(function(event){_this3.on(_this3.tech_,event,_this3["handleTech"+toTitleCase(event)+"_"])});Object.keys(TECH_EVENTS_QUEUE).forEach(function(event){_this3.on(_this3.tech_,event,function(eventObj){if(_this3.tech_.playbackRate()===0&&_this3.tech_.seeking()){_this3.queuedCallbacks_.push({callback:_this3["handleTech"+TECH_EVENTS_QUEUE[event]+"_"].bind(_this3),event:eventObj});return}_this3["handleTech"+TECH_EVENTS_QUEUE[event]+"_"](eventObj)})});this.on(this.tech_,"loadstart",this.handleTechLoadStart_);this.on(this.tech_,"sourceset",this.handleTechSourceset_);this.on(this.tech_,"waiting",this.handleTechWaiting_);this.on(this.tech_,"ended",this.handleTechEnded_);this.on(this.tech_,"seeking",this.handleTechSeeking_);this.on(this.tech_,"play",this.handleTechPlay_);this.on(this.tech_,"firstplay",this.handleTechFirstPlay_);this.on(this.tech_,"pause",this.handleTechPause_);this.on(this.tech_,"durationchange",this.handleTechDurationChange_);this.on(this.tech_,"fullscreenchange",this.handleTechFullscreenChange_);this.on(this.tech_,"enterpictureinpicture",this.handleTechEnterPictureInPicture_);this.on(this.tech_,"leavepictureinpicture",this.handleTechLeavePictureInPicture_);this.on(this.tech_,"error",this.handleTechError_);this.on(this.tech_,"loadedmetadata",this.updateStyleEl_);this.on(this.tech_,"posterchange",this.handleTechPosterChange_);this.on(this.tech_,"textdata",this.handleTechTextData_);this.on(this.tech_,"ratechange",this.handleTechRateChange_);this.usingNativeControls(this.techGet_("controls"));if(this.controls()&&!this.usingNativeControls()){this.addTechControlsListeners_()}if(this.tech_.el().parentNode!==this.el()&&(titleTechName!=="Html5"||!this.tag)){prependTo(this.tech_.el(),this.el())}if(this.tag){this.tag.player=null;this.tag=null}};_proto.unloadTech_=function unloadTech_(){var _this4=this;ALL.names.forEach(function(name){var props=ALL[name];_this4[props.privateName]=_this4[props.getterName]()});this.textTracksJson_=textTrackConverter.textTracksToJson(this.tech_);this.isReady_=false;this.tech_.dispose();this.tech_=false;if(this.isPosterFromTech_){this.poster_="";this.trigger("posterchange")}this.isPosterFromTech_=false};_proto.tech=function tech(safety){if(safety===undefined){log.warn("Using the tech directly can be dangerous. I hope you know what you're doing.\n"+"See https://github.com/videojs/video.js/issues/2617 for more info.\n")}return this.tech_};_proto.addTechControlsListeners_=function addTechControlsListeners_(){this.removeTechControlsListeners_();this.on(this.tech_,"mouseup",this.handleTechClick_);this.on(this.tech_,"dblclick",this.handleTechDoubleClick_);this.on(this.tech_,"touchstart",this.handleTechTouchStart_);this.on(this.tech_,"touchmove",this.handleTechTouchMove_);this.on(this.tech_,"touchend",this.handleTechTouchEnd_);this.on(this.tech_,"tap",this.handleTechTap_)};_proto.removeTechControlsListeners_=function removeTechControlsListeners_(){this.off(this.tech_,"tap",this.handleTechTap_);this.off(this.tech_,"touchstart",this.handleTechTouchStart_);this.off(this.tech_,"touchmove",this.handleTechTouchMove_);this.off(this.tech_,"touchend",this.handleTechTouchEnd_);this.off(this.tech_,"mouseup",this.handleTechClick_);this.off(this.tech_,"dblclick",this.handleTechDoubleClick_)};_proto.handleTechReady_=function handleTechReady_(){this.triggerReady();if(this.cache_.volume){this.techCall_("setVolume",this.cache_.volume)}this.handleTechPosterChange_();this.handleTechDurationChange_()};_proto.handleTechLoadStart_=function handleTechLoadStart_(){this.removeClass("vjs-ended");this.removeClass("vjs-seeking");this.error(null);this.handleTechDurationChange_();if(!this.paused()){this.trigger("loadstart");this.trigger("firstplay")}else{this.hasStarted(false);this.trigger("loadstart")}this.manualAutoplay_(this.autoplay())};_proto.manualAutoplay_=function manualAutoplay_(type){var _this5=this;if(!this.tech_||typeof type!=="string"){return}var muted=function muted(){var previouslyMuted=_this5.muted();_this5.muted(true);var restoreMuted=function restoreMuted(){_this5.muted(previouslyMuted)};_this5.playTerminatedQueue_.push(restoreMuted);var mutedPromise=_this5.play();if(!isPromise(mutedPromise)){return}return mutedPromise["catch"](restoreMuted)};var promise;if(type==="any"&&this.muted()!==true){promise=this.play();if(isPromise(promise)){promise=promise["catch"](muted)}}else if(type==="muted"&&this.muted()!==true){promise=muted()}else{promise=this.play()}if(!isPromise(promise)){return}return promise.then(function(){_this5.trigger({type:"autoplay-success",autoplay:type})})["catch"](function(e){_this5.trigger({type:"autoplay-failure",autoplay:type})})};_proto.updateSourceCaches_=function updateSourceCaches_(srcObj){if(srcObj===void 0){srcObj=""}var src=srcObj;var type="";if(typeof src!=="string"){src=srcObj.src;type=srcObj.type}this.cache_.source=this.cache_.source||{};this.cache_.sources=this.cache_.sources||[];if(src&&!type){type=findMimetype(this,src)}this.cache_.source=mergeOptions({},srcObj,{src:src,type:type});var matchingSources=this.cache_.sources.filter(function(s){return s.src&&s.src===src});var sourceElSources=[];var sourceEls=this.$$("source");var matchingSourceEls=[];for(var i=0;i<sourceEls.length;i++){var sourceObj=getAttributes(sourceEls[i]);sourceElSources.push(sourceObj);if(sourceObj.src&&sourceObj.src===src){matchingSourceEls.push(sourceObj.src)}}if(matchingSourceEls.length&&!matchingSources.length){this.cache_.sources=sourceElSources}else if(!matchingSources.length){this.cache_.sources=[this.cache_.source]}this.cache_.src=src};_proto.handleTechSourceset_=function handleTechSourceset_(event){var _this6=this;if(!this.changingSrc_){var updateSourceCaches=function updateSourceCaches(src){return _this6.updateSourceCaches_(src)};var playerSrc=this.currentSource().src;var eventSrc=event.src;if(playerSrc&&!/^blob:/.test(playerSrc)&&/^blob:/.test(eventSrc)){if(!this.lastSource_||this.lastSource_.tech!==eventSrc&&this.lastSource_.player!==playerSrc){updateSourceCaches=function updateSourceCaches(){}}}updateSourceCaches(eventSrc);if(!event.src){this.tech_.any(["sourceset","loadstart"],function(e){if(e.type==="sourceset"){return}var techSrc=_this6.techGet("currentSrc");_this6.lastSource_.tech=techSrc;_this6.updateSourceCaches_(techSrc)})}}this.lastSource_={player:this.currentSource().src,tech:event.src};this.trigger({src:event.src,type:"sourceset"})};_proto.hasStarted=function hasStarted(request){if(request===undefined){return this.hasStarted_}if(request===this.hasStarted_){return}this.hasStarted_=request;if(this.hasStarted_){this.addClass("vjs-has-started");this.trigger("firstplay")}else{this.removeClass("vjs-has-started")}};_proto.handleTechPlay_=function handleTechPlay_(){this.removeClass("vjs-ended");this.removeClass("vjs-paused");this.addClass("vjs-playing");this.hasStarted(true);this.trigger("play")};_proto.handleTechRateChange_=function handleTechRateChange_(){if(this.tech_.playbackRate()>0&&this.cache_.lastPlaybackRate===0){this.queuedCallbacks_.forEach(function(queued){return queued.callback(queued.event)});this.queuedCallbacks_=[]}this.cache_.lastPlaybackRate=this.tech_.playbackRate();this.trigger("ratechange")};_proto.handleTechWaiting_=function handleTechWaiting_(){var _this7=this;this.addClass("vjs-waiting");this.trigger("waiting");var timeWhenWaiting=this.currentTime();var timeUpdateListener=function timeUpdateListener(){if(timeWhenWaiting!==_this7.currentTime()){_this7.removeClass("vjs-waiting");_this7.off("timeupdate",timeUpdateListener)}};this.on("timeupdate",timeUpdateListener)};_proto.handleTechCanPlay_=function handleTechCanPlay_(){this.removeClass("vjs-waiting");this.trigger("canplay")};_proto.handleTechCanPlayThrough_=function handleTechCanPlayThrough_(){this.removeClass("vjs-waiting");this.trigger("canplaythrough")};_proto.handleTechPlaying_=function handleTechPlaying_(){this.removeClass("vjs-waiting");this.trigger("playing")};_proto.handleTechSeeking_=function handleTechSeeking_(){this.addClass("vjs-seeking");this.trigger("seeking")};_proto.handleTechSeeked_=function handleTechSeeked_(){this.removeClass("vjs-seeking");this.removeClass("vjs-ended");this.trigger("seeked")};_proto.handleTechFirstPlay_=function handleTechFirstPlay_(){if(this.options_.starttime){log.warn("Passing the `starttime` option to the player will be deprecated in 6.0");this.currentTime(this.options_.starttime)}this.addClass("vjs-has-started");this.trigger("firstplay")};_proto.handleTechPause_=function handleTechPause_(){this.removeClass("vjs-playing");this.addClass("vjs-paused");this.trigger("pause")};_proto.handleTechEnded_=function handleTechEnded_(){this.addClass("vjs-ended");if(this.options_.loop){this.currentTime(0);this.play()}else if(!this.paused()){this.pause()}this.trigger("ended")};_proto.handleTechDurationChange_=function handleTechDurationChange_(){this.duration(this.techGet_("duration"))};_proto.handleTechClick_=function handleTechClick_(event){if(!isSingleLeftClick(event)){return}if(!this.controls_){return}if(this.paused()){silencePromise(this.play())}else{this.pause()}};_proto.handleTechDoubleClick_=function handleTechDoubleClick_(event){if(!this.controls_){return}var inAllowedEls=Array.prototype.some.call(this.$$(".vjs-control-bar, .vjs-modal-dialog"),function(el){return el.contains(event.target)});if(!inAllowedEls){if(this.options_===undefined||this.options_.userActions===undefined||this.options_.userActions.doubleClick===undefined||this.options_.userActions.doubleClick!==false){if(this.options_!==undefined&&this.options_.userActions!==undefined&&typeof this.options_.userActions.doubleClick==="function"){this.options_.userActions.doubleClick.call(this,event)}else if(this.isFullscreen()){this.exitFullscreen()}else{this.requestFullscreen()}}}};_proto.handleTechTap_=function handleTechTap_(){this.userActive(!this.userActive())};_proto.handleTechTouchStart_=function handleTechTouchStart_(){this.userWasActive=this.userActive()};_proto.handleTechTouchMove_=function handleTechTouchMove_(){if(this.userWasActive){this.reportUserActivity()}};_proto.handleTechTouchEnd_=function handleTechTouchEnd_(event){event.preventDefault()};_proto.handleStageClick_=function handleStageClick_(){this.reportUserActivity()};_proto.toggleFullscreenClass_=function toggleFullscreenClass_(){if(this.isFullscreen()){this.addClass("vjs-fullscreen")}else{this.removeClass("vjs-fullscreen")}};_proto.documentFullscreenChange_=function documentFullscreenChange_(e){var el=this.el();var isFs=document[this.fsApi_.fullscreenElement]===el;if(!isFs&&el.matches){isFs=el.matches(":"+this.fsApi_.fullscreen)}else if(!isFs&&el.msMatchesSelector){isFs=el.msMatchesSelector(":"+this.fsApi_.fullscreen)}this.isFullscreen(isFs);if(this.isFullscreen()===false){off(document,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_)}if(this.fsApi_.prefixed){this.trigger("fullscreenchange")}};_proto.handleTechFullscreenChange_=function handleTechFullscreenChange_(event,data){if(data){this.isFullscreen(data.isFullscreen)}this.trigger("fullscreenchange")};_proto.togglePictureInPictureClass_=function togglePictureInPictureClass_(){if(this.isInPictureInPicture()){this.addClass("vjs-picture-in-picture")}else{this.removeClass("vjs-picture-in-picture")}};_proto.handleTechEnterPictureInPicture_=function handleTechEnterPictureInPicture_(event){this.isInPictureInPicture(true)};_proto.handleTechLeavePictureInPicture_=function handleTechLeavePictureInPicture_(event){this.isInPictureInPicture(false)};_proto.handleTechError_=function handleTechError_(){var error=this.tech_.error();this.error(error)};_proto.handleTechTextData_=function handleTechTextData_(){var data=null;if(arguments.length>1){data=arguments[1]}this.trigger("textdata",data)};_proto.getCache=function getCache(){return this.cache_};_proto.resetCache_=function resetCache_(){this.cache_={currentTime:0,inactivityTimeout:this.options_.inactivityTimeout,duration:NaN,lastVolume:1,lastPlaybackRate:this.defaultPlaybackRate(),media:null,src:"",source:{},sources:[],volume:1}};_proto.techCall_=function techCall_(method,arg){this.ready(function(){if(method in allowedSetters){return set(this.middleware_,this.tech_,method,arg)}else if(method in allowedMediators){return mediate(this.middleware_,this.tech_,method,arg)}try{if(this.tech_){this.tech_[method](arg)}}catch(e){log(e);throw e}},true)};_proto.techGet_=function techGet_(method){if(!this.tech_||!this.tech_.isReady_){return}if(method in allowedGetters){return get(this.middleware_,this.tech_,method)}else if(method in allowedMediators){return mediate(this.middleware_,this.tech_,method)}try{return this.tech_[method]()}catch(e){if(this.tech_[method]===undefined){log("Video.js: "+method+" method not defined for "+this.techName_+" playback technology.",e);throw e}if(e.name==="TypeError"){log("Video.js: "+method+" unavailable on "+this.techName_+" playback technology element.",e);this.tech_.isReady_=false;throw e}log(e);throw e}};_proto.play=function play(){var _this8=this;var PromiseClass=this.options_.Promise||window$1.Promise;if(PromiseClass){return new PromiseClass(function(resolve){_this8.play_(resolve)})}return this.play_()};_proto.play_=function play_(callback){var _this9=this;if(callback===void 0){callback=silencePromise}this.playCallbacks_.push(callback);var isSrcReady=Boolean(!this.changingSrc_&&(this.src()||this.currentSrc()));if(this.waitToPlay_){this.off(["ready","loadstart"],this.waitToPlay_);this.waitToPlay_=null}if(!this.isReady_||!isSrcReady){this.waitToPlay_=function(e){_this9.play_()};this.one(["ready","loadstart"],this.waitToPlay_);if(!isSrcReady&&(IS_ANY_SAFARI||IS_IOS)){this.load()}return}var val=this.techGet_("play");if(val===null){this.runPlayTerminatedQueue_()}else{this.runPlayCallbacks_(val)}};_proto.runPlayTerminatedQueue_=function runPlayTerminatedQueue_(){var queue=this.playTerminatedQueue_.slice(0);this.playTerminatedQueue_=[];queue.forEach(function(q){q()})};_proto.runPlayCallbacks_=function runPlayCallbacks_(val){var callbacks=this.playCallbacks_.slice(0);this.playCallbacks_=[];this.playTerminatedQueue_=[];callbacks.forEach(function(cb){cb(val)})};_proto.pause=function pause(){this.techCall_("pause")};_proto.paused=function paused(){return this.techGet_("paused")===false?false:true};_proto.played=function played(){return this.techGet_("played")||createTimeRanges(0,0)};_proto.scrubbing=function scrubbing(isScrubbing){if(typeof isScrubbing==="undefined"){return this.scrubbing_}this.scrubbing_=!!isScrubbing;if(isScrubbing){this.addClass("vjs-scrubbing")}else{this.removeClass("vjs-scrubbing")}};_proto.currentTime=function currentTime(seconds){if(typeof seconds!=="undefined"){if(seconds<0){seconds=0}this.techCall_("setCurrentTime",seconds);return}this.cache_.currentTime=this.techGet_("currentTime")||0;return this.cache_.currentTime};_proto.duration=function duration(seconds){if(seconds===undefined){return this.cache_.duration!==undefined?this.cache_.duration:NaN}seconds=parseFloat(seconds);if(seconds<0){seconds=Infinity}if(seconds!==this.cache_.duration){this.cache_.duration=seconds;if(seconds===Infinity){this.addClass("vjs-live");if(this.options_.liveui&&this.player_.liveTracker){this.addClass("vjs-liveui")}}else{this.removeClass("vjs-live");this.removeClass("vjs-liveui")}if(!isNaN(seconds)){this.trigger("durationchange")}}};_proto.remainingTime=function remainingTime(){return this.duration()-this.currentTime()};_proto.remainingTimeDisplay=function remainingTimeDisplay(){return Math.floor(this.duration())-Math.floor(this.currentTime())};_proto.buffered=function buffered(){var buffered=this.techGet_("buffered");if(!buffered||!buffered.length){buffered=createTimeRanges(0,0)}return buffered};_proto.bufferedPercent=function bufferedPercent$1(){return bufferedPercent(this.buffered(),this.duration())};_proto.bufferedEnd=function bufferedEnd(){var buffered=this.buffered();var duration=this.duration();var end=buffered.end(buffered.length-1);if(end>duration){end=duration}return end};_proto.volume=function volume(percentAsDecimal){var vol;if(percentAsDecimal!==undefined){vol=Math.max(0,Math.min(1,parseFloat(percentAsDecimal)));this.cache_.volume=vol;this.techCall_("setVolume",vol);if(vol>0){this.lastVolume_(vol)}return}vol=parseFloat(this.techGet_("volume"));return isNaN(vol)?1:vol};_proto.muted=function muted(_muted){if(_muted!==undefined){this.techCall_("setMuted",_muted);return}return this.techGet_("muted")||false};_proto.defaultMuted=function defaultMuted(_defaultMuted){if(_defaultMuted!==undefined){return this.techCall_("setDefaultMuted",_defaultMuted)}return this.techGet_("defaultMuted")||false};_proto.lastVolume_=function lastVolume_(percentAsDecimal){if(percentAsDecimal!==undefined&&percentAsDecimal!==0){this.cache_.lastVolume=percentAsDecimal;return}return this.cache_.lastVolume};_proto.supportsFullScreen=function supportsFullScreen(){return this.techGet_("supportsFullScreen")||false};_proto.isFullscreen=function isFullscreen(isFS){if(isFS!==undefined){this.isFullscreen_=!!isFS;this.toggleFullscreenClass_();return}return!!this.isFullscreen_};_proto.requestFullscreen=function requestFullscreen(fullscreenOptions){var fsOptions;this.isFullscreen(true);if(this.fsApi_.requestFullscreen){on(document,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_);if(!this.fsApi_.prefixed){fsOptions=this.options_.fullscreen&&this.options_.fullscreen.options||{};if(fullscreenOptions!==undefined){fsOptions=fullscreenOptions}}silencePromise(this.el_[this.fsApi_.requestFullscreen](fsOptions))}else if(this.tech_.supportsFullScreen()){this.techCall_("enterFullScreen")}else{this.enterFullWindow();this.trigger("fullscreenchange")}};_proto.exitFullscreen=function exitFullscreen(){this.isFullscreen(false);if(this.fsApi_.requestFullscreen){silencePromise(document[this.fsApi_.exitFullscreen]())}else if(this.tech_.supportsFullScreen()){this.techCall_("exitFullScreen")}else{this.exitFullWindow();this.trigger("fullscreenchange")}};_proto.enterFullWindow=function enterFullWindow(){this.isFullWindow=true;this.docOrigOverflow=document.documentElement.style.overflow;on(document,"keydown",this.boundFullWindowOnEscKey_);document.documentElement.style.overflow="hidden";addClass(document.body,"vjs-full-window");this.trigger("enterFullWindow")};_proto.fullWindowOnEscKey=function fullWindowOnEscKey(event){if(keycode.isEventKey(event,"Esc")){if(this.isFullscreen()===true){this.exitFullscreen()}else{this.exitFullWindow()}}};_proto.exitFullWindow=function exitFullWindow(){this.isFullWindow=false;off(document,"keydown",this.boundFullWindowOnEscKey_);document.documentElement.style.overflow=this.docOrigOverflow;removeClass(document.body,"vjs-full-window");this.trigger("exitFullWindow")};_proto.isInPictureInPicture=function isInPictureInPicture(isPiP){if(isPiP!==undefined){this.isInPictureInPicture_=!!isPiP;this.togglePictureInPictureClass_();return}return!!this.isInPictureInPicture_};_proto.requestPictureInPicture=function requestPictureInPicture(){if("pictureInPictureEnabled"in document){return this.techGet_("requestPictureInPicture")}};_proto.exitPictureInPicture=function exitPictureInPicture(){if("pictureInPictureEnabled"in document){return document.exitPictureInPicture()}};_proto.handleKeyDown=function handleKeyDown(event){var userActions=this.options_.userActions;if(!userActions||!userActions.hotkeys){return}var excludeElement=function excludeElement(el){var tagName=el.tagName.toLowerCase();if(el.isContentEditable){return true}var allowedInputTypes=["button","checkbox","hidden","radio","reset","submit"];if(tagName==="input"){return allowedInputTypes.indexOf(el.type)===-1}var excludedTags=["textarea"];return excludedTags.indexOf(tagName)!==-1};if(excludeElement(this.el_.ownerDocument.activeElement)){return}if(typeof userActions.hotkeys==="function"){userActions.hotkeys.call(this,event)}else{this.handleHotkeys(event)}};_proto.handleHotkeys=function handleHotkeys(event){var hotkeys=this.options_.userActions?this.options_.userActions.hotkeys:{};var _hotkeys$fullscreenKe=hotkeys.fullscreenKey,fullscreenKey=_hotkeys$fullscreenKe===void 0?function(keydownEvent){return keycode.isEventKey(keydownEvent,"f")}:_hotkeys$fullscreenKe,_hotkeys$muteKey=hotkeys.muteKey,muteKey=_hotkeys$muteKey===void 0?function(keydownEvent){return keycode.isEventKey(keydownEvent,"m")}:_hotkeys$muteKey,_hotkeys$playPauseKey=hotkeys.playPauseKey,playPauseKey=_hotkeys$playPauseKey===void 0?function(keydownEvent){return keycode.isEventKey(keydownEvent,"k")||keycode.isEventKey(keydownEvent,"Space")}:_hotkeys$playPauseKey;if(fullscreenKey.call(this,event)){event.preventDefault();event.stopPropagation();var FSToggle=Component.getComponent("FullscreenToggle");if(document[this.fsApi_.fullscreenEnabled]!==false){FSToggle.prototype.handleClick.call(this,event)}}else if(muteKey.call(this,event)){event.preventDefault();event.stopPropagation();var MuteToggle=Component.getComponent("MuteToggle");MuteToggle.prototype.handleClick.call(this,event)}else if(playPauseKey.call(this,event)){event.preventDefault();event.stopPropagation();var PlayToggle=Component.getComponent("PlayToggle");PlayToggle.prototype.handleClick.call(this,event)}};_proto.canPlayType=function canPlayType(type){var can;for(var i=0,j=this.options_.techOrder;i<j.length;i++){var techName=j[i];var tech=Tech.getTech(techName);if(!tech){tech=Component.getComponent(techName)}if(!tech){log.error('The "'+techName+'" tech is undefined. Skipped browser support check for that tech.');continue}if(tech.isSupported()){can=tech.canPlayType(type);if(can){return can}}}return""};_proto.selectSource=function selectSource(sources){var _this10=this;var techs=this.options_.techOrder.map(function(techName){return[techName,Tech.getTech(techName)]}).filter(function(_ref){var techName=_ref[0],tech=_ref[1];if(tech){return tech.isSupported()}log.error('The "'+techName+'" tech is undefined. Skipped browser support check for that tech.');return false});var findFirstPassingTechSourcePair=function findFirstPassingTechSourcePair(outerArray,innerArray,tester){var found;outerArray.some(function(outerChoice){return innerArray.some(function(innerChoice){found=tester(outerChoice,innerChoice);if(found){return true}})});return found};var foundSourceAndTech;var flip=function flip(fn){return function(a,b){return fn(b,a)}};var finder=function finder(_ref2,source){var techName=_ref2[0],tech=_ref2[1];if(tech.canPlaySource(source,_this10.options_[techName.toLowerCase()])){return{source:source,tech:techName}}};if(this.options_.sourceOrder){foundSourceAndTech=findFirstPassingTechSourcePair(sources,techs,flip(finder))}else{foundSourceAndTech=findFirstPassingTechSourcePair(techs,sources,finder)}return foundSourceAndTech||false};_proto.src=function src(source){var _this11=this;if(typeof source==="undefined"){return this.cache_.src||""}var sources=filterSource(source);if(!sources.length){this.setTimeout(function(){this.error({code:4,message:this.localize(this.options_.notSupportedMessage)})},0);return}this.changingSrc_=true;this.cache_.sources=sources;this.updateSourceCaches_(sources[0]);setSource(this,sources[0],function(middlewareSource,mws){_this11.middleware_=mws;_this11.cache_.sources=sources;_this11.updateSourceCaches_(middlewareSource);var err=_this11.src_(middlewareSource);if(err){if(sources.length>1){return _this11.src(sources.slice(1))}_this11.changingSrc_=false;_this11.setTimeout(function(){this.error({code:4,message:this.localize(this.options_.notSupportedMessage)})},0);_this11.triggerReady();return}setTech(mws,_this11.tech_)})};_proto.src_=function src_(source){var _this12=this;var sourceTech=this.selectSource([source]);if(!sourceTech){return true}if(!titleCaseEquals(sourceTech.tech,this.techName_)){this.changingSrc_=true;this.loadTech_(sourceTech.tech,sourceTech.source);this.tech_.ready(function(){_this12.changingSrc_=false});return false}this.ready(function(){if(this.tech_.constructor.prototype.hasOwnProperty("setSource")){this.techCall_("setSource",source)}else{this.techCall_("src",source.src)}this.changingSrc_=false},true);return false};_proto.load=function load(){this.techCall_("load")};_proto.reset=function reset(){var _this13=this;var PromiseClass=this.options_.Promise||window$1.Promise;if(this.paused()||!PromiseClass){this.doReset_()}else{var playPromise=this.play();silencePromise(playPromise.then(function(){return _this13.doReset_()}))}};_proto.doReset_=function doReset_(){if(this.tech_){this.tech_.clearTracks("text")}this.resetCache_();this.poster("");this.loadTech_(this.options_.techOrder[0],null);this.techCall_("reset");this.resetControlBarUI_();if(isEvented(this)){this.trigger("playerreset")}};_proto.resetControlBarUI_=function resetControlBarUI_(){this.resetProgressBar_();this.resetPlaybackRate_();this.resetVolumeBar_()};_proto.resetProgressBar_=function resetProgressBar_(){this.currentTime(0);var _this$controlBar=this.controlBar,durationDisplay=_this$controlBar.durationDisplay,remainingTimeDisplay=_this$controlBar.remainingTimeDisplay;if(durationDisplay){durationDisplay.updateContent()}if(remainingTimeDisplay){remainingTimeDisplay.updateContent()}};_proto.resetPlaybackRate_=function resetPlaybackRate_(){this.playbackRate(this.defaultPlaybackRate());this.handleTechRateChange_()};_proto.resetVolumeBar_=function resetVolumeBar_(){this.volume(1);this.trigger("volumechange")};_proto.currentSources=function currentSources(){var source=this.currentSource();var sources=[];if(Object.keys(source).length!==0){sources.push(source)}return this.cache_.sources||sources};_proto.currentSource=function currentSource(){return this.cache_.source||{}};_proto.currentSrc=function currentSrc(){return this.currentSource()&&this.currentSource().src||""};_proto.currentType=function currentType(){return this.currentSource()&&this.currentSource().type||""};_proto.preload=function preload(value){if(value!==undefined){this.techCall_("setPreload",value);this.options_.preload=value;return}return this.techGet_("preload")};_proto.autoplay=function autoplay(value){if(value===undefined){return this.options_.autoplay||false}var techAutoplay;if(typeof value==="string"&&/(any|play|muted)/.test(value)){this.options_.autoplay=value;this.manualAutoplay_(value);techAutoplay=false}else if(!value){this.options_.autoplay=false}else{this.options_.autoplay=true}techAutoplay=typeof techAutoplay==="undefined"?this.options_.autoplay:techAutoplay;if(this.tech_){this.techCall_("setAutoplay",techAutoplay)}};_proto.playsinline=function playsinline(value){if(value!==undefined){this.techCall_("setPlaysinline",value);this.options_.playsinline=value;return this}return this.techGet_("playsinline")};_proto.loop=function loop(value){if(value!==undefined){this.techCall_("setLoop",value);this.options_.loop=value;return}return this.techGet_("loop")};_proto.poster=function poster(src){if(src===undefined){return this.poster_}if(!src){src=""}if(src===this.poster_){return}this.poster_=src;this.techCall_("setPoster",src);this.isPosterFromTech_=false;this.trigger("posterchange")};_proto.handleTechPosterChange_=function handleTechPosterChange_(){if((!this.poster_||this.options_.techCanOverridePoster)&&this.tech_&&this.tech_.poster){var newPoster=this.tech_.poster()||"";if(newPoster!==this.poster_){this.poster_=newPoster;this.isPosterFromTech_=true;this.trigger("posterchange")}}};_proto.controls=function controls(bool){if(bool===undefined){return!!this.controls_}bool=!!bool;if(this.controls_===bool){return}this.controls_=bool;if(this.usingNativeControls()){this.techCall_("setControls",bool)}if(this.controls_){this.removeClass("vjs-controls-disabled");this.addClass("vjs-controls-enabled");this.trigger("controlsenabled");if(!this.usingNativeControls()){this.addTechControlsListeners_()}}else{this.removeClass("vjs-controls-enabled");this.addClass("vjs-controls-disabled");this.trigger("controlsdisabled");if(!this.usingNativeControls()){this.removeTechControlsListeners_()}}};_proto.usingNativeControls=function usingNativeControls(bool){if(bool===undefined){return!!this.usingNativeControls_}bool=!!bool;if(this.usingNativeControls_===bool){return}this.usingNativeControls_=bool;if(this.usingNativeControls_){this.addClass("vjs-using-native-controls");this.trigger("usingnativecontrols")}else{this.removeClass("vjs-using-native-controls");this.trigger("usingcustomcontrols")}};_proto.error=function error(err){if(err===undefined){return this.error_||null}if(this.options_.suppressNotSupportedError&&err&&err.message&&err.message===this.localize(this.options_.notSupportedMessage)){var triggerSuppressedError=function triggerSuppressedError(){this.error(err)};this.options_.suppressNotSupportedError=false;this.any(["click","touchstart"],triggerSuppressedError);this.one("loadstart",function(){this.off(["click","touchstart"],triggerSuppressedError)});return}if(err===null){this.error_=err;this.removeClass("vjs-error");if(this.errorDisplay){this.errorDisplay.close()}return}this.error_=new MediaError(err);this.addClass("vjs-error");log.error("(CODE:"+this.error_.code+" "+MediaError.errorTypes[this.error_.code]+")",this.error_.message,this.error_);this.trigger("error");return};_proto.reportUserActivity=function reportUserActivity(event){this.userActivity_=true};_proto.userActive=function userActive(bool){if(bool===undefined){return this.userActive_}bool=!!bool;if(bool===this.userActive_){return}this.userActive_=bool;if(this.userActive_){this.userActivity_=true;this.removeClass("vjs-user-inactive");this.addClass("vjs-user-active");this.trigger("useractive");return}if(this.tech_){this.tech_.one("mousemove",function(e){e.stopPropagation();e.preventDefault()})}this.userActivity_=false;this.removeClass("vjs-user-active");this.addClass("vjs-user-inactive");this.trigger("userinactive")};_proto.listenForUserActivity_=function listenForUserActivity_(){var mouseInProgress;var lastMoveX;var lastMoveY;var handleActivity=bind(this,this.reportUserActivity);var handleMouseMove=function handleMouseMove(e){if(e.screenX!==lastMoveX||e.screenY!==lastMoveY){lastMoveX=e.screenX;lastMoveY=e.screenY;handleActivity()}};var handleMouseDown=function handleMouseDown(){handleActivity();this.clearInterval(mouseInProgress);mouseInProgress=this.setInterval(handleActivity,250)};var handleMouseUp=function handleMouseUp(event){handleActivity();this.clearInterval(mouseInProgress)};this.on("mousedown",handleMouseDown);this.on("mousemove",handleMouseMove);this.on("mouseup",handleMouseUp);var controlBar=this.getChild("controlBar");if(controlBar&&!IS_IOS&&!IS_ANDROID){controlBar.on("mouseenter",function(event){this.player().cache_.inactivityTimeout=this.player().options_.inactivityTimeout;this.player().options_.inactivityTimeout=0});controlBar.on("mouseleave",function(event){this.player().options_.inactivityTimeout=this.player().cache_.inactivityTimeout})}this.on("keydown",handleActivity);this.on("keyup",handleActivity);var inactivityTimeout;this.setInterval(function(){if(!this.userActivity_){return}this.userActivity_=false;this.userActive(true);this.clearTimeout(inactivityTimeout);var timeout=this.options_.inactivityTimeout;if(timeout<=0){return}inactivityTimeout=this.setTimeout(function(){if(!this.userActivity_){this.userActive(false)}},timeout)},250)};_proto.playbackRate=function playbackRate(rate){if(rate!==undefined){this.techCall_("setPlaybackRate",rate);return}if(this.tech_&&this.tech_.featuresPlaybackRate){return this.cache_.lastPlaybackRate||this.techGet_("playbackRate")}return 1};_proto.defaultPlaybackRate=function defaultPlaybackRate(rate){if(rate!==undefined){return this.techCall_("setDefaultPlaybackRate",rate)}if(this.tech_&&this.tech_.featuresPlaybackRate){return this.techGet_("defaultPlaybackRate")}return 1};_proto.isAudio=function isAudio(bool){if(bool!==undefined){this.isAudio_=!!bool;return}return!!this.isAudio_};_proto.addTextTrack=function addTextTrack(kind,label,language){if(this.tech_){return this.tech_.addTextTrack(kind,label,language)}};_proto.addRemoteTextTrack=function addRemoteTextTrack(options,manualCleanup){if(this.tech_){return this.tech_.addRemoteTextTrack(options,manualCleanup)}};_proto.removeRemoteTextTrack=function removeRemoteTextTrack(obj){if(obj===void 0){obj={}}var _obj=obj,track=_obj.track;if(!track){track=obj}if(this.tech_){return this.tech_.removeRemoteTextTrack(track)}};_proto.getVideoPlaybackQuality=function getVideoPlaybackQuality(){return this.techGet_("getVideoPlaybackQuality")};_proto.videoWidth=function videoWidth(){return this.tech_&&this.tech_.videoWidth&&this.tech_.videoWidth()||0};_proto.videoHeight=function videoHeight(){return this.tech_&&this.tech_.videoHeight&&this.tech_.videoHeight()||0};_proto.language=function language(code){if(code===undefined){return this.language_}this.language_=String(code).toLowerCase()};_proto.languages=function languages(){return mergeOptions(Player.prototype.options_.languages,this.languages_)};_proto.toJSON=function toJSON(){var options=mergeOptions(this.options_);var tracks=options.tracks;options.tracks=[];for(var i=0;i<tracks.length;i++){var track=tracks[i];track=mergeOptions(track);track.player=undefined;options.tracks[i]=track}return options};_proto.createModal=function createModal(content,options){var _this14=this;options=options||{};options.content=content||"";var modal=new ModalDialog(this,options);this.addChild(modal);modal.on("dispose",function(){_this14.removeChild(modal)});modal.open();return modal};_proto.updateCurrentBreakpoint_=function updateCurrentBreakpoint_(){if(!this.responsive()){return}var currentBreakpoint=this.currentBreakpoint();var currentWidth=this.currentWidth();for(var i=0;i<BREAKPOINT_ORDER.length;i++){var candidateBreakpoint=BREAKPOINT_ORDER[i];var maxWidth=this.breakpoints_[candidateBreakpoint];if(currentWidth<=maxWidth){if(currentBreakpoint===candidateBreakpoint){return}if(currentBreakpoint){this.removeClass(BREAKPOINT_CLASSES[currentBreakpoint])}this.addClass(BREAKPOINT_CLASSES[candidateBreakpoint]);this.breakpoint_=candidateBreakpoint;break}}};_proto.removeCurrentBreakpoint_=function removeCurrentBreakpoint_(){var className=this.currentBreakpointClass();this.breakpoint_="";if(className){this.removeClass(className)}};_proto.breakpoints=function breakpoints(_breakpoints){if(_breakpoints===undefined){return assign(this.breakpoints_)}this.breakpoint_="";this.breakpoints_=assign({},DEFAULT_BREAKPOINTS,_breakpoints);this.updateCurrentBreakpoint_();return assign(this.breakpoints_)};_proto.responsive=function responsive(value){if(value===undefined){return this.responsive_}value=Boolean(value);var current=this.responsive_;if(value===current){return}this.responsive_=value;if(value){this.on("playerresize",this.updateCurrentBreakpoint_);this.updateCurrentBreakpoint_()}else{this.off("playerresize",this.updateCurrentBreakpoint_);this.removeCurrentBreakpoint_()}return value};_proto.currentBreakpoint=function currentBreakpoint(){return this.breakpoint_};_proto.currentBreakpointClass=function currentBreakpointClass(){return BREAKPOINT_CLASSES[this.breakpoint_]||""};_proto.loadMedia=function loadMedia(media,ready){var _this15=this;if(!media||typeof media!=="object"){return}this.reset();this.cache_.media=mergeOptions(media);var _this$cache_$media=this.cache_.media,artwork=_this$cache_$media.artwork,poster=_this$cache_$media.poster,src=_this$cache_$media.src,textTracks=_this$cache_$media.textTracks;if(!artwork&&poster){this.cache_.media.artwork=[{src:poster,type:getMimetype(poster)}]}if(src){this.src(src)}if(poster){this.poster(poster)}if(Array.isArray(textTracks)){textTracks.forEach(function(tt){return _this15.addRemoteTextTrack(tt,false)})}this.ready(ready)};_proto.getMedia=function getMedia(){if(!this.cache_.media){var poster=this.poster();var src=this.currentSources();var textTracks=Array.prototype.map.call(this.remoteTextTracks(),function(tt){return{kind:tt.kind,label:tt.label,language:tt.language,src:tt.src}});var media={src:src,textTracks:textTracks};if(poster){media.poster=poster;media.artwork=[{src:media.poster,type:getMimetype(media.poster)}]}return media}return mergeOptions(this.cache_.media)};Player.getTagSettings=function getTagSettings(tag){var baseOptions={sources:[],tracks:[]};var tagOptions=getAttributes(tag);var dataSetup=tagOptions["data-setup"];if(hasClass(tag,"vjs-fill")){tagOptions.fill=true}if(hasClass(tag,"vjs-fluid")){tagOptions.fluid=true}if(dataSetup!==null){var _safeParseTuple=tuple(dataSetup||"{}"),err=_safeParseTuple[0],data=_safeParseTuple[1];if(err){log.error(err)}assign(tagOptions,data)}assign(baseOptions,tagOptions);if(tag.hasChildNodes()){var children=tag.childNodes;for(var i=0,j=children.length;i<j;i++){var child=children[i];var childName=child.nodeName.toLowerCase();if(childName==="source"){baseOptions.sources.push(getAttributes(child))}else if(childName==="track"){baseOptions.tracks.push(getAttributes(child))}}}return baseOptions};_proto.flexNotSupported_=function flexNotSupported_(){var elem=document.createElement("i");return!("flexBasis"in elem.style||"webkitFlexBasis"in elem.style||"mozFlexBasis"in elem.style||"msFlexBasis"in elem.style||"msFlexOrder"in elem.style)};return Player}(Component);ALL.names.forEach(function(name){var props=ALL[name];Player.prototype[props.getterName]=function(){if(this.tech_){return this.tech_[props.getterName]()}this[props.privateName]=this[props.privateName]||new props.ListClass;return this[props.privateName]}});Player.players={};var navigator=window$1.navigator;Player.prototype.options_={techOrder:Tech.defaultTechOrder_,html5:{},flash:{},inactivityTimeout:2e3,playbackRates:[],liveui:false,children:["mediaLoader","posterImage","textTrackDisplay","loadingSpinner","bigPlayButton","liveTracker","controlBar","errorDisplay","textTrackSettings","resizeManager"],language:navigator&&(navigator.languages&&navigator.languages[0]||navigator.userLanguage||navigator.language)||"en",languages:{},notSupportedMessage:"No compatible source was found for this media.",fullscreen:{options:{navigationUI:"hide"}},breakpoints:{},responsive:false};["ended","seeking","seekable","networkState","readyState"].forEach(function(fn){Player.prototype[fn]=function(){return this.techGet_(fn)}});TECH_EVENTS_RETRIGGER.forEach(function(event){Player.prototype["handleTech"+toTitleCase(event)+"_"]=function(){return this.trigger(event)}});Component.registerComponent("Player",Player);var BASE_PLUGIN_NAME="plugin";var PLUGIN_CACHE_KEY="activePlugins_";var pluginStorage={};var pluginExists=function pluginExists(name){return pluginStorage.hasOwnProperty(name)};var getPlugin=function getPlugin(name){return pluginExists(name)?pluginStorage[name]:undefined};var markPluginAsActive=function markPluginAsActive(player,name){player[PLUGIN_CACHE_KEY]=player[PLUGIN_CACHE_KEY]||{};player[PLUGIN_CACHE_KEY][name]=true};var triggerSetupEvent=function triggerSetupEvent(player,hash,before){var eventName=(before?"before":"")+"pluginsetup";player.trigger(eventName,hash);player.trigger(eventName+":"+hash.name,hash)};var createBasicPlugin=function createBasicPlugin(name,plugin){var basicPluginWrapper=function basicPluginWrapper(){triggerSetupEvent(this,{name:name,plugin:plugin,instance:null},true);var instance=plugin.apply(this,arguments);markPluginAsActive(this,name);triggerSetupEvent(this,{name:name,plugin:plugin,instance:instance});return instance};Object.keys(plugin).forEach(function(prop){basicPluginWrapper[prop]=plugin[prop]});return basicPluginWrapper};var createPluginFactory=function createPluginFactory(name,PluginSubClass){PluginSubClass.prototype.name=name;return function(){triggerSetupEvent(this,{name:name,plugin:PluginSubClass,instance:null},true);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}var instance=_construct(PluginSubClass,[this].concat(args));this[name]=function(){return instance};triggerSetupEvent(this,instance.getEventHash());return instance}};var Plugin=function(){function Plugin(player){if(this.constructor===Plugin){throw new Error("Plugin must be sub-classed; not directly instantiated.")}this.player=player;evented(this);delete this.trigger;stateful(this,this.constructor.defaultState);markPluginAsActive(player,this.name);this.dispose=bind(this,this.dispose);player.on("dispose",this.dispose)}var _proto=Plugin.prototype;_proto.version=function version(){return this.constructor.VERSION};_proto.getEventHash=function getEventHash(hash){if(hash===void 0){hash={}}hash.name=this.name;hash.plugin=this.constructor;hash.instance=this;return hash};_proto.trigger=function trigger$1(event,hash){if(hash===void 0){hash={}}return trigger(this.eventBusEl_,event,this.getEventHash(hash))};_proto.handleStateChanged=function handleStateChanged(e){};_proto.dispose=function dispose(){var name=this.name,player=this.player;this.trigger("dispose");this.off();player.off("dispose",this.dispose);player[PLUGIN_CACHE_KEY][name]=false;this.player=this.state=null;player[name]=createPluginFactory(name,pluginStorage[name])};Plugin.isBasic=function isBasic(plugin){var p=typeof plugin==="string"?getPlugin(plugin):plugin;return typeof p==="function"&&!Plugin.prototype.isPrototypeOf(p.prototype)};Plugin.registerPlugin=function registerPlugin(name,plugin){if(typeof name!=="string"){throw new Error('Illegal plugin name, "'+name+'", must be a string, was '+typeof name+".")}if(pluginExists(name)){log.warn('A plugin named "'+name+'" already exists. You may want to avoid re-registering plugins!')}else if(Player.prototype.hasOwnProperty(name)){throw new Error('Illegal plugin name, "'+name+'", cannot share a name with an existing player method!')}if(typeof plugin!=="function"){throw new Error('Illegal plugin for "'+name+'", must be a function, was '+typeof plugin+".")}pluginStorage[name]=plugin;if(name!==BASE_PLUGIN_NAME){if(Plugin.isBasic(plugin)){Player.prototype[name]=createBasicPlugin(name,plugin)}else{Player.prototype[name]=createPluginFactory(name,plugin)}}return plugin};Plugin.deregisterPlugin=function deregisterPlugin(name){if(name===BASE_PLUGIN_NAME){throw new Error("Cannot de-register base plugin.")}if(pluginExists(name)){delete pluginStorage[name];delete Player.prototype[name]}};Plugin.getPlugins=function getPlugins(names){if(names===void 0){names=Object.keys(pluginStorage)}var result;names.forEach(function(name){var plugin=getPlugin(name);if(plugin){result=result||{};result[name]=plugin}});return result};Plugin.getPluginVersion=function getPluginVersion(name){var plugin=getPlugin(name);return plugin&&plugin.VERSION||""};return Plugin}();Plugin.getPlugin=getPlugin;Plugin.BASE_PLUGIN_NAME=BASE_PLUGIN_NAME;Plugin.registerPlugin(BASE_PLUGIN_NAME,Plugin);Player.prototype.usingPlugin=function(name){return!!this[PLUGIN_CACHE_KEY]&&this[PLUGIN_CACHE_KEY][name]===true};Player.prototype.hasPlugin=function(name){return!!pluginExists(name)};var _inherits=function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass){subClass.super_=superClass}};var extend$1=function extend(superClass,subClassMethods){if(subClassMethods===void 0){subClassMethods={}}var subClass=function subClass(){superClass.apply(this,arguments)};var methods={};if(typeof subClassMethods==="object"){if(subClassMethods.constructor!==Object.prototype.constructor){subClass=subClassMethods.constructor}methods=subClassMethods}else if(typeof subClassMethods==="function"){subClass=subClassMethods}_inherits(subClass,superClass);for(var name in methods){if(methods.hasOwnProperty(name)){subClass.prototype[name]=methods[name]}}return subClass};var normalizeId=function normalizeId(id){return id.indexOf("#")===0?id.slice(1):id};function videojs$1(id,options,ready){var player=videojs$1.getPlayer(id);if(player){if(options){log.warn('Player "'+id+'" is already initialised. Options will not be applied.')}if(ready){player.ready(ready)}return player}var el=typeof id==="string"?$("#"+normalizeId(id)):id;if(!isEl(el)){throw new TypeError("The element or ID supplied is not valid. (videojs)")}if(!el.ownerDocument.defaultView||!el.ownerDocument.body.contains(el)){log.warn("The element supplied is not included in the DOM")}options=options||{};videojs$1.hooks("beforesetup").forEach(function(hookFunction){var opts=hookFunction(el,mergeOptions(options));if(!isObject(opts)||Array.isArray(opts)){log.error("please return an object in beforesetup hooks");return}options=mergeOptions(options,opts)});var PlayerComponent=Component.getComponent("Player");player=new PlayerComponent(el,options,ready);videojs$1.hooks("setup").forEach(function(hookFunction){return hookFunction(player)});return player}videojs$1.hooks_={};videojs$1.hooks=function(type,fn){videojs$1.hooks_[type]=videojs$1.hooks_[type]||[];if(fn){videojs$1.hooks_[type]=videojs$1.hooks_[type].concat(fn)}return videojs$1.hooks_[type]};videojs$1.hook=function(type,fn){videojs$1.hooks(type,fn)};videojs$1.hookOnce=function(type,fn){videojs$1.hooks(type,[].concat(fn).map(function(original){var wrapper=function wrapper(){videojs$1.removeHook(type,wrapper);return original.apply(void 0,arguments)};return wrapper}))};videojs$1.removeHook=function(type,fn){var index=videojs$1.hooks(type).indexOf(fn);if(index<=-1){return false}videojs$1.hooks_[type]=videojs$1.hooks_[type].slice();videojs$1.hooks_[type].splice(index,1);return true};if(window$1.VIDEOJS_NO_DYNAMIC_STYLE!==true&&isReal()){var style=$(".vjs-styles-defaults");if(!style){style=createStyleElement("vjs-styles-defaults");var head=$("head");if(head){head.insertBefore(style,head.firstChild)}setTextContent(style,"\n .video-js {\n width: 300px;\n height: 150px;\n }\n\n .vjs-fluid {\n padding-top: 56.25%\n }\n ")}}autoSetupTimeout(1,videojs$1);videojs$1.VERSION=version;videojs$1.options=Player.prototype.options_;videojs$1.getPlayers=function(){return Player.players};videojs$1.getPlayer=function(id){var players=Player.players;var tag;if(typeof id==="string"){var nId=normalizeId(id);var player=players[nId];if(player){return player}tag=$("#"+nId)}else{tag=id}if(isEl(tag)){var _tag=tag,_player=_tag.player,playerId=_tag.playerId;if(_player||players[playerId]){return _player||players[playerId]}}};videojs$1.getAllPlayers=function(){return Object.keys(Player.players).map(function(k){return Player.players[k]}).filter(Boolean)};videojs$1.players=Player.players;videojs$1.getComponent=Component.getComponent;videojs$1.registerComponent=function(name,comp){if(Tech.isTech(comp)){log.warn("The "+name+" tech was registered as a component. It should instead be registered using videojs.registerTech(name, tech)")}Component.registerComponent.call(Component,name,comp)};videojs$1.getTech=Tech.getTech;videojs$1.registerTech=Tech.registerTech;videojs$1.use=use;Object.defineProperty(videojs$1,"middleware",{value:{},writeable:false,enumerable:true});Object.defineProperty(videojs$1.middleware,"TERMINATOR",{value:TERMINATOR,writeable:false,enumerable:true});videojs$1.browser=browser;videojs$1.TOUCH_ENABLED=TOUCH_ENABLED;videojs$1.extend=extend$1;videojs$1.mergeOptions=mergeOptions;videojs$1.bind=bind;videojs$1.registerPlugin=Plugin.registerPlugin;videojs$1.deregisterPlugin=Plugin.deregisterPlugin;videojs$1.plugin=function(name,plugin){log.warn("videojs.plugin() is deprecated; use videojs.registerPlugin() instead");return Plugin.registerPlugin(name,plugin)};videojs$1.getPlugins=Plugin.getPlugins;videojs$1.getPlugin=Plugin.getPlugin;videojs$1.getPluginVersion=Plugin.getPluginVersion;videojs$1.addLanguage=function(code,data){var _mergeOptions;code=(""+code).toLowerCase();videojs$1.options.languages=mergeOptions(videojs$1.options.languages,(_mergeOptions={},_mergeOptions[code]=data,_mergeOptions));return videojs$1.options.languages[code]};videojs$1.log=log;videojs$1.createLogger=createLogger$1;videojs$1.createTimeRange=videojs$1.createTimeRanges=createTimeRanges;videojs$1.formatTime=formatTime;videojs$1.setFormatTime=setFormatTime;videojs$1.resetFormatTime=resetFormatTime;videojs$1.parseUrl=parseUrl;videojs$1.isCrossOrigin=isCrossOrigin;videojs$1.EventTarget=EventTarget;videojs$1.on=on;videojs$1.one=one;videojs$1.off=off;videojs$1.trigger=trigger;videojs$1.xhr=xhr;videojs$1.TextTrack=TextTrack;videojs$1.AudioTrack=AudioTrack;videojs$1.VideoTrack=VideoTrack;["isEl","isTextNode","createEl","hasClass","addClass","removeClass","toggleClass","setAttributes","getAttributes","emptyEl","appendContent","insertContent"].forEach(function(k){videojs$1[k]=function(){log.warn("videojs."+k+"() is deprecated; use videojs.dom."+k+"() instead");return Dom[k].apply(null,arguments)}});videojs$1.computedStyle=computedStyle;videojs$1.dom=Dom;videojs$1.url=Url;var urlToolkit=createCommonjsModule(function(module,exports){(function(root){var URL_REGEX=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/;var FIRST_SEGMENT_REGEX=/^([^\/?#]*)(.*)$/;var SLASH_DOT_REGEX=/(?:\/|^)\.(?=\/)/g;var SLASH_DOT_DOT_REGEX=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g;var URLToolkit={buildAbsoluteURL:function buildAbsoluteURL(baseURL,relativeURL,opts){opts=opts||{};baseURL=baseURL.trim();relativeURL=relativeURL.trim();if(!relativeURL){if(!opts.alwaysNormalize){return baseURL}var basePartsForNormalise=URLToolkit.parseURL(baseURL);if(!basePartsForNormalise){throw new Error("Error trying to parse base URL.")}basePartsForNormalise.path=URLToolkit.normalizePath(basePartsForNormalise.path);return URLToolkit.buildURLFromParts(basePartsForNormalise)}var relativeParts=URLToolkit.parseURL(relativeURL);if(!relativeParts){throw new Error("Error trying to parse relative URL.")}if(relativeParts.scheme){if(!opts.alwaysNormalize){return relativeURL}relativeParts.path=URLToolkit.normalizePath(relativeParts.path);return URLToolkit.buildURLFromParts(relativeParts)}var baseParts=URLToolkit.parseURL(baseURL);if(!baseParts){throw new Error("Error trying to parse base URL.")}if(!baseParts.netLoc&&baseParts.path&&baseParts.path[0]!=="/"){var pathParts=FIRST_SEGMENT_REGEX.exec(baseParts.path);baseParts.netLoc=pathParts[1];baseParts.path=pathParts[2]}if(baseParts.netLoc&&!baseParts.path){baseParts.path="/"}var builtParts={scheme:baseParts.scheme,netLoc:relativeParts.netLoc,path:null,params:relativeParts.params,query:relativeParts.query,fragment:relativeParts.fragment};if(!relativeParts.netLoc){builtParts.netLoc=baseParts.netLoc;if(relativeParts.path[0]!=="/"){if(!relativeParts.path){builtParts.path=baseParts.path;if(!relativeParts.params){builtParts.params=baseParts.params;if(!relativeParts.query){builtParts.query=baseParts.query}}}else{var baseURLPath=baseParts.path;var newPath=baseURLPath.substring(0,baseURLPath.lastIndexOf("/")+1)+relativeParts.path;builtParts.path=URLToolkit.normalizePath(newPath)}}}if(builtParts.path===null){builtParts.path=opts.alwaysNormalize?URLToolkit.normalizePath(relativeParts.path):relativeParts.path}return URLToolkit.buildURLFromParts(builtParts)},parseURL:function parseURL(url){var parts=URL_REGEX.exec(url);if(!parts){return null}return{scheme:parts[1]||"",netLoc:parts[2]||"",path:parts[3]||"",params:parts[4]||"",query:parts[5]||"",fragment:parts[6]||""}},normalizePath:function normalizePath(path){path=path.split("").reverse().join("").replace(SLASH_DOT_REGEX,"");while(path.length!==(path=path.replace(SLASH_DOT_DOT_REGEX,"")).length){}return path.split("").reverse().join("")},buildURLFromParts:function buildURLFromParts(parts){return parts.scheme+parts.netLoc+parts.path+parts.params+parts.query+parts.fragment}};module.exports=URLToolkit})()});function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _inheritsLoose$1(subClass,superClass){subClass.prototype=Object.create(superClass.prototype);subClass.prototype.constructor=subClass;subClass.__proto__=superClass}function _assertThisInitialized$1(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}var Stream=function(){function Stream(){this.listeners={}}var _proto=Stream.prototype;_proto.on=function on(type,listener){if(!this.listeners[type]){this.listeners[type]=[]}this.listeners[type].push(listener)};_proto.off=function off(type,listener){if(!this.listeners[type]){return false}var index=this.listeners[type].indexOf(listener);this.listeners[type].splice(index,1);return index>-1};_proto.trigger=function trigger(type){var callbacks=this.listeners[type];var i;var length;var args;if(!callbacks){return}if(arguments.length===2){length=callbacks.length;for(i=0;i<length;++i){callbacks[i].call(this,arguments[1])}}else{args=Array.prototype.slice.call(arguments,1);length=callbacks.length;for(i=0;i<length;++i){callbacks[i].apply(this,args)}}};_proto.dispose=function dispose(){this.listeners={}};_proto.pipe=function pipe(destination){this.on("data",function(data){destination.push(data)})};return Stream}();var LineStream=function(_Stream){_inheritsLoose$1(LineStream,_Stream);function LineStream(){var _this;_this=_Stream.call(this)||this;_this.buffer="";return _this}var _proto=LineStream.prototype;_proto.push=function push(data){var nextNewline;this.buffer+=data;nextNewline=this.buffer.indexOf("\n");for(;nextNewline>-1;nextNewline=this.buffer.indexOf("\n")){this.trigger("data",this.buffer.substring(0,nextNewline));this.buffer=this.buffer.substring(nextNewline+1)}};return LineStream}(Stream);var attributeSeparator=function attributeSeparator(){var key="[^=]*";var value='"[^"]*"|[^,]*';var keyvalue="(?:"+key+")=(?:"+value+")";return new RegExp("(?:^|,)("+keyvalue+")")};var parseAttributes=function parseAttributes(attributes){var attrs=attributes.split(attributeSeparator());var result={};var i=attrs.length;var attr;while(i--){if(attrs[i]===""){continue}attr=/([^=]*)=(.*)/.exec(attrs[i]).slice(1);attr[0]=attr[0].replace(/^\s+|\s+$/g,"");attr[1]=attr[1].replace(/^\s+|\s+$/g,"");attr[1]=attr[1].replace(/^['"](.*)['"]$/g,"$1");result[attr[0]]=attr[1]}return result};var ParseStream=function(_Stream){_inheritsLoose$1(ParseStream,_Stream);function ParseStream(){var _this;_this=_Stream.call(this)||this;_this.customParsers=[];_this.tagMappers=[];return _this}var _proto=ParseStream.prototype;_proto.push=function push(line){var _this2=this;var match;var event;line=line.trim();if(line.length===0){return}if(line[0]!=="#"){this.trigger("data",{type:"uri",uri:line});return}var newLines=this.tagMappers.reduce(function(acc,mapper){var mappedLine=mapper(line);if(mappedLine===line){return acc}return acc.concat([mappedLine])},[line]);newLines.forEach(function(newLine){for(var i=0;i<_this2.customParsers.length;i++){if(_this2.customParsers[i].call(_this2,newLine)){return}}if(newLine.indexOf("#EXT")!==0){_this2.trigger("data",{type:"comment",text:newLine.slice(1)});return}newLine=newLine.replace("\r","");match=/^#EXTM3U/.exec(newLine);if(match){_this2.trigger("data",{type:"tag",tagType:"m3u"});return}match=/^#EXTINF:?([0-9\.]*)?,?(.*)?$/.exec(newLine);if(match){event={type:"tag",tagType:"inf"};if(match[1]){event.duration=parseFloat(match[1])}if(match[2]){event.title=match[2]}_this2.trigger("data",event);return}match=/^#EXT-X-TARGETDURATION:?([0-9.]*)?/.exec(newLine);if(match){event={type:"tag",tagType:"targetduration"};if(match[1]){event.duration=parseInt(match[1],10)}_this2.trigger("data",event);return}match=/^#ZEN-TOTAL-DURATION:?([0-9.]*)?/.exec(newLine);if(match){event={type:"tag",tagType:"totalduration"};if(match[1]){event.duration=parseInt(match[1],10)}_this2.trigger("data",event);return}match=/^#EXT-X-VERSION:?([0-9.]*)?/.exec(newLine);if(match){event={type:"tag",tagType:"version"};if(match[1]){event.version=parseInt(match[1],10)}_this2.trigger("data",event);return}match=/^#EXT-X-MEDIA-SEQUENCE:?(\-?[0-9.]*)?/.exec(newLine);if(match){event={type:"tag",tagType:"media-sequence"};if(match[1]){event.number=parseInt(match[1],10)}_this2.trigger("data",event);return}match=/^#EXT-X-DISCONTINUITY-SEQUENCE:?(\-?[0-9.]*)?/.exec(newLine);if(match){event={type:"tag",tagType:"discontinuity-sequence"};if(match[1]){event.number=parseInt(match[1],10)}_this2.trigger("data",event);return}match=/^#EXT-X-PLAYLIST-TYPE:?(.*)?$/.exec(newLine);if(match){event={type:"tag",tagType:"playlist-type"};if(match[1]){event.playlistType=match[1]}_this2.trigger("data",event);return}match=/^#EXT-X-BYTERANGE:?([0-9.]*)?@?([0-9.]*)?/.exec(newLine);if(match){event={type:"tag",tagType:"byterange"};if(match[1]){event.length=parseInt(match[1],10)}if(match[2]){event.offset=parseInt(match[2],10)}_this2.trigger("data",event);return}match=/^#EXT-X-ALLOW-CACHE:?(YES|NO)?/.exec(newLine);if(match){event={type:"tag",tagType:"allow-cache"};if(match[1]){event.allowed=!/NO/.test(match[1])}_this2.trigger("data",event);return}match=/^#EXT-X-MAP:?(.*)$/.exec(newLine);if(match){event={type:"tag",tagType:"map"};if(match[1]){var attributes=parseAttributes(match[1]);if(attributes.URI){event.uri=attributes.URI}if(attributes.BYTERANGE){var _attributes$BYTERANGE=attributes.BYTERANGE.split("@"),length=_attributes$BYTERANGE[0],offset=_attributes$BYTERANGE[1];event.byterange={};if(length){event.byterange.length=parseInt(length,10)}if(offset){event.byterange.offset=parseInt(offset,10)}}}_this2.trigger("data",event);return}match=/^#EXT-X-STREAM-INF:?(.*)$/.exec(newLine);if(match){event={type:"tag",tagType:"stream-inf"};if(match[1]){event.attributes=parseAttributes(match[1]);if(event.attributes.RESOLUTION){var split=event.attributes.RESOLUTION.split("x");var resolution={};if(split[0]){resolution.width=parseInt(split[0],10)}if(split[1]){resolution.height=parseInt(split[1],10)}event.attributes.RESOLUTION=resolution}if(event.attributes.BANDWIDTH){event.attributes.BANDWIDTH=parseInt(event.attributes.BANDWIDTH,10)}if(event.attributes["PROGRAM-ID"]){event.attributes["PROGRAM-ID"]=parseInt(event.attributes["PROGRAM-ID"],10)}}_this2.trigger("data",event);return}match=/^#EXT-X-MEDIA:?(.*)$/.exec(newLine);if(match){event={type:"tag",tagType:"media"};if(match[1]){event.attributes=parseAttributes(match[1])}_this2.trigger("data",event);return}match=/^#EXT-X-ENDLIST/.exec(newLine);if(match){_this2.trigger("data",{type:"tag",tagType:"endlist"});return}match=/^#EXT-X-DISCONTINUITY/.exec(newLine);if(match){_this2.trigger("data",{type:"tag",tagType:"discontinuity"});return}match=/^#EXT-X-PROGRAM-DATE-TIME:?(.*)$/.exec(newLine);if(match){event={type:"tag",tagType:"program-date-time"};if(match[1]){event.dateTimeString=match[1];event.dateTimeObject=new Date(match[1])}_this2.trigger("data",event);return}match=/^#EXT-X-KEY:?(.*)$/.exec(newLine);if(match){event={type:"tag",tagType:"key"};if(match[1]){event.attributes=parseAttributes(match[1]);if(event.attributes.IV){if(event.attributes.IV.substring(0,2).toLowerCase()==="0x"){event.attributes.IV=event.attributes.IV.substring(2)}event.attributes.IV=event.attributes.IV.match(/.{8}/g);event.attributes.IV[0]=parseInt(event.attributes.IV[0],16);event.attributes.IV[1]=parseInt(event.attributes.IV[1],16);event.attributes.IV[2]=parseInt(event.attributes.IV[2],16);event.attributes.IV[3]=parseInt(event.attributes.IV[3],16);event.attributes.IV=new Uint32Array(event.attributes.IV)}}_this2.trigger("data",event);return}match=/^#EXT-X-START:?(.*)$/.exec(newLine);if(match){event={type:"tag",tagType:"start"};if(match[1]){event.attributes=parseAttributes(match[1]);event.attributes["TIME-OFFSET"]=parseFloat(event.attributes["TIME-OFFSET"]);event.attributes.PRECISE=/YES/.test(event.attributes.PRECISE)}_this2.trigger("data",event);return}match=/^#EXT-X-CUE-OUT-CONT:?(.*)?$/.exec(newLine);if(match){event={type:"tag",tagType:"cue-out-cont"};if(match[1]){event.data=match[1]}else{event.data=""}_this2.trigger("data",event);return}match=/^#EXT-X-CUE-OUT:?(.*)?$/.exec(newLine);if(match){event={type:"tag",tagType:"cue-out"};if(match[1]){event.data=match[1]}else{event.data=""}_this2.trigger("data",event);return}match=/^#EXT-X-CUE-IN:?(.*)?$/.exec(newLine);if(match){event={type:"tag",tagType:"cue-in"};if(match[1]){event.data=match[1]}else{event.data=""}_this2.trigger("data",event);return}_this2.trigger("data",{type:"tag",data:newLine.slice(4)})})};_proto.addParser=function addParser(_ref){var _this3=this;var expression=_ref.expression,customType=_ref.customType,dataParser=_ref.dataParser,segment=_ref.segment;if(typeof dataParser!=="function"){dataParser=function dataParser(line){return line}}this.customParsers.push(function(line){var match=expression.exec(line);if(match){_this3.trigger("data",{type:"custom",data:dataParser(line),customType:customType,segment:segment});return true}})};_proto.addTagMapper=function addTagMapper(_ref2){var expression=_ref2.expression,map=_ref2.map;var mapFn=function mapFn(line){if(expression.test(line)){return map(line)}return line};this.tagMappers.push(mapFn)};return ParseStream}(Stream);function decodeB64ToUint8Array(b64Text){var decodedString=window$1.atob(b64Text||"");var array=new Uint8Array(decodedString.length);for(var i=0;i<decodedString.length;i++){array[i]=decodedString.charCodeAt(i)}return array}var Parser=function(_Stream){_inheritsLoose$1(Parser,_Stream);function Parser(){var _this;_this=_Stream.call(this)||this;_this.lineStream=new LineStream;_this.parseStream=new ParseStream;_this.lineStream.pipe(_this.parseStream);var self=_assertThisInitialized$1(_this);var uris=[];var currentUri={};var currentMap;var _key;var noop=function noop(){};var defaultMediaGroups={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}};var widevineUuid="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";var currentTimeline=0;_this.manifest={allowCache:true,discontinuityStarts:[],segments:[]};_this.parseStream.on("data",function(entry){var mediaGroup;var rendition;({tag:function tag(){({"allow-cache":function allowCache(){this.manifest.allowCache=entry.allowed;if(!("allowed"in entry)){this.trigger("info",{message:"defaulting allowCache to YES"});this.manifest.allowCache=true}},byterange:function byterange(){var byterange={};if("length"in entry){currentUri.byterange=byterange;byterange.length=entry.length;if(!("offset"in entry)){this.trigger("info",{message:"defaulting offset to zero"});entry.offset=0}}if("offset"in entry){currentUri.byterange=byterange;byterange.offset=entry.offset}},endlist:function endlist(){this.manifest.endList=true},inf:function inf(){if(!("mediaSequence"in this.manifest)){this.manifest.mediaSequence=0;this.trigger("info",{message:"defaulting media sequence to zero"})}if(!("discontinuitySequence"in this.manifest)){this.manifest.discontinuitySequence=0;this.trigger("info",{message:"defaulting discontinuity sequence to zero"})}if(entry.duration>0){currentUri.duration=entry.duration}if(entry.duration===0){currentUri.duration=.01;this.trigger("info",{message:"updating zero segment duration to a small value"})}this.manifest.segments=uris},key:function key(){if(!entry.attributes){this.trigger("warn",{message:"ignoring key declaration without attribute list"});return}if(entry.attributes.METHOD==="NONE"){_key=null;return}if(!entry.attributes.URI){this.trigger("warn",{message:"ignoring key declaration without URI"});return}if(entry.attributes.KEYFORMAT===widevineUuid){var VALID_METHODS=["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"];if(VALID_METHODS.indexOf(entry.attributes.METHOD)===-1){this.trigger("warn",{message:"invalid key method provided for Widevine"});return}if(entry.attributes.METHOD==="SAMPLE-AES-CENC"){this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"})}if(entry.attributes.URI.substring(0,23)!=="data:text/plain;base64,"){this.trigger("warn",{message:"invalid key URI provided for Widevine"});return}if(!(entry.attributes.KEYID&&entry.attributes.KEYID.substring(0,2)==="0x")){this.trigger("warn",{message:"invalid key ID provided for Widevine"});return}this.manifest.contentProtection={"com.widevine.alpha":{attributes:{schemeIdUri:entry.attributes.KEYFORMAT,keyId:entry.attributes.KEYID.substring(2)},pssh:decodeB64ToUint8Array(entry.attributes.URI.split(",")[1])}};return}if(!entry.attributes.METHOD){this.trigger("warn",{message:"defaulting key method to AES-128"})}_key={method:entry.attributes.METHOD||"AES-128",uri:entry.attributes.URI};if(typeof entry.attributes.IV!=="undefined"){_key.iv=entry.attributes.IV}},"media-sequence":function mediaSequence(){if(!isFinite(entry.number)){this.trigger("warn",{message:"ignoring invalid media sequence: "+entry.number});return}this.manifest.mediaSequence=entry.number},"discontinuity-sequence":function discontinuitySequence(){if(!isFinite(entry.number)){this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+entry.number});return}this.manifest.discontinuitySequence=entry.number;currentTimeline=entry.number},"playlist-type":function playlistType(){if(!/VOD|EVENT/.test(entry.playlistType)){this.trigger("warn",{message:"ignoring unknown playlist type: "+entry.playlist});return}this.manifest.playlistType=entry.playlistType},map:function map(){currentMap={};if(entry.uri){currentMap.uri=entry.uri}if(entry.byterange){currentMap.byterange=entry.byterange}},"stream-inf":function streamInf(){this.manifest.playlists=uris;this.manifest.mediaGroups=this.manifest.mediaGroups||defaultMediaGroups;if(!entry.attributes){this.trigger("warn",{message:"ignoring empty stream-inf attributes"});return}if(!currentUri.attributes){currentUri.attributes={}}_extends(currentUri.attributes,entry.attributes)},media:function media(){this.manifest.mediaGroups=this.manifest.mediaGroups||defaultMediaGroups;if(!(entry.attributes&&entry.attributes.TYPE&&entry.attributes["GROUP-ID"]&&entry.attributes.NAME)){this.trigger("warn",{message:"ignoring incomplete or missing media group"});return}var mediaGroupType=this.manifest.mediaGroups[entry.attributes.TYPE];mediaGroupType[entry.attributes["GROUP-ID"]]=mediaGroupType[entry.attributes["GROUP-ID"]]||{};mediaGroup=mediaGroupType[entry.attributes["GROUP-ID"]];rendition={default:/yes/i.test(entry.attributes.DEFAULT)};if(rendition["default"]){rendition.autoselect=true}else{rendition.autoselect=/yes/i.test(entry.attributes.AUTOSELECT)}if(entry.attributes.LANGUAGE){rendition.language=entry.attributes.LANGUAGE}if(entry.attributes.URI){rendition.uri=entry.attributes.URI}if(entry.attributes["INSTREAM-ID"]){rendition.instreamId=entry.attributes["INSTREAM-ID"]}if(entry.attributes.CHARACTERISTICS){rendition.characteristics=entry.attributes.CHARACTERISTICS}if(entry.attributes.FORCED){rendition.forced=/yes/i.test(entry.attributes.FORCED)}mediaGroup[entry.attributes.NAME]=rendition},discontinuity:function discontinuity(){currentTimeline+=1;currentUri.discontinuity=true;this.manifest.discontinuityStarts.push(uris.length)},"program-date-time":function programDateTime(){if(typeof this.manifest.dateTimeString==="undefined"){this.manifest.dateTimeString=entry.dateTimeString;this.manifest.dateTimeObject=entry.dateTimeObject}currentUri.dateTimeString=entry.dateTimeString;currentUri.dateTimeObject=entry.dateTimeObject},targetduration:function targetduration(){if(!isFinite(entry.duration)||entry.duration<0){this.trigger("warn",{message:"ignoring invalid target duration: "+entry.duration});return}this.manifest.targetDuration=entry.duration},totalduration:function totalduration(){if(!isFinite(entry.duration)||entry.duration<0){this.trigger("warn",{message:"ignoring invalid total duration: "+entry.duration});return}this.manifest.totalDuration=entry.duration},start:function start(){if(!entry.attributes||isNaN(entry.attributes["TIME-OFFSET"])){this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"});return}this.manifest.start={timeOffset:entry.attributes["TIME-OFFSET"],precise:entry.attributes.PRECISE}},"cue-out":function cueOut(){currentUri.cueOut=entry.data},"cue-out-cont":function cueOutCont(){currentUri.cueOutCont=entry.data},"cue-in":function cueIn(){currentUri.cueIn=entry.data}}[entry.tagType]||noop).call(self)},uri:function uri(){currentUri.uri=entry.uri;uris.push(currentUri);if(this.manifest.targetDuration&&!("duration"in currentUri)){this.trigger("warn",{message:"defaulting segment duration to the target duration"});currentUri.duration=this.manifest.targetDuration}if(_key){currentUri.key=_key}currentUri.timeline=currentTimeline;if(currentMap){currentUri.map=currentMap}currentUri={}},comment:function comment(){},custom:function custom(){if(entry.segment){currentUri.custom=currentUri.custom||{};currentUri.custom[entry.customType]=entry.data}else{this.manifest.custom=this.manifest.custom||{};this.manifest.custom[entry.customType]=entry.data}}})[entry.type].call(self)});return _this}var _proto=Parser.prototype;_proto.push=function push(chunk){this.lineStream.push(chunk)};_proto.end=function end(){this.lineStream.push("\n")};_proto.addParser=function addParser(options){this.parseStream.addParser(options)};_proto.addTagMapper=function addTagMapper(options){this.parseStream.addTagMapper(options)};return Parser}(Stream);var isObject$1=function isObject(obj){return!!obj&&typeof obj==="object"};var merge=function merge(){for(var _len=arguments.length,objects=new Array(_len),_key=0;_key<_len;_key++){objects[_key]=arguments[_key]}return objects.reduce(function(result,source){Object.keys(source).forEach(function(key){if(Array.isArray(result[key])&&Array.isArray(source[key])){result[key]=result[key].concat(source[key])}else if(isObject$1(result[key])&&isObject$1(source[key])){result[key]=merge(result[key],source[key])}else{result[key]=source[key]}});return result},{})};var values=function values(o){return Object.keys(o).map(function(k){return o[k]})};var range=function range(start,end){var result=[];for(var i=start;i<end;i++){result.push(i)}return result};var flatten=function flatten(lists){return lists.reduce(function(x,y){return x.concat(y)},[])};var from=function from(list){if(!list.length){return[]}var result=[];for(var i=0;i<list.length;i++){result.push(list[i])}return result};var findIndexes=function findIndexes(l,key){return l.reduce(function(a,e,i){if(e[key]){a.push(i)}return a},[])};var errors={INVALID_NUMBER_OF_PERIOD:"INVALID_NUMBER_OF_PERIOD",DASH_EMPTY_MANIFEST:"DASH_EMPTY_MANIFEST",DASH_INVALID_XML:"DASH_INVALID_XML",NO_BASE_URL:"NO_BASE_URL",MISSING_SEGMENT_INFORMATION:"MISSING_SEGMENT_INFORMATION",SEGMENT_TIME_UNSPECIFIED:"SEGMENT_TIME_UNSPECIFIED",UNSUPPORTED_UTC_TIMING_SCHEME:"UNSUPPORTED_UTC_TIMING_SCHEME"};function createCommonjsModule$1(fn,module){return module={exports:{}},fn(module,module.exports),module.exports}var urlToolkit$1=createCommonjsModule$1(function(module,exports){(function(root){var URL_REGEX=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/;var FIRST_SEGMENT_REGEX=/^([^\/?#]*)(.*)$/;var SLASH_DOT_REGEX=/(?:\/|^)\.(?=\/)/g;var SLASH_DOT_DOT_REGEX=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g;var URLToolkit={buildAbsoluteURL:function buildAbsoluteURL(baseURL,relativeURL,opts){opts=opts||{};baseURL=baseURL.trim();relativeURL=relativeURL.trim();if(!relativeURL){if(!opts.alwaysNormalize){return baseURL}var basePartsForNormalise=URLToolkit.parseURL(baseURL);if(!basePartsForNormalise){throw new Error("Error trying to parse base URL.")}basePartsForNormalise.path=URLToolkit.normalizePath(basePartsForNormalise.path);return URLToolkit.buildURLFromParts(basePartsForNormalise)}var relativeParts=URLToolkit.parseURL(relativeURL);if(!relativeParts){throw new Error("Error trying to parse relative URL.")}if(relativeParts.scheme){if(!opts.alwaysNormalize){return relativeURL}relativeParts.path=URLToolkit.normalizePath(relativeParts.path);return URLToolkit.buildURLFromParts(relativeParts)}var baseParts=URLToolkit.parseURL(baseURL);if(!baseParts){throw new Error("Error trying to parse base URL.")}if(!baseParts.netLoc&&baseParts.path&&baseParts.path[0]!=="/"){var pathParts=FIRST_SEGMENT_REGEX.exec(baseParts.path);baseParts.netLoc=pathParts[1];baseParts.path=pathParts[2]}if(baseParts.netLoc&&!baseParts.path){baseParts.path="/"}var builtParts={scheme:baseParts.scheme,netLoc:relativeParts.netLoc,path:null,params:relativeParts.params,query:relativeParts.query,fragment:relativeParts.fragment};if(!relativeParts.netLoc){builtParts.netLoc=baseParts.netLoc;if(relativeParts.path[0]!=="/"){if(!relativeParts.path){builtParts.path=baseParts.path;if(!relativeParts.params){builtParts.params=baseParts.params;if(!relativeParts.query){builtParts.query=baseParts.query}}}else{var baseURLPath=baseParts.path;var newPath=baseURLPath.substring(0,baseURLPath.lastIndexOf("/")+1)+relativeParts.path;builtParts.path=URLToolkit.normalizePath(newPath)}}}if(builtParts.path===null){builtParts.path=opts.alwaysNormalize?URLToolkit.normalizePath(relativeParts.path):relativeParts.path}return URLToolkit.buildURLFromParts(builtParts)},parseURL:function parseURL(url){var parts=URL_REGEX.exec(url);if(!parts){return null}return{scheme:parts[1]||"",netLoc:parts[2]||"",path:parts[3]||"",params:parts[4]||"",query:parts[5]||"",fragment:parts[6]||""}},normalizePath:function normalizePath(path){path=path.split("").reverse().join("").replace(SLASH_DOT_REGEX,"");while(path.length!==(path=path.replace(SLASH_DOT_DOT_REGEX,"")).length){}return path.split("").reverse().join("")},buildURLFromParts:function buildURLFromParts(parts){return parts.scheme+parts.netLoc+parts.path+parts.params+parts.query+parts.fragment}};module.exports=URLToolkit})()});var resolveUrl=function resolveUrl(baseUrl,relativeUrl){if(/^[a-z]+:/i.test(relativeUrl)){return relativeUrl}if(!/\/\//i.test(baseUrl)){baseUrl=urlToolkit$1.buildAbsoluteURL(window$1.location.href,baseUrl)}return urlToolkit$1.buildAbsoluteURL(baseUrl,relativeUrl)};var urlTypeToSegment=function urlTypeToSegment(_ref){var _ref$baseUrl=_ref.baseUrl,baseUrl=_ref$baseUrl===void 0?"":_ref$baseUrl,_ref$source=_ref.source,source=_ref$source===void 0?"":_ref$source,_ref$range=_ref.range,range=_ref$range===void 0?"":_ref$range,_ref$indexRange=_ref.indexRange,indexRange=_ref$indexRange===void 0?"":_ref$indexRange;var segment={uri:source,resolvedUri:resolveUrl(baseUrl||"",source)};if(range||indexRange){var rangeStr=range?range:indexRange;var ranges=rangeStr.split("-");var startRange=parseInt(ranges[0],10);var endRange=parseInt(ranges[1],10);segment.byterange={length:endRange-startRange+1,offset:startRange}}return segment};var byteRangeToString=function byteRangeToString(byterange){var endRange=byterange.offset+byterange.length-1;return byterange.offset+"-"+endRange};var segmentRange={static:function _static(attributes){var duration=attributes.duration,_attributes$timescale=attributes.timescale,timescale=_attributes$timescale===void 0?1:_attributes$timescale,sourceDuration=attributes.sourceDuration;return{start:0,end:Math.ceil(sourceDuration/(duration/timescale))}},dynamic:function dynamic(attributes){var NOW=attributes.NOW,clientOffset=attributes.clientOffset,availabilityStartTime=attributes.availabilityStartTime,_attributes$timescale2=attributes.timescale,timescale=_attributes$timescale2===void 0?1:_attributes$timescale2,duration=attributes.duration,_attributes$start=attributes.start,start=_attributes$start===void 0?0:_attributes$start,_attributes$minimumUp=attributes.minimumUpdatePeriod,minimumUpdatePeriod=_attributes$minimumUp===void 0?0:_attributes$minimumUp,_attributes$timeShift=attributes.timeShiftBufferDepth,timeShiftBufferDepth=_attributes$timeShift===void 0?Infinity:_attributes$timeShift;var now=(NOW+clientOffset)/1e3;var periodStartWC=availabilityStartTime+start;var periodEndWC=now+minimumUpdatePeriod;var periodDuration=periodEndWC-periodStartWC;var segmentCount=Math.ceil(periodDuration*timescale/duration);var availableStart=Math.floor((now-periodStartWC-timeShiftBufferDepth)*timescale/duration);var availableEnd=Math.floor((now-periodStartWC)*timescale/duration);return{start:Math.max(0,availableStart),end:Math.min(segmentCount,availableEnd)}}};var toSegments=function toSegments(attributes){return function(number,index){var duration=attributes.duration,_attributes$timescale3=attributes.timescale,timescale=_attributes$timescale3===void 0?1:_attributes$timescale3,periodIndex=attributes.periodIndex,_attributes$startNumb=attributes.startNumber,startNumber=_attributes$startNumb===void 0?1:_attributes$startNumb;return{number:startNumber+number,duration:duration/timescale,timeline:periodIndex,time:index*duration}}};var parseByDuration=function parseByDuration(attributes){var _attributes$type=attributes.type,type=_attributes$type===void 0?"static":_attributes$type,duration=attributes.duration,_attributes$timescale4=attributes.timescale,timescale=_attributes$timescale4===void 0?1:_attributes$timescale4,sourceDuration=attributes.sourceDuration;var _segmentRange$type=segmentRange[type](attributes),start=_segmentRange$type.start,end=_segmentRange$type.end;var segments=range(start,end).map(toSegments(attributes));if(type==="static"){var index=segments.length-1;segments[index].duration=sourceDuration-duration/timescale*index}return segments};var segmentsFromBase=function segmentsFromBase(attributes){var baseUrl=attributes.baseUrl,_attributes$initializ=attributes.initialization,initialization=_attributes$initializ===void 0?{}:_attributes$initializ,sourceDuration=attributes.sourceDuration,_attributes$timescale=attributes.timescale,timescale=_attributes$timescale===void 0?1:_attributes$timescale,_attributes$indexRang=attributes.indexRange,indexRange=_attributes$indexRang===void 0?"":_attributes$indexRang,duration=attributes.duration;if(!baseUrl){throw new Error(errors.NO_BASE_URL)}var initSegment=urlTypeToSegment({baseUrl:baseUrl,source:initialization.sourceURL,range:initialization.range});var segment=urlTypeToSegment({baseUrl:baseUrl,source:baseUrl,indexRange:indexRange});segment.map=initSegment;if(duration){var segmentTimeInfo=parseByDuration(attributes);if(segmentTimeInfo.length){segment.duration=segmentTimeInfo[0].duration;segment.timeline=segmentTimeInfo[0].timeline}}else if(sourceDuration){segment.duration=sourceDuration/timescale;segment.timeline=0}segment.number=0;return[segment]};var addSegmentsToPlaylist=function addSegmentsToPlaylist(playlist,sidx,baseUrl){var initSegment=playlist.sidx.map?playlist.sidx.map:null;var sourceDuration=playlist.sidx.duration;var timeline=playlist.timeline||0;var sidxByteRange=playlist.sidx.byterange;var sidxEnd=sidxByteRange.offset+sidxByteRange.length;var timescale=sidx.timescale;var mediaReferences=sidx.references.filter(function(r){return r.referenceType!==1});var segments=[];var startIndex=sidxEnd+sidx.firstOffset;for(var i=0;i<mediaReferences.length;i++){var reference=sidx.references[i];var size=reference.referencedSize;var duration=reference.subsegmentDuration;var endIndex=startIndex+size-1;var indexRange=startIndex+"-"+endIndex;var attributes={baseUrl:baseUrl,timescale:timescale,timeline:timeline,periodIndex:timeline,duration:duration,sourceDuration:sourceDuration,indexRange:indexRange};var segment=segmentsFromBase(attributes)[0];if(initSegment){segment.map=initSegment}segments.push(segment);startIndex+=size}playlist.segments=segments;return playlist};var mergeDiscontiguousPlaylists=function mergeDiscontiguousPlaylists(playlists){var mergedPlaylists=values(playlists.reduce(function(acc,playlist){var name=playlist.attributes.id+(playlist.attributes.lang||"");if(acc[name]){var _acc$name$segments;if(playlist.segments[0]){playlist.segments[0].discontinuity=true}(_acc$name$segments=acc[name].segments).push.apply(_acc$name$segments,playlist.segments);if(playlist.attributes.contentProtection){acc[name].attributes.contentProtection=playlist.attributes.contentProtection}}else{acc[name]=playlist}return acc},{}));return mergedPlaylists.map(function(playlist){playlist.discontinuityStarts=findIndexes(playlist.segments,"discontinuity");return playlist})};var addSegmentInfoFromSidx=function addSegmentInfoFromSidx(playlists,sidxMapping){if(sidxMapping===void 0){sidxMapping={}}if(!Object.keys(sidxMapping).length){return playlists}for(var i in playlists){var playlist=playlists[i];if(!playlist.sidx){continue}var sidxKey=playlist.sidx.uri+"-"+byteRangeToString(playlist.sidx.byterange);var sidxMatch=sidxMapping[sidxKey]&&sidxMapping[sidxKey].sidx;if(playlist.sidx&&sidxMatch){addSegmentsToPlaylist(playlist,sidxMatch,playlist.sidx.resolvedUri)}}return playlists};var formatAudioPlaylist=function formatAudioPlaylist(_ref){var _attributes;var attributes=_ref.attributes,segments=_ref.segments,sidx=_ref.sidx;var playlist={attributes:(_attributes={NAME:attributes.id,BANDWIDTH:attributes.bandwidth,CODECS:attributes.codecs},_attributes["PROGRAM-ID"]=1,_attributes),uri:"",endList:(attributes.type||"static")==="static",timeline:attributes.periodIndex,resolvedUri:"",targetDuration:attributes.duration,segments:segments,mediaSequence:segments.length?segments[0].number:1};if(attributes.contentProtection){playlist.contentProtection=attributes.contentProtection}if(sidx){playlist.sidx=sidx}return playlist};var formatVttPlaylist=function formatVttPlaylist(_ref2){var _attributes2;var attributes=_ref2.attributes,segments=_ref2.segments;if(typeof segments==="undefined"){segments=[{uri:attributes.baseUrl,timeline:attributes.periodIndex,resolvedUri:attributes.baseUrl||"",duration:attributes.sourceDuration,number:0}];attributes.duration=attributes.sourceDuration}return{attributes:(_attributes2={NAME:attributes.id,BANDWIDTH:attributes.bandwidth},_attributes2["PROGRAM-ID"]=1,_attributes2),uri:"",endList:(attributes.type||"static")==="static",timeline:attributes.periodIndex,resolvedUri:attributes.baseUrl||"",targetDuration:attributes.duration,segments:segments,mediaSequence:segments.length?segments[0].number:1}};var organizeAudioPlaylists=function organizeAudioPlaylists(playlists,sidxMapping){if(sidxMapping===void 0){sidxMapping={}}var mainPlaylist;var formattedPlaylists=playlists.reduce(function(a,playlist){var role=playlist.attributes.role&&playlist.attributes.role.value||"";var language=playlist.attributes.lang||"";var label="main";if(language){var roleLabel=role?" ("+role+")":"";label=""+playlist.attributes.lang+roleLabel}if(a[label]&&a[label].playlists[0].attributes.BANDWIDTH>playlist.attributes.bandwidth){return a}a[label]={language:language,autoselect:true,default:role==="main",playlists:addSegmentInfoFromSidx([formatAudioPlaylist(playlist)],sidxMapping),uri:""};if(typeof mainPlaylist==="undefined"&&role==="main"){mainPlaylist=playlist;mainPlaylist["default"]=true}return a},{});if(!mainPlaylist){var firstLabel=Object.keys(formattedPlaylists)[0];formattedPlaylists[firstLabel]["default"]=true}return formattedPlaylists};var organizeVttPlaylists=function organizeVttPlaylists(playlists,sidxMapping){if(sidxMapping===void 0){sidxMapping={}}return playlists.reduce(function(a,playlist){var label=playlist.attributes.lang||"text";if(a[label]){return a}a[label]={language:label,default:false,autoselect:false,playlists:addSegmentInfoFromSidx([formatVttPlaylist(playlist)],sidxMapping),uri:""};return a},{})};var formatVideoPlaylist=function formatVideoPlaylist(_ref3){var _attributes3;var attributes=_ref3.attributes,segments=_ref3.segments,sidx=_ref3.sidx;var playlist={attributes:(_attributes3={NAME:attributes.id,AUDIO:"audio",SUBTITLES:"subs",RESOLUTION:{width:attributes.width,height:attributes.height},CODECS:attributes.codecs,BANDWIDTH:attributes.bandwidth},_attributes3["PROGRAM-ID"]=1,_attributes3),uri:"",endList:(attributes.type||"static")==="static",timeline:attributes.periodIndex,resolvedUri:"",targetDuration:attributes.duration,segments:segments,mediaSequence:segments.length?segments[0].number:1};if(attributes.contentProtection){playlist.contentProtection=attributes.contentProtection}if(sidx){playlist.sidx=sidx}return playlist};var toM3u8=function toM3u8(dashPlaylists,sidxMapping){var _mediaGroups;if(sidxMapping===void 0){sidxMapping={}}if(!dashPlaylists.length){return{}}var _dashPlaylists$0$attr=dashPlaylists[0].attributes,duration=_dashPlaylists$0$attr.sourceDuration,_dashPlaylists$0$attr2=_dashPlaylists$0$attr.minimumUpdatePeriod,minimumUpdatePeriod=_dashPlaylists$0$attr2===void 0?0:_dashPlaylists$0$attr2;var videoOnly=function videoOnly(_ref4){var attributes=_ref4.attributes;return attributes.mimeType==="video/mp4"||attributes.contentType==="video"};var audioOnly=function audioOnly(_ref5){var attributes=_ref5.attributes;return attributes.mimeType==="audio/mp4"||attributes.contentType==="audio"};var vttOnly=function vttOnly(_ref6){var attributes=_ref6.attributes;return attributes.mimeType==="text/vtt"||attributes.contentType==="text"};var videoPlaylists=mergeDiscontiguousPlaylists(dashPlaylists.filter(videoOnly)).map(formatVideoPlaylist);var audioPlaylists=mergeDiscontiguousPlaylists(dashPlaylists.filter(audioOnly));var vttPlaylists=dashPlaylists.filter(vttOnly);var master={allowCache:true,discontinuityStarts:[],segments:[],endList:true,mediaGroups:(_mediaGroups={AUDIO:{},VIDEO:{}},_mediaGroups["CLOSED-CAPTIONS"]={},_mediaGroups.SUBTITLES={},_mediaGroups),uri:"",duration:duration,playlists:addSegmentInfoFromSidx(videoPlaylists,sidxMapping),minimumUpdatePeriod:minimumUpdatePeriod*1e3};if(audioPlaylists.length){master.mediaGroups.AUDIO.audio=organizeAudioPlaylists(audioPlaylists,sidxMapping)}if(vttPlaylists.length){master.mediaGroups.SUBTITLES.subs=organizeVttPlaylists(vttPlaylists,sidxMapping)}return master};var getLiveRValue=function getLiveRValue(attributes,time,duration){var NOW=attributes.NOW,clientOffset=attributes.clientOffset,availabilityStartTime=attributes.availabilityStartTime,_attributes$timescale=attributes.timescale,timescale=_attributes$timescale===void 0?1:_attributes$timescale,_attributes$start=attributes.start,start=_attributes$start===void 0?0:_attributes$start,_attributes$minimumUp=attributes.minimumUpdatePeriod,minimumUpdatePeriod=_attributes$minimumUp===void 0?0:_attributes$minimumUp;var now=(NOW+clientOffset)/1e3;var periodStartWC=availabilityStartTime+start;var periodEndWC=now+minimumUpdatePeriod;var periodDuration=periodEndWC-periodStartWC;return Math.ceil((periodDuration*timescale-time)/duration)};var parseByTimeline=function parseByTimeline(attributes,segmentTimeline){var _attributes$type=attributes.type,type=_attributes$type===void 0?"static":_attributes$type,_attributes$minimumUp2=attributes.minimumUpdatePeriod,minimumUpdatePeriod=_attributes$minimumUp2===void 0?0:_attributes$minimumUp2,_attributes$media=attributes.media,media=_attributes$media===void 0?"":_attributes$media,sourceDuration=attributes.sourceDuration,_attributes$timescale2=attributes.timescale,timescale=_attributes$timescale2===void 0?1:_attributes$timescale2,_attributes$startNumb=attributes.startNumber,startNumber=_attributes$startNumb===void 0?1:_attributes$startNumb,timeline=attributes.periodIndex;var segments=[];var time=-1;for(var sIndex=0;sIndex<segmentTimeline.length;sIndex++){var S=segmentTimeline[sIndex];var duration=S.d;var repeat=S.r||0;var segmentTime=S.t||0;if(time<0){time=segmentTime}if(segmentTime&&segmentTime>time){time=segmentTime}var count=void 0;if(repeat<0){var nextS=sIndex+1;if(nextS===segmentTimeline.length){if(type==="dynamic"&&minimumUpdatePeriod>0&&media.indexOf("$Number$")>0){count=getLiveRValue(attributes,time,duration)}else{count=(sourceDuration*timescale-time)/duration}}else{count=(segmentTimeline[nextS].t-time)/duration}}else{count=repeat+1}var end=startNumber+segments.length+count;var number=startNumber+segments.length;while(number<end){segments.push({number:number,duration:duration/timescale,time:time,timeline:timeline});time+=duration;number++}}return segments};var identifierPattern=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g;var identifierReplacement=function identifierReplacement(values){return function(match,identifier,format,width){if(match==="$$"){return"$"}if(typeof values[identifier]==="undefined"){return match}var value=""+values[identifier];if(identifier==="RepresentationID"){return value}if(!format){width=1}else{width=parseInt(width,10)}if(value.length>=width){return value}return""+new Array(width-value.length+1).join("0")+value}};var constructTemplateUrl=function constructTemplateUrl(url,values){return url.replace(identifierPattern,identifierReplacement(values))};var parseTemplateInfo=function parseTemplateInfo(attributes,segmentTimeline){if(!attributes.duration&&!segmentTimeline){return[{number:attributes.startNumber||1,duration:attributes.sourceDuration,time:0,timeline:attributes.periodIndex}]}if(attributes.duration){return parseByDuration(attributes)}return parseByTimeline(attributes,segmentTimeline)};var segmentsFromTemplate=function segmentsFromTemplate(attributes,segmentTimeline){var templateValues={RepresentationID:attributes.id,Bandwidth:attributes.bandwidth||0};var _attributes$initializ=attributes.initialization,initialization=_attributes$initializ===void 0?{sourceURL:"",range:""}:_attributes$initializ;var mapSegment=urlTypeToSegment({baseUrl:attributes.baseUrl,source:constructTemplateUrl(initialization.sourceURL,templateValues),range:initialization.range});var segments=parseTemplateInfo(attributes,segmentTimeline);return segments.map(function(segment){templateValues.Number=segment.number;templateValues.Time=segment.time;var uri=constructTemplateUrl(attributes.media||"",templateValues);return{uri:uri,timeline:segment.timeline,duration:segment.duration,resolvedUri:resolveUrl(attributes.baseUrl||"",uri),map:mapSegment,number:segment.number}})};var SegmentURLToSegmentObject=function SegmentURLToSegmentObject(attributes,segmentUrl){var baseUrl=attributes.baseUrl,_attributes$initializ=attributes.initialization,initialization=_attributes$initializ===void 0?{}:_attributes$initializ;var initSegment=urlTypeToSegment({baseUrl:baseUrl,source:initialization.sourceURL,range:initialization.range});var segment=urlTypeToSegment({baseUrl:baseUrl,source:segmentUrl.media,range:segmentUrl.mediaRange});segment.map=initSegment;return segment};var segmentsFromList=function segmentsFromList(attributes,segmentTimeline){var duration=attributes.duration,_attributes$segmentUr=attributes.segmentUrls,segmentUrls=_attributes$segmentUr===void 0?[]:_attributes$segmentUr;if(!duration&&!segmentTimeline||duration&&segmentTimeline){throw new Error(errors.SEGMENT_TIME_UNSPECIFIED)}var segmentUrlMap=segmentUrls.map(function(segmentUrlObject){return SegmentURLToSegmentObject(attributes,segmentUrlObject)});var segmentTimeInfo;if(duration){segmentTimeInfo=parseByDuration(attributes)}if(segmentTimeline){segmentTimeInfo=parseByTimeline(attributes,segmentTimeline)}var segments=segmentTimeInfo.map(function(segmentTime,index){if(segmentUrlMap[index]){var segment=segmentUrlMap[index];segment.timeline=segmentTime.timeline;segment.duration=segmentTime.duration;segment.number=segmentTime.number;return segment}}).filter(function(segment){return segment});return segments};var generateSegments=function generateSegments(_ref){var attributes=_ref.attributes,segmentInfo=_ref.segmentInfo;var segmentAttributes;var segmentsFn;if(segmentInfo.template){segmentsFn=segmentsFromTemplate;segmentAttributes=merge(attributes,segmentInfo.template)}else if(segmentInfo.base){segmentsFn=segmentsFromBase;segmentAttributes=merge(attributes,segmentInfo.base)}else if(segmentInfo.list){segmentsFn=segmentsFromList;segmentAttributes=merge(attributes,segmentInfo.list)}var segmentsInfo={attributes:attributes};if(!segmentsFn){return segmentsInfo}var segments=segmentsFn(segmentAttributes,segmentInfo.timeline);if(segmentAttributes.duration){var _segmentAttributes=segmentAttributes,duration=_segmentAttributes.duration,_segmentAttributes$ti=_segmentAttributes.timescale,timescale=_segmentAttributes$ti===void 0?1:_segmentAttributes$ti;segmentAttributes.duration=duration/timescale}else if(segments.length){segmentAttributes.duration=segments.reduce(function(max,segment){return Math.max(max,Math.ceil(segment.duration))},0)}else{segmentAttributes.duration=0}segmentsInfo.attributes=segmentAttributes;segmentsInfo.segments=segments;if(segmentInfo.base&&segmentAttributes.indexRange){segmentsInfo.sidx=segments[0];segmentsInfo.segments=[]}return segmentsInfo};var toPlaylists=function toPlaylists(representations){return representations.map(generateSegments)};var findChildren=function findChildren(element,name){return from(element.childNodes).filter(function(_ref){var tagName=_ref.tagName;return tagName===name})};var getContent=function getContent(element){return element.textContent.trim()};var parseDuration=function parseDuration(str){var SECONDS_IN_YEAR=365*24*60*60;var SECONDS_IN_MONTH=30*24*60*60;var SECONDS_IN_DAY=24*60*60;var SECONDS_IN_HOUR=60*60;var SECONDS_IN_MIN=60;var durationRegex=/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/;var match=durationRegex.exec(str);if(!match){return 0}var _match$slice=match.slice(1),year=_match$slice[0],month=_match$slice[1],day=_match$slice[2],hour=_match$slice[3],minute=_match$slice[4],second=_match$slice[5];return parseFloat(year||0)*SECONDS_IN_YEAR+parseFloat(month||0)*SECONDS_IN_MONTH+parseFloat(day||0)*SECONDS_IN_DAY+parseFloat(hour||0)*SECONDS_IN_HOUR+parseFloat(minute||0)*SECONDS_IN_MIN+parseFloat(second||0)};var parseDate=function parseDate(str){var dateRegex=/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/;if(dateRegex.test(str)){str+="Z"}return Date.parse(str)};var parsers={mediaPresentationDuration:function mediaPresentationDuration(value){return parseDuration(value)},availabilityStartTime:function availabilityStartTime(value){return parseDate(value)/1e3},minimumUpdatePeriod:function minimumUpdatePeriod(value){return parseDuration(value)},timeShiftBufferDepth:function timeShiftBufferDepth(value){return parseDuration(value)},start:function start(value){return parseDuration(value)},width:function width(value){return parseInt(value,10)},height:function height(value){return parseInt(value,10)},bandwidth:function bandwidth(value){return parseInt(value,10)},startNumber:function startNumber(value){return parseInt(value,10)},timescale:function timescale(value){return parseInt(value,10)},duration:function duration(value){var parsedValue=parseInt(value,10);if(isNaN(parsedValue)){return parseDuration(value)}return parsedValue},d:function d(value){return parseInt(value,10)},t:function t(value){return parseInt(value,10)},r:function r(value){return parseInt(value,10)},DEFAULT:function DEFAULT(value){return value}};var parseAttributes$1=function parseAttributes(el){if(!(el&&el.attributes)){return{}}return from(el.attributes).reduce(function(a,e){var parseFn=parsers[e.name]||parsers.DEFAULT;a[e.name]=parseFn(e.value);return a},{})};function decodeB64ToUint8Array$1(b64Text){var decodedString=window$1.atob(b64Text);var array=new Uint8Array(decodedString.length);for(var i=0;i<decodedString.length;i++){array[i]=decodedString.charCodeAt(i)}return array}var keySystemsMap={"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":"com.widevine.alpha","urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb":"com.adobe.primetime"};var buildBaseUrls=function buildBaseUrls(referenceUrls,baseUrlElements){if(!baseUrlElements.length){return referenceUrls}return flatten(referenceUrls.map(function(reference){return baseUrlElements.map(function(baseUrlElement){return resolveUrl(reference,getContent(baseUrlElement))})}))};var getSegmentInformation=function getSegmentInformation(adaptationSet){var segmentTemplate=findChildren(adaptationSet,"SegmentTemplate")[0];var segmentList=findChildren(adaptationSet,"SegmentList")[0];var segmentUrls=segmentList&&findChildren(segmentList,"SegmentURL").map(function(s){return merge({tag:"SegmentURL"},parseAttributes$1(s))});var segmentBase=findChildren(adaptationSet,"SegmentBase")[0];var segmentTimelineParentNode=segmentList||segmentTemplate;var segmentTimeline=segmentTimelineParentNode&&findChildren(segmentTimelineParentNode,"SegmentTimeline")[0];var segmentInitializationParentNode=segmentList||segmentBase||segmentTemplate;var segmentInitialization=segmentInitializationParentNode&&findChildren(segmentInitializationParentNode,"Initialization")[0];var template=segmentTemplate&&parseAttributes$1(segmentTemplate);if(template&&segmentInitialization){template.initialization=segmentInitialization&&parseAttributes$1(segmentInitialization)}else if(template&&template.initialization){template.initialization={sourceURL:template.initialization}}var segmentInfo={template:template,timeline:segmentTimeline&&findChildren(segmentTimeline,"S").map(function(s){return parseAttributes$1(s)}),list:segmentList&&merge(parseAttributes$1(segmentList),{segmentUrls:segmentUrls,initialization:parseAttributes$1(segmentInitialization)}),base:segmentBase&&merge(parseAttributes$1(segmentBase),{initialization:parseAttributes$1(segmentInitialization)})};Object.keys(segmentInfo).forEach(function(key){if(!segmentInfo[key]){delete segmentInfo[key]}});return segmentInfo};var inheritBaseUrls=function inheritBaseUrls(adaptationSetAttributes,adaptationSetBaseUrls,adaptationSetSegmentInfo){return function(representation){var repBaseUrlElements=findChildren(representation,"BaseURL");var repBaseUrls=buildBaseUrls(adaptationSetBaseUrls,repBaseUrlElements);var attributes=merge(adaptationSetAttributes,parseAttributes$1(representation));var representationSegmentInfo=getSegmentInformation(representation);return repBaseUrls.map(function(baseUrl){return{segmentInfo:merge(adaptationSetSegmentInfo,representationSegmentInfo),attributes:merge(attributes,{baseUrl:baseUrl})}})}};var generateKeySystemInformation=function generateKeySystemInformation(contentProtectionNodes){return contentProtectionNodes.reduce(function(acc,node){var attributes=parseAttributes$1(node);var keySystem=keySystemsMap[attributes.schemeIdUri];if(keySystem){acc[keySystem]={attributes:attributes};var psshNode=findChildren(node,"cenc:pssh")[0];if(psshNode){var pssh=getContent(psshNode);var psshBuffer=pssh&&decodeB64ToUint8Array$1(pssh);acc[keySystem].pssh=psshBuffer}}return acc},{})};var toRepresentations=function toRepresentations(periodAttributes,periodBaseUrls,periodSegmentInfo){return function(adaptationSet){var adaptationSetAttributes=parseAttributes$1(adaptationSet);var adaptationSetBaseUrls=buildBaseUrls(periodBaseUrls,findChildren(adaptationSet,"BaseURL"));var role=findChildren(adaptationSet,"Role")[0];var roleAttributes={role:parseAttributes$1(role)};var attrs=merge(periodAttributes,adaptationSetAttributes,roleAttributes);var contentProtection=generateKeySystemInformation(findChildren(adaptationSet,"ContentProtection"));if(Object.keys(contentProtection).length){attrs=merge(attrs,{contentProtection:contentProtection})}var segmentInfo=getSegmentInformation(adaptationSet);var representations=findChildren(adaptationSet,"Representation");var adaptationSetSegmentInfo=merge(periodSegmentInfo,segmentInfo);return flatten(representations.map(inheritBaseUrls(attrs,adaptationSetBaseUrls,adaptationSetSegmentInfo)))}};var toAdaptationSets=function toAdaptationSets(mpdAttributes,mpdBaseUrls){return function(period,index){var periodBaseUrls=buildBaseUrls(mpdBaseUrls,findChildren(period,"BaseURL"));var periodAtt=parseAttributes$1(period);var parsedPeriodId=parseInt(periodAtt.id,10);var periodIndex=window$1.isNaN(parsedPeriodId)?index:parsedPeriodId;var periodAttributes=merge(mpdAttributes,{periodIndex:periodIndex});var adaptationSets=findChildren(period,"AdaptationSet");var periodSegmentInfo=getSegmentInformation(period);return flatten(adaptationSets.map(toRepresentations(periodAttributes,periodBaseUrls,periodSegmentInfo)))}};var inheritAttributes=function inheritAttributes(mpd,options){if(options===void 0){options={}}var _options=options,_options$manifestUri=_options.manifestUri,manifestUri=_options$manifestUri===void 0?"":_options$manifestUri,_options$NOW=_options.NOW,NOW=_options$NOW===void 0?Date.now():_options$NOW,_options$clientOffset=_options.clientOffset,clientOffset=_options$clientOffset===void 0?0:_options$clientOffset;var periods=findChildren(mpd,"Period");if(!periods.length){throw new Error(errors.INVALID_NUMBER_OF_PERIOD)}var mpdAttributes=parseAttributes$1(mpd);var mpdBaseUrls=buildBaseUrls([manifestUri],findChildren(mpd,"BaseURL"));mpdAttributes.sourceDuration=mpdAttributes.mediaPresentationDuration||0;mpdAttributes.NOW=NOW;mpdAttributes.clientOffset=clientOffset;return flatten(periods.map(toAdaptationSets(mpdAttributes,mpdBaseUrls)))};var stringToMpdXml=function stringToMpdXml(manifestString){if(manifestString===""){throw new Error(errors.DASH_EMPTY_MANIFEST)}var parser=new window$1.DOMParser;var xml=parser.parseFromString(manifestString,"application/xml");var mpd=xml&&xml.documentElement.tagName==="MPD"?xml.documentElement:null;if(!mpd||mpd&&mpd.getElementsByTagName("parsererror").length>0){throw new Error(errors.DASH_INVALID_XML)}return mpd};var parseUTCTimingScheme=function parseUTCTimingScheme(mpd){var UTCTimingNode=findChildren(mpd,"UTCTiming")[0];if(!UTCTimingNode){return null}var attributes=parseAttributes$1(UTCTimingNode);switch(attributes.schemeIdUri){case"urn:mpeg:dash:utc:http-head:2014":case"urn:mpeg:dash:utc:http-head:2012":attributes.method="HEAD";break;case"urn:mpeg:dash:utc:http-xsdate:2014":case"urn:mpeg:dash:utc:http-iso:2014":case"urn:mpeg:dash:utc:http-xsdate:2012":case"urn:mpeg:dash:utc:http-iso:2012":attributes.method="GET";break;case"urn:mpeg:dash:utc:direct:2014":case"urn:mpeg:dash:utc:direct:2012":attributes.method="DIRECT";attributes.value=Date.parse(attributes.value);break;case"urn:mpeg:dash:utc:http-ntp:2014":case"urn:mpeg:dash:utc:ntp:2014":case"urn:mpeg:dash:utc:sntp:2014":default:throw new Error(errors.UNSUPPORTED_UTC_TIMING_SCHEME)}return attributes};var parse=function parse(manifestString,options){if(options===void 0){options={}}return toM3u8(toPlaylists(inheritAttributes(stringToMpdXml(manifestString),options)),options.sidxMapping)};var parseUTCTiming=function parseUTCTiming(manifestString){return parseUTCTimingScheme(stringToMpdXml(manifestString))};var toUnsigned=function toUnsigned(value){return value>>>0};var toHexString=function toHexString(value){return("00"+value.toString(16)).slice(-2)};var bin={toUnsigned:toUnsigned,toHexString:toHexString};var toUnsigned$1=bin.toUnsigned;var toHexString$1=bin.toHexString;var _findBox,parseType,timescale,startTime,getVideoTrackIds,getTracks;_findBox=function findBox(data,path){var results=[],i,size,type,end,subresults;if(!path.length){return null}for(i=0;i<data.byteLength;){size=toUnsigned$1(data[i]<<24|data[i+1]<<16|data[i+2]<<8|data[i+3]);type=parseType(data.subarray(i+4,i+8));end=size>1?i+size:data.byteLength;if(type===path[0]){if(path.length===1){results.push(data.subarray(i+8,end))}else{subresults=_findBox(data.subarray(i+8,end),path.slice(1));if(subresults.length){results=results.concat(subresults)}}}i=end}return results};parseType=function parseType(buffer){var result="";result+=String.fromCharCode(buffer[0]);result+=String.fromCharCode(buffer[1]);result+=String.fromCharCode(buffer[2]);result+=String.fromCharCode(buffer[3]);return result};timescale=function timescale(init){var result={},traks=_findBox(init,["moov","trak"]);return traks.reduce(function(result,trak){var tkhd,version,index,id,mdhd;tkhd=_findBox(trak,["tkhd"])[0];if(!tkhd){return null}version=tkhd[0];index=version===0?12:20;id=toUnsigned$1(tkhd[index]<<24|tkhd[index+1]<<16|tkhd[index+2]<<8|tkhd[index+3]);mdhd=_findBox(trak,["mdia","mdhd"])[0];if(!mdhd){return null}version=mdhd[0];index=version===0?12:20;result[id]=toUnsigned$1(mdhd[index]<<24|mdhd[index+1]<<16|mdhd[index+2]<<8|mdhd[index+3]);return result},result)};startTime=function startTime(timescale,fragment){var trafs,baseTimes,result;trafs=_findBox(fragment,["moof","traf"]);baseTimes=[].concat.apply([],trafs.map(function(traf){return _findBox(traf,["tfhd"]).map(function(tfhd){var id,scale,baseTime;id=toUnsigned$1(tfhd[4]<<24|tfhd[5]<<16|tfhd[6]<<8|tfhd[7]);scale=timescale[id]||9e4;baseTime=_findBox(traf,["tfdt"]).map(function(tfdt){var version,result;version=tfdt[0];result=toUnsigned$1(tfdt[4]<<24|tfdt[5]<<16|tfdt[6]<<8|tfdt[7]);if(version===1){result*=Math.pow(2,32);result+=toUnsigned$1(tfdt[8]<<24|tfdt[9]<<16|tfdt[10]<<8|tfdt[11])}return result})[0];baseTime=baseTime||Infinity;return baseTime/scale})}));result=Math.min.apply(null,baseTimes);return isFinite(result)?result:0};getVideoTrackIds=function getVideoTrackIds(init){var traks=_findBox(init,["moov","trak"]);var videoTrackIds=[];traks.forEach(function(trak){var hdlrs=_findBox(trak,["mdia","hdlr"]);var tkhds=_findBox(trak,["tkhd"]);hdlrs.forEach(function(hdlr,index){var handlerType=parseType(hdlr.subarray(8,12));var tkhd=tkhds[index];var view;var version;var trackId;if(handlerType==="vide"){view=new DataView(tkhd.buffer,tkhd.byteOffset,tkhd.byteLength);version=view.getUint8(0);trackId=version===0?view.getUint32(12):view.getUint32(20);videoTrackIds.push(trackId)}})});return videoTrackIds};getTracks=function getTracks(init){var traks=_findBox(init,["moov","trak"]);var tracks=[];traks.forEach(function(trak){var track={};var tkhd=_findBox(trak,["tkhd"])[0];var view,version;if(tkhd){view=new DataView(tkhd.buffer,tkhd.byteOffset,tkhd.byteLength);version=view.getUint8(0);track.id=version===0?view.getUint32(12):view.getUint32(20)}var hdlr=_findBox(trak,["mdia","hdlr"])[0];if(hdlr){var type=parseType(hdlr.subarray(8,12));if(type==="vide"){track.type="video"}else if(type==="soun"){track.type="audio"}else{track.type=type}}var stsd=_findBox(trak,["mdia","minf","stbl","stsd"])[0];if(stsd){var sampleDescriptions=stsd.subarray(8);track.codec=parseType(sampleDescriptions.subarray(4,8));var codecBox=_findBox(sampleDescriptions,[track.codec])[0];var codecConfig,codecConfigType;if(codecBox){if(/^[a-z]vc[1-9]$/i.test(track.codec)){codecConfig=codecBox.subarray(78);codecConfigType=parseType(codecConfig.subarray(4,8));if(codecConfigType==="avcC"&&codecConfig.length>11){track.codec+=".";track.codec+=toHexString$1(codecConfig[9]);track.codec+=toHexString$1(codecConfig[10]);track.codec+=toHexString$1(codecConfig[11])}else{track.codec="avc1.4d400d"}}else if(/^mp4[a,v]$/i.test(track.codec)){codecConfig=codecBox.subarray(28);codecConfigType=parseType(codecConfig.subarray(4,8));if(codecConfigType==="esds"&&codecConfig.length>20&&codecConfig[19]!==0){track.codec+="."+toHexString$1(codecConfig[19]);track.codec+="."+toHexString$1(codecConfig[20]>>>2&63).replace(/^0/,"")}else{track.codec="mp4a.40.2"}}}}var mdhd=_findBox(trak,["mdia","mdhd"])[0];if(mdhd&&tkhd){var index=version===0?12:20;track.timescale=toUnsigned$1(mdhd[index]<<24|mdhd[index+1]<<16|mdhd[index+2]<<8|mdhd[index+3])}tracks.push(track)});return tracks};var probe={findBox:_findBox,parseType:parseType,timescale:timescale,startTime:startTime,videoTrackIds:getVideoTrackIds,tracks:getTracks};var inspectMp4,_textifyMp,parseType$1=probe.parseType,parseMp4Date=function parseMp4Date(seconds){return new Date(seconds*1e3-20828448e5)},parseSampleFlags=function parseSampleFlags(flags){return{isLeading:(flags[0]&12)>>>2,dependsOn:flags[0]&3,isDependedOn:(flags[1]&192)>>>6,hasRedundancy:(flags[1]&48)>>>4,paddingValue:(flags[1]&14)>>>1,isNonSyncSample:flags[1]&1,degradationPriority:flags[2]<<8|flags[3]}},nalParse=function nalParse(avcStream){var avcView=new DataView(avcStream.buffer,avcStream.byteOffset,avcStream.byteLength),result=[],i,length;for(i=0;i+4<avcStream.length;i+=length){length=avcView.getUint32(i);i+=4;if(length<=0){result.push("<span style='color:red;'>MALFORMED DATA</span>");continue}switch(avcStream[i]&31){case 1:result.push("slice_layer_without_partitioning_rbsp");break;case 5:result.push("slice_layer_without_partitioning_rbsp_idr");break;case 6:result.push("sei_rbsp");break;case 7:result.push("seq_parameter_set_rbsp");break;case 8:result.push("pic_parameter_set_rbsp");break;case 9:result.push("access_unit_delimiter_rbsp");break;default:result.push("UNKNOWN NAL - "+avcStream[i]&31);break}}return result},parse$1={avc1:function avc1(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength);return{dataReferenceIndex:view.getUint16(6),width:view.getUint16(24),height:view.getUint16(26),horizresolution:view.getUint16(28)+view.getUint16(30)/16,vertresolution:view.getUint16(32)+view.getUint16(34)/16,frameCount:view.getUint16(40),depth:view.getUint16(74),config:inspectMp4(data.subarray(78,data.byteLength))}},avcC:function avcC(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength),result={configurationVersion:data[0],avcProfileIndication:data[1],profileCompatibility:data[2],avcLevelIndication:data[3],lengthSizeMinusOne:data[4]&3,sps:[],pps:[]},numOfSequenceParameterSets=data[5]&31,numOfPictureParameterSets,nalSize,offset,i;offset=6;for(i=0;i<numOfSequenceParameterSets;i++){nalSize=view.getUint16(offset);offset+=2;result.sps.push(new Uint8Array(data.subarray(offset,offset+nalSize)));offset+=nalSize}numOfPictureParameterSets=data[offset];offset++;for(i=0;i<numOfPictureParameterSets;i++){nalSize=view.getUint16(offset);offset+=2;result.pps.push(new Uint8Array(data.subarray(offset,offset+nalSize)));offset+=nalSize}return result},btrt:function btrt(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength);return{bufferSizeDB:view.getUint32(0),maxBitrate:view.getUint32(4),avgBitrate:view.getUint32(8)}},esds:function esds(data){return{version:data[0],flags:new Uint8Array(data.subarray(1,4)),esId:data[6]<<8|data[7],streamPriority:data[8]&31,decoderConfig:{objectProfileIndication:data[11],streamType:data[12]>>>2&63,bufferSize:data[13]<<16|data[14]<<8|data[15],maxBitrate:data[16]<<24|data[17]<<16|data[18]<<8|data[19],avgBitrate:data[20]<<24|data[21]<<16|data[22]<<8|data[23],decoderConfigDescriptor:{tag:data[24],length:data[25],audioObjectType:data[26]>>>3&31,samplingFrequencyIndex:(data[26]&7)<<1|data[27]>>>7&1,channelConfiguration:data[27]>>>3&15}}}},ftyp:function ftyp(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength),result={majorBrand:parseType$1(data.subarray(0,4)),minorVersion:view.getUint32(4),compatibleBrands:[]},i=8;while(i<data.byteLength){result.compatibleBrands.push(parseType$1(data.subarray(i,i+4)));i+=4}return result},dinf:function dinf(data){return{boxes:inspectMp4(data)}},dref:function dref(data){return{version:data[0],flags:new Uint8Array(data.subarray(1,4)),dataReferences:inspectMp4(data.subarray(8))}},hdlr:function hdlr(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength),result={version:view.getUint8(0),flags:new Uint8Array(data.subarray(1,4)),handlerType:parseType$1(data.subarray(8,12)),name:""},i=8;for(i=24;i<data.byteLength;i++){if(data[i]===0){i++;break}result.name+=String.fromCharCode(data[i])}result.name=decodeURIComponent(escape(result.name));return result},mdat:function mdat(data){return{byteLength:data.byteLength,nals:nalParse(data)}},mdhd:function mdhd(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength),i=4,language,result={version:view.getUint8(0),flags:new Uint8Array(data.subarray(1,4)),language:""};if(result.version===1){i+=4;result.creationTime=parseMp4Date(view.getUint32(i));i+=8;result.modificationTime=parseMp4Date(view.getUint32(i));i+=4;result.timescale=view.getUint32(i);i+=8;result.duration=view.getUint32(i)}else{result.creationTime=parseMp4Date(view.getUint32(i));i+=4;result.modificationTime=parseMp4Date(view.getUint32(i));i+=4;result.timescale=view.getUint32(i);i+=4;result.duration=view.getUint32(i)}i+=4;language=view.getUint16(i);result.language+=String.fromCharCode((language>>10)+96);result.language+=String.fromCharCode(((language&992)>>5)+96);result.language+=String.fromCharCode((language&31)+96);return result},mdia:function mdia(data){return{boxes:inspectMp4(data)}},mfhd:function mfhd(data){return{version:data[0],flags:new Uint8Array(data.subarray(1,4)),sequenceNumber:data[4]<<24|data[5]<<16|data[6]<<8|data[7]}},minf:function minf(data){return{boxes:inspectMp4(data)}},mp4a:function mp4a(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength),result={dataReferenceIndex:view.getUint16(6),channelcount:view.getUint16(16),samplesize:view.getUint16(18),samplerate:view.getUint16(24)+view.getUint16(26)/65536};if(data.byteLength>28){result.streamDescriptor=inspectMp4(data.subarray(28))[0]}return result},moof:function moof(data){return{boxes:inspectMp4(data)}},moov:function moov(data){return{boxes:inspectMp4(data)}},mvex:function mvex(data){return{boxes:inspectMp4(data)}},mvhd:function mvhd(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength),i=4,result={version:view.getUint8(0),flags:new Uint8Array(data.subarray(1,4))};if(result.version===1){i+=4;result.creationTime=parseMp4Date(view.getUint32(i));i+=8;result.modificationTime=parseMp4Date(view.getUint32(i));i+=4;result.timescale=view.getUint32(i);i+=8;result.duration=view.getUint32(i)}else{result.creationTime=parseMp4Date(view.getUint32(i));i+=4;result.modificationTime=parseMp4Date(view.getUint32(i));i+=4;result.timescale=view.getUint32(i);i+=4;result.duration=view.getUint32(i)}i+=4;result.rate=view.getUint16(i)+view.getUint16(i+2)/16;i+=4;result.volume=view.getUint8(i)+view.getUint8(i+1)/8;i+=2;i+=2;i+=2*4;result.matrix=new Uint32Array(data.subarray(i,i+9*4));i+=9*4;i+=6*4;result.nextTrackId=view.getUint32(i);return result},pdin:function pdin(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength);return{version:view.getUint8(0),flags:new Uint8Array(data.subarray(1,4)),rate:view.getUint32(4),initialDelay:view.getUint32(8)}},sdtp:function sdtp(data){var result={version:data[0],flags:new Uint8Array(data.subarray(1,4)),samples:[]},i;for(i=4;i<data.byteLength;i++){result.samples.push({dependsOn:(data[i]&48)>>4,isDependedOn:(data[i]&12)>>2,hasRedundancy:data[i]&3})}return result},sidx:function sidx(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength),result={version:data[0],flags:new Uint8Array(data.subarray(1,4)),references:[],referenceId:view.getUint32(4),timescale:view.getUint32(8),earliestPresentationTime:view.getUint32(12),firstOffset:view.getUint32(16)},referenceCount=view.getUint16(22),i;for(i=24;referenceCount;i+=12,referenceCount--){result.references.push({referenceType:(data[i]&128)>>>7,referencedSize:view.getUint32(i)&2147483647,subsegmentDuration:view.getUint32(i+4),startsWithSap:!!(data[i+8]&128),sapType:(data[i+8]&112)>>>4,sapDeltaTime:view.getUint32(i+8)&268435455})}return result},smhd:function smhd(data){return{version:data[0],flags:new Uint8Array(data.subarray(1,4)),balance:data[4]+data[5]/256}},stbl:function stbl(data){return{boxes:inspectMp4(data)}},stco:function stco(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength),result={version:data[0],flags:new Uint8Array(data.subarray(1,4)),chunkOffsets:[]},entryCount=view.getUint32(4),i;for(i=8;entryCount;i+=4,entryCount--){result.chunkOffsets.push(view.getUint32(i))}return result},stsc:function stsc(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength),entryCount=view.getUint32(4),result={version:data[0],flags:new Uint8Array(data.subarray(1,4)),sampleToChunks:[]},i;for(i=8;entryCount;i+=12,entryCount--){result.sampleToChunks.push({firstChunk:view.getUint32(i),samplesPerChunk:view.getUint32(i+4),sampleDescriptionIndex:view.getUint32(i+8)})}return result},stsd:function stsd(data){return{version:data[0],flags:new Uint8Array(data.subarray(1,4)),sampleDescriptions:inspectMp4(data.subarray(8))}},stsz:function stsz(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength),result={version:data[0],flags:new Uint8Array(data.subarray(1,4)),sampleSize:view.getUint32(4),entries:[]},i;for(i=12;i<data.byteLength;i+=4){result.entries.push(view.getUint32(i))}return result},stts:function stts(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength),result={version:data[0],flags:new Uint8Array(data.subarray(1,4)),timeToSamples:[]},entryCount=view.getUint32(4),i;for(i=8;entryCount;i+=8,entryCount--){result.timeToSamples.push({sampleCount:view.getUint32(i),sampleDelta:view.getUint32(i+4)})}return result},styp:function styp(data){return parse$1.ftyp(data)},tfdt:function tfdt(data){var result={version:data[0],flags:new Uint8Array(data.subarray(1,4)),baseMediaDecodeTime:data[4]<<24|data[5]<<16|data[6]<<8|data[7]};if(result.version===1){result.baseMediaDecodeTime*=Math.pow(2,32);result.baseMediaDecodeTime+=data[8]<<24|data[9]<<16|data[10]<<8|data[11]}return result},tfhd:function tfhd(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength),result={version:data[0],flags:new Uint8Array(data.subarray(1,4)),trackId:view.getUint32(4)},baseDataOffsetPresent=result.flags[2]&1,sampleDescriptionIndexPresent=result.flags[2]&2,defaultSampleDurationPresent=result.flags[2]&8,defaultSampleSizePresent=result.flags[2]&16,defaultSampleFlagsPresent=result.flags[2]&32,durationIsEmpty=result.flags[0]&65536,defaultBaseIsMoof=result.flags[0]&131072,i;i=8;if(baseDataOffsetPresent){i+=4;result.baseDataOffset=view.getUint32(12);i+=4}if(sampleDescriptionIndexPresent){result.sampleDescriptionIndex=view.getUint32(i);i+=4}if(defaultSampleDurationPresent){result.defaultSampleDuration=view.getUint32(i);i+=4}if(defaultSampleSizePresent){result.defaultSampleSize=view.getUint32(i);i+=4}if(defaultSampleFlagsPresent){result.defaultSampleFlags=view.getUint32(i)}if(durationIsEmpty){result.durationIsEmpty=true}if(!baseDataOffsetPresent&&defaultBaseIsMoof){result.baseDataOffsetIsMoof=true}return result},tkhd:function tkhd(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength),i=4,result={version:view.getUint8(0),flags:new Uint8Array(data.subarray(1,4))};if(result.version===1){i+=4;result.creationTime=parseMp4Date(view.getUint32(i));i+=8;result.modificationTime=parseMp4Date(view.getUint32(i));i+=4;result.trackId=view.getUint32(i);i+=4;i+=8;result.duration=view.getUint32(i)}else{result.creationTime=parseMp4Date(view.getUint32(i));i+=4;result.modificationTime=parseMp4Date(view.getUint32(i));i+=4;result.trackId=view.getUint32(i);i+=4;i+=4;result.duration=view.getUint32(i)}i+=4;i+=2*4;result.layer=view.getUint16(i);i+=2;result.alternateGroup=view.getUint16(i);i+=2;result.volume=view.getUint8(i)+view.getUint8(i+1)/8;i+=2;i+=2;result.matrix=new Uint32Array(data.subarray(i,i+9*4));i+=9*4;result.width=view.getUint16(i)+view.getUint16(i+2)/16;i+=4;result.height=view.getUint16(i)+view.getUint16(i+2)/16;return result},traf:function traf(data){return{boxes:inspectMp4(data)}},trak:function trak(data){return{boxes:inspectMp4(data)}},trex:function trex(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength);return{version:data[0],flags:new Uint8Array(data.subarray(1,4)),trackId:view.getUint32(4),defaultSampleDescriptionIndex:view.getUint32(8),defaultSampleDuration:view.getUint32(12),defaultSampleSize:view.getUint32(16),sampleDependsOn:data[20]&3,sampleIsDependedOn:(data[21]&192)>>6,sampleHasRedundancy:(data[21]&48)>>4,samplePaddingValue:(data[21]&14)>>1,sampleIsDifferenceSample:!!(data[21]&1),sampleDegradationPriority:view.getUint16(22)}},trun:function trun(data){var result={version:data[0],flags:new Uint8Array(data.subarray(1,4)),samples:[]},view=new DataView(data.buffer,data.byteOffset,data.byteLength),dataOffsetPresent=result.flags[2]&1,firstSampleFlagsPresent=result.flags[2]&4,sampleDurationPresent=result.flags[1]&1,sampleSizePresent=result.flags[1]&2,sampleFlagsPresent=result.flags[1]&4,sampleCompositionTimeOffsetPresent=result.flags[1]&8,sampleCount=view.getUint32(4),offset=8,sample;if(dataOffsetPresent){result.dataOffset=view.getInt32(offset);offset+=4}if(firstSampleFlagsPresent&&sampleCount){sample={flags:parseSampleFlags(data.subarray(offset,offset+4))};offset+=4;if(sampleDurationPresent){sample.duration=view.getUint32(offset);offset+=4}if(sampleSizePresent){sample.size=view.getUint32(offset);offset+=4}if(sampleCompositionTimeOffsetPresent){sample.compositionTimeOffset=view.getUint32(offset);offset+=4}result.samples.push(sample);sampleCount--}while(sampleCount--){sample={};if(sampleDurationPresent){sample.duration=view.getUint32(offset);offset+=4}if(sampleSizePresent){sample.size=view.getUint32(offset);offset+=4}if(sampleFlagsPresent){sample.flags=parseSampleFlags(data.subarray(offset,offset+4));offset+=4}if(sampleCompositionTimeOffsetPresent){sample.compositionTimeOffset=view.getUint32(offset);offset+=4}result.samples.push(sample)}return result},"url ":function url(data){return{version:data[0],flags:new Uint8Array(data.subarray(1,4))}},vmhd:function vmhd(data){var view=new DataView(data.buffer,data.byteOffset,data.byteLength);return{version:data[0],flags:new Uint8Array(data.subarray(1,4)),graphicsmode:view.getUint16(4),opcolor:new Uint16Array([view.getUint16(6),view.getUint16(8),view.getUint16(10)])}}};inspectMp4=function inspectMp4(data){var i=0,result=[],view,size,type,end,box;var ab=new ArrayBuffer(data.length);var v=new Uint8Array(ab);for(var z=0;z<data.length;++z){v[z]=data[z]}view=new DataView(ab);while(i<data.byteLength){size=view.getUint32(i);type=parseType$1(data.subarray(i+4,i+8));end=size>1?i+size:data.byteLength;box=(parse$1[type]||function(data){return{data:data}})(data.subarray(i+8,end));box.size=size;box.type=type;result.push(box);i=end}return result};_textifyMp=function textifyMp4(inspectedMp4,depth){var indent;depth=depth||0;indent=new Array(depth*2+1).join(" ");return inspectedMp4.map(function(box,index){return indent+box.type+"\n"+Object.keys(box).filter(function(key){return key!=="type"&&key!=="boxes"}).map(function(key){var prefix=indent+" "+key+": ",value=box[key];if(value instanceof Uint8Array||value instanceof Uint32Array){var bytes=Array.prototype.slice.call(new Uint8Array(value.buffer,value.byteOffset,value.byteLength)).map(function(_byte){return" "+("00"+_byte.toString(16)).slice(-2)}).join("").match(/.{1,24}/g);if(!bytes){return prefix+"<>"}if(bytes.length===1){return prefix+"<"+bytes.join("").slice(1)+">"}return prefix+"<\n"+bytes.map(function(line){return indent+" "+line}).join("\n")+"\n"+indent+" >"}return prefix+JSON.stringify(value,null,2).split("\n").map(function(line,index){if(index===0){return line}return indent+" "+line}).join("\n")}).join("\n")+(box.boxes?"\n"+_textifyMp(box.boxes,depth+1):"")}).join("\n")};var mp4Inspector={inspect:inspectMp4,textify:_textifyMp,parseTfdt:parse$1.tfdt,parseHdlr:parse$1.hdlr,parseTfhd:parse$1.tfhd,parseTrun:parse$1.trun,parseSidx:parse$1.sidx};var USER_DATA_REGISTERED_ITU_T_T35=4,RBSP_TRAILING_BITS=128;var parseSei=function parseSei(bytes){var i=0,result={payloadType:-1,payloadSize:0},payloadType=0,payloadSize=0;while(i<bytes.byteLength){if(bytes[i]===RBSP_TRAILING_BITS){break}while(bytes[i]===255){payloadType+=255;i++}payloadType+=bytes[i++];while(bytes[i]===255){payloadSize+=255;i++}payloadSize+=bytes[i++];if(!result.payload&&payloadType===USER_DATA_REGISTERED_ITU_T_T35){result.payloadType=payloadType;result.payloadSize=payloadSize;result.payload=bytes.subarray(i,i+payloadSize);break}i+=payloadSize;payloadType=0;payloadSize=0}return result};var parseUserData=function parseUserData(sei){if(sei.payload[0]!==181){return null}if((sei.payload[1]<<8|sei.payload[2])!==49){return null}if(String.fromCharCode(sei.payload[3],sei.payload[4],sei.payload[5],sei.payload[6])!=="GA94"){return null}if(sei.payload[7]!==3){return null}return sei.payload.subarray(8,sei.payload.length-1)};var parseCaptionPackets=function parseCaptionPackets(pts,userData){var results=[],i,count,offset,data;if(!(userData[0]&64)){return results}count=userData[0]&31;for(i=0;i<count;i++){offset=i*3;data={type:userData[offset+2]&3,pts:pts};if(userData[offset+2]&4){data.ccData=userData[offset+3]<<8|userData[offset+4];results.push(data)}}return results};var discardEmulationPreventionBytes=function discardEmulationPreventionBytes(data){var length=data.byteLength,emulationPreventionBytesPositions=[],i=1,newLength,newData;while(i<length-2){if(data[i]===0&&data[i+1]===0&&data[i+2]===3){emulationPreventionBytesPositions.push(i+2);i+=2}else{i++}}if(emulationPreventionBytesPositions.length===0){return data}newLength=length-emulationPreventionBytesPositions.length;newData=new Uint8Array(newLength);var sourceIndex=0;for(i=0;i<newLength;sourceIndex++,i++){if(sourceIndex===emulationPreventionBytesPositions[0]){sourceIndex++;emulationPreventionBytesPositions.shift()}newData[i]=data[sourceIndex]}return newData};var captionPacketParser={parseSei:parseSei,parseUserData:parseUserData,parseCaptionPackets:parseCaptionPackets,discardEmulationPreventionBytes:discardEmulationPreventionBytes,USER_DATA_REGISTERED_ITU_T_T35:USER_DATA_REGISTERED_ITU_T_T35};var Stream$1=function Stream(){this.init=function(){var listeners={};this.on=function(type,listener){if(!listeners[type]){listeners[type]=[]}listeners[type]=listeners[type].concat(listener)};this.off=function(type,listener){var index;if(!listeners[type]){return false}index=listeners[type].indexOf(listener);listeners[type]=listeners[type].slice();listeners[type].splice(index,1);return index>-1};this.trigger=function(type){var callbacks,i,length,args;callbacks=listeners[type];if(!callbacks){return}if(arguments.length===2){length=callbacks.length;for(i=0;i<length;++i){callbacks[i].call(this,arguments[1])}}else{args=[];i=arguments.length;for(i=1;i<arguments.length;++i){args.push(arguments[i])}length=callbacks.length;for(i=0;i<length;++i){callbacks[i].apply(this,args)}}};this.dispose=function(){listeners={}}}};Stream$1.prototype.pipe=function(destination){this.on("data",function(data){destination.push(data)});this.on("done",function(flushSource){destination.flush(flushSource)});this.on("partialdone",function(flushSource){destination.partialFlush(flushSource)});this.on("endedtimeline",function(flushSource){destination.endTimeline(flushSource)});this.on("reset",function(flushSource){destination.reset(flushSource)});return destination};Stream$1.prototype.push=function(data){this.trigger("data",data)};Stream$1.prototype.flush=function(flushSource){this.trigger("done",flushSource)};Stream$1.prototype.partialFlush=function(flushSource){this.trigger("partialdone",flushSource)};Stream$1.prototype.endTimeline=function(flushSource){this.trigger("endedtimeline",flushSource)};Stream$1.prototype.reset=function(flushSource){this.trigger("reset",flushSource)};var stream=Stream$1;var CaptionStream=function CaptionStream(){CaptionStream.prototype.init.call(this);this.captionPackets_=[];this.ccStreams_=[new Cea608Stream(0,0),new Cea608Stream(0,1),new Cea608Stream(1,0),new Cea608Stream(1,1)];this.reset();this.ccStreams_.forEach(function(cc){cc.on("data",this.trigger.bind(this,"data"));cc.on("partialdone",this.trigger.bind(this,"partialdone"));cc.on("done",this.trigger.bind(this,"done"))},this)};CaptionStream.prototype=new stream;CaptionStream.prototype.push=function(event){var sei,userData,newCaptionPackets;if(event.nalUnitType!=="sei_rbsp"){return}sei=captionPacketParser.parseSei(event.escapedRBSP);if(sei.payloadType!==captionPacketParser.USER_DATA_REGISTERED_ITU_T_T35){return}userData=captionPacketParser.parseUserData(sei);if(!userData){return}if(event.dts<this.latestDts_){this.ignoreNextEqualDts_=true;return}else if(event.dts===this.latestDts_&&this.ignoreNextEqualDts_){this.numSameDts_--;if(!this.numSameDts_){this.ignoreNextEqualDts_=false}return}newCaptionPackets=captionPacketParser.parseCaptionPackets(event.pts,userData);this.captionPackets_=this.captionPackets_.concat(newCaptionPackets);if(this.latestDts_!==event.dts){this.numSameDts_=0}this.numSameDts_++;this.latestDts_=event.dts};CaptionStream.prototype.flushCCStreams=function(flushType){this.ccStreams_.forEach(function(cc){return flushType==="flush"?cc.flush():cc.partialFlush()},this)};CaptionStream.prototype.flushStream=function(flushType){if(!this.captionPackets_.length){this.flushCCStreams(flushType);return}this.captionPackets_.forEach(function(elem,idx){elem.presortIndex=idx});this.captionPackets_.sort(function(a,b){if(a.pts===b.pts){return a.presortIndex-b.presortIndex}return a.pts-b.pts});this.captionPackets_.forEach(function(packet){if(packet.type<2){this.dispatchCea608Packet(packet)}},this);this.captionPackets_.length=0;this.flushCCStreams(flushType)};CaptionStream.prototype.flush=function(){return this.flushStream("flush")};CaptionStream.prototype.partialFlush=function(){return this.flushStream("partialFlush")};CaptionStream.prototype.reset=function(){this.latestDts_=null;this.ignoreNextEqualDts_=false;this.numSameDts_=0;this.activeCea608Channel_=[null,null];this.ccStreams_.forEach(function(ccStream){ccStream.reset()})};CaptionStream.prototype.dispatchCea608Packet=function(packet){if(this.setsTextOrXDSActive(packet)){this.activeCea608Channel_[packet.type]=null}else if(this.setsChannel1Active(packet)){this.activeCea608Channel_[packet.type]=0}else if(this.setsChannel2Active(packet)){this.activeCea608Channel_[packet.type]=1}if(this.activeCea608Channel_[packet.type]===null){return}this.ccStreams_[(packet.type<<1)+this.activeCea608Channel_[packet.type]].push(packet)};CaptionStream.prototype.setsChannel1Active=function(packet){return(packet.ccData&30720)===4096};CaptionStream.prototype.setsChannel2Active=function(packet){return(packet.ccData&30720)===6144};CaptionStream.prototype.setsTextOrXDSActive=function(packet){return(packet.ccData&28928)===256||(packet.ccData&30974)===4138||(packet.ccData&30974)===6186};var CHARACTER_TRANSLATION={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496};var getCharFromCode=function getCharFromCode(code){if(code===null){return""}code=CHARACTER_TRANSLATION[code]||code;return String.fromCharCode(code)};var BOTTOM_ROW=14;var ROWS=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152];var createDisplayBuffer=function createDisplayBuffer(){var result=[],i=BOTTOM_ROW+1;while(i--){result.push("")}return result};var Cea608Stream=function Cea608Stream(field,dataChannel){Cea608Stream.prototype.init.call(this);this.field_=field||0;this.dataChannel_=dataChannel||0;this.name_="CC"+((this.field_<<1|this.dataChannel_)+1);this.setConstants();this.reset();this.push=function(packet){var data,swap,char0,char1,text;data=packet.ccData&32639;if(data===this.lastControlCode_){this.lastControlCode_=null;return}if((data&61440)===4096){this.lastControlCode_=data}else if(data!==this.PADDING_){this.lastControlCode_=null}char0=data>>>8;char1=data&255;if(data===this.PADDING_){return}else if(data===this.RESUME_CAPTION_LOADING_){this.mode_="popOn"}else if(data===this.END_OF_CAPTION_){this.mode_="popOn";this.clearFormatting(packet.pts);this.flushDisplayed(packet.pts);swap=this.displayed_;this.displayed_=this.nonDisplayed_;this.nonDisplayed_=swap;this.startPts_=packet.pts}else if(data===this.ROLL_UP_2_ROWS_){this.rollUpRows_=2;this.setRollUp(packet.pts)}else if(data===this.ROLL_UP_3_ROWS_){this.rollUpRows_=3;this.setRollUp(packet.pts)}else if(data===this.ROLL_UP_4_ROWS_){this.rollUpRows_=4;this.setRollUp(packet.pts)}else if(data===this.CARRIAGE_RETURN_){this.clearFormatting(packet.pts);this.flushDisplayed(packet.pts);this.shiftRowsUp_();this.startPts_=packet.pts}else if(data===this.BACKSPACE_){if(this.mode_==="popOn"){this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1)}else{this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1)}}else if(data===this.ERASE_DISPLAYED_MEMORY_){this.flushDisplayed(packet.pts);this.displayed_=createDisplayBuffer()}else if(data===this.ERASE_NON_DISPLAYED_MEMORY_){this.nonDisplayed_=createDisplayBuffer()}else if(data===this.RESUME_DIRECT_CAPTIONING_){if(this.mode_!=="paintOn"){this.flushDisplayed(packet.pts);this.displayed_=createDisplayBuffer()}this.mode_="paintOn";this.startPts_=packet.pts}else if(this.isSpecialCharacter(char0,char1)){char0=(char0&3)<<8;text=getCharFromCode(char0|char1);this[this.mode_](packet.pts,text);this.column_++}else if(this.isExtCharacter(char0,char1)){if(this.mode_==="popOn"){this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1)}else{this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1)}char0=(char0&3)<<8;text=getCharFromCode(char0|char1);this[this.mode_](packet.pts,text);this.column_++}else if(this.isMidRowCode(char0,char1)){this.clearFormatting(packet.pts);this[this.mode_](packet.pts," ");this.column_++;if((char1&14)===14){this.addFormatting(packet.pts,["i"])}if((char1&1)===1){this.addFormatting(packet.pts,["u"])}}else if(this.isOffsetControlCode(char0,char1)){this.column_+=char1&3}else if(this.isPAC(char0,char1)){var row=ROWS.indexOf(data&7968);if(this.mode_==="rollUp"){if(row-this.rollUpRows_+1<0){row=this.rollUpRows_-1}this.setRollUp(packet.pts,row)}if(row!==this.row_){this.clearFormatting(packet.pts);this.row_=row}if(char1&1&&this.formatting_.indexOf("u")===-1){this.addFormatting(packet.pts,["u"])}if((data&16)===16){this.column_=((data&14)>>1)*4}if(this.isColorPAC(char1)){if((char1&14)===14){this.addFormatting(packet.pts,["i"])}}}else if(this.isNormalChar(char0)){if(char1===0){char1=null}text=getCharFromCode(char0);text+=getCharFromCode(char1);this[this.mode_](packet.pts,text);this.column_+=text.length}}};Cea608Stream.prototype=new stream;Cea608Stream.prototype.flushDisplayed=function(pts){var content=this.displayed_.map(function(row){try{return row.trim()}catch(e){console.error("Skipping malformed caption.");return""}}).join("\n").replace(/^\n+|\n+$/g,"");if(content.length){this.trigger("data",{startPts:this.startPts_,endPts:pts,text:content,stream:this.name_})}};Cea608Stream.prototype.reset=function(){this.mode_="popOn";this.topRow_=0;this.startPts_=0;this.displayed_=createDisplayBuffer();this.nonDisplayed_=createDisplayBuffer();this.lastControlCode_=null;this.column_=0;this.row_=BOTTOM_ROW;this.rollUpRows_=2;this.formatting_=[]};Cea608Stream.prototype.setConstants=function(){if(this.dataChannel_===0){this.BASE_=16;this.EXT_=17;this.CONTROL_=(20|this.field_)<<8;this.OFFSET_=23}else if(this.dataChannel_===1){this.BASE_=24;this.EXT_=25;this.CONTROL_=(28|this.field_)<<8;this.OFFSET_=31}this.PADDING_=0;this.RESUME_CAPTION_LOADING_=this.CONTROL_|32;this.END_OF_CAPTION_=this.CONTROL_|47;this.ROLL_UP_2_ROWS_=this.CONTROL_|37;this.ROLL_UP_3_ROWS_=this.CONTROL_|38;this.ROLL_UP_4_ROWS_=this.CONTROL_|39;this.CARRIAGE_RETURN_=this.CONTROL_|45;this.RESUME_DIRECT_CAPTIONING_=this.CONTROL_|41;this.BACKSPACE_=this.CONTROL_|33;this.ERASE_DISPLAYED_MEMORY_=this.CONTROL_|44;this.ERASE_NON_DISPLAYED_MEMORY_=this.CONTROL_|46};Cea608Stream.prototype.isSpecialCharacter=function(char0,char1){return char0===this.EXT_&&char1>=48&&char1<=63};Cea608Stream.prototype.isExtCharacter=function(char0,char1){return(char0===this.EXT_+1||char0===this.EXT_+2)&&char1>=32&&char1<=63};Cea608Stream.prototype.isMidRowCode=function(char0,char1){return char0===this.EXT_&&char1>=32&&char1<=47};Cea608Stream.prototype.isOffsetControlCode=function(char0,char1){return char0===this.OFFSET_&&char1>=33&&char1<=35};Cea608Stream.prototype.isPAC=function(char0,char1){return char0>=this.BASE_&&char0<this.BASE_+8&&char1>=64&&char1<=127};Cea608Stream.prototype.isColorPAC=function(char1){return char1>=64&&char1<=79||char1>=96&&char1<=127};Cea608Stream.prototype.isNormalChar=function(_char){return _char>=32&&_char<=127};Cea608Stream.prototype.setRollUp=function(pts,newBaseRow){if(this.mode_!=="rollUp"){this.row_=BOTTOM_ROW;this.mode_="rollUp";this.flushDisplayed(pts);this.nonDisplayed_=createDisplayBuffer();this.displayed_=createDisplayBuffer()}if(newBaseRow!==undefined&&newBaseRow!==this.row_){for(var i=0;i<this.rollUpRows_;i++){this.displayed_[newBaseRow-i]=this.displayed_[this.row_-i];this.displayed_[this.row_-i]=""}}if(newBaseRow===undefined){newBaseRow=this.row_}this.topRow_=newBaseRow-this.rollUpRows_+1};Cea608Stream.prototype.addFormatting=function(pts,format){this.formatting_=this.formatting_.concat(format);var text=format.reduce(function(text,format){return text+"<"+format+">"},"");this[this.mode_](pts,text)};Cea608Stream.prototype.clearFormatting=function(pts){if(!this.formatting_.length){return}var text=this.formatting_.reverse().reduce(function(text,format){return text+"</"+format+">"},"");this.formatting_=[];this[this.mode_](pts,text)};Cea608Stream.prototype.popOn=function(pts,text){var baseRow=this.nonDisplayed_[this.row_];baseRow+=text;this.nonDisplayed_[this.row_]=baseRow};Cea608Stream.prototype.rollUp=function(pts,text){var baseRow=this.displayed_[this.row_];baseRow+=text;this.displayed_[this.row_]=baseRow};Cea608Stream.prototype.shiftRowsUp_=function(){var i;for(i=0;i<this.topRow_;i++){this.displayed_[i]=""}for(i=this.row_+1;i<BOTTOM_ROW+1;i++){this.displayed_[i]=""}for(i=this.topRow_;i<this.row_;i++){this.displayed_[i]=this.displayed_[i+1]}this.displayed_[this.row_]=""};Cea608Stream.prototype.paintOn=function(pts,text){var baseRow=this.displayed_[this.row_];baseRow+=text;this.displayed_[this.row_]=baseRow};var captionStream={CaptionStream:CaptionStream,Cea608Stream:Cea608Stream};var discardEmulationPreventionBytes$1=captionPacketParser.discardEmulationPreventionBytes;var CaptionStream$1=captionStream.CaptionStream;var mapToSample=function mapToSample(offset,samples){var approximateOffset=offset;for(var i=0;i<samples.length;i++){var sample=samples[i];if(approximateOffset<sample.size){return sample}approximateOffset-=sample.size}return null};var findSeiNals=function findSeiNals(avcStream,samples,trackId){var avcView=new DataView(avcStream.buffer,avcStream.byteOffset,avcStream.byteLength),result=[],seiNal,i,length,lastMatchedSample;for(i=0;i+4<avcStream.length;i+=length){length=avcView.getUint32(i);i+=4;if(length<=0){continue}switch(avcStream[i]&31){case 6:var data=avcStream.subarray(i+1,i+1+length);var matchingSample=mapToSample(i,samples);seiNal={nalUnitType:"sei_rbsp",size:length,data:data,escapedRBSP:discardEmulationPreventionBytes$1(data),trackId:trackId};if(matchingSample){seiNal.pts=matchingSample.pts;seiNal.dts=matchingSample.dts;lastMatchedSample=matchingSample}else{seiNal.pts=lastMatchedSample.pts;seiNal.dts=lastMatchedSample.dts}result.push(seiNal);break;default:break}}return result};var parseSamples=function parseSamples(truns,baseMediaDecodeTime,tfhd){var currentDts=baseMediaDecodeTime;var defaultSampleDuration=tfhd.defaultSampleDuration||0;var defaultSampleSize=tfhd.defaultSampleSize||0;var trackId=tfhd.trackId;var allSamples=[];truns.forEach(function(trun){var trackRun=mp4Inspector.parseTrun(trun);var samples=trackRun.samples;samples.forEach(function(sample){if(sample.duration===undefined){sample.duration=defaultSampleDuration}if(sample.size===undefined){sample.size=defaultSampleSize}sample.trackId=trackId;sample.dts=currentDts;if(sample.compositionTimeOffset===undefined){sample.compositionTimeOffset=0}sample.pts=currentDts+sample.compositionTimeOffset;currentDts+=sample.duration});allSamples=allSamples.concat(samples)});return allSamples};var parseCaptionNals=function parseCaptionNals(segment,videoTrackId){var trafs=probe.findBox(segment,["moof","traf"]);var mdats=probe.findBox(segment,["mdat"]);var captionNals={};var mdatTrafPairs=[];mdats.forEach(function(mdat,index){var matchingTraf=trafs[index];mdatTrafPairs.push({mdat:mdat,traf:matchingTraf})});mdatTrafPairs.forEach(function(pair){var mdat=pair.mdat;var traf=pair.traf;var tfhd=probe.findBox(traf,["tfhd"]);var headerInfo=mp4Inspector.parseTfhd(tfhd[0]);var trackId=headerInfo.trackId;var tfdt=probe.findBox(traf,["tfdt"]);var baseMediaDecodeTime=tfdt.length>0?mp4Inspector.parseTfdt(tfdt[0]).baseMediaDecodeTime:0;var truns=probe.findBox(traf,["trun"]);var samples;var seiNals;if(videoTrackId===trackId&&truns.length>0){samples=parseSamples(truns,baseMediaDecodeTime,headerInfo);seiNals=findSeiNals(mdat,samples,trackId);if(!captionNals[trackId]){captionNals[trackId]=[]}captionNals[trackId]=captionNals[trackId].concat(seiNals)}});return captionNals};var parseEmbeddedCaptions=function parseEmbeddedCaptions(segment,trackId,timescale){var seiNals;if(trackId===null){return null}seiNals=parseCaptionNals(segment,trackId);return{seiNals:seiNals[trackId],timescale:timescale}};var CaptionParser=function CaptionParser(){var isInitialized=false;var captionStream;var segmentCache;var trackId;var timescale;var parsedCaptions;var parsingPartial;this.isInitialized=function(){return isInitialized};this.init=function(options){captionStream=new CaptionStream$1;isInitialized=true;parsingPartial=options?options.isPartial:false;captionStream.on("data",function(event){event.startTime=event.startPts/timescale;event.endTime=event.endPts/timescale;parsedCaptions.captions.push(event);parsedCaptions.captionStreams[event.stream]=true})};this.isNewInit=function(videoTrackIds,timescales){if(videoTrackIds&&videoTrackIds.length===0||timescales&&typeof timescales==="object"&&Object.keys(timescales).length===0){return false}return trackId!==videoTrackIds[0]||timescale!==timescales[trackId]};this.parse=function(segment,videoTrackIds,timescales){var parsedData;if(!this.isInitialized()){return null}else if(!videoTrackIds||!timescales){return null}else if(this.isNewInit(videoTrackIds,timescales)){trackId=videoTrackIds[0];timescale=timescales[trackId]}else if(trackId===null||!timescale){segmentCache.push(segment);return null}while(segmentCache.length>0){var cachedSegment=segmentCache.shift();this.parse(cachedSegment,videoTrackIds,timescales)}parsedData=parseEmbeddedCaptions(segment,trackId,timescale);if(parsedData===null||!parsedData.seiNals){return null}this.pushNals(parsedData.seiNals);this.flushStream();return parsedCaptions};this.pushNals=function(nals){if(!this.isInitialized()||!nals||nals.length===0){return null}nals.forEach(function(nal){captionStream.push(nal)})};this.flushStream=function(){if(!this.isInitialized()){return null}if(!parsingPartial){captionStream.flush()}else{captionStream.partialFlush()}};this.clearParsedCaptions=function(){parsedCaptions.captions=[];parsedCaptions.captionStreams={}};this.resetCaptionStream=function(){if(!this.isInitialized()){return null}captionStream.reset()};this.clearAllCaptions=function(){this.clearParsedCaptions();this.resetCaptionStream()};this.reset=function(){segmentCache=[];trackId=null;timescale=null;if(!parsedCaptions){parsedCaptions={captions:[],captionStreams:{}}}else{this.clearParsedCaptions()}this.resetCaptionStream()};this.reset()};var captionParser=CaptionParser;var streamTypes={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21};var MAX_TS=8589934592;var RO_THRESH=4294967296;var TYPE_SHARED="shared";var handleRollover=function handleRollover(value,reference){var direction=1;if(value>reference){direction=-1}while(Math.abs(reference-value)>RO_THRESH){value+=direction*MAX_TS}return value};var TimestampRolloverStream=function TimestampRolloverStream(type){var lastDTS,referenceDTS;TimestampRolloverStream.prototype.init.call(this);this.type_=type||TYPE_SHARED;this.push=function(data){if(this.type_!==TYPE_SHARED&&data.type!==this.type_){return}if(referenceDTS===undefined){referenceDTS=data.dts}data.dts=handleRollover(data.dts,referenceDTS);data.pts=handleRollover(data.pts,referenceDTS);lastDTS=data.dts;this.trigger("data",data)};this.flush=function(){referenceDTS=lastDTS;this.trigger("done")};this.endTimeline=function(){this.flush();this.trigger("endedtimeline")};this.discontinuity=function(){referenceDTS=void 0;lastDTS=void 0};this.reset=function(){this.discontinuity();this.trigger("reset")}};TimestampRolloverStream.prototype=new stream;var timestampRolloverStream={TimestampRolloverStream:TimestampRolloverStream,handleRollover:handleRollover};var parsePid=function parsePid(packet){var pid=packet[1]&31;pid<<=8;pid|=packet[2];return pid};var parsePayloadUnitStartIndicator=function parsePayloadUnitStartIndicator(packet){return!!(packet[1]&64)};var parseAdaptionField=function parseAdaptionField(packet){var offset=0;if((packet[3]&48)>>>4>1){offset+=packet[4]+1}return offset};var parseType$2=function parseType(packet,pmtPid){var pid=parsePid(packet);if(pid===0){return"pat"}else if(pid===pmtPid){return"pmt"}else if(pmtPid){return"pes"}return null};var parsePat=function parsePat(packet){var pusi=parsePayloadUnitStartIndicator(packet);var offset=4+parseAdaptionField(packet);if(pusi){offset+=packet[offset]+1}return(packet[offset+10]&31)<<8|packet[offset+11]};var parsePmt=function parsePmt(packet){var programMapTable={};var pusi=parsePayloadUnitStartIndicator(packet);var payloadOffset=4+parseAdaptionField(packet);if(pusi){payloadOffset+=packet[payloadOffset]+1}if(!(packet[payloadOffset+5]&1)){return}var sectionLength,tableEnd,programInfoLength;sectionLength=(packet[payloadOffset+1]&15)<<8|packet[payloadOffset+2];tableEnd=3+sectionLength-4;programInfoLength=(packet[payloadOffset+10]&15)<<8|packet[payloadOffset+11];var offset=12+programInfoLength;while(offset<tableEnd){var i=payloadOffset+offset;programMapTable[(packet[i+1]&31)<<8|packet[i+2]]=packet[i];offset+=((packet[i+3]&15)<<8|packet[i+4])+5}return programMapTable};var parsePesType=function parsePesType(packet,programMapTable){var pid=parsePid(packet);var type=programMapTable[pid];switch(type){case streamTypes.H264_STREAM_TYPE:return"video";case streamTypes.ADTS_STREAM_TYPE:return"audio";case streamTypes.METADATA_STREAM_TYPE:return"timed-metadata";default:return null}};var parsePesTime=function parsePesTime(packet){var pusi=parsePayloadUnitStartIndicator(packet);if(!pusi){return null}var offset=4+parseAdaptionField(packet);if(offset>=packet.byteLength){return null}var pes=null;var ptsDtsFlags;ptsDtsFlags=packet[offset+7];if(ptsDtsFlags&192){pes={};pes.pts=(packet[offset+9]&14)<<27|(packet[offset+10]&255)<<20|(packet[offset+11]&254)<<12|(packet[offset+12]&255)<<5|(packet[offset+13]&254)>>>3;pes.pts*=4;pes.pts+=(packet[offset+13]&6)>>>1;pes.dts=pes.pts;if(ptsDtsFlags&64){pes.dts=(packet[offset+14]&14)<<27|(packet[offset+15]&255)<<20|(packet[offset+16]&254)<<12|(packet[offset+17]&255)<<5|(packet[offset+18]&254)>>>3;pes.dts*=4;pes.dts+=(packet[offset+18]&6)>>>1}}return pes};var parseNalUnitType=function parseNalUnitType(type){switch(type){case 5:return"slice_layer_without_partitioning_rbsp_idr";case 6:return"sei_rbsp";case 7:return"seq_parameter_set_rbsp";case 8:return"pic_parameter_set_rbsp";case 9:return"access_unit_delimiter_rbsp";default:return null}};var videoPacketContainsKeyFrame=function videoPacketContainsKeyFrame(packet){var offset=4+parseAdaptionField(packet);var frameBuffer=packet.subarray(offset);var frameI=0;var frameSyncPoint=0;var foundKeyFrame=false;var nalType;for(;frameSyncPoint<frameBuffer.byteLength-3;frameSyncPoint++){if(frameBuffer[frameSyncPoint+2]===1){frameI=frameSyncPoint+5;break}}while(frameI<frameBuffer.byteLength){switch(frameBuffer[frameI]){case 0:if(frameBuffer[frameI-1]!==0){frameI+=2;break}else if(frameBuffer[frameI-2]!==0){frameI++;break}if(frameSyncPoint+3!==frameI-2){nalType=parseNalUnitType(frameBuffer[frameSyncPoint+3]&31);if(nalType==="slice_layer_without_partitioning_rbsp_idr"){foundKeyFrame=true}}do{frameI++}while(frameBuffer[frameI]!==1&&frameI<frameBuffer.length);frameSyncPoint=frameI-2;frameI+=3;break;case 1:if(frameBuffer[frameI-1]!==0||frameBuffer[frameI-2]!==0){frameI+=3;break}nalType=parseNalUnitType(frameBuffer[frameSyncPoint+3]&31);if(nalType==="slice_layer_without_partitioning_rbsp_idr"){foundKeyFrame=true}frameSyncPoint=frameI-2;frameI+=3;break;default:frameI+=3;break}}frameBuffer=frameBuffer.subarray(frameSyncPoint);frameI-=frameSyncPoint;frameSyncPoint=0;if(frameBuffer&&frameBuffer.byteLength>3){nalType=parseNalUnitType(frameBuffer[frameSyncPoint+3]&31);if(nalType==="slice_layer_without_partitioning_rbsp_idr"){foundKeyFrame=true}}return foundKeyFrame};var probe$1={parseType:parseType$2,parsePat:parsePat,parsePmt:parsePmt,parsePayloadUnitStartIndicator:parsePayloadUnitStartIndicator,parsePesType:parsePesType,parsePesTime:parsePesTime,videoPacketContainsKeyFrame:videoPacketContainsKeyFrame};var ADTS_SAMPLING_FREQUENCIES=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];var isLikelyAacData=function isLikelyAacData(data){if(data[0]==="I".charCodeAt(0)&&data[1]==="D".charCodeAt(0)&&data[2]==="3".charCodeAt(0)){return true}return false};var parseSyncSafeInteger=function parseSyncSafeInteger(data){return data[0]<<21|data[1]<<14|data[2]<<7|data[3]};var percentEncode=function percentEncode(bytes,start,end){var i,result="";for(i=start;i<end;i++){result+="%"+("00"+bytes[i].toString(16)).slice(-2)}return result};var parseIso88591=function parseIso88591(bytes,start,end){return unescape(percentEncode(bytes,start,end))};var parseId3TagSize=function parseId3TagSize(header,byteIndex){var returnSize=header[byteIndex+6]<<21|header[byteIndex+7]<<14|header[byteIndex+8]<<7|header[byteIndex+9],flags=header[byteIndex+5],footerPresent=(flags&16)>>4;if(footerPresent){return returnSize+20}return returnSize+10};var parseAdtsSize=function parseAdtsSize(header,byteIndex){var lowThree=(header[byteIndex+5]&224)>>5,middle=header[byteIndex+4]<<3,highTwo=header[byteIndex+3]&3<<11;return highTwo|middle|lowThree};var parseType$3=function parseType(header,byteIndex){if(header[byteIndex]==="I".charCodeAt(0)&&header[byteIndex+1]==="D".charCodeAt(0)&&header[byteIndex+2]==="3".charCodeAt(0)){return"timed-metadata"}else if(header[byteIndex]&255===255&&(header[byteIndex+1]&240)===240){return"audio"}return null};var parseSampleRate=function parseSampleRate(packet){var i=0;while(i+5<packet.length){if(packet[i]!==255||(packet[i+1]&246)!==240){i++;continue}return ADTS_SAMPLING_FREQUENCIES[(packet[i+2]&60)>>>2]}return null};var parseAacTimestamp=function parseAacTimestamp(packet){var frameStart,frameSize,frame,frameHeader;frameStart=10;if(packet[5]&64){frameStart+=4;frameStart+=parseSyncSafeInteger(packet.subarray(10,14))}do{frameSize=parseSyncSafeInteger(packet.subarray(frameStart+4,frameStart+8));if(frameSize<1){return null}frameHeader=String.fromCharCode(packet[frameStart],packet[frameStart+1],packet[frameStart+2],packet[frameStart+3]);if(frameHeader==="PRIV"){frame=packet.subarray(frameStart+10,frameStart+frameSize+10);for(var i=0;i<frame.byteLength;i++){if(frame[i]===0){var owner=parseIso88591(frame,0,i);if(owner==="com.apple.streaming.transportStreamTimestamp"){var d=frame.subarray(i+1);var size=(d[3]&1)<<30|d[4]<<22|d[5]<<14|d[6]<<6|d[7]>>>2;size*=4;size+=d[7]&3;return size}break}}}frameStart+=10;frameStart+=frameSize}while(frameStart<packet.byteLength);return null};var utils={isLikelyAacData:isLikelyAacData,parseId3TagSize:parseId3TagSize,parseAdtsSize:parseAdtsSize,parseType:parseType$3,parseSampleRate:parseSampleRate,parseAacTimestamp:parseAacTimestamp};var ONE_SECOND_IN_TS=9e4,secondsToVideoTs,secondsToAudioTs,videoTsToSeconds,audioTsToSeconds,audioTsToVideoTs,videoTsToAudioTs,metadataTsToSeconds;secondsToVideoTs=function secondsToVideoTs(seconds){return seconds*ONE_SECOND_IN_TS};secondsToAudioTs=function secondsToAudioTs(seconds,sampleRate){return seconds*sampleRate};videoTsToSeconds=function videoTsToSeconds(timestamp){return timestamp/ONE_SECOND_IN_TS};audioTsToSeconds=function audioTsToSeconds(timestamp,sampleRate){return timestamp/sampleRate};audioTsToVideoTs=function audioTsToVideoTs(timestamp,sampleRate){return secondsToVideoTs(audioTsToSeconds(timestamp,sampleRate))};videoTsToAudioTs=function videoTsToAudioTs(timestamp,sampleRate){return secondsToAudioTs(videoTsToSeconds(timestamp),sampleRate)};metadataTsToSeconds=function metadataTsToSeconds(timestamp,timelineStartPts,keepOriginalTimestamps){return videoTsToSeconds(keepOriginalTimestamps?timestamp:timestamp-timelineStartPts)};var clock={ONE_SECOND_IN_TS:ONE_SECOND_IN_TS,secondsToVideoTs:secondsToVideoTs,secondsToAudioTs:secondsToAudioTs,videoTsToSeconds:videoTsToSeconds,audioTsToSeconds:audioTsToSeconds,audioTsToVideoTs:audioTsToVideoTs,videoTsToAudioTs:videoTsToAudioTs,metadataTsToSeconds:metadataTsToSeconds};var handleRollover$1=timestampRolloverStream.handleRollover;var probe$2={};probe$2.ts=probe$1;probe$2.aac=utils;var ONE_SECOND_IN_TS$1=clock.ONE_SECOND_IN_TS;var MP2T_PACKET_LENGTH=188,SYNC_BYTE=71;var parsePsi_=function parsePsi_(bytes,pmt){var startIndex=0,endIndex=MP2T_PACKET_LENGTH,packet,type;while(endIndex<bytes.byteLength){if(bytes[startIndex]===SYNC_BYTE&&bytes[endIndex]===SYNC_BYTE){packet=bytes.subarray(startIndex,endIndex);type=probe$2.ts.parseType(packet,pmt.pid);switch(type){case"pat":if(!pmt.pid){pmt.pid=probe$2.ts.parsePat(packet)}break;case"pmt":if(!pmt.table){pmt.table=probe$2.ts.parsePmt(packet)}break;default:break}if(pmt.pid&&pmt.table){return}startIndex+=MP2T_PACKET_LENGTH;endIndex+=MP2T_PACKET_LENGTH;continue}startIndex++;endIndex++}};var parseAudioPes_=function parseAudioPes_(bytes,pmt,result){var startIndex=0,endIndex=MP2T_PACKET_LENGTH,packet,type,pesType,pusi,parsed;var endLoop=false;while(endIndex<=bytes.byteLength){if(bytes[startIndex]===SYNC_BYTE&&(bytes[endIndex]===SYNC_BYTE||endIndex===bytes.byteLength)){packet=bytes.subarray(startIndex,endIndex);type=probe$2.ts.parseType(packet,pmt.pid);switch(type){case"pes":pesType=probe$2.ts.parsePesType(packet,pmt.table);pusi=probe$2.ts.parsePayloadUnitStartIndicator(packet);if(pesType==="audio"&&pusi){parsed=probe$2.ts.parsePesTime(packet);if(parsed){parsed.type="audio";result.audio.push(parsed);endLoop=true}}break;default:break}if(endLoop){break}startIndex+=MP2T_PACKET_LENGTH;endIndex+=MP2T_PACKET_LENGTH;continue}startIndex++;endIndex++}endIndex=bytes.byteLength;startIndex=endIndex-MP2T_PACKET_LENGTH;endLoop=false;while(startIndex>=0){if(bytes[startIndex]===SYNC_BYTE&&(bytes[endIndex]===SYNC_BYTE||endIndex===bytes.byteLength)){packet=bytes.subarray(startIndex,endIndex);type=probe$2.ts.parseType(packet,pmt.pid);switch(type){case"pes":pesType=probe$2.ts.parsePesType(packet,pmt.table);pusi=probe$2.ts.parsePayloadUnitStartIndicator(packet);if(pesType==="audio"&&pusi){parsed=probe$2.ts.parsePesTime(packet);if(parsed){parsed.type="audio";result.audio.push(parsed);endLoop=true}}break;default:break}if(endLoop){break}startIndex-=MP2T_PACKET_LENGTH;endIndex-=MP2T_PACKET_LENGTH;continue}startIndex--;endIndex--}};var parseVideoPes_=function parseVideoPes_(bytes,pmt,result){var startIndex=0,endIndex=MP2T_PACKET_LENGTH,packet,type,pesType,pusi,parsed,frame,i,pes;var endLoop=false;var currentFrame={data:[],size:0};while(endIndex<bytes.byteLength){if(bytes[startIndex]===SYNC_BYTE&&bytes[endIndex]===SYNC_BYTE){packet=bytes.subarray(startIndex,endIndex);type=probe$2.ts.parseType(packet,pmt.pid);switch(type){case"pes":pesType=probe$2.ts.parsePesType(packet,pmt.table);pusi=probe$2.ts.parsePayloadUnitStartIndicator(packet);if(pesType==="video"){if(pusi&&!endLoop){parsed=probe$2.ts.parsePesTime(packet);if(parsed){parsed.type="video";result.video.push(parsed);endLoop=true}}if(!result.firstKeyFrame){if(pusi){if(currentFrame.size!==0){frame=new Uint8Array(currentFrame.size);i=0;while(currentFrame.data.length){pes=currentFrame.data.shift();frame.set(pes,i);i+=pes.byteLength}if(probe$2.ts.videoPacketContainsKeyFrame(frame)){var firstKeyFrame=probe$2.ts.parsePesTime(frame);if(firstKeyFrame){result.firstKeyFrame=firstKeyFrame;result.firstKeyFrame.type="video"}else{console.warn("Failed to extract PTS/DTS from PES at first keyframe. "+"This could be an unusual TS segment, or else mux.js did not "+"parse your TS segment correctly. If you know your TS "+"segments do contain PTS/DTS on keyframes please file a bug "+"report! You can try ffprobe to double check for yourself.")}}currentFrame.size=0}}currentFrame.data.push(packet);currentFrame.size+=packet.byteLength}}break;default:break}if(endLoop&&result.firstKeyFrame){break}startIndex+=MP2T_PACKET_LENGTH;endIndex+=MP2T_PACKET_LENGTH;continue}startIndex++;endIndex++}endIndex=bytes.byteLength;startIndex=endIndex-MP2T_PACKET_LENGTH;endLoop=false;while(startIndex>=0){if(bytes[startIndex]===SYNC_BYTE&&bytes[endIndex]===SYNC_BYTE){packet=bytes.subarray(startIndex,endIndex);type=probe$2.ts.parseType(packet,pmt.pid);switch(type){case"pes":pesType=probe$2.ts.parsePesType(packet,pmt.table);pusi=probe$2.ts.parsePayloadUnitStartIndicator(packet);if(pesType==="video"&&pusi){parsed=probe$2.ts.parsePesTime(packet);if(parsed){parsed.type="video";result.video.push(parsed);endLoop=true}}break;default:break}if(endLoop){break}startIndex-=MP2T_PACKET_LENGTH;endIndex-=MP2T_PACKET_LENGTH;continue}startIndex--;endIndex--}};var adjustTimestamp_=function adjustTimestamp_(segmentInfo,baseTimestamp){if(segmentInfo.audio&&segmentInfo.audio.length){var audioBaseTimestamp=baseTimestamp;if(typeof audioBaseTimestamp==="undefined"){audioBaseTimestamp=segmentInfo.audio[0].dts}segmentInfo.audio.forEach(function(info){info.dts=handleRollover$1(info.dts,audioBaseTimestamp);info.pts=handleRollover$1(info.pts,audioBaseTimestamp);info.dtsTime=info.dts/ONE_SECOND_IN_TS$1;info.ptsTime=info.pts/ONE_SECOND_IN_TS$1})}if(segmentInfo.video&&segmentInfo.video.length){var videoBaseTimestamp=baseTimestamp;if(typeof videoBaseTimestamp==="undefined"){videoBaseTimestamp=segmentInfo.video[0].dts}segmentInfo.video.forEach(function(info){info.dts=handleRollover$1(info.dts,videoBaseTimestamp);info.pts=handleRollover$1(info.pts,videoBaseTimestamp);info.dtsTime=info.dts/ONE_SECOND_IN_TS$1;info.ptsTime=info.pts/ONE_SECOND_IN_TS$1});if(segmentInfo.firstKeyFrame){var frame=segmentInfo.firstKeyFrame;frame.dts=handleRollover$1(frame.dts,videoBaseTimestamp);frame.pts=handleRollover$1(frame.pts,videoBaseTimestamp);frame.dtsTime=frame.dts/ONE_SECOND_IN_TS$1;frame.ptsTime=frame.dts/ONE_SECOND_IN_TS$1}}};var inspectAac_=function inspectAac_(bytes){var endLoop=false,audioCount=0,sampleRate=null,timestamp=null,frameSize=0,byteIndex=0,packet;while(bytes.length-byteIndex>=3){var type=probe$2.aac.parseType(bytes,byteIndex);switch(type){case"timed-metadata":if(bytes.length-byteIndex<10){endLoop=true;break}frameSize=probe$2.aac.parseId3TagSize(bytes,byteIndex);if(frameSize>bytes.length){endLoop=true;break}if(timestamp===null){packet=bytes.subarray(byteIndex,byteIndex+frameSize);timestamp=probe$2.aac.parseAacTimestamp(packet)}byteIndex+=frameSize;break;case"audio":if(bytes.length-byteIndex<7){endLoop=true;break}frameSize=probe$2.aac.parseAdtsSize(bytes,byteIndex);if(frameSize>bytes.length){endLoop=true;break}if(sampleRate===null){packet=bytes.subarray(byteIndex,byteIndex+frameSize);sampleRate=probe$2.aac.parseSampleRate(packet)}audioCount++;byteIndex+=frameSize;break;default:byteIndex++;break}if(endLoop){return null}}if(sampleRate===null||timestamp===null){return null}var audioTimescale=ONE_SECOND_IN_TS$1/sampleRate;var result={audio:[{type:"audio",dts:timestamp,pts:timestamp},{type:"audio",dts:timestamp+audioCount*1024*audioTimescale,pts:timestamp+audioCount*1024*audioTimescale}]};return result};var inspectTs_=function inspectTs_(bytes){var pmt={pid:null,table:null};var result={};parsePsi_(bytes,pmt);for(var pid in pmt.table){if(pmt.table.hasOwnProperty(pid)){var type=pmt.table[pid];switch(type){case streamTypes.H264_STREAM_TYPE:result.video=[];parseVideoPes_(bytes,pmt,result);if(result.video.length===0){delete result.video}break;case streamTypes.ADTS_STREAM_TYPE:result.audio=[];parseAudioPes_(bytes,pmt,result);if(result.audio.length===0){delete result.audio}break;default:break}}}return result};var inspect=function inspect(bytes,baseTimestamp){var isAacData=probe$2.aac.isLikelyAacData(bytes);var result;if(isAacData){result=inspectAac_(bytes)}else{result=inspectTs_(bytes)}if(!result||!result.audio&&!result.video){return null}adjustTimestamp_(result,baseTimestamp);return result};var tsInspector={inspect:inspect,parseAudioPes_:parseAudioPes_};function unpad(padded){return padded.subarray(0,padded.byteLength-padded[padded.byteLength-1])}var classCallCheck=function classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}};var createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();var inherits=function inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass};var possibleConstructorReturn=function possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self};var precompute=function precompute(){var tables=[[[],[],[],[],[]],[[],[],[],[],[]]];var encTable=tables[0];var decTable=tables[1];var sbox=encTable[4];var sboxInv=decTable[4];var i=void 0;var x=void 0;var xInv=void 0;var d=[];var th=[];var x2=void 0;var x4=void 0;var x8=void 0;var s=void 0;var tEnc=void 0;var tDec=void 0;for(i=0;i<256;i++){th[(d[i]=i<<1^(i>>7)*283)^i]=i}for(x=xInv=0;!sbox[x];x^=x2||1,xInv=th[xInv]||1){s=xInv^xInv<<1^xInv<<2^xInv<<3^xInv<<4;s=s>>8^s&255^99;sbox[x]=s;sboxInv[s]=x;x8=d[x4=d[x2=d[x]]];tDec=x8*16843009^x4*65537^x2*257^x*16843008;tEnc=d[s]*257^s*16843008;for(i=0;i<4;i++){encTable[i][x]=tEnc=tEnc<<24^tEnc>>>8;decTable[i][s]=tDec=tDec<<24^tDec>>>8}}for(i=0;i<5;i++){encTable[i]=encTable[i].slice(0);decTable[i]=decTable[i].slice(0)}return tables};var aesTables=null;var AES=function(){function AES(key){classCallCheck(this,AES);if(!aesTables){aesTables=precompute()}this._tables=[[aesTables[0][0].slice(),aesTables[0][1].slice(),aesTables[0][2].slice(),aesTables[0][3].slice(),aesTables[0][4].slice()],[aesTables[1][0].slice(),aesTables[1][1].slice(),aesTables[1][2].slice(),aesTables[1][3].slice(),aesTables[1][4].slice()]];var i=void 0;var j=void 0;var tmp=void 0;var encKey=void 0;var decKey=void 0;var sbox=this._tables[0][4];var decTable=this._tables[1];var keyLen=key.length;var rcon=1;if(keyLen!==4&&keyLen!==6&&keyLen!==8){throw new Error("Invalid aes key size")}encKey=key.slice(0);decKey=[];this._key=[encKey,decKey];for(i=keyLen;i<4*keyLen+28;i++){tmp=encKey[i-1];if(i%keyLen===0||keyLen===8&&i%keyLen===4){tmp=sbox[tmp>>>24]<<24^sbox[tmp>>16&255]<<16^sbox[tmp>>8&255]<<8^sbox[tmp&255];if(i%keyLen===0){tmp=tmp<<8^tmp>>>24^rcon<<24;rcon=rcon<<1^(rcon>>7)*283}}encKey[i]=encKey[i-keyLen]^tmp}for(j=0;i;j++,i--){tmp=encKey[j&3?i:i-4];if(i<=4||j<4){decKey[j]=tmp}else{decKey[j]=decTable[0][sbox[tmp>>>24]]^decTable[1][sbox[tmp>>16&255]]^decTable[2][sbox[tmp>>8&255]]^decTable[3][sbox[tmp&255]]}}}AES.prototype.decrypt=function decrypt(encrypted0,encrypted1,encrypted2,encrypted3,out,offset){var key=this._key[1];var a=encrypted0^key[0];var b=encrypted3^key[1];var c=encrypted2^key[2];var d=encrypted1^key[3];var a2=void 0;var b2=void 0;var c2=void 0;var nInnerRounds=key.length/4-2;var i=void 0;var kIndex=4;var table=this._tables[1];var table0=table[0];var table1=table[1];var table2=table[2];var table3=table[3];var sbox=table[4];for(i=0;i<nInnerRounds;i++){a2=table0[a>>>24]^table1[b>>16&255]^table2[c>>8&255]^table3[d&255]^key[kIndex];b2=table0[b>>>24]^table1[c>>16&255]^table2[d>>8&255]^table3[a&255]^key[kIndex+1];c2=table0[c>>>24]^table1[d>>16&255]^table2[a>>8&255]^table3[b&255]^key[kIndex+2];d=table0[d>>>24]^table1[a>>16&255]^table2[b>>8&255]^table3[c&255]^key[kIndex+3];kIndex+=4;a=a2;b=b2;c=c2}for(i=0;i<4;i++){out[(3&-i)+offset]=sbox[a>>>24]<<24^sbox[b>>16&255]<<16^sbox[c>>8&255]<<8^sbox[d&255]^key[kIndex++];a2=a;a=b;b=c;c=d;d=a2}};return AES}();var Stream$2=function(){function Stream(){classCallCheck(this,Stream);this.listeners={}}Stream.prototype.on=function on(type,listener){if(!this.listeners[type]){this.listeners[type]=[]}this.listeners[type].push(listener)};Stream.prototype.off=function off(type,listener){if(!this.listeners[type]){return false}var index=this.listeners[type].indexOf(listener);this.listeners[type].splice(index,1);return index>-1};Stream.prototype.trigger=function trigger(type){var callbacks=this.listeners[type];if(!callbacks){return}if(arguments.length===2){var length=callbacks.length;for(var i=0;i<length;++i){callbacks[i].call(this,arguments[1])}}else{var args=Array.prototype.slice.call(arguments,1);var _length=callbacks.length;for(var _i=0;_i<_length;++_i){callbacks[_i].apply(this,args)}}};Stream.prototype.dispose=function dispose(){this.listeners={}};Stream.prototype.pipe=function pipe(destination){this.on("data",function(data){destination.push(data)})};return Stream}();var AsyncStream=function(_Stream){inherits(AsyncStream,_Stream);function AsyncStream(){classCallCheck(this,AsyncStream);var _this=possibleConstructorReturn(this,_Stream.call(this,Stream$2));_this.jobs=[];_this.delay=1;_this.timeout_=null;return _this}AsyncStream.prototype.processJob_=function processJob_(){this.jobs.shift()();if(this.jobs.length){this.timeout_=setTimeout(this.processJob_.bind(this),this.delay)}else{this.timeout_=null}};AsyncStream.prototype.push=function push(job){this.jobs.push(job);if(!this.timeout_){this.timeout_=setTimeout(this.processJob_.bind(this),this.delay)}};return AsyncStream}(Stream$2);var ntoh=function ntoh(word){return word<<24|(word&65280)<<8|(word&16711680)>>8|word>>>24};var decrypt=function decrypt(encrypted,key,initVector){var encrypted32=new Int32Array(encrypted.buffer,encrypted.byteOffset,encrypted.byteLength>>2);var decipher=new AES(Array.prototype.slice.call(key));var decrypted=new Uint8Array(encrypted.byteLength);var decrypted32=new Int32Array(decrypted.buffer);var init0=void 0;var init1=void 0;var init2=void 0;var init3=void 0;var encrypted0=void 0;var encrypted1=void 0;var encrypted2=void 0;var encrypted3=void 0;var wordIx=void 0;init0=initVector[0];init1=initVector[1];init2=initVector[2];init3=initVector[3];for(wordIx=0;wordIx<encrypted32.length;wordIx+=4){encrypted0=ntoh(encrypted32[wordIx]);encrypted1=ntoh(encrypted32[wordIx+1]);encrypted2=ntoh(encrypted32[wordIx+2]);encrypted3=ntoh(encrypted32[wordIx+3]);decipher.decrypt(encrypted0,encrypted1,encrypted2,encrypted3,decrypted32,wordIx);decrypted32[wordIx]=ntoh(decrypted32[wordIx]^init0);decrypted32[wordIx+1]=ntoh(decrypted32[wordIx+1]^init1);decrypted32[wordIx+2]=ntoh(decrypted32[wordIx+2]^init2);decrypted32[wordIx+3]=ntoh(decrypted32[wordIx+3]^init3);init0=encrypted0;init1=encrypted1;init2=encrypted2;init3=encrypted3}return decrypted};var Decrypter=function(){function Decrypter(encrypted,key,initVector,done){classCallCheck(this,Decrypter);var step=Decrypter.STEP;var encrypted32=new Int32Array(encrypted.buffer);var decrypted=new Uint8Array(encrypted.byteLength);var i=0;this.asyncStream_=new AsyncStream;this.asyncStream_.push(this.decryptChunk_(encrypted32.subarray(i,i+step),key,initVector,decrypted));for(i=step;i<encrypted32.length;i+=step){initVector=new Uint32Array([ntoh(encrypted32[i-4]),ntoh(encrypted32[i-3]),ntoh(encrypted32[i-2]),ntoh(encrypted32[i-1])]);this.asyncStream_.push(this.decryptChunk_(encrypted32.subarray(i,i+step),key,initVector,decrypted))}this.asyncStream_.push(function(){done(null,unpad(decrypted))})}Decrypter.prototype.decryptChunk_=function decryptChunk_(encrypted,key,initVector,decrypted){return function(){var bytes=decrypt(encrypted,key,initVector);decrypted.set(bytes,encrypted.byteOffset)}};createClass(Decrypter,null,[{key:"STEP",get:function get$$1(){return 32e3}}]);return Decrypter}();var resolveUrl$1=function resolveUrl(baseURL,relativeURL){if(/^[a-z]+:/i.test(relativeURL)){return relativeURL}if(!/\/\//i.test(baseURL)){baseURL=urlToolkit.buildAbsoluteURL(window$1.location.href,baseURL)}return urlToolkit.buildAbsoluteURL(baseURL,relativeURL)};var resolveManifestRedirect=function resolveManifestRedirect(handleManifestRedirect,url,req){if(handleManifestRedirect&&req.responseURL&&url!==req.responseURL){return req.responseURL}return url};var classCallCheck$1=function classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}};var createClass$1=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();var get$1=function get(object,property,receiver){if(object===null)object=Function.prototype;var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent===null){return undefined}else{return get(parent,property,receiver)}}else if("value"in desc){return desc.value}else{var getter=desc.get;if(getter===undefined){return undefined}return getter.call(receiver)}};var inherits$1=function inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass};var possibleConstructorReturn$1=function possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self};var slicedToArray=function(){function sliceIterator(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"])_i["return"]()}finally{if(_d)throw _e}}return _arr}return function(arr,i){if(Array.isArray(arr)){return arr}else if(Symbol.iterator in Object(arr)){return sliceIterator(arr,i)}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}}}();var mergeOptions$1=videojs$1.mergeOptions,EventTarget$1=videojs$1.EventTarget,log$1=videojs$1.log;var forEachMediaGroup=function forEachMediaGroup(master,callback){["AUDIO","SUBTITLES"].forEach(function(mediaType){for(var groupKey in master.mediaGroups[mediaType]){for(var labelKey in master.mediaGroups[mediaType][groupKey]){var mediaProperties=master.mediaGroups[mediaType][groupKey][labelKey];callback(mediaProperties,mediaType,groupKey,labelKey)}}})};var updateSegments=function updateSegments(original,update,offset){var result=update.slice();offset=offset||0;var length=Math.min(original.length,update.length+offset);for(var i=offset;i<length;i++){result[i-offset]=mergeOptions$1(original[i],result[i-offset])}return result};var resolveSegmentUris=function resolveSegmentUris(segment,baseUri){if(!segment.resolvedUri){segment.resolvedUri=resolveUrl$1(baseUri,segment.uri)}if(segment.key&&!segment.key.resolvedUri){segment.key.resolvedUri=resolveUrl$1(baseUri,segment.key.uri)}if(segment.map&&!segment.map.resolvedUri){segment.map.resolvedUri=resolveUrl$1(baseUri,segment.map.uri)}};var updateMaster=function updateMaster(master,media){var result=mergeOptions$1(master,{});var playlist=result.playlists[media.uri];if(!playlist){return null}if(playlist.segments&&media.segments&&playlist.segments.length===media.segments.length&&playlist.endList===media.endList&&playlist.mediaSequence===media.mediaSequence){return null}var mergedPlaylist=mergeOptions$1(playlist,media);if(playlist.segments){mergedPlaylist.segments=updateSegments(playlist.segments,media.segments,media.mediaSequence-playlist.mediaSequence)}mergedPlaylist.segments.forEach(function(segment){resolveSegmentUris(segment,mergedPlaylist.resolvedUri)});for(var i=0;i<result.playlists.length;i++){if(result.playlists[i].uri===media.uri){result.playlists[i]=mergedPlaylist}}result.playlists[media.uri]=mergedPlaylist;return result};var setupMediaPlaylists=function setupMediaPlaylists(master){var i=master.playlists.length;while(i--){var playlist=master.playlists[i];master.playlists[playlist.uri]=playlist;playlist.resolvedUri=resolveUrl$1(master.uri,playlist.uri);playlist.id=i;if(!playlist.attributes){playlist.attributes={};log$1.warn("Invalid playlist STREAM-INF detected. Missing BANDWIDTH attribute.")}}};var resolveMediaGroupUris=function resolveMediaGroupUris(master){forEachMediaGroup(master,function(properties){if(properties.uri){properties.resolvedUri=resolveUrl$1(master.uri,properties.uri)}})};var refreshDelay=function refreshDelay(media,update){var lastSegment=media.segments[media.segments.length-1];var delay=void 0;if(update&&lastSegment&&lastSegment.duration){delay=lastSegment.duration*1e3}else{delay=(media.targetDuration||10)*500}return delay};var PlaylistLoader=function(_EventTarget){inherits$1(PlaylistLoader,_EventTarget);function PlaylistLoader(srcUrl,hls){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};classCallCheck$1(this,PlaylistLoader);var _this=possibleConstructorReturn$1(this,(PlaylistLoader.__proto__||Object.getPrototypeOf(PlaylistLoader)).call(this));var _options$withCredenti=options.withCredentials,withCredentials=_options$withCredenti===undefined?false:_options$withCredenti,_options$handleManife=options.handleManifestRedirects,handleManifestRedirects=_options$handleManife===undefined?false:_options$handleManife;_this.srcUrl=srcUrl;_this.hls_=hls;_this.withCredentials=withCredentials;_this.handleManifestRedirects=handleManifestRedirects;var hlsOptions=hls.options_;_this.customTagParsers=hlsOptions&&hlsOptions.customTagParsers||[];_this.customTagMappers=hlsOptions&&hlsOptions.customTagMappers||[];if(!_this.srcUrl){throw new Error("A non-empty playlist URL is required")}_this.state="HAVE_NOTHING";_this.on("mediaupdatetimeout",function(){if(_this.state!=="HAVE_METADATA"){return}_this.state="HAVE_CURRENT_METADATA";_this.request=_this.hls_.xhr({uri:resolveUrl$1(_this.master.uri,_this.media().uri),withCredentials:_this.withCredentials},function(error,req){if(!_this.request){return}if(error){return _this.playlistRequestError(_this.request,_this.media().uri,"HAVE_METADATA")}_this.haveMetadata(_this.request,_this.media().uri)})});return _this}createClass$1(PlaylistLoader,[{key:"playlistRequestError",value:function playlistRequestError(xhr,url,startingState){this.request=null;if(startingState){this.state=startingState}this.error={playlist:this.master.playlists[url],status:xhr.status,message:"HLS playlist request error at URL: "+url+".",responseText:xhr.responseText,code:xhr.status>=500?4:2};this.trigger("error")}},{key:"haveMetadata",value:function haveMetadata(xhr,url){var _this2=this;this.request=null;this.state="HAVE_METADATA";var parser=new Parser;this.customTagParsers.forEach(function(customParser){return parser.addParser(customParser)});this.customTagMappers.forEach(function(mapper){return parser.addTagMapper(mapper)});parser.push(xhr.responseText);parser.end();parser.manifest.uri=url;parser.manifest.attributes=parser.manifest.attributes||{};var update=updateMaster(this.master,parser.manifest);this.targetDuration=parser.manifest.targetDuration;if(update){this.master=update;this.media_=this.master.playlists[parser.manifest.uri]}else{this.trigger("playlistunchanged")}if(!this.media().endList){window$1.clearTimeout(this.mediaUpdateTimeout);this.mediaUpdateTimeout=window$1.setTimeout(function(){_this2.trigger("mediaupdatetimeout")},refreshDelay(this.media(),!!update))}this.trigger("loadedplaylist")}},{key:"dispose",value:function dispose(){this.stopRequest();window$1.clearTimeout(this.mediaUpdateTimeout);window$1.clearTimeout(this.finalRenditionTimeout)}},{key:"stopRequest",value:function stopRequest(){if(this.request){var oldRequest=this.request;this.request=null;oldRequest.onreadystatechange=null;oldRequest.abort()}}},{key:"media",value:function media(playlist,isFinalRendition){var _this3=this;if(!playlist){return this.media_}if(this.state==="HAVE_NOTHING"){throw new Error("Cannot switch media playlist from "+this.state)}if(typeof playlist==="string"){if(!this.master.playlists[playlist]){throw new Error("Unknown playlist URI: "+playlist)}playlist=this.master.playlists[playlist]}window$1.clearTimeout(this.finalRenditionTimeout);if(isFinalRendition){var delay=playlist.targetDuration/2*1e3||5*1e3;this.finalRenditionTimeout=window$1.setTimeout(this.media.bind(this,playlist,false),delay);return}var startingState=this.state;var mediaChange=!this.media_||playlist.uri!==this.media_.uri;if(this.master.playlists[playlist.uri].endList){if(this.request){this.request.onreadystatechange=null;this.request.abort();this.request=null}this.state="HAVE_METADATA";this.media_=playlist;if(mediaChange){this.trigger("mediachanging");this.trigger("mediachange")}return}if(!mediaChange){return}this.state="SWITCHING_MEDIA";if(this.request){if(playlist.resolvedUri===this.request.url){return}this.request.onreadystatechange=null;this.request.abort();this.request=null}if(this.media_){this.trigger("mediachanging")}this.request=this.hls_.xhr({uri:playlist.resolvedUri,withCredentials:this.withCredentials},function(error,req){if(!_this3.request){return}playlist.resolvedUri=resolveManifestRedirect(_this3.handleManifestRedirects,playlist.resolvedUri,req);if(error){return _this3.playlistRequestError(_this3.request,playlist.uri,startingState)}_this3.haveMetadata(req,playlist.uri);if(startingState==="HAVE_MASTER"){_this3.trigger("loadedmetadata")}else{_this3.trigger("mediachange")}})}},{key:"pause",value:function pause(){this.stopRequest();window$1.clearTimeout(this.mediaUpdateTimeout);if(this.state==="HAVE_NOTHING"){this.started=false}if(this.state==="SWITCHING_MEDIA"){if(this.media_){this.state="HAVE_METADATA"}else{this.state="HAVE_MASTER"}}else if(this.state==="HAVE_CURRENT_METADATA"){this.state="HAVE_METADATA"}}},{key:"load",value:function load(isFinalRendition){var _this4=this;window$1.clearTimeout(this.mediaUpdateTimeout);var media=this.media();if(isFinalRendition){var delay=media?media.targetDuration/2*1e3:5*1e3;this.mediaUpdateTimeout=window$1.setTimeout(function(){return _this4.load()},delay);return}if(!this.started){this.start();return}if(media&&!media.endList){this.trigger("mediaupdatetimeout")}else{this.trigger("loadedplaylist")}}},{key:"start",value:function start(){var _this5=this;this.started=true;this.request=this.hls_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},function(error,req){if(!_this5.request){return}_this5.request=null;if(error){_this5.error={status:req.status,message:"HLS playlist request error at URL: "+_this5.srcUrl+".",responseText:req.responseText,code:2};if(_this5.state==="HAVE_NOTHING"){_this5.started=false}return _this5.trigger("error")}var parser=new Parser;_this5.customTagParsers.forEach(function(customParser){return parser.addParser(customParser)});_this5.customTagMappers.forEach(function(mapper){return parser.addTagMapper(mapper)});parser.push(req.responseText);parser.end();_this5.state="HAVE_MASTER";_this5.srcUrl=resolveManifestRedirect(_this5.handleManifestRedirects,_this5.srcUrl,req);parser.manifest.uri=_this5.srcUrl;if(parser.manifest.playlists){_this5.master=parser.manifest;setupMediaPlaylists(_this5.master);resolveMediaGroupUris(_this5.master);_this5.trigger("loadedplaylist");if(!_this5.request){_this5.media(parser.manifest.playlists[0])}return}_this5.master={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:window$1.location.href,playlists:[{uri:_this5.srcUrl,id:0,resolvedUri:_this5.srcUrl,attributes:{}}]};_this5.master.playlists[_this5.srcUrl]=_this5.master.playlists[0];_this5.haveMetadata(req,_this5.srcUrl);return _this5.trigger("loadedmetadata")})}}]);return PlaylistLoader}(EventTarget$1);var createTimeRange=videojs$1.createTimeRange;var backwardDuration=function backwardDuration(playlist,endSequence){var result=0;var i=endSequence-playlist.mediaSequence;var segment=playlist.segments[i];if(segment){if(typeof segment.start!=="undefined"){return{result:segment.start,precise:true}}if(typeof segment.end!=="undefined"){return{result:segment.end-segment.duration,precise:true}}}while(i--){segment=playlist.segments[i];if(typeof segment.end!=="undefined"){return{result:result+segment.end,precise:true}}result+=segment.duration;if(typeof segment.start!=="undefined"){return{result:result+segment.start,precise:true}}}return{result:result,precise:false}};var forwardDuration=function forwardDuration(playlist,endSequence){var result=0;var segment=void 0;var i=endSequence-playlist.mediaSequence;for(;i<playlist.segments.length;i++){segment=playlist.segments[i];if(typeof segment.start!=="undefined"){return{result:segment.start-result,precise:true}}result+=segment.duration;if(typeof segment.end!=="undefined"){return{result:segment.end-result,precise:true}}}return{result:-1,precise:false}};var intervalDuration=function intervalDuration(playlist,endSequence,expired){var backward=void 0;var forward=void 0;if(typeof endSequence==="undefined"){endSequence=playlist.mediaSequence+playlist.segments.length}if(endSequence<playlist.mediaSequence){return 0}backward=backwardDuration(playlist,endSequence);if(backward.precise){return backward.result}forward=forwardDuration(playlist,endSequence);if(forward.precise){return forward.result}return backward.result+expired};var duration=function duration(playlist,endSequence,expired){if(!playlist){return 0}if(typeof expired!=="number"){expired=0}if(typeof endSequence==="undefined"){if(playlist.totalDuration){return playlist.totalDuration}if(!playlist.endList){return window$1.Infinity}}return intervalDuration(playlist,endSequence,expired)};var sumDurations=function sumDurations(playlist,startIndex,endIndex){var durations=0;if(startIndex>endIndex){var _ref=[endIndex,startIndex];startIndex=_ref[0];endIndex=_ref[1]}if(startIndex<0){for(var i=startIndex;i<Math.min(0,endIndex);i++){durations+=playlist.targetDuration}startIndex=0}for(var _i=startIndex;_i<endIndex;_i++){durations+=playlist.segments[_i].duration}return durations};var safeLiveIndex=function safeLiveIndex(playlist){if(!playlist.segments.length){return 0}var i=playlist.segments.length-1;var distanceFromEnd=playlist.segments[i].duration||playlist.targetDuration;var safeDistance=distanceFromEnd+playlist.targetDuration*2;while(i--){distanceFromEnd+=playlist.segments[i].duration;if(distanceFromEnd>=safeDistance){break}}return Math.max(0,i)};var playlistEnd=function playlistEnd(playlist,expired,useSafeLiveEnd){if(!playlist||!playlist.segments){return null}if(playlist.endList){return duration(playlist)}if(expired===null){return null}expired=expired||0;var endSequence=useSafeLiveEnd?safeLiveIndex(playlist):playlist.segments.length;return intervalDuration(playlist,playlist.mediaSequence+endSequence,expired)};var seekable=function seekable(playlist,expired){var useSafeLiveEnd=true;var seekableStart=expired||0;var seekableEnd=playlistEnd(playlist,expired,useSafeLiveEnd);if(seekableEnd===null){return createTimeRange()}return createTimeRange(seekableStart,seekableEnd)};var isWholeNumber=function isWholeNumber(num){return num-Math.floor(num)===0};var roundSignificantDigit=function roundSignificantDigit(increment,num){if(isWholeNumber(num)){return num+increment*.1}var numDecimalDigits=num.toString().split(".")[1].length;for(var i=1;i<=numDecimalDigits;i++){var scale=Math.pow(10,i);var temp=num*scale;if(isWholeNumber(temp)||i===numDecimalDigits){return(temp+increment)/scale}}};var ceilLeastSignificantDigit=roundSignificantDigit.bind(null,1);var floorLeastSignificantDigit=roundSignificantDigit.bind(null,-1);var getMediaInfoForTime=function getMediaInfoForTime(playlist,currentTime,startIndex,startTime){var i=void 0;var segment=void 0;var numSegments=playlist.segments.length;var time=currentTime-startTime;if(time<0){if(startIndex>0){for(i=startIndex-1;i>=0;i--){segment=playlist.segments[i];time+=floorLeastSignificantDigit(segment.duration);if(time>0){return{mediaIndex:i,startTime:startTime-sumDurations(playlist,startIndex,i)}}}}return{mediaIndex:0,startTime:currentTime}}if(startIndex<0){for(i=startIndex;i<0;i++){time-=playlist.targetDuration;if(time<0){return{mediaIndex:0,startTime:currentTime}}}startIndex=0}for(i=startIndex;i<numSegments;i++){segment=playlist.segments[i];time-=ceilLeastSignificantDigit(segment.duration);if(time<0){return{mediaIndex:i,startTime:startTime+sumDurations(playlist,startIndex,i)}}}return{mediaIndex:numSegments-1,startTime:currentTime}};var isBlacklisted=function isBlacklisted(playlist){return playlist.excludeUntil&&playlist.excludeUntil>Date.now()};var isIncompatible=function isIncompatible(playlist){return playlist.excludeUntil&&playlist.excludeUntil===Infinity};var isEnabled=function isEnabled(playlist){var blacklisted=isBlacklisted(playlist);return!playlist.disabled&&!blacklisted};var isDisabled=function isDisabled(playlist){return playlist.disabled};var isAes=function isAes(media){for(var i=0;i<media.segments.length;i++){if(media.segments[i].key){return true}}return false};var isFmp4=function isFmp4(media){for(var i=0;i<media.segments.length;i++){if(media.segments[i].map){return true}}return false};var hasAttribute=function hasAttribute(attr,playlist){return playlist.attributes&&playlist.attributes[attr]};var estimateSegmentRequestTime=function estimateSegmentRequestTime(segmentDuration,bandwidth,playlist){var bytesReceived=arguments.length>3&&arguments[3]!==undefined?arguments[3]:0;if(!hasAttribute("BANDWIDTH",playlist)){return NaN}var size=segmentDuration*playlist.attributes.BANDWIDTH;return(size-bytesReceived*8)/bandwidth};var isLowestEnabledRendition=function isLowestEnabledRendition(master,media){if(master.playlists.length===1){return true}var currentBandwidth=media.attributes.BANDWIDTH||Number.MAX_VALUE;return master.playlists.filter(function(playlist){if(!isEnabled(playlist)){return false}return(playlist.attributes.BANDWIDTH||0)<currentBandwidth}).length===0};var Playlist={duration:duration,seekable:seekable,safeLiveIndex:safeLiveIndex,getMediaInfoForTime:getMediaInfoForTime,isEnabled:isEnabled,isDisabled:isDisabled,isBlacklisted:isBlacklisted,isIncompatible:isIncompatible,playlistEnd:playlistEnd,isAes:isAes,isFmp4:isFmp4,hasAttribute:hasAttribute,estimateSegmentRequestTime:estimateSegmentRequestTime,isLowestEnabledRendition:isLowestEnabledRendition};var videojsXHR=videojs$1.xhr,mergeOptions$1$1=videojs$1.mergeOptions;var xhrFactory=function xhrFactory(){var xhr=function XhrFunction(options,callback){options=mergeOptions$1$1({timeout:45e3},options);var beforeRequest=XhrFunction.beforeRequest||videojs$1.Hls.xhr.beforeRequest;if(beforeRequest&&typeof beforeRequest==="function"){var newOptions=beforeRequest(options);if(newOptions){options=newOptions}}var request=videojsXHR(options,function(error,response){var reqResponse=request.response;if(!error&&reqResponse){request.responseTime=Date.now();request.roundTripTime=request.responseTime-request.requestTime;request.bytesReceived=reqResponse.byteLength||reqResponse.length;if(!request.bandwidth){request.bandwidth=Math.floor(request.bytesReceived/request.roundTripTime*8*1e3)}}if(response.headers){request.responseHeaders=response.headers}if(error&&error.code==="ETIMEDOUT"){request.timedout=true}if(!error&&!request.aborted&&response.statusCode!==200&&response.statusCode!==206&&response.statusCode!==0){error=new Error("XHR Failed with a response of: "+(request&&(reqResponse||request.responseText)))}callback(error,request)});var originalAbort=request.abort;request.abort=function(){request.aborted=true;return originalAbort.apply(request,arguments)};request.uri=options.uri;request.requestTime=Date.now();return request};return xhr};var byterangeStr=function byterangeStr(byterange){var byterangeStart=void 0;var byterangeEnd=void 0;byterangeEnd=byterange.offset+byterange.length-1;byterangeStart=byterange.offset;return"bytes="+byterangeStart+"-"+byterangeEnd};var segmentXhrHeaders=function segmentXhrHeaders(segment){var headers={};if(segment.byterange){headers.Range=byterangeStr(segment.byterange)}return headers};var textRange=function textRange(range,i){return range.start(i)+"-"+range.end(i)};var formatHexString=function formatHexString(e,i){var value=e.toString(16);return"00".substring(0,2-value.length)+value+(i%2?" ":"")};var formatAsciiString=function formatAsciiString(e){if(e>=32&&e<126){return String.fromCharCode(e)}return"."};var createTransferableMessage=function createTransferableMessage(message){var transferable={};Object.keys(message).forEach(function(key){var value=message[key];if(ArrayBuffer.isView(value)){transferable[key]={bytes:value.buffer,byteOffset:value.byteOffset,byteLength:value.byteLength}}else{transferable[key]=value}});return transferable};var initSegmentId=function initSegmentId(initSegment){var byterange=initSegment.byterange||{length:Infinity,offset:0};return[byterange.length,byterange.offset,initSegment.resolvedUri].join(",")};var segmentKeyId=function segmentKeyId(key){return key.resolvedUri};var hexDump=function hexDump(data){var bytes=Array.prototype.slice.call(data);var step=16;var result="";var hex=void 0;var ascii=void 0;for(var j=0;j<bytes.length/step;j++){hex=bytes.slice(j*step,j*step+step).map(formatHexString).join("");ascii=bytes.slice(j*step,j*step+step).map(formatAsciiString).join("");result+=hex+" "+ascii+"\n"}return result};var tagDump=function tagDump(_ref){var bytes=_ref.bytes;return hexDump(bytes)};var textRanges=function textRanges(ranges){var result="";var i=void 0;for(i=0;i<ranges.length;i++){result+=textRange(ranges,i)+" "}return result};var utils$1=Object.freeze({createTransferableMessage:createTransferableMessage,initSegmentId:initSegmentId,segmentKeyId:segmentKeyId,hexDump:hexDump,tagDump:tagDump,textRanges:textRanges});var SEGMENT_END_FUDGE_PERCENT=.25;var playerTimeToProgramTime=function playerTimeToProgramTime(playerTime,segment){if(!segment.dateTimeObject){return null}var transmuxerPrependedSeconds=segment.videoTimingInfo.transmuxerPrependedSeconds;var transmuxedStart=segment.videoTimingInfo.transmuxedPresentationStart;var startOfSegment=transmuxedStart+transmuxerPrependedSeconds;var offsetFromSegmentStart=playerTime-startOfSegment;return new Date(segment.dateTimeObject.getTime()+offsetFromSegmentStart*1e3)};var originalSegmentVideoDuration=function originalSegmentVideoDuration(videoTimingInfo){return videoTimingInfo.transmuxedPresentationEnd-videoTimingInfo.transmuxedPresentationStart-videoTimingInfo.transmuxerPrependedSeconds};var findSegmentForProgramTime=function findSegmentForProgramTime(programTime,playlist){var dateTimeObject=void 0;try{dateTimeObject=new Date(programTime)}catch(e){return null}if(!playlist||!playlist.segments||playlist.segments.length===0){return null}var segment=playlist.segments[0];if(dateTimeObject<segment.dateTimeObject){return null}for(var i=0;i<playlist.segments.length-1;i++){segment=playlist.segments[i];var nextSegmentStart=playlist.segments[i+1].dateTimeObject;if(dateTimeObject<nextSegmentStart){break}}var lastSegment=playlist.segments[playlist.segments.length-1];var lastSegmentStart=lastSegment.dateTimeObject;var lastSegmentDuration=lastSegment.videoTimingInfo?originalSegmentVideoDuration(lastSegment.videoTimingInfo):lastSegment.duration+lastSegment.duration*SEGMENT_END_FUDGE_PERCENT;var lastSegmentEnd=new Date(lastSegmentStart.getTime()+lastSegmentDuration*1e3);if(dateTimeObject>lastSegmentEnd){return null}if(dateTimeObject>lastSegmentStart){segment=lastSegment}return{segment:segment,estimatedStart:segment.videoTimingInfo?segment.videoTimingInfo.transmuxedPresentationStart:Playlist.duration(playlist,playlist.mediaSequence+playlist.segments.indexOf(segment)),type:segment.videoTimingInfo?"accurate":"estimate"}};var findSegmentForPlayerTime=function findSegmentForPlayerTime(time,playlist){if(!playlist||!playlist.segments||playlist.segments.length===0){return null}var segmentEnd=0;var segment=void 0;for(var i=0;i<playlist.segments.length;i++){segment=playlist.segments[i];segmentEnd=segment.videoTimingInfo?segment.videoTimingInfo.transmuxedPresentationEnd:segmentEnd+segment.duration;if(time<=segmentEnd){break}}var lastSegment=playlist.segments[playlist.segments.length-1];if(lastSegment.videoTimingInfo&&lastSegment.videoTimingInfo.transmuxedPresentationEnd<time){return null}if(time>segmentEnd){if(time>segmentEnd+lastSegment.duration*SEGMENT_END_FUDGE_PERCENT){return null}segment=lastSegment}return{segment:segment,estimatedStart:segment.videoTimingInfo?segment.videoTimingInfo.transmuxedPresentationStart:segmentEnd-segment.duration,type:segment.videoTimingInfo?"accurate":"estimate"}};var getOffsetFromTimestamp=function getOffsetFromTimestamp(comparisonTimeStamp,programTime){var segmentDateTime=void 0;var programDateTime=void 0;try{segmentDateTime=new Date(comparisonTimeStamp);programDateTime=new Date(programTime)}catch(e){}var segmentTimeEpoch=segmentDateTime.getTime();var programTimeEpoch=programDateTime.getTime();return(programTimeEpoch-segmentTimeEpoch)/1e3};var verifyProgramDateTimeTags=function verifyProgramDateTimeTags(playlist){if(!playlist.segments||playlist.segments.length===0){return false}for(var i=0;i<playlist.segments.length;i++){var segment=playlist.segments[i];if(!segment.dateTimeObject){return false}}return true};var getProgramTime=function getProgramTime(_ref){var playlist=_ref.playlist,_ref$time=_ref.time,time=_ref$time===undefined?undefined:_ref$time,callback=_ref.callback;if(!callback){throw new Error("getProgramTime: callback must be provided")}if(!playlist||time===undefined){return callback({message:"getProgramTime: playlist and time must be provided"})}var matchedSegment=findSegmentForPlayerTime(time,playlist);if(!matchedSegment){return callback({message:"valid programTime was not found"})}if(matchedSegment.type==="estimate"){return callback({message:"Accurate programTime could not be determined."+" Please seek to e.seekTime and try again",seekTime:matchedSegment.estimatedStart})}var programTimeObject={mediaSeconds:time};var programTime=playerTimeToProgramTime(time,matchedSegment.segment);if(programTime){programTimeObject.programDateTime=programTime.toISOString()}return callback(null,programTimeObject)};var seekToProgramTime=function seekToProgramTime(_ref2){var programTime=_ref2.programTime,playlist=_ref2.playlist,_ref2$retryCount=_ref2.retryCount,retryCount=_ref2$retryCount===undefined?2:_ref2$retryCount,seekTo=_ref2.seekTo,_ref2$pauseAfterSeek=_ref2.pauseAfterSeek,pauseAfterSeek=_ref2$pauseAfterSeek===undefined?true:_ref2$pauseAfterSeek,tech=_ref2.tech,callback=_ref2.callback;if(!callback){throw new Error("seekToProgramTime: callback must be provided")}if(typeof programTime==="undefined"||!playlist||!seekTo){return callback({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"})}if(!playlist.endList&&!tech.hasStarted_){return callback({message:"player must be playing a live stream to start buffering"})}if(!verifyProgramDateTimeTags(playlist)){return callback({message:"programDateTime tags must be provided in the manifest "+playlist.resolvedUri})}var matchedSegment=findSegmentForProgramTime(programTime,playlist);if(!matchedSegment){return callback({message:programTime+" was not found in the stream"})}var segment=matchedSegment.segment;var mediaOffset=getOffsetFromTimestamp(segment.dateTimeObject,programTime);if(matchedSegment.type==="estimate"){if(retryCount===0){return callback({message:programTime+" is not buffered yet. Try again"})}seekTo(matchedSegment.estimatedStart+mediaOffset);tech.one("seeked",function(){seekToProgramTime({programTime:programTime,playlist:playlist,retryCount:retryCount-1,seekTo:seekTo,pauseAfterSeek:pauseAfterSeek,tech:tech,callback:callback})});return}var seekToTime=segment.start+mediaOffset;var seekedCallback=function seekedCallback(){return callback(null,tech.currentTime())};tech.one("seeked",seekedCallback);if(pauseAfterSeek){tech.pause()}seekTo(seekToTime)};var TIME_FUDGE_FACTOR=1/30;var SAFE_TIME_DELTA=TIME_FUDGE_FACTOR*3;var filterRanges=function filterRanges(timeRanges,predicate){var results=[];var i=void 0;if(timeRanges&&timeRanges.length){for(i=0;i<timeRanges.length;i++){if(predicate(timeRanges.start(i),timeRanges.end(i))){results.push([timeRanges.start(i),timeRanges.end(i)])}}}return videojs$1.createTimeRanges(results)};var findRange=function findRange(buffered,time){return filterRanges(buffered,function(start,end){return start-SAFE_TIME_DELTA<=time&&end+SAFE_TIME_DELTA>=time})};var findNextRange=function findNextRange(timeRanges,time){return filterRanges(timeRanges,function(start){return start-TIME_FUDGE_FACTOR>=time})};var findGaps=function findGaps(buffered){if(buffered.length<2){return videojs$1.createTimeRanges()}var ranges=[];for(var i=1;i<buffered.length;i++){var start=buffered.end(i-1);var end=buffered.start(i);ranges.push([start,end])}return videojs$1.createTimeRanges(ranges)};var printableRange=function printableRange(range){var strArr=[];if(!range||!range.length){return""}for(var i=0;i<range.length;i++){strArr.push(range.start(i)+" => "+range.end(i))}return strArr.join(", ")};var timeUntilRebuffer=function timeUntilRebuffer(buffered,currentTime){var playbackRate=arguments.length>2&&arguments[2]!==undefined?arguments[2]:1;var bufferedEnd=buffered.length?buffered.end(buffered.length-1):0;return(bufferedEnd-currentTime)/playbackRate};var timeRangesToArray=function timeRangesToArray(timeRanges){var timeRangesList=[];for(var i=0;i<timeRanges.length;i++){timeRangesList.push({start:timeRanges.start(i),end:timeRanges.end(i)})}return timeRangesList};var createTextTracksIfNecessary=function createTextTracksIfNecessary(sourceBuffer,mediaSource,segment){var player=mediaSource.player_;if(segment.captions&&segment.captions.length){if(!sourceBuffer.inbandTextTracks_){sourceBuffer.inbandTextTracks_={}}for(var trackId in segment.captionStreams){if(!sourceBuffer.inbandTextTracks_[trackId]){player.tech_.trigger({type:"usage",name:"hls-608"});var track=player.textTracks().getTrackById(trackId);if(track){sourceBuffer.inbandTextTracks_[trackId]=track}else{sourceBuffer.inbandTextTracks_[trackId]=player.addRemoteTextTrack({kind:"captions",id:trackId,label:trackId},false).track}}}}if(segment.metadata&&segment.metadata.length&&!sourceBuffer.metadataTrack_){sourceBuffer.metadataTrack_=player.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},false).track;sourceBuffer.metadataTrack_.inBandMetadataTrackDispatchType=segment.metadata.dispatchType}};var removeCuesFromTrack=function removeCuesFromTrack(start,end,track){var i=void 0;var cue=void 0;if(!track){return}if(!track.cues){return}i=track.cues.length;while(i--){cue=track.cues[i];if(cue.startTime<=end&&cue.endTime>=start){track.removeCue(cue)}}};var deprecateOldCue=function deprecateOldCue(cue){Object.defineProperties(cue.frame,{id:{get:function get(){videojs$1.log.warn("cue.frame.id is deprecated. Use cue.value.key instead.");return cue.value.key}},value:{get:function get(){videojs$1.log.warn("cue.frame.value is deprecated. Use cue.value.data instead.");return cue.value.data}},privateData:{get:function get(){videojs$1.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead.");return cue.value.data}}})};var durationOfVideo=function durationOfVideo(duration){var dur=void 0;if(isNaN(duration)||Math.abs(duration)===Infinity){dur=Number.MAX_VALUE}else{dur=duration}return dur};var addTextTrackData=function addTextTrackData(sourceHandler,captionArray,metadataArray){var Cue=window$1.WebKitDataCue||window$1.VTTCue;if(captionArray){captionArray.forEach(function(caption){var track=caption.stream;this.inbandTextTracks_[track].addCue(new Cue(caption.startTime+this.timestampOffset,caption.endTime+this.timestampOffset,caption.text))},sourceHandler)}if(metadataArray){var videoDuration=durationOfVideo(sourceHandler.mediaSource_.duration);metadataArray.forEach(function(metadata){var time=metadata.cueTime+this.timestampOffset;if(typeof time!=="number"||window$1.isNaN(time)||time<0||!(time<Infinity)){return}metadata.frames.forEach(function(frame){var cue=new Cue(time,time,frame.value||frame.url||frame.data||"");cue.frame=frame;cue.value=frame;deprecateOldCue(cue);this.metadataTrack_.addCue(cue)},this)},sourceHandler);if(sourceHandler.metadataTrack_&&sourceHandler.metadataTrack_.cues&&sourceHandler.metadataTrack_.cues.length){var cues=sourceHandler.metadataTrack_.cues;var cuesArray=[];for(var i=0;i<cues.length;i++){if(cues[i]){cuesArray.push(cues[i])}}var cuesGroupedByStartTime=cuesArray.reduce(function(obj,cue){var timeSlot=obj[cue.startTime]||[];timeSlot.push(cue);obj[cue.startTime]=timeSlot;return obj},{});var sortedStartTimes=Object.keys(cuesGroupedByStartTime).sort(function(a,b){return Number(a)-Number(b)});sortedStartTimes.forEach(function(startTime,idx){var cueGroup=cuesGroupedByStartTime[startTime];var nextTime=Number(sortedStartTimes[idx+1])||videoDuration;cueGroup.forEach(function(cue){cue.endTime=nextTime})})}}};var win=typeof window!=="undefined"?window:{},TARGET=typeof Symbol==="undefined"?"__target":Symbol(),SCRIPT_TYPE="application/javascript",BlobBuilder=win.BlobBuilder||win.WebKitBlobBuilder||win.MozBlobBuilder||win.MSBlobBuilder,URL=win.URL||win.webkitURL||URL&&URL.msURL,Worker=win.Worker;function shimWorker(filename,fn){return function ShimWorker(forceFallback){var o=this;if(!fn){return new Worker(filename)}else if(Worker&&!forceFallback){var source=fn.toString().replace(/^function.+?{/,"").slice(0,-1),objURL=createSourceObject(source);this[TARGET]=new Worker(objURL);wrapTerminate(this[TARGET],objURL);return this[TARGET]}else{var selfShim={postMessage:function postMessage(m){if(o.onmessage){setTimeout(function(){o.onmessage({data:m,target:selfShim})})}}};fn.call(selfShim);this.postMessage=function(m){setTimeout(function(){selfShim.onmessage({data:m,target:o})})};this.isThisThread=true}}}if(Worker){var testWorker,objURL=createSourceObject("self.onmessage = function () {}"),testArray=new Uint8Array(1);try{testWorker=new Worker(objURL);testWorker.postMessage(testArray,[testArray.buffer])}catch(e){Worker=null}finally{URL.revokeObjectURL(objURL);if(testWorker){testWorker.terminate()}}}function createSourceObject(str){try{return URL.createObjectURL(new Blob([str],{type:SCRIPT_TYPE}))}catch(e){var blob=new BlobBuilder;blob.append(str);return URL.createObjectURL(blob.getBlob(type))}}function wrapTerminate(worker,objURL){if(!worker||!objURL)return;var term=worker.terminate;worker.objURL=objURL;worker.terminate=function(){if(worker.objURL)URL.revokeObjectURL(worker.objURL);term.call(worker)}}var TransmuxWorker=new shimWorker("./transmuxer-worker.worker.js",function(window,document$$1){var self=this;var transmuxerWorker=function(){var Stream=function Stream(){this.init=function(){var listeners={};this.on=function(type,listener){if(!listeners[type]){listeners[type]=[]}listeners[type]=listeners[type].concat(listener)};this.off=function(type,listener){var index;if(!listeners[type]){return false}index=listeners[type].indexOf(listener);listeners[type]=listeners[type].slice();listeners[type].splice(index,1);return index>-1};this.trigger=function(type){var callbacks,i,length,args;callbacks=listeners[type];if(!callbacks){return}if(arguments.length===2){length=callbacks.length;for(i=0;i<length;++i){callbacks[i].call(this,arguments[1])}}else{args=[];i=arguments.length;for(i=1;i<arguments.length;++i){args.push(arguments[i])}length=callbacks.length;for(i=0;i<length;++i){callbacks[i].apply(this,args)}}};this.dispose=function(){listeners={}}}};Stream.prototype.pipe=function(destination){this.on("data",function(data){destination.push(data)});this.on("done",function(flushSource){destination.flush(flushSource)});this.on("partialdone",function(flushSource){destination.partialFlush(flushSource)});this.on("endedtimeline",function(flushSource){destination.endTimeline(flushSource)});this.on("reset",function(flushSource){destination.reset(flushSource)});return destination};Stream.prototype.push=function(data){this.trigger("data",data)};Stream.prototype.flush=function(flushSource){this.trigger("done",flushSource)};Stream.prototype.partialFlush=function(flushSource){this.trigger("partialdone",flushSource)};Stream.prototype.endTimeline=function(flushSource){this.trigger("endedtimeline",flushSource)};Stream.prototype.reset=function(flushSource){this.trigger("reset",flushSource)};var stream=Stream;var UINT32_MAX=Math.pow(2,32)-1;var box,dinf,esds,ftyp,mdat,mfhd,minf,moof,moov,mvex,mvhd,trak,tkhd,mdia,mdhd,hdlr,sdtp,stbl,stsd,traf,trex,trun,types,MAJOR_BRAND,MINOR_VERSION,AVC1_BRAND,VIDEO_HDLR,AUDIO_HDLR,HDLR_TYPES,VMHD,SMHD,DREF,STCO,STSC,STSZ,STTS;(function(){var i;types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],pasp:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]};if(typeof Uint8Array==="undefined"){return}for(i in types){if(types.hasOwnProperty(i)){types[i]=[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]}}MAJOR_BRAND=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]);AVC1_BRAND=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]);MINOR_VERSION=new Uint8Array([0,0,0,1]);VIDEO_HDLR=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]);AUDIO_HDLR=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);HDLR_TYPES={video:VIDEO_HDLR,audio:AUDIO_HDLR};DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]);SMHD=new Uint8Array([0,0,0,0,0,0,0,0]);STCO=new Uint8Array([0,0,0,0,0,0,0,0]);STSC=STCO;STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);STTS=STCO;VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])})();box=function box(type){var payload=[],size=0,i,result,view;for(i=1;i<arguments.length;i++){payload.push(arguments[i])}i=payload.length;while(i--){size+=payload[i].byteLength}result=new Uint8Array(size+8);view=new DataView(result.buffer,result.byteOffset,result.byteLength);view.setUint32(0,result.byteLength);result.set(type,4);for(i=0,size=8;i<payload.length;i++){result.set(payload[i],size);size+=payload[i].byteLength}return result};dinf=function dinf(){return box(types.dinf,box(types.dref,DREF))};esds=function esds(track){return box(types.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,track.audioobjecttype<<3|track.samplingfrequencyindex>>>1,track.samplingfrequencyindex<<7|track.channelcount<<3,6,1,2]))};ftyp=function ftyp(){return box(types.ftyp,MAJOR_BRAND,MINOR_VERSION,MAJOR_BRAND,AVC1_BRAND)};hdlr=function hdlr(type){return box(types.hdlr,HDLR_TYPES[type])};mdat=function mdat(data){return box(types.mdat,data)};mdhd=function mdhd(track){var result=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,track.duration>>>24&255,track.duration>>>16&255,track.duration>>>8&255,track.duration&255,85,196,0,0]);if(track.samplerate){result[12]=track.samplerate>>>24&255;result[13]=track.samplerate>>>16&255;result[14]=track.samplerate>>>8&255;result[15]=track.samplerate&255}return box(types.mdhd,result)};mdia=function mdia(track){return box(types.mdia,mdhd(track),hdlr(track.type),minf(track))};mfhd=function mfhd(sequenceNumber){return box(types.mfhd,new Uint8Array([0,0,0,0,(sequenceNumber&4278190080)>>24,(sequenceNumber&16711680)>>16,(sequenceNumber&65280)>>8,sequenceNumber&255]))};minf=function minf(track){return box(types.minf,track.type==="video"?box(types.vmhd,VMHD):box(types.smhd,SMHD),dinf(),stbl(track))};moof=function moof(sequenceNumber,tracks){var trackFragments=[],i=tracks.length;while(i--){trackFragments[i]=traf(tracks[i])}return box.apply(null,[types.moof,mfhd(sequenceNumber)].concat(trackFragments))};moov=function moov(tracks){var i=tracks.length,boxes=[];while(i--){boxes[i]=trak(tracks[i])}return box.apply(null,[types.moov,mvhd(4294967295)].concat(boxes).concat(mvex(tracks)))};mvex=function mvex(tracks){var i=tracks.length,boxes=[];while(i--){boxes[i]=trex(tracks[i])}return box.apply(null,[types.mvex].concat(boxes))};mvhd=function mvhd(duration){var bytes=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(duration&4278190080)>>24,(duration&16711680)>>16,(duration&65280)>>8,duration&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return box(types.mvhd,bytes)};sdtp=function sdtp(track){var samples=track.samples||[],bytes=new Uint8Array(4+samples.length),flags,i;for(i=0;i<samples.length;i++){flags=samples[i].flags;bytes[i+4]=flags.dependsOn<<4|flags.isDependedOn<<2|flags.hasRedundancy}return box(types.sdtp,bytes)};stbl=function stbl(track){return box(types.stbl,stsd(track),box(types.stts,STTS),box(types.stsc,STSC),box(types.stsz,STSZ),box(types.stco,STCO))};(function(){var videoSample,audioSample;stsd=function stsd(track){return box(types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),track.type==="video"?videoSample(track):audioSample(track))};videoSample=function videoSample(track){var sps=track.sps||[],pps=track.pps||[],sequenceParameterSets=[],pictureParameterSets=[],i,avc1Box;for(i=0;i<sps.length;i++){sequenceParameterSets.push((sps[i].byteLength&65280)>>>8);sequenceParameterSets.push(sps[i].byteLength&255);sequenceParameterSets=sequenceParameterSets.concat(Array.prototype.slice.call(sps[i]))}for(i=0;i<pps.length;i++){pictureParameterSets.push((pps[i].byteLength&65280)>>>8);pictureParameterSets.push(pps[i].byteLength&255);pictureParameterSets=pictureParameterSets.concat(Array.prototype.slice.call(pps[i]))}avc1Box=[types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(track.width&65280)>>8,track.width&255,(track.height&65280)>>8,track.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),box(types.avcC,new Uint8Array([1,track.profileIdc,track.profileCompatibility,track.levelIdc,255].concat([sps.length],sequenceParameterSets,[pps.length],pictureParameterSets))),box(types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))];if(track.sarRatio){var hSpacing=track.sarRatio[0],vSpacing=track.sarRatio[1];avc1Box.push(box(types.pasp,new Uint8Array([(hSpacing&4278190080)>>24,(hSpacing&16711680)>>16,(hSpacing&65280)>>8,hSpacing&255,(vSpacing&4278190080)>>24,(vSpacing&16711680)>>16,(vSpacing&65280)>>8,vSpacing&255])))}return box.apply(null,avc1Box)};audioSample=function audioSample(track){return box(types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(track.channelcount&65280)>>8,track.channelcount&255,(track.samplesize&65280)>>8,track.samplesize&255,0,0,0,0,(track.samplerate&65280)>>8,track.samplerate&255,0,0]),esds(track))}})();tkhd=function tkhd(track){var result=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(track.id&4278190080)>>24,(track.id&16711680)>>16,(track.id&65280)>>8,track.id&255,0,0,0,0,(track.duration&4278190080)>>24,(track.duration&16711680)>>16,(track.duration&65280)>>8,track.duration&255,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,(track.width&65280)>>8,track.width&255,0,0,(track.height&65280)>>8,track.height&255,0,0]);return box(types.tkhd,result)};traf=function traf(track){var trackFragmentHeader,trackFragmentDecodeTime,trackFragmentRun,sampleDependencyTable,dataOffset,upperWordBaseMediaDecodeTime,lowerWordBaseMediaDecodeTime;trackFragmentHeader=box(types.tfhd,new Uint8Array([0,0,0,58,(track.id&4278190080)>>24,(track.id&16711680)>>16,(track.id&65280)>>8,track.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0]));upperWordBaseMediaDecodeTime=Math.floor(track.baseMediaDecodeTime/(UINT32_MAX+1));lowerWordBaseMediaDecodeTime=Math.floor(track.baseMediaDecodeTime%(UINT32_MAX+1));trackFragmentDecodeTime=box(types.tfdt,new Uint8Array([1,0,0,0,upperWordBaseMediaDecodeTime>>>24&255,upperWordBaseMediaDecodeTime>>>16&255,upperWordBaseMediaDecodeTime>>>8&255,upperWordBaseMediaDecodeTime&255,lowerWordBaseMediaDecodeTime>>>24&255,lowerWordBaseMediaDecodeTime>>>16&255,lowerWordBaseMediaDecodeTime>>>8&255,lowerWordBaseMediaDecodeTime&255]));dataOffset=32+20+8+16+8+8;if(track.type==="audio"){trackFragmentRun=trun(track,dataOffset);return box(types.traf,trackFragmentHeader,trackFragmentDecodeTime,trackFragmentRun)}sampleDependencyTable=sdtp(track);trackFragmentRun=trun(track,sampleDependencyTable.length+dataOffset);return box(types.traf,trackFragmentHeader,trackFragmentDecodeTime,trackFragmentRun,sampleDependencyTable)};trak=function trak(track){track.duration=track.duration||4294967295;return box(types.trak,tkhd(track),mdia(track))};trex=function trex(track){var result=new Uint8Array([0,0,0,0,(track.id&4278190080)>>24,(track.id&16711680)>>16,(track.id&65280)>>8,track.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);if(track.type!=="video"){result[result.length-1]=0}return box(types.trex,result)};(function(){var audioTrun,videoTrun,trunHeader;trunHeader=function trunHeader(samples,offset){var durationPresent=0,sizePresent=0,flagsPresent=0,compositionTimeOffset=0;if(samples.length){if(samples[0].duration!==undefined){durationPresent=1}if(samples[0].size!==undefined){sizePresent=2}if(samples[0].flags!==undefined){flagsPresent=4}if(samples[0].compositionTimeOffset!==undefined){compositionTimeOffset=8}}return[0,0,durationPresent|sizePresent|flagsPresent|compositionTimeOffset,1,(samples.length&4278190080)>>>24,(samples.length&16711680)>>>16,(samples.length&65280)>>>8,samples.length&255,(offset&4278190080)>>>24,(offset&16711680)>>>16,(offset&65280)>>>8,offset&255]};videoTrun=function videoTrun(track,offset){var bytes,samples,sample,i;samples=track.samples||[];offset+=8+12+16*samples.length;bytes=trunHeader(samples,offset);for(i=0;i<samples.length;i++){sample=samples[i];bytes=bytes.concat([(sample.duration&4278190080)>>>24,(sample.duration&16711680)>>>16,(sample.duration&65280)>>>8,sample.duration&255,(sample.size&4278190080)>>>24,(sample.size&16711680)>>>16,(sample.size&65280)>>>8,sample.size&255,sample.flags.isLeading<<2|sample.flags.dependsOn,sample.flags.isDependedOn<<6|sample.flags.hasRedundancy<<4|sample.flags.paddingValue<<1|sample.flags.isNonSyncSample,sample.flags.degradationPriority&240<<8,sample.flags.degradationPriority&15,(sample.compositionTimeOffset&4278190080)>>>24,(sample.compositionTimeOffset&16711680)>>>16,(sample.compositionTimeOffset&65280)>>>8,sample.compositionTimeOffset&255])}return box(types.trun,new Uint8Array(bytes))};audioTrun=function audioTrun(track,offset){var bytes,samples,sample,i;samples=track.samples||[];offset+=8+12+8*samples.length;bytes=trunHeader(samples,offset);for(i=0;i<samples.length;i++){sample=samples[i];bytes=bytes.concat([(sample.duration&4278190080)>>>24,(sample.duration&16711680)>>>16,(sample.duration&65280)>>>8,sample.duration&255,(sample.size&4278190080)>>>24,(sample.size&16711680)>>>16,(sample.size&65280)>>>8,sample.size&255])}return box(types.trun,new Uint8Array(bytes))};trun=function trun(track,offset){if(track.type==="audio"){return audioTrun(track,offset)}return videoTrun(track,offset)}})();var mp4Generator={ftyp:ftyp,mdat:mdat,moof:moof,moov:moov,initSegment:function initSegment(tracks){var fileType=ftyp(),movie=moov(tracks),result;result=new Uint8Array(fileType.byteLength+movie.byteLength);result.set(fileType);result.set(movie,fileType.byteLength);return result}};var groupNalsIntoFrames=function groupNalsIntoFrames(nalUnits){var i,currentNal,currentFrame=[],frames=[];frames.byteLength=0;frames.nalCount=0;frames.duration=0;currentFrame.byteLength=0;for(i=0;i<nalUnits.length;i++){currentNal=nalUnits[i];if(currentNal.nalUnitType==="access_unit_delimiter_rbsp"){if(currentFrame.length){currentFrame.duration=currentNal.dts-currentFrame.dts;frames.byteLength+=currentFrame.byteLength;frames.nalCount+=currentFrame.length;frames.duration+=currentFrame.duration;frames.push(currentFrame)}currentFrame=[currentNal];currentFrame.byteLength=currentNal.data.byteLength;currentFrame.pts=currentNal.pts;currentFrame.dts=currentNal.dts}else{if(currentNal.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"){currentFrame.keyFrame=true}currentFrame.duration=currentNal.dts-currentFrame.dts;currentFrame.byteLength+=currentNal.data.byteLength;currentFrame.push(currentNal)}}if(frames.length&&(!currentFrame.duration||currentFrame.duration<=0)){currentFrame.duration=frames[frames.length-1].duration}frames.byteLength+=currentFrame.byteLength;frames.nalCount+=currentFrame.length;frames.duration+=currentFrame.duration;frames.push(currentFrame);return frames};var groupFramesIntoGops=function groupFramesIntoGops(frames){var i,currentFrame,currentGop=[],gops=[];currentGop.byteLength=0;currentGop.nalCount=0;currentGop.duration=0;currentGop.pts=frames[0].pts;currentGop.dts=frames[0].dts;gops.byteLength=0;gops.nalCount=0;gops.duration=0;gops.pts=frames[0].pts;gops.dts=frames[0].dts;for(i=0;i<frames.length;i++){currentFrame=frames[i];if(currentFrame.keyFrame){if(currentGop.length){gops.push(currentGop);gops.byteLength+=currentGop.byteLength;gops.nalCount+=currentGop.nalCount;gops.duration+=currentGop.duration}currentGop=[currentFrame];currentGop.nalCount=currentFrame.length;currentGop.byteLength=currentFrame.byteLength;currentGop.pts=currentFrame.pts;currentGop.dts=currentFrame.dts;currentGop.duration=currentFrame.duration}else{currentGop.duration+=currentFrame.duration;currentGop.nalCount+=currentFrame.length;currentGop.byteLength+=currentFrame.byteLength;currentGop.push(currentFrame)}}if(gops.length&&currentGop.duration<=0){currentGop.duration=gops[gops.length-1].duration}gops.byteLength+=currentGop.byteLength;gops.nalCount+=currentGop.nalCount;gops.duration+=currentGop.duration;gops.push(currentGop);return gops};var extendFirstKeyFrame=function extendFirstKeyFrame(gops){var currentGop;if(!gops[0][0].keyFrame&&gops.length>1){currentGop=gops.shift();gops.byteLength-=currentGop.byteLength;gops.nalCount-=currentGop.nalCount;gops[0][0].dts=currentGop.dts;gops[0][0].pts=currentGop.pts;gops[0][0].duration+=currentGop.duration}return gops};var createDefaultSample=function createDefaultSample(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}};var sampleForFrame=function sampleForFrame(frame,dataOffset){var sample=createDefaultSample();sample.dataOffset=dataOffset;sample.compositionTimeOffset=frame.pts-frame.dts;sample.duration=frame.duration;sample.size=4*frame.length;sample.size+=frame.byteLength;if(frame.keyFrame){sample.flags.dependsOn=2;sample.flags.isNonSyncSample=0}return sample};var generateSampleTable=function generateSampleTable(gops,baseDataOffset){var h,i,sample,currentGop,currentFrame,dataOffset=baseDataOffset||0,samples=[];for(h=0;h<gops.length;h++){currentGop=gops[h];for(i=0;i<currentGop.length;i++){currentFrame=currentGop[i];sample=sampleForFrame(currentFrame,dataOffset);dataOffset+=sample.size;samples.push(sample)}}return samples};var concatenateNalData=function concatenateNalData(gops){var h,i,j,currentGop,currentFrame,currentNal,dataOffset=0,nalsByteLength=gops.byteLength,numberOfNals=gops.nalCount,totalByteLength=nalsByteLength+4*numberOfNals,data=new Uint8Array(totalByteLength),view=new DataView(data.buffer);for(h=0;h<gops.length;h++){currentGop=gops[h];for(i=0;i<currentGop.length;i++){currentFrame=currentGop[i];for(j=0;j<currentFrame.length;j++){currentNal=currentFrame[j];view.setUint32(dataOffset,currentNal.data.byteLength);dataOffset+=4;data.set(currentNal.data,dataOffset);dataOffset+=currentNal.data.byteLength}}}return data};var generateSampleTableForFrame=function generateSampleTableForFrame(frame,baseDataOffset){var sample,dataOffset=baseDataOffset||0,samples=[];sample=sampleForFrame(frame,dataOffset);samples.push(sample);return samples};var concatenateNalDataForFrame=function concatenateNalDataForFrame(frame){var i,currentNal,dataOffset=0,nalsByteLength=frame.byteLength,numberOfNals=frame.length,totalByteLength=nalsByteLength+4*numberOfNals,data=new Uint8Array(totalByteLength),view=new DataView(data.buffer);for(i=0;i<frame.length;i++){currentNal=frame[i];view.setUint32(dataOffset,currentNal.data.byteLength);dataOffset+=4;data.set(currentNal.data,dataOffset);dataOffset+=currentNal.data.byteLength}return data};var frameUtils={groupNalsIntoFrames:groupNalsIntoFrames,groupFramesIntoGops:groupFramesIntoGops,extendFirstKeyFrame:extendFirstKeyFrame,generateSampleTable:generateSampleTable,concatenateNalData:concatenateNalData,generateSampleTableForFrame:generateSampleTableForFrame,concatenateNalDataForFrame:concatenateNalDataForFrame};var highPrefix=[33,16,5,32,164,27];var lowPrefix=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252];var zeroFill=function zeroFill(count){var a=[];while(count--){a.push(0)}return a};var makeTable=function makeTable(metaTable){return Object.keys(metaTable).reduce(function(obj,key){obj[key]=new Uint8Array(metaTable[key].reduce(function(arr,part){return arr.concat(part)},[]));return obj},{})};var coneOfSilence={96e3:[highPrefix,[227,64],zeroFill(154),[56]],88200:[highPrefix,[231],zeroFill(170),[56]],64e3:[highPrefix,[248,192],zeroFill(240),[56]],48e3:[highPrefix,[255,192],zeroFill(268),[55,148,128],zeroFill(54),[112]],44100:[highPrefix,[255,192],zeroFill(268),[55,163,128],zeroFill(84),[112]],32e3:[highPrefix,[255,192],zeroFill(268),[55,234],zeroFill(226),[112]],24e3:[highPrefix,[255,192],zeroFill(268),[55,255,128],zeroFill(268),[111,112],zeroFill(126),[224]],16e3:[highPrefix,[255,192],zeroFill(268),[55,255,128],zeroFill(268),[111,255],zeroFill(269),[223,108],zeroFill(195),[1,192]],12e3:[lowPrefix,zeroFill(268),[3,127,248],zeroFill(268),[6,255,240],zeroFill(268),[13,255,224],zeroFill(268),[27,253,128],zeroFill(259),[56]],11025:[lowPrefix,zeroFill(268),[3,127,248],zeroFill(268),[6,255,240],zeroFill(268),[13,255,224],zeroFill(268),[27,255,192],zeroFill(268),[55,175,128],zeroFill(108),[112]],8e3:[lowPrefix,zeroFill(268),[3,121,16],zeroFill(47),[7]]};var silence=makeTable(coneOfSilence);var ONE_SECOND_IN_TS=9e4,secondsToVideoTs,secondsToAudioTs,videoTsToSeconds,audioTsToSeconds,audioTsToVideoTs,videoTsToAudioTs,metadataTsToSeconds;secondsToVideoTs=function secondsToVideoTs(seconds){return seconds*ONE_SECOND_IN_TS};secondsToAudioTs=function secondsToAudioTs(seconds,sampleRate){return seconds*sampleRate};videoTsToSeconds=function videoTsToSeconds(timestamp){return timestamp/ONE_SECOND_IN_TS};audioTsToSeconds=function audioTsToSeconds(timestamp,sampleRate){return timestamp/sampleRate};audioTsToVideoTs=function audioTsToVideoTs(timestamp,sampleRate){return secondsToVideoTs(audioTsToSeconds(timestamp,sampleRate))};videoTsToAudioTs=function videoTsToAudioTs(timestamp,sampleRate){return secondsToAudioTs(videoTsToSeconds(timestamp),sampleRate)};metadataTsToSeconds=function metadataTsToSeconds(timestamp,timelineStartPts,keepOriginalTimestamps){return videoTsToSeconds(keepOriginalTimestamps?timestamp:timestamp-timelineStartPts)};var clock={ONE_SECOND_IN_TS:ONE_SECOND_IN_TS,secondsToVideoTs:secondsToVideoTs,secondsToAudioTs:secondsToAudioTs,videoTsToSeconds:videoTsToSeconds,audioTsToSeconds:audioTsToSeconds,audioTsToVideoTs:audioTsToVideoTs,videoTsToAudioTs:videoTsToAudioTs,metadataTsToSeconds:metadataTsToSeconds};var sumFrameByteLengths=function sumFrameByteLengths(array){var i,currentObj,sum=0;for(i=0;i<array.length;i++){currentObj=array[i];sum+=currentObj.data.byteLength}return sum};var prefixWithSilence=function prefixWithSilence(track,frames,audioAppendStartTs,videoBaseMediaDecodeTime){var baseMediaDecodeTimeTs,frameDuration=0,audioGapDuration=0,audioFillFrameCount=0,audioFillDuration=0,silentFrame,i,firstFrame;if(!frames.length){return}baseMediaDecodeTimeTs=clock.audioTsToVideoTs(track.baseMediaDecodeTime,track.samplerate);frameDuration=Math.ceil(clock.ONE_SECOND_IN_TS/(track.samplerate/1024));if(audioAppendStartTs&&videoBaseMediaDecodeTime){audioGapDuration=baseMediaDecodeTimeTs-Math.max(audioAppendStartTs,videoBaseMediaDecodeTime);audioFillFrameCount=Math.floor(audioGapDuration/frameDuration);audioFillDuration=audioFillFrameCount*frameDuration}if(audioFillFrameCount<1||audioFillDuration>clock.ONE_SECOND_IN_TS/2){return}silentFrame=silence[track.samplerate];if(!silentFrame){silentFrame=frames[0].data}for(i=0;i<audioFillFrameCount;i++){firstFrame=frames[0];frames.splice(0,0,{data:silentFrame,dts:firstFrame.dts-frameDuration,pts:firstFrame.pts-frameDuration})}track.baseMediaDecodeTime-=Math.floor(clock.videoTsToAudioTs(audioFillDuration,track.samplerate))};var trimAdtsFramesByEarliestDts=function trimAdtsFramesByEarliestDts(adtsFrames,track,earliestAllowedDts){if(track.minSegmentDts>=earliestAllowedDts){return adtsFrames}track.minSegmentDts=Infinity;return adtsFrames.filter(function(currentFrame){if(currentFrame.dts>=earliestAllowedDts){track.minSegmentDts=Math.min(track.minSegmentDts,currentFrame.dts);track.minSegmentPts=track.minSegmentDts;return true}return false})};var generateSampleTable$1=function generateSampleTable(frames){var i,currentFrame,samples=[];for(i=0;i<frames.length;i++){currentFrame=frames[i];samples.push({size:currentFrame.data.byteLength,duration:1024})}return samples};var concatenateFrameData=function concatenateFrameData(frames){var i,currentFrame,dataOffset=0,data=new Uint8Array(sumFrameByteLengths(frames));for(i=0;i<frames.length;i++){currentFrame=frames[i];data.set(currentFrame.data,dataOffset);dataOffset+=currentFrame.data.byteLength}return data};var audioFrameUtils={prefixWithSilence:prefixWithSilence,trimAdtsFramesByEarliestDts:trimAdtsFramesByEarliestDts,generateSampleTable:generateSampleTable$1,concatenateFrameData:concatenateFrameData};var ONE_SECOND_IN_TS$1=clock.ONE_SECOND_IN_TS;var collectDtsInfo=function collectDtsInfo(track,data){if(typeof data.pts==="number"){if(track.timelineStartInfo.pts===undefined){track.timelineStartInfo.pts=data.pts}if(track.minSegmentPts===undefined){track.minSegmentPts=data.pts}else{track.minSegmentPts=Math.min(track.minSegmentPts,data.pts)}if(track.maxSegmentPts===undefined){track.maxSegmentPts=data.pts}else{track.maxSegmentPts=Math.max(track.maxSegmentPts,data.pts)}}if(typeof data.dts==="number"){if(track.timelineStartInfo.dts===undefined){track.timelineStartInfo.dts=data.dts}if(track.minSegmentDts===undefined){track.minSegmentDts=data.dts}else{track.minSegmentDts=Math.min(track.minSegmentDts,data.dts)}if(track.maxSegmentDts===undefined){track.maxSegmentDts=data.dts}else{track.maxSegmentDts=Math.max(track.maxSegmentDts,data.dts)}}};var clearDtsInfo=function clearDtsInfo(track){delete track.minSegmentDts;delete track.maxSegmentDts;delete track.minSegmentPts;delete track.maxSegmentPts};var calculateTrackBaseMediaDecodeTime=function calculateTrackBaseMediaDecodeTime(track,keepOriginalTimestamps){var baseMediaDecodeTime,scale,minSegmentDts=track.minSegmentDts;if(!keepOriginalTimestamps){minSegmentDts-=track.timelineStartInfo.dts}baseMediaDecodeTime=track.timelineStartInfo.baseMediaDecodeTime;baseMediaDecodeTime+=minSegmentDts;baseMediaDecodeTime=Math.max(0,baseMediaDecodeTime);if(track.type==="audio"){scale=track.samplerate/ONE_SECOND_IN_TS$1;baseMediaDecodeTime*=scale;baseMediaDecodeTime=Math.floor(baseMediaDecodeTime)}return baseMediaDecodeTime};var trackDecodeInfo={clearDtsInfo:clearDtsInfo,calculateTrackBaseMediaDecodeTime:calculateTrackBaseMediaDecodeTime,collectDtsInfo:collectDtsInfo};var USER_DATA_REGISTERED_ITU_T_T35=4,RBSP_TRAILING_BITS=128;var parseSei=function parseSei(bytes){var i=0,result={payloadType:-1,payloadSize:0},payloadType=0,payloadSize=0;while(i<bytes.byteLength){if(bytes[i]===RBSP_TRAILING_BITS){break}while(bytes[i]===255){payloadType+=255;i++}payloadType+=bytes[i++];while(bytes[i]===255){payloadSize+=255;i++}payloadSize+=bytes[i++];if(!result.payload&&payloadType===USER_DATA_REGISTERED_ITU_T_T35){result.payloadType=payloadType;result.payloadSize=payloadSize;result.payload=bytes.subarray(i,i+payloadSize);break}i+=payloadSize;payloadType=0;payloadSize=0}return result};var parseUserData=function parseUserData(sei){if(sei.payload[0]!==181){return null}if((sei.payload[1]<<8|sei.payload[2])!==49){return null}if(String.fromCharCode(sei.payload[3],sei.payload[4],sei.payload[5],sei.payload[6])!=="GA94"){return null}if(sei.payload[7]!==3){return null}return sei.payload.subarray(8,sei.payload.length-1)};var parseCaptionPackets=function parseCaptionPackets(pts,userData){var results=[],i,count,offset,data;if(!(userData[0]&64)){return results}count=userData[0]&31;for(i=0;i<count;i++){offset=i*3;data={type:userData[offset+2]&3,pts:pts};if(userData[offset+2]&4){data.ccData=userData[offset+3]<<8|userData[offset+4];results.push(data)}}return results};var discardEmulationPreventionBytes=function discardEmulationPreventionBytes(data){var length=data.byteLength,emulationPreventionBytesPositions=[],i=1,newLength,newData;while(i<length-2){if(data[i]===0&&data[i+1]===0&&data[i+2]===3){emulationPreventionBytesPositions.push(i+2);i+=2}else{i++}}if(emulationPreventionBytesPositions.length===0){return data}newLength=length-emulationPreventionBytesPositions.length;newData=new Uint8Array(newLength);var sourceIndex=0;for(i=0;i<newLength;sourceIndex++,i++){if(sourceIndex===emulationPreventionBytesPositions[0]){sourceIndex++;emulationPreventionBytesPositions.shift()}newData[i]=data[sourceIndex]}return newData};var captionPacketParser={parseSei:parseSei,parseUserData:parseUserData,parseCaptionPackets:parseCaptionPackets,discardEmulationPreventionBytes:discardEmulationPreventionBytes,USER_DATA_REGISTERED_ITU_T_T35:USER_DATA_REGISTERED_ITU_T_T35};var CaptionStream=function CaptionStream(){CaptionStream.prototype.init.call(this);this.captionPackets_=[];this.ccStreams_=[new Cea608Stream(0,0),new Cea608Stream(0,1),new Cea608Stream(1,0),new Cea608Stream(1,1)];this.reset();this.ccStreams_.forEach(function(cc){cc.on("data",this.trigger.bind(this,"data"));cc.on("partialdone",this.trigger.bind(this,"partialdone"));cc.on("done",this.trigger.bind(this,"done"))},this)};CaptionStream.prototype=new stream;CaptionStream.prototype.push=function(event){var sei,userData,newCaptionPackets;if(event.nalUnitType!=="sei_rbsp"){return}sei=captionPacketParser.parseSei(event.escapedRBSP);if(sei.payloadType!==captionPacketParser.USER_DATA_REGISTERED_ITU_T_T35){return}userData=captionPacketParser.parseUserData(sei);if(!userData){return}if(event.dts<this.latestDts_){this.ignoreNextEqualDts_=true;return}else if(event.dts===this.latestDts_&&this.ignoreNextEqualDts_){this.numSameDts_--;if(!this.numSameDts_){this.ignoreNextEqualDts_=false}return}newCaptionPackets=captionPacketParser.parseCaptionPackets(event.pts,userData);this.captionPackets_=this.captionPackets_.concat(newCaptionPackets);if(this.latestDts_!==event.dts){this.numSameDts_=0}this.numSameDts_++;this.latestDts_=event.dts};CaptionStream.prototype.flushCCStreams=function(flushType){this.ccStreams_.forEach(function(cc){return flushType==="flush"?cc.flush():cc.partialFlush()},this)};CaptionStream.prototype.flushStream=function(flushType){if(!this.captionPackets_.length){this.flushCCStreams(flushType);return}this.captionPackets_.forEach(function(elem,idx){elem.presortIndex=idx});this.captionPackets_.sort(function(a,b){if(a.pts===b.pts){return a.presortIndex-b.presortIndex}return a.pts-b.pts});this.captionPackets_.forEach(function(packet){if(packet.type<2){this.dispatchCea608Packet(packet)}},this);this.captionPackets_.length=0;this.flushCCStreams(flushType)};CaptionStream.prototype.flush=function(){return this.flushStream("flush")};CaptionStream.prototype.partialFlush=function(){return this.flushStream("partialFlush")};CaptionStream.prototype.reset=function(){this.latestDts_=null;this.ignoreNextEqualDts_=false;this.numSameDts_=0;this.activeCea608Channel_=[null,null];this.ccStreams_.forEach(function(ccStream){ccStream.reset()})};CaptionStream.prototype.dispatchCea608Packet=function(packet){if(this.setsTextOrXDSActive(packet)){this.activeCea608Channel_[packet.type]=null}else if(this.setsChannel1Active(packet)){this.activeCea608Channel_[packet.type]=0}else if(this.setsChannel2Active(packet)){this.activeCea608Channel_[packet.type]=1}if(this.activeCea608Channel_[packet.type]===null){return}this.ccStreams_[(packet.type<<1)+this.activeCea608Channel_[packet.type]].push(packet)};CaptionStream.prototype.setsChannel1Active=function(packet){return(packet.ccData&30720)===4096};CaptionStream.prototype.setsChannel2Active=function(packet){return(packet.ccData&30720)===6144};CaptionStream.prototype.setsTextOrXDSActive=function(packet){return(packet.ccData&28928)===256||(packet.ccData&30974)===4138||(packet.ccData&30974)===6186};var CHARACTER_TRANSLATION={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496};var getCharFromCode=function getCharFromCode(code){if(code===null){return""}code=CHARACTER_TRANSLATION[code]||code;return String.fromCharCode(code)};var BOTTOM_ROW=14;var ROWS=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152];var createDisplayBuffer=function createDisplayBuffer(){var result=[],i=BOTTOM_ROW+1;while(i--){result.push("")}return result};var Cea608Stream=function Cea608Stream(field,dataChannel){Cea608Stream.prototype.init.call(this);this.field_=field||0;this.dataChannel_=dataChannel||0;this.name_="CC"+((this.field_<<1|this.dataChannel_)+1);this.setConstants();this.reset();this.push=function(packet){var data,swap,char0,char1,text;data=packet.ccData&32639;if(data===this.lastControlCode_){this.lastControlCode_=null;return}if((data&61440)===4096){this.lastControlCode_=data}else if(data!==this.PADDING_){this.lastControlCode_=null}char0=data>>>8;char1=data&255;if(data===this.PADDING_){return}else if(data===this.RESUME_CAPTION_LOADING_){this.mode_="popOn"}else if(data===this.END_OF_CAPTION_){this.mode_="popOn";this.clearFormatting(packet.pts);this.flushDisplayed(packet.pts);swap=this.displayed_;this.displayed_=this.nonDisplayed_;this.nonDisplayed_=swap;this.startPts_=packet.pts}else if(data===this.ROLL_UP_2_ROWS_){this.rollUpRows_=2;this.setRollUp(packet.pts)}else if(data===this.ROLL_UP_3_ROWS_){this.rollUpRows_=3;this.setRollUp(packet.pts)}else if(data===this.ROLL_UP_4_ROWS_){this.rollUpRows_=4;this.setRollUp(packet.pts)}else if(data===this.CARRIAGE_RETURN_){this.clearFormatting(packet.pts);this.flushDisplayed(packet.pts);this.shiftRowsUp_();this.startPts_=packet.pts}else if(data===this.BACKSPACE_){if(this.mode_==="popOn"){this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1)}else{this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1)}}else if(data===this.ERASE_DISPLAYED_MEMORY_){this.flushDisplayed(packet.pts);this.displayed_=createDisplayBuffer()}else if(data===this.ERASE_NON_DISPLAYED_MEMORY_){this.nonDisplayed_=createDisplayBuffer()}else if(data===this.RESUME_DIRECT_CAPTIONING_){if(this.mode_!=="paintOn"){this.flushDisplayed(packet.pts);this.displayed_=createDisplayBuffer()}this.mode_="paintOn";this.startPts_=packet.pts}else if(this.isSpecialCharacter(char0,char1)){char0=(char0&3)<<8;text=getCharFromCode(char0|char1);this[this.mode_](packet.pts,text);this.column_++}else if(this.isExtCharacter(char0,char1)){if(this.mode_==="popOn"){this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1)}else{this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1)}char0=(char0&3)<<8;text=getCharFromCode(char0|char1);this[this.mode_](packet.pts,text);this.column_++}else if(this.isMidRowCode(char0,char1)){this.clearFormatting(packet.pts);this[this.mode_](packet.pts," ");this.column_++;if((char1&14)===14){this.addFormatting(packet.pts,["i"])}if((char1&1)===1){this.addFormatting(packet.pts,["u"])}}else if(this.isOffsetControlCode(char0,char1)){this.column_+=char1&3}else if(this.isPAC(char0,char1)){var row=ROWS.indexOf(data&7968);if(this.mode_==="rollUp"){if(row-this.rollUpRows_+1<0){row=this.rollUpRows_-1}this.setRollUp(packet.pts,row)}if(row!==this.row_){this.clearFormatting(packet.pts);this.row_=row}if(char1&1&&this.formatting_.indexOf("u")===-1){this.addFormatting(packet.pts,["u"])}if((data&16)===16){this.column_=((data&14)>>1)*4}if(this.isColorPAC(char1)){if((char1&14)===14){this.addFormatting(packet.pts,["i"])}}}else if(this.isNormalChar(char0)){if(char1===0){char1=null}text=getCharFromCode(char0);text+=getCharFromCode(char1);this[this.mode_](packet.pts,text);this.column_+=text.length}}};Cea608Stream.prototype=new stream;Cea608Stream.prototype.flushDisplayed=function(pts){var content=this.displayed_.map(function(row){try{return row.trim()}catch(e){console.error("Skipping malformed caption.");return""}}).join("\n").replace(/^\n+|\n+$/g,"");if(content.length){this.trigger("data",{startPts:this.startPts_,endPts:pts,text:content,stream:this.name_})}};Cea608Stream.prototype.reset=function(){this.mode_="popOn";this.topRow_=0;this.startPts_=0;this.displayed_=createDisplayBuffer();this.nonDisplayed_=createDisplayBuffer();this.lastControlCode_=null;this.column_=0;this.row_=BOTTOM_ROW;this.rollUpRows_=2;this.formatting_=[]};Cea608Stream.prototype.setConstants=function(){if(this.dataChannel_===0){this.BASE_=16;this.EXT_=17;this.CONTROL_=(20|this.field_)<<8;this.OFFSET_=23}else if(this.dataChannel_===1){this.BASE_=24;this.EXT_=25;this.CONTROL_=(28|this.field_)<<8;this.OFFSET_=31}this.PADDING_=0;this.RESUME_CAPTION_LOADING_=this.CONTROL_|32;this.END_OF_CAPTION_=this.CONTROL_|47;this.ROLL_UP_2_ROWS_=this.CONTROL_|37;this.ROLL_UP_3_ROWS_=this.CONTROL_|38;this.ROLL_UP_4_ROWS_=this.CONTROL_|39;this.CARRIAGE_RETURN_=this.CONTROL_|45;this.RESUME_DIRECT_CAPTIONING_=this.CONTROL_|41;this.BACKSPACE_=this.CONTROL_|33;this.ERASE_DISPLAYED_MEMORY_=this.CONTROL_|44;this.ERASE_NON_DISPLAYED_MEMORY_=this.CONTROL_|46};Cea608Stream.prototype.isSpecialCharacter=function(char0,char1){return char0===this.EXT_&&char1>=48&&char1<=63};Cea608Stream.prototype.isExtCharacter=function(char0,char1){return(char0===this.EXT_+1||char0===this.EXT_+2)&&char1>=32&&char1<=63};Cea608Stream.prototype.isMidRowCode=function(char0,char1){return char0===this.EXT_&&char1>=32&&char1<=47};Cea608Stream.prototype.isOffsetControlCode=function(char0,char1){return char0===this.OFFSET_&&char1>=33&&char1<=35};Cea608Stream.prototype.isPAC=function(char0,char1){return char0>=this.BASE_&&char0<this.BASE_+8&&char1>=64&&char1<=127};Cea608Stream.prototype.isColorPAC=function(char1){return char1>=64&&char1<=79||char1>=96&&char1<=127};Cea608Stream.prototype.isNormalChar=function(_char){return _char>=32&&_char<=127};Cea608Stream.prototype.setRollUp=function(pts,newBaseRow){if(this.mode_!=="rollUp"){this.row_=BOTTOM_ROW;this.mode_="rollUp";this.flushDisplayed(pts);this.nonDisplayed_=createDisplayBuffer();this.displayed_=createDisplayBuffer()}if(newBaseRow!==undefined&&newBaseRow!==this.row_){for(var i=0;i<this.rollUpRows_;i++){this.displayed_[newBaseRow-i]=this.displayed_[this.row_-i];this.displayed_[this.row_-i]=""}}if(newBaseRow===undefined){newBaseRow=this.row_}this.topRow_=newBaseRow-this.rollUpRows_+1};Cea608Stream.prototype.addFormatting=function(pts,format){this.formatting_=this.formatting_.concat(format);var text=format.reduce(function(text,format){return text+"<"+format+">"},"");this[this.mode_](pts,text)};Cea608Stream.prototype.clearFormatting=function(pts){if(!this.formatting_.length){return}var text=this.formatting_.reverse().reduce(function(text,format){return text+"</"+format+">"},"");this.formatting_=[];this[this.mode_](pts,text)};Cea608Stream.prototype.popOn=function(pts,text){var baseRow=this.nonDisplayed_[this.row_];baseRow+=text;this.nonDisplayed_[this.row_]=baseRow};Cea608Stream.prototype.rollUp=function(pts,text){var baseRow=this.displayed_[this.row_];baseRow+=text;this.displayed_[this.row_]=baseRow};Cea608Stream.prototype.shiftRowsUp_=function(){var i;for(i=0;i<this.topRow_;i++){this.displayed_[i]=""}for(i=this.row_+1;i<BOTTOM_ROW+1;i++){this.displayed_[i]=""}for(i=this.topRow_;i<this.row_;i++){this.displayed_[i]=this.displayed_[i+1]}this.displayed_[this.row_]=""};Cea608Stream.prototype.paintOn=function(pts,text){var baseRow=this.displayed_[this.row_];baseRow+=text;this.displayed_[this.row_]=baseRow};var captionStream={CaptionStream:CaptionStream,Cea608Stream:Cea608Stream};var streamTypes={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21};var MAX_TS=8589934592;var RO_THRESH=4294967296;var TYPE_SHARED="shared";var handleRollover=function handleRollover(value,reference){var direction=1;if(value>reference){direction=-1}while(Math.abs(reference-value)>RO_THRESH){value+=direction*MAX_TS}return value};var TimestampRolloverStream=function TimestampRolloverStream(type){var lastDTS,referenceDTS;TimestampRolloverStream.prototype.init.call(this);this.type_=type||TYPE_SHARED;this.push=function(data){if(this.type_!==TYPE_SHARED&&data.type!==this.type_){return}if(referenceDTS===undefined){referenceDTS=data.dts}data.dts=handleRollover(data.dts,referenceDTS);data.pts=handleRollover(data.pts,referenceDTS);lastDTS=data.dts;this.trigger("data",data)};this.flush=function(){referenceDTS=lastDTS;this.trigger("done")};this.endTimeline=function(){this.flush();this.trigger("endedtimeline")};this.discontinuity=function(){referenceDTS=void 0;lastDTS=void 0};this.reset=function(){this.discontinuity();this.trigger("reset")}};TimestampRolloverStream.prototype=new stream;var timestampRolloverStream={TimestampRolloverStream:TimestampRolloverStream,handleRollover:handleRollover};var percentEncode=function percentEncode(bytes,start,end){var i,result="";for(i=start;i<end;i++){result+="%"+("00"+bytes[i].toString(16)).slice(-2)}return result},parseUtf8=function parseUtf8(bytes,start,end){return decodeURIComponent(percentEncode(bytes,start,end))},parseIso88591=function parseIso88591(bytes,start,end){return unescape(percentEncode(bytes,start,end))},parseSyncSafeInteger=function parseSyncSafeInteger(data){return data[0]<<21|data[1]<<14|data[2]<<7|data[3]},tagParsers={TXXX:function TXXX(tag){var i;if(tag.data[0]!==3){return}for(i=1;i<tag.data.length;i++){if(tag.data[i]===0){tag.description=parseUtf8(tag.data,1,i);tag.value=parseUtf8(tag.data,i+1,tag.data.length).replace(/\0*$/,"");break}}tag.data=tag.value},WXXX:function WXXX(tag){var i;if(tag.data[0]!==3){return}for(i=1;i<tag.data.length;i++){if(tag.data[i]===0){tag.description=parseUtf8(tag.data,1,i);tag.url=parseUtf8(tag.data,i+1,tag.data.length);break}}},PRIV:function PRIV(tag){var i;for(i=0;i<tag.data.length;i++){if(tag.data[i]===0){tag.owner=parseIso88591(tag.data,0,i);break}}tag.privateData=tag.data.subarray(i+1);tag.data=tag.privateData}},_MetadataStream;_MetadataStream=function MetadataStream(options){var settings={debug:!!(options&&options.debug),descriptor:options&&options.descriptor},tagSize=0,buffer=[],bufferSize=0,i;_MetadataStream.prototype.init.call(this);this.dispatchType=streamTypes.METADATA_STREAM_TYPE.toString(16);if(settings.descriptor){for(i=0;i<settings.descriptor.length;i++){this.dispatchType+=("00"+settings.descriptor[i].toString(16)).slice(-2)}}this.push=function(chunk){var tag,frameStart,frameSize,frame,i,frameHeader;if(chunk.type!=="timed-metadata"){return}if(chunk.dataAlignmentIndicator){bufferSize=0;buffer.length=0}if(buffer.length===0&&(chunk.data.length<10||chunk.data[0]!=="I".charCodeAt(0)||chunk.data[1]!=="D".charCodeAt(0)||chunk.data[2]!=="3".charCodeAt(0))){if(settings.debug){console.log("Skipping unrecognized metadata packet")}return}buffer.push(chunk);bufferSize+=chunk.data.byteLength;if(buffer.length===1){tagSize=parseSyncSafeInteger(chunk.data.subarray(6,10));tagSize+=10}if(bufferSize<tagSize){return}tag={data:new Uint8Array(tagSize),frames:[],pts:buffer[0].pts,dts:buffer[0].dts};for(i=0;i<tagSize;){tag.data.set(buffer[0].data.subarray(0,tagSize-i),i);i+=buffer[0].data.byteLength;bufferSize-=buffer[0].data.byteLength;buffer.shift()}frameStart=10;if(tag.data[5]&64){frameStart+=4;frameStart+=parseSyncSafeInteger(tag.data.subarray(10,14));tagSize-=parseSyncSafeInteger(tag.data.subarray(16,20))}do{frameSize=parseSyncSafeInteger(tag.data.subarray(frameStart+4,frameStart+8));if(frameSize<1){return console.log("Malformed ID3 frame encountered. Skipping metadata parsing.")}frameHeader=String.fromCharCode(tag.data[frameStart],tag.data[frameStart+1],tag.data[frameStart+2],tag.data[frameStart+3]);frame={id:frameHeader,data:tag.data.subarray(frameStart+10,frameStart+frameSize+10)};frame.key=frame.id;if(tagParsers[frame.id]){tagParsers[frame.id](frame);if(frame.owner==="com.apple.streaming.transportStreamTimestamp"){var d=frame.data,size=(d[3]&1)<<30|d[4]<<22|d[5]<<14|d[6]<<6|d[7]>>>2;size*=4;size+=d[7]&3;frame.timeStamp=size;if(tag.pts===undefined&&tag.dts===undefined){tag.pts=frame.timeStamp;tag.dts=frame.timeStamp}this.trigger("timestamp",frame)}}tag.frames.push(frame);frameStart+=10;frameStart+=frameSize}while(frameStart<tagSize);this.trigger("data",tag)}};_MetadataStream.prototype=new stream;var metadataStream=_MetadataStream;var TimestampRolloverStream$1=timestampRolloverStream.TimestampRolloverStream;var _TransportPacketStream,_TransportParseStream,_ElementaryStream;var MP2T_PACKET_LENGTH=188,SYNC_BYTE=71;_TransportPacketStream=function TransportPacketStream(){var buffer=new Uint8Array(MP2T_PACKET_LENGTH),bytesInBuffer=0;_TransportPacketStream.prototype.init.call(this);this.push=function(bytes){var startIndex=0,endIndex=MP2T_PACKET_LENGTH,everything;if(bytesInBuffer){everything=new Uint8Array(bytes.byteLength+bytesInBuffer);everything.set(buffer.subarray(0,bytesInBuffer));everything.set(bytes,bytesInBuffer);bytesInBuffer=0}else{everything=bytes}while(endIndex<everything.byteLength){if(everything[startIndex]===SYNC_BYTE&&everything[endIndex]===SYNC_BYTE){this.trigger("data",everything.subarray(startIndex,endIndex));startIndex+=MP2T_PACKET_LENGTH;endIndex+=MP2T_PACKET_LENGTH;continue}startIndex++;endIndex++}if(startIndex<everything.byteLength){buffer.set(everything.subarray(startIndex),0);bytesInBuffer=everything.byteLength-startIndex}};this.flush=function(){if(bytesInBuffer===MP2T_PACKET_LENGTH&&buffer[0]===SYNC_BYTE){this.trigger("data",buffer);bytesInBuffer=0}this.trigger("done")};this.endTimeline=function(){this.flush();this.trigger("endedtimeline")};this.reset=function(){bytesInBuffer=0;this.trigger("reset")}};_TransportPacketStream.prototype=new stream;_TransportParseStream=function TransportParseStream(){var parsePsi,parsePat,parsePmt,self;_TransportParseStream.prototype.init.call(this);self=this;this.packetsWaitingForPmt=[];this.programMapTable=undefined;parsePsi=function parsePsi(payload,psi){var offset=0;if(psi.payloadUnitStartIndicator){offset+=payload[offset]+1}if(psi.type==="pat"){parsePat(payload.subarray(offset),psi)}else{parsePmt(payload.subarray(offset),psi)}};parsePat=function parsePat(payload,pat){pat.section_number=payload[7];pat.last_section_number=payload[8];self.pmtPid=(payload[10]&31)<<8|payload[11];pat.pmtPid=self.pmtPid};parsePmt=function parsePmt(payload,pmt){var sectionLength,tableEnd,programInfoLength,offset;if(!(payload[5]&1)){return}self.programMapTable={video:null,audio:null,"timed-metadata":{}};sectionLength=(payload[1]&15)<<8|payload[2];tableEnd=3+sectionLength-4;programInfoLength=(payload[10]&15)<<8|payload[11];offset=12+programInfoLength;while(offset<tableEnd){var streamType=payload[offset];var pid=(payload[offset+1]&31)<<8|payload[offset+2];if(streamType===streamTypes.H264_STREAM_TYPE&&self.programMapTable.video===null){self.programMapTable.video=pid}else if(streamType===streamTypes.ADTS_STREAM_TYPE&&self.programMapTable.audio===null){self.programMapTable.audio=pid}else if(streamType===streamTypes.METADATA_STREAM_TYPE){self.programMapTable["timed-metadata"][pid]=streamType}offset+=((payload[offset+3]&15)<<8|payload[offset+4])+5}pmt.programMapTable=self.programMapTable};this.push=function(packet){var result={},offset=4;result.payloadUnitStartIndicator=!!(packet[1]&64);result.pid=packet[1]&31;result.pid<<=8;result.pid|=packet[2];if((packet[3]&48)>>>4>1){offset+=packet[offset]+1}if(result.pid===0){result.type="pat";parsePsi(packet.subarray(offset),result);this.trigger("data",result)}else if(result.pid===this.pmtPid){result.type="pmt";parsePsi(packet.subarray(offset),result);this.trigger("data",result);while(this.packetsWaitingForPmt.length){this.processPes_.apply(this,this.packetsWaitingForPmt.shift())}}else if(this.programMapTable===undefined){this.packetsWaitingForPmt.push([packet,offset,result])}else{this.processPes_(packet,offset,result)}};this.processPes_=function(packet,offset,result){if(result.pid===this.programMapTable.video){result.streamType=streamTypes.H264_STREAM_TYPE}else if(result.pid===this.programMapTable.audio){result.streamType=streamTypes.ADTS_STREAM_TYPE}else{result.streamType=this.programMapTable["timed-metadata"][result.pid]}result.type="pes";result.data=packet.subarray(offset);this.trigger("data",result)}};_TransportParseStream.prototype=new stream;_TransportParseStream.STREAM_TYPES={h264:27,adts:15};_ElementaryStream=function ElementaryStream(){var self=this,video={data:[],size:0},audio={data:[],size:0},timedMetadata={data:[],size:0},programMapTable,parsePes=function parsePes(payload,pes){var ptsDtsFlags;pes.packetLength=6+(payload[4]<<8|payload[5]);pes.dataAlignmentIndicator=(payload[6]&4)!==0;ptsDtsFlags=payload[7];if(ptsDtsFlags&192){pes.pts=(payload[9]&14)<<27|(payload[10]&255)<<20|(payload[11]&254)<<12|(payload[12]&255)<<5|(payload[13]&254)>>>3;pes.pts*=4;pes.pts+=(payload[13]&6)>>>1;pes.dts=pes.pts;if(ptsDtsFlags&64){pes.dts=(payload[14]&14)<<27|(payload[15]&255)<<20|(payload[16]&254)<<12|(payload[17]&255)<<5|(payload[18]&254)>>>3;pes.dts*=4;pes.dts+=(payload[18]&6)>>>1}}pes.data=payload.subarray(9+payload[8])},flushStream=function flushStream(stream$$1,type,forceFlush){var packetData=new Uint8Array(stream$$1.size),event={type:type},i=0,offset=0,packetFlushable=false,fragment;if(!stream$$1.data.length||stream$$1.size<9){return}event.trackId=stream$$1.data[0].pid;for(i=0;i<stream$$1.data.length;i++){fragment=stream$$1.data[i];packetData.set(fragment.data,offset);offset+=fragment.data.byteLength}parsePes(packetData,event);packetFlushable=type==="video"||event.packetLength<=stream$$1.size;if(forceFlush||packetFlushable){stream$$1.size=0;stream$$1.data.length=0}if(packetFlushable){self.trigger("data",event)}};_ElementaryStream.prototype.init.call(this);this.push=function(data){({pat:function pat(){},pes:function pes(){var stream$$1,streamType;switch(data.streamType){case streamTypes.H264_STREAM_TYPE:case streamTypes.H264_STREAM_TYPE:stream$$1=video;streamType="video";break;case streamTypes.ADTS_STREAM_TYPE:stream$$1=audio;streamType="audio";break;case streamTypes.METADATA_STREAM_TYPE:stream$$1=timedMetadata;streamType="timed-metadata";break;default:return}if(data.payloadUnitStartIndicator){flushStream(stream$$1,streamType,true)}stream$$1.data.push(data);stream$$1.size+=data.data.byteLength},pmt:function pmt(){var event={type:"metadata",tracks:[]};programMapTable=data.programMapTable;if(programMapTable.video!==null){event.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+programMapTable.video,codec:"avc",type:"video"})}if(programMapTable.audio!==null){event.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+programMapTable.audio,codec:"adts",type:"audio"})}self.trigger("data",event)}})[data.type]()};this.reset=function(){video.size=0;video.data.length=0;audio.size=0;audio.data.length=0;this.trigger("reset")};this.flushStreams_=function(){flushStream(video,"video");flushStream(audio,"audio");flushStream(timedMetadata,"timed-metadata")};this.flush=function(){this.flushStreams_();this.trigger("done")}};_ElementaryStream.prototype=new stream;var m2ts={PAT_PID:0,MP2T_PACKET_LENGTH:MP2T_PACKET_LENGTH,TransportPacketStream:_TransportPacketStream,TransportParseStream:_TransportParseStream,ElementaryStream:_ElementaryStream,TimestampRolloverStream:TimestampRolloverStream$1,CaptionStream:captionStream.CaptionStream,Cea608Stream:captionStream.Cea608Stream,MetadataStream:metadataStream};for(var type in streamTypes){if(streamTypes.hasOwnProperty(type)){m2ts[type]=streamTypes[type]}}var m2ts_1=m2ts;var ONE_SECOND_IN_TS$2=clock.ONE_SECOND_IN_TS;var _AdtsStream;var ADTS_SAMPLING_FREQUENCIES=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];_AdtsStream=function AdtsStream(handlePartialSegments){var buffer,frameNum=0;_AdtsStream.prototype.init.call(this);this.push=function(packet){var i=0,frameLength,protectionSkipBytes,frameEnd,oldBuffer,sampleCount,adtsFrameDuration;if(!handlePartialSegments){frameNum=0}if(packet.type!=="audio"){return}if(buffer){oldBuffer=buffer;buffer=new Uint8Array(oldBuffer.byteLength+packet.data.byteLength);buffer.set(oldBuffer);buffer.set(packet.data,oldBuffer.byteLength)}else{buffer=packet.data}while(i+5<buffer.length){if(buffer[i]!==255||(buffer[i+1]&246)!==240){i++;continue}protectionSkipBytes=(~buffer[i+1]&1)*2;frameLength=(buffer[i+3]&3)<<11|buffer[i+4]<<3|(buffer[i+5]&224)>>5;sampleCount=((buffer[i+6]&3)+1)*1024;adtsFrameDuration=sampleCount*ONE_SECOND_IN_TS$2/ADTS_SAMPLING_FREQUENCIES[(buffer[i+2]&60)>>>2];frameEnd=i+frameLength;if(buffer.byteLength<frameEnd){return}this.trigger("data",{pts:packet.pts+frameNum*adtsFrameDuration,dts:packet.dts+frameNum*adtsFrameDuration,sampleCount:sampleCount,audioobjecttype:(buffer[i+2]>>>6&3)+1,channelcount:(buffer[i+2]&1)<<2|(buffer[i+3]&192)>>>6,samplerate:ADTS_SAMPLING_FREQUENCIES[(buffer[i+2]&60)>>>2],samplingfrequencyindex:(buffer[i+2]&60)>>>2,samplesize:16,data:buffer.subarray(i+7+protectionSkipBytes,frameEnd)});frameNum++;if(buffer.byteLength===frameEnd){buffer=undefined;return}buffer=buffer.subarray(frameEnd)}};this.flush=function(){frameNum=0;this.trigger("done")};this.reset=function(){buffer=void 0;this.trigger("reset")};this.endTimeline=function(){buffer=void 0;this.trigger("endedtimeline")}};_AdtsStream.prototype=new stream;var adts=_AdtsStream;var ExpGolomb;ExpGolomb=function ExpGolomb(workingData){var workingBytesAvailable=workingData.byteLength,workingWord=0,workingBitsAvailable=0;this.length=function(){return 8*workingBytesAvailable};this.bitsAvailable=function(){return 8*workingBytesAvailable+workingBitsAvailable};this.loadWord=function(){var position=workingData.byteLength-workingBytesAvailable,workingBytes=new Uint8Array(4),availableBytes=Math.min(4,workingBytesAvailable);if(availableBytes===0){throw new Error("no bytes available")}workingBytes.set(workingData.subarray(position,position+availableBytes));workingWord=new DataView(workingBytes.buffer).getUint32(0);workingBitsAvailable=availableBytes*8;workingBytesAvailable-=availableBytes};this.skipBits=function(count){var skipBytes;if(workingBitsAvailable>count){workingWord<<=count;workingBitsAvailable-=count}else{count-=workingBitsAvailable;skipBytes=Math.floor(count/8);count-=skipBytes*8;workingBytesAvailable-=skipBytes;this.loadWord();workingWord<<=count;workingBitsAvailable-=count}};this.readBits=function(size){var bits=Math.min(workingBitsAvailable,size),valu=workingWord>>>32-bits;workingBitsAvailable-=bits;if(workingBitsAvailable>0){workingWord<<=bits}else if(workingBytesAvailable>0){this.loadWord()}bits=size-bits;if(bits>0){return valu<<bits|this.readBits(bits)}return valu};this.skipLeadingZeros=function(){var leadingZeroCount;for(leadingZeroCount=0;leadingZeroCount<workingBitsAvailable;++leadingZeroCount){if((workingWord&2147483648>>>leadingZeroCount)!==0){workingWord<<=leadingZeroCount;workingBitsAvailable-=leadingZeroCount;return leadingZeroCount}}this.loadWord();return leadingZeroCount+this.skipLeadingZeros()};this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())};this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())};this.readUnsignedExpGolomb=function(){var clz=this.skipLeadingZeros();return this.readBits(clz+1)-1};this.readExpGolomb=function(){var valu=this.readUnsignedExpGolomb();if(1&valu){return 1+valu>>>1}return-1*(valu>>>1)};this.readBoolean=function(){return this.readBits(1)===1};this.readUnsignedByte=function(){return this.readBits(8)};this.loadWord()};var expGolomb=ExpGolomb;var _H264Stream,_NalByteStream;var PROFILES_WITH_OPTIONAL_SPS_DATA;_NalByteStream=function NalByteStream(){var syncPoint=0,i,buffer;_NalByteStream.prototype.init.call(this);this.push=function(data){var swapBuffer;if(!buffer){buffer=data.data}else{swapBuffer=new Uint8Array(buffer.byteLength+data.data.byteLength);swapBuffer.set(buffer);swapBuffer.set(data.data,buffer.byteLength);buffer=swapBuffer}var len=buffer.byteLength;for(;syncPoint<len-3;syncPoint++){if(buffer[syncPoint+2]===1){i=syncPoint+5;break}}while(i<len){switch(buffer[i]){case 0:if(buffer[i-1]!==0){i+=2;break}else if(buffer[i-2]!==0){i++;break}if(syncPoint+3!==i-2){this.trigger("data",buffer.subarray(syncPoint+3,i-2))}do{i++}while(buffer[i]!==1&&i<len);syncPoint=i-2;i+=3;break;case 1:if(buffer[i-1]!==0||buffer[i-2]!==0){i+=3;break}this.trigger("data",buffer.subarray(syncPoint+3,i-2));syncPoint=i-2;i+=3;break;default:i+=3;break}}buffer=buffer.subarray(syncPoint);i-=syncPoint;syncPoint=0};this.reset=function(){buffer=null;syncPoint=0;this.trigger("reset")};this.flush=function(){if(buffer&&buffer.byteLength>3){this.trigger("data",buffer.subarray(syncPoint+3))}buffer=null;syncPoint=0;this.trigger("done")};this.endTimeline=function(){this.flush();this.trigger("endedtimeline")}};_NalByteStream.prototype=new stream;PROFILES_WITH_OPTIONAL_SPS_DATA={100:true,110:true,122:true,244:true,44:true,83:true,86:true,118:true,128:true,138:true,139:true,134:true};_H264Stream=function H264Stream(){var nalByteStream=new _NalByteStream,self,trackId,currentPts,currentDts,discardEmulationPreventionBytes,readSequenceParameterSet,skipScalingList;_H264Stream.prototype.init.call(this);self=this;this.push=function(packet){if(packet.type!=="video"){return}trackId=packet.trackId;currentPts=packet.pts;currentDts=packet.dts;nalByteStream.push(packet)};nalByteStream.on("data",function(data){var event={trackId:trackId,pts:currentPts,dts:currentDts,data:data};switch(data[0]&31){case 5:event.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:event.nalUnitType="sei_rbsp";event.escapedRBSP=discardEmulationPreventionBytes(data.subarray(1));break;case 7:event.nalUnitType="seq_parameter_set_rbsp";event.escapedRBSP=discardEmulationPreventionBytes(data.subarray(1));event.config=readSequenceParameterSet(event.escapedRBSP);break;case 8:event.nalUnitType="pic_parameter_set_rbsp";break;case 9:event.nalUnitType="access_unit_delimiter_rbsp";break;default:break}self.trigger("data",event)});nalByteStream.on("done",function(){self.trigger("done")});nalByteStream.on("partialdone",function(){self.trigger("partialdone")});nalByteStream.on("reset",function(){self.trigger("reset")});nalByteStream.on("endedtimeline",function(){self.trigger("endedtimeline")});this.flush=function(){nalByteStream.flush()};this.partialFlush=function(){nalByteStream.partialFlush()};this.reset=function(){nalByteStream.reset()};this.endTimeline=function(){nalByteStream.endTimeline()};skipScalingList=function skipScalingList(count,expGolombDecoder){var lastScale=8,nextScale=8,j,deltaScale;for(j=0;j<count;j++){if(nextScale!==0){deltaScale=expGolombDecoder.readExpGolomb();nextScale=(lastScale+deltaScale+256)%256}lastScale=nextScale===0?lastScale:nextScale}};discardEmulationPreventionBytes=function discardEmulationPreventionBytes(data){var length=data.byteLength,emulationPreventionBytesPositions=[],i=1,newLength,newData;while(i<length-2){if(data[i]===0&&data[i+1]===0&&data[i+2]===3){emulationPreventionBytesPositions.push(i+2);i+=2}else{i++}}if(emulationPreventionBytesPositions.length===0){return data}newLength=length-emulationPreventionBytesPositions.length;newData=new Uint8Array(newLength);var sourceIndex=0;for(i=0;i<newLength;sourceIndex++,i++){if(sourceIndex===emulationPreventionBytesPositions[0]){sourceIndex++;emulationPreventionBytesPositions.shift()}newData[i]=data[sourceIndex]}return newData};readSequenceParameterSet=function readSequenceParameterSet(data){var frameCropLeftOffset=0,frameCropRightOffset=0,frameCropTopOffset=0,frameCropBottomOffset=0,sarScale=1,expGolombDecoder,profileIdc,levelIdc,profileCompatibility,chromaFormatIdc,picOrderCntType,numRefFramesInPicOrderCntCycle,picWidthInMbsMinus1,picHeightInMapUnitsMinus1,frameMbsOnlyFlag,scalingListCount,sarRatio,aspectRatioIdc,i;expGolombDecoder=new expGolomb(data);profileIdc=expGolombDecoder.readUnsignedByte();profileCompatibility=expGolombDecoder.readUnsignedByte();levelIdc=expGolombDecoder.readUnsignedByte();expGolombDecoder.skipUnsignedExpGolomb();if(PROFILES_WITH_OPTIONAL_SPS_DATA[profileIdc]){chromaFormatIdc=expGolombDecoder.readUnsignedExpGolomb();if(chromaFormatIdc===3){expGolombDecoder.skipBits(1)}expGolombDecoder.skipUnsignedExpGolomb();expGolombDecoder.skipUnsignedExpGolomb();expGolombDecoder.skipBits(1);if(expGolombDecoder.readBoolean()){scalingListCount=chromaFormatIdc!==3?8:12;for(i=0;i<scalingListCount;i++){if(expGolombDecoder.readBoolean()){if(i<6){skipScalingList(16,expGolombDecoder)}else{skipScalingList(64,expGolombDecoder)}}}}}expGolombDecoder.skipUnsignedExpGolomb();picOrderCntType=expGolombDecoder.readUnsignedExpGolomb();if(picOrderCntType===0){expGolombDecoder.readUnsignedExpGolomb()}else if(picOrderCntType===1){expGolombDecoder.skipBits(1);expGolombDecoder.skipExpGolomb();expGolombDecoder.skipExpGolomb();numRefFramesInPicOrderCntCycle=expGolombDecoder.readUnsignedExpGolomb();for(i=0;i<numRefFramesInPicOrderCntCycle;i++){expGolombDecoder.skipExpGolomb()}}expGolombDecoder.skipUnsignedExpGolomb();expGolombDecoder.skipBits(1);picWidthInMbsMinus1=expGolombDecoder.readUnsignedExpGolomb();picHeightInMapUnitsMinus1=expGolombDecoder.readUnsignedExpGolomb();frameMbsOnlyFlag=expGolombDecoder.readBits(1);if(frameMbsOnlyFlag===0){expGolombDecoder.skipBits(1)}expGolombDecoder.skipBits(1);if(expGolombDecoder.readBoolean()){frameCropLeftOffset=expGolombDecoder.readUnsignedExpGolomb();frameCropRightOffset=expGolombDecoder.readUnsignedExpGolomb();frameCropTopOffset=expGolombDecoder.readUnsignedExpGolomb();frameCropBottomOffset=expGolombDecoder.readUnsignedExpGolomb()}if(expGolombDecoder.readBoolean()){if(expGolombDecoder.readBoolean()){aspectRatioIdc=expGolombDecoder.readUnsignedByte();switch(aspectRatioIdc){case 1:sarRatio=[1,1];break;case 2:sarRatio=[12,11];break;case 3:sarRatio=[10,11];break;case 4:sarRatio=[16,11];break;case 5:sarRatio=[40,33];break;case 6:sarRatio=[24,11];break;case 7:sarRatio=[20,11];break;case 8:sarRatio=[32,11];break;case 9:sarRatio=[80,33];break;case 10:sarRatio=[18,11];break;case 11:sarRatio=[15,11];break;case 12:sarRatio=[64,33];break;case 13:sarRatio=[160,99];break;case 14:sarRatio=[4,3];break;case 15:sarRatio=[3,2];break;case 16:sarRatio=[2,1];break;case 255:{sarRatio=[expGolombDecoder.readUnsignedByte()<<8|expGolombDecoder.readUnsignedByte(),expGolombDecoder.readUnsignedByte()<<8|expGolombDecoder.readUnsignedByte()];break}}if(sarRatio){sarScale=sarRatio[0]/sarRatio[1]}}}return{profileIdc:profileIdc,levelIdc:levelIdc,profileCompatibility:profileCompatibility,width:Math.ceil(((picWidthInMbsMinus1+1)*16-frameCropLeftOffset*2-frameCropRightOffset*2)*sarScale),height:(2-frameMbsOnlyFlag)*(picHeightInMapUnitsMinus1+1)*16-frameCropTopOffset*2-frameCropBottomOffset*2,sarRatio:sarRatio}}};_H264Stream.prototype=new stream;var h264={H264Stream:_H264Stream,NalByteStream:_NalByteStream};var ADTS_SAMPLING_FREQUENCIES$1=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];var isLikelyAacData=function isLikelyAacData(data){if(data[0]==="I".charCodeAt(0)&&data[1]==="D".charCodeAt(0)&&data[2]==="3".charCodeAt(0)){return true}return false};var parseSyncSafeInteger$1=function parseSyncSafeInteger(data){return data[0]<<21|data[1]<<14|data[2]<<7|data[3]};var percentEncode$1=function percentEncode(bytes,start,end){var i,result="";for(i=start;i<end;i++){result+="%"+("00"+bytes[i].toString(16)).slice(-2)}return result};var parseIso88591$1=function parseIso88591(bytes,start,end){return unescape(percentEncode$1(bytes,start,end))};var parseId3TagSize=function parseId3TagSize(header,byteIndex){var returnSize=header[byteIndex+6]<<21|header[byteIndex+7]<<14|header[byteIndex+8]<<7|header[byteIndex+9],flags=header[byteIndex+5],footerPresent=(flags&16)>>4;if(footerPresent){return returnSize+20}return returnSize+10};var parseAdtsSize=function parseAdtsSize(header,byteIndex){var lowThree=(header[byteIndex+5]&224)>>5,middle=header[byteIndex+4]<<3,highTwo=header[byteIndex+3]&3<<11;return highTwo|middle|lowThree};var parseType=function parseType(header,byteIndex){if(header[byteIndex]==="I".charCodeAt(0)&&header[byteIndex+1]==="D".charCodeAt(0)&&header[byteIndex+2]==="3".charCodeAt(0)){return"timed-metadata"}else if(header[byteIndex]&255===255&&(header[byteIndex+1]&240)===240){return"audio"}return null};var parseSampleRate=function parseSampleRate(packet){var i=0;while(i+5<packet.length){if(packet[i]!==255||(packet[i+1]&246)!==240){i++;continue}return ADTS_SAMPLING_FREQUENCIES$1[(packet[i+2]&60)>>>2]}return null};var parseAacTimestamp=function parseAacTimestamp(packet){var frameStart,frameSize,frame,frameHeader;frameStart=10;if(packet[5]&64){frameStart+=4;frameStart+=parseSyncSafeInteger$1(packet.subarray(10,14))}do{frameSize=parseSyncSafeInteger$1(packet.subarray(frameStart+4,frameStart+8));if(frameSize<1){return null}frameHeader=String.fromCharCode(packet[frameStart],packet[frameStart+1],packet[frameStart+2],packet[frameStart+3]);if(frameHeader==="PRIV"){frame=packet.subarray(frameStart+10,frameStart+frameSize+10);for(var i=0;i<frame.byteLength;i++){if(frame[i]===0){var owner=parseIso88591$1(frame,0,i);if(owner==="com.apple.streaming.transportStreamTimestamp"){var d=frame.subarray(i+1);var size=(d[3]&1)<<30|d[4]<<22|d[5]<<14|d[6]<<6|d[7]>>>2;size*=4;size+=d[7]&3;return size}break}}}frameStart+=10;frameStart+=frameSize}while(frameStart<packet.byteLength);return null};var utils={isLikelyAacData:isLikelyAacData,parseId3TagSize:parseId3TagSize,parseAdtsSize:parseAdtsSize,parseType:parseType,parseSampleRate:parseSampleRate,parseAacTimestamp:parseAacTimestamp};var _AacStream;_AacStream=function AacStream(){var everything=new Uint8Array,timeStamp=0;_AacStream.prototype.init.call(this);this.setTimestamp=function(timestamp){timeStamp=timestamp};this.push=function(bytes){var frameSize=0,byteIndex=0,bytesLeft,chunk,packet,tempLength;if(everything.length){tempLength=everything.length;everything=new Uint8Array(bytes.byteLength+tempLength);everything.set(everything.subarray(0,tempLength));everything.set(bytes,tempLength)}else{everything=bytes}while(everything.length-byteIndex>=3){if(everything[byteIndex]==="I".charCodeAt(0)&&everything[byteIndex+1]==="D".charCodeAt(0)&&everything[byteIndex+2]==="3".charCodeAt(0)){if(everything.length-byteIndex<10){break}frameSize=utils.parseId3TagSize(everything,byteIndex);if(byteIndex+frameSize>everything.length){break}chunk={type:"timed-metadata",data:everything.subarray(byteIndex,byteIndex+frameSize)};this.trigger("data",chunk);byteIndex+=frameSize;continue}else if((everything[byteIndex]&255)===255&&(everything[byteIndex+1]&240)===240){if(everything.length-byteIndex<7){break}frameSize=utils.parseAdtsSize(everything,byteIndex);if(byteIndex+frameSize>everything.length){break}packet={type:"audio",data:everything.subarray(byteIndex,byteIndex+frameSize),pts:timeStamp,dts:timeStamp};this.trigger("data",packet);byteIndex+=frameSize;continue}byteIndex++}bytesLeft=everything.length-byteIndex;if(bytesLeft>0){everything=everything.subarray(byteIndex)}else{everything=new Uint8Array}};this.reset=function(){everything=new Uint8Array;this.trigger("reset")};this.endTimeline=function(){everything=new Uint8Array;this.trigger("endedtimeline")}};_AacStream.prototype=new stream;var aac=_AacStream;var H264Stream=h264.H264Stream;var isLikelyAacData$1=utils.isLikelyAacData;var ONE_SECOND_IN_TS$3=clock.ONE_SECOND_IN_TS;var AUDIO_PROPERTIES=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"];var VIDEO_PROPERTIES=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"];var _VideoSegmentStream,_AudioSegmentStream,_Transmuxer,_CoalesceStream;var arrayEquals=function arrayEquals(a,b){var i;if(a.length!==b.length){return false}for(i=0;i<a.length;i++){if(a[i]!==b[i]){return false}}return true};var generateVideoSegmentTimingInfo=function generateVideoSegmentTimingInfo(baseMediaDecodeTime,startDts,startPts,endDts,endPts,prependedContentDuration){var ptsOffsetFromDts=startPts-startDts,decodeDuration=endDts-startDts,presentationDuration=endPts-startPts;return{start:{dts:baseMediaDecodeTime,pts:baseMediaDecodeTime+ptsOffsetFromDts},end:{dts:baseMediaDecodeTime+decodeDuration,pts:baseMediaDecodeTime+presentationDuration},prependedContentDuration:prependedContentDuration,baseMediaDecodeTime:baseMediaDecodeTime}};_AudioSegmentStream=function AudioSegmentStream(track,options){var adtsFrames=[],sequenceNumber=0,earliestAllowedDts=0,audioAppendStartTs=0,videoBaseMediaDecodeTime=Infinity;options=options||{};_AudioSegmentStream.prototype.init.call(this);this.push=function(data){trackDecodeInfo.collectDtsInfo(track,data);if(track){AUDIO_PROPERTIES.forEach(function(prop){track[prop]=data[prop]})}adtsFrames.push(data)};this.setEarliestDts=function(earliestDts){earliestAllowedDts=earliestDts-track.timelineStartInfo.baseMediaDecodeTime};this.setVideoBaseMediaDecodeTime=function(baseMediaDecodeTime){videoBaseMediaDecodeTime=baseMediaDecodeTime};this.setAudioAppendStart=function(timestamp){audioAppendStartTs=timestamp};this.flush=function(){var frames,moof,mdat,boxes,frameDuration;if(adtsFrames.length===0){this.trigger("done","AudioSegmentStream");return}frames=audioFrameUtils.trimAdtsFramesByEarliestDts(adtsFrames,track,earliestAllowedDts);track.baseMediaDecodeTime=trackDecodeInfo.calculateTrackBaseMediaDecodeTime(track,options.keepOriginalTimestamps);audioFrameUtils.prefixWithSilence(track,frames,audioAppendStartTs,videoBaseMediaDecodeTime);track.samples=audioFrameUtils.generateSampleTable(frames);mdat=mp4Generator.mdat(audioFrameUtils.concatenateFrameData(frames));adtsFrames=[];moof=mp4Generator.moof(sequenceNumber,[track]);boxes=new Uint8Array(moof.byteLength+mdat.byteLength);sequenceNumber++;boxes.set(moof);boxes.set(mdat,moof.byteLength);trackDecodeInfo.clearDtsInfo(track);frameDuration=Math.ceil(ONE_SECOND_IN_TS$3*1024/track.samplerate);if(frames.length){this.trigger("timingInfo",{start:frames[0].dts,end:frames[0].dts+frames.length*frameDuration})}this.trigger("data",{track:track,boxes:boxes});this.trigger("done","AudioSegmentStream")};this.reset=function(){trackDecodeInfo.clearDtsInfo(track);adtsFrames=[];this.trigger("reset")}};_AudioSegmentStream.prototype=new stream;_VideoSegmentStream=function VideoSegmentStream(track,options){var sequenceNumber=0,nalUnits=[],gopsToAlignWith=[],config,pps;options=options||{};_VideoSegmentStream.prototype.init.call(this);delete track.minPTS;this.gopCache_=[];this.push=function(nalUnit){trackDecodeInfo.collectDtsInfo(track,nalUnit);if(nalUnit.nalUnitType==="seq_parameter_set_rbsp"&&!config){config=nalUnit.config;track.sps=[nalUnit.data];VIDEO_PROPERTIES.forEach(function(prop){track[prop]=config[prop]},this)}if(nalUnit.nalUnitType==="pic_parameter_set_rbsp"&&!pps){pps=nalUnit.data;track.pps=[nalUnit.data]}nalUnits.push(nalUnit)};this.flush=function(){var frames,gopForFusion,gops,moof,mdat,boxes,prependedContentDuration=0,firstGop,lastGop;while(nalUnits.length){if(nalUnits[0].nalUnitType==="access_unit_delimiter_rbsp"){break}nalUnits.shift()}if(nalUnits.length===0){this.resetStream_();this.trigger("done","VideoSegmentStream");return}frames=frameUtils.groupNalsIntoFrames(nalUnits);gops=frameUtils.groupFramesIntoGops(frames);if(!gops[0][0].keyFrame){gopForFusion=this.getGopForFusion_(nalUnits[0],track);if(gopForFusion){prependedContentDuration=gopForFusion.duration;gops.unshift(gopForFusion);gops.byteLength+=gopForFusion.byteLength;gops.nalCount+=gopForFusion.nalCount;gops.pts=gopForFusion.pts;gops.dts=gopForFusion.dts;gops.duration+=gopForFusion.duration}else{gops=frameUtils.extendFirstKeyFrame(gops)}}if(gopsToAlignWith.length){var alignedGops;if(options.alignGopsAtEnd){alignedGops=this.alignGopsAtEnd_(gops)}else{alignedGops=this.alignGopsAtStart_(gops)}if(!alignedGops){this.gopCache_.unshift({gop:gops.pop(),pps:track.pps,sps:track.sps});this.gopCache_.length=Math.min(6,this.gopCache_.length);nalUnits=[];this.resetStream_();this.trigger("done","VideoSegmentStream");return}trackDecodeInfo.clearDtsInfo(track);gops=alignedGops}trackDecodeInfo.collectDtsInfo(track,gops);track.samples=frameUtils.generateSampleTable(gops);mdat=mp4Generator.mdat(frameUtils.concatenateNalData(gops));track.baseMediaDecodeTime=trackDecodeInfo.calculateTrackBaseMediaDecodeTime(track,options.keepOriginalTimestamps);this.trigger("processedGopsInfo",gops.map(function(gop){return{pts:gop.pts,dts:gop.dts,byteLength:gop.byteLength}}));firstGop=gops[0];lastGop=gops[gops.length-1];this.trigger("segmentTimingInfo",generateVideoSegmentTimingInfo(track.baseMediaDecodeTime,firstGop.dts,firstGop.pts,lastGop.dts+lastGop.duration,lastGop.pts+lastGop.duration,prependedContentDuration));this.trigger("timingInfo",{start:gops[0].dts,end:gops[gops.length-1].dts+gops[gops.length-1].duration});this.gopCache_.unshift({gop:gops.pop(),pps:track.pps,sps:track.sps});this.gopCache_.length=Math.min(6,this.gopCache_.length);nalUnits=[];this.trigger("baseMediaDecodeTime",track.baseMediaDecodeTime);this.trigger("timelineStartInfo",track.timelineStartInfo);moof=mp4Generator.moof(sequenceNumber,[track]);boxes=new Uint8Array(moof.byteLength+mdat.byteLength);sequenceNumber++;boxes.set(moof);boxes.set(mdat,moof.byteLength);this.trigger("data",{track:track,boxes:boxes});this.resetStream_();this.trigger("done","VideoSegmentStream")};this.reset=function(){this.resetStream_();nalUnits=[];this.gopCache_.length=0;gopsToAlignWith.length=0;this.trigger("reset")};this.resetStream_=function(){trackDecodeInfo.clearDtsInfo(track);config=undefined;pps=undefined};this.getGopForFusion_=function(nalUnit){var halfSecond=45e3,allowableOverlap=1e4,nearestDistance=Infinity,dtsDistance,nearestGopObj,currentGop,currentGopObj,i;for(i=0;i<this.gopCache_.length;i++){currentGopObj=this.gopCache_[i];currentGop=currentGopObj.gop;if(!(track.pps&&arrayEquals(track.pps[0],currentGopObj.pps[0]))||!(track.sps&&arrayEquals(track.sps[0],currentGopObj.sps[0]))){continue}if(currentGop.dts<track.timelineStartInfo.dts){continue}dtsDistance=nalUnit.dts-currentGop.dts-currentGop.duration;if(dtsDistance>=-allowableOverlap&&dtsDistance<=halfSecond){if(!nearestGopObj||nearestDistance>dtsDistance){nearestGopObj=currentGopObj;nearestDistance=dtsDistance}}}if(nearestGopObj){return nearestGopObj.gop}return null};this.alignGopsAtStart_=function(gops){var alignIndex,gopIndex,align,gop,byteLength,nalCount,duration,alignedGops;byteLength=gops.byteLength;nalCount=gops.nalCount;duration=gops.duration;alignIndex=gopIndex=0;while(alignIndex<gopsToAlignWith.length&&gopIndex<gops.length){align=gopsToAlignWith[alignIndex];gop=gops[gopIndex];if(align.pts===gop.pts){break}if(gop.pts>align.pts){alignIndex++;continue}gopIndex++;byteLength-=gop.byteLength;nalCount-=gop.nalCount;duration-=gop.duration}if(gopIndex===0){return gops}if(gopIndex===gops.length){return null}alignedGops=gops.slice(gopIndex);alignedGops.byteLength=byteLength;alignedGops.duration=duration;alignedGops.nalCount=nalCount;alignedGops.pts=alignedGops[0].pts;alignedGops.dts=alignedGops[0].dts;return alignedGops};this.alignGopsAtEnd_=function(gops){var alignIndex,gopIndex,align,gop,alignEndIndex,matchFound;alignIndex=gopsToAlignWith.length-1;gopIndex=gops.length-1;alignEndIndex=null;matchFound=false;while(alignIndex>=0&&gopIndex>=0){align=gopsToAlignWith[alignIndex];gop=gops[gopIndex];if(align.pts===gop.pts){matchFound=true;break}if(align.pts>gop.pts){alignIndex--;continue}if(alignIndex===gopsToAlignWith.length-1){alignEndIndex=gopIndex}gopIndex--}if(!matchFound&&alignEndIndex===null){return null}var trimIndex;if(matchFound){trimIndex=gopIndex}else{trimIndex=alignEndIndex}if(trimIndex===0){return gops}var alignedGops=gops.slice(trimIndex);var metadata=alignedGops.reduce(function(total,gop){total.byteLength+=gop.byteLength;total.duration+=gop.duration;total.nalCount+=gop.nalCount;return total},{byteLength:0,duration:0,nalCount:0});alignedGops.byteLength=metadata.byteLength;alignedGops.duration=metadata.duration;alignedGops.nalCount=metadata.nalCount;alignedGops.pts=alignedGops[0].pts;alignedGops.dts=alignedGops[0].dts;return alignedGops};this.alignGopsWith=function(newGopsToAlignWith){gopsToAlignWith=newGopsToAlignWith}};_VideoSegmentStream.prototype=new stream;_CoalesceStream=function CoalesceStream(options,metadataStream){this.numberOfTracks=0;this.metadataStream=metadataStream;options=options||{};if(typeof options.remux!=="undefined"){this.remuxTracks=!!options.remux}else{this.remuxTracks=true}if(typeof options.keepOriginalTimestamps==="boolean"){this.keepOriginalTimestamps=options.keepOriginalTimestamps}else{this.keepOriginalTimestamps=false}this.pendingTracks=[];this.videoTrack=null;this.pendingBoxes=[];this.pendingCaptions=[];this.pendingMetadata=[];this.pendingBytes=0;this.emittedTracks=0;_CoalesceStream.prototype.init.call(this);this.push=function(output){if(output.text){return this.pendingCaptions.push(output)}if(output.frames){return this.pendingMetadata.push(output)}this.pendingTracks.push(output.track);this.pendingBytes+=output.boxes.byteLength;if(output.track.type==="video"){this.videoTrack=output.track;this.pendingBoxes.push(output.boxes)}if(output.track.type==="audio"){this.audioTrack=output.track;this.pendingBoxes.unshift(output.boxes)}}};_CoalesceStream.prototype=new stream;_CoalesceStream.prototype.flush=function(flushSource){var offset=0,event={captions:[],captionStreams:{},metadata:[],info:{}},caption,id3,initSegment,timelineStartPts=0,i;if(this.pendingTracks.length<this.numberOfTracks){if(flushSource!=="VideoSegmentStream"&&flushSource!=="AudioSegmentStream"){return}else if(this.remuxTracks){return}else if(this.pendingTracks.length===0){this.emittedTracks++;if(this.emittedTracks>=this.numberOfTracks){this.trigger("done");this.emittedTracks=0}return}}if(this.videoTrack){timelineStartPts=this.videoTrack.timelineStartInfo.pts;VIDEO_PROPERTIES.forEach(function(prop){event.info[prop]=this.videoTrack[prop]},this)}else if(this.audioTrack){timelineStartPts=this.audioTrack.timelineStartInfo.pts;AUDIO_PROPERTIES.forEach(function(prop){event.info[prop]=this.audioTrack[prop]},this)}if(this.videoTrack||this.audioTrack){if(this.pendingTracks.length===1){event.type=this.pendingTracks[0].type}else{event.type="combined"}this.emittedTracks+=this.pendingTracks.length;initSegment=mp4Generator.initSegment(this.pendingTracks);event.initSegment=new Uint8Array(initSegment.byteLength);event.initSegment.set(initSegment);event.data=new Uint8Array(this.pendingBytes);for(i=0;i<this.pendingBoxes.length;i++){event.data.set(this.pendingBoxes[i],offset);offset+=this.pendingBoxes[i].byteLength}for(i=0;i<this.pendingCaptions.length;i++){caption=this.pendingCaptions[i];caption.startTime=clock.metadataTsToSeconds(caption.startPts,timelineStartPts,this.keepOriginalTimestamps);caption.endTime=clock.metadataTsToSeconds(caption.endPts,timelineStartPts,this.keepOriginalTimestamps);event.captionStreams[caption.stream]=true;event.captions.push(caption)}for(i=0;i<this.pendingMetadata.length;i++){id3=this.pendingMetadata[i];id3.cueTime=clock.metadataTsToSeconds(id3.pts,timelineStartPts,this.keepOriginalTimestamps);event.metadata.push(id3)}event.metadata.dispatchType=this.metadataStream.dispatchType;this.pendingTracks.length=0;this.videoTrack=null;this.pendingBoxes.length=0;this.pendingCaptions.length=0;this.pendingBytes=0;this.pendingMetadata.length=0;this.trigger("data",event);for(i=0;i<event.captions.length;i++){caption=event.captions[i];this.trigger("caption",caption)}for(i=0;i<event.metadata.length;i++){id3=event.metadata[i];this.trigger("id3Frame",id3)}}if(this.emittedTracks>=this.numberOfTracks){this.trigger("done");this.emittedTracks=0}};_CoalesceStream.prototype.setRemux=function(val){this.remuxTracks=val};_Transmuxer=function Transmuxer(options){var self=this,hasFlushed=true,videoTrack,audioTrack;_Transmuxer.prototype.init.call(this);options=options||{};this.baseMediaDecodeTime=options.baseMediaDecodeTime||0;this.transmuxPipeline_={};this.setupAacPipeline=function(){var pipeline={};this.transmuxPipeline_=pipeline;pipeline.type="aac";pipeline.metadataStream=new m2ts_1.MetadataStream;pipeline.aacStream=new aac;pipeline.audioTimestampRolloverStream=new m2ts_1.TimestampRolloverStream("audio");pipeline.timedMetadataTimestampRolloverStream=new m2ts_1.TimestampRolloverStream("timed-metadata");pipeline.adtsStream=new adts;pipeline.coalesceStream=new _CoalesceStream(options,pipeline.metadataStream);pipeline.headOfPipeline=pipeline.aacStream;pipeline.aacStream.pipe(pipeline.audioTimestampRolloverStream).pipe(pipeline.adtsStream);pipeline.aacStream.pipe(pipeline.timedMetadataTimestampRolloverStream).pipe(pipeline.metadataStream).pipe(pipeline.coalesceStream);pipeline.metadataStream.on("timestamp",function(frame){pipeline.aacStream.setTimestamp(frame.timeStamp)});pipeline.aacStream.on("data",function(data){if(data.type==="timed-metadata"&&!pipeline.audioSegmentStream){audioTrack=audioTrack||{timelineStartInfo:{baseMediaDecodeTime:self.baseMediaDecodeTime},codec:"adts",type:"audio"};pipeline.coalesceStream.numberOfTracks++;pipeline.audioSegmentStream=new _AudioSegmentStream(audioTrack,options);pipeline.audioSegmentStream.on("timingInfo",self.trigger.bind(self,"audioTimingInfo"));pipeline.adtsStream.pipe(pipeline.audioSegmentStream).pipe(pipeline.coalesceStream)}self.trigger("trackinfo",{hasAudio:!!audioTrack,hasVideo:!!videoTrack})});pipeline.coalesceStream.on("data",this.trigger.bind(this,"data"));pipeline.coalesceStream.on("done",this.trigger.bind(this,"done"))};this.setupTsPipeline=function(){var pipeline={};this.transmuxPipeline_=pipeline;pipeline.type="ts";pipeline.metadataStream=new m2ts_1.MetadataStream;pipeline.packetStream=new m2ts_1.TransportPacketStream;pipeline.parseStream=new m2ts_1.TransportParseStream;pipeline.elementaryStream=new m2ts_1.ElementaryStream;pipeline.timestampRolloverStream=new m2ts_1.TimestampRolloverStream;pipeline.adtsStream=new adts;pipeline.h264Stream=new H264Stream;pipeline.captionStream=new m2ts_1.CaptionStream;pipeline.coalesceStream=new _CoalesceStream(options,pipeline.metadataStream);pipeline.headOfPipeline=pipeline.packetStream;pipeline.packetStream.pipe(pipeline.parseStream).pipe(pipeline.elementaryStream).pipe(pipeline.timestampRolloverStream);pipeline.timestampRolloverStream.pipe(pipeline.h264Stream);pipeline.timestampRolloverStream.pipe(pipeline.adtsStream);pipeline.timestampRolloverStream.pipe(pipeline.metadataStream).pipe(pipeline.coalesceStream);pipeline.h264Stream.pipe(pipeline.captionStream).pipe(pipeline.coalesceStream);pipeline.elementaryStream.on("data",function(data){var i;if(data.type==="metadata"){i=data.tracks.length;while(i--){if(!videoTrack&&data.tracks[i].type==="video"){videoTrack=data.tracks[i];videoTrack.timelineStartInfo.baseMediaDecodeTime=self.baseMediaDecodeTime}else if(!audioTrack&&data.tracks[i].type==="audio"){audioTrack=data.tracks[i];audioTrack.timelineStartInfo.baseMediaDecodeTime=self.baseMediaDecodeTime}}if(videoTrack&&!pipeline.videoSegmentStream){pipeline.coalesceStream.numberOfTracks++;pipeline.videoSegmentStream=new _VideoSegmentStream(videoTrack,options);pipeline.videoSegmentStream.on("timelineStartInfo",function(timelineStartInfo){if(audioTrack){audioTrack.timelineStartInfo=timelineStartInfo;pipeline.audioSegmentStream.setEarliestDts(timelineStartInfo.dts)}});pipeline.videoSegmentStream.on("processedGopsInfo",self.trigger.bind(self,"gopInfo"));pipeline.videoSegmentStream.on("segmentTimingInfo",self.trigger.bind(self,"videoSegmentTimingInfo"));pipeline.videoSegmentStream.on("baseMediaDecodeTime",function(baseMediaDecodeTime){if(audioTrack){pipeline.audioSegmentStream.setVideoBaseMediaDecodeTime(baseMediaDecodeTime)}});pipeline.videoSegmentStream.on("timingInfo",self.trigger.bind(self,"videoTimingInfo"));pipeline.h264Stream.pipe(pipeline.videoSegmentStream).pipe(pipeline.coalesceStream)}if(audioTrack&&!pipeline.audioSegmentStream){pipeline.coalesceStream.numberOfTracks++;pipeline.audioSegmentStream=new _AudioSegmentStream(audioTrack,options);pipeline.audioSegmentStream.on("timingInfo",self.trigger.bind(self,"audioTimingInfo"));pipeline.adtsStream.pipe(pipeline.audioSegmentStream).pipe(pipeline.coalesceStream)}self.trigger("trackinfo",{hasAudio:!!audioTrack,hasVideo:!!videoTrack})}});pipeline.coalesceStream.on("data",this.trigger.bind(this,"data"));pipeline.coalesceStream.on("id3Frame",function(id3Frame){id3Frame.dispatchType=pipeline.metadataStream.dispatchType;self.trigger("id3Frame",id3Frame)});pipeline.coalesceStream.on("caption",this.trigger.bind(this,"caption"));pipeline.coalesceStream.on("done",this.trigger.bind(this,"done"))};this.setBaseMediaDecodeTime=function(baseMediaDecodeTime){var pipeline=this.transmuxPipeline_;if(!options.keepOriginalTimestamps){this.baseMediaDecodeTime=baseMediaDecodeTime}if(audioTrack){audioTrack.timelineStartInfo.dts=undefined;audioTrack.timelineStartInfo.pts=undefined;trackDecodeInfo.clearDtsInfo(audioTrack);if(!options.keepOriginalTimestamps){audioTrack.timelineStartInfo.baseMediaDecodeTime=baseMediaDecodeTime}if(pipeline.audioTimestampRolloverStream){pipeline.audioTimestampRolloverStream.discontinuity()}}if(videoTrack){if(pipeline.videoSegmentStream){pipeline.videoSegmentStream.gopCache_=[]}videoTrack.timelineStartInfo.dts=undefined;videoTrack.timelineStartInfo.pts=undefined;trackDecodeInfo.clearDtsInfo(videoTrack);pipeline.captionStream.reset();if(!options.keepOriginalTimestamps){videoTrack.timelineStartInfo.baseMediaDecodeTime=baseMediaDecodeTime}}if(pipeline.timestampRolloverStream){pipeline.timestampRolloverStream.discontinuity()}};this.setAudioAppendStart=function(timestamp){if(audioTrack){this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(timestamp)}};this.setRemux=function(val){var pipeline=this.transmuxPipeline_;options.remux=val;if(pipeline&&pipeline.coalesceStream){pipeline.coalesceStream.setRemux(val)}};this.alignGopsWith=function(gopsToAlignWith){if(videoTrack&&this.transmuxPipeline_.videoSegmentStream){this.transmuxPipeline_.videoSegmentStream.alignGopsWith(gopsToAlignWith)}};this.push=function(data){if(hasFlushed){var isAac=isLikelyAacData$1(data);if(isAac&&this.transmuxPipeline_.type!=="aac"){this.setupAacPipeline()}else if(!isAac&&this.transmuxPipeline_.type!=="ts"){this.setupTsPipeline()}hasFlushed=false}this.transmuxPipeline_.headOfPipeline.push(data)};this.flush=function(){hasFlushed=true;this.transmuxPipeline_.headOfPipeline.flush()};this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()};this.reset=function(){if(this.transmuxPipeline_.headOfPipeline){this.transmuxPipeline_.headOfPipeline.reset()}};this.resetCaptions=function(){if(this.transmuxPipeline_.captionStream){this.transmuxPipeline_.captionStream.reset()}}};_Transmuxer.prototype=new stream;var transmuxer={Transmuxer:_Transmuxer,VideoSegmentStream:_VideoSegmentStream,AudioSegmentStream:_AudioSegmentStream,AUDIO_PROPERTIES:AUDIO_PROPERTIES,VIDEO_PROPERTIES:VIDEO_PROPERTIES,generateVideoSegmentTimingInfo:generateVideoSegmentTimingInfo};var classCallCheck=function classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}};var createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();var wireTransmuxerEvents=function wireTransmuxerEvents(self,transmuxer$$1){transmuxer$$1.on("data",function(segment){var initArray=segment.initSegment;segment.initSegment={data:initArray.buffer,byteOffset:initArray.byteOffset,byteLength:initArray.byteLength};var typedArray=segment.data;segment.data=typedArray.buffer;self.postMessage({action:"data",segment:segment,byteOffset:typedArray.byteOffset,byteLength:typedArray.byteLength},[segment.data])});if(transmuxer$$1.captionStream){transmuxer$$1.captionStream.on("data",function(caption){self.postMessage({action:"caption",data:caption})})}transmuxer$$1.on("done",function(data){self.postMessage({action:"done"})});transmuxer$$1.on("gopInfo",function(gopInfo){self.postMessage({action:"gopInfo",gopInfo:gopInfo})});transmuxer$$1.on("videoSegmentTimingInfo",function(videoSegmentTimingInfo){self.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:videoSegmentTimingInfo})})};var MessageHandlers=function(){function MessageHandlers(self,options){classCallCheck(this,MessageHandlers);this.options=options||{};this.self=self;this.init()}createClass(MessageHandlers,[{key:"init",value:function init(){if(this.transmuxer){this.transmuxer.dispose()}this.transmuxer=new transmuxer.Transmuxer(this.options);wireTransmuxerEvents(this.self,this.transmuxer)}},{key:"push",value:function push(data){var segment=new Uint8Array(data.data,data.byteOffset,data.byteLength);this.transmuxer.push(segment)}},{key:"reset",value:function reset(){this.init()}},{key:"setTimestampOffset",value:function setTimestampOffset(data){var timestampOffset=data.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(timestampOffset*9e4))}},{key:"setAudioAppendStart",value:function setAudioAppendStart(data){this.transmuxer.setAudioAppendStart(Math.ceil(data.appendStart*9e4))}},{key:"flush",value:function flush(data){this.transmuxer.flush()}},{key:"resetCaptions",value:function resetCaptions(){this.transmuxer.resetCaptions()}},{key:"alignGopsWith",value:function alignGopsWith(data){this.transmuxer.alignGopsWith(data.gopsToAlignWith.slice())}}]);return MessageHandlers}();var TransmuxerWorker=function TransmuxerWorker(self){self.onmessage=function(event){if(event.data.action==="init"&&event.data.options){this.messageHandlers=new MessageHandlers(self,event.data.options);return}if(!this.messageHandlers){this.messageHandlers=new MessageHandlers(self)}if(event.data&&event.data.action&&event.data.action!=="init"){if(this.messageHandlers[event.data.action]){this.messageHandlers[event.data.action](event.data)}}}};var transmuxerWorker=new TransmuxerWorker(self);return transmuxerWorker}()});var defaultCodecs={videoCodec:"avc1",videoObjectTypeIndicator:".4d400d",audioProfile:"2"};var translateLegacyCodecs=function translateLegacyCodecs(codecs){return codecs.map(function(codec){return codec.replace(/avc1\.(\d+)\.(\d+)/i,function(orig,profile,avcLevel){var profileHex=("00"+Number(profile).toString(16)).slice(-2);var avcLevelHex=("00"+Number(avcLevel).toString(16)).slice(-2);return"avc1."+profileHex+"00"+avcLevelHex})})};var parseCodecs=function parseCodecs(){var codecs=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";var result={codecCount:0};var parsed=void 0;result.codecCount=codecs.split(",").length;result.codecCount=result.codecCount||2;parsed=/(^|\s|,)+(avc[13])([^ ,]*)/i.exec(codecs);if(parsed){result.videoCodec=parsed[2];result.videoObjectTypeIndicator=parsed[3]}result.audioProfile=/(^|\s|,)+mp4a.[0-9A-Fa-f]+\.([0-9A-Fa-f]+)/i.exec(codecs);result.audioProfile=result.audioProfile&&result.audioProfile[2];return result};var mapLegacyAvcCodecs=function mapLegacyAvcCodecs(codecString){return codecString.replace(/avc1\.(\d+)\.(\d+)/i,function(match){return translateLegacyCodecs([match])[0]})};var makeMimeTypeString=function makeMimeTypeString(type,container,codecs){return type+"/"+container+'; codecs="'+codecs.filter(function(c){return!!c}).join(", ")+'"'};var getContainerType=function getContainerType(media){if(media.segments&&media.segments.length&&media.segments[0].map){return"mp4"}return"mp2t"};var getCodecs=function getCodecs(media){var mediaAttributes=media.attributes||{};if(mediaAttributes.CODECS){return parseCodecs(mediaAttributes.CODECS)}return defaultCodecs};var audioProfileFromDefault=function audioProfileFromDefault(master,audioGroupId){if(!master.mediaGroups.AUDIO||!audioGroupId){return null}var audioGroup=master.mediaGroups.AUDIO[audioGroupId];if(!audioGroup){return null}for(var name in audioGroup){var audioType=audioGroup[name];if(audioType["default"]&&audioType.playlists){return parseCodecs(audioType.playlists[0].attributes.CODECS).audioProfile}}return null};var mimeTypesForPlaylist=function mimeTypesForPlaylist(master,media){var containerType=getContainerType(media);var codecInfo=getCodecs(media);var mediaAttributes=media.attributes||{};var isMuxed=true;var isMaat=false;if(!media){return[]}if(master.mediaGroups.AUDIO&&mediaAttributes.AUDIO){var audioGroup=master.mediaGroups.AUDIO[mediaAttributes.AUDIO];if(audioGroup){isMaat=true;isMuxed=false;for(var groupId in audioGroup){if(!audioGroup[groupId].uri&&!audioGroup[groupId].playlists){isMuxed=true;break}}}}if(isMaat&&!codecInfo.audioProfile){if(!isMuxed){codecInfo.audioProfile=audioProfileFromDefault(master,mediaAttributes.AUDIO)}if(!codecInfo.audioProfile){videojs$1.log.warn("Multiple audio tracks present but no audio codec string is specified. "+"Attempting to use the default audio codec (mp4a.40.2)");codecInfo.audioProfile=defaultCodecs.audioProfile}}var codecStrings={};if(codecInfo.videoCodec){codecStrings.video=""+codecInfo.videoCodec+codecInfo.videoObjectTypeIndicator}if(codecInfo.audioProfile){codecStrings.audio="mp4a.40."+codecInfo.audioProfile}var justAudio=makeMimeTypeString("audio",containerType,[codecStrings.audio]);var justVideo=makeMimeTypeString("video",containerType,[codecStrings.video]);var bothVideoAudio=makeMimeTypeString("video",containerType,[codecStrings.video,codecStrings.audio]);if(isMaat){if(!isMuxed&&codecStrings.video){return[justVideo,justAudio]}if(!isMuxed&&!codecStrings.video){return[justAudio,justAudio]}return[bothVideoAudio,justAudio]}if(!codecStrings.video){return[justAudio]}return[bothVideoAudio]};var parseContentType=function parseContentType(type){var object={type:"",parameters:{}};var parameters=type.trim().split(";");object.type=parameters.shift().trim();parameters.forEach(function(parameter){var pair=parameter.trim().split("=");if(pair.length>1){var name=pair[0].replace(/"/g,"").trim();var value=pair[1].replace(/"/g,"").trim();object.parameters[name]=value}});return object};var isAudioCodec=function isAudioCodec(codec){return/mp4a\.\d+.\d+/i.test(codec)};var isVideoCodec=function isVideoCodec(codec){return/avc1\.[\da-f]+/i.test(codec)};var gopsSafeToAlignWith=function gopsSafeToAlignWith(buffer,currentTime,mapping){if(typeof currentTime==="undefined"||currentTime===null||!buffer.length){return[]}var currentTimePts=Math.ceil((currentTime-mapping+3)*9e4);var i=void 0;for(i=0;i<buffer.length;i++){if(buffer[i].pts>currentTimePts){break}}return buffer.slice(i)};var updateGopBuffer=function updateGopBuffer(buffer,gops,replace){if(!gops.length){return buffer}if(replace){return gops.slice()}var start=gops[0].pts;var i=0;for(i;i<buffer.length;i++){if(buffer[i].pts>=start){break}}return buffer.slice(0,i).concat(gops)};var removeGopBuffer=function removeGopBuffer(buffer,start,end,mapping){var startPts=Math.ceil((start-mapping)*9e4);var endPts=Math.ceil((end-mapping)*9e4);var updatedBuffer=buffer.slice();var i=buffer.length;while(i--){if(buffer[i].pts<=endPts){break}}if(i===-1){return updatedBuffer}var j=i+1;while(j--){if(buffer[j].pts<=startPts){break}}j=Math.max(j,0);updatedBuffer.splice(j,i-j+1);return updatedBuffer};var buffered=function buffered(videoBuffer,audioBuffer,audioDisabled){var start=null;var end=null;var arity=0;var extents=[];var ranges=[];if(!videoBuffer&&!audioBuffer){return videojs$1.createTimeRange()}if(!videoBuffer){return audioBuffer.buffered}if(!audioBuffer){return videoBuffer.buffered}if(audioDisabled){return videoBuffer.buffered}if(videoBuffer.buffered.length===0&&audioBuffer.buffered.length===0){return videojs$1.createTimeRange()}var videoBuffered=videoBuffer.buffered;var audioBuffered=audioBuffer.buffered;var count=videoBuffered.length;while(count--){extents.push({time:videoBuffered.start(count),type:"start"});extents.push({time:videoBuffered.end(count),type:"end"})}count=audioBuffered.length;while(count--){extents.push({time:audioBuffered.start(count),type:"start"});extents.push({time:audioBuffered.end(count),type:"end"})}extents.sort(function(a,b){return a.time-b.time});for(count=0;count<extents.length;count++){if(extents[count].type==="start"){arity++;if(arity===2){start=extents[count].time}}else if(extents[count].type==="end"){arity--;if(arity===1){end=extents[count].time}}if(start!==null&&end!==null){ranges.push([start,end]);start=null;end=null}}return videojs$1.createTimeRanges(ranges)};var ONE_SECOND_IN_TS$2=9e4;var makeWrappedSourceBuffer=function makeWrappedSourceBuffer(mediaSource,mimeType){var sourceBuffer=mediaSource.addSourceBuffer(mimeType);var wrapper=Object.create(null);wrapper.updating=false;wrapper.realBuffer_=sourceBuffer;var _loop=function _loop(key){if(typeof sourceBuffer[key]==="function"){wrapper[key]=function(){return sourceBuffer[key].apply(sourceBuffer,arguments)}}else if(typeof wrapper[key]==="undefined"){Object.defineProperty(wrapper,key,{get:function get$$1(){return sourceBuffer[key]},set:function set$$1(v){return sourceBuffer[key]=v}})}};for(var key in sourceBuffer){_loop(key)}return wrapper};var VirtualSourceBuffer=function(_videojs$EventTarget){inherits$1(VirtualSourceBuffer,_videojs$EventTarget);function VirtualSourceBuffer(mediaSource,codecs){classCallCheck$1(this,VirtualSourceBuffer);var _this=possibleConstructorReturn$1(this,(VirtualSourceBuffer.__proto__||Object.getPrototypeOf(VirtualSourceBuffer)).call(this,videojs$1.EventTarget));_this.timestampOffset_=0;_this.pendingBuffers_=[];_this.bufferUpdating_=false;_this.mediaSource_=mediaSource;_this.codecs_=codecs;_this.audioCodec_=null;_this.videoCodec_=null;_this.audioDisabled_=false;_this.appendAudioInitSegment_=true;_this.gopBuffer_=[];_this.timeMapping_=0;_this.safeAppend_=videojs$1.browser.IE_VERSION>=11;var options={remux:false,alignGopsAtEnd:_this.safeAppend_};_this.codecs_.forEach(function(codec){if(isAudioCodec(codec)){_this.audioCodec_=codec}else if(isVideoCodec(codec)){_this.videoCodec_=codec}});_this.transmuxer_=new TransmuxWorker;_this.transmuxer_.postMessage({action:"init",options:options});_this.transmuxer_.onmessage=function(event){if(event.data.action==="data"){return _this.data_(event)}if(event.data.action==="done"){return _this.done_(event)}if(event.data.action==="gopInfo"){return _this.appendGopInfo_(event)}if(event.data.action==="videoSegmentTimingInfo"){return _this.videoSegmentTimingInfo_(event.data.videoSegmentTimingInfo)}};Object.defineProperty(_this,"timestampOffset",{get:function get$$1(){return this.timestampOffset_},set:function set$$1(val){if(typeof val==="number"&&val>=0){this.timestampOffset_=val;this.appendAudioInitSegment_=true;this.gopBuffer_.length=0;this.timeMapping_=0;this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:val})}}});Object.defineProperty(_this,"appendWindowStart",{get:function get$$1(){return(this.videoBuffer_||this.audioBuffer_).appendWindowStart},set:function set$$1(start){if(this.videoBuffer_){this.videoBuffer_.appendWindowStart=start}if(this.audioBuffer_){this.audioBuffer_.appendWindowStart=start}}});Object.defineProperty(_this,"updating",{get:function get$$1(){return!!(this.bufferUpdating_||!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.updating||this.videoBuffer_&&this.videoBuffer_.updating)}});Object.defineProperty(_this,"buffered",{get:function get$$1(){return buffered(this.videoBuffer_,this.audioBuffer_,this.audioDisabled_)}});return _this}createClass$1(VirtualSourceBuffer,[{key:"data_",value:function data_(event){var segment=event.data.segment;segment.data=new Uint8Array(segment.data,event.data.byteOffset,event.data.byteLength);segment.initSegment=new Uint8Array(segment.initSegment.data,segment.initSegment.byteOffset,segment.initSegment.byteLength);createTextTracksIfNecessary(this,this.mediaSource_,segment);this.pendingBuffers_.push(segment);return}},{key:"done_",value:function done_(event){if(this.mediaSource_.readyState==="closed"){this.pendingBuffers_.length=0;return}this.processPendingSegments_();return}},{key:"videoSegmentTimingInfo_",value:function videoSegmentTimingInfo_(timingInfo){var timingInfoInSeconds={start:{decode:timingInfo.start.dts/ONE_SECOND_IN_TS$2,presentation:timingInfo.start.pts/ONE_SECOND_IN_TS$2},end:{decode:timingInfo.end.dts/ONE_SECOND_IN_TS$2,presentation:timingInfo.end.pts/ONE_SECOND_IN_TS$2},baseMediaDecodeTime:timingInfo.baseMediaDecodeTime/ONE_SECOND_IN_TS$2};if(timingInfo.prependedContentDuration){timingInfoInSeconds.prependedContentDuration=timingInfo.prependedContentDuration/ONE_SECOND_IN_TS$2}this.trigger({type:"videoSegmentTimingInfo",videoSegmentTimingInfo:timingInfoInSeconds})}},{key:"createRealSourceBuffers_",value:function createRealSourceBuffers_(){var _this2=this;var types=["audio","video"];types.forEach(function(type){if(!_this2[type+"Codec_"]){return}if(_this2[type+"Buffer_"]){return}var buffer=null;if(_this2.mediaSource_[type+"Buffer_"]){buffer=_this2.mediaSource_[type+"Buffer_"];buffer.updating=false}else{var codecProperty=type+"Codec_";var mimeType=type+'/mp4;codecs="'+_this2[codecProperty]+'"';buffer=makeWrappedSourceBuffer(_this2.mediaSource_.nativeMediaSource_,mimeType);_this2.mediaSource_[type+"Buffer_"]=buffer}_this2[type+"Buffer_"]=buffer;["update","updatestart","updateend"].forEach(function(event){buffer.addEventListener(event,function(){if(type==="audio"&&_this2.audioDisabled_){return}if(event==="updateend"){_this2[type+"Buffer_"].updating=false}var shouldTrigger=types.every(function(t){if(t==="audio"&&_this2.audioDisabled_){return true}if(type!==t&&_this2[t+"Buffer_"]&&_this2[t+"Buffer_"].updating){return false}return true});if(shouldTrigger){return _this2.trigger(event)}})})})}},{key:"appendBuffer",value:function appendBuffer(segment){this.bufferUpdating_=true;if(this.audioBuffer_&&this.audioBuffer_.buffered.length){var audioBuffered=this.audioBuffer_.buffered;this.transmuxer_.postMessage({action:"setAudioAppendStart",appendStart:audioBuffered.end(audioBuffered.length-1)})}if(this.videoBuffer_){this.transmuxer_.postMessage({action:"alignGopsWith",gopsToAlignWith:gopsSafeToAlignWith(this.gopBuffer_,this.mediaSource_.player_?this.mediaSource_.player_.currentTime():null,this.timeMapping_)})}this.transmuxer_.postMessage({action:"push",data:segment.buffer,byteOffset:segment.byteOffset,byteLength:segment.byteLength},[segment.buffer]);this.transmuxer_.postMessage({action:"flush"})}},{key:"appendGopInfo_",value:function appendGopInfo_(event){this.gopBuffer_=updateGopBuffer(this.gopBuffer_,event.data.gopInfo,this.safeAppend_)}},{key:"remove",value:function remove(start,end){if(this.videoBuffer_){this.videoBuffer_.updating=true;this.videoBuffer_.remove(start,end);this.gopBuffer_=removeGopBuffer(this.gopBuffer_,start,end,this.timeMapping_)}if(!this.audioDisabled_&&this.audioBuffer_){this.audioBuffer_.updating=true;this.audioBuffer_.remove(start,end)}removeCuesFromTrack(start,end,this.metadataTrack_);if(this.inbandTextTracks_){for(var track in this.inbandTextTracks_){removeCuesFromTrack(start,end,this.inbandTextTracks_[track])}}}},{key:"processPendingSegments_",value:function processPendingSegments_(){var sortedSegments={video:{segments:[],bytes:0},audio:{segments:[],bytes:0},captions:[],metadata:[]};if(!this.pendingBuffers_.length){this.trigger("updateend");this.bufferUpdating_=false;return}sortedSegments=this.pendingBuffers_.reduce(function(segmentObj,segment){var type=segment.type;var data=segment.data;var initSegment=segment.initSegment;segmentObj[type].segments.push(data);segmentObj[type].bytes+=data.byteLength;segmentObj[type].initSegment=initSegment;if(segment.captions){segmentObj.captions=segmentObj.captions.concat(segment.captions)}if(segment.info){segmentObj[type].info=segment.info}if(segment.metadata){segmentObj.metadata=segmentObj.metadata.concat(segment.metadata)}return segmentObj},sortedSegments);if(!this.videoBuffer_&&!this.audioBuffer_){if(sortedSegments.video.bytes===0){this.videoCodec_=null}if(sortedSegments.audio.bytes===0){this.audioCodec_=null}this.createRealSourceBuffers_()}if(sortedSegments.audio.info){this.mediaSource_.trigger({type:"audioinfo",info:sortedSegments.audio.info})}if(sortedSegments.video.info){this.mediaSource_.trigger({type:"videoinfo",info:sortedSegments.video.info})}if(this.appendAudioInitSegment_){if(!this.audioDisabled_&&this.audioBuffer_){sortedSegments.audio.segments.unshift(sortedSegments.audio.initSegment);sortedSegments.audio.bytes+=sortedSegments.audio.initSegment.byteLength}this.appendAudioInitSegment_=false}var triggerUpdateend=false;if(this.videoBuffer_&&sortedSegments.video.bytes){sortedSegments.video.segments.unshift(sortedSegments.video.initSegment);sortedSegments.video.bytes+=sortedSegments.video.initSegment.byteLength;this.concatAndAppendSegments_(sortedSegments.video,this.videoBuffer_)}else if(this.videoBuffer_&&(this.audioDisabled_||!this.audioBuffer_)){triggerUpdateend=true}addTextTrackData(this,sortedSegments.captions,sortedSegments.metadata);if(!this.audioDisabled_&&this.audioBuffer_){this.concatAndAppendSegments_(sortedSegments.audio,this.audioBuffer_)}this.pendingBuffers_.length=0;if(triggerUpdateend){this.trigger("updateend")}this.bufferUpdating_=false}},{key:"concatAndAppendSegments_",value:function concatAndAppendSegments_(segmentObj,destinationBuffer){var offset=0;var tempBuffer=void 0;if(segmentObj.bytes){tempBuffer=new Uint8Array(segmentObj.bytes);segmentObj.segments.forEach(function(segment){tempBuffer.set(segment,offset);offset+=segment.byteLength});try{destinationBuffer.updating=true;destinationBuffer.appendBuffer(tempBuffer)}catch(error){if(this.mediaSource_.player_){this.mediaSource_.player_.error({code:-3,type:"APPEND_BUFFER_ERR",message:error.message,originalError:error})}}}}},{key:"abort",value:function abort(){if(this.videoBuffer_){this.videoBuffer_.abort()}if(!this.audioDisabled_&&this.audioBuffer_){this.audioBuffer_.abort()}if(this.transmuxer_){this.transmuxer_.postMessage({action:"reset"})}this.pendingBuffers_.length=0;this.bufferUpdating_=false}}]);return VirtualSourceBuffer}(videojs$1.EventTarget);var HtmlMediaSource=function(_videojs$EventTarget){inherits$1(HtmlMediaSource,_videojs$EventTarget);function HtmlMediaSource(){classCallCheck$1(this,HtmlMediaSource);var _this=possibleConstructorReturn$1(this,(HtmlMediaSource.__proto__||Object.getPrototypeOf(HtmlMediaSource)).call(this));var property=void 0;_this.nativeMediaSource_=new window$1.MediaSource;for(property in _this.nativeMediaSource_){if(!(property in HtmlMediaSource.prototype)&&typeof _this.nativeMediaSource_[property]==="function"){_this[property]=_this.nativeMediaSource_[property].bind(_this.nativeMediaSource_)}}_this.duration_=NaN;Object.defineProperty(_this,"duration",{get:function get$$1(){if(this.duration_===Infinity){return this.duration_}return this.nativeMediaSource_.duration},set:function set$$1(duration){this.duration_=duration;if(duration!==Infinity){this.nativeMediaSource_.duration=duration;return}}});Object.defineProperty(_this,"seekable",{get:function get$$1(){if(this.duration_===Infinity){return videojs$1.createTimeRanges([[0,this.nativeMediaSource_.duration]])}return this.nativeMediaSource_.seekable}});Object.defineProperty(_this,"readyState",{get:function get$$1(){return this.nativeMediaSource_.readyState}});Object.defineProperty(_this,"activeSourceBuffers",{get:function get$$1(){return this.activeSourceBuffers_}});_this.sourceBuffers=[];_this.activeSourceBuffers_=[];_this.updateActiveSourceBuffers_=function(){_this.activeSourceBuffers_.length=0;if(_this.sourceBuffers.length===1){var sourceBuffer=_this.sourceBuffers[0];sourceBuffer.appendAudioInitSegment_=true;sourceBuffer.audioDisabled_=!sourceBuffer.audioCodec_;_this.activeSourceBuffers_.push(sourceBuffer);return}var disableCombined=false;var disableAudioOnly=true;for(var i=0;i<_this.player_.audioTracks().length;i++){var track=_this.player_.audioTracks()[i];if(track.enabled&&track.kind!=="main"){disableCombined=true;disableAudioOnly=false;break}}_this.sourceBuffers.forEach(function(sourceBuffer,index){sourceBuffer.appendAudioInitSegment_=true;if(sourceBuffer.videoCodec_&&sourceBuffer.audioCodec_){sourceBuffer.audioDisabled_=disableCombined}else if(sourceBuffer.videoCodec_&&!sourceBuffer.audioCodec_){sourceBuffer.audioDisabled_=true;disableAudioOnly=false}else if(!sourceBuffer.videoCodec_&&sourceBuffer.audioCodec_){sourceBuffer.audioDisabled_=index?disableAudioOnly:!disableAudioOnly;if(sourceBuffer.audioDisabled_){return}}_this.activeSourceBuffers_.push(sourceBuffer)})};_this.onPlayerMediachange_=function(){_this.sourceBuffers.forEach(function(sourceBuffer){sourceBuffer.appendAudioInitSegment_=true})};_this.onHlsReset_=function(){_this.sourceBuffers.forEach(function(sourceBuffer){if(sourceBuffer.transmuxer_){sourceBuffer.transmuxer_.postMessage({action:"resetCaptions"})}})};_this.onHlsSegmentTimeMapping_=function(event){_this.sourceBuffers.forEach(function(buffer){return buffer.timeMapping_=event.mapping})};["sourceopen","sourceclose","sourceended"].forEach(function(eventName){this.nativeMediaSource_.addEventListener(eventName,this.trigger.bind(this))},_this);_this.on("sourceopen",function(event){var video=document.querySelector('[src="'+_this.url_+'"]');if(!video){return}_this.player_=videojs$1(video.parentNode);if(!_this.player_){return}_this.player_.tech_.on("hls-reset",_this.onHlsReset_);_this.player_.tech_.on("hls-segment-time-mapping",_this.onHlsSegmentTimeMapping_);if(_this.player_.audioTracks&&_this.player_.audioTracks()){_this.player_.audioTracks().on("change",_this.updateActiveSourceBuffers_);_this.player_.audioTracks().on("addtrack",_this.updateActiveSourceBuffers_);_this.player_.audioTracks().on("removetrack",_this.updateActiveSourceBuffers_)}_this.player_.on("mediachange",_this.onPlayerMediachange_)});_this.on("sourceended",function(event){var duration=durationOfVideo(_this.duration);for(var i=0;i<_this.sourceBuffers.length;i++){var sourcebuffer=_this.sourceBuffers[i];var cues=sourcebuffer.metadataTrack_&&sourcebuffer.metadataTrack_.cues;if(cues&&cues.length){cues[cues.length-1].endTime=duration}}});_this.on("sourceclose",function(event){this.sourceBuffers.forEach(function(sourceBuffer){if(sourceBuffer.transmuxer_){sourceBuffer.transmuxer_.terminate()}});this.sourceBuffers.length=0;if(!this.player_){return}if(this.player_.audioTracks&&this.player_.audioTracks()){this.player_.audioTracks().off("change",this.updateActiveSourceBuffers_);this.player_.audioTracks().off("addtrack",this.updateActiveSourceBuffers_);this.player_.audioTracks().off("removetrack",this.updateActiveSourceBuffers_)}if(this.player_.el_){this.player_.off("mediachange",this.onPlayerMediachange_)}if(this.player_.tech_&&this.player_.tech_.el_){this.player_.tech_.off("hls-reset",this.onHlsReset_);this.player_.tech_.off("hls-segment-time-mapping",this.onHlsSegmentTimeMapping_)}});return _this}createClass$1(HtmlMediaSource,[{key:"addSeekableRange_",value:function addSeekableRange_(start,end){var error=void 0;if(this.duration!==Infinity){error=new Error("MediaSource.addSeekableRange() can only be invoked "+"when the duration is Infinity");error.name="InvalidStateError";error.code=11;throw error}if(end>this.nativeMediaSource_.duration||isNaN(this.nativeMediaSource_.duration)){this.nativeMediaSource_.duration=end}}},{key:"addSourceBuffer",value:function addSourceBuffer(type){var buffer=void 0;var parsedType=parseContentType(type);if(/^(video|audio)\/mp2t$/i.test(parsedType.type)){var codecs=[];if(parsedType.parameters&&parsedType.parameters.codecs){codecs=parsedType.parameters.codecs.split(",");codecs=translateLegacyCodecs(codecs);codecs=codecs.filter(function(codec){return isAudioCodec(codec)||isVideoCodec(codec)})}if(codecs.length===0){codecs=["avc1.4d400d","mp4a.40.2"]}buffer=new VirtualSourceBuffer(this,codecs);if(this.sourceBuffers.length!==0){this.sourceBuffers[0].createRealSourceBuffers_();buffer.createRealSourceBuffers_();this.sourceBuffers[0].audioDisabled_=true}}else{buffer=this.nativeMediaSource_.addSourceBuffer(type)}this.sourceBuffers.push(buffer);return buffer}}]);return HtmlMediaSource}(videojs$1.EventTarget);var urlCount=0;videojs$1.mediaSources={};var open=function open(msObjectURL,swfId){var mediaSource=videojs$1.mediaSources[msObjectURL];if(mediaSource){mediaSource.trigger({type:"sourceopen",swfId:swfId})}else{throw new Error("Media Source not found (Video.js)")}};var supportsNativeMediaSources=function supportsNativeMediaSources(){return!!window$1.MediaSource&&!!window$1.MediaSource.isTypeSupported&&window$1.MediaSource.isTypeSupported('video/mp4;codecs="avc1.4d400d,mp4a.40.2"')};var MediaSource=function MediaSource(){this.MediaSource={open:open,supportsNativeMediaSources:supportsNativeMediaSources};if(supportsNativeMediaSources()){return new HtmlMediaSource}throw new Error("Cannot use create a virtual MediaSource for this video")};MediaSource.open=open;MediaSource.supportsNativeMediaSources=supportsNativeMediaSources;var URL$1={createObjectURL:function createObjectURL(object){var objectUrlPrefix="blob:vjs-media-source/";var url=void 0;if(object instanceof HtmlMediaSource){url=window$1.URL.createObjectURL(object.nativeMediaSource_);object.url_=url;return url}if(!(object instanceof HtmlMediaSource)){url=window$1.URL.createObjectURL(object);object.url_=url;return url}url=objectUrlPrefix+urlCount;urlCount++;videojs$1.mediaSources[url]=object;return url}};videojs$1.MediaSource=MediaSource;videojs$1.URL=URL$1;var EventTarget$1$1=videojs$1.EventTarget,mergeOptions$2=videojs$1.mergeOptions;var updateMaster$1=function updateMaster$$1(oldMaster,newMaster){var noChanges=void 0;var update=mergeOptions$2(oldMaster,{duration:newMaster.duration,minimumUpdatePeriod:newMaster.minimumUpdatePeriod});for(var i=0;i<newMaster.playlists.length;i++){var playlistUpdate=updateMaster(update,newMaster.playlists[i]);if(playlistUpdate){update=playlistUpdate}else{noChanges=true}}forEachMediaGroup(newMaster,function(properties,type,group,label){if(properties.playlists&&properties.playlists.length){var uri=properties.playlists[0].uri;var _playlistUpdate=updateMaster(update,properties.playlists[0]);if(_playlistUpdate){update=_playlistUpdate;update.mediaGroups[type][group][label].playlists[0]=update.playlists[uri];noChanges=false}}});if(noChanges){return null}return update};var generateSidxKey=function generateSidxKey(sidxInfo){var sidxByteRangeEnd=sidxInfo.byterange.offset+sidxInfo.byterange.length-1;return sidxInfo.uri+"-"+sidxInfo.byterange.offset+"-"+sidxByteRangeEnd};var equivalentSidx=function equivalentSidx(a,b){var neitherMap=Boolean(!a.map&&!b.map);var equivalentMap=neitherMap||Boolean(a.map&&b.map&&a.map.byterange.offset===b.map.byterange.offset&&a.map.byterange.length===b.map.byterange.length);return equivalentMap&&a.uri===b.uri&&a.byterange.offset===b.byterange.offset&&a.byterange.length===b.byterange.length};var compareSidxEntry=function compareSidxEntry(playlists,oldSidxMapping){var newSidxMapping={};for(var uri in playlists){var playlist=playlists[uri];var currentSidxInfo=playlist.sidx;if(currentSidxInfo){var key=generateSidxKey(currentSidxInfo);if(!oldSidxMapping[key]){break}var savedSidxInfo=oldSidxMapping[key].sidxInfo;if(equivalentSidx(savedSidxInfo,currentSidxInfo)){newSidxMapping[key]=oldSidxMapping[key]}}}return newSidxMapping};var filterChangedSidxMappings=function filterChangedSidxMappings(masterXml,srcUrl,clientOffset,oldSidxMapping){var master=parse(masterXml,{manifestUri:srcUrl,clientOffset:clientOffset});var videoSidx=compareSidxEntry(master.playlists,oldSidxMapping);var mediaGroupSidx=videoSidx;forEachMediaGroup(master,function(properties,mediaType,groupKey,labelKey){if(properties.playlists&&properties.playlists.length){var playlists=properties.playlists;mediaGroupSidx=mergeOptions$2(mediaGroupSidx,compareSidxEntry(playlists,oldSidxMapping))}});return mediaGroupSidx};var requestSidx_=function requestSidx_(sidxRange,playlist,xhr,options,finishProcessingFn){var sidxInfo={uri:resolveManifestRedirect(options.handleManifestRedirects,sidxRange.resolvedUri),byterange:sidxRange.byterange,playlist:playlist};var sidxRequestOptions=videojs$1.mergeOptions(sidxInfo,{responseType:"arraybuffer",headers:segmentXhrHeaders(sidxInfo)});return xhr(sidxRequestOptions,finishProcessingFn)};var DashPlaylistLoader=function(_EventTarget){inherits$1(DashPlaylistLoader,_EventTarget);function DashPlaylistLoader(srcUrlOrPlaylist,hls){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var masterPlaylistLoader=arguments[3];classCallCheck$1(this,DashPlaylistLoader);var _this=possibleConstructorReturn$1(this,(DashPlaylistLoader.__proto__||Object.getPrototypeOf(DashPlaylistLoader)).call(this));var _options$withCredenti=options.withCredentials,withCredentials=_options$withCredenti===undefined?false:_options$withCredenti,_options$handleManife=options.handleManifestRedirects,handleManifestRedirects=_options$handleManife===undefined?false:_options$handleManife;_this.hls_=hls;_this.withCredentials=withCredentials;_this.handleManifestRedirects=handleManifestRedirects;if(!srcUrlOrPlaylist){throw new Error("A non-empty playlist URL or playlist is required")}_this.on("minimumUpdatePeriod",function(){_this.refreshXml_()});_this.on("mediaupdatetimeout",function(){_this.refreshMedia_(_this.media().uri)});_this.state="HAVE_NOTHING";_this.loadedPlaylists_={};if(typeof srcUrlOrPlaylist==="string"){_this.srcUrl=srcUrlOrPlaylist;_this.sidxMapping_={};return possibleConstructorReturn$1(_this)}_this.setupChildLoader(masterPlaylistLoader,srcUrlOrPlaylist);return _this}createClass$1(DashPlaylistLoader,[{key:"setupChildLoader",value:function setupChildLoader(masterPlaylistLoader,playlist){this.masterPlaylistLoader_=masterPlaylistLoader;this.childPlaylist_=playlist}},{key:"dispose",value:function dispose(){this.stopRequest();this.loadedPlaylists_={};window$1.clearTimeout(this.minimumUpdatePeriodTimeout_);window$1.clearTimeout(this.mediaRequest_);window$1.clearTimeout(this.mediaUpdateTimeout)}},{key:"hasPendingRequest",value:function hasPendingRequest(){return this.request||this.mediaRequest_}},{key:"stopRequest",value:function stopRequest(){if(this.request){var oldRequest=this.request;this.request=null;oldRequest.onreadystatechange=null;oldRequest.abort()}}},{key:"sidxRequestFinished_",value:function sidxRequestFinished_(playlist,master,startingState,doneFn){var _this2=this;return function(err,request){if(!_this2.request){return}_this2.request=null;if(err){_this2.error={status:request.status,message:"DASH playlist request error at URL: "+playlist.uri,response:request.response,code:2};if(startingState){_this2.state=startingState}_this2.trigger("error");return doneFn(master,null)}var bytes=new Uint8Array(request.response);var sidx=mp4Inspector.parseSidx(bytes.subarray(8));return doneFn(master,sidx)}}},{key:"media",value:function media(playlist){var _this3=this;if(!playlist){return this.media_}if(this.state==="HAVE_NOTHING"){throw new Error("Cannot switch media playlist from "+this.state)}var startingState=this.state;if(typeof playlist==="string"){if(!this.master.playlists[playlist]){throw new Error("Unknown playlist URI: "+playlist)}playlist=this.master.playlists[playlist]}var mediaChange=!this.media_||playlist.uri!==this.media_.uri;if(mediaChange&&this.loadedPlaylists_[playlist.uri]&&this.loadedPlaylists_[playlist.uri].endList){this.state="HAVE_METADATA";this.media_=playlist;if(mediaChange){this.trigger("mediachanging");this.trigger("mediachange")}return}if(!mediaChange){return}if(this.media_){this.trigger("mediachanging")}if(!playlist.sidx){this.mediaRequest_=window$1.setTimeout(this.haveMetadata.bind(this,{startingState:startingState,playlist:playlist}),0);return}var oldMaster=void 0;var sidxMapping=void 0;if(this.masterPlaylistLoader_){oldMaster=this.masterPlaylistLoader_.master;sidxMapping=this.masterPlaylistLoader_.sidxMapping_}else{oldMaster=this.master;sidxMapping=this.sidxMapping_}var sidxKey=generateSidxKey(playlist.sidx);sidxMapping[sidxKey]={sidxInfo:playlist.sidx};this.request=requestSidx_(playlist.sidx,playlist,this.hls_.xhr,{handleManifestRedirects:this.handleManifestRedirects},this.sidxRequestFinished_(playlist,oldMaster,startingState,function(newMaster,sidx){if(!newMaster||!sidx){throw new Error("failed to request sidx")}sidxMapping[sidxKey].sidx=sidx;_this3.haveMetadata({startingState:startingState,playlist:newMaster.playlists[playlist.uri]})}))}},{key:"haveMetadata",value:function haveMetadata(_ref){var startingState=_ref.startingState,playlist=_ref.playlist;this.state="HAVE_METADATA";this.loadedPlaylists_[playlist.uri]=playlist;this.mediaRequest_=null;this.refreshMedia_(playlist.uri);if(startingState==="HAVE_MASTER"){this.trigger("loadedmetadata")}else{this.trigger("mediachange")}}},{key:"pause",value:function pause(){this.stopRequest();window$1.clearTimeout(this.mediaUpdateTimeout);window$1.clearTimeout(this.minimumUpdatePeriodTimeout_);if(this.state==="HAVE_NOTHING"){this.started=false}}},{key:"load",value:function load(isFinalRendition){var _this4=this;window$1.clearTimeout(this.mediaUpdateTimeout);window$1.clearTimeout(this.minimumUpdatePeriodTimeout_);var media=this.media();if(isFinalRendition){var delay=media?media.targetDuration/2*1e3:5*1e3;this.mediaUpdateTimeout=window$1.setTimeout(function(){return _this4.load()},delay);return}if(!this.started){this.start();return}this.trigger("loadedplaylist")}},{key:"parseMasterXml",value:function parseMasterXml(){var master=parse(this.masterXml_,{manifestUri:this.srcUrl,clientOffset:this.clientOffset_,sidxMapping:this.sidxMapping_});master.uri=this.srcUrl;for(var i=0;i<master.playlists.length;i++){var phonyUri="placeholder-uri-"+i;master.playlists[i].uri=phonyUri;master.playlists[phonyUri]=master.playlists[i]}forEachMediaGroup(master,function(properties,mediaType,groupKey,labelKey){if(properties.playlists&&properties.playlists.length){var _phonyUri="placeholder-uri-"+mediaType+"-"+groupKey+"-"+labelKey;properties.playlists[0].uri=_phonyUri;master.playlists[_phonyUri]=properties.playlists[0]}});setupMediaPlaylists(master);resolveMediaGroupUris(master);return master}},{key:"start",value:function start(){var _this5=this;this.started=true;if(this.masterPlaylistLoader_){this.mediaRequest_=window$1.setTimeout(this.haveMaster_.bind(this),0);return}this.request=this.hls_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},function(error,req){if(!_this5.request){return}_this5.request=null;if(error){_this5.error={status:req.status,message:"DASH playlist request error at URL: "+_this5.srcUrl,responseText:req.responseText,code:2};if(_this5.state==="HAVE_NOTHING"){_this5.started=false}return _this5.trigger("error")}_this5.masterXml_=req.responseText;if(req.responseHeaders&&req.responseHeaders.date){_this5.masterLoaded_=Date.parse(req.responseHeaders.date)}else{_this5.masterLoaded_=Date.now()}_this5.srcUrl=resolveManifestRedirect(_this5.handleManifestRedirects,_this5.srcUrl,req);_this5.syncClientServerClock_(_this5.onClientServerClockSync_.bind(_this5))})}},{key:"syncClientServerClock_",value:function syncClientServerClock_(done){var _this6=this;var utcTiming=parseUTCTiming(this.masterXml_);if(utcTiming===null){this.clientOffset_=this.masterLoaded_-Date.now();return done()}if(utcTiming.method==="DIRECT"){this.clientOffset_=utcTiming.value-Date.now();return done()}this.request=this.hls_.xhr({uri:resolveUrl$1(this.srcUrl,utcTiming.value),method:utcTiming.method,withCredentials:this.withCredentials},function(error,req){if(!_this6.request){return}if(error){_this6.clientOffset_=_this6.masterLoaded_-Date.now();return done()}var serverTime=void 0;if(utcTiming.method==="HEAD"){if(!req.responseHeaders||!req.responseHeaders.date){serverTime=_this6.masterLoaded_}else{serverTime=Date.parse(req.responseHeaders.date)}}else{serverTime=Date.parse(req.responseText)}_this6.clientOffset_=serverTime-Date.now();done()})}},{key:"haveMaster_",value:function haveMaster_(){this.state="HAVE_MASTER";this.mediaRequest_=null;if(!this.masterPlaylistLoader_){this.master=this.parseMasterXml();this.trigger("loadedplaylist")}else if(!this.media_){this.media(this.childPlaylist_)}}},{key:"onClientServerClockSync_",value:function onClientServerClockSync_(){var _this7=this;this.haveMaster_();if(!this.hasPendingRequest()&&!this.media_){this.media(this.master.playlists[0])}if(this.master&&this.master.minimumUpdatePeriod){this.minimumUpdatePeriodTimeout_=window$1.setTimeout(function(){_this7.trigger("minimumUpdatePeriod")},this.master.minimumUpdatePeriod)}}},{key:"refreshXml_",value:function refreshXml_(){var _this8=this;this.request=this.hls_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},function(error,req){if(!_this8.request){return}_this8.request=null;if(error){_this8.error={status:req.status,message:"DASH playlist request error at URL: "+_this8.srcUrl,responseText:req.responseText,code:2};if(_this8.state==="HAVE_NOTHING"){_this8.started=false}return _this8.trigger("error")}_this8.masterXml_=req.responseText;_this8.sidxMapping_=filterChangedSidxMappings(_this8.masterXml_,_this8.srcUrl,_this8.clientOffset_,_this8.sidxMapping_);var master=_this8.parseMasterXml();var updatedMaster=updateMaster$1(_this8.master,master);var currentSidxInfo=_this8.media().sidx;if(updatedMaster){if(currentSidxInfo){var sidxKey=generateSidxKey(currentSidxInfo);if(!_this8.sidxMapping_[sidxKey]){var playlist=_this8.media();_this8.request=requestSidx_(playlist.sidx,playlist,_this8.hls_.xhr,{handleManifestRedirects:_this8.handleManifestRedirects},_this8.sidxRequestFinished_(playlist,master,_this8.state,function(newMaster,sidx){if(!newMaster||!sidx){throw new Error("failed to request sidx on minimumUpdatePeriod")}_this8.sidxMapping_[sidxKey].sidx=sidx;_this8.minimumUpdatePeriodTimeout_=window$1.setTimeout(function(){_this8.trigger("minimumUpdatePeriod")},_this8.master.minimumUpdatePeriod);_this8.refreshMedia_(_this8.media().uri);return}))}}else{_this8.master=updatedMaster}}_this8.minimumUpdatePeriodTimeout_=window$1.setTimeout(function(){_this8.trigger("minimumUpdatePeriod")},_this8.master.minimumUpdatePeriod)})}},{key:"refreshMedia_",value:function refreshMedia_(mediaUri){var _this9=this;if(!mediaUri){throw new Error("refreshMedia_ must take a media uri")}var oldMaster=void 0;var newMaster=void 0;if(this.masterPlaylistLoader_){oldMaster=this.masterPlaylistLoader_.master;newMaster=this.masterPlaylistLoader_.parseMasterXml()}else{oldMaster=this.master;newMaster=this.parseMasterXml()}var updatedMaster=updateMaster$1(oldMaster,newMaster);if(updatedMaster){if(this.masterPlaylistLoader_){this.masterPlaylistLoader_.master=updatedMaster}else{this.master=updatedMaster}this.media_=updatedMaster.playlists[mediaUri]}else{this.media_=newMaster.playlists[mediaUri];this.trigger("playlistunchanged")}if(!this.media().endList){this.mediaUpdateTimeout=window$1.setTimeout(function(){_this9.trigger("mediaupdatetimeout")},refreshDelay(this.media(),!!updatedMaster))}this.trigger("loadedplaylist")}}]);return DashPlaylistLoader}(EventTarget$1$1);var logger=function logger(source){if(videojs$1.log.debug){return videojs$1.log.debug.bind(videojs$1,"VHS:",source+" >")}return function(){}};function noop$1(){}var SourceUpdater=function(){function SourceUpdater(mediaSource,mimeType,type,sourceBufferEmitter){classCallCheck$1(this,SourceUpdater);this.callbacks_=[];this.pendingCallback_=null;this.timestampOffset_=0;this.mediaSource=mediaSource;this.processedAppend_=false;this.type_=type;this.mimeType_=mimeType;this.logger_=logger("SourceUpdater["+type+"]["+mimeType+"]");if(mediaSource.readyState==="closed"){mediaSource.addEventListener("sourceopen",this.createSourceBuffer_.bind(this,mimeType,sourceBufferEmitter))}else{this.createSourceBuffer_(mimeType,sourceBufferEmitter)}}createClass$1(SourceUpdater,[{key:"createSourceBuffer_",value:function createSourceBuffer_(mimeType,sourceBufferEmitter){var _this=this;this.sourceBuffer_=this.mediaSource.addSourceBuffer(mimeType);this.logger_("created SourceBuffer");if(sourceBufferEmitter){sourceBufferEmitter.trigger("sourcebufferadded");if(this.mediaSource.sourceBuffers.length<2){sourceBufferEmitter.on("sourcebufferadded",function(){_this.start_()});return}}this.start_()}},{key:"start_",value:function start_(){var _this2=this;this.started_=true;this.onUpdateendCallback_=function(){var pendingCallback=_this2.pendingCallback_;_this2.pendingCallback_=null;_this2.sourceBuffer_.removing=false;_this2.logger_("buffered ["+printableRange(_this2.buffered())+"]");if(pendingCallback){pendingCallback()}_this2.runCallback_()};this.sourceBuffer_.addEventListener("updateend",this.onUpdateendCallback_);this.runCallback_()}},{key:"abort",value:function abort(done){var _this3=this;if(this.processedAppend_){this.queueCallback_(function(){_this3.sourceBuffer_.abort()},done)}}},{key:"appendBuffer",value:function appendBuffer(config,done){var _this4=this;this.processedAppend_=true;this.queueCallback_(function(){if(config.videoSegmentTimingInfoCallback){_this4.sourceBuffer_.addEventListener("videoSegmentTimingInfo",config.videoSegmentTimingInfoCallback)}_this4.sourceBuffer_.appendBuffer(config.bytes)},function(){if(config.videoSegmentTimingInfoCallback){_this4.sourceBuffer_.removeEventListener("videoSegmentTimingInfo",config.videoSegmentTimingInfoCallback)}done()})}},{key:"buffered",value:function buffered(){if(!this.sourceBuffer_){return videojs$1.createTimeRanges()}return this.sourceBuffer_.buffered}},{key:"remove",value:function remove(start,end){var _this5=this;var done=arguments.length>2&&arguments[2]!==undefined?arguments[2]:noop$1;if(this.processedAppend_){this.queueCallback_(function(){_this5.logger_("remove ["+start+" => "+end+"]");_this5.sourceBuffer_.removing=true;_this5.sourceBuffer_.remove(start,end)},done)}}},{key:"updating",value:function updating(){return!this.sourceBuffer_||this.sourceBuffer_.updating||!!this.pendingCallback_&&this.pendingCallback_!==noop$1}},{key:"timestampOffset",value:function timestampOffset(offset){var _this6=this;if(typeof offset!=="undefined"){this.queueCallback_(function(){_this6.sourceBuffer_.timestampOffset=offset;_this6.runCallback_()});this.timestampOffset_=offset}return this.timestampOffset_}},{key:"queueCallback_",value:function queueCallback_(callback,done){this.callbacks_.push([callback.bind(this),done]);this.runCallback_()}},{key:"runCallback_",value:function runCallback_(){var callbacks=void 0;if(!this.updating()&&this.callbacks_.length&&this.started_){callbacks=this.callbacks_.shift();this.pendingCallback_=callbacks[1];callbacks[0]()}}},{key:"dispose",value:function dispose(){var _this7=this;var disposeFn=function disposeFn(){if(_this7.sourceBuffer_&&_this7.mediaSource.readyState==="open"){_this7.sourceBuffer_.abort()}_this7.sourceBuffer_.removeEventListener("updateend",disposeFn)};this.sourceBuffer_.removeEventListener("updateend",this.onUpdateendCallback_);if(this.sourceBuffer_.removing){this.sourceBuffer_.addEventListener("updateend",disposeFn)}else{disposeFn()}}}]);return SourceUpdater}();var Config={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,BUFFER_LOW_WATER_LINE_RATE:1};var REQUEST_ERRORS={FAILURE:2,TIMEOUT:-101,ABORTED:-102};var abortAll=function abortAll(activeXhrs){activeXhrs.forEach(function(xhr){xhr.abort()})};var getRequestStats=function getRequestStats(request){return{bandwidth:request.bandwidth,bytesReceived:request.bytesReceived||0,roundTripTime:request.roundTripTime||0}};var getProgressStats=function getProgressStats(progressEvent){var request=progressEvent.target;var roundTripTime=Date.now()-request.requestTime;var stats={bandwidth:Infinity,bytesReceived:0,roundTripTime:roundTripTime||0};stats.bytesReceived=progressEvent.loaded;stats.bandwidth=Math.floor(stats.bytesReceived/stats.roundTripTime*8*1e3);return stats};var handleErrors=function handleErrors(error,request){if(request.timedout){return{status:request.status,message:"HLS request timed-out at URL: "+request.uri,code:REQUEST_ERRORS.TIMEOUT,xhr:request}}if(request.aborted){return{status:request.status,message:"HLS request aborted at URL: "+request.uri,code:REQUEST_ERRORS.ABORTED,xhr:request}}if(error){return{status:request.status,message:"HLS request errored at URL: "+request.uri,code:REQUEST_ERRORS.FAILURE,xhr:request}}return null};var handleKeyResponse=function handleKeyResponse(segment,finishProcessingFn){return function(error,request){var response=request.response;var errorObj=handleErrors(error,request);if(errorObj){return finishProcessingFn(errorObj,segment)}if(response.byteLength!==16){return finishProcessingFn({status:request.status,message:"Invalid HLS key at URL: "+request.uri,code:REQUEST_ERRORS.FAILURE,xhr:request},segment)}var view=new DataView(response);segment.key.bytes=new Uint32Array([view.getUint32(0),view.getUint32(4),view.getUint32(8),view.getUint32(12)]);return finishProcessingFn(null,segment)}};var handleInitSegmentResponse=function handleInitSegmentResponse(segment,captionParser,finishProcessingFn){return function(error,request){var response=request.response;var errorObj=handleErrors(error,request);if(errorObj){return finishProcessingFn(errorObj,segment)}if(response.byteLength===0){return finishProcessingFn({status:request.status,message:"Empty HLS segment content at URL: "+request.uri,code:REQUEST_ERRORS.FAILURE,xhr:request},segment)}segment.map.bytes=new Uint8Array(request.response);if(captionParser&&!captionParser.isInitialized()){captionParser.init()}segment.map.timescales=probe.timescale(segment.map.bytes);segment.map.videoTrackIds=probe.videoTrackIds(segment.map.bytes);return finishProcessingFn(null,segment)}};var handleSegmentResponse=function handleSegmentResponse(segment,captionParser,finishProcessingFn){return function(error,request){var response=request.response;var errorObj=handleErrors(error,request);var parsed=void 0;if(errorObj){return finishProcessingFn(errorObj,segment)}if(response.byteLength===0){return finishProcessingFn({status:request.status,message:"Empty HLS segment content at URL: "+request.uri,code:REQUEST_ERRORS.FAILURE,xhr:request},segment)}segment.stats=getRequestStats(request);if(segment.key){segment.encryptedBytes=new Uint8Array(request.response)}else{segment.bytes=new Uint8Array(request.response)}if(captionParser&&segment.map&&segment.map.bytes){if(!captionParser.isInitialized()){captionParser.init()}parsed=captionParser.parse(segment.bytes,segment.map.videoTrackIds,segment.map.timescales);if(parsed&&parsed.captions){segment.captionStreams=parsed.captionStreams;segment.fmp4Captions=parsed.captions}}return finishProcessingFn(null,segment)}};var decryptSegment=function decryptSegment(decrypter,segment,doneFn){var decryptionHandler=function decryptionHandler(event){if(event.data.source===segment.requestId){decrypter.removeEventListener("message",decryptionHandler);var decrypted=event.data.decrypted;segment.bytes=new Uint8Array(decrypted.bytes,decrypted.byteOffset,decrypted.byteLength);return doneFn(null,segment)}};decrypter.addEventListener("message",decryptionHandler);var keyBytes=void 0;if(segment.key.bytes.slice){keyBytes=segment.key.bytes.slice()}else{keyBytes=new Uint32Array(Array.prototype.slice.call(segment.key.bytes))}decrypter.postMessage(createTransferableMessage({source:segment.requestId,encrypted:segment.encryptedBytes,key:keyBytes,iv:segment.key.iv}),[segment.encryptedBytes.buffer,keyBytes.buffer])};var waitForCompletion=function waitForCompletion(activeXhrs,decrypter,doneFn){var count=0;var didError=false;return function(error,segment){if(didError){return}if(error){didError=true;abortAll(activeXhrs);return doneFn(error,segment)}count+=1;if(count===activeXhrs.length){segment.endOfAllRequests=Date.now();if(segment.encryptedBytes){return decryptSegment(decrypter,segment,doneFn)}return doneFn(null,segment)}}};var handleProgress=function handleProgress(segment,progressFn){return function(event){segment.stats=videojs$1.mergeOptions(segment.stats,getProgressStats(event));if(!segment.stats.firstBytesReceivedAt&&segment.stats.bytesReceived){segment.stats.firstBytesReceivedAt=Date.now()}return progressFn(event,segment)}};var mediaSegmentRequest=function mediaSegmentRequest(xhr,xhrOptions,decryptionWorker,captionParser,segment,progressFn,doneFn){var activeXhrs=[];var finishProcessingFn=waitForCompletion(activeXhrs,decryptionWorker,doneFn);if(segment.key&&!segment.key.bytes){var keyRequestOptions=videojs$1.mergeOptions(xhrOptions,{uri:segment.key.resolvedUri,responseType:"arraybuffer"});var keyRequestCallback=handleKeyResponse(segment,finishProcessingFn);var keyXhr=xhr(keyRequestOptions,keyRequestCallback);activeXhrs.push(keyXhr)}if(segment.map&&!segment.map.bytes){var initSegmentOptions=videojs$1.mergeOptions(xhrOptions,{uri:segment.map.resolvedUri,responseType:"arraybuffer",headers:segmentXhrHeaders(segment.map)});var initSegmentRequestCallback=handleInitSegmentResponse(segment,captionParser,finishProcessingFn);var initSegmentXhr=xhr(initSegmentOptions,initSegmentRequestCallback);activeXhrs.push(initSegmentXhr)}var segmentRequestOptions=videojs$1.mergeOptions(xhrOptions,{uri:segment.resolvedUri,responseType:"arraybuffer",headers:segmentXhrHeaders(segment)});var segmentRequestCallback=handleSegmentResponse(segment,captionParser,finishProcessingFn);var segmentXhr=xhr(segmentRequestOptions,segmentRequestCallback);segmentXhr.addEventListener("progress",handleProgress(segment,progressFn));activeXhrs.push(segmentXhr);return function(){return abortAll(activeXhrs)}};var safeGetComputedStyle=function safeGetComputedStyle(el,property){var result=void 0;if(!el){return""}result=window$1.getComputedStyle(el);if(!result){return""}return result[property]};var stableSort=function stableSort(array,sortFn){var newArray=array.slice();array.sort(function(left,right){var cmp=sortFn(left,right);if(cmp===0){return newArray.indexOf(left)-newArray.indexOf(right)}return cmp})};var comparePlaylistBandwidth=function comparePlaylistBandwidth(left,right){var leftBandwidth=void 0;var rightBandwidth=void 0;if(left.attributes.BANDWIDTH){leftBandwidth=left.attributes.BANDWIDTH}leftBandwidth=leftBandwidth||window$1.Number.MAX_VALUE;if(right.attributes.BANDWIDTH){rightBandwidth=right.attributes.BANDWIDTH}rightBandwidth=rightBandwidth||window$1.Number.MAX_VALUE;return leftBandwidth-rightBandwidth};var comparePlaylistResolution=function comparePlaylistResolution(left,right){var leftWidth=void 0;var rightWidth=void 0;if(left.attributes.RESOLUTION&&left.attributes.RESOLUTION.width){leftWidth=left.attributes.RESOLUTION.width}leftWidth=leftWidth||window$1.Number.MAX_VALUE;if(right.attributes.RESOLUTION&&right.attributes.RESOLUTION.width){rightWidth=right.attributes.RESOLUTION.width}rightWidth=rightWidth||window$1.Number.MAX_VALUE;if(leftWidth===rightWidth&&left.attributes.BANDWIDTH&&right.attributes.BANDWIDTH){return left.attributes.BANDWIDTH-right.attributes.BANDWIDTH}return leftWidth-rightWidth};var simpleSelector=function simpleSelector(master,playerBandwidth,playerWidth,playerHeight,limitRenditionByPlayerDimensions){var sortedPlaylistReps=master.playlists.map(function(playlist){var width=void 0;var height=void 0;var bandwidth=void 0;width=playlist.attributes.RESOLUTION&&playlist.attributes.RESOLUTION.width;height=playlist.attributes.RESOLUTION&&playlist.attributes.RESOLUTION.height;bandwidth=playlist.attributes.BANDWIDTH;bandwidth=bandwidth||window$1.Number.MAX_VALUE;return{bandwidth:bandwidth,width:width,height:height,playlist:playlist}});stableSort(sortedPlaylistReps,function(left,right){return left.bandwidth-right.bandwidth});sortedPlaylistReps=sortedPlaylistReps.filter(function(rep){return!Playlist.isIncompatible(rep.playlist)});var enabledPlaylistReps=sortedPlaylistReps.filter(function(rep){return Playlist.isEnabled(rep.playlist)});if(!enabledPlaylistReps.length){enabledPlaylistReps=sortedPlaylistReps.filter(function(rep){return!Playlist.isDisabled(rep.playlist)})}var bandwidthPlaylistReps=enabledPlaylistReps.filter(function(rep){return rep.bandwidth*Config.BANDWIDTH_VARIANCE<playerBandwidth});var highestRemainingBandwidthRep=bandwidthPlaylistReps[bandwidthPlaylistReps.length-1];var bandwidthBestRep=bandwidthPlaylistReps.filter(function(rep){return rep.bandwidth===highestRemainingBandwidthRep.bandwidth})[0];if(limitRenditionByPlayerDimensions===false){var _chosenRep=bandwidthBestRep||enabledPlaylistReps[0]||sortedPlaylistReps[0];return _chosenRep?_chosenRep.playlist:null}var haveResolution=bandwidthPlaylistReps.filter(function(rep){return rep.width&&rep.height});stableSort(haveResolution,function(left,right){return left.width-right.width});var resolutionBestRepList=haveResolution.filter(function(rep){return rep.width===playerWidth&&rep.height===playerHeight});highestRemainingBandwidthRep=resolutionBestRepList[resolutionBestRepList.length-1];var resolutionBestRep=resolutionBestRepList.filter(function(rep){return rep.bandwidth===highestRemainingBandwidthRep.bandwidth})[0];var resolutionPlusOneList=void 0;var resolutionPlusOneSmallest=void 0;var resolutionPlusOneRep=void 0;if(!resolutionBestRep){resolutionPlusOneList=haveResolution.filter(function(rep){return rep.width>playerWidth||rep.height>playerHeight});resolutionPlusOneSmallest=resolutionPlusOneList.filter(function(rep){return rep.width===resolutionPlusOneList[0].width&&rep.height===resolutionPlusOneList[0].height});highestRemainingBandwidthRep=resolutionPlusOneSmallest[resolutionPlusOneSmallest.length-1];resolutionPlusOneRep=resolutionPlusOneSmallest.filter(function(rep){return rep.bandwidth===highestRemainingBandwidthRep.bandwidth})[0]}var chosenRep=resolutionPlusOneRep||resolutionBestRep||bandwidthBestRep||enabledPlaylistReps[0]||sortedPlaylistReps[0];return chosenRep?chosenRep.playlist:null};var lastBandwidthSelector=function lastBandwidthSelector(){return simpleSelector(this.playlists.master,this.systemBandwidth,parseInt(safeGetComputedStyle(this.tech_.el(),"width"),10),parseInt(safeGetComputedStyle(this.tech_.el(),"height"),10),this.limitRenditionByPlayerDimensions)};var minRebufferMaxBandwidthSelector=function minRebufferMaxBandwidthSelector(settings){var master=settings.master,currentTime=settings.currentTime,bandwidth=settings.bandwidth,duration$$1=settings.duration,segmentDuration=settings.segmentDuration,timeUntilRebuffer=settings.timeUntilRebuffer,currentTimeline=settings.currentTimeline,syncController=settings.syncController;var compatiblePlaylists=master.playlists.filter(function(playlist){return!Playlist.isIncompatible(playlist)});var enabledPlaylists=compatiblePlaylists.filter(Playlist.isEnabled);if(!enabledPlaylists.length){enabledPlaylists=compatiblePlaylists.filter(function(playlist){return!Playlist.isDisabled(playlist)})}var bandwidthPlaylists=enabledPlaylists.filter(Playlist.hasAttribute.bind(null,"BANDWIDTH"));var rebufferingEstimates=bandwidthPlaylists.map(function(playlist){var syncPoint=syncController.getSyncPoint(playlist,duration$$1,currentTimeline,currentTime);var numRequests=syncPoint?1:2;var requestTimeEstimate=Playlist.estimateSegmentRequestTime(segmentDuration,bandwidth,playlist);var rebufferingImpact=requestTimeEstimate*numRequests-timeUntilRebuffer;return{playlist:playlist,rebufferingImpact:rebufferingImpact}});var noRebufferingPlaylists=rebufferingEstimates.filter(function(estimate){return estimate.rebufferingImpact<=0});stableSort(noRebufferingPlaylists,function(a,b){return comparePlaylistBandwidth(b.playlist,a.playlist)});if(noRebufferingPlaylists.length){return noRebufferingPlaylists[0]}stableSort(rebufferingEstimates,function(a,b){return a.rebufferingImpact-b.rebufferingImpact});return rebufferingEstimates[0]||null};var lowestBitrateCompatibleVariantSelector=function lowestBitrateCompatibleVariantSelector(){var playlists=this.playlists.master.playlists.filter(Playlist.isEnabled);stableSort(playlists,function(a,b){return comparePlaylistBandwidth(a,b)});var playlistsWithVideo=playlists.filter(function(playlist){return parseCodecs(playlist.attributes.CODECS).videoCodec});return playlistsWithVideo[0]||null};var createCaptionsTrackIfNotExists=function createCaptionsTrackIfNotExists(inbandTextTracks,tech,captionStreams){for(var trackId in captionStreams){if(!inbandTextTracks[trackId]){tech.trigger({type:"usage",name:"hls-608"});var track=tech.textTracks().getTrackById(trackId);if(track){inbandTextTracks[trackId]=track}else{inbandTextTracks[trackId]=tech.addRemoteTextTrack({kind:"captions",id:trackId,label:trackId},false).track}}}};var addCaptionData=function addCaptionData(_ref){var inbandTextTracks=_ref.inbandTextTracks,captionArray=_ref.captionArray,timestampOffset=_ref.timestampOffset;if(!captionArray){return}var Cue=window.WebKitDataCue||window.VTTCue;captionArray.forEach(function(caption){var track=caption.stream;var startTime=caption.startTime;var endTime=caption.endTime;if(!inbandTextTracks[track]){return}startTime+=timestampOffset;endTime+=timestampOffset;inbandTextTracks[track].addCue(new Cue(startTime,endTime,caption.text))})};var CHECK_BUFFER_DELAY=500;var detectEndOfStream=function detectEndOfStream(playlist,mediaSource,segmentIndex){if(!playlist||!mediaSource){return false}var segments=playlist.segments;var appendedLastSegment=segmentIndex===segments.length;return playlist.endList&&mediaSource.readyState==="open"&&appendedLastSegment};var finite=function finite(num){return typeof num==="number"&&isFinite(num)};var illegalMediaSwitch=function illegalMediaSwitch(loaderType,startingMedia,newSegmentMedia){if(loaderType!=="main"||!startingMedia||!newSegmentMedia){return null}if(!newSegmentMedia.containsAudio&&!newSegmentMedia.containsVideo){return"Neither audio nor video found in segment."}if(startingMedia.containsVideo&&!newSegmentMedia.containsVideo){return"Only audio found in segment when we expected video."+" We can't switch to audio only from a stream that had video."+" To get rid of this message, please add codec information to the manifest."}if(!startingMedia.containsVideo&&newSegmentMedia.containsVideo){return"Video found in segment when we expected only audio."+" We can't switch to a stream with video from an audio only stream."+" To get rid of this message, please add codec information to the manifest."}return null};var safeBackBufferTrimTime=function safeBackBufferTrimTime(seekable$$1,currentTime,targetDuration){var removeToTime=void 0;if(seekable$$1.length&&seekable$$1.start(0)>0&&seekable$$1.start(0)<currentTime){removeToTime=seekable$$1.start(0)}else{removeToTime=currentTime-30}return Math.min(removeToTime,currentTime-targetDuration)};var segmentInfoString=function segmentInfoString(segmentInfo){var _segmentInfo$segment=segmentInfo.segment,start=_segmentInfo$segment.start,end=_segmentInfo$segment.end,_segmentInfo$playlist=segmentInfo.playlist,seq=_segmentInfo$playlist.mediaSequence,id=_segmentInfo$playlist.id,_segmentInfo$playlist2=_segmentInfo$playlist.segments,segments=_segmentInfo$playlist2===undefined?[]:_segmentInfo$playlist2,index=segmentInfo.mediaIndex,timeline=segmentInfo.timeline;return["appending ["+index+"] of ["+seq+", "+(seq+segments.length)+"] from playlist ["+id+"]","["+start+" => "+end+"] in timeline ["+timeline+"]"].join(" ")};var SegmentLoader=function(_videojs$EventTarget){inherits$1(SegmentLoader,_videojs$EventTarget);function SegmentLoader(settings){classCallCheck$1(this,SegmentLoader);var _this=possibleConstructorReturn$1(this,(SegmentLoader.__proto__||Object.getPrototypeOf(SegmentLoader)).call(this));if(!settings){throw new TypeError("Initialization settings are required")}if(typeof settings.currentTime!=="function"){throw new TypeError("No currentTime getter specified")}if(!settings.mediaSource){throw new TypeError("No MediaSource specified")}_this.bandwidth=settings.bandwidth;_this.throughput={rate:0,count:0};_this.roundTrip=NaN;_this.resetStats_();_this.mediaIndex=null;_this.hasPlayed_=settings.hasPlayed;_this.currentTime_=settings.currentTime;_this.seekable_=settings.seekable;_this.seeking_=settings.seeking;_this.duration_=settings.duration;_this.mediaSource_=settings.mediaSource;_this.hls_=settings.hls;_this.loaderType_=settings.loaderType;_this.startingMedia_=void 0;_this.segmentMetadataTrack_=settings.segmentMetadataTrack;_this.goalBufferLength_=settings.goalBufferLength;_this.sourceType_=settings.sourceType;_this.inbandTextTracks_=settings.inbandTextTracks;_this.state_="INIT";_this.checkBufferTimeout_=null;_this.error_=void 0;_this.currentTimeline_=-1;_this.pendingSegment_=null;_this.mimeType_=null;_this.sourceUpdater_=null;_this.xhrOptions_=null;_this.activeInitSegmentId_=null;_this.initSegments_={};_this.cacheEncryptionKeys_=settings.cacheEncryptionKeys;_this.keyCache_={};if(_this.loaderType_==="main"){_this.captionParser_=new captionParser}else{_this.captionParser_=null}_this.decrypter_=settings.decrypter;_this.syncController_=settings.syncController;_this.syncPoint_={segmentIndex:0,time:0};_this.syncController_.on("syncinfoupdate",function(){return _this.trigger("syncinfoupdate")});_this.mediaSource_.addEventListener("sourceopen",function(){return _this.ended_=false});_this.fetchAtBuffer_=false;_this.logger_=logger("SegmentLoader["+_this.loaderType_+"]");Object.defineProperty(_this,"state",{get:function get$$1(){return this.state_},set:function set$$1(newState){if(newState!==this.state_){this.logger_(this.state_+" -> "+newState);this.state_=newState}}});return _this}createClass$1(SegmentLoader,[{key:"resetStats_",value:function resetStats_(){this.mediaBytesTransferred=0;this.mediaRequests=0;this.mediaRequestsAborted=0;this.mediaRequestsTimedout=0;this.mediaRequestsErrored=0;this.mediaTransferDuration=0;this.mediaSecondsLoaded=0}},{key:"dispose",value:function dispose(){this.state="DISPOSED";this.pause();this.abort_();if(this.sourceUpdater_){this.sourceUpdater_.dispose()}this.resetStats_();if(this.captionParser_){this.captionParser_.reset()}}},{key:"abort",value:function abort(){if(this.state!=="WAITING"){if(this.pendingSegment_){this.pendingSegment_=null}return}this.abort_();this.state="READY";if(!this.paused()){this.monitorBuffer_()}}},{key:"abort_",value:function abort_(){if(this.pendingSegment_){this.pendingSegment_.abortRequests()}this.pendingSegment_=null}},{key:"error",value:function error(_error){if(typeof _error!=="undefined"){this.error_=_error}this.pendingSegment_=null;return this.error_}},{key:"endOfStream",value:function endOfStream(){this.ended_=true;this.pause();this.trigger("ended")}},{key:"buffered_",value:function buffered_(){if(!this.sourceUpdater_){return videojs$1.createTimeRanges()}return this.sourceUpdater_.buffered()}},{key:"initSegment",value:function initSegment(map){var set$$1=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!map){return null}var id=initSegmentId(map);var storedMap=this.initSegments_[id];if(set$$1&&!storedMap&&map.bytes){this.initSegments_[id]=storedMap={resolvedUri:map.resolvedUri,byterange:map.byterange,bytes:map.bytes,timescales:map.timescales,videoTrackIds:map.videoTrackIds}}return storedMap||map}},{key:"segmentKey",value:function segmentKey(key){var set$$1=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!key){return null}var id=segmentKeyId(key);var storedKey=this.keyCache_[id];if(this.cacheEncryptionKeys_&&set$$1&&!storedKey&&key.bytes){this.keyCache_[id]=storedKey={resolvedUri:key.resolvedUri,bytes:key.bytes}}var result={resolvedUri:(storedKey||key).resolvedUri};if(storedKey){result.bytes=storedKey.bytes}return result}},{key:"couldBeginLoading_",value:function couldBeginLoading_(){return this.playlist_&&(this.sourceUpdater_||this.mimeType_&&this.state==="INIT")&&!this.paused()}},{key:"load",value:function load(){this.monitorBuffer_();if(!this.playlist_){return}this.syncController_.setDateTimeMapping(this.playlist_);if(this.state==="INIT"&&this.couldBeginLoading_()){return this.init_()}if(!this.couldBeginLoading_()||this.state!=="READY"&&this.state!=="INIT"){return}this.state="READY"}},{key:"init_",value:function init_(){this.state="READY";this.sourceUpdater_=new SourceUpdater(this.mediaSource_,this.mimeType_,this.loaderType_,this.sourceBufferEmitter_);this.resetEverything();return this.monitorBuffer_()}},{key:"playlist",value:function playlist(newPlaylist){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(!newPlaylist){return}var oldPlaylist=this.playlist_;var segmentInfo=this.pendingSegment_;this.playlist_=newPlaylist;this.xhrOptions_=options;if(!this.hasPlayed_()){newPlaylist.syncInfo={mediaSequence:newPlaylist.mediaSequence,time:0}}var oldId=null;if(oldPlaylist){if(oldPlaylist.id){oldId=oldPlaylist.id}else if(oldPlaylist.uri){oldId=oldPlaylist.uri}}this.logger_("playlist update ["+oldId+" => "+(newPlaylist.id||newPlaylist.uri)+"]");this.trigger("syncinfoupdate");if(this.state==="INIT"&&this.couldBeginLoading_()){return this.init_()}if(!oldPlaylist||oldPlaylist.uri!==newPlaylist.uri){if(this.mediaIndex!==null){this.resyncLoader()}return}var mediaSequenceDiff=newPlaylist.mediaSequence-oldPlaylist.mediaSequence;this.logger_("live window shift ["+mediaSequenceDiff+"]");if(this.mediaIndex!==null){this.mediaIndex-=mediaSequenceDiff}if(segmentInfo){segmentInfo.mediaIndex-=mediaSequenceDiff;if(segmentInfo.mediaIndex>=0){segmentInfo.segment=newPlaylist.segments[segmentInfo.mediaIndex]}}this.syncController_.saveExpiredSegmentInfo(oldPlaylist,newPlaylist)}},{key:"pause",value:function pause(){if(this.checkBufferTimeout_){window$1.clearTimeout(this.checkBufferTimeout_);this.checkBufferTimeout_=null}}},{key:"paused",value:function paused(){return this.checkBufferTimeout_===null}},{key:"mimeType",value:function mimeType(_mimeType,sourceBufferEmitter){if(this.mimeType_){return}this.mimeType_=_mimeType;this.sourceBufferEmitter_=sourceBufferEmitter;if(this.state==="INIT"&&this.couldBeginLoading_()){this.init_()}}},{key:"resetEverything",value:function resetEverything(done){this.ended_=false;this.resetLoader();this.remove(0,this.duration_(),done);if(this.captionParser_){this.captionParser_.clearAllCaptions()}this.trigger("reseteverything")}},{key:"resetLoader",value:function resetLoader(){this.fetchAtBuffer_=false;this.resyncLoader()}},{key:"resyncLoader",value:function resyncLoader(){this.mediaIndex=null;this.syncPoint_=null;this.abort()}},{key:"remove",value:function remove(start,end,done){if(this.sourceUpdater_){this.sourceUpdater_.remove(start,end,done)}removeCuesFromTrack(start,end,this.segmentMetadataTrack_);if(this.inbandTextTracks_){for(var id in this.inbandTextTracks_){removeCuesFromTrack(start,end,this.inbandTextTracks_[id])}}}},{key:"monitorBuffer_",value:function monitorBuffer_(){if(this.checkBufferTimeout_){window$1.clearTimeout(this.checkBufferTimeout_)}this.checkBufferTimeout_=window$1.setTimeout(this.monitorBufferTick_.bind(this),1)}},{key:"monitorBufferTick_",value:function monitorBufferTick_(){if(this.state==="READY"){this.fillBuffer_()}if(this.checkBufferTimeout_){window$1.clearTimeout(this.checkBufferTimeout_)}this.checkBufferTimeout_=window$1.setTimeout(this.monitorBufferTick_.bind(this),CHECK_BUFFER_DELAY)}},{key:"fillBuffer_",value:function fillBuffer_(){if(this.sourceUpdater_.updating()){return}if(!this.syncPoint_){this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_())}var segmentInfo=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(!segmentInfo){return}if(this.isEndOfStream_(segmentInfo.mediaIndex)){this.endOfStream();return}if(segmentInfo.mediaIndex===this.playlist_.segments.length-1&&this.mediaSource_.readyState==="ended"&&!this.seeking_()){return}if(segmentInfo.timeline!==this.currentTimeline_){this.syncController_.reset();segmentInfo.timestampOffset=segmentInfo.startOfSegment;if(this.captionParser_){this.captionParser_.clearAllCaptions()}}this.loadSegment_(segmentInfo)}},{key:"isEndOfStream_",value:function isEndOfStream_(mediaIndex){var playlist=arguments.length>1&&arguments[1]!==undefined?arguments[1]:this.playlist_;return detectEndOfStream(playlist,this.mediaSource_,mediaIndex)&&!this.sourceUpdater_.updating()}},{key:"checkBuffer_",value:function checkBuffer_(buffered,playlist,mediaIndex,hasPlayed,currentTime,syncPoint){var lastBufferedEnd=0;var startOfSegment=void 0;if(buffered.length){lastBufferedEnd=buffered.end(buffered.length-1)}var bufferedTime=Math.max(0,lastBufferedEnd-currentTime);if(!playlist.segments.length){return null}if(bufferedTime>=this.goalBufferLength_()){return null}if(!hasPlayed&&bufferedTime>=1){return null}if(syncPoint===null){mediaIndex=this.getSyncSegmentCandidate_(playlist);return this.generateSegmentInfo_(playlist,mediaIndex,null,true)}if(mediaIndex!==null){var segment=playlist.segments[mediaIndex];startOfSegment=lastBufferedEnd;return this.generateSegmentInfo_(playlist,mediaIndex+1,startOfSegment,false)}if(this.fetchAtBuffer_){var mediaSourceInfo=Playlist.getMediaInfoForTime(playlist,lastBufferedEnd,syncPoint.segmentIndex,syncPoint.time);mediaIndex=mediaSourceInfo.mediaIndex;startOfSegment=mediaSourceInfo.startTime}else{var _mediaSourceInfo=Playlist.getMediaInfoForTime(playlist,currentTime,syncPoint.segmentIndex,syncPoint.time);mediaIndex=_mediaSourceInfo.mediaIndex;startOfSegment=_mediaSourceInfo.startTime}return this.generateSegmentInfo_(playlist,mediaIndex,startOfSegment,false)}},{key:"getSyncSegmentCandidate_",value:function getSyncSegmentCandidate_(playlist){var _this2=this;if(this.currentTimeline_===-1){return 0}var segmentIndexArray=playlist.segments.map(function(s,i){return{timeline:s.timeline,segmentIndex:i}}).filter(function(s){return s.timeline===_this2.currentTimeline_});if(segmentIndexArray.length){return segmentIndexArray[Math.min(segmentIndexArray.length-1,1)].segmentIndex}return Math.max(playlist.segments.length-1,0)}},{key:"generateSegmentInfo_",value:function generateSegmentInfo_(playlist,mediaIndex,startOfSegment,isSyncRequest){if(mediaIndex<0||mediaIndex>=playlist.segments.length){return null}var segment=playlist.segments[mediaIndex];return{requestId:"segment-loader-"+Math.random(),uri:segment.resolvedUri,mediaIndex:mediaIndex,isSyncRequest:isSyncRequest,startOfSegment:startOfSegment,playlist:playlist,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:segment.timeline,duration:segment.duration,segment:segment}}},{key:"abortRequestEarly_",value:function abortRequestEarly_(stats){if(this.hls_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH){return false}if(Date.now()-(stats.firstBytesReceivedAt||Date.now())<1e3){return false}var currentTime=this.currentTime_();var measuredBandwidth=stats.bandwidth;var segmentDuration=this.pendingSegment_.duration;var requestTimeRemaining=Playlist.estimateSegmentRequestTime(segmentDuration,measuredBandwidth,this.playlist_,stats.bytesReceived);var timeUntilRebuffer$$1=timeUntilRebuffer(this.buffered_(),currentTime,this.hls_.tech_.playbackRate())-1;if(requestTimeRemaining<=timeUntilRebuffer$$1){return false}var switchCandidate=minRebufferMaxBandwidthSelector({master:this.hls_.playlists.master,currentTime:currentTime,bandwidth:measuredBandwidth,duration:this.duration_(),segmentDuration:segmentDuration,timeUntilRebuffer:timeUntilRebuffer$$1,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!switchCandidate){return}var rebufferingImpact=requestTimeRemaining-timeUntilRebuffer$$1;var timeSavedBySwitching=rebufferingImpact-switchCandidate.rebufferingImpact;var minimumTimeSaving=.5;if(timeUntilRebuffer$$1<=TIME_FUDGE_FACTOR){minimumTimeSaving=1}if(!switchCandidate.playlist||switchCandidate.playlist.uri===this.playlist_.uri||timeSavedBySwitching<minimumTimeSaving){return false}this.bandwidth=switchCandidate.playlist.attributes.BANDWIDTH*Config.BANDWIDTH_VARIANCE+1;this.abort();this.trigger("earlyabort");return true}},{key:"handleProgress_",value:function handleProgress_(event,simpleSegment){if(!this.pendingSegment_||simpleSegment.requestId!==this.pendingSegment_.requestId||this.abortRequestEarly_(simpleSegment.stats)){return}this.trigger("progress")}},{key:"loadSegment_",value:function loadSegment_(segmentInfo){this.state="WAITING";this.pendingSegment_=segmentInfo;this.trimBackBuffer_(segmentInfo);segmentInfo.abortRequests=mediaSegmentRequest(this.hls_.xhr,this.xhrOptions_,this.decrypter_,this.captionParser_,this.createSimplifiedSegmentObj_(segmentInfo),this.handleProgress_.bind(this),this.segmentRequestFinished_.bind(this))}},{key:"trimBackBuffer_",value:function trimBackBuffer_(segmentInfo){var removeToTime=safeBackBufferTrimTime(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);if(removeToTime>0){this.remove(0,removeToTime)}}},{key:"createSimplifiedSegmentObj_",value:function createSimplifiedSegmentObj_(segmentInfo){var segment=segmentInfo.segment;var simpleSegment={resolvedUri:segment.resolvedUri,byterange:segment.byterange,requestId:segmentInfo.requestId};if(segment.key){var iv=segment.key.iv||new Uint32Array([0,0,0,segmentInfo.mediaIndex+segmentInfo.playlist.mediaSequence]);simpleSegment.key=this.segmentKey(segment.key);simpleSegment.key.iv=iv}if(segment.map){simpleSegment.map=this.initSegment(segment.map)}return simpleSegment}},{key:"segmentRequestFinished_",value:function segmentRequestFinished_(error,simpleSegment){this.mediaRequests+=1;if(simpleSegment.stats){this.mediaBytesTransferred+=simpleSegment.stats.bytesReceived;this.mediaTransferDuration+=simpleSegment.stats.roundTripTime}if(!this.pendingSegment_){this.mediaRequestsAborted+=1;return}if(simpleSegment.requestId!==this.pendingSegment_.requestId){return}if(error){this.pendingSegment_=null;this.state="READY";if(error.code===REQUEST_ERRORS.ABORTED){this.mediaRequestsAborted+=1;return}this.pause();if(error.code===REQUEST_ERRORS.TIMEOUT){this.mediaRequestsTimedout+=1;this.bandwidth=1;this.roundTrip=NaN;this.trigger("bandwidthupdate");return}this.mediaRequestsErrored+=1;this.error(error);this.trigger("error");return}this.bandwidth=simpleSegment.stats.bandwidth;this.roundTrip=simpleSegment.stats.roundTripTime;if(simpleSegment.map){simpleSegment.map=this.initSegment(simpleSegment.map,true)}if(simpleSegment.key){this.segmentKey(simpleSegment.key,true)}this.processSegmentResponse_(simpleSegment)}},{key:"processSegmentResponse_",value:function processSegmentResponse_(simpleSegment){var segmentInfo=this.pendingSegment_;segmentInfo.bytes=simpleSegment.bytes;if(simpleSegment.map){segmentInfo.segment.map.bytes=simpleSegment.map.bytes}segmentInfo.endOfAllRequests=simpleSegment.endOfAllRequests;if(simpleSegment.fmp4Captions){createCaptionsTrackIfNotExists(this.inbandTextTracks_,this.hls_.tech_,simpleSegment.captionStreams);addCaptionData({inbandTextTracks:this.inbandTextTracks_,captionArray:simpleSegment.fmp4Captions,timestampOffset:0});if(this.captionParser_){this.captionParser_.clearParsedCaptions()}}this.handleSegment_()}},{key:"handleSegment_",value:function handleSegment_(){var _this3=this;if(!this.pendingSegment_){this.state="READY";return}var segmentInfo=this.pendingSegment_;var segment=segmentInfo.segment;var timingInfo=this.syncController_.probeSegmentInfo(segmentInfo);if(typeof this.startingMedia_==="undefined"&&timingInfo&&(timingInfo.containsAudio||timingInfo.containsVideo)){this.startingMedia_={containsAudio:timingInfo.containsAudio,containsVideo:timingInfo.containsVideo}}var illegalMediaSwitchError=illegalMediaSwitch(this.loaderType_,this.startingMedia_,timingInfo);if(illegalMediaSwitchError){this.error({message:illegalMediaSwitchError,blacklistDuration:Infinity});this.trigger("error");return}if(segmentInfo.isSyncRequest){this.trigger("syncinfoupdate");this.pendingSegment_=null;this.state="READY";return}if(segmentInfo.timestampOffset!==null&&segmentInfo.timestampOffset!==this.sourceUpdater_.timestampOffset()){if(timingInfo&&timingInfo.segmentTimestampInfo){var ptsStartTime=timingInfo.segmentTimestampInfo[0].ptsTime;var dtsStartTime=timingInfo.segmentTimestampInfo[0].dtsTime;segmentInfo.timestampOffset-=ptsStartTime-dtsStartTime}this.sourceUpdater_.timestampOffset(segmentInfo.timestampOffset);this.trigger("timestampoffset")}var timelineMapping=this.syncController_.mappingForTimeline(segmentInfo.timeline);if(timelineMapping!==null){this.trigger({type:"segmenttimemapping",mapping:timelineMapping})}this.state="APPENDING";if(segment.map){var initId=initSegmentId(segment.map);if(!this.activeInitSegmentId_||this.activeInitSegmentId_!==initId){var initSegment=this.initSegment(segment.map);this.sourceUpdater_.appendBuffer({bytes:initSegment.bytes},function(){_this3.activeInitSegmentId_=initId})}}segmentInfo.byteLength=segmentInfo.bytes.byteLength;if(typeof segment.start==="number"&&typeof segment.end==="number"){this.mediaSecondsLoaded+=segment.end-segment.start}else{this.mediaSecondsLoaded+=segment.duration}this.logger_(segmentInfoString(segmentInfo));this.sourceUpdater_.appendBuffer({bytes:segmentInfo.bytes,videoSegmentTimingInfoCallback:this.handleVideoSegmentTimingInfo_.bind(this,segmentInfo.requestId)},this.handleUpdateEnd_.bind(this))}},{key:"handleVideoSegmentTimingInfo_",value:function handleVideoSegmentTimingInfo_(requestId,event){if(!this.pendingSegment_||requestId!==this.pendingSegment_.requestId){return}var segment=this.pendingSegment_.segment;if(!segment.videoTimingInfo){segment.videoTimingInfo={}}segment.videoTimingInfo.transmuxerPrependedSeconds=event.videoSegmentTimingInfo.prependedContentDuration||0;segment.videoTimingInfo.transmuxedPresentationStart=event.videoSegmentTimingInfo.start.presentation;segment.videoTimingInfo.transmuxedPresentationEnd=event.videoSegmentTimingInfo.end.presentation;segment.videoTimingInfo.baseMediaDecodeTime=event.videoSegmentTimingInfo.baseMediaDecodeTime}},{key:"handleUpdateEnd_",value:function handleUpdateEnd_(){if(!this.pendingSegment_){this.state="READY";if(!this.paused()){this.monitorBuffer_()}return}var segmentInfo=this.pendingSegment_;var segment=segmentInfo.segment;var isWalkingForward=this.mediaIndex!==null;this.pendingSegment_=null;this.recordThroughput_(segmentInfo);this.addSegmentMetadataCue_(segmentInfo);this.state="READY";this.mediaIndex=segmentInfo.mediaIndex;this.fetchAtBuffer_=true;this.currentTimeline_=segmentInfo.timeline;this.trigger("syncinfoupdate");if(segment.end&&this.currentTime_()-segment.end>segmentInfo.playlist.targetDuration*3){this.resetEverything();return}if(isWalkingForward){this.trigger("bandwidthupdate")}this.trigger("progress");if(this.isEndOfStream_(segmentInfo.mediaIndex+1,segmentInfo.playlist)){this.endOfStream()}if(!this.paused()){this.monitorBuffer_()}}},{key:"recordThroughput_",value:function recordThroughput_(segmentInfo){var rate=this.throughput.rate;var segmentProcessingTime=Date.now()-segmentInfo.endOfAllRequests+1;var segmentProcessingThroughput=Math.floor(segmentInfo.byteLength/segmentProcessingTime*8*1e3);this.throughput.rate+=(segmentProcessingThroughput-rate)/++this.throughput.count}},{key:"addSegmentMetadataCue_",value:function addSegmentMetadataCue_(segmentInfo){if(!this.segmentMetadataTrack_){return}var segment=segmentInfo.segment;var start=segment.start;var end=segment.end;if(!finite(start)||!finite(end)){return}removeCuesFromTrack(start,end,this.segmentMetadataTrack_);var Cue=window$1.WebKitDataCue||window$1.VTTCue;var value={custom:segment.custom,dateTimeObject:segment.dateTimeObject,dateTimeString:segment.dateTimeString,bandwidth:segmentInfo.playlist.attributes.BANDWIDTH,resolution:segmentInfo.playlist.attributes.RESOLUTION,codecs:segmentInfo.playlist.attributes.CODECS,byteLength:segmentInfo.byteLength,uri:segmentInfo.uri,timeline:segmentInfo.timeline,playlist:segmentInfo.playlist.uri,start:start,end:end};var data=JSON.stringify(value);var cue=new Cue(start,end,data);cue.value=value;this.segmentMetadataTrack_.addCue(cue)}}]);return SegmentLoader}(videojs$1.EventTarget);var uint8ToUtf8=function uint8ToUtf8(uintArray){return decodeURIComponent(escape(String.fromCharCode.apply(null,uintArray)))};var VTT_LINE_TERMINATORS=new Uint8Array("\n\n".split("").map(function(_char2){return _char2.charCodeAt(0)}));var VTTSegmentLoader=function(_SegmentLoader){inherits$1(VTTSegmentLoader,_SegmentLoader);function VTTSegmentLoader(settings){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};classCallCheck$1(this,VTTSegmentLoader);var _this=possibleConstructorReturn$1(this,(VTTSegmentLoader.__proto__||Object.getPrototypeOf(VTTSegmentLoader)).call(this,settings,options));_this.mediaSource_=null;_this.subtitlesTrack_=null;return _this}createClass$1(VTTSegmentLoader,[{key:"buffered_",value:function buffered_(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length){return videojs$1.createTimeRanges()}var cues=this.subtitlesTrack_.cues;var start=cues[0].startTime;var end=cues[cues.length-1].startTime;return videojs$1.createTimeRanges([[start,end]])}},{key:"initSegment",value:function initSegment(map){var set$$1=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!map){return null}var id=initSegmentId(map);var storedMap=this.initSegments_[id];if(set$$1&&!storedMap&&map.bytes){var combinedByteLength=VTT_LINE_TERMINATORS.byteLength+map.bytes.byteLength;var combinedSegment=new Uint8Array(combinedByteLength);combinedSegment.set(map.bytes);combinedSegment.set(VTT_LINE_TERMINATORS,map.bytes.byteLength);this.initSegments_[id]=storedMap={resolvedUri:map.resolvedUri,byterange:map.byterange,bytes:combinedSegment}}return storedMap||map}},{key:"couldBeginLoading_",value:function couldBeginLoading_(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}},{key:"init_",value:function init_(){this.state="READY";this.resetEverything();return this.monitorBuffer_()}},{key:"track",value:function track(_track){if(typeof _track==="undefined"){return this.subtitlesTrack_}this.subtitlesTrack_=_track;if(this.state==="INIT"&&this.couldBeginLoading_()){this.init_()}return this.subtitlesTrack_}},{key:"remove",value:function remove(start,end){removeCuesFromTrack(start,end,this.subtitlesTrack_)}},{key:"fillBuffer_",value:function fillBuffer_(){var _this2=this;if(!this.syncPoint_){this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_())}var segmentInfo=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);segmentInfo=this.skipEmptySegments_(segmentInfo);if(!segmentInfo){return}if(this.syncController_.timestampOffsetForTimeline(segmentInfo.timeline)===null){var checkTimestampOffset=function checkTimestampOffset(){_this2.state="READY";if(!_this2.paused()){_this2.monitorBuffer_()}};this.syncController_.one("timestampoffset",checkTimestampOffset);this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(segmentInfo)}},{key:"skipEmptySegments_",value:function skipEmptySegments_(segmentInfo){while(segmentInfo&&segmentInfo.segment.empty){segmentInfo=this.generateSegmentInfo_(segmentInfo.playlist,segmentInfo.mediaIndex+1,segmentInfo.startOfSegment+segmentInfo.duration,segmentInfo.isSyncRequest)}return segmentInfo}},{key:"handleSegment_",value:function handleSegment_(){var _this3=this;if(!this.pendingSegment_||!this.subtitlesTrack_){this.state="READY";return}this.state="APPENDING";var segmentInfo=this.pendingSegment_;var segment=segmentInfo.segment;if(typeof window$1.WebVTT!=="function"&&this.subtitlesTrack_&&this.subtitlesTrack_.tech_){var loadHandler=void 0;var errorHandler=function errorHandler(){_this3.subtitlesTrack_.tech_.off("vttjsloaded",loadHandler);_this3.error({message:"Error loading vtt.js"});_this3.state="READY";_this3.pause();_this3.trigger("error")};loadHandler=function loadHandler(){_this3.subtitlesTrack_.tech_.off("vttjserror",errorHandler);_this3.handleSegment_()};this.state="WAITING_ON_VTTJS";this.subtitlesTrack_.tech_.one("vttjsloaded",loadHandler);this.subtitlesTrack_.tech_.one("vttjserror",errorHandler);return}segment.requested=true;try{this.parseVTTCues_(segmentInfo)}catch(e){this.error({message:e.message});this.state="READY";this.pause();return this.trigger("error")}this.updateTimeMapping_(segmentInfo,this.syncController_.timelines[segmentInfo.timeline],this.playlist_);if(segmentInfo.isSyncRequest){this.trigger("syncinfoupdate");this.pendingSegment_=null;this.state="READY";return}segmentInfo.byteLength=segmentInfo.bytes.byteLength;this.mediaSecondsLoaded+=segment.duration;if(segmentInfo.cues.length){this.remove(segmentInfo.cues[0].endTime,segmentInfo.cues[segmentInfo.cues.length-1].endTime)}segmentInfo.cues.forEach(function(cue){_this3.subtitlesTrack_.addCue(cue)});this.handleUpdateEnd_()}},{key:"parseVTTCues_",value:function parseVTTCues_(segmentInfo){var decoder=void 0;var decodeBytesToString=false;if(typeof window$1.TextDecoder==="function"){decoder=new window$1.TextDecoder("utf8")}else{decoder=window$1.WebVTT.StringDecoder();decodeBytesToString=true}var parser=new window$1.WebVTT.Parser(window$1,window$1.vttjs,decoder);segmentInfo.cues=[];segmentInfo.timestampmap={MPEGTS:0,LOCAL:0};parser.oncue=segmentInfo.cues.push.bind(segmentInfo.cues);parser.ontimestampmap=function(map){return segmentInfo.timestampmap=map};parser.onparsingerror=function(error){videojs$1.log.warn("Error encountered when parsing cues: "+error.message)};if(segmentInfo.segment.map){var mapData=segmentInfo.segment.map.bytes;if(decodeBytesToString){mapData=uint8ToUtf8(mapData)}parser.parse(mapData)}var segmentData=segmentInfo.bytes;if(decodeBytesToString){segmentData=uint8ToUtf8(segmentData)}parser.parse(segmentData);parser.flush()}},{key:"updateTimeMapping_",value:function updateTimeMapping_(segmentInfo,mappingObj,playlist){var segment=segmentInfo.segment;if(!mappingObj){return}if(!segmentInfo.cues.length){segment.empty=true;return}var timestampmap=segmentInfo.timestampmap;var diff=timestampmap.MPEGTS/9e4-timestampmap.LOCAL+mappingObj.mapping;segmentInfo.cues.forEach(function(cue){cue.startTime+=diff;cue.endTime+=diff});if(!playlist.syncInfo){var firstStart=segmentInfo.cues[0].startTime;var lastStart=segmentInfo.cues[segmentInfo.cues.length-1].startTime;playlist.syncInfo={mediaSequence:playlist.mediaSequence+segmentInfo.mediaIndex,time:Math.min(firstStart,lastStart-segment.duration)}}}}]);return VTTSegmentLoader}(SegmentLoader);var findAdCue=function findAdCue(track,mediaTime){var cues=track.cues;for(var i=0;i<cues.length;i++){var cue=cues[i];if(mediaTime>=cue.adStartTime&&mediaTime<=cue.adEndTime){return cue}}return null};var updateAdCues=function updateAdCues(media,track){var offset=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;if(!media.segments){return}var mediaTime=offset;var cue=void 0;for(var i=0;i<media.segments.length;i++){var segment=media.segments[i];if(!cue){cue=findAdCue(track,mediaTime+segment.duration/2)}if(cue){if("cueIn"in segment){cue.endTime=mediaTime;cue.adEndTime=mediaTime;mediaTime+=segment.duration;cue=null;continue}if(mediaTime<cue.endTime){mediaTime+=segment.duration;continue}cue.endTime+=segment.duration}else{if("cueOut"in segment){cue=new window$1.VTTCue(mediaTime,mediaTime+segment.duration,segment.cueOut);cue.adStartTime=mediaTime;cue.adEndTime=mediaTime+parseFloat(segment.cueOut);track.addCue(cue)}if("cueOutCont"in segment){var adOffset=void 0;var adTotal=void 0;var _segment$cueOutCont$s=segment.cueOutCont.split("/").map(parseFloat);var _segment$cueOutCont$s2=slicedToArray(_segment$cueOutCont$s,2);adOffset=_segment$cueOutCont$s2[0];adTotal=_segment$cueOutCont$s2[1];cue=new window$1.VTTCue(mediaTime,mediaTime+segment.duration,"");cue.adStartTime=mediaTime-adOffset;cue.adEndTime=cue.adStartTime+adTotal;track.addCue(cue)}}mediaTime+=segment.duration}};var tsprobe=tsInspector.inspect;var syncPointStrategies=[{name:"VOD",run:function run(syncController,playlist,duration$$1,currentTimeline,currentTime){if(duration$$1!==Infinity){var syncPoint={time:0,segmentIndex:0};return syncPoint}return null}},{name:"ProgramDateTime",run:function run(syncController,playlist,duration$$1,currentTimeline,currentTime){if(!syncController.datetimeToDisplayTime){return null}var segments=playlist.segments||[];var syncPoint=null;var lastDistance=null;currentTime=currentTime||0;for(var i=0;i<segments.length;i++){var segment=segments[i];if(segment.dateTimeObject){var segmentTime=segment.dateTimeObject.getTime()/1e3;var segmentStart=segmentTime+syncController.datetimeToDisplayTime;var distance=Math.abs(currentTime-segmentStart);if(lastDistance!==null&&(distance===0||lastDistance<distance)){break}lastDistance=distance;syncPoint={time:segmentStart,segmentIndex:i}}}return syncPoint}},{name:"Segment",run:function run(syncController,playlist,duration$$1,currentTimeline,currentTime){var segments=playlist.segments||[];var syncPoint=null;var lastDistance=null;currentTime=currentTime||0;for(var i=0;i<segments.length;i++){var segment=segments[i];if(segment.timeline===currentTimeline&&typeof segment.start!=="undefined"){var distance=Math.abs(currentTime-segment.start);if(lastDistance!==null&&lastDistance<distance){break}if(!syncPoint||lastDistance===null||lastDistance>=distance){lastDistance=distance;syncPoint={time:segment.start,segmentIndex:i}}}}return syncPoint}},{name:"Discontinuity",run:function run(syncController,playlist,duration$$1,currentTimeline,currentTime){var syncPoint=null;currentTime=currentTime||0;if(playlist.discontinuityStarts&&playlist.discontinuityStarts.length){var lastDistance=null;for(var i=0;i<playlist.discontinuityStarts.length;i++){var segmentIndex=playlist.discontinuityStarts[i];var discontinuity=playlist.discontinuitySequence+i+1;var discontinuitySync=syncController.discontinuities[discontinuity];if(discontinuitySync){var distance=Math.abs(currentTime-discontinuitySync.time);if(lastDistance!==null&&lastDistance<distance){break}if(!syncPoint||lastDistance===null||lastDistance>=distance){lastDistance=distance;syncPoint={time:discontinuitySync.time,segmentIndex:segmentIndex}}}}}return syncPoint}},{name:"Playlist",run:function run(syncController,playlist,duration$$1,currentTimeline,currentTime){if(playlist.syncInfo){var syncPoint={time:playlist.syncInfo.time,segmentIndex:playlist.syncInfo.mediaSequence-playlist.mediaSequence};return syncPoint}return null}}];var SyncController=function(_videojs$EventTarget){inherits$1(SyncController,_videojs$EventTarget);function SyncController(){classCallCheck$1(this,SyncController);var _this=possibleConstructorReturn$1(this,(SyncController.__proto__||Object.getPrototypeOf(SyncController)).call(this));_this.inspectCache_=undefined;_this.timelines=[];_this.discontinuities=[];_this.datetimeToDisplayTime=null;_this.logger_=logger("SyncController");return _this}createClass$1(SyncController,[{key:"getSyncPoint",value:function getSyncPoint(playlist,duration$$1,currentTimeline,currentTime){var syncPoints=this.runStrategies_(playlist,duration$$1,currentTimeline,currentTime);if(!syncPoints.length){return null}return this.selectSyncPoint_(syncPoints,{key:"time",value:currentTime})}},{key:"getExpiredTime",value:function getExpiredTime(playlist,duration$$1){if(!playlist||!playlist.segments){return null}var syncPoints=this.runStrategies_(playlist,duration$$1,playlist.discontinuitySequence,0);if(!syncPoints.length){return null}var syncPoint=this.selectSyncPoint_(syncPoints,{key:"segmentIndex",value:0});if(syncPoint.segmentIndex>0){syncPoint.time*=-1}return Math.abs(syncPoint.time+sumDurations(playlist,syncPoint.segmentIndex,0))}},{key:"runStrategies_",value:function runStrategies_(playlist,duration$$1,currentTimeline,currentTime){var syncPoints=[];for(var i=0;i<syncPointStrategies.length;i++){var strategy=syncPointStrategies[i];var syncPoint=strategy.run(this,playlist,duration$$1,currentTimeline,currentTime);if(syncPoint){syncPoint.strategy=strategy.name;syncPoints.push({strategy:strategy.name,syncPoint:syncPoint})}}return syncPoints}},{key:"selectSyncPoint_",value:function selectSyncPoint_(syncPoints,target){var bestSyncPoint=syncPoints[0].syncPoint;var bestDistance=Math.abs(syncPoints[0].syncPoint[target.key]-target.value);var bestStrategy=syncPoints[0].strategy;for(var i=1;i<syncPoints.length;i++){var newDistance=Math.abs(syncPoints[i].syncPoint[target.key]-target.value);if(newDistance<bestDistance){bestDistance=newDistance;bestSyncPoint=syncPoints[i].syncPoint;bestStrategy=syncPoints[i].strategy}}this.logger_("syncPoint for ["+target.key+": "+target.value+"] chosen with strategy"+(" ["+bestStrategy+"]: [time:"+bestSyncPoint.time+",")+(" segmentIndex:"+bestSyncPoint.segmentIndex+"]"));return bestSyncPoint}},{key:"saveExpiredSegmentInfo",value:function saveExpiredSegmentInfo(oldPlaylist,newPlaylist){var mediaSequenceDiff=newPlaylist.mediaSequence-oldPlaylist.mediaSequence;for(var i=mediaSequenceDiff-1;i>=0;i--){var lastRemovedSegment=oldPlaylist.segments[i];if(lastRemovedSegment&&typeof lastRemovedSegment.start!=="undefined"){newPlaylist.syncInfo={mediaSequence:oldPlaylist.mediaSequence+i,time:lastRemovedSegment.start};this.logger_("playlist refresh sync: [time:"+newPlaylist.syncInfo.time+","+(" mediaSequence: "+newPlaylist.syncInfo.mediaSequence+"]"));this.trigger("syncinfoupdate");break}}}},{key:"setDateTimeMapping",value:function setDateTimeMapping(playlist){if(!this.datetimeToDisplayTime&&playlist.segments&&playlist.segments.length&&playlist.segments[0].dateTimeObject){var playlistTimestamp=playlist.segments[0].dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-playlistTimestamp}}},{key:"reset",value:function reset(){this.inspectCache_=undefined}},{key:"probeSegmentInfo",value:function probeSegmentInfo(segmentInfo){var segment=segmentInfo.segment;var playlist=segmentInfo.playlist;var timingInfo=void 0;if(segment.map){timingInfo=this.probeMp4Segment_(segmentInfo)}else{timingInfo=this.probeTsSegment_(segmentInfo)}if(timingInfo){if(this.calculateSegmentTimeMapping_(segmentInfo,timingInfo)){this.saveDiscontinuitySyncInfo_(segmentInfo);if(!playlist.syncInfo){playlist.syncInfo={mediaSequence:playlist.mediaSequence+segmentInfo.mediaIndex,time:segment.start}}}}return timingInfo}},{key:"probeMp4Segment_",value:function probeMp4Segment_(segmentInfo){var segment=segmentInfo.segment;var timescales=probe.timescale(segment.map.bytes);var startTime=probe.startTime(timescales,segmentInfo.bytes);if(segmentInfo.timestampOffset!==null){segmentInfo.timestampOffset-=startTime}return{start:startTime,end:startTime+segment.duration}}},{key:"probeTsSegment_",value:function probeTsSegment_(segmentInfo){var timeInfo=tsprobe(segmentInfo.bytes,this.inspectCache_);var segmentStartTime=void 0;var segmentEndTime=void 0;var segmentTimestampInfo=void 0;if(!timeInfo){return null}if(timeInfo.video&&timeInfo.video.length===2){this.inspectCache_=timeInfo.video[1].dts;segmentStartTime=timeInfo.video[0].dtsTime;segmentEndTime=timeInfo.video[1].dtsTime;segmentTimestampInfo=timeInfo.video}else if(timeInfo.audio&&timeInfo.audio.length===2){this.inspectCache_=timeInfo.audio[1].dts;segmentStartTime=timeInfo.audio[0].dtsTime;segmentEndTime=timeInfo.audio[1].dtsTime;segmentTimestampInfo=timeInfo.audio}var probedInfo={segmentTimestampInfo:segmentTimestampInfo,start:segmentStartTime,end:segmentEndTime,containsVideo:timeInfo.video&&timeInfo.video.length===2,containsAudio:timeInfo.audio&&timeInfo.audio.length===2};return probedInfo}},{key:"timestampOffsetForTimeline",value:function timestampOffsetForTimeline(timeline){if(typeof this.timelines[timeline]==="undefined"){return null}return this.timelines[timeline].time}},{key:"mappingForTimeline",value:function mappingForTimeline(timeline){if(typeof this.timelines[timeline]==="undefined"){return null}return this.timelines[timeline].mapping}},{key:"calculateSegmentTimeMapping_",value:function calculateSegmentTimeMapping_(segmentInfo,timingInfo){var segment=segmentInfo.segment;var mappingObj=this.timelines[segmentInfo.timeline];if(segmentInfo.timestampOffset!==null){mappingObj={time:segmentInfo.startOfSegment,mapping:segmentInfo.startOfSegment-timingInfo.start};this.timelines[segmentInfo.timeline]=mappingObj;this.trigger("timestampoffset");this.logger_("time mapping for timeline "+segmentInfo.timeline+": "+("[time: "+mappingObj.time+"] [mapping: "+mappingObj.mapping+"]"));segment.start=segmentInfo.startOfSegment;segment.end=timingInfo.end+mappingObj.mapping}else if(mappingObj){segment.start=timingInfo.start+mappingObj.mapping;segment.end=timingInfo.end+mappingObj.mapping}else{return false}return true}},{key:"saveDiscontinuitySyncInfo_",value:function saveDiscontinuitySyncInfo_(segmentInfo){var playlist=segmentInfo.playlist;var segment=segmentInfo.segment;if(segment.discontinuity){this.discontinuities[segment.timeline]={time:segment.start,accuracy:0}}else if(playlist.discontinuityStarts&&playlist.discontinuityStarts.length){for(var i=0;i<playlist.discontinuityStarts.length;i++){var segmentIndex=playlist.discontinuityStarts[i];var discontinuity=playlist.discontinuitySequence+i+1;var mediaIndexDiff=segmentIndex-segmentInfo.mediaIndex;var accuracy=Math.abs(mediaIndexDiff);if(!this.discontinuities[discontinuity]||this.discontinuities[discontinuity].accuracy>accuracy){var time=void 0;if(mediaIndexDiff<0){time=segment.start-sumDurations(playlist,segmentInfo.mediaIndex,segmentIndex)}else{time=segment.end+sumDurations(playlist,segmentInfo.mediaIndex+1,segmentIndex)}this.discontinuities[discontinuity]={time:time,accuracy:accuracy}}}}}}]);return SyncController}(videojs$1.EventTarget);var Decrypter$1=new shimWorker("./decrypter-worker.worker.js",function(window,document$$1){var self=this;var decrypterWorker=function(){function unpad(padded){return padded.subarray(0,padded.byteLength-padded[padded.byteLength-1])}var classCallCheck=function classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}};var createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();var inherits=function inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass};var possibleConstructorReturn=function possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self};var precompute=function precompute(){var tables=[[[],[],[],[],[]],[[],[],[],[],[]]];var encTable=tables[0];var decTable=tables[1];var sbox=encTable[4];var sboxInv=decTable[4];var i=void 0;var x=void 0;var xInv=void 0;var d=[];var th=[];var x2=void 0;var x4=void 0;var x8=void 0;var s=void 0;var tEnc=void 0;var tDec=void 0;for(i=0;i<256;i++){th[(d[i]=i<<1^(i>>7)*283)^i]=i}for(x=xInv=0;!sbox[x];x^=x2||1,xInv=th[xInv]||1){s=xInv^xInv<<1^xInv<<2^xInv<<3^xInv<<4;s=s>>8^s&255^99;sbox[x]=s;sboxInv[s]=x;x8=d[x4=d[x2=d[x]]];tDec=x8*16843009^x4*65537^x2*257^x*16843008;tEnc=d[s]*257^s*16843008;for(i=0;i<4;i++){encTable[i][x]=tEnc=tEnc<<24^tEnc>>>8;decTable[i][s]=tDec=tDec<<24^tDec>>>8}}for(i=0;i<5;i++){encTable[i]=encTable[i].slice(0);decTable[i]=decTable[i].slice(0)}return tables};var aesTables=null;var AES=function(){function AES(key){classCallCheck(this,AES);if(!aesTables){aesTables=precompute()}this._tables=[[aesTables[0][0].slice(),aesTables[0][1].slice(),aesTables[0][2].slice(),aesTables[0][3].slice(),aesTables[0][4].slice()],[aesTables[1][0].slice(),aesTables[1][1].slice(),aesTables[1][2].slice(),aesTables[1][3].slice(),aesTables[1][4].slice()]];var i=void 0;var j=void 0;var tmp=void 0;var encKey=void 0;var decKey=void 0;var sbox=this._tables[0][4];var decTable=this._tables[1];var keyLen=key.length;var rcon=1;if(keyLen!==4&&keyLen!==6&&keyLen!==8){throw new Error("Invalid aes key size")}encKey=key.slice(0);decKey=[];this._key=[encKey,decKey];for(i=keyLen;i<4*keyLen+28;i++){tmp=encKey[i-1];if(i%keyLen===0||keyLen===8&&i%keyLen===4){tmp=sbox[tmp>>>24]<<24^sbox[tmp>>16&255]<<16^sbox[tmp>>8&255]<<8^sbox[tmp&255];if(i%keyLen===0){tmp=tmp<<8^tmp>>>24^rcon<<24;rcon=rcon<<1^(rcon>>7)*283}}encKey[i]=encKey[i-keyLen]^tmp}for(j=0;i;j++,i--){tmp=encKey[j&3?i:i-4];if(i<=4||j<4){decKey[j]=tmp}else{decKey[j]=decTable[0][sbox[tmp>>>24]]^decTable[1][sbox[tmp>>16&255]]^decTable[2][sbox[tmp>>8&255]]^decTable[3][sbox[tmp&255]]}}}AES.prototype.decrypt=function decrypt$$1(encrypted0,encrypted1,encrypted2,encrypted3,out,offset){var key=this._key[1];var a=encrypted0^key[0];var b=encrypted3^key[1];var c=encrypted2^key[2];var d=encrypted1^key[3];var a2=void 0;var b2=void 0;var c2=void 0;var nInnerRounds=key.length/4-2;var i=void 0;var kIndex=4;var table=this._tables[1];var table0=table[0];var table1=table[1];var table2=table[2];var table3=table[3];var sbox=table[4];for(i=0;i<nInnerRounds;i++){a2=table0[a>>>24]^table1[b>>16&255]^table2[c>>8&255]^table3[d&255]^key[kIndex];b2=table0[b>>>24]^table1[c>>16&255]^table2[d>>8&255]^table3[a&255]^key[kIndex+1];c2=table0[c>>>24]^table1[d>>16&255]^table2[a>>8&255]^table3[b&255]^key[kIndex+2];d=table0[d>>>24]^table1[a>>16&255]^table2[b>>8&255]^table3[c&255]^key[kIndex+3];kIndex+=4;a=a2;b=b2;c=c2}for(i=0;i<4;i++){out[(3&-i)+offset]=sbox[a>>>24]<<24^sbox[b>>16&255]<<16^sbox[c>>8&255]<<8^sbox[d&255]^key[kIndex++];a2=a;a=b;b=c;c=d;d=a2}};return AES}();var Stream=function(){function Stream(){classCallCheck(this,Stream);this.listeners={}}Stream.prototype.on=function on(type,listener){if(!this.listeners[type]){this.listeners[type]=[]}this.listeners[type].push(listener)};Stream.prototype.off=function off(type,listener){if(!this.listeners[type]){return false}var index=this.listeners[type].indexOf(listener);this.listeners[type].splice(index,1);return index>-1};Stream.prototype.trigger=function trigger(type){var callbacks=this.listeners[type];if(!callbacks){return}if(arguments.length===2){var length=callbacks.length;for(var i=0;i<length;++i){callbacks[i].call(this,arguments[1])}}else{var args=Array.prototype.slice.call(arguments,1);var _length=callbacks.length;for(var _i=0;_i<_length;++_i){callbacks[_i].apply(this,args)}}};Stream.prototype.dispose=function dispose(){this.listeners={}};Stream.prototype.pipe=function pipe(destination){this.on("data",function(data){destination.push(data)})};return Stream}();var AsyncStream$$1=function(_Stream){inherits(AsyncStream$$1,_Stream);function AsyncStream$$1(){classCallCheck(this,AsyncStream$$1);var _this=possibleConstructorReturn(this,_Stream.call(this,Stream));_this.jobs=[];_this.delay=1;_this.timeout_=null;return _this}AsyncStream$$1.prototype.processJob_=function processJob_(){this.jobs.shift()();if(this.jobs.length){this.timeout_=setTimeout(this.processJob_.bind(this),this.delay)}else{this.timeout_=null}};AsyncStream$$1.prototype.push=function push(job){this.jobs.push(job);if(!this.timeout_){this.timeout_=setTimeout(this.processJob_.bind(this),this.delay)}};return AsyncStream$$1}(Stream);var ntoh=function ntoh(word){return word<<24|(word&65280)<<8|(word&16711680)>>8|word>>>24};var decrypt$$1=function decrypt$$1(encrypted,key,initVector){var encrypted32=new Int32Array(encrypted.buffer,encrypted.byteOffset,encrypted.byteLength>>2);var decipher=new AES(Array.prototype.slice.call(key));var decrypted=new Uint8Array(encrypted.byteLength);var decrypted32=new Int32Array(decrypted.buffer);var init0=void 0;var init1=void 0;var init2=void 0;var init3=void 0;var encrypted0=void 0;var encrypted1=void 0;var encrypted2=void 0;var encrypted3=void 0;var wordIx=void 0;init0=initVector[0];init1=initVector[1];init2=initVector[2];init3=initVector[3];for(wordIx=0;wordIx<encrypted32.length;wordIx+=4){encrypted0=ntoh(encrypted32[wordIx]);encrypted1=ntoh(encrypted32[wordIx+1]);encrypted2=ntoh(encrypted32[wordIx+2]);encrypted3=ntoh(encrypted32[wordIx+3]);decipher.decrypt(encrypted0,encrypted1,encrypted2,encrypted3,decrypted32,wordIx);decrypted32[wordIx]=ntoh(decrypted32[wordIx]^init0);decrypted32[wordIx+1]=ntoh(decrypted32[wordIx+1]^init1);decrypted32[wordIx+2]=ntoh(decrypted32[wordIx+2]^init2);decrypted32[wordIx+3]=ntoh(decrypted32[wordIx+3]^init3);init0=encrypted0;init1=encrypted1;init2=encrypted2;init3=encrypted3}return decrypted};var Decrypter$$1=function(){function Decrypter$$1(encrypted,key,initVector,done){classCallCheck(this,Decrypter$$1);var step=Decrypter$$1.STEP;var encrypted32=new Int32Array(encrypted.buffer);var decrypted=new Uint8Array(encrypted.byteLength);var i=0;this.asyncStream_=new AsyncStream$$1;this.asyncStream_.push(this.decryptChunk_(encrypted32.subarray(i,i+step),key,initVector,decrypted));for(i=step;i<encrypted32.length;i+=step){initVector=new Uint32Array([ntoh(encrypted32[i-4]),ntoh(encrypted32[i-3]),ntoh(encrypted32[i-2]),ntoh(encrypted32[i-1])]);this.asyncStream_.push(this.decryptChunk_(encrypted32.subarray(i,i+step),key,initVector,decrypted))}this.asyncStream_.push(function(){done(null,unpad(decrypted))})}Decrypter$$1.prototype.decryptChunk_=function decryptChunk_(encrypted,key,initVector,decrypted){return function(){var bytes=decrypt$$1(encrypted,key,initVector);decrypted.set(bytes,encrypted.byteOffset)}};createClass(Decrypter$$1,null,[{key:"STEP",get:function get$$1(){return 32e3}}]);return Decrypter$$1}();var createTransferableMessage=function createTransferableMessage(message){var transferable={};Object.keys(message).forEach(function(key){var value=message[key];if(ArrayBuffer.isView(value)){transferable[key]={bytes:value.buffer,byteOffset:value.byteOffset,byteLength:value.byteLength}}else{transferable[key]=value}});return transferable};var DecrypterWorker=function DecrypterWorker(self){self.onmessage=function(event){var data=event.data;var encrypted=new Uint8Array(data.encrypted.bytes,data.encrypted.byteOffset,data.encrypted.byteLength);var key=new Uint32Array(data.key.bytes,data.key.byteOffset,data.key.byteLength/4);var iv=new Uint32Array(data.iv.bytes,data.iv.byteOffset,data.iv.byteLength/4);new Decrypter$$1(encrypted,key,iv,function(err,bytes){self.postMessage(createTransferableMessage({source:data.source,decrypted:bytes}),[bytes.buffer])})}};var decrypterWorker=new DecrypterWorker(self);return decrypterWorker}()});var audioTrackKind_=function audioTrackKind_(properties){var kind=properties["default"]?"main":"alternative";if(properties.characteristics&&properties.characteristics.indexOf("public.accessibility.describes-video")>=0){kind="main-desc"}return kind};var stopLoaders=function stopLoaders(segmentLoader,mediaType){segmentLoader.abort();segmentLoader.pause();if(mediaType&&mediaType.activePlaylistLoader){mediaType.activePlaylistLoader.pause();mediaType.activePlaylistLoader=null}};var startLoaders=function startLoaders(playlistLoader,mediaType){mediaType.activePlaylistLoader=playlistLoader;playlistLoader.load()};var onGroupChanged=function onGroupChanged(type,settings){return function(){var _settings$segmentLoad=settings.segmentLoaders,segmentLoader=_settings$segmentLoad[type],mainSegmentLoader=_settings$segmentLoad.main,mediaType=settings.mediaTypes[type];var activeTrack=mediaType.activeTrack();var activeGroup=mediaType.activeGroup(activeTrack);var previousActiveLoader=mediaType.activePlaylistLoader;stopLoaders(segmentLoader,mediaType);if(!activeGroup){return}if(!activeGroup.playlistLoader){if(previousActiveLoader){mainSegmentLoader.resetEverything()}return}segmentLoader.resyncLoader();startLoaders(activeGroup.playlistLoader,mediaType)}};var onTrackChanged=function onTrackChanged(type,settings){return function(){var _settings$segmentLoad2=settings.segmentLoaders,segmentLoader=_settings$segmentLoad2[type],mainSegmentLoader=_settings$segmentLoad2.main,mediaType=settings.mediaTypes[type];var activeTrack=mediaType.activeTrack();var activeGroup=mediaType.activeGroup(activeTrack);var previousActiveLoader=mediaType.activePlaylistLoader;stopLoaders(segmentLoader,mediaType);if(!activeGroup){return}if(!activeGroup.playlistLoader){mainSegmentLoader.resetEverything();return}if(previousActiveLoader===activeGroup.playlistLoader){startLoaders(activeGroup.playlistLoader,mediaType);return}if(segmentLoader.track){segmentLoader.track(activeTrack)}segmentLoader.resetEverything();startLoaders(activeGroup.playlistLoader,mediaType)}};var onError={AUDIO:function AUDIO(type,settings){return function(){var segmentLoader=settings.segmentLoaders[type],mediaType=settings.mediaTypes[type],blacklistCurrentPlaylist=settings.blacklistCurrentPlaylist;stopLoaders(segmentLoader,mediaType);var activeTrack=mediaType.activeTrack();var activeGroup=mediaType.activeGroup();var id=(activeGroup.filter(function(group){return group["default"]})[0]||activeGroup[0]).id;var defaultTrack=mediaType.tracks[id];if(activeTrack===defaultTrack){blacklistCurrentPlaylist({message:"Problem encountered loading the default audio track."});return}videojs$1.log.warn("Problem encountered loading the alternate audio track."+"Switching back to default.");for(var trackId in mediaType.tracks){mediaType.tracks[trackId].enabled=mediaType.tracks[trackId]===defaultTrack}mediaType.onTrackChanged()}},SUBTITLES:function SUBTITLES(type,settings){return function(){var segmentLoader=settings.segmentLoaders[type],mediaType=settings.mediaTypes[type];videojs$1.log.warn("Problem encountered loading the subtitle track."+"Disabling subtitle track.");stopLoaders(segmentLoader,mediaType);var track=mediaType.activeTrack();if(track){track.mode="disabled"}mediaType.onTrackChanged()}}};var setupListeners={AUDIO:function AUDIO(type,playlistLoader,settings){if(!playlistLoader){return}var tech=settings.tech,requestOptions=settings.requestOptions,segmentLoader=settings.segmentLoaders[type];playlistLoader.on("loadedmetadata",function(){var media=playlistLoader.media();segmentLoader.playlist(media,requestOptions);if(!tech.paused()||media.endList&&tech.preload()!=="none"){segmentLoader.load()}});playlistLoader.on("loadedplaylist",function(){segmentLoader.playlist(playlistLoader.media(),requestOptions);if(!tech.paused()){segmentLoader.load()}});playlistLoader.on("error",onError[type](type,settings))},SUBTITLES:function SUBTITLES(type,playlistLoader,settings){var tech=settings.tech,requestOptions=settings.requestOptions,segmentLoader=settings.segmentLoaders[type],mediaType=settings.mediaTypes[type];playlistLoader.on("loadedmetadata",function(){var media=playlistLoader.media();segmentLoader.playlist(media,requestOptions);segmentLoader.track(mediaType.activeTrack());if(!tech.paused()||media.endList&&tech.preload()!=="none"){segmentLoader.load()}});playlistLoader.on("loadedplaylist",function(){segmentLoader.playlist(playlistLoader.media(),requestOptions);if(!tech.paused()){segmentLoader.load()}});playlistLoader.on("error",onError[type](type,settings))}};var initialize={AUDIO:function AUDIO(type,settings){var hls=settings.hls,sourceType=settings.sourceType,segmentLoader=settings.segmentLoaders[type],requestOptions=settings.requestOptions,mediaGroups=settings.master.mediaGroups,_settings$mediaTypes$=settings.mediaTypes[type],groups=_settings$mediaTypes$.groups,tracks=_settings$mediaTypes$.tracks,masterPlaylistLoader=settings.masterPlaylistLoader;if(!mediaGroups[type]||Object.keys(mediaGroups[type]).length===0){mediaGroups[type]={main:{default:{default:true}}}}for(var groupId in mediaGroups[type]){if(!groups[groupId]){groups[groupId]=[]}for(var variantLabel in mediaGroups[type][groupId]){var properties=mediaGroups[type][groupId][variantLabel];var playlistLoader=void 0;if(properties.resolvedUri){playlistLoader=new PlaylistLoader(properties.resolvedUri,hls,requestOptions)}else if(properties.playlists&&sourceType==="dash"){playlistLoader=new DashPlaylistLoader(properties.playlists[0],hls,requestOptions,masterPlaylistLoader)}else{playlistLoader=null}properties=videojs$1.mergeOptions({id:variantLabel,playlistLoader:playlistLoader},properties);setupListeners[type](type,properties.playlistLoader,settings);groups[groupId].push(properties);if(typeof tracks[variantLabel]==="undefined"){var track=new videojs$1.AudioTrack({id:variantLabel,kind:audioTrackKind_(properties),enabled:false,language:properties.language,default:properties["default"],label:variantLabel});tracks[variantLabel]=track}}}segmentLoader.on("error",onError[type](type,settings))},SUBTITLES:function SUBTITLES(type,settings){var tech=settings.tech,hls=settings.hls,sourceType=settings.sourceType,segmentLoader=settings.segmentLoaders[type],requestOptions=settings.requestOptions,mediaGroups=settings.master.mediaGroups,_settings$mediaTypes$2=settings.mediaTypes[type],groups=_settings$mediaTypes$2.groups,tracks=_settings$mediaTypes$2.tracks,masterPlaylistLoader=settings.masterPlaylistLoader;for(var groupId in mediaGroups[type]){if(!groups[groupId]){groups[groupId]=[]}for(var variantLabel in mediaGroups[type][groupId]){if(mediaGroups[type][groupId][variantLabel].forced){continue}var properties=mediaGroups[type][groupId][variantLabel];var playlistLoader=void 0;if(sourceType==="hls"){playlistLoader=new PlaylistLoader(properties.resolvedUri,hls,requestOptions)}else if(sourceType==="dash"){playlistLoader=new DashPlaylistLoader(properties.playlists[0],hls,requestOptions,masterPlaylistLoader)}properties=videojs$1.mergeOptions({id:variantLabel,playlistLoader:playlistLoader},properties);setupListeners[type](type,properties.playlistLoader,settings);groups[groupId].push(properties);if(typeof tracks[variantLabel]==="undefined"){var track=tech.addRemoteTextTrack({id:variantLabel,kind:"subtitles",default:properties["default"]&&properties.autoselect,language:properties.language,label:variantLabel},false).track;tracks[variantLabel]=track}}}segmentLoader.on("error",onError[type](type,settings))},"CLOSED-CAPTIONS":function CLOSEDCAPTIONS(type,settings){var tech=settings.tech,mediaGroups=settings.master.mediaGroups,_settings$mediaTypes$3=settings.mediaTypes[type],groups=_settings$mediaTypes$3.groups,tracks=_settings$mediaTypes$3.tracks;for(var groupId in mediaGroups[type]){if(!groups[groupId]){groups[groupId]=[]}for(var variantLabel in mediaGroups[type][groupId]){var properties=mediaGroups[type][groupId][variantLabel];if(!properties.instreamId.match(/CC\d/)){continue}groups[groupId].push(videojs$1.mergeOptions({id:variantLabel},properties));if(typeof tracks[variantLabel]==="undefined"){var track=tech.addRemoteTextTrack({id:properties.instreamId,kind:"captions",default:properties["default"]&&properties.autoselect,language:properties.language,label:variantLabel},false).track;tracks[variantLabel]=track}}}}};var activeGroup=function activeGroup(type,settings){return function(track){var masterPlaylistLoader=settings.masterPlaylistLoader,groups=settings.mediaTypes[type].groups;var media=masterPlaylistLoader.media();if(!media){return null}var variants=null;if(media.attributes[type]){variants=groups[media.attributes[type]]}variants=variants||groups.main;if(typeof track==="undefined"){return variants}if(track===null){return null}return variants.filter(function(props){return props.id===track.id})[0]||null}};var activeTrack={AUDIO:function AUDIO(type,settings){return function(){var tracks=settings.mediaTypes[type].tracks;for(var id in tracks){if(tracks[id].enabled){return tracks[id]}}return null}},SUBTITLES:function SUBTITLES(type,settings){return function(){var tracks=settings.mediaTypes[type].tracks;for(var id in tracks){if(tracks[id].mode==="showing"){return tracks[id]}}return null}}};var setupMediaGroups=function setupMediaGroups(settings){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(type){initialize[type](type,settings)});var mediaTypes=settings.mediaTypes,masterPlaylistLoader=settings.masterPlaylistLoader,tech=settings.tech,hls=settings.hls;["AUDIO","SUBTITLES"].forEach(function(type){mediaTypes[type].activeGroup=activeGroup(type,settings);mediaTypes[type].activeTrack=activeTrack[type](type,settings);mediaTypes[type].onGroupChanged=onGroupChanged(type,settings);mediaTypes[type].onTrackChanged=onTrackChanged(type,settings)});var audioGroup=mediaTypes.AUDIO.activeGroup();var groupId=(audioGroup.filter(function(group){return group["default"]})[0]||audioGroup[0]).id;mediaTypes.AUDIO.tracks[groupId].enabled=true;mediaTypes.AUDIO.onTrackChanged();masterPlaylistLoader.on("mediachange",function(){["AUDIO","SUBTITLES"].forEach(function(type){return mediaTypes[type].onGroupChanged()})});var onAudioTrackChanged=function onAudioTrackChanged(){mediaTypes.AUDIO.onTrackChanged();tech.trigger({type:"usage",name:"hls-audio-change"})};tech.audioTracks().addEventListener("change",onAudioTrackChanged);tech.remoteTextTracks().addEventListener("change",mediaTypes.SUBTITLES.onTrackChanged);hls.on("dispose",function(){tech.audioTracks().removeEventListener("change",onAudioTrackChanged);tech.remoteTextTracks().removeEventListener("change",mediaTypes.SUBTITLES.onTrackChanged)});tech.clearTracks("audio");for(var id in mediaTypes.AUDIO.tracks){tech.audioTracks().addTrack(mediaTypes.AUDIO.tracks[id])}};var createMediaTypes=function createMediaTypes(){var mediaTypes={};["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(type){mediaTypes[type]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:noop$1,activeTrack:noop$1,onGroupChanged:noop$1,onTrackChanged:noop$1}});return mediaTypes};var ABORT_EARLY_BLACKLIST_SECONDS=60*2;var Hls=void 0;var loaderStats=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"];var sumLoaderStat=function sumLoaderStat(stat){return this.audioSegmentLoader_[stat]+this.mainSegmentLoader_[stat]};var MasterPlaylistController=function(_videojs$EventTarget){inherits$1(MasterPlaylistController,_videojs$EventTarget);function MasterPlaylistController(options){classCallCheck$1(this,MasterPlaylistController);var _this=possibleConstructorReturn$1(this,(MasterPlaylistController.__proto__||Object.getPrototypeOf(MasterPlaylistController)).call(this));var url=options.url,handleManifestRedirects=options.handleManifestRedirects,withCredentials=options.withCredentials,tech=options.tech,bandwidth=options.bandwidth,externHls=options.externHls,useCueTags=options.useCueTags,blacklistDuration=options.blacklistDuration,enableLowInitialPlaylist=options.enableLowInitialPlaylist,sourceType=options.sourceType,seekTo=options.seekTo,cacheEncryptionKeys=options.cacheEncryptionKeys;if(!url){throw new Error("A non-empty playlist URL is required")}Hls=externHls;_this.withCredentials=withCredentials;_this.tech_=tech;_this.hls_=tech.hls;_this.seekTo_=seekTo;_this.sourceType_=sourceType;_this.useCueTags_=useCueTags;_this.blacklistDuration=blacklistDuration;_this.enableLowInitialPlaylist=enableLowInitialPlaylist;if(_this.useCueTags_){_this.cueTagsTrack_=_this.tech_.addTextTrack("metadata","ad-cues");_this.cueTagsTrack_.inBandMetadataTrackDispatchType=""}_this.requestOptions_={withCredentials:withCredentials,handleManifestRedirects:handleManifestRedirects,timeout:null};_this.mediaTypes_=createMediaTypes();_this.mediaSource=new videojs$1.MediaSource;_this.mediaSource.addEventListener("sourceopen",_this.handleSourceOpen_.bind(_this));_this.seekable_=videojs$1.createTimeRanges();_this.hasPlayed_=function(){return false};_this.syncController_=new SyncController(options);_this.segmentMetadataTrack_=tech.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},false).track;_this.decrypter_=new Decrypter$1;_this.inbandTextTracks_={};var segmentLoaderSettings={hls:_this.hls_,mediaSource:_this.mediaSource,currentTime:_this.tech_.currentTime.bind(_this.tech_),seekable:function seekable$$1(){return _this.seekable()},seeking:function seeking(){return _this.tech_.seeking()},duration:function duration$$1(){return _this.mediaSource.duration},hasPlayed:function hasPlayed(){return _this.hasPlayed_()},goalBufferLength:function goalBufferLength(){return _this.goalBufferLength()},bandwidth:bandwidth,syncController:_this.syncController_,decrypter:_this.decrypter_,sourceType:_this.sourceType_,inbandTextTracks:_this.inbandTextTracks_,cacheEncryptionKeys:cacheEncryptionKeys};_this.masterPlaylistLoader_=_this.sourceType_==="dash"?new DashPlaylistLoader(url,_this.hls_,_this.requestOptions_):new PlaylistLoader(url,_this.hls_,_this.requestOptions_);_this.setupMasterPlaylistLoaderListeners_();_this.mainSegmentLoader_=new SegmentLoader(videojs$1.mergeOptions(segmentLoaderSettings,{segmentMetadataTrack:_this.segmentMetadataTrack_,loaderType:"main"}),options);_this.audioSegmentLoader_=new SegmentLoader(videojs$1.mergeOptions(segmentLoaderSettings,{loaderType:"audio"}),options);_this.subtitleSegmentLoader_=new VTTSegmentLoader(videojs$1.mergeOptions(segmentLoaderSettings,{loaderType:"vtt"}),options);_this.setupSegmentLoaderListeners_();loaderStats.forEach(function(stat){_this[stat+"_"]=sumLoaderStat.bind(_this,stat)});_this.logger_=logger("MPC");_this.masterPlaylistLoader_.load();return _this}createClass$1(MasterPlaylistController,[{key:"setupMasterPlaylistLoaderListeners_",value:function setupMasterPlaylistLoaderListeners_(){var _this2=this;this.masterPlaylistLoader_.on("loadedmetadata",function(){var media=_this2.masterPlaylistLoader_.media();var requestTimeout=media.targetDuration*1.5*1e3;if(isLowestEnabledRendition(_this2.masterPlaylistLoader_.master,_this2.masterPlaylistLoader_.media())){_this2.requestOptions_.timeout=0}else{_this2.requestOptions_.timeout=requestTimeout}if(media.endList&&_this2.tech_.preload()!=="none"){_this2.mainSegmentLoader_.playlist(media,_this2.requestOptions_);_this2.mainSegmentLoader_.load()}setupMediaGroups({sourceType:_this2.sourceType_,segmentLoaders:{AUDIO:_this2.audioSegmentLoader_,SUBTITLES:_this2.subtitleSegmentLoader_,main:_this2.mainSegmentLoader_},tech:_this2.tech_,requestOptions:_this2.requestOptions_,masterPlaylistLoader:_this2.masterPlaylistLoader_,hls:_this2.hls_,master:_this2.master(),mediaTypes:_this2.mediaTypes_,blacklistCurrentPlaylist:_this2.blacklistCurrentPlaylist.bind(_this2)});_this2.triggerPresenceUsage_(_this2.master(),media);try{_this2.setupSourceBuffers_()}catch(e){videojs$1.log.warn("Failed to create SourceBuffers",e);return _this2.mediaSource.endOfStream("decode")}_this2.setupFirstPlay();if(!_this2.mediaTypes_.AUDIO.activePlaylistLoader||_this2.mediaTypes_.AUDIO.activePlaylistLoader.media()){_this2.trigger("selectedinitialmedia")}else{_this2.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",function(){_this2.trigger("selectedinitialmedia")})}});this.masterPlaylistLoader_.on("loadedplaylist",function(){var updatedPlaylist=_this2.masterPlaylistLoader_.media();if(!updatedPlaylist){_this2.excludeUnsupportedVariants_();var selectedMedia=void 0;if(_this2.enableLowInitialPlaylist){selectedMedia=_this2.selectInitialPlaylist()}if(!selectedMedia){selectedMedia=_this2.selectPlaylist()}_this2.initialMedia_=selectedMedia;_this2.masterPlaylistLoader_.media(_this2.initialMedia_);return}if(_this2.useCueTags_){_this2.updateAdCues_(updatedPlaylist)}_this2.mainSegmentLoader_.playlist(updatedPlaylist,_this2.requestOptions_);_this2.updateDuration();if(!_this2.tech_.paused()){_this2.mainSegmentLoader_.load();if(_this2.audioSegmentLoader_){_this2.audioSegmentLoader_.load()}}if(!updatedPlaylist.endList){var addSeekableRange=function addSeekableRange(){var seekable$$1=_this2.seekable();if(seekable$$1.length!==0){_this2.mediaSource.addSeekableRange_(seekable$$1.start(0),seekable$$1.end(0))}};if(_this2.duration()!==Infinity){var onDurationchange=function onDurationchange(){if(_this2.duration()===Infinity){addSeekableRange()}else{_this2.tech_.one("durationchange",onDurationchange)}};_this2.tech_.one("durationchange",onDurationchange)}else{addSeekableRange()}}});this.masterPlaylistLoader_.on("error",function(){_this2.blacklistCurrentPlaylist(_this2.masterPlaylistLoader_.error)});this.masterPlaylistLoader_.on("mediachanging",function(){_this2.mainSegmentLoader_.abort();_this2.mainSegmentLoader_.pause()});this.masterPlaylistLoader_.on("mediachange",function(){var media=_this2.masterPlaylistLoader_.media();var requestTimeout=media.targetDuration*1.5*1e3;if(isLowestEnabledRendition(_this2.masterPlaylistLoader_.master,_this2.masterPlaylistLoader_.media())){_this2.requestOptions_.timeout=0}else{_this2.requestOptions_.timeout=requestTimeout}_this2.mainSegmentLoader_.playlist(media,_this2.requestOptions_);_this2.mainSegmentLoader_.load();_this2.tech_.trigger({type:"mediachange",bubbles:true})});this.masterPlaylistLoader_.on("playlistunchanged",function(){var updatedPlaylist=_this2.masterPlaylistLoader_.media();var playlistOutdated=_this2.stuckAtPlaylistEnd_(updatedPlaylist);if(playlistOutdated){_this2.blacklistCurrentPlaylist({message:"Playlist no longer updating."});_this2.tech_.trigger("playliststuck")}});this.masterPlaylistLoader_.on("renditiondisabled",function(){_this2.tech_.trigger({type:"usage",name:"hls-rendition-disabled"})});this.masterPlaylistLoader_.on("renditionenabled",function(){_this2.tech_.trigger({type:"usage",name:"hls-rendition-enabled"})})}},{key:"triggerPresenceUsage_",value:function triggerPresenceUsage_(master,media){var mediaGroups=master.mediaGroups||{};var defaultDemuxed=true;var audioGroupKeys=Object.keys(mediaGroups.AUDIO);for(var mediaGroup in mediaGroups.AUDIO){for(var label in mediaGroups.AUDIO[mediaGroup]){var properties=mediaGroups.AUDIO[mediaGroup][label];if(!properties.uri){defaultDemuxed=false}}}if(defaultDemuxed){this.tech_.trigger({type:"usage",name:"hls-demuxed"})}if(Object.keys(mediaGroups.SUBTITLES).length){this.tech_.trigger({type:"usage",name:"hls-webvtt"})}if(Hls.Playlist.isAes(media)){this.tech_.trigger({type:"usage",name:"hls-aes"})}if(Hls.Playlist.isFmp4(media)){this.tech_.trigger({type:"usage",name:"hls-fmp4"})}if(audioGroupKeys.length&&Object.keys(mediaGroups.AUDIO[audioGroupKeys[0]]).length>1){this.tech_.trigger({type:"usage",name:"hls-alternate-audio"})}if(this.useCueTags_){this.tech_.trigger({type:"usage",name:"hls-playlist-cue-tags"})}}},{key:"setupSegmentLoaderListeners_",value:function setupSegmentLoaderListeners_(){var _this3=this;this.mainSegmentLoader_.on("bandwidthupdate",function(){var nextPlaylist=_this3.selectPlaylist();var currentPlaylist=_this3.masterPlaylistLoader_.media();var buffered=_this3.tech_.buffered();var forwardBuffer=buffered.length?buffered.end(buffered.length-1)-_this3.tech_.currentTime():0;var bufferLowWaterLine=_this3.bufferLowWaterLine();if(!currentPlaylist.endList||_this3.duration()<Config.MAX_BUFFER_LOW_WATER_LINE||nextPlaylist.attributes.BANDWIDTH<currentPlaylist.attributes.BANDWIDTH||forwardBuffer>=bufferLowWaterLine){_this3.masterPlaylistLoader_.media(nextPlaylist)}_this3.tech_.trigger("bandwidthupdate")});this.mainSegmentLoader_.on("progress",function(){_this3.trigger("progress")});this.mainSegmentLoader_.on("error",function(){_this3.blacklistCurrentPlaylist(_this3.mainSegmentLoader_.error())});this.mainSegmentLoader_.on("syncinfoupdate",function(){_this3.onSyncInfoUpdate_()});this.mainSegmentLoader_.on("timestampoffset",function(){_this3.tech_.trigger({type:"usage",name:"hls-timestamp-offset"})});this.audioSegmentLoader_.on("syncinfoupdate",function(){_this3.onSyncInfoUpdate_()});this.mainSegmentLoader_.on("ended",function(){_this3.onEndOfStream()});this.mainSegmentLoader_.on("earlyabort",function(){_this3.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the "+"request without rebuffering."},ABORT_EARLY_BLACKLIST_SECONDS)});this.mainSegmentLoader_.on("reseteverything",function(){_this3.tech_.trigger("hls-reset")});this.mainSegmentLoader_.on("segmenttimemapping",function(event){_this3.tech_.trigger({type:"hls-segment-time-mapping",mapping:event.mapping})});this.audioSegmentLoader_.on("ended",function(){_this3.onEndOfStream()})}},{key:"mediaSecondsLoaded_",value:function mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}},{key:"load",value:function load(){this.mainSegmentLoader_.load();if(this.mediaTypes_.AUDIO.activePlaylistLoader){this.audioSegmentLoader_.load()}if(this.mediaTypes_.SUBTITLES.activePlaylistLoader){this.subtitleSegmentLoader_.load()}}},{key:"smoothQualityChange_",value:function smoothQualityChange_(){var media=this.selectPlaylist();if(media!==this.masterPlaylistLoader_.media()){this.masterPlaylistLoader_.media(media);this.mainSegmentLoader_.resetLoader()}}},{key:"fastQualityChange_",value:function fastQualityChange_(){var _this4=this;var media=this.selectPlaylist();if(media===this.masterPlaylistLoader_.media()){return}this.masterPlaylistLoader_.media(media);this.mainSegmentLoader_.resetEverything(function(){if(videojs$1.browser.IE_VERSION||videojs$1.browser.IS_EDGE){_this4.tech_.setCurrentTime(_this4.tech_.currentTime()+.04)}else{_this4.tech_.setCurrentTime(_this4.tech_.currentTime())}})}},{key:"play",value:function play(){if(this.setupFirstPlay()){return}if(this.tech_.ended()){this.seekTo_(0)}if(this.hasPlayed_()){this.load()}var seekable$$1=this.tech_.seekable();if(this.tech_.duration()===Infinity){if(this.tech_.currentTime()<seekable$$1.start(0)){return this.seekTo_(seekable$$1.end(seekable$$1.length-1))}}}},{key:"setupFirstPlay",value:function setupFirstPlay(){var _this5=this;var media=this.masterPlaylistLoader_.media();if(!media||this.tech_.paused()||this.hasPlayed_()){return false}if(!media.endList){var seekable$$1=this.seekable();if(!seekable$$1.length){return false}if(videojs$1.browser.IE_VERSION&&this.tech_.readyState()===0){this.tech_.one("loadedmetadata",function(){_this5.trigger("firstplay");_this5.seekTo_(seekable$$1.end(0));_this5.hasPlayed_=function(){return true}});return false}this.trigger("firstplay");this.seekTo_(seekable$$1.end(0))}this.hasPlayed_=function(){return true};this.load();return true}},{key:"handleSourceOpen_",value:function handleSourceOpen_(){try{this.setupSourceBuffers_()}catch(e){videojs$1.log.warn("Failed to create Source Buffers",e);return this.mediaSource.endOfStream("decode")}if(this.tech_.autoplay()){var playPromise=this.tech_.play();if(typeof playPromise!=="undefined"&&typeof playPromise.then==="function"){playPromise.then(null,function(e){})}}this.trigger("sourceopen")}},{key:"onEndOfStream",value:function onEndOfStream(){var isEndOfStream=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader){if(!this.mainSegmentLoader_.startingMedia_||this.mainSegmentLoader_.startingMedia_.containsVideo){isEndOfStream=isEndOfStream&&this.audioSegmentLoader_.ended_}else{isEndOfStream=this.audioSegmentLoader_.ended_}}if(!isEndOfStream){return}this.logger_("calling mediaSource.endOfStream()");try{this.mediaSource.endOfStream()}catch(e){videojs$1.log.warn("Failed to call media source endOfStream",e)}}},{key:"stuckAtPlaylistEnd_",value:function stuckAtPlaylistEnd_(playlist){var seekable$$1=this.seekable();if(!seekable$$1.length){return false}var expired=this.syncController_.getExpiredTime(playlist,this.mediaSource.duration);if(expired===null){return false}var absolutePlaylistEnd=Hls.Playlist.playlistEnd(playlist,expired);var currentTime=this.tech_.currentTime();var buffered=this.tech_.buffered();if(!buffered.length){return absolutePlaylistEnd-currentTime<=SAFE_TIME_DELTA}var bufferedEnd=buffered.end(buffered.length-1);return bufferedEnd-currentTime<=SAFE_TIME_DELTA&&absolutePlaylistEnd-bufferedEnd<=SAFE_TIME_DELTA}},{key:"blacklistCurrentPlaylist",value:function blacklistCurrentPlaylist(){var error=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var blacklistDuration=arguments[1];var currentPlaylist=void 0;var nextPlaylist=void 0;currentPlaylist=error.playlist||this.masterPlaylistLoader_.media();blacklistDuration=blacklistDuration||error.blacklistDuration||this.blacklistDuration;if(!currentPlaylist){this.error=error;try{return this.mediaSource.endOfStream("network")}catch(e){return this.trigger("error")}}var isFinalRendition=this.masterPlaylistLoader_.master.playlists.filter(isEnabled).length===1;var playlists=this.masterPlaylistLoader_.master.playlists;if(playlists.length===1){videojs$1.log.warn("Problem encountered with the current "+"HLS playlist. Trying again since it is the only playlist.");this.tech_.trigger("retryplaylist");return this.masterPlaylistLoader_.load(isFinalRendition)}if(isFinalRendition){videojs$1.log.warn("Removing all playlists from the blacklist because the last "+"rendition is about to be blacklisted.");playlists.forEach(function(playlist){if(playlist.excludeUntil!==Infinity){delete playlist.excludeUntil}});this.tech_.trigger("retryplaylist")}currentPlaylist.excludeUntil=Date.now()+blacklistDuration*1e3;this.tech_.trigger("blacklistplaylist");this.tech_.trigger({type:"usage",name:"hls-rendition-blacklisted"});nextPlaylist=this.selectPlaylist();videojs$1.log.warn("Problem encountered with the current HLS playlist."+(error.message?" "+error.message:"")+" Switching to another playlist.");return this.masterPlaylistLoader_.media(nextPlaylist,isFinalRendition)}},{key:"pauseLoading",value:function pauseLoading(){this.mainSegmentLoader_.pause();if(this.mediaTypes_.AUDIO.activePlaylistLoader){this.audioSegmentLoader_.pause()}if(this.mediaTypes_.SUBTITLES.activePlaylistLoader){this.subtitleSegmentLoader_.pause()}}},{key:"setCurrentTime",value:function setCurrentTime(currentTime){var buffered=findRange(this.tech_.buffered(),currentTime);if(!(this.masterPlaylistLoader_&&this.masterPlaylistLoader_.media())){return 0}if(!this.masterPlaylistLoader_.media().segments){return 0}if(buffered&&buffered.length){return currentTime}this.mainSegmentLoader_.resetEverything();this.mainSegmentLoader_.abort();if(this.mediaTypes_.AUDIO.activePlaylistLoader){this.audioSegmentLoader_.resetEverything();this.audioSegmentLoader_.abort()}if(this.mediaTypes_.SUBTITLES.activePlaylistLoader){this.subtitleSegmentLoader_.resetEverything();this.subtitleSegmentLoader_.abort()}this.load()}},{key:"duration",value:function duration$$1(){if(!this.masterPlaylistLoader_){return 0}if(this.mediaSource){return this.mediaSource.duration}return Hls.Playlist.duration(this.masterPlaylistLoader_.media())}},{key:"seekable",value:function seekable$$1(){return this.seekable_}},{key:"onSyncInfoUpdate_",value:function onSyncInfoUpdate_(){var mainSeekable=void 0;var audioSeekable=void 0;if(!this.masterPlaylistLoader_){return}var media=this.masterPlaylistLoader_.media();if(!media){return}var expired=this.syncController_.getExpiredTime(media,this.mediaSource.duration);if(expired===null){return}mainSeekable=Hls.Playlist.seekable(media,expired);if(mainSeekable.length===0){return}if(this.mediaTypes_.AUDIO.activePlaylistLoader){media=this.mediaTypes_.AUDIO.activePlaylistLoader.media();expired=this.syncController_.getExpiredTime(media,this.mediaSource.duration);if(expired===null){return}audioSeekable=Hls.Playlist.seekable(media,expired);if(audioSeekable.length===0){return}}var oldEnd=void 0;var oldStart=void 0;if(this.seekable_&&this.seekable_.length){oldEnd=this.seekable_.end(0);oldStart=this.seekable_.start(0)}if(!audioSeekable){this.seekable_=mainSeekable}else if(audioSeekable.start(0)>mainSeekable.end(0)||mainSeekable.start(0)>audioSeekable.end(0)){this.seekable_=mainSeekable}else{this.seekable_=videojs$1.createTimeRanges([[audioSeekable.start(0)>mainSeekable.start(0)?audioSeekable.start(0):mainSeekable.start(0),audioSeekable.end(0)<mainSeekable.end(0)?audioSeekable.end(0):mainSeekable.end(0)]])}if(this.seekable_&&this.seekable_.length){if(this.seekable_.end(0)===oldEnd&&this.seekable_.start(0)===oldStart){return}}this.logger_("seekable updated ["+printableRange(this.seekable_)+"]");this.tech_.trigger("seekablechanged")}},{key:"updateDuration",value:function updateDuration(){var _this6=this;var oldDuration=this.mediaSource.duration;var newDuration=Hls.Playlist.duration(this.masterPlaylistLoader_.media());var buffered=this.tech_.buffered();var setDuration=function setDuration(){_this6.logger_("Setting duration from "+_this6.mediaSource.duration+" => "+newDuration);try{_this6.mediaSource.duration=newDuration}catch(e){videojs$1.log.warn("Failed to set media source duration",e)}_this6.tech_.trigger("durationchange");_this6.mediaSource.removeEventListener("sourceopen",setDuration)};if(buffered.length>0){newDuration=Math.max(newDuration,buffered.end(buffered.length-1))}if(oldDuration!==newDuration){if(this.mediaSource.readyState!=="open"){this.mediaSource.addEventListener("sourceopen",setDuration)}else{setDuration()}}}},{key:"dispose",value:function dispose(){var _this7=this;this.decrypter_.terminate();this.masterPlaylistLoader_.dispose();this.mainSegmentLoader_.dispose();["AUDIO","SUBTITLES"].forEach(function(type){var groups=_this7.mediaTypes_[type].groups;for(var id in groups){groups[id].forEach(function(group){if(group.playlistLoader){group.playlistLoader.dispose()}})}});this.audioSegmentLoader_.dispose();this.subtitleSegmentLoader_.dispose()}},{key:"master",value:function master(){return this.masterPlaylistLoader_.master}},{key:"media",value:function media(){return this.masterPlaylistLoader_.media()||this.initialMedia_}},{key:"setupSourceBuffers_",value:function setupSourceBuffers_(){var media=this.masterPlaylistLoader_.media();var mimeTypes=void 0;if(!media||this.mediaSource.readyState!=="open"){return}mimeTypes=mimeTypesForPlaylist(this.masterPlaylistLoader_.master,media);if(mimeTypes.length<1){this.error="No compatible SourceBuffer configuration for the variant stream:"+media.resolvedUri;return this.mediaSource.endOfStream("decode")}this.configureLoaderMimeTypes_(mimeTypes);this.excludeIncompatibleVariants_(media)}},{key:"configureLoaderMimeTypes_",value:function configureLoaderMimeTypes_(mimeTypes){var sourceBufferEmitter=mimeTypes.length>1&&mimeTypes[0].indexOf(",")===-1&&mimeTypes[0]!==mimeTypes[1]?new videojs$1.EventTarget:null;this.mainSegmentLoader_.mimeType(mimeTypes[0],sourceBufferEmitter);if(mimeTypes[1]){this.audioSegmentLoader_.mimeType(mimeTypes[1],sourceBufferEmitter)}}},{key:"excludeUnsupportedVariants_",value:function excludeUnsupportedVariants_(){this.master().playlists.forEach(function(variant){if(variant.attributes.CODECS&&window$1.MediaSource&&window$1.MediaSource.isTypeSupported&&!window$1.MediaSource.isTypeSupported('video/mp4; codecs="'+mapLegacyAvcCodecs(variant.attributes.CODECS)+'"')){variant.excludeUntil=Infinity}})}},{key:"excludeIncompatibleVariants_",value:function excludeIncompatibleVariants_(media){var codecCount=2;var videoCodec=null;var codecs=void 0;if(media.attributes.CODECS){codecs=parseCodecs(media.attributes.CODECS);videoCodec=codecs.videoCodec;codecCount=codecs.codecCount}this.master().playlists.forEach(function(variant){var variantCodecs={codecCount:2,videoCodec:null};if(variant.attributes.CODECS){variantCodecs=parseCodecs(variant.attributes.CODECS)}if(variantCodecs.codecCount!==codecCount){variant.excludeUntil=Infinity}if(variantCodecs.videoCodec!==videoCodec){variant.excludeUntil=Infinity}})}},{key:"updateAdCues_",value:function updateAdCues_(media){var offset=0;var seekable$$1=this.seekable();if(seekable$$1.length){offset=seekable$$1.start(0)}updateAdCues(media,this.cueTagsTrack_,offset)}},{key:"goalBufferLength",value:function goalBufferLength(){var currentTime=this.tech_.currentTime();var initial=Config.GOAL_BUFFER_LENGTH;var rate=Config.GOAL_BUFFER_LENGTH_RATE;var max=Math.max(initial,Config.MAX_GOAL_BUFFER_LENGTH);return Math.min(initial+currentTime*rate,max)}},{key:"bufferLowWaterLine",value:function bufferLowWaterLine(){var currentTime=this.tech_.currentTime();var initial=Config.BUFFER_LOW_WATER_LINE;var rate=Config.BUFFER_LOW_WATER_LINE_RATE;var max=Math.max(initial,Config.MAX_BUFFER_LOW_WATER_LINE);return Math.min(initial+currentTime*rate,max)}}]);return MasterPlaylistController}(videojs$1.EventTarget);var enableFunction=function enableFunction(loader,playlistUri,changePlaylistFn){return function(enable){var playlist=loader.master.playlists[playlistUri];var incompatible=isIncompatible(playlist);var currentlyEnabled=isEnabled(playlist);if(typeof enable==="undefined"){return currentlyEnabled}if(enable){delete playlist.disabled}else{playlist.disabled=true}if(enable!==currentlyEnabled&&!incompatible){changePlaylistFn();if(enable){loader.trigger("renditionenabled")}else{loader.trigger("renditiondisabled")}}return enable}};var Representation=function Representation(hlsHandler,playlist,id){classCallCheck$1(this,Representation);var mpc=hlsHandler.masterPlaylistController_,smoothQualityChange=hlsHandler.options_.smoothQualityChange;var changeType=smoothQualityChange?"smooth":"fast";var qualityChangeFunction=mpc[changeType+"QualityChange_"].bind(mpc);if(playlist.attributes.RESOLUTION){var resolution=playlist.attributes.RESOLUTION;this.width=resolution.width;this.height=resolution.height}this.bandwidth=playlist.attributes.BANDWIDTH;this.id=id;this.enabled=enableFunction(hlsHandler.playlists,playlist.uri,qualityChangeFunction)};var renditionSelectionMixin=function renditionSelectionMixin(hlsHandler){var playlists=hlsHandler.playlists;hlsHandler.representations=function(){return playlists.master.playlists.filter(function(media){return!isIncompatible(media)}).map(function(e,i){return new Representation(hlsHandler,e,e.uri)})}};var timerCancelEvents=["seeking","seeked","pause","playing","error"];var PlaybackWatcher=function(){function PlaybackWatcher(options){var _this=this;classCallCheck$1(this,PlaybackWatcher);this.tech_=options.tech;this.seekable=options.seekable;this.seekTo=options.seekTo;this.allowSeeksWithinUnsafeLiveWindow=options.allowSeeksWithinUnsafeLiveWindow;this.media=options.media;this.consecutiveUpdates=0;this.lastRecordedTime=null;this.timer_=null;this.checkCurrentTimeTimeout_=null;this.logger_=logger("PlaybackWatcher");this.logger_("initialize");var canPlayHandler=function canPlayHandler(){return _this.monitorCurrentTime_()};var waitingHandler=function waitingHandler(){return _this.techWaiting_()};var cancelTimerHandler=function cancelTimerHandler(){return _this.cancelTimer_()};var fixesBadSeeksHandler=function fixesBadSeeksHandler(){return _this.fixesBadSeeks_()};this.tech_.on("seekablechanged",fixesBadSeeksHandler);this.tech_.on("waiting",waitingHandler);this.tech_.on(timerCancelEvents,cancelTimerHandler);this.tech_.on("canplay",canPlayHandler);this.dispose=function(){_this.logger_("dispose");_this.tech_.off("seekablechanged",fixesBadSeeksHandler);_this.tech_.off("waiting",waitingHandler);_this.tech_.off(timerCancelEvents,cancelTimerHandler);_this.tech_.off("canplay",canPlayHandler);if(_this.checkCurrentTimeTimeout_){window$1.clearTimeout(_this.checkCurrentTimeTimeout_)}_this.cancelTimer_()}}createClass$1(PlaybackWatcher,[{key:"monitorCurrentTime_",value:function monitorCurrentTime_(){this.checkCurrentTime_();if(this.checkCurrentTimeTimeout_){window$1.clearTimeout(this.checkCurrentTimeTimeout_)}this.checkCurrentTimeTimeout_=window$1.setTimeout(this.monitorCurrentTime_.bind(this),250)}},{key:"checkCurrentTime_",value:function checkCurrentTime_(){if(this.tech_.seeking()&&this.fixesBadSeeks_()){this.consecutiveUpdates=0;this.lastRecordedTime=this.tech_.currentTime();return}if(this.tech_.paused()||this.tech_.seeking()){return}var currentTime=this.tech_.currentTime();var buffered=this.tech_.buffered();if(this.lastRecordedTime===currentTime&&(!buffered.length||currentTime+SAFE_TIME_DELTA>=buffered.end(buffered.length-1))){return this.techWaiting_()}if(this.consecutiveUpdates>=5&&currentTime===this.lastRecordedTime){this.consecutiveUpdates++;this.waiting_()}else if(currentTime===this.lastRecordedTime){this.consecutiveUpdates++}else{this.consecutiveUpdates=0;this.lastRecordedTime=currentTime}}},{key:"cancelTimer_",value:function cancelTimer_(){this.consecutiveUpdates=0;if(this.timer_){this.logger_("cancelTimer_");clearTimeout(this.timer_)}this.timer_=null}},{key:"fixesBadSeeks_",value:function fixesBadSeeks_(){var seeking=this.tech_.seeking();if(!seeking){return false}var seekable=this.seekable();var currentTime=this.tech_.currentTime();var isAfterSeekableRange=this.afterSeekableWindow_(seekable,currentTime,this.media(),this.allowSeeksWithinUnsafeLiveWindow);var seekTo=void 0;if(isAfterSeekableRange){var seekableEnd=seekable.end(seekable.length-1);seekTo=seekableEnd}if(this.beforeSeekableWindow_(seekable,currentTime)){var seekableStart=seekable.start(0);seekTo=seekableStart+SAFE_TIME_DELTA}if(typeof seekTo!=="undefined"){this.logger_("Trying to seek outside of seekable at time "+currentTime+" with "+("seekable range "+printableRange(seekable)+". Seeking to ")+(seekTo+"."));this.seekTo(seekTo);return true}return false}},{key:"waiting_",value:function waiting_(){if(this.techWaiting_()){return}var currentTime=this.tech_.currentTime();var buffered=this.tech_.buffered();var currentRange=findRange(buffered,currentTime);if(currentRange.length&&currentTime+3<=currentRange.end(0)){this.cancelTimer_();this.seekTo(currentTime);this.logger_("Stopped at "+currentTime+" while inside a buffered region "+("["+currentRange.start(0)+" -> "+currentRange.end(0)+"]. Attempting to resume ")+"playback by seeking to the current time.");this.tech_.trigger({type:"usage",name:"hls-unknown-waiting"});return}}},{key:"techWaiting_",value:function techWaiting_(){var seekable=this.seekable();var currentTime=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_()){return true}if(this.tech_.seeking()||this.timer_!==null){return true}if(this.beforeSeekableWindow_(seekable,currentTime)){var livePoint=seekable.end(seekable.length-1);this.logger_("Fell out of live window at time "+currentTime+". Seeking to "+("live point (seekable end) "+livePoint));this.cancelTimer_();this.seekTo(livePoint);this.tech_.trigger({type:"usage",name:"hls-live-resync"});return true}var buffered=this.tech_.buffered();var nextRange=findNextRange(buffered,currentTime);if(this.videoUnderflow_(nextRange,buffered,currentTime)){this.cancelTimer_();this.seekTo(currentTime);this.tech_.trigger({type:"usage",name:"hls-video-underflow"});return true}if(nextRange.length>0){var difference=nextRange.start(0)-currentTime;this.logger_("Stopped at "+currentTime+", setting timer for "+difference+", seeking "+("to "+nextRange.start(0)));this.timer_=setTimeout(this.skipTheGap_.bind(this),difference*1e3,currentTime);return true}return false}},{key:"afterSeekableWindow_",value:function afterSeekableWindow_(seekable,currentTime,playlist){var allowSeeksWithinUnsafeLiveWindow=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;if(!seekable.length){return false}var allowedEnd=seekable.end(seekable.length-1)+SAFE_TIME_DELTA;var isLive=!playlist.endList;if(isLive&&allowSeeksWithinUnsafeLiveWindow){allowedEnd=seekable.end(seekable.length-1)+playlist.targetDuration*3}if(currentTime>allowedEnd){return true}return false}},{key:"beforeSeekableWindow_",value:function beforeSeekableWindow_(seekable,currentTime){if(seekable.length&&seekable.start(0)>0&&currentTime<seekable.start(0)-SAFE_TIME_DELTA){return true}return false}},{key:"videoUnderflow_",value:function videoUnderflow_(nextRange,buffered,currentTime){if(nextRange.length===0){var gap=this.gapFromVideoUnderflow_(buffered,currentTime);if(gap){this.logger_("Encountered a gap in video from "+gap.start+" to "+gap.end+". "+("Seeking to current time "+currentTime));return true}}return false}},{key:"skipTheGap_",value:function skipTheGap_(scheduledCurrentTime){var buffered=this.tech_.buffered();var currentTime=this.tech_.currentTime();var nextRange=findNextRange(buffered,currentTime);this.cancelTimer_();if(nextRange.length===0||currentTime!==scheduledCurrentTime){return}this.logger_("skipTheGap_:","currentTime:",currentTime,"scheduled currentTime:",scheduledCurrentTime,"nextRange start:",nextRange.start(0));this.seekTo(nextRange.start(0)+TIME_FUDGE_FACTOR);this.tech_.trigger({type:"usage",name:"hls-gap-skip"})}},{key:"gapFromVideoUnderflow_",value:function gapFromVideoUnderflow_(buffered,currentTime){var gaps=findGaps(buffered);for(var i=0;i<gaps.length;i++){var start=gaps.start(i);var end=gaps.end(i);if(currentTime-start<4&&currentTime-start>2){return{start:start,end:end}}}return null}}]);return PlaybackWatcher}();var defaultOptions={errorInterval:30,getSource:function getSource(next){var tech=this.tech({IWillNotUseThisInPlugins:true});var sourceObj=tech.currentSource_;return next(sourceObj)}};var initPlugin=function initPlugin(player,options){var lastCalled=0;var seekTo=0;var localOptions=videojs$1.mergeOptions(defaultOptions,options);player.ready(function(){player.trigger({type:"usage",name:"hls-error-reload-initialized"})});var loadedMetadataHandler=function loadedMetadataHandler(){if(seekTo){player.currentTime(seekTo)}};var setSource=function setSource(sourceObj){if(sourceObj===null||sourceObj===undefined){return}seekTo=player.duration()!==Infinity&&player.currentTime()||0;player.one("loadedmetadata",loadedMetadataHandler);player.src(sourceObj);player.trigger({type:"usage",name:"hls-error-reload"});player.play()};var errorHandler=function errorHandler(){if(Date.now()-lastCalled<localOptions.errorInterval*1e3){player.trigger({type:"usage",name:"hls-error-reload-canceled"});return}if(!localOptions.getSource||typeof localOptions.getSource!=="function"){videojs$1.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}lastCalled=Date.now();return localOptions.getSource.call(player,setSource)};var cleanupEvents=function cleanupEvents(){player.off("loadedmetadata",loadedMetadataHandler);player.off("error",errorHandler);player.off("dispose",cleanupEvents)};var reinitPlugin=function reinitPlugin(newOptions){cleanupEvents();initPlugin(player,newOptions)};player.on("error",errorHandler);player.on("dispose",cleanupEvents);player.reloadSourceOnError=reinitPlugin};var reloadSourceOnError=function reloadSourceOnError(options){initPlugin(this,options)};var version$1="1.10.6";videojs$1.use("*",function(player){return{setSource:function setSource(srcObj,next){next(null,srcObj)},setCurrentTime:function setCurrentTime(time){if(player.vhs&&player.currentSource().src===player.vhs.source_.src){player.vhs.setCurrentTime(time)}return time},play:function play(){if(player.vhs&&player.currentSource().src===player.vhs.source_.src){player.vhs.setCurrentTime(player.tech_.currentTime())}}}});var Hls$1={PlaylistLoader:PlaylistLoader,Playlist:Playlist,Decrypter:Decrypter,AsyncStream:AsyncStream,decrypt:decrypt,utils:utils$1,STANDARD_PLAYLIST_SELECTOR:lastBandwidthSelector,INITIAL_PLAYLIST_SELECTOR:lowestBitrateCompatibleVariantSelector,comparePlaylistBandwidth:comparePlaylistBandwidth,comparePlaylistResolution:comparePlaylistResolution,xhr:xhrFactory()};["GOAL_BUFFER_LENGTH","MAX_GOAL_BUFFER_LENGTH","GOAL_BUFFER_LENGTH_RATE","BUFFER_LOW_WATER_LINE","MAX_BUFFER_LOW_WATER_LINE","BUFFER_LOW_WATER_LINE_RATE","BANDWIDTH_VARIANCE"].forEach(function(prop){Object.defineProperty(Hls$1,prop,{get:function get$$1(){videojs$1.log.warn("using Hls."+prop+" is UNSAFE be sure you know what you are doing");return Config[prop]},set:function set$$1(value){videojs$1.log.warn("using Hls."+prop+" is UNSAFE be sure you know what you are doing");if(typeof value!=="number"||value<0){videojs$1.log.warn("value of Hls."+prop+" must be greater than or equal to 0");return}Config[prop]=value}})});var LOCAL_STORAGE_KEY$1="videojs-vhs";var simpleTypeFromSourceType=function simpleTypeFromSourceType(type){var mpegurlRE=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;if(mpegurlRE.test(type)){return"hls"}var dashRE=/^application\/dash\+xml/i;if(dashRE.test(type)){return"dash"}return null};var handleHlsMediaChange=function handleHlsMediaChange(qualityLevels,playlistLoader){var newPlaylist=playlistLoader.media();var selectedIndex=-1;for(var i=0;i<qualityLevels.length;i++){if(qualityLevels[i].id===newPlaylist.uri){selectedIndex=i;break}}qualityLevels.selectedIndex_=selectedIndex;qualityLevels.trigger({selectedIndex:selectedIndex,type:"change"})};var handleHlsLoadedMetadata=function handleHlsLoadedMetadata(qualityLevels,hls){hls.representations().forEach(function(rep){qualityLevels.addQualityLevel(rep)});handleHlsMediaChange(qualityLevels,hls.playlists)};Hls$1.canPlaySource=function(){return videojs$1.log.warn("HLS is no longer a tech. Please remove it from "+"your player's techOrder.")};var emeKeySystems=function emeKeySystems(keySystemOptions,videoPlaylist,audioPlaylist){if(!keySystemOptions){return keySystemOptions}var keySystemContentTypes={};for(var keySystem in keySystemOptions){keySystemContentTypes[keySystem]={audioContentType:'audio/mp4; codecs="'+audioPlaylist.attributes.CODECS+'"',videoContentType:'video/mp4; codecs="'+videoPlaylist.attributes.CODECS+'"'};if(videoPlaylist.contentProtection&&videoPlaylist.contentProtection[keySystem]&&videoPlaylist.contentProtection[keySystem].pssh){keySystemContentTypes[keySystem].pssh=videoPlaylist.contentProtection[keySystem].pssh}if(typeof keySystemOptions[keySystem]==="string"){keySystemContentTypes[keySystem].url=keySystemOptions[keySystem]}}return videojs$1.mergeOptions(keySystemOptions,keySystemContentTypes)};var setupEmeOptions=function setupEmeOptions(hlsHandler){if(hlsHandler.options_.sourceType!=="dash"){return}var player=videojs$1.players[hlsHandler.tech_.options_.playerId];if(player.eme){var sourceOptions=emeKeySystems(hlsHandler.source_.keySystems,hlsHandler.playlists.media(),hlsHandler.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader.media());if(sourceOptions){player.currentSource().keySystems=sourceOptions;if(player.eme.initializeMediaKeys){player.eme.initializeMediaKeys()}}}};var getVhsLocalStorage=function getVhsLocalStorage(){if(!window.localStorage){return null}var storedObject=window.localStorage.getItem(LOCAL_STORAGE_KEY$1);if(!storedObject){return null}try{return JSON.parse(storedObject)}catch(e){return null}};var updateVhsLocalStorage=function updateVhsLocalStorage(options){if(!window.localStorage){return false}var objectToStore=getVhsLocalStorage();objectToStore=objectToStore?videojs$1.mergeOptions(objectToStore,options):options;try{window.localStorage.setItem(LOCAL_STORAGE_KEY$1,JSON.stringify(objectToStore))}catch(e){return false}return objectToStore};Hls$1.supportsNativeHls=function(){var video=document.createElement("video");if(!videojs$1.getTech("Html5").isSupported()){return false}var canPlay=["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"];return canPlay.some(function(canItPlay){return/maybe|probably/i.test(video.canPlayType(canItPlay))})}();Hls$1.supportsNativeDash=function(){if(!videojs$1.getTech("Html5").isSupported()){return false}return/maybe|probably/i.test(document.createElement("video").canPlayType("application/dash+xml"))}();Hls$1.supportsTypeNatively=function(type){if(type==="hls"){return Hls$1.supportsNativeHls}if(type==="dash"){return Hls$1.supportsNativeDash}return false};Hls$1.isSupported=function(){return videojs$1.log.warn("HLS is no longer a tech. Please remove it from "+"your player's techOrder.")};var Component$1=videojs$1.getComponent("Component");var HlsHandler=function(_Component){inherits$1(HlsHandler,_Component);function HlsHandler(source,tech,options){classCallCheck$1(this,HlsHandler);var _this=possibleConstructorReturn$1(this,(HlsHandler.__proto__||Object.getPrototypeOf(HlsHandler)).call(this,tech,options.hls));if(tech.options_&&tech.options_.playerId){var _player=videojs$1(tech.options_.playerId);if(!_player.hasOwnProperty("hls")){Object.defineProperty(_player,"hls",{get:function get$$1(){videojs$1.log.warn("player.hls is deprecated. Use player.tech().hls instead.");tech.trigger({type:"usage",name:"hls-player-access"});return _this},configurable:true})}_player.vhs=_this;_player.dash=_this;_this.player_=_player}_this.tech_=tech;_this.source_=source;_this.stats={};_this.setOptions_();if(_this.options_.overrideNative&&tech.overrideNativeAudioTracks&&tech.overrideNativeVideoTracks){tech.overrideNativeAudioTracks(true);tech.overrideNativeVideoTracks(true)}else if(_this.options_.overrideNative&&(tech.featuresNativeVideoTracks||tech.featuresNativeAudioTracks)){throw new Error("Overriding native HLS requires emulated tracks. "+"See https://git.io/vMpjB")}_this.on(document,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],function(event){var fullscreenElement=document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;if(fullscreenElement&&fullscreenElement.contains(_this.tech_.el())){_this.masterPlaylistController_.smoothQualityChange_()}});_this.on(_this.tech_,"seeking",function(){if(this.tech_.currentTime()===0&&this.tech_.player_.loop()){this.setCurrentTime(0)}});_this.on(_this.tech_,"error",function(){if(this.masterPlaylistController_){this.masterPlaylistController_.pauseLoading()}});_this.on(_this.tech_,"play",_this.play);return _this}createClass$1(HlsHandler,[{key:"setOptions_",value:function setOptions_(){var _this2=this;this.options_.withCredentials=this.options_.withCredentials||false;this.options_.handleManifestRedirects=this.options_.handleManifestRedirects||false;this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions===false?false:true;this.options_.smoothQualityChange=this.options_.smoothQualityChange||false;this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage!=="undefined"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||false;this.options_.customTagParsers=this.options_.customTagParsers||[];this.options_.customTagMappers=this.options_.customTagMappers||[];this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||false;if(typeof this.options_.blacklistDuration!=="number"){this.options_.blacklistDuration=5*60}if(typeof this.options_.bandwidth!=="number"){if(this.options_.useBandwidthFromLocalStorage){var storedObject=getVhsLocalStorage();if(storedObject&&storedObject.bandwidth){this.options_.bandwidth=storedObject.bandwidth;this.tech_.trigger({type:"usage",name:"hls-bandwidth-from-local-storage"})}if(storedObject&&storedObject.throughput){this.options_.throughput=storedObject.throughput;this.tech_.trigger({type:"usage",name:"hls-throughput-from-local-storage"})}}}if(typeof this.options_.bandwidth!=="number"){this.options_.bandwidth=Config.INITIAL_BANDWIDTH}this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===Config.INITIAL_BANDWIDTH;["withCredentials","limitRenditionByPlayerDimensions","bandwidth","smoothQualityChange","customTagParsers","customTagMappers","handleManifestRedirects","cacheEncryptionKeys"].forEach(function(option){if(typeof _this2.source_[option]!=="undefined"){_this2.options_[option]=_this2.source_[option]}});this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions}},{key:"src",value:function src(_src,type){var _this3=this;if(!_src){return}this.setOptions_();this.options_.url=this.source_.src;this.options_.tech=this.tech_;this.options_.externHls=Hls$1;this.options_.sourceType=simpleTypeFromSourceType(type);this.options_.seekTo=function(time){_this3.tech_.setCurrentTime(time);_this3.setCurrentTime(time)};this.masterPlaylistController_=new MasterPlaylistController(this.options_);this.playbackWatcher_=new PlaybackWatcher(videojs$1.mergeOptions(this.options_,{seekable:function seekable$$1(){return _this3.seekable()},media:function media(){return _this3.masterPlaylistController_.media()}}));this.masterPlaylistController_.on("error",function(){var player=videojs$1.players[_this3.tech_.options_.playerId];player.error(_this3.masterPlaylistController_.error)});this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):Hls$1.STANDARD_PLAYLIST_SELECTOR.bind(this);this.masterPlaylistController_.selectInitialPlaylist=Hls$1.INITIAL_PLAYLIST_SELECTOR.bind(this);this.playlists=this.masterPlaylistController_.masterPlaylistLoader_;this.mediaSource=this.masterPlaylistController_.mediaSource;Object.defineProperties(this,{selectPlaylist:{get:function get$$1(){return this.masterPlaylistController_.selectPlaylist},set:function set$$1(selectPlaylist){this.masterPlaylistController_.selectPlaylist=selectPlaylist.bind(this)}},throughput:{get:function get$$1(){return this.masterPlaylistController_.mainSegmentLoader_.throughput.rate},set:function set$$1(throughput){this.masterPlaylistController_.mainSegmentLoader_.throughput.rate=throughput;this.masterPlaylistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get:function get$$1(){return this.masterPlaylistController_.mainSegmentLoader_.bandwidth},set:function set$$1(bandwidth){this.masterPlaylistController_.mainSegmentLoader_.bandwidth=bandwidth;this.masterPlaylistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get:function get$$1(){var invBandwidth=1/(this.bandwidth||1);var invThroughput=void 0;if(this.throughput>0){invThroughput=1/this.throughput}else{invThroughput=0}var systemBitrate=Math.floor(1/(invBandwidth+invThroughput));return systemBitrate},set:function set$$1(){videojs$1.log.error('The "systemBandwidth" property is read-only')}}});if(this.options_.bandwidth){this.bandwidth=this.options_.bandwidth}if(this.options_.throughput){this.throughput=this.options_.throughput}Object.defineProperties(this.stats,{bandwidth:{get:function get$$1(){return _this3.bandwidth||0},enumerable:true},mediaRequests:{get:function get$$1(){return _this3.masterPlaylistController_.mediaRequests_()||0},enumerable:true},mediaRequestsAborted:{get:function get$$1(){return _this3.masterPlaylistController_.mediaRequestsAborted_()||0},enumerable:true},mediaRequestsTimedout:{get:function get$$1(){return _this3.masterPlaylistController_.mediaRequestsTimedout_()||0},enumerable:true},mediaRequestsErrored:{get:function get$$1(){return _this3.masterPlaylistController_.mediaRequestsErrored_()||0},enumerable:true},mediaTransferDuration:{get:function get$$1(){return _this3.masterPlaylistController_.mediaTransferDuration_()||0},enumerable:true},mediaBytesTransferred:{get:function get$$1(){return _this3.masterPlaylistController_.mediaBytesTransferred_()||0},enumerable:true},mediaSecondsLoaded:{get:function get$$1(){return _this3.masterPlaylistController_.mediaSecondsLoaded_()||0},enumerable:true},buffered:{get:function get$$1(){return timeRangesToArray(_this3.tech_.buffered())},enumerable:true},currentTime:{get:function get$$1(){return _this3.tech_.currentTime()},enumerable:true},currentSource:{get:function get$$1(){return _this3.tech_.currentSource_},enumerable:true},currentTech:{get:function get$$1(){return _this3.tech_.name_},enumerable:true},duration:{get:function get$$1(){return _this3.tech_.duration()},enumerable:true},master:{get:function get$$1(){return _this3.playlists.master},enumerable:true},playerDimensions:{get:function get$$1(){return _this3.tech_.currentDimensions()},enumerable:true},seekable:{get:function get$$1(){return timeRangesToArray(_this3.tech_.seekable())},enumerable:true},timestamp:{get:function get$$1(){return Date.now()},enumerable:true},videoPlaybackQuality:{get:function get$$1(){return _this3.tech_.getVideoPlaybackQuality()},enumerable:true}});this.tech_.one("canplay",this.masterPlaylistController_.setupFirstPlay.bind(this.masterPlaylistController_));this.tech_.on("bandwidthupdate",function(){if(_this3.options_.useBandwidthFromLocalStorage){updateVhsLocalStorage({bandwidth:_this3.bandwidth,throughput:Math.round(_this3.throughput)})}});this.masterPlaylistController_.on("selectedinitialmedia",function(){renditionSelectionMixin(_this3);setupEmeOptions(_this3)});this.on(this.masterPlaylistController_,"progress",function(){this.tech_.trigger("progress")});this.tech_.ready(function(){return _this3.setupQualityLevels_()});if(!this.tech_.el()){return}this.tech_.src(videojs$1.URL.createObjectURL(this.masterPlaylistController_.mediaSource))}},{key:"setupQualityLevels_",value:function setupQualityLevels_(){var _this4=this;var player=videojs$1.players[this.tech_.options_.playerId];if(player&&player.qualityLevels){this.qualityLevels_=player.qualityLevels();this.masterPlaylistController_.on("selectedinitialmedia",function(){handleHlsLoadedMetadata(_this4.qualityLevels_,_this4)});this.playlists.on("mediachange",function(){handleHlsMediaChange(_this4.qualityLevels_,_this4.playlists)})}}},{key:"play",value:function play(){this.masterPlaylistController_.play()}},{key:"setCurrentTime",value:function setCurrentTime(currentTime){this.masterPlaylistController_.setCurrentTime(currentTime)}},{key:"duration",value:function duration$$1(){return this.masterPlaylistController_.duration()}},{key:"seekable",value:function seekable$$1(){return this.masterPlaylistController_.seekable()}},{key:"dispose",value:function dispose(){if(this.playbackWatcher_){this.playbackWatcher_.dispose()}if(this.masterPlaylistController_){this.masterPlaylistController_.dispose()}if(this.qualityLevels_){this.qualityLevels_.dispose()}if(this.player_){delete this.player_.vhs;delete this.player_.dash;delete this.player_.hls}if(this.tech_&&this.tech_.hls){delete this.tech_.hls}get$1(HlsHandler.prototype.__proto__||Object.getPrototypeOf(HlsHandler.prototype),"dispose",this).call(this)}},{key:"convertToProgramTime",value:function convertToProgramTime(time,callback){return getProgramTime({playlist:this.masterPlaylistController_.media(),time:time,callback:callback})}},{key:"seekToProgramTime",value:function seekToProgramTime$$1(programTime,callback){var pauseAfterSeek=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;var retryCount=arguments.length>3&&arguments[3]!==undefined?arguments[3]:2;return seekToProgramTime({programTime:programTime,playlist:this.masterPlaylistController_.media(),retryCount:retryCount,pauseAfterSeek:pauseAfterSeek,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:callback})}}]);return HlsHandler}(Component$1);var HlsSourceHandler={name:"videojs-http-streaming",VERSION:version$1,canHandleSource:function canHandleSource(srcObj){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var localOptions=videojs$1.mergeOptions(videojs$1.options,options);return HlsSourceHandler.canPlayType(srcObj.type,localOptions)},handleSource:function handleSource(source,tech){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var localOptions=videojs$1.mergeOptions(videojs$1.options,options);tech.hls=new HlsHandler(source,tech,localOptions);tech.hls.xhr=xhrFactory();tech.hls.src(source.src,source.type);return tech.hls},canPlayType:function canPlayType(type){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var _videojs$mergeOptions=videojs$1.mergeOptions(videojs$1.options,options),overrideNative=_videojs$mergeOptions.hls.overrideNative;var supportedType=simpleTypeFromSourceType(type);var canUseMsePlayback=supportedType&&(!Hls$1.supportsTypeNatively(supportedType)||overrideNative);return canUseMsePlayback?"maybe":""}};if(typeof videojs$1.MediaSource==="undefined"||typeof videojs$1.URL==="undefined"){videojs$1.MediaSource=MediaSource;videojs$1.URL=URL$1}if(MediaSource.supportsNativeMediaSources()){videojs$1.getTech("Html5").registerSourceHandler(HlsSourceHandler,0)}videojs$1.HlsHandler=HlsHandler;videojs$1.HlsSourceHandler=HlsSourceHandler;videojs$1.Hls=Hls$1;if(!videojs$1.use){videojs$1.registerComponent("Hls",Hls$1)}videojs$1.options.hls=videojs$1.options.hls||{};if(videojs$1.registerPlugin){videojs$1.registerPlugin("reloadSourceOnError",reloadSourceOnError)}else{videojs$1.plugin("reloadSourceOnError",reloadSourceOnError)}return videojs$1});!function(){!function(a){var b=a&&a.videojs;b&&(b.CDN_VERSION="7.6.6")}(window)}();
const vd = (function() {
let vd = {};
function createEl(tagName = 'div', properties = {}, attributes = {}, content) {
const el = document.createElement(tagName);
Object.getOwnPropertyNames(properties).forEach(function(propName) {
const val = properties[propName];
// See #2176
// We originally were accepting both properties and attributes in the
// same object, but that doesn't work so well.
if (propName.indexOf('aria-') !== -1 || propName === 'role' || propName === 'type') {
log.warn(tsml`Setting attributes in the second argument of createEl()
has been deprecated. Use the third argument instead.
createEl(type, properties, attributes). Attempting to set ${propName} to ${val}.`);
el.setAttribute(propName, val);
// Handle textContent since it's not supported everywhere and we have a
// method for it.
} else if (propName === 'textContent') {
textContent(el, val);
} else {
el[propName] = val;
}
});
return el;
}
function findPosition(el) {
let box;
if (el.getBoundingClientRect && el.parentNode) {
box = el.getBoundingClientRect();
}
if (!box) {
return {
left: 0,
top: 0
};
}
const docEl = document.documentElement;
const body = document.body;
const clientLeft = docEl.clientLeft || body.clientLeft || 0;
const scrollLeft = window.pageXOffset || body.scrollLeft;
const left = box.left + scrollLeft - clientLeft;
const clientTop = docEl.clientTop || body.clientTop || 0;
const scrollTop = window.pageYOffset || body.scrollTop;
const top = box.top + scrollTop - clientTop;
// Android sometimes returns slightly off decimal values, so need to round
return {
left: Math.round(left),
top: Math.round(top)
};
}
function getBoundingClientRect(el) {
if (el && el.getBoundingClientRect && el.parentNode) {
const rect = el.getBoundingClientRect();
const result = {};
['bottom', 'height', 'left', 'right', 'top', 'width'].forEach(k => {
if (rect[k] !== undefined) {
result[k] = rect[k];
}
});
if (!result.height) {
result.height = parseFloat(computedStyle(el, 'height'));
}
if (!result.width) {
result.width = parseFloat(computedStyle(el, 'width'));
}
return result;
}
}
function getPointerPosition(el, event) {
const position = {};
const box = findPosition(el);
const boxW = el.offsetWidth;
const boxH = el.offsetHeight;
const boxY = box.top;
const boxX = box.left;
let pageY = event.pageY;
let pageX = event.pageX;
if (event.changedTouches) {
pageX = event.changedTouches[0].pageX;
pageY = event.changedTouches[0].pageY;
}
position.y = Math.max(0, Math.min(1, ((boxY - pageY) + boxH) / boxH));
position.x = Math.max(0, Math.min(1, (pageX - boxX) / boxW));
return position;
}
let vjs = {};
vjs.Component = videojs.getComponent('Component');
vjs.Menu = videojs.getComponent('Menu');
vjs.MenuButton = videojs.getComponent('MenuButton');
vjs.MenuItem = videojs.getComponent('MenuItem');
class MenuButton extends vjs.MenuButton {
constructor(player, options) {
super(player, options);
this.updateLabel(options === undefined ? "" : options.label || "");
}
createEl() {
const el = super.createEl();
this.labelEl_ = createEl('div', {
className: 'vjs-playback-rate-value',
innerHTML: 'auto'
});
el.appendChild(this.labelEl_);
return el;
}
dispose() {
this.labelEl_ = null;
super.dispose();
}
buildCSSClass() {
return `vjs-playback-rate ${super.buildCSSClass()}`;
}
buildWrapperCSSClass() {
return `vjs-playback-rate ${super.buildWrapperCSSClass()}`;
}
createMenu() {
const menu = new vjs.Menu(this.player());
return menu;
}
updateARIAAttributes() {
this.el().setAttribute('aria-valuenow', this.labelEl_.innerHTML);
}
updateLabel(newLabel) {
this.labelEl_.innerHTML = newLabel;
}
}
class ResolutionItem extends vjs.MenuItem {
constructor() {
super(...arguments);
this.representation = arguments[1].representation;
this.menuButton = arguments[1].menuButton;
this.label = arguments[1].label;
}
handleClick() {
if (this.representation === undefined) {
// Clicked on the auto button
this.player().tech({IWillNotUseThisInPlugins: true}).hls.representations().forEach(function(rep) {
rep.enabled(true);
});
} else {
// Clicked on another button
let self = this;
this.player().tech({IWillNotUseThisInPlugins: true}).hls.representations().forEach(function(rep) {
rep.enabled(rep.height === self.options_.representation.height);
});
}
this.menuButton.updateLabel(this.label);
}
}
class SpeedItem extends vjs.MenuItem {
constructor() {
super(...arguments);
this.label = arguments[1].label;
this.speed = arguments[1].speed;
this.menuButton = arguments[1].menuButton;
}
handleClick() {
this.player().playbackRate(this.speed);
this.menuButton.updateLabel(this.label);
}
}
class Thumbnail extends vjs.Component {
constructor() {
super(...arguments);
this.thumbnails = arguments[1].thumbnails;
this.width = arguments[1].width;
this.height = arguments[1].height;
}
createEl() {
let el = super.createEl('img', {
src: this.options_.thumbnails[0],
width: '0px',
});
el.style.position = 'absolute';
el.style.left = '0px';
el.style.top = -this.options_.height + "px";
el.style.border = "solid";
el.style.borderColor = "black";
el.style.borderWidth = "1px";
return el;
}
update(ratio) {
this.el().src = this.options_.thumbnails[Math.round(100 * ratio)];
}
}
function createRepresentationButtons(player, menuButton = undefined) {
if (menuButton === undefined) {
menuButton = new MenuButton(player);
menuButton.updateLabel("auto");
}
let hls = player.tech({IWillNotUseThisInPlugins: true}).hls;
if (hls === undefined || hls.representations === undefined) {
setTimeout(() => createRepresentationButtons(player, menuButton), 500);
return menuButton;
}
let representations = hls.representations();
representations.sort((a, b) => b.height - a.height);
menuButton.menu.items = [];
menuButton.menu.addAndRecordItem = function(item) {
this.addItem(item);
this.items.push(item);
}
menuButton.menu.addAndRecordItem(new ResolutionItem(player, { label: "auto", menuButton }));
for (let representation of representations) {
menuButton.menu.addAndRecordItem(new ResolutionItem(player, {
label: representation.height + "p",
representation,
menuButton
}));
}
return menuButton;
}
function createSpeedButtons(player) {
let menuButton = new MenuButton(player);
let speeds = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2];
menuButton.updateLabel('x1');
menuButton.menu.items = [];
menuButton.menu.addAndRecordItem = function(item) {
this.addItem(item);
this.items.push(item);
}
for (let speed of speeds) {
menuButton.menu.addAndRecordItem(new SpeedItem(player, {
label: "x" + speed,
menuButton,
speed,
}));
}
return menuButton;
}
vd.parseTime = function(t) {
let parsed = 1 * t;
if (!isNaN(parsed)) {
return parsed;
}
// Compute the split
let split = t.split("h");
let hours;
let minutes;
let seconds;
switch (split.length) {
case 1:
hours = 0;
split = split[0].split("m");
break;
case 2:
hours = 1 * split[0];
if (isNaN(hours)) {
return NaN;
}
split = split[1].split("m");
break;
default:
return NaN;
}
switch (split.length) {
case 1:
minutes = 0;
split = split[0].split("s");
break;
case 2:
minutes = 1 * split[0];
if (isNaN(minutes)) {
return NaN;
}
split = split[1].split("s");
break;
default:
return NaN;
}
seconds = 1 * split[0];
if ((split.length !== 1 && (! (split.length == 2 && split[1] === ""))) || isNaN(seconds)) {
return NaN;
}
return 3600 * hours + 60 * minutes + seconds;
}
vd.setup = function(video, args) {
let src;
if (typeof video === 'string' || video instanceof String) {
video = document.getElementById(video);
}
if (video === undefined) {
throw new Error("video element or ID invalid");
}
if (typeof args === "string" || args instanceof String) {
src = args;
}
if (typeof args === "object") {
src = args.v;
}
if (src === undefined) {
throw new Error("video src is undefined");
}
let player = videojs(video);
if (src.endsWith('.mpd')) {
player.src({
src,
type: 'application/dash+xml'
});
} else {
player.src({
src,
});
}
if (args.focus === true) {
player.focus();
}
player._oldRequestFullscreen = player.requestFullscreen;
player.requestFullscreen = function() {
var player = document.getElementById(this.id());
if (player === null) {
return;
}
player = typeof player.player === "function" ? player.player() : player.player;
player._oldRequestFullscreen(...arguments);
setTimeout(() => {
if (screen.orientation) {
screen.orientation.lock("landscape")
}
}, 1000);
};
player._oldExitFullscreen = player.exitFullscreen;
player.exitFullscreen = function() {
var player = document.getElementById(this.id());
if (player === null) {
return;
}
player = typeof player.player === "function" ? player.player() : player.player;
player._oldExitFullscreen(...arguments);
setTimeout(() => {
if (screen.orientation) {
screen.orientation.unlock();
}
}, 1000);
};
if (args.t !== undefined) {
let time = vd.parseTime(args.t);
if (!isNaN(time)) {
player.currentTime(time);
}
}
if (player.getAttribute('disable-shortcuts') == undefined) {
player.el().addEventListener('keydown', (e) => {
if (e.ctrlKey || e.shiftKey || e.altKey) {
return;
}
let p = document.getElementById(player.id());
if (p === null) {
return;
}
p = typeof p.player === "function" ? p.player() : p.player;
switch (e.keyCode) {
case 37: e.preventDefault(); p.currentTime(p.currentTime() - 5); break;
case 39: e.preventDefault(); p.currentTime(p.currentTime() + 5); break;
case 32: e.preventDefault(); if (p.paused()) p.play(); else p.pause(); break;
case 40: e.preventDefault(); p.volume(p.volume() - 0.1); break;
case 38: e.preventDefault(); p.volume(p.volume() + 0.1); break;
}
}, true);
document.body.addEventListener('keydown', (e) => {
if (e.ctrlKey || e.shiftKey || e.altKey) {
return;
}
let p = document.getElementById(player.id());
if (p === null) {
return;
}
p = typeof p.player === "function" ? p.player() : p.player;
switch (e.keyCode) {
case 74: e.preventDefault(); p.currentTime(p.currentTime() - 10); break; // J -> -10s
case 76: e.preventDefault(); p.currentTime(p.currentTime() + 10); break; // L -> +10s
case 75: e.preventDefault(); if (p.paused()) p.play(); else p.pause(); break; // K -> play/pause
case 77: e.preventDefault(); p.muted(!p.muted()); break; // M -> mute
// F -> toggle fullscreen
case 70:
e.preventDefault();
if (p.isFullscreen()) {
p.exitFullscreen();
} else {
p.requestFullscreen();
}
break;
// Seek shortcuts
case 48: case 96: e.preventDefault(); p.currentTime(0); break;
case 49: case 97: e.preventDefault(); p.currentTime( p.duration() / 10); break;
case 50: case 98: e.preventDefault(); p.currentTime(2 * p.duration() / 10); break;
case 51: case 99: e.preventDefault(); p.currentTime(3 * p.duration() / 10); break;
case 52: case 100: e.preventDefault(); p.currentTime(4 * p.duration() / 10); break;
case 53: case 101: e.preventDefault(); p.currentTime(5 * p.duration() / 10); break;
case 54: case 102: e.preventDefault(); p.currentTime(6 * p.duration() / 10); break;
case 55: case 103: e.preventDefault(); p.currentTime(7 * p.duration() / 10); break;
case 56: case 104: e.preventDefault(); p.currentTime(8 * p.duration() / 10); break;
case 57: case 105: e.preventDefault(); p.currentTime(9 * p.duration() / 10); break;
}
}, true);
}
let root = src.split('/').slice(0, -1).join('/');
if (root !== "") {
root += "/";
}
if (player.getAttribute('disable-thumbnails') == undefined) {
player.poster(root + "poster.png");
let thumbnails = [];
const MAX_INDEX = 100;
for (let i = 0; i <= MAX_INDEX; i++) {
thumbnails.push(root + "miniature-" + ("" + i).padStart(3, "0") + ".png");
}
let thumbnail = new Thumbnail(player, {
thumbnails,
width: 192 * 0.75,
height: 108 * 0.75,
});
player.controlBar.progressControl.addChild(thumbnail);
player.controlBar.progressControl.el().addEventListener('mouseenter', e => {
thumbnail.el().width = thumbnail.width;
thumbnail.update(e.offsetX / e.target.offsetWidth);
});
player.controlBar.progressControl.el().addEventListener('mouseleave', e => {
thumbnail.el().width = 0;
});
player.controlBar.progressControl.on('mousemove', (event) => {
const seekBar = player.controlBar.progressControl.seekBar;
const seekBarEl = seekBar.el();
const seekBarRect = getBoundingClientRect(seekBarEl);
let seekBarPoint = getPointerPosition(seekBarEl, event).x;
seekBarPoint = Math.max(0, Math.min(1, seekBarPoint));
thumbnail.update(seekBarPoint);
thumbnail.el().style.left = (seekBarPoint * seekBarRect.width - thumbnail.width / 2) + "px";
});
}
let controlBar = player.getChild('controlBar');
let fullscreenButton = controlBar.children()[controlBar.children().length - 1];
controlBar.removeChild(fullscreenButton);
let menuButton = createRepresentationButtons(player);
if (player.getAttribute('disable-speed') == undefined) {
let speedButton = createSpeedButtons(player);
controlBar.addChild(speedButton, {});
}
controlBar.addChild(menuButton, {});
controlBar.addChild(fullscreenButton, {});
window.player = player;
if (video.getAttribute('autoplay') != undefined) {
player.play();
}
return player;
}
for (let element of document.getElementsByTagName('video')) {
let src = element.getAttribute('data-dash-src');
if (src != undefined) {
vd.setup(element, src);
}
}
return vd;
})();