mirror of
https://github.com/owncast/owncast.git
synced 2024-12-21 16:54:46 +03:00
cc78564c64
* Bump @videojs/http-streaming from 2.3.0 to 2.3.1 in /build/javascript Bumps [@videojs/http-streaming](https://github.com/videojs/http-streaming) from 2.3.0 to 2.3.1. - [Release notes](https://github.com/videojs/http-streaming/releases) - [Changelog](https://github.com/videojs/http-streaming/blob/v2.3.1/CHANGELOG.md) - [Commits](https://github.com/videojs/http-streaming/compare/v2.3.0...v2.3.1) Signed-off-by: dependabot[bot] <support@github.com> * Commit updated Javascript packages Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Owncast <owncast@owncast.online>
2138 lines
327 KiB
JavaScript
2138 lines
327 KiB
JavaScript
import { c as createCommonjsModule, g as getDefaultExportFromCjs, a as commonjsGlobal } from '../../../common/_commonjsHelpers-37fa8da4.js';
|
||
import { d as document_1, w as window_1, c as core } from '../../../common/core-440932cf.js';
|
||
|
||
//[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
||
//[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
|
||
//[5] Name ::= NameStartChar (NameChar)*
|
||
var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;//\u10000-\uEFFFF
|
||
var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
|
||
var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
|
||
//var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
|
||
//var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')
|
||
|
||
//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
|
||
//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
|
||
var S_TAG = 0;//tag name offerring
|
||
var S_ATTR = 1;//attr name offerring
|
||
var S_ATTR_SPACE=2;//attr name end and space offer
|
||
var S_EQ = 3;//=space?
|
||
var S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only)
|
||
var S_ATTR_END = 5;//attr value end and no space(quot end)
|
||
var S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer)
|
||
var S_TAG_CLOSE = 7;//closed el<el />
|
||
|
||
function XMLReader(){
|
||
|
||
}
|
||
|
||
XMLReader.prototype = {
|
||
parse:function(source,defaultNSMap,entityMap){
|
||
var domBuilder = this.domBuilder;
|
||
domBuilder.startDocument();
|
||
_copy(defaultNSMap ,defaultNSMap = {});
|
||
parse(source,defaultNSMap,entityMap,
|
||
domBuilder,this.errorHandler);
|
||
domBuilder.endDocument();
|
||
}
|
||
};
|
||
function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
|
||
function fixedFromCharCode(code) {
|
||
// String.prototype.fromCharCode does not supports
|
||
// > 2 bytes unicode chars directly
|
||
if (code > 0xffff) {
|
||
code -= 0x10000;
|
||
var surrogate1 = 0xd800 + (code >> 10)
|
||
, surrogate2 = 0xdc00 + (code & 0x3ff);
|
||
|
||
return String.fromCharCode(surrogate1, surrogate2);
|
||
} else {
|
||
return String.fromCharCode(code);
|
||
}
|
||
}
|
||
function entityReplacer(a){
|
||
var k = a.slice(1,-1);
|
||
if(k in entityMap){
|
||
return entityMap[k];
|
||
}else if(k.charAt(0) === '#'){
|
||
return fixedFromCharCode(parseInt(k.substr(1).replace('x','0x')))
|
||
}else {
|
||
errorHandler.error('entity not found:'+a);
|
||
return a;
|
||
}
|
||
}
|
||
function appendText(end){//has some bugs
|
||
if(end>start){
|
||
var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer);
|
||
locator&&position(start);
|
||
domBuilder.characters(xt,0,end-start);
|
||
start = end;
|
||
}
|
||
}
|
||
function position(p,m){
|
||
while(p>=lineEnd && (m = linePattern.exec(source))){
|
||
lineStart = m.index;
|
||
lineEnd = lineStart + m[0].length;
|
||
locator.lineNumber++;
|
||
//console.log('line++:',locator,startPos,endPos)
|
||
}
|
||
locator.columnNumber = p-lineStart+1;
|
||
}
|
||
var lineStart = 0;
|
||
var lineEnd = 0;
|
||
var linePattern = /.*(?:\r\n?|\n)|.*$/g;
|
||
var locator = domBuilder.locator;
|
||
|
||
var parseStack = [{currentNSMap:defaultNSMapCopy}];
|
||
var closeMap = {};
|
||
var start = 0;
|
||
while(true){
|
||
try{
|
||
var tagStart = source.indexOf('<',start);
|
||
if(tagStart<0){
|
||
if(!source.substr(start).match(/^\s*$/)){
|
||
var doc = domBuilder.doc;
|
||
var text = doc.createTextNode(source.substr(start));
|
||
doc.appendChild(text);
|
||
domBuilder.currentElement = text;
|
||
}
|
||
return;
|
||
}
|
||
if(tagStart>start){
|
||
appendText(tagStart);
|
||
}
|
||
switch(source.charAt(tagStart+1)){
|
||
case '/':
|
||
var end = source.indexOf('>',tagStart+3);
|
||
var tagName = source.substring(tagStart+2,end);
|
||
var config = parseStack.pop();
|
||
if(end<0){
|
||
|
||
tagName = source.substring(tagStart+2).replace(/[\s<].*/,'');
|
||
//console.error('#@@@@@@'+tagName)
|
||
errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName);
|
||
end = tagStart+1+tagName.length;
|
||
}else if(tagName.match(/\s</)){
|
||
tagName = tagName.replace(/[\s<].*/,'');
|
||
errorHandler.error("end tag name: "+tagName+' maybe not complete');
|
||
end = tagStart+1+tagName.length;
|
||
}
|
||
//console.error(parseStack.length,parseStack)
|
||
//console.error(config);
|
||
var localNSMap = config.localNSMap;
|
||
var endMatch = config.tagName == tagName;
|
||
var endIgnoreCaseMach = endMatch || config.tagName&&config.tagName.toLowerCase() == tagName.toLowerCase();
|
||
if(endIgnoreCaseMach){
|
||
domBuilder.endElement(config.uri,config.localName,tagName);
|
||
if(localNSMap){
|
||
for(var prefix in localNSMap){
|
||
domBuilder.endPrefixMapping(prefix) ;
|
||
}
|
||
}
|
||
if(!endMatch){
|
||
errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName );
|
||
}
|
||
}else {
|
||
parseStack.push(config);
|
||
}
|
||
|
||
end++;
|
||
break;
|
||
// end elment
|
||
case '?':// <?...?>
|
||
locator&&position(tagStart);
|
||
end = parseInstruction(source,tagStart,domBuilder);
|
||
break;
|
||
case '!':// <!doctype,<![CDATA,<!--
|
||
locator&&position(tagStart);
|
||
end = parseDCC(source,tagStart,domBuilder,errorHandler);
|
||
break;
|
||
default:
|
||
locator&&position(tagStart);
|
||
var el = new ElementAttributes();
|
||
var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
|
||
//elStartEnd
|
||
var end = parseElementStartPart(source,tagStart,el,currentNSMap,entityReplacer,errorHandler);
|
||
var len = el.length;
|
||
|
||
|
||
if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
|
||
el.closed = true;
|
||
if(!entityMap.nbsp){
|
||
errorHandler.warning('unclosed xml attribute');
|
||
}
|
||
}
|
||
if(locator && len){
|
||
var locator2 = copyLocator(locator,{});
|
||
//try{//attribute position fixed
|
||
for(var i = 0;i<len;i++){
|
||
var a = el[i];
|
||
position(a.offset);
|
||
a.locator = copyLocator(locator,{});
|
||
}
|
||
//}catch(e){console.error('@@@@@'+e)}
|
||
domBuilder.locator = locator2;
|
||
if(appendElement(el,domBuilder,currentNSMap)){
|
||
parseStack.push(el);
|
||
}
|
||
domBuilder.locator = locator;
|
||
}else {
|
||
if(appendElement(el,domBuilder,currentNSMap)){
|
||
parseStack.push(el);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
|
||
end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder);
|
||
}else {
|
||
end++;
|
||
}
|
||
}
|
||
}catch(e){
|
||
errorHandler.error('element parse error: '+e);
|
||
//errorHandler.error('element parse error: '+e);
|
||
end = -1;
|
||
//throw e;
|
||
}
|
||
if(end>start){
|
||
start = end;
|
||
}else {
|
||
//TODO: 这里有可能sax回退,有位置错误风险
|
||
appendText(Math.max(tagStart,start)+1);
|
||
}
|
||
}
|
||
}
|
||
function copyLocator(f,t){
|
||
t.lineNumber = f.lineNumber;
|
||
t.columnNumber = f.columnNumber;
|
||
return t;
|
||
}
|
||
|
||
/**
|
||
* @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);
|
||
* @return end of the elementStartPart(end of elementEndPart for selfClosed el)
|
||
*/
|
||
function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){
|
||
var attrName;
|
||
var value;
|
||
var p = ++start;
|
||
var s = S_TAG;//status
|
||
while(true){
|
||
var c = source.charAt(p);
|
||
switch(c){
|
||
case '=':
|
||
if(s === S_ATTR){//attrName
|
||
attrName = source.slice(start,p);
|
||
s = S_EQ;
|
||
}else if(s === S_ATTR_SPACE){
|
||
s = S_EQ;
|
||
}else {
|
||
//fatalError: equal must after attrName or space after attrName
|
||
throw new Error('attribute equal must after attrName');
|
||
}
|
||
break;
|
||
case '\'':
|
||
case '"':
|
||
if(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE
|
||
){//equal
|
||
if(s === S_ATTR){
|
||
errorHandler.warning('attribute value must after "="');
|
||
attrName = source.slice(start,p);
|
||
}
|
||
start = p+1;
|
||
p = source.indexOf(c,start);
|
||
if(p>0){
|
||
value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
|
||
el.add(attrName,value,start-1);
|
||
s = S_ATTR_END;
|
||
}else {
|
||
//fatalError: no end quot match
|
||
throw new Error('attribute value no end \''+c+'\' match');
|
||
}
|
||
}else if(s == S_ATTR_NOQUOT_VALUE){
|
||
value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
|
||
//console.log(attrName,value,start,p)
|
||
el.add(attrName,value,start);
|
||
//console.dir(el)
|
||
errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!');
|
||
start = p+1;
|
||
s = S_ATTR_END;
|
||
}else {
|
||
//fatalError: no equal before
|
||
throw new Error('attribute value must after "="');
|
||
}
|
||
break;
|
||
case '/':
|
||
switch(s){
|
||
case S_TAG:
|
||
el.setTagName(source.slice(start,p));
|
||
case S_ATTR_END:
|
||
case S_TAG_SPACE:
|
||
case S_TAG_CLOSE:
|
||
s =S_TAG_CLOSE;
|
||
el.closed = true;
|
||
case S_ATTR_NOQUOT_VALUE:
|
||
case S_ATTR:
|
||
case S_ATTR_SPACE:
|
||
break;
|
||
//case S_EQ:
|
||
default:
|
||
throw new Error("attribute invalid close char('/')")
|
||
}
|
||
break;
|
||
case ''://end document
|
||
//throw new Error('unexpected end of input')
|
||
errorHandler.error('unexpected end of input');
|
||
if(s == S_TAG){
|
||
el.setTagName(source.slice(start,p));
|
||
}
|
||
return p;
|
||
case '>':
|
||
switch(s){
|
||
case S_TAG:
|
||
el.setTagName(source.slice(start,p));
|
||
case S_ATTR_END:
|
||
case S_TAG_SPACE:
|
||
case S_TAG_CLOSE:
|
||
break;//normal
|
||
case S_ATTR_NOQUOT_VALUE://Compatible state
|
||
case S_ATTR:
|
||
value = source.slice(start,p);
|
||
if(value.slice(-1) === '/'){
|
||
el.closed = true;
|
||
value = value.slice(0,-1);
|
||
}
|
||
case S_ATTR_SPACE:
|
||
if(s === S_ATTR_SPACE){
|
||
value = attrName;
|
||
}
|
||
if(s == S_ATTR_NOQUOT_VALUE){
|
||
errorHandler.warning('attribute "'+value+'" missed quot(")!!');
|
||
el.add(attrName,value.replace(/&#?\w+;/g,entityReplacer),start);
|
||
}else {
|
||
if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !value.match(/^(?:disabled|checked|selected)$/i)){
|
||
errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!');
|
||
}
|
||
el.add(value,value,start);
|
||
}
|
||
break;
|
||
case S_EQ:
|
||
throw new Error('attribute value missed!!');
|
||
}
|
||
// console.log(tagName,tagNamePattern,tagNamePattern.test(tagName))
|
||
return p;
|
||
/*xml space '\x20' | #x9 | #xD | #xA; */
|
||
case '\u0080':
|
||
c = ' ';
|
||
default:
|
||
if(c<= ' '){//space
|
||
switch(s){
|
||
case S_TAG:
|
||
el.setTagName(source.slice(start,p));//tagName
|
||
s = S_TAG_SPACE;
|
||
break;
|
||
case S_ATTR:
|
||
attrName = source.slice(start,p);
|
||
s = S_ATTR_SPACE;
|
||
break;
|
||
case S_ATTR_NOQUOT_VALUE:
|
||
var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
|
||
errorHandler.warning('attribute "'+value+'" missed quot(")!!');
|
||
el.add(attrName,value,start);
|
||
case S_ATTR_END:
|
||
s = S_TAG_SPACE;
|
||
break;
|
||
//case S_TAG_SPACE:
|
||
//case S_EQ:
|
||
//case S_ATTR_SPACE:
|
||
// void();break;
|
||
//case S_TAG_CLOSE:
|
||
//ignore warning
|
||
}
|
||
}else {//not space
|
||
//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
|
||
//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
|
||
switch(s){
|
||
//case S_TAG:void();break;
|
||
//case S_ATTR:void();break;
|
||
//case S_ATTR_NOQUOT_VALUE:void();break;
|
||
case S_ATTR_SPACE:
|
||
var tagName = el.tagName;
|
||
if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !attrName.match(/^(?:disabled|checked|selected)$/i)){
|
||
errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!');
|
||
}
|
||
el.add(attrName,attrName,start);
|
||
start = p;
|
||
s = S_ATTR;
|
||
break;
|
||
case S_ATTR_END:
|
||
errorHandler.warning('attribute space is required"'+attrName+'"!!');
|
||
case S_TAG_SPACE:
|
||
s = S_ATTR;
|
||
start = p;
|
||
break;
|
||
case S_EQ:
|
||
s = S_ATTR_NOQUOT_VALUE;
|
||
start = p;
|
||
break;
|
||
case S_TAG_CLOSE:
|
||
throw new Error("elements closed character '/' and '>' must be connected to");
|
||
}
|
||
}
|
||
}//end outer switch
|
||
//console.log('p++',p)
|
||
p++;
|
||
}
|
||
}
|
||
/**
|
||
* @return true if has new namespace define
|
||
*/
|
||
function appendElement(el,domBuilder,currentNSMap){
|
||
var tagName = el.tagName;
|
||
var localNSMap = null;
|
||
//var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
|
||
var i = el.length;
|
||
while(i--){
|
||
var a = el[i];
|
||
var qName = a.qName;
|
||
var value = a.value;
|
||
var nsp = qName.indexOf(':');
|
||
if(nsp>0){
|
||
var prefix = a.prefix = qName.slice(0,nsp);
|
||
var localName = qName.slice(nsp+1);
|
||
var nsPrefix = prefix === 'xmlns' && localName;
|
||
}else {
|
||
localName = qName;
|
||
prefix = null;
|
||
nsPrefix = qName === 'xmlns' && '';
|
||
}
|
||
//can not set prefix,because prefix !== ''
|
||
a.localName = localName ;
|
||
//prefix == null for no ns prefix attribute
|
||
if(nsPrefix !== false){//hack!!
|
||
if(localNSMap == null){
|
||
localNSMap = {};
|
||
//console.log(currentNSMap,0)
|
||
_copy(currentNSMap,currentNSMap={});
|
||
//console.log(currentNSMap,1)
|
||
}
|
||
currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
|
||
a.uri = 'http://www.w3.org/2000/xmlns/';
|
||
domBuilder.startPrefixMapping(nsPrefix, value);
|
||
}
|
||
}
|
||
var i = el.length;
|
||
while(i--){
|
||
a = el[i];
|
||
var prefix = a.prefix;
|
||
if(prefix){//no prefix attribute has no namespace
|
||
if(prefix === 'xml'){
|
||
a.uri = 'http://www.w3.org/XML/1998/namespace';
|
||
}if(prefix !== 'xmlns'){
|
||
a.uri = currentNSMap[prefix || ''];
|
||
|
||
//{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}
|
||
}
|
||
}
|
||
}
|
||
var nsp = tagName.indexOf(':');
|
||
if(nsp>0){
|
||
prefix = el.prefix = tagName.slice(0,nsp);
|
||
localName = el.localName = tagName.slice(nsp+1);
|
||
}else {
|
||
prefix = null;//important!!
|
||
localName = el.localName = tagName;
|
||
}
|
||
//no prefix element has default namespace
|
||
var ns = el.uri = currentNSMap[prefix || ''];
|
||
domBuilder.startElement(ns,localName,tagName,el);
|
||
//endPrefixMapping and startPrefixMapping have not any help for dom builder
|
||
//localNSMap = null
|
||
if(el.closed){
|
||
domBuilder.endElement(ns,localName,tagName);
|
||
if(localNSMap){
|
||
for(prefix in localNSMap){
|
||
domBuilder.endPrefixMapping(prefix);
|
||
}
|
||
}
|
||
}else {
|
||
el.currentNSMap = currentNSMap;
|
||
el.localNSMap = localNSMap;
|
||
//parseStack.push(el);
|
||
return true;
|
||
}
|
||
}
|
||
function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){
|
||
if(/^(?:script|textarea)$/i.test(tagName)){
|
||
var elEndStart = source.indexOf('</'+tagName+'>',elStartEnd);
|
||
var text = source.substring(elStartEnd+1,elEndStart);
|
||
if(/[&<]/.test(text)){
|
||
if(/^script$/i.test(tagName)){
|
||
//if(!/\]\]>/.test(text)){
|
||
//lexHandler.startCDATA();
|
||
domBuilder.characters(text,0,text.length);
|
||
//lexHandler.endCDATA();
|
||
return elEndStart;
|
||
//}
|
||
}//}else{//text area
|
||
text = text.replace(/&#?\w+;/g,entityReplacer);
|
||
domBuilder.characters(text,0,text.length);
|
||
return elEndStart;
|
||
//}
|
||
|
||
}
|
||
}
|
||
return elStartEnd+1;
|
||
}
|
||
function fixSelfClosed(source,elStartEnd,tagName,closeMap){
|
||
//if(tagName in closeMap){
|
||
var pos = closeMap[tagName];
|
||
if(pos == null){
|
||
//console.log(tagName)
|
||
pos = source.lastIndexOf('</'+tagName+'>');
|
||
if(pos<elStartEnd){//忘记闭合
|
||
pos = source.lastIndexOf('</'+tagName);
|
||
}
|
||
closeMap[tagName] =pos;
|
||
}
|
||
return pos<elStartEnd;
|
||
//}
|
||
}
|
||
function _copy(source,target){
|
||
for(var n in source){target[n] = source[n];}
|
||
}
|
||
function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
|
||
var next= source.charAt(start+2);
|
||
switch(next){
|
||
case '-':
|
||
if(source.charAt(start + 3) === '-'){
|
||
var end = source.indexOf('-->',start+4);
|
||
//append comment source.substring(4,end)//<!--
|
||
if(end>start){
|
||
domBuilder.comment(source,start+4,end-start-4);
|
||
return end+3;
|
||
}else {
|
||
errorHandler.error("Unclosed comment");
|
||
return -1;
|
||
}
|
||
}else {
|
||
//error
|
||
return -1;
|
||
}
|
||
default:
|
||
if(source.substr(start+3,6) == 'CDATA['){
|
||
var end = source.indexOf(']]>',start+9);
|
||
domBuilder.startCDATA();
|
||
domBuilder.characters(source,start+9,end-start-9);
|
||
domBuilder.endCDATA();
|
||
return end+3;
|
||
}
|
||
//<!DOCTYPE
|
||
//startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
|
||
var matchs = split(source,start);
|
||
var len = matchs.length;
|
||
if(len>1 && /!doctype/i.test(matchs[0][0])){
|
||
var name = matchs[1][0];
|
||
var pubid = len>3 && /^public$/i.test(matchs[2][0]) && matchs[3][0];
|
||
var sysid = len>4 && matchs[4][0];
|
||
var lastMatch = matchs[len-1];
|
||
domBuilder.startDTD(name,pubid && pubid.replace(/^(['"])(.*?)\1$/,'$2'),
|
||
sysid && sysid.replace(/^(['"])(.*?)\1$/,'$2'));
|
||
domBuilder.endDTD();
|
||
|
||
return lastMatch.index+lastMatch[0].length
|
||
}
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
|
||
|
||
function parseInstruction(source,start,domBuilder){
|
||
var end = source.indexOf('?>',start);
|
||
if(end){
|
||
var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
|
||
if(match){
|
||
var len = match[0].length;
|
||
domBuilder.processingInstruction(match[1], match[2]) ;
|
||
return end+2;
|
||
}else {//error
|
||
return -1;
|
||
}
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
/**
|
||
* @param source
|
||
*/
|
||
function ElementAttributes(source){
|
||
|
||
}
|
||
ElementAttributes.prototype = {
|
||
setTagName:function(tagName){
|
||
if(!tagNamePattern.test(tagName)){
|
||
throw new Error('invalid tagName:'+tagName)
|
||
}
|
||
this.tagName = tagName;
|
||
},
|
||
add:function(qName,value,offset){
|
||
if(!tagNamePattern.test(qName)){
|
||
throw new Error('invalid attribute:'+qName)
|
||
}
|
||
this[this.length++] = {qName:qName,value:value,offset:offset};
|
||
},
|
||
length:0,
|
||
getLocalName:function(i){return this[i].localName},
|
||
getLocator:function(i){return this[i].locator},
|
||
getQName:function(i){return this[i].qName},
|
||
getURI:function(i){return this[i].uri},
|
||
getValue:function(i){return this[i].value}
|
||
// ,getIndex:function(uri, localName)){
|
||
// if(localName){
|
||
//
|
||
// }else{
|
||
// var qName = uri
|
||
// }
|
||
// },
|
||
// getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
|
||
// getType:function(uri,localName){}
|
||
// getType:function(i){},
|
||
};
|
||
|
||
|
||
|
||
|
||
function _set_proto_(thiz,parent){
|
||
thiz.__proto__ = parent;
|
||
return thiz;
|
||
}
|
||
if(!(_set_proto_({},_set_proto_.prototype) instanceof _set_proto_)){
|
||
_set_proto_ = function(thiz,parent){
|
||
function p(){} p.prototype = parent;
|
||
p = new p();
|
||
for(parent in thiz){
|
||
p[parent] = thiz[parent];
|
||
}
|
||
return p;
|
||
};
|
||
}
|
||
|
||
function split(source,start){
|
||
var match;
|
||
var buf = [];
|
||
var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
|
||
reg.lastIndex = start;
|
||
reg.exec(source);//skip <
|
||
while(match = reg.exec(source)){
|
||
buf.push(match);
|
||
if(match[1])return buf;
|
||
}
|
||
}
|
||
|
||
var XMLReader_1 = XMLReader;
|
||
|
||
var sax = {
|
||
XMLReader: XMLReader_1
|
||
};
|
||
|
||
/*
|
||
* DOM Level 2
|
||
* Object DOMException
|
||
* @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
|
||
* @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
|
||
*/
|
||
|
||
function copy(src,dest){
|
||
for(var p in src){
|
||
dest[p] = src[p];
|
||
}
|
||
}
|
||
/**
|
||
^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));?
|
||
^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));?
|
||
*/
|
||
function _extends(Class,Super){
|
||
var pt = Class.prototype;
|
||
if(Object.create){
|
||
var ppt = Object.create(Super.prototype);
|
||
pt.__proto__ = ppt;
|
||
}
|
||
if(!(pt instanceof Super)){
|
||
function t(){} t.prototype = Super.prototype;
|
||
t = new t();
|
||
copy(pt,t);
|
||
Class.prototype = pt = t;
|
||
}
|
||
if(pt.constructor != Class){
|
||
if(typeof Class != 'function'){
|
||
console.error("unknow Class:"+Class);
|
||
}
|
||
pt.constructor = Class;
|
||
}
|
||
}
|
||
var htmlns = 'http://www.w3.org/1999/xhtml' ;
|
||
// Node Types
|
||
var NodeType = {};
|
||
var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
|
||
var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
|
||
var TEXT_NODE = NodeType.TEXT_NODE = 3;
|
||
var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
|
||
var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
|
||
var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
|
||
var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
|
||
var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
|
||
var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
|
||
var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
|
||
var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
|
||
var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
|
||
|
||
// ExceptionCode
|
||
var ExceptionCode = {};
|
||
var ExceptionMessage = {};
|
||
var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]="Index size error"),1);
|
||
var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2);
|
||
var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3);
|
||
var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4);
|
||
var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
|
||
var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6);
|
||
var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
|
||
var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8);
|
||
var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9);
|
||
var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10);
|
||
//level2
|
||
var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
|
||
var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12);
|
||
var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13);
|
||
var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
|
||
var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15);
|
||
|
||
|
||
function DOMException(code, message) {
|
||
if(message instanceof Error){
|
||
var error = message;
|
||
}else {
|
||
error = this;
|
||
Error.call(this, ExceptionMessage[code]);
|
||
this.message = ExceptionMessage[code];
|
||
if(Error.captureStackTrace) Error.captureStackTrace(this, DOMException);
|
||
}
|
||
error.code = code;
|
||
if(message) this.message = this.message + ": " + message;
|
||
return error;
|
||
}DOMException.prototype = Error.prototype;
|
||
copy(ExceptionCode,DOMException);
|
||
/**
|
||
* @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177
|
||
* The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live.
|
||
* The items in the NodeList are accessible via an integral index, starting from 0.
|
||
*/
|
||
function NodeList() {
|
||
}NodeList.prototype = {
|
||
/**
|
||
* The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
|
||
* @standard level1
|
||
*/
|
||
length:0,
|
||
/**
|
||
* Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
|
||
* @standard level1
|
||
* @param index unsigned long
|
||
* Index into the collection.
|
||
* @return Node
|
||
* The node at the indexth position in the NodeList, or null if that is not a valid index.
|
||
*/
|
||
item: function(index) {
|
||
return this[index] || null;
|
||
},
|
||
toString:function(isHTML,nodeFilter){
|
||
for(var buf = [], i = 0;i<this.length;i++){
|
||
serializeToString(this[i],buf,isHTML,nodeFilter);
|
||
}
|
||
return buf.join('');
|
||
}
|
||
};
|
||
function LiveNodeList(node,refresh){
|
||
this._node = node;
|
||
this._refresh = refresh;
|
||
_updateLiveList(this);
|
||
}
|
||
function _updateLiveList(list){
|
||
var inc = list._node._inc || list._node.ownerDocument._inc;
|
||
if(list._inc != inc){
|
||
var ls = list._refresh(list._node);
|
||
//console.log(ls.length)
|
||
__set__(list,'length',ls.length);
|
||
copy(ls,list);
|
||
list._inc = inc;
|
||
}
|
||
}
|
||
LiveNodeList.prototype.item = function(i){
|
||
_updateLiveList(this);
|
||
return this[i];
|
||
};
|
||
|
||
_extends(LiveNodeList,NodeList);
|
||
/**
|
||
*
|
||
* Objects implementing the NamedNodeMap interface are used to represent collections of nodes that can be accessed by name. Note that NamedNodeMap does not inherit from NodeList; NamedNodeMaps are not maintained in any particular order. Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index, but this is simply to allow convenient enumeration of the contents of a NamedNodeMap, and does not imply that the DOM specifies an order to these Nodes.
|
||
* NamedNodeMap objects in the DOM are live.
|
||
* used for attributes or DocumentType entities
|
||
*/
|
||
function NamedNodeMap() {
|
||
}
|
||
function _findNodeIndex(list,node){
|
||
var i = list.length;
|
||
while(i--){
|
||
if(list[i] === node){return i}
|
||
}
|
||
}
|
||
|
||
function _addNamedNode(el,list,newAttr,oldAttr){
|
||
if(oldAttr){
|
||
list[_findNodeIndex(list,oldAttr)] = newAttr;
|
||
}else {
|
||
list[list.length++] = newAttr;
|
||
}
|
||
if(el){
|
||
newAttr.ownerElement = el;
|
||
var doc = el.ownerDocument;
|
||
if(doc){
|
||
oldAttr && _onRemoveAttribute(doc,el,oldAttr);
|
||
_onAddAttribute(doc,el,newAttr);
|
||
}
|
||
}
|
||
}
|
||
function _removeNamedNode(el,list,attr){
|
||
//console.log('remove attr:'+attr)
|
||
var i = _findNodeIndex(list,attr);
|
||
if(i>=0){
|
||
var lastIndex = list.length-1;
|
||
while(i<lastIndex){
|
||
list[i] = list[++i];
|
||
}
|
||
list.length = lastIndex;
|
||
if(el){
|
||
var doc = el.ownerDocument;
|
||
if(doc){
|
||
_onRemoveAttribute(doc,el,attr);
|
||
attr.ownerElement = null;
|
||
}
|
||
}
|
||
}else {
|
||
throw DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr))
|
||
}
|
||
}
|
||
NamedNodeMap.prototype = {
|
||
length:0,
|
||
item:NodeList.prototype.item,
|
||
getNamedItem: function(key) {
|
||
// if(key.indexOf(':')>0 || key == 'xmlns'){
|
||
// return null;
|
||
// }
|
||
//console.log()
|
||
var i = this.length;
|
||
while(i--){
|
||
var attr = this[i];
|
||
//console.log(attr.nodeName,key)
|
||
if(attr.nodeName == key){
|
||
return attr;
|
||
}
|
||
}
|
||
},
|
||
setNamedItem: function(attr) {
|
||
var el = attr.ownerElement;
|
||
if(el && el!=this._ownerElement){
|
||
throw new DOMException(INUSE_ATTRIBUTE_ERR);
|
||
}
|
||
var oldAttr = this.getNamedItem(attr.nodeName);
|
||
_addNamedNode(this._ownerElement,this,attr,oldAttr);
|
||
return oldAttr;
|
||
},
|
||
/* returns Node */
|
||
setNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR
|
||
var el = attr.ownerElement, oldAttr;
|
||
if(el && el!=this._ownerElement){
|
||
throw new DOMException(INUSE_ATTRIBUTE_ERR);
|
||
}
|
||
oldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName);
|
||
_addNamedNode(this._ownerElement,this,attr,oldAttr);
|
||
return oldAttr;
|
||
},
|
||
|
||
/* returns Node */
|
||
removeNamedItem: function(key) {
|
||
var attr = this.getNamedItem(key);
|
||
_removeNamedNode(this._ownerElement,this,attr);
|
||
return attr;
|
||
|
||
|
||
},// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
|
||
|
||
//for level2
|
||
removeNamedItemNS:function(namespaceURI,localName){
|
||
var attr = this.getNamedItemNS(namespaceURI,localName);
|
||
_removeNamedNode(this._ownerElement,this,attr);
|
||
return attr;
|
||
},
|
||
getNamedItemNS: function(namespaceURI, localName) {
|
||
var i = this.length;
|
||
while(i--){
|
||
var node = this[i];
|
||
if(node.localName == localName && node.namespaceURI == namespaceURI){
|
||
return node;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
};
|
||
/**
|
||
* @see http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490
|
||
*/
|
||
function DOMImplementation(/* Object */ features) {
|
||
this._features = {};
|
||
if (features) {
|
||
for (var feature in features) {
|
||
this._features = features[feature];
|
||
}
|
||
}
|
||
}
|
||
DOMImplementation.prototype = {
|
||
hasFeature: function(/* string */ feature, /* string */ version) {
|
||
var versions = this._features[feature.toLowerCase()];
|
||
if (versions && (!version || version in versions)) {
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
},
|
||
// Introduced in DOM Level 2:
|
||
createDocument:function(namespaceURI, qualifiedName, doctype){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR,WRONG_DOCUMENT_ERR
|
||
var doc = new Document();
|
||
doc.implementation = this;
|
||
doc.childNodes = new NodeList();
|
||
doc.doctype = doctype;
|
||
if(doctype){
|
||
doc.appendChild(doctype);
|
||
}
|
||
if(qualifiedName){
|
||
var root = doc.createElementNS(namespaceURI,qualifiedName);
|
||
doc.appendChild(root);
|
||
}
|
||
return doc;
|
||
},
|
||
// Introduced in DOM Level 2:
|
||
createDocumentType:function(qualifiedName, publicId, systemId){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR
|
||
var node = new DocumentType();
|
||
node.name = qualifiedName;
|
||
node.nodeName = qualifiedName;
|
||
node.publicId = publicId;
|
||
node.systemId = systemId;
|
||
// Introduced in DOM Level 2:
|
||
//readonly attribute DOMString internalSubset;
|
||
|
||
//TODO:..
|
||
// readonly attribute NamedNodeMap entities;
|
||
// readonly attribute NamedNodeMap notations;
|
||
return node;
|
||
}
|
||
};
|
||
|
||
|
||
/**
|
||
* @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
|
||
*/
|
||
|
||
function Node() {
|
||
}
|
||
Node.prototype = {
|
||
firstChild : null,
|
||
lastChild : null,
|
||
previousSibling : null,
|
||
nextSibling : null,
|
||
attributes : null,
|
||
parentNode : null,
|
||
childNodes : null,
|
||
ownerDocument : null,
|
||
nodeValue : null,
|
||
namespaceURI : null,
|
||
prefix : null,
|
||
localName : null,
|
||
// Modified in DOM Level 2:
|
||
insertBefore:function(newChild, refChild){//raises
|
||
return _insertBefore(this,newChild,refChild);
|
||
},
|
||
replaceChild:function(newChild, oldChild){//raises
|
||
this.insertBefore(newChild,oldChild);
|
||
if(oldChild){
|
||
this.removeChild(oldChild);
|
||
}
|
||
},
|
||
removeChild:function(oldChild){
|
||
return _removeChild(this,oldChild);
|
||
},
|
||
appendChild:function(newChild){
|
||
return this.insertBefore(newChild,null);
|
||
},
|
||
hasChildNodes:function(){
|
||
return this.firstChild != null;
|
||
},
|
||
cloneNode:function(deep){
|
||
return cloneNode(this.ownerDocument||this,this,deep);
|
||
},
|
||
// Modified in DOM Level 2:
|
||
normalize:function(){
|
||
var child = this.firstChild;
|
||
while(child){
|
||
var next = child.nextSibling;
|
||
if(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){
|
||
this.removeChild(next);
|
||
child.appendData(next.data);
|
||
}else {
|
||
child.normalize();
|
||
child = next;
|
||
}
|
||
}
|
||
},
|
||
// Introduced in DOM Level 2:
|
||
isSupported:function(feature, version){
|
||
return this.ownerDocument.implementation.hasFeature(feature,version);
|
||
},
|
||
// Introduced in DOM Level 2:
|
||
hasAttributes:function(){
|
||
return this.attributes.length>0;
|
||
},
|
||
lookupPrefix:function(namespaceURI){
|
||
var el = this;
|
||
while(el){
|
||
var map = el._nsMap;
|
||
//console.dir(map)
|
||
if(map){
|
||
for(var n in map){
|
||
if(map[n] == namespaceURI){
|
||
return n;
|
||
}
|
||
}
|
||
}
|
||
el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
|
||
}
|
||
return null;
|
||
},
|
||
// Introduced in DOM Level 3:
|
||
lookupNamespaceURI:function(prefix){
|
||
var el = this;
|
||
while(el){
|
||
var map = el._nsMap;
|
||
//console.dir(map)
|
||
if(map){
|
||
if(prefix in map){
|
||
return map[prefix] ;
|
||
}
|
||
}
|
||
el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
|
||
}
|
||
return null;
|
||
},
|
||
// Introduced in DOM Level 3:
|
||
isDefaultNamespace:function(namespaceURI){
|
||
var prefix = this.lookupPrefix(namespaceURI);
|
||
return prefix == null;
|
||
}
|
||
};
|
||
|
||
|
||
function _xmlEncoder(c){
|
||
return c == '<' && '<' ||
|
||
c == '>' && '>' ||
|
||
c == '&' && '&' ||
|
||
c == '"' && '"' ||
|
||
'&#'+c.charCodeAt()+';'
|
||
}
|
||
|
||
|
||
copy(NodeType,Node);
|
||
copy(NodeType,Node.prototype);
|
||
|
||
/**
|
||
* @param callback return true for continue,false for break
|
||
* @return boolean true: break visit;
|
||
*/
|
||
function _visitNode(node,callback){
|
||
if(callback(node)){
|
||
return true;
|
||
}
|
||
if(node = node.firstChild){
|
||
do{
|
||
if(_visitNode(node,callback)){return true}
|
||
}while(node=node.nextSibling)
|
||
}
|
||
}
|
||
|
||
|
||
|
||
function Document(){
|
||
}
|
||
function _onAddAttribute(doc,el,newAttr){
|
||
doc && doc._inc++;
|
||
var ns = newAttr.namespaceURI ;
|
||
if(ns == 'http://www.w3.org/2000/xmlns/'){
|
||
//update namespace
|
||
el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value;
|
||
}
|
||
}
|
||
function _onRemoveAttribute(doc,el,newAttr,remove){
|
||
doc && doc._inc++;
|
||
var ns = newAttr.namespaceURI ;
|
||
if(ns == 'http://www.w3.org/2000/xmlns/'){
|
||
//update namespace
|
||
delete el._nsMap[newAttr.prefix?newAttr.localName:''];
|
||
}
|
||
}
|
||
function _onUpdateChild(doc,el,newChild){
|
||
if(doc && doc._inc){
|
||
doc._inc++;
|
||
//update childNodes
|
||
var cs = el.childNodes;
|
||
if(newChild){
|
||
cs[cs.length++] = newChild;
|
||
}else {
|
||
//console.log(1)
|
||
var child = el.firstChild;
|
||
var i = 0;
|
||
while(child){
|
||
cs[i++] = child;
|
||
child =child.nextSibling;
|
||
}
|
||
cs.length = i;
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* attributes;
|
||
* children;
|
||
*
|
||
* writeable properties:
|
||
* nodeValue,Attr:value,CharacterData:data
|
||
* prefix
|
||
*/
|
||
function _removeChild(parentNode,child){
|
||
var previous = child.previousSibling;
|
||
var next = child.nextSibling;
|
||
if(previous){
|
||
previous.nextSibling = next;
|
||
}else {
|
||
parentNode.firstChild = next;
|
||
}
|
||
if(next){
|
||
next.previousSibling = previous;
|
||
}else {
|
||
parentNode.lastChild = previous;
|
||
}
|
||
_onUpdateChild(parentNode.ownerDocument,parentNode);
|
||
return child;
|
||
}
|
||
/**
|
||
* preformance key(refChild == null)
|
||
*/
|
||
function _insertBefore(parentNode,newChild,nextChild){
|
||
var cp = newChild.parentNode;
|
||
if(cp){
|
||
cp.removeChild(newChild);//remove and update
|
||
}
|
||
if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
|
||
var newFirst = newChild.firstChild;
|
||
if (newFirst == null) {
|
||
return newChild;
|
||
}
|
||
var newLast = newChild.lastChild;
|
||
}else {
|
||
newFirst = newLast = newChild;
|
||
}
|
||
var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild;
|
||
|
||
newFirst.previousSibling = pre;
|
||
newLast.nextSibling = nextChild;
|
||
|
||
|
||
if(pre){
|
||
pre.nextSibling = newFirst;
|
||
}else {
|
||
parentNode.firstChild = newFirst;
|
||
}
|
||
if(nextChild == null){
|
||
parentNode.lastChild = newLast;
|
||
}else {
|
||
nextChild.previousSibling = newLast;
|
||
}
|
||
do{
|
||
newFirst.parentNode = parentNode;
|
||
}while(newFirst !== newLast && (newFirst= newFirst.nextSibling))
|
||
_onUpdateChild(parentNode.ownerDocument||parentNode,parentNode);
|
||
//console.log(parentNode.lastChild.nextSibling == null)
|
||
if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
|
||
newChild.firstChild = newChild.lastChild = null;
|
||
}
|
||
return newChild;
|
||
}
|
||
function _appendSingleChild(parentNode,newChild){
|
||
var cp = newChild.parentNode;
|
||
if(cp){
|
||
var pre = parentNode.lastChild;
|
||
cp.removeChild(newChild);//remove and update
|
||
var pre = parentNode.lastChild;
|
||
}
|
||
var pre = parentNode.lastChild;
|
||
newChild.parentNode = parentNode;
|
||
newChild.previousSibling = pre;
|
||
newChild.nextSibling = null;
|
||
if(pre){
|
||
pre.nextSibling = newChild;
|
||
}else {
|
||
parentNode.firstChild = newChild;
|
||
}
|
||
parentNode.lastChild = newChild;
|
||
_onUpdateChild(parentNode.ownerDocument,parentNode,newChild);
|
||
return newChild;
|
||
//console.log("__aa",parentNode.lastChild.nextSibling == null)
|
||
}
|
||
Document.prototype = {
|
||
//implementation : null,
|
||
nodeName : '#document',
|
||
nodeType : DOCUMENT_NODE,
|
||
doctype : null,
|
||
documentElement : null,
|
||
_inc : 1,
|
||
|
||
insertBefore : function(newChild, refChild){//raises
|
||
if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){
|
||
var child = newChild.firstChild;
|
||
while(child){
|
||
var next = child.nextSibling;
|
||
this.insertBefore(child,refChild);
|
||
child = next;
|
||
}
|
||
return newChild;
|
||
}
|
||
if(this.documentElement == null && newChild.nodeType == ELEMENT_NODE){
|
||
this.documentElement = newChild;
|
||
}
|
||
|
||
return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild;
|
||
},
|
||
removeChild : function(oldChild){
|
||
if(this.documentElement == oldChild){
|
||
this.documentElement = null;
|
||
}
|
||
return _removeChild(this,oldChild);
|
||
},
|
||
// Introduced in DOM Level 2:
|
||
importNode : function(importedNode,deep){
|
||
return importNode(this,importedNode,deep);
|
||
},
|
||
// Introduced in DOM Level 2:
|
||
getElementById : function(id){
|
||
var rtv = null;
|
||
_visitNode(this.documentElement,function(node){
|
||
if(node.nodeType == ELEMENT_NODE){
|
||
if(node.getAttribute('id') == id){
|
||
rtv = node;
|
||
return true;
|
||
}
|
||
}
|
||
});
|
||
return rtv;
|
||
},
|
||
|
||
//document factory method:
|
||
createElement : function(tagName){
|
||
var node = new Element();
|
||
node.ownerDocument = this;
|
||
node.nodeName = tagName;
|
||
node.tagName = tagName;
|
||
node.childNodes = new NodeList();
|
||
var attrs = node.attributes = new NamedNodeMap();
|
||
attrs._ownerElement = node;
|
||
return node;
|
||
},
|
||
createDocumentFragment : function(){
|
||
var node = new DocumentFragment();
|
||
node.ownerDocument = this;
|
||
node.childNodes = new NodeList();
|
||
return node;
|
||
},
|
||
createTextNode : function(data){
|
||
var node = new Text();
|
||
node.ownerDocument = this;
|
||
node.appendData(data);
|
||
return node;
|
||
},
|
||
createComment : function(data){
|
||
var node = new Comment();
|
||
node.ownerDocument = this;
|
||
node.appendData(data);
|
||
return node;
|
||
},
|
||
createCDATASection : function(data){
|
||
var node = new CDATASection();
|
||
node.ownerDocument = this;
|
||
node.appendData(data);
|
||
return node;
|
||
},
|
||
createProcessingInstruction : function(target,data){
|
||
var node = new ProcessingInstruction();
|
||
node.ownerDocument = this;
|
||
node.tagName = node.target = target;
|
||
node.nodeValue= node.data = data;
|
||
return node;
|
||
},
|
||
createAttribute : function(name){
|
||
var node = new Attr();
|
||
node.ownerDocument = this;
|
||
node.name = name;
|
||
node.nodeName = name;
|
||
node.localName = name;
|
||
node.specified = true;
|
||
return node;
|
||
},
|
||
createEntityReference : function(name){
|
||
var node = new EntityReference();
|
||
node.ownerDocument = this;
|
||
node.nodeName = name;
|
||
return node;
|
||
},
|
||
// Introduced in DOM Level 2:
|
||
createElementNS : function(namespaceURI,qualifiedName){
|
||
var node = new Element();
|
||
var pl = qualifiedName.split(':');
|
||
var attrs = node.attributes = new NamedNodeMap();
|
||
node.childNodes = new NodeList();
|
||
node.ownerDocument = this;
|
||
node.nodeName = qualifiedName;
|
||
node.tagName = qualifiedName;
|
||
node.namespaceURI = namespaceURI;
|
||
if(pl.length == 2){
|
||
node.prefix = pl[0];
|
||
node.localName = pl[1];
|
||
}else {
|
||
//el.prefix = null;
|
||
node.localName = qualifiedName;
|
||
}
|
||
attrs._ownerElement = node;
|
||
return node;
|
||
},
|
||
// Introduced in DOM Level 2:
|
||
createAttributeNS : function(namespaceURI,qualifiedName){
|
||
var node = new Attr();
|
||
var pl = qualifiedName.split(':');
|
||
node.ownerDocument = this;
|
||
node.nodeName = qualifiedName;
|
||
node.name = qualifiedName;
|
||
node.namespaceURI = namespaceURI;
|
||
node.specified = true;
|
||
if(pl.length == 2){
|
||
node.prefix = pl[0];
|
||
node.localName = pl[1];
|
||
}else {
|
||
//el.prefix = null;
|
||
node.localName = qualifiedName;
|
||
}
|
||
return node;
|
||
}
|
||
};
|
||
_extends(Document,Node);
|
||
|
||
|
||
function Element() {
|
||
this._nsMap = {};
|
||
}Element.prototype = {
|
||
nodeType : ELEMENT_NODE,
|
||
hasAttribute : function(name){
|
||
return this.getAttributeNode(name)!=null;
|
||
},
|
||
getAttribute : function(name){
|
||
var attr = this.getAttributeNode(name);
|
||
return attr && attr.value || '';
|
||
},
|
||
getAttributeNode : function(name){
|
||
return this.attributes.getNamedItem(name);
|
||
},
|
||
setAttribute : function(name, value){
|
||
var attr = this.ownerDocument.createAttribute(name);
|
||
attr.value = attr.nodeValue = "" + value;
|
||
this.setAttributeNode(attr);
|
||
},
|
||
removeAttribute : function(name){
|
||
var attr = this.getAttributeNode(name);
|
||
attr && this.removeAttributeNode(attr);
|
||
},
|
||
|
||
//four real opeartion method
|
||
appendChild:function(newChild){
|
||
if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
|
||
return this.insertBefore(newChild,null);
|
||
}else {
|
||
return _appendSingleChild(this,newChild);
|
||
}
|
||
},
|
||
setAttributeNode : function(newAttr){
|
||
return this.attributes.setNamedItem(newAttr);
|
||
},
|
||
setAttributeNodeNS : function(newAttr){
|
||
return this.attributes.setNamedItemNS(newAttr);
|
||
},
|
||
removeAttributeNode : function(oldAttr){
|
||
//console.log(this == oldAttr.ownerElement)
|
||
return this.attributes.removeNamedItem(oldAttr.nodeName);
|
||
},
|
||
//get real attribute name,and remove it by removeAttributeNode
|
||
removeAttributeNS : function(namespaceURI, localName){
|
||
var old = this.getAttributeNodeNS(namespaceURI, localName);
|
||
old && this.removeAttributeNode(old);
|
||
},
|
||
|
||
hasAttributeNS : function(namespaceURI, localName){
|
||
return this.getAttributeNodeNS(namespaceURI, localName)!=null;
|
||
},
|
||
getAttributeNS : function(namespaceURI, localName){
|
||
var attr = this.getAttributeNodeNS(namespaceURI, localName);
|
||
return attr && attr.value || '';
|
||
},
|
||
setAttributeNS : function(namespaceURI, qualifiedName, value){
|
||
var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
|
||
attr.value = attr.nodeValue = "" + value;
|
||
this.setAttributeNode(attr);
|
||
},
|
||
getAttributeNodeNS : function(namespaceURI, localName){
|
||
return this.attributes.getNamedItemNS(namespaceURI, localName);
|
||
},
|
||
|
||
getElementsByTagName : function(tagName){
|
||
return new LiveNodeList(this,function(base){
|
||
var ls = [];
|
||
_visitNode(base,function(node){
|
||
if(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){
|
||
ls.push(node);
|
||
}
|
||
});
|
||
return ls;
|
||
});
|
||
},
|
||
getElementsByTagNameNS : function(namespaceURI, localName){
|
||
return new LiveNodeList(this,function(base){
|
||
var ls = [];
|
||
_visitNode(base,function(node){
|
||
if(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){
|
||
ls.push(node);
|
||
}
|
||
});
|
||
return ls;
|
||
|
||
});
|
||
}
|
||
};
|
||
Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
|
||
Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
|
||
|
||
|
||
_extends(Element,Node);
|
||
function Attr() {
|
||
}Attr.prototype.nodeType = ATTRIBUTE_NODE;
|
||
_extends(Attr,Node);
|
||
|
||
|
||
function CharacterData() {
|
||
}CharacterData.prototype = {
|
||
data : '',
|
||
substringData : function(offset, count) {
|
||
return this.data.substring(offset, offset+count);
|
||
},
|
||
appendData: function(text) {
|
||
text = this.data+text;
|
||
this.nodeValue = this.data = text;
|
||
this.length = text.length;
|
||
},
|
||
insertData: function(offset,text) {
|
||
this.replaceData(offset,0,text);
|
||
|
||
},
|
||
appendChild:function(newChild){
|
||
throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])
|
||
},
|
||
deleteData: function(offset, count) {
|
||
this.replaceData(offset,count,"");
|
||
},
|
||
replaceData: function(offset, count, text) {
|
||
var start = this.data.substring(0,offset);
|
||
var end = this.data.substring(offset+count);
|
||
text = start + text + end;
|
||
this.nodeValue = this.data = text;
|
||
this.length = text.length;
|
||
}
|
||
};
|
||
_extends(CharacterData,Node);
|
||
function Text() {
|
||
}Text.prototype = {
|
||
nodeName : "#text",
|
||
nodeType : TEXT_NODE,
|
||
splitText : function(offset) {
|
||
var text = this.data;
|
||
var newText = text.substring(offset);
|
||
text = text.substring(0, offset);
|
||
this.data = this.nodeValue = text;
|
||
this.length = text.length;
|
||
var newNode = this.ownerDocument.createTextNode(newText);
|
||
if(this.parentNode){
|
||
this.parentNode.insertBefore(newNode, this.nextSibling);
|
||
}
|
||
return newNode;
|
||
}
|
||
};
|
||
_extends(Text,CharacterData);
|
||
function Comment() {
|
||
}Comment.prototype = {
|
||
nodeName : "#comment",
|
||
nodeType : COMMENT_NODE
|
||
};
|
||
_extends(Comment,CharacterData);
|
||
|
||
function CDATASection() {
|
||
}CDATASection.prototype = {
|
||
nodeName : "#cdata-section",
|
||
nodeType : CDATA_SECTION_NODE
|
||
};
|
||
_extends(CDATASection,CharacterData);
|
||
|
||
|
||
function DocumentType() {
|
||
}DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
|
||
_extends(DocumentType,Node);
|
||
|
||
function Notation() {
|
||
}Notation.prototype.nodeType = NOTATION_NODE;
|
||
_extends(Notation,Node);
|
||
|
||
function Entity() {
|
||
}Entity.prototype.nodeType = ENTITY_NODE;
|
||
_extends(Entity,Node);
|
||
|
||
function EntityReference() {
|
||
}EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
|
||
_extends(EntityReference,Node);
|
||
|
||
function DocumentFragment() {
|
||
}DocumentFragment.prototype.nodeName = "#document-fragment";
|
||
DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
|
||
_extends(DocumentFragment,Node);
|
||
|
||
|
||
function ProcessingInstruction() {
|
||
}
|
||
ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
|
||
_extends(ProcessingInstruction,Node);
|
||
function XMLSerializer(){}
|
||
XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){
|
||
return nodeSerializeToString.call(node,isHtml,nodeFilter);
|
||
};
|
||
Node.prototype.toString = nodeSerializeToString;
|
||
function nodeSerializeToString(isHtml,nodeFilter){
|
||
var buf = [];
|
||
var refNode = this.nodeType == 9?this.documentElement:this;
|
||
var prefix = refNode.prefix;
|
||
var uri = refNode.namespaceURI;
|
||
|
||
if(uri && prefix == null){
|
||
//console.log(prefix)
|
||
var prefix = refNode.lookupPrefix(uri);
|
||
if(prefix == null){
|
||
//isHTML = true;
|
||
var visibleNamespaces=[
|
||
{namespace:uri,prefix:null}
|
||
//{namespace:uri,prefix:''}
|
||
];
|
||
}
|
||
}
|
||
serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);
|
||
//console.log('###',this.nodeType,uri,prefix,buf.join(''))
|
||
return buf.join('');
|
||
}
|
||
function needNamespaceDefine(node,isHTML, visibleNamespaces) {
|
||
var prefix = node.prefix||'';
|
||
var uri = node.namespaceURI;
|
||
if (!prefix && !uri){
|
||
return false;
|
||
}
|
||
if (prefix === "xml" && uri === "http://www.w3.org/XML/1998/namespace"
|
||
|| uri == 'http://www.w3.org/2000/xmlns/'){
|
||
return false;
|
||
}
|
||
|
||
var i = visibleNamespaces.length;
|
||
//console.log('@@@@',node.tagName,prefix,uri,visibleNamespaces)
|
||
while (i--) {
|
||
var ns = visibleNamespaces[i];
|
||
// get namespace prefix
|
||
//console.log(node.nodeType,node.tagName,ns.prefix,prefix)
|
||
if (ns.prefix == prefix){
|
||
return ns.namespace != uri;
|
||
}
|
||
}
|
||
//console.log(isHTML,uri,prefix=='')
|
||
//if(isHTML && prefix ==null && uri == 'http://www.w3.org/1999/xhtml'){
|
||
// return false;
|
||
//}
|
||
//node.flag = '11111'
|
||
//console.error(3,true,node.flag,node.prefix,node.namespaceURI)
|
||
return true;
|
||
}
|
||
function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
|
||
if(nodeFilter){
|
||
node = nodeFilter(node);
|
||
if(node){
|
||
if(typeof node == 'string'){
|
||
buf.push(node);
|
||
return;
|
||
}
|
||
}else {
|
||
return;
|
||
}
|
||
//buf.sort.apply(attrs, attributeSorter);
|
||
}
|
||
switch(node.nodeType){
|
||
case ELEMENT_NODE:
|
||
if (!visibleNamespaces) visibleNamespaces = [];
|
||
var startVisibleNamespaces = visibleNamespaces.length;
|
||
var attrs = node.attributes;
|
||
var len = attrs.length;
|
||
var child = node.firstChild;
|
||
var nodeName = node.tagName;
|
||
|
||
isHTML = (htmlns === node.namespaceURI) ||isHTML;
|
||
buf.push('<',nodeName);
|
||
|
||
|
||
|
||
for(var i=0;i<len;i++){
|
||
// add namespaces for attributes
|
||
var attr = attrs.item(i);
|
||
if (attr.prefix == 'xmlns') {
|
||
visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
|
||
}else if(attr.nodeName == 'xmlns'){
|
||
visibleNamespaces.push({ prefix: '', namespace: attr.value });
|
||
}
|
||
}
|
||
for(var i=0;i<len;i++){
|
||
var attr = attrs.item(i);
|
||
if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
|
||
var prefix = attr.prefix||'';
|
||
var uri = attr.namespaceURI;
|
||
var ns = prefix ? ' xmlns:' + prefix : " xmlns";
|
||
buf.push(ns, '="' , uri , '"');
|
||
visibleNamespaces.push({ prefix: prefix, namespace:uri });
|
||
}
|
||
serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
|
||
}
|
||
// add namespace for current node
|
||
if (needNamespaceDefine(node,isHTML, visibleNamespaces)) {
|
||
var prefix = node.prefix||'';
|
||
var uri = node.namespaceURI;
|
||
var ns = prefix ? ' xmlns:' + prefix : " xmlns";
|
||
buf.push(ns, '="' , uri , '"');
|
||
visibleNamespaces.push({ prefix: prefix, namespace:uri });
|
||
}
|
||
|
||
if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
|
||
buf.push('>');
|
||
//if is cdata child node
|
||
if(isHTML && /^script$/i.test(nodeName)){
|
||
while(child){
|
||
if(child.data){
|
||
buf.push(child.data);
|
||
}else {
|
||
serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
|
||
}
|
||
child = child.nextSibling;
|
||
}
|
||
}else
|
||
{
|
||
while(child){
|
||
serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
|
||
child = child.nextSibling;
|
||
}
|
||
}
|
||
buf.push('</',nodeName,'>');
|
||
}else {
|
||
buf.push('/>');
|
||
}
|
||
// remove added visible namespaces
|
||
//visibleNamespaces.length = startVisibleNamespaces;
|
||
return;
|
||
case DOCUMENT_NODE:
|
||
case DOCUMENT_FRAGMENT_NODE:
|
||
var child = node.firstChild;
|
||
while(child){
|
||
serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
|
||
child = child.nextSibling;
|
||
}
|
||
return;
|
||
case ATTRIBUTE_NODE:
|
||
return buf.push(' ',node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"');
|
||
case TEXT_NODE:
|
||
return buf.push(node.data.replace(/[<&]/g,_xmlEncoder));
|
||
case CDATA_SECTION_NODE:
|
||
return buf.push( '<![CDATA[',node.data,']]>');
|
||
case COMMENT_NODE:
|
||
return buf.push( "<!--",node.data,"-->");
|
||
case DOCUMENT_TYPE_NODE:
|
||
var pubid = node.publicId;
|
||
var sysid = node.systemId;
|
||
buf.push('<!DOCTYPE ',node.name);
|
||
if(pubid){
|
||
buf.push(' PUBLIC "',pubid);
|
||
if (sysid && sysid!='.') {
|
||
buf.push( '" "',sysid);
|
||
}
|
||
buf.push('">');
|
||
}else if(sysid && sysid!='.'){
|
||
buf.push(' SYSTEM "',sysid,'">');
|
||
}else {
|
||
var sub = node.internalSubset;
|
||
if(sub){
|
||
buf.push(" [",sub,"]");
|
||
}
|
||
buf.push(">");
|
||
}
|
||
return;
|
||
case PROCESSING_INSTRUCTION_NODE:
|
||
return buf.push( "<?",node.target," ",node.data,"?>");
|
||
case ENTITY_REFERENCE_NODE:
|
||
return buf.push( '&',node.nodeName,';');
|
||
//case ENTITY_NODE:
|
||
//case NOTATION_NODE:
|
||
default:
|
||
buf.push('??',node.nodeName);
|
||
}
|
||
}
|
||
function importNode(doc,node,deep){
|
||
var node2;
|
||
switch (node.nodeType) {
|
||
case ELEMENT_NODE:
|
||
node2 = node.cloneNode(false);
|
||
node2.ownerDocument = doc;
|
||
//var attrs = node2.attributes;
|
||
//var len = attrs.length;
|
||
//for(var i=0;i<len;i++){
|
||
//node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep));
|
||
//}
|
||
case DOCUMENT_FRAGMENT_NODE:
|
||
break;
|
||
case ATTRIBUTE_NODE:
|
||
deep = true;
|
||
break;
|
||
//case ENTITY_REFERENCE_NODE:
|
||
//case PROCESSING_INSTRUCTION_NODE:
|
||
////case TEXT_NODE:
|
||
//case CDATA_SECTION_NODE:
|
||
//case COMMENT_NODE:
|
||
// deep = false;
|
||
// break;
|
||
//case DOCUMENT_NODE:
|
||
//case DOCUMENT_TYPE_NODE:
|
||
//cannot be imported.
|
||
//case ENTITY_NODE:
|
||
//case NOTATION_NODE:
|
||
//can not hit in level3
|
||
//default:throw e;
|
||
}
|
||
if(!node2){
|
||
node2 = node.cloneNode(false);//false
|
||
}
|
||
node2.ownerDocument = doc;
|
||
node2.parentNode = null;
|
||
if(deep){
|
||
var child = node.firstChild;
|
||
while(child){
|
||
node2.appendChild(importNode(doc,child,deep));
|
||
child = child.nextSibling;
|
||
}
|
||
}
|
||
return node2;
|
||
}
|
||
//
|
||
//var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
|
||
// attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
|
||
function cloneNode(doc,node,deep){
|
||
var node2 = new node.constructor();
|
||
for(var n in node){
|
||
var v = node[n];
|
||
if(typeof v != 'object' ){
|
||
if(v != node2[n]){
|
||
node2[n] = v;
|
||
}
|
||
}
|
||
}
|
||
if(node.childNodes){
|
||
node2.childNodes = new NodeList();
|
||
}
|
||
node2.ownerDocument = doc;
|
||
switch (node2.nodeType) {
|
||
case ELEMENT_NODE:
|
||
var attrs = node.attributes;
|
||
var attrs2 = node2.attributes = new NamedNodeMap();
|
||
var len = attrs.length;
|
||
attrs2._ownerElement = node2;
|
||
for(var i=0;i<len;i++){
|
||
node2.setAttributeNode(cloneNode(doc,attrs.item(i),true));
|
||
}
|
||
break; case ATTRIBUTE_NODE:
|
||
deep = true;
|
||
}
|
||
if(deep){
|
||
var child = node.firstChild;
|
||
while(child){
|
||
node2.appendChild(cloneNode(doc,child,deep));
|
||
child = child.nextSibling;
|
||
}
|
||
}
|
||
return node2;
|
||
}
|
||
|
||
function __set__(object,key,value){
|
||
object[key] = value;
|
||
}
|
||
//do dynamic
|
||
try{
|
||
if(Object.defineProperty){
|
||
Object.defineProperty(LiveNodeList.prototype,'length',{
|
||
get:function(){
|
||
_updateLiveList(this);
|
||
return this.$$length;
|
||
}
|
||
});
|
||
Object.defineProperty(Node.prototype,'textContent',{
|
||
get:function(){
|
||
return getTextContent(this);
|
||
},
|
||
set:function(data){
|
||
switch(this.nodeType){
|
||
case ELEMENT_NODE:
|
||
case DOCUMENT_FRAGMENT_NODE:
|
||
while(this.firstChild){
|
||
this.removeChild(this.firstChild);
|
||
}
|
||
if(data || String(data)){
|
||
this.appendChild(this.ownerDocument.createTextNode(data));
|
||
}
|
||
break;
|
||
default:
|
||
//TODO:
|
||
this.data = data;
|
||
this.value = data;
|
||
this.nodeValue = data;
|
||
}
|
||
}
|
||
});
|
||
|
||
function getTextContent(node){
|
||
switch(node.nodeType){
|
||
case ELEMENT_NODE:
|
||
case DOCUMENT_FRAGMENT_NODE:
|
||
var buf = [];
|
||
node = node.firstChild;
|
||
while(node){
|
||
if(node.nodeType!==7 && node.nodeType !==8){
|
||
buf.push(getTextContent(node));
|
||
}
|
||
node = node.nextSibling;
|
||
}
|
||
return buf.join('');
|
||
default:
|
||
return node.nodeValue;
|
||
}
|
||
}
|
||
__set__ = function(object,key,value){
|
||
//console.log(value)
|
||
object['$$'+key] = value;
|
||
};
|
||
}
|
||
}catch(e){//ie8
|
||
}
|
||
|
||
//if(typeof require == 'function'){
|
||
var DOMImplementation_1 = DOMImplementation;
|
||
var XMLSerializer_1 = XMLSerializer;
|
||
//}
|
||
|
||
var dom = {
|
||
DOMImplementation: DOMImplementation_1,
|
||
XMLSerializer: XMLSerializer_1
|
||
};
|
||
|
||
var domParser = createCommonjsModule(function (module, exports) {
|
||
function DOMParser(options){
|
||
this.options = options ||{locator:{}};
|
||
|
||
}
|
||
DOMParser.prototype.parseFromString = function(source,mimeType){
|
||
var options = this.options;
|
||
var sax = new XMLReader();
|
||
var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
|
||
var errorHandler = options.errorHandler;
|
||
var locator = options.locator;
|
||
var defaultNSMap = options.xmlns||{};
|
||
var entityMap = {'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'"};
|
||
if(locator){
|
||
domBuilder.setDocumentLocator(locator);
|
||
}
|
||
|
||
sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator);
|
||
sax.domBuilder = options.domBuilder || domBuilder;
|
||
if(/\/x?html?$/.test(mimeType)){
|
||
entityMap.nbsp = '\xa0';
|
||
entityMap.copy = '\xa9';
|
||
defaultNSMap['']= 'http://www.w3.org/1999/xhtml';
|
||
}
|
||
defaultNSMap.xml = defaultNSMap.xml || 'http://www.w3.org/XML/1998/namespace';
|
||
if(source){
|
||
sax.parse(source,defaultNSMap,entityMap);
|
||
}else {
|
||
sax.errorHandler.error("invalid doc source");
|
||
}
|
||
return domBuilder.doc;
|
||
};
|
||
function buildErrorHandler(errorImpl,domBuilder,locator){
|
||
if(!errorImpl){
|
||
if(domBuilder instanceof DOMHandler){
|
||
return domBuilder;
|
||
}
|
||
errorImpl = domBuilder ;
|
||
}
|
||
var errorHandler = {};
|
||
var isCallback = errorImpl instanceof Function;
|
||
locator = locator||{};
|
||
function build(key){
|
||
var fn = errorImpl[key];
|
||
if(!fn && isCallback){
|
||
fn = errorImpl.length == 2?function(msg){errorImpl(key,msg);}:errorImpl;
|
||
}
|
||
errorHandler[key] = fn && function(msg){
|
||
fn('[xmldom '+key+']\t'+msg+_locator(locator));
|
||
}||function(){};
|
||
}
|
||
build('warning');
|
||
build('error');
|
||
build('fatalError');
|
||
return errorHandler;
|
||
}
|
||
|
||
//console.log('#\n\n\n\n\n\n\n####')
|
||
/**
|
||
* +ContentHandler+ErrorHandler
|
||
* +LexicalHandler+EntityResolver2
|
||
* -DeclHandler-DTDHandler
|
||
*
|
||
* DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler
|
||
* DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2
|
||
* @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html
|
||
*/
|
||
function DOMHandler() {
|
||
this.cdata = false;
|
||
}
|
||
function position(locator,node){
|
||
node.lineNumber = locator.lineNumber;
|
||
node.columnNumber = locator.columnNumber;
|
||
}
|
||
/**
|
||
* @see org.xml.sax.ContentHandler#startDocument
|
||
* @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
|
||
*/
|
||
DOMHandler.prototype = {
|
||
startDocument : function() {
|
||
this.doc = new DOMImplementation().createDocument(null, null, null);
|
||
if (this.locator) {
|
||
this.doc.documentURI = this.locator.systemId;
|
||
}
|
||
},
|
||
startElement:function(namespaceURI, localName, qName, attrs) {
|
||
var doc = this.doc;
|
||
var el = doc.createElementNS(namespaceURI, qName||localName);
|
||
var len = attrs.length;
|
||
appendElement(this, el);
|
||
this.currentElement = el;
|
||
|
||
this.locator && position(this.locator,el);
|
||
for (var i = 0 ; i < len; i++) {
|
||
var namespaceURI = attrs.getURI(i);
|
||
var value = attrs.getValue(i);
|
||
var qName = attrs.getQName(i);
|
||
var attr = doc.createAttributeNS(namespaceURI, qName);
|
||
this.locator &&position(attrs.getLocator(i),attr);
|
||
attr.value = attr.nodeValue = value;
|
||
el.setAttributeNode(attr);
|
||
}
|
||
},
|
||
endElement:function(namespaceURI, localName, qName) {
|
||
var current = this.currentElement;
|
||
var tagName = current.tagName;
|
||
this.currentElement = current.parentNode;
|
||
},
|
||
startPrefixMapping:function(prefix, uri) {
|
||
},
|
||
endPrefixMapping:function(prefix) {
|
||
},
|
||
processingInstruction:function(target, data) {
|
||
var ins = this.doc.createProcessingInstruction(target, data);
|
||
this.locator && position(this.locator,ins);
|
||
appendElement(this, ins);
|
||
},
|
||
ignorableWhitespace:function(ch, start, length) {
|
||
},
|
||
characters:function(chars, start, length) {
|
||
chars = _toString.apply(this,arguments);
|
||
//console.log(chars)
|
||
if(chars){
|
||
if (this.cdata) {
|
||
var charNode = this.doc.createCDATASection(chars);
|
||
} else {
|
||
var charNode = this.doc.createTextNode(chars);
|
||
}
|
||
if(this.currentElement){
|
||
this.currentElement.appendChild(charNode);
|
||
}else if(/^\s*$/.test(chars)){
|
||
this.doc.appendChild(charNode);
|
||
//process xml
|
||
}
|
||
this.locator && position(this.locator,charNode);
|
||
}
|
||
},
|
||
skippedEntity:function(name) {
|
||
},
|
||
endDocument:function() {
|
||
this.doc.normalize();
|
||
},
|
||
setDocumentLocator:function (locator) {
|
||
if(this.locator = locator){// && !('lineNumber' in locator)){
|
||
locator.lineNumber = 0;
|
||
}
|
||
},
|
||
//LexicalHandler
|
||
comment:function(chars, start, length) {
|
||
chars = _toString.apply(this,arguments);
|
||
var comm = this.doc.createComment(chars);
|
||
this.locator && position(this.locator,comm);
|
||
appendElement(this, comm);
|
||
},
|
||
|
||
startCDATA:function() {
|
||
//used in characters() methods
|
||
this.cdata = true;
|
||
},
|
||
endCDATA:function() {
|
||
this.cdata = false;
|
||
},
|
||
|
||
startDTD:function(name, publicId, systemId) {
|
||
var impl = this.doc.implementation;
|
||
if (impl && impl.createDocumentType) {
|
||
var dt = impl.createDocumentType(name, publicId, systemId);
|
||
this.locator && position(this.locator,dt);
|
||
appendElement(this, dt);
|
||
}
|
||
},
|
||
/**
|
||
* @see org.xml.sax.ErrorHandler
|
||
* @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
|
||
*/
|
||
warning:function(error) {
|
||
console.warn('[xmldom warning]\t'+error,_locator(this.locator));
|
||
},
|
||
error:function(error) {
|
||
console.error('[xmldom error]\t'+error,_locator(this.locator));
|
||
},
|
||
fatalError:function(error) {
|
||
console.error('[xmldom fatalError]\t'+error,_locator(this.locator));
|
||
throw error;
|
||
}
|
||
};
|
||
function _locator(l){
|
||
if(l){
|
||
return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']'
|
||
}
|
||
}
|
||
function _toString(chars,start,length){
|
||
if(typeof chars == 'string'){
|
||
return chars.substr(start,length)
|
||
}else {//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
|
||
if(chars.length >= start+length || start){
|
||
return new java.lang.String(chars,start,length)+'';
|
||
}
|
||
return chars;
|
||
}
|
||
}
|
||
|
||
/*
|
||
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
|
||
* used method of org.xml.sax.ext.LexicalHandler:
|
||
* #comment(chars, start, length)
|
||
* #startCDATA()
|
||
* #endCDATA()
|
||
* #startDTD(name, publicId, systemId)
|
||
*
|
||
*
|
||
* IGNORED method of org.xml.sax.ext.LexicalHandler:
|
||
* #endDTD()
|
||
* #startEntity(name)
|
||
* #endEntity(name)
|
||
*
|
||
*
|
||
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
|
||
* IGNORED method of org.xml.sax.ext.DeclHandler
|
||
* #attributeDecl(eName, aName, type, mode, value)
|
||
* #elementDecl(name, model)
|
||
* #externalEntityDecl(name, publicId, systemId)
|
||
* #internalEntityDecl(name, value)
|
||
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
|
||
* IGNORED method of org.xml.sax.EntityResolver2
|
||
* #resolveEntity(String name,String publicId,String baseURI,String systemId)
|
||
* #resolveEntity(publicId, systemId)
|
||
* #getExternalSubset(name, baseURI)
|
||
* @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
|
||
* IGNORED method of org.xml.sax.DTDHandler
|
||
* #notationDecl(name, publicId, systemId) {};
|
||
* #unparsedEntityDecl(name, publicId, systemId, notationName) {};
|
||
*/
|
||
"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){
|
||
DOMHandler.prototype[key] = function(){return null};
|
||
});
|
||
|
||
/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
|
||
function appendElement (hander,node) {
|
||
if (!hander.currentElement) {
|
||
hander.doc.appendChild(node);
|
||
} else {
|
||
hander.currentElement.appendChild(node);
|
||
}
|
||
}//appendChild and setAttributeNS are preformance key
|
||
|
||
//if(typeof require == 'function'){
|
||
var XMLReader = sax.XMLReader;
|
||
var DOMImplementation = exports.DOMImplementation = dom.DOMImplementation;
|
||
exports.XMLSerializer = dom.XMLSerializer ;
|
||
exports.DOMParser = DOMParser;
|
||
//}
|
||
});
|
||
|
||
var videojsHttpStreaming_min = createCommonjsModule(function (module, exports) {
|
||
/*! @name @videojs/http-streaming @version 2.3.1 @license Apache-2.0 */
|
||
!function(e,t){t(exports,document_1,window_1,core,domParser);}(commonjsGlobal,(function(e,t,i,n,r){t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t,i=i&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i,n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;var a=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},s=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t;};function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function u(e,t){return e(t={exports:{}},t.exports),t.exports}function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=d(u((function(e,t){var i,n,r,a,s;i=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#.*)?$/,n=/^([^\/?#]*)(.*)$/,r=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var r=s.parseURL(e);if(!r)throw new Error("Error trying to parse base URL.");return r.path=s.normalizePath(r.path),s.buildURLFromParts(r)}var a=s.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return i.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):t;var o=s.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var u=n.exec(o.path);o.netLoc=u[1],o.path=u[2];}o.netLoc&&!o.path&&(o.path="/");var d={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(d.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var l=o.path,h=l.substring(0,l.lastIndexOf("/")+1)+a.path;d.path=s.normalizePath(h);}else d.path=o.path,a.params||(d.params=o.params,a.query||(d.query=o.query));return null===d.path&&(d.path=i.alwaysNormalize?s.normalizePath(a.path):a.path),s.buildURLFromParts(d)},parseURL:function(e){var t=i.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(r,"");e.length!==(e=e.replace(a,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=s;}))),h=d(i),c=function(e,t){return /^[a-z]+:/i.test(t)?t:(/\/\//i.test(e)||(e=l.default.buildAbsoluteURL(h.default.location&&h.default.location.href||"",e)),l.default.buildAbsoluteURL(e,t))},f=c,m=function(e,t,i){return e&&i&&i.responseURL&&t!==i.responseURL?i.responseURL:t},p=function(){function e(){this.listeners={};}var t=e.prototype;return t.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t);},t.off=function(e,t){if(!this.listeners[e])return !1;var i=this.listeners[e].indexOf(t);return this.listeners[e]=this.listeners[e].slice(0),this.listeners[e].splice(i,1),i>-1},t.trigger=function(e){var t=this.listeners[e];if(t)if(2===arguments.length)for(var i=t.length,n=0;n<i;++n)t[n].call(this,arguments[1]);else for(var r=Array.prototype.slice.call(arguments,1),a=t.length,s=0;s<a;++s)t[s].apply(this,r);},t.dispose=function(){this.listeners={};},t.pipe=function(e){this.on("data",(function(t){e.push(t);}));},e}(),g=u((function(e){function t(){return e.exports=t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);}return e},t.apply(this,arguments)}e.exports=t;}));function y(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var _=y(i),v=function(e){for(var t,i=(t=e,_.default.atob?_.default.atob(t):Buffer.from(t,"base64").toString("binary")),n=new Uint8Array(i.length),r=0;r<i.length;r++)n[r]=i.charCodeAt(r);return n},b=function(e){function t(){var t;return (t=e.call(this)||this).buffer="",t}return s(t,e),t.prototype.push=function(e){var t;for(this.buffer+=e,t=this.buffer.indexOf("\n");t>-1;t=this.buffer.indexOf("\n"))this.trigger("data",this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1);},t}(p),T=function(e){for(var t,i=e.split(new RegExp('(?:^|,)((?:[^=]*)=(?:"[^"]*"|[^,]*))')),n={},r=i.length;r--;)""!==i[r]&&((t=/([^=]*)=(.*)/.exec(i[r]).slice(1))[0]=t[0].replace(/^\s+|\s+$/g,""),t[1]=t[1].replace(/^\s+|\s+$/g,""),t[1]=t[1].replace(/^['"](.*)['"]$/g,"$1"),n[t[0]]=t[1]);return n},S=function(e){function t(){var t;return (t=e.call(this)||this).customParsers=[],t.tagMappers=[],t}s(t,e);var i=t.prototype;return i.push=function(e){var t,i,n=this;0!==(e=e.trim()).length&&("#"===e[0]?this.tagMappers.reduce((function(t,i){var n=i(e);return n===e?t:t.concat([n])}),[e]).forEach((function(e){for(var r=0;r<n.customParsers.length;r++)if(n.customParsers[r].call(n,e))return;if(0===e.indexOf("#EXT"))if(e=e.replace("\r",""),t=/^#EXTM3U/.exec(e))n.trigger("data",{type:"tag",tagType:"m3u"});else {if(t=/^#EXTINF:?([0-9\.]*)?,?(.*)?$/.exec(e))return i={type:"tag",tagType:"inf"},t[1]&&(i.duration=parseFloat(t[1])),t[2]&&(i.title=t[2]),void n.trigger("data",i);if(t=/^#EXT-X-TARGETDURATION:?([0-9.]*)?/.exec(e))return i={type:"tag",tagType:"targetduration"},t[1]&&(i.duration=parseInt(t[1],10)),void n.trigger("data",i);if(t=/^#ZEN-TOTAL-DURATION:?([0-9.]*)?/.exec(e))return i={type:"tag",tagType:"totalduration"},t[1]&&(i.duration=parseInt(t[1],10)),void n.trigger("data",i);if(t=/^#EXT-X-VERSION:?([0-9.]*)?/.exec(e))return i={type:"tag",tagType:"version"},t[1]&&(i.version=parseInt(t[1],10)),void n.trigger("data",i);if(t=/^#EXT-X-MEDIA-SEQUENCE:?(\-?[0-9.]*)?/.exec(e))return i={type:"tag",tagType:"media-sequence"},t[1]&&(i.number=parseInt(t[1],10)),void n.trigger("data",i);if(t=/^#EXT-X-DISCONTINUITY-SEQUENCE:?(\-?[0-9.]*)?/.exec(e))return i={type:"tag",tagType:"discontinuity-sequence"},t[1]&&(i.number=parseInt(t[1],10)),void n.trigger("data",i);if(t=/^#EXT-X-PLAYLIST-TYPE:?(.*)?$/.exec(e))return i={type:"tag",tagType:"playlist-type"},t[1]&&(i.playlistType=t[1]),void n.trigger("data",i);if(t=/^#EXT-X-BYTERANGE:?([0-9.]*)?@?([0-9.]*)?/.exec(e))return i={type:"tag",tagType:"byterange"},t[1]&&(i.length=parseInt(t[1],10)),t[2]&&(i.offset=parseInt(t[2],10)),void n.trigger("data",i);if(t=/^#EXT-X-ALLOW-CACHE:?(YES|NO)?/.exec(e))return i={type:"tag",tagType:"allow-cache"},t[1]&&(i.allowed=!/NO/.test(t[1])),void n.trigger("data",i);if(t=/^#EXT-X-MAP:?(.*)$/.exec(e)){if(i={type:"tag",tagType:"map"},t[1]){var a=T(t[1]);if(a.URI&&(i.uri=a.URI),a.BYTERANGE){var s=a.BYTERANGE.split("@"),o=s[0],u=s[1];i.byterange={},o&&(i.byterange.length=parseInt(o,10)),u&&(i.byterange.offset=parseInt(u,10));}}n.trigger("data",i);}else if(t=/^#EXT-X-STREAM-INF:?(.*)$/.exec(e)){if(i={type:"tag",tagType:"stream-inf"},t[1]){if(i.attributes=T(t[1]),i.attributes.RESOLUTION){var d=i.attributes.RESOLUTION.split("x"),l={};d[0]&&(l.width=parseInt(d[0],10)),d[1]&&(l.height=parseInt(d[1],10)),i.attributes.RESOLUTION=l;}i.attributes.BANDWIDTH&&(i.attributes.BANDWIDTH=parseInt(i.attributes.BANDWIDTH,10)),i.attributes["PROGRAM-ID"]&&(i.attributes["PROGRAM-ID"]=parseInt(i.attributes["PROGRAM-ID"],10));}n.trigger("data",i);}else {if(t=/^#EXT-X-MEDIA:?(.*)$/.exec(e))return i={type:"tag",tagType:"media"},t[1]&&(i.attributes=T(t[1])),void n.trigger("data",i);if(t=/^#EXT-X-ENDLIST/.exec(e))n.trigger("data",{type:"tag",tagType:"endlist"});else if(t=/^#EXT-X-DISCONTINUITY/.exec(e))n.trigger("data",{type:"tag",tagType:"discontinuity"});else {if(t=/^#EXT-X-PROGRAM-DATE-TIME:?(.*)$/.exec(e))return i={type:"tag",tagType:"program-date-time"},t[1]&&(i.dateTimeString=t[1],i.dateTimeObject=new Date(t[1])),void n.trigger("data",i);if(t=/^#EXT-X-KEY:?(.*)$/.exec(e))return i={type:"tag",tagType:"key"},t[1]&&(i.attributes=T(t[1]),i.attributes.IV&&("0x"===i.attributes.IV.substring(0,2).toLowerCase()&&(i.attributes.IV=i.attributes.IV.substring(2)),i.attributes.IV=i.attributes.IV.match(/.{8}/g),i.attributes.IV[0]=parseInt(i.attributes.IV[0],16),i.attributes.IV[1]=parseInt(i.attributes.IV[1],16),i.attributes.IV[2]=parseInt(i.attributes.IV[2],16),i.attributes.IV[3]=parseInt(i.attributes.IV[3],16),i.attributes.IV=new Uint32Array(i.attributes.IV))),void n.trigger("data",i);if(t=/^#EXT-X-START:?(.*)$/.exec(e))return i={type:"tag",tagType:"start"},t[1]&&(i.attributes=T(t[1]),i.attributes["TIME-OFFSET"]=parseFloat(i.attributes["TIME-OFFSET"]),i.attributes.PRECISE=/YES/.test(i.attributes.PRECISE)),void n.trigger("data",i);if(t=/^#EXT-X-CUE-OUT-CONT:?(.*)?$/.exec(e))return i={type:"tag",tagType:"cue-out-cont"},t[1]?i.data=t[1]:i.data="",void n.trigger("data",i);if(t=/^#EXT-X-CUE-OUT:?(.*)?$/.exec(e))return i={type:"tag",tagType:"cue-out"},t[1]?i.data=t[1]:i.data="",void n.trigger("data",i);if(t=/^#EXT-X-CUE-IN:?(.*)?$/.exec(e))return i={type:"tag",tagType:"cue-in"},t[1]?i.data=t[1]:i.data="",void n.trigger("data",i);n.trigger("data",{type:"tag",data:e.slice(4)});}}}else n.trigger("data",{type:"comment",text:e.slice(1)});})):this.trigger("data",{type:"uri",uri:e}));},i.addParser=function(e){var t=this,i=e.expression,n=e.customType,r=e.dataParser,a=e.segment;"function"!=typeof r&&(r=function(e){return e}),this.customParsers.push((function(e){if(i.exec(e))return t.trigger("data",{type:"custom",data:r(e),customType:n,segment:a}),!0}));},i.addTagMapper=function(e){var t=e.expression,i=e.map;this.tagMappers.push((function(e){return t.test(e)?i(e):e}));},t}(p),I=function(e){function t(){var t;(t=e.call(this)||this).lineStream=new b,t.parseStream=new S,t.lineStream.pipe(t.parseStream);var i,n,r=a(t),s=[],o={},u=function(){},d={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},l=0;t.manifest={allowCache:!0,discontinuityStarts:[],segments:[]};var h=0;return t.parseStream.on("data",(function(e){var t,a;({tag:function(){({"allow-cache":function(){this.manifest.allowCache=e.allowed,"allowed"in e||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0);},byterange:function(){var t={};"length"in e&&(o.byterange=t,t.length=e.length,"offset"in e||(e.offset=h)),"offset"in e&&(o.byterange=t,t.offset=e.offset),h=t.offset+t.length;},endlist:function(){this.manifest.endList=!0;},inf:function(){"mediaSequence"in this.manifest||(this.manifest.mediaSequence=0,this.trigger("info",{message:"defaulting media sequence to zero"})),"discontinuitySequence"in this.manifest||(this.manifest.discontinuitySequence=0,this.trigger("info",{message:"defaulting discontinuity sequence to zero"})),e.duration>0&&(o.duration=e.duration),0===e.duration&&(o.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=s;},key:function(){if(e.attributes)if("NONE"!==e.attributes.METHOD)if(e.attributes.URI){if("urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"===e.attributes.KEYFORMAT)return -1===["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"].indexOf(e.attributes.METHOD)?void this.trigger("warn",{message:"invalid key method provided for Widevine"}):("SAMPLE-AES-CENC"===e.attributes.METHOD&&this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"}),"data:text/plain;base64,"!==e.attributes.URI.substring(0,23)?void this.trigger("warn",{message:"invalid key URI provided for Widevine"}):e.attributes.KEYID&&"0x"===e.attributes.KEYID.substring(0,2)?void(this.manifest.contentProtection={"com.widevine.alpha":{attributes:{schemeIdUri:e.attributes.KEYFORMAT,keyId:e.attributes.KEYID.substring(2)},pssh:v(e.attributes.URI.split(",")[1])}}):void this.trigger("warn",{message:"invalid key ID provided for Widevine"}));e.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),n={method:e.attributes.METHOD||"AES-128",uri:e.attributes.URI},void 0!==e.attributes.IV&&(n.iv=e.attributes.IV);}else this.trigger("warn",{message:"ignoring key declaration without URI"});else n=null;else this.trigger("warn",{message:"ignoring key declaration without attribute list"});},"media-sequence":function(){isFinite(e.number)?this.manifest.mediaSequence=e.number:this.trigger("warn",{message:"ignoring invalid media sequence: "+e.number});},"discontinuity-sequence":function(){isFinite(e.number)?(this.manifest.discontinuitySequence=e.number,l=e.number):this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+e.number});},"playlist-type":function(){/VOD|EVENT/.test(e.playlistType)?this.manifest.playlistType=e.playlistType:this.trigger("warn",{message:"ignoring unknown playlist type: "+e.playlist});},map:function(){i={},e.uri&&(i.uri=e.uri),e.byterange&&(i.byterange=e.byterange);},"stream-inf":function(){this.manifest.playlists=s,this.manifest.mediaGroups=this.manifest.mediaGroups||d,e.attributes?(o.attributes||(o.attributes={}),g(o.attributes,e.attributes)):this.trigger("warn",{message:"ignoring empty stream-inf attributes"});},media:function(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||d,e.attributes&&e.attributes.TYPE&&e.attributes["GROUP-ID"]&&e.attributes.NAME){var i=this.manifest.mediaGroups[e.attributes.TYPE];i[e.attributes["GROUP-ID"]]=i[e.attributes["GROUP-ID"]]||{},t=i[e.attributes["GROUP-ID"]],(a={default:/yes/i.test(e.attributes.DEFAULT)}).default?a.autoselect=!0:a.autoselect=/yes/i.test(e.attributes.AUTOSELECT),e.attributes.LANGUAGE&&(a.language=e.attributes.LANGUAGE),e.attributes.URI&&(a.uri=e.attributes.URI),e.attributes["INSTREAM-ID"]&&(a.instreamId=e.attributes["INSTREAM-ID"]),e.attributes.CHARACTERISTICS&&(a.characteristics=e.attributes.CHARACTERISTICS),e.attributes.FORCED&&(a.forced=/yes/i.test(e.attributes.FORCED)),t[e.attributes.NAME]=a;}else this.trigger("warn",{message:"ignoring incomplete or missing media group"});},discontinuity:function(){l+=1,o.discontinuity=!0,this.manifest.discontinuityStarts.push(s.length);},"program-date-time":function(){void 0===this.manifest.dateTimeString&&(this.manifest.dateTimeString=e.dateTimeString,this.manifest.dateTimeObject=e.dateTimeObject),o.dateTimeString=e.dateTimeString,o.dateTimeObject=e.dateTimeObject;},targetduration:function(){!isFinite(e.duration)||e.duration<0?this.trigger("warn",{message:"ignoring invalid target duration: "+e.duration}):this.manifest.targetDuration=e.duration;},totalduration:function(){!isFinite(e.duration)||e.duration<0?this.trigger("warn",{message:"ignoring invalid total duration: "+e.duration}):this.manifest.totalDuration=e.duration;},start:function(){e.attributes&&!isNaN(e.attributes["TIME-OFFSET"])?this.manifest.start={timeOffset:e.attributes["TIME-OFFSET"],precise:e.attributes.PRECISE}:this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"});},"cue-out":function(){o.cueOut=e.data;},"cue-out-cont":function(){o.cueOutCont=e.data;},"cue-in":function(){o.cueIn=e.data;}}[e.tagType]||u).call(r);},uri:function(){o.uri=e.uri,s.push(o),this.manifest.targetDuration&&!("duration"in o)&&(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),o.duration=this.manifest.targetDuration),n&&(o.key=n),o.timeline=l,i&&(o.map=i),o={};},comment:function(){},custom:function(){e.segment?(o.custom=o.custom||{},o.custom[e.customType]=e.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[e.customType]=e.data);}})[e.type].call(r);})),t}s(t,e);var i=t.prototype;return i.push=function(e){this.lineStream.push(e);},i.end=function(){this.lineStream.push("\n");},i.addParser=function(e){this.parseStream.addParser(e);},i.addTagMapper=function(e){this.parseStream.addTagMapper(e);},t}(p),A=n.log,L=function(e,t){return e+"-"+t},E=function(e){var t=e.manifestString,i=e.customTagParsers,n=void 0===i?[]:i,r=e.customTagMappers,a=void 0===r?[]:r,s=new I;return n.forEach((function(e){return s.addParser(e)})),a.forEach((function(e){return s.addTagMapper(e)})),s.push(t),s.end(),s.manifest},w=function(e,t){["AUDIO","SUBTITLES"].forEach((function(i){for(var n in e.mediaGroups[i])for(var r in e.mediaGroups[i][n]){var a=e.mediaGroups[i][n][r];t(a,i,n,r);}}));},k=function(e){var t=e.playlist,i=e.uri,n=e.id;t.id=n,i&&(t.uri=i),t.attributes=t.attributes||{};},O=function(e,t){e.uri=t;for(var i=0;i<e.playlists.length;i++)if(!e.playlists[i].uri){var n="placeholder-uri-"+i;e.playlists[i].uri=n;}w(e,(function(t,i,n,r){if(t.playlists&&t.playlists.length&&!t.playlists[0].uri){var a="placeholder-uri-"+i+"-"+n+"-"+r,s=L(0,a);t.playlists[0].uri=a,t.playlists[0].id=s,e.playlists[s]=t.playlists[0],e.playlists[a]=t.playlists[0];}})),function(e){for(var t=e.playlists.length;t--;){var i=e.playlists[t];k({playlist:i,id:L(t,i.uri)}),i.resolvedUri=f(e.uri,i.uri),e.playlists[i.id]=i,e.playlists[i.uri]=i,i.attributes.BANDWIDTH||A.warn("Invalid playlist STREAM-INF detected. Missing BANDWIDTH attribute.");}}(e),function(e){w(e,(function(t){t.uri&&(t.resolvedUri=f(e.uri,t.uri));}));}(e);},U=n.mergeOptions,C=n.EventTarget,P=function(e,t){e.resolvedUri||(e.resolvedUri=f(t,e.uri)),e.key&&!e.key.resolvedUri&&(e.key.resolvedUri=f(t,e.key.uri)),e.map&&!e.map.resolvedUri&&(e.map.resolvedUri=f(t,e.map.uri));},D=function(e,t){var i=U(e,{}),n=i.playlists[t.id];if(!n)return null;if(n.segments&&t.segments&&n.segments.length===t.segments.length&&n.endList===t.endList&&n.mediaSequence===t.mediaSequence)return null;var r=U(n,t);n.segments&&(r.segments=function(e,t,i){var n=t.slice();i=i||0;for(var r=Math.min(e.length,t.length+i),a=i;a<r;a++)n[a-i]=U(e[a],n[a-i]);return n}(n.segments,t.segments,t.mediaSequence-n.mediaSequence)),r.segments.forEach((function(e){P(e,r.resolvedUri);}));for(var a=0;a<i.playlists.length;a++)i.playlists[a].id===t.id&&(i.playlists[a]=r);return i.playlists[t.id]=r,i.playlists[t.uri]=r,i},x=function(e,t){var i=e.segments[e.segments.length-1];return t&&i&&i.duration?1e3*i.duration:500*(e.targetDuration||10)},R=function(e){function t(t,i,n){var r;if(void 0===n&&(n={}),r=e.call(this)||this,!t)throw new Error("A non-empty playlist URL or object is required");var a=n,s=a.withCredentials,o=void 0!==s&&s,u=a.handleManifestRedirects,d=void 0!==u&&u;r.src=t,r.vhs_=i,r.withCredentials=o,r.handleManifestRedirects=d;var l=i.options_;return r.customTagParsers=l&&l.customTagParsers||[],r.customTagMappers=l&&l.customTagMappers||[],r.state="HAVE_NOTHING",r.on("mediaupdatetimeout",(function(){"HAVE_METADATA"===r.state&&(r.state="HAVE_CURRENT_METADATA",r.request=r.vhs_.xhr({uri:f(r.master.uri,r.media().uri),withCredentials:r.withCredentials},(function(e,t){if(r.request)return e?r.playlistRequestError(r.request,r.media(),"HAVE_METADATA"):void r.haveMetadata({playlistString:r.request.responseText,url:r.media().uri,id:r.media().id})})));})),r}s(t,e);var n=t.prototype;return n.playlistRequestError=function(e,t,i){var n=t.uri,r=t.id;this.request=null,i&&(this.state=i),this.error={playlist:this.master.playlists[r],status:e.status,message:"HLS playlist request error at URL: "+n+".",responseText:e.responseText,code:e.status>=500?4:2},this.trigger("error");},n.haveMetadata=function(e){var t=this,n=e.playlistString,r=e.playlistObject,a=e.url,s=e.id;this.request=null,this.state="HAVE_METADATA";var o=r||E({manifestString:n,customTagParsers:this.customTagParsers,customTagMappers:this.customTagMappers});k({playlist:o,uri:a,id:s});var u=D(this.master,o);this.targetDuration=o.targetDuration,u?(this.master=u,this.media_=this.master.playlists[s]):this.trigger("playlistunchanged"),this.media().endList||(i.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=i.setTimeout((function(){t.trigger("mediaupdatetimeout");}),x(this.media(),!!u))),this.trigger("loadedplaylist");},n.dispose=function(){this.trigger("dispose"),this.stopRequest(),i.clearTimeout(this.mediaUpdateTimeout),i.clearTimeout(this.finalRenditionTimeout),this.off();},n.stopRequest=function(){if(this.request){var e=this.request;this.request=null,e.onreadystatechange=null,e.abort();}},n.media=function(e,t){var n=this;if(!e)return this.media_;if("HAVE_NOTHING"===this.state)throw new Error("Cannot switch media playlist from "+this.state);if("string"==typeof e){if(!this.master.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.master.playlists[e];}if(i.clearTimeout(this.finalRenditionTimeout),t){var r=e.targetDuration/2*1e3||5e3;this.finalRenditionTimeout=i.setTimeout(this.media.bind(this,e,!1),r);}else {var a=this.state,s=!this.media_||e.id!==this.media_.id;if(this.master.playlists[e.id].endList||e.endList&&e.segments.length)return this.request&&(this.request.onreadystatechange=null,this.request.abort(),this.request=null),this.state="HAVE_METADATA",this.media_=e,void(s&&(this.trigger("mediachanging"),"HAVE_MASTER"===a?this.trigger("loadedmetadata"):this.trigger("mediachange")));if(s){if(this.state="SWITCHING_MEDIA",this.request){if(e.resolvedUri===this.request.url)return;this.request.onreadystatechange=null,this.request.abort(),this.request=null;}this.media_&&this.trigger("mediachanging"),this.request=this.vhs_.xhr({uri:e.resolvedUri,withCredentials:this.withCredentials},(function(t,i){if(n.request){if(e.resolvedUri=m(n.handleManifestRedirects,e.resolvedUri,i),t)return n.playlistRequestError(n.request,e,a);n.haveMetadata({playlistString:i.responseText,url:e.uri,id:e.id}),"HAVE_MASTER"===a?n.trigger("loadedmetadata"):n.trigger("mediachange");}}));}}},n.pause=function(){this.stopRequest(),i.clearTimeout(this.mediaUpdateTimeout),"HAVE_NOTHING"===this.state&&(this.started=!1),"SWITCHING_MEDIA"===this.state?this.media_?this.state="HAVE_METADATA":this.state="HAVE_MASTER":"HAVE_CURRENT_METADATA"===this.state&&(this.state="HAVE_METADATA");},n.load=function(e){var t=this;i.clearTimeout(this.mediaUpdateTimeout);var n=this.media();if(e){var r=n?n.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=i.setTimeout((function(){return t.load()}),r);}else this.started?n&&!n.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist"):this.start();},n.start=function(){var e=this;if(this.started=!0,"object"==typeof this.src)return this.src.uri||(this.src.uri=i.location.href),this.src.resolvedUri=this.src.uri,void setTimeout((function(){e.setupInitialPlaylist(e.src);}),0);this.request=this.vhs_.xhr({uri:this.src,withCredentials:this.withCredentials},(function(t,i){if(e.request){if(e.request=null,t)return e.error={status:i.status,message:"HLS playlist request error at URL: "+e.src+".",responseText:i.responseText,code:2},"HAVE_NOTHING"===e.state&&(e.started=!1),e.trigger("error");e.src=m(e.handleManifestRedirects,e.src,i);var n=E({manifestString:i.responseText,customTagParsers:e.customTagParsers,customTagMappers:e.customTagMappers});e.setupInitialPlaylist(n);}}));},n.srcUri=function(){return "string"==typeof this.src?this.src:this.src.uri},n.setupInitialPlaylist=function(e){if(this.state="HAVE_MASTER",e.playlists)return this.master=e,O(this.master,this.srcUri()),e.playlists.forEach((function(e){e.segments&&e.segments.forEach((function(t){P(t,e.resolvedUri);}));})),this.trigger("loadedplaylist"),void(this.request||this.media(this.master.playlists[0]));var t=this.srcUri()||i.location.href;this.master=function(e,t){var n=L(0,t),r={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:i.location.href,resolvedUri:i.location.href,playlists:[{uri:t,id:n,resolvedUri:t,attributes:{}}]};return r.playlists[n]=r.playlists[0],r.playlists[t]=r.playlists[0],r}(0,t),this.haveMetadata({playlistObject:e,url:t,id:this.master.playlists[0].id}),this.trigger("loadedmetadata");},t}(C),M=function(e,t){var i,r=[];if(e&&e.length)for(i=0;i<e.length;i++)t(e.start(i),e.end(i))&&r.push([e.start(i),e.end(i)]);return n.createTimeRanges(r)},B=function(e,t){return M(e,(function(e,i){return e-.1<=t&&i+.1>=t}))},F=function(e,t){return M(e,(function(e){return e-1/30>=t}))},N=function(e){var t=[];if(!e||!e.length)return "";for(var i=0;i<e.length;i++)t.push(e.start(i)+" => "+e.end(i));return t.join(", ")},q=function(e){for(var t=[],i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t},V=n.createTimeRange,W=function(e,t,i){if(void 0===t&&(t=e.mediaSequence+e.segments.length),t<e.mediaSequence)return 0;var n=function(e,t){var i=0,n=t-e.mediaSequence,r=e.segments[n];if(r){if(void 0!==r.start)return {result:r.start,precise:!0};if(void 0!==r.end)return {result:r.end-r.duration,precise:!0}}for(;n--;){if(void 0!==(r=e.segments[n]).end)return {result:i+r.end,precise:!0};if(i+=r.duration,void 0!==r.start)return {result:i+r.start,precise:!0}}return {result:i,precise:!1}}(e,t);if(n.precise)return n.result;var r=function(e,t){for(var i,n=0,r=t-e.mediaSequence;r<e.segments.length;r++){if(void 0!==(i=e.segments[r]).start)return {result:i.start-n,precise:!0};if(n+=i.duration,void 0!==i.end)return {result:i.end-n,precise:!0}}return {result:-1,precise:!1}}(e,t);return r.precise?r.result:n.result+i},H=function(e,t,n){if(!e)return 0;if("number"!=typeof n&&(n=0),void 0===t){if(e.totalDuration)return e.totalDuration;if(!e.endList)return i.Infinity}return W(e,t,n)},G=function(e,t,i){var n=0;if(t>i){var r=[i,t];t=r[0],i=r[1];}if(t<0){for(var a=t;a<Math.min(0,i);a++)n+=e.targetDuration;t=0;}for(var s=t;s<i;s++)n+=e.segments[s].duration;return n},j=function(e,t){if(!e.segments.length)return 0;var i=e.segments.length,n=e.segments[i-1].duration||e.targetDuration,r="number"==typeof t?t:n+2*e.targetDuration;if(0===r)return i;for(var a=0;i--&&!((a+=e.segments[i].duration)>=r););return Math.max(0,i)},z=function(e,t,i,n){if(!e||!e.segments)return null;if(e.endList)return H(e);if(null===t)return null;t=t||0;var r=i?j(e,n):e.segments.length;return W(e,e.mediaSequence+r,t)},X=function(e){return e.excludeUntil&&e.excludeUntil>Date.now()},Q=function(e){return e.excludeUntil&&e.excludeUntil===1/0},Y=function(e){var t=X(e);return !e.disabled&&!t},K=function(e,t){return t.attributes&&t.attributes[e]},$=function(e,t){if(1===e.playlists.length)return !0;var i=t.attributes.BANDWIDTH||Number.MAX_VALUE;return 0===e.playlists.filter((function(e){return !!Y(e)&&(e.attributes.BANDWIDTH||0)<i})).length},J={duration:H,seekable:function(e,t,i){var n=t||0,r=z(e,t,!0,i);return null===r?V():V(n,r)},safeLiveIndex:j,getMediaInfoForTime:function(e,t,i,n){var r,a=e.segments.length,s=t-n;if(s<0){if(i>0)for(r=i-1;r>=0;r--)if((s+=e.segments[r].duration+1/30)>0)return {mediaIndex:r,startTime:n-G(e,i,r)};return {mediaIndex:0,startTime:t}}if(i<0){for(r=i;r<0;r++)if((s-=e.targetDuration)<0)return {mediaIndex:0,startTime:t};i=0;}for(r=i;r<a;r++)if((s-=e.segments[r].duration+1/30)<0)return {mediaIndex:r,startTime:n+G(e,i,r)};return {mediaIndex:a-1,startTime:t}},isEnabled:Y,isDisabled:function(e){return e.disabled},isBlacklisted:X,isIncompatible:Q,playlistEnd:z,isAes:function(e){for(var t=0;t<e.segments.length;t++)if(e.segments[t].key)return !0;return !1},hasAttribute:K,estimateSegmentRequestTime:function(e,t,i,n){return void 0===n&&(n=0),K("BANDWIDTH",i)?(e*i.attributes.BANDWIDTH-8*n)/t:NaN},isLowestEnabledRendition:$},Z=n.xhr,ee=n.mergeOptions,te=function(e,t,i,n){var r="arraybuffer"===e.responseType?e.response:e.responseText;!t&&r&&(e.responseTime=Date.now(),e.roundTripTime=e.responseTime-e.requestTime,e.bytesReceived=r.byteLength||r.length,e.bandwidth||(e.bandwidth=Math.floor(e.bytesReceived/e.roundTripTime*8*1e3))),i.headers&&(e.responseHeaders=i.headers),t&&"ETIMEDOUT"===t.code&&(e.timedout=!0),t||e.aborted||200===i.statusCode||206===i.statusCode||0===i.statusCode||(t=new Error("XHR Failed with a response of: "+(e&&(r||e.responseText)))),n(t,e);},ie=function(){return function e(t,i){t=ee({timeout:45e3},t);var r=e.beforeRequest||n.Vhs.xhr.beforeRequest;if(r&&"function"==typeof r){var a=r(t);a&&(t=a);}var s=Z(t,(function(e,t){return te(s,e,t,i)})),o=s.abort;return s.abort=function(){return s.aborted=!0,o.apply(s,arguments)},s.uri=t.uri,s.requestTime=Date.now(),s}},ne=function(e){var t,i,n={};return e.byterange&&(n.Range=(i=(t=e.byterange).offset+t.length-1,"bytes="+t.offset+"-"+i)),n},re=u((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var i=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i,n=/^application\/dash\+xml/i;t.simpleTypeFromSourceType=function(e){return i.test(e)?"hls":n.test(e)?"dash":"application/vnd.videojs.vhs+json"===e?"vhs-json":null};}));o(re);var ae=re.simpleTypeFromSourceType,se=function(e,t){return e.start(t)+"-"+e.end(t)},oe=function(e,t){var i=e.toString(16);return "00".substring(0,2-i.length)+i+(t%2?" ":"")},ue=function(e){return e>=32&&e<126?String.fromCharCode(e):"."},de=function(e){var t={};return Object.keys(e).forEach((function(i){var n=e[i];ArrayBuffer.isView(n)?t[i]={bytes:n.buffer,byteOffset:n.byteOffset,byteLength:n.byteLength}:t[i]=n;})),t},le=function(e){var t=e.byterange||{length:1/0,offset:0};return [t.length,t.offset,e.resolvedUri].join(",")},he=function(e){return e.resolvedUri},ce=function(e){for(var t=Array.prototype.slice.call(e),i="",n=0;n<t.length/16;n++)i+=t.slice(16*n,16*n+16).map(oe).join("")+" "+t.slice(16*n,16*n+16).map(ue).join("")+"\n";return i},fe=Object.freeze({__proto__:null,createTransferableMessage:de,initSegmentId:le,segmentKeyId:he,hexDump:ce,tagDump:function(e){var t=e.bytes;return ce(t)},textRanges:function(e){var t,i="";for(t=0;t<e.length;t++)i+=se(e,t)+" ";return i}}),me=function(e){return !!e&&"object"==typeof e},pe=function e(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];return i.reduce((function(t,i){return Object.keys(i).forEach((function(n){Array.isArray(t[n])&&Array.isArray(i[n])?t[n]=t[n].concat(i[n]):me(t[n])&&me(i[n])?t[n]=e(t[n],i[n]):t[n]=i[n];})),t}),{})},ge=function(e){return e.reduce((function(e,t){return e.concat(t)}),[])},ye=function(e){if(!e.length)return [];for(var t=[],i=0;i<e.length;i++)t.push(e[i]);return t},_e=function(e){var t=e.baseUrl,i=void 0===t?"":t,n=e.source,r=void 0===n?"":n,a=e.range,s=void 0===a?"":a,o=e.indexRange,u=void 0===o?"":o,d={uri:r,resolvedUri:c(i||"",r)};if(s||u){var l=(s||u).split("-"),h=parseInt(l[0],10),f=parseInt(l[1],10);d.byterange={length:f-h+1,offset:h};}return d},ve={static:function(e){var t=e.duration,i=e.timescale,n=void 0===i?1:i,r=e.sourceDuration;return {start:0,end:Math.ceil(r/(t/n))}},dynamic:function(e){var t=e.NOW,i=e.clientOffset,n=e.availabilityStartTime,r=e.timescale,a=void 0===r?1:r,s=e.duration,o=e.start,u=void 0===o?0:o,d=e.minimumUpdatePeriod,l=void 0===d?0:d,h=e.timeShiftBufferDepth,c=void 0===h?1/0:h,f=(t+i)/1e3,m=n+u,p=f+l-m,g=Math.ceil(p*a/s),y=Math.floor((f-m-c)*a/s),_=Math.floor((f-m)*a/s);return {start:Math.max(0,y),end:Math.min(g,_)}}},be=function(e){var t=e.type,i=void 0===t?"static":t,n=e.duration,r=e.timescale,a=void 0===r?1:r,s=e.sourceDuration,o=ve[i](e),u=function(e,t){for(var i=[],n=e;n<t;n++)i.push(n);return i}(o.start,o.end).map(function(e){return function(t,i){var n=e.duration,r=e.timescale,a=void 0===r?1:r,s=e.periodIndex,o=e.startNumber;return {number:(void 0===o?1:o)+t,duration:n/a,timeline:s,time:i*n}}}(e));if("static"===i){var d=u.length-1;u[d].duration=s-n/a*d;}return u},Te=function(e){var t=e.baseUrl,i=e.initialization,n=void 0===i?{}:i,r=e.sourceDuration,a=e.indexRange,s=void 0===a?"":a,o=e.duration;if(!t)throw new Error("NO_BASE_URL");var u=_e({baseUrl:t,source:n.sourceURL,range:n.range}),d=_e({baseUrl:t,source:t,indexRange:s});if(d.map=u,o){var l=be(e);l.length&&(d.duration=l[0].duration,d.timeline=l[0].timeline);}else r&&(d.duration=r,d.timeline=0);return d.number=0,[d]},Se=function(e,t,i){for(var n=e.sidx.map?e.sidx.map:null,r=e.sidx.duration,a=e.timeline||0,s=e.sidx.byterange,o=s.offset+s.length,u=t.timescale,d=t.references.filter((function(e){return 1!==e.referenceType})),l=[],h=o+t.firstOffset,c=0;c<d.length;c++){var f=t.references[c],m=f.referencedSize,p=f.subsegmentDuration,g=Te({baseUrl:i,timescale:u,timeline:a,periodIndex:a,duration:p,sourceDuration:r,indexRange:h+"-"+(h+m-1)})[0];n&&(g.map=n),l.push(g),h+=m;}return e.segments=l,e},Ie=function(e){var t;return (t=e.reduce((function(e,t){var i,n=t.attributes.id+(t.attributes.lang||"");return e[n]?(t.segments[0]&&(t.segments[0].discontinuity=!0),(i=e[n].segments).push.apply(i,t.segments),t.attributes.contentProtection&&(e[n].attributes.contentProtection=t.attributes.contentProtection)):e[n]=t,e}),{}),Object.keys(t).map((function(e){return t[e]}))).map((function(e){var t;return e.discontinuityStarts=(t=e.segments,t.reduce((function(e,t,i){return t.discontinuity&&e.push(i),e}),[])),e}))},Ae=function(e,t){if(void 0===t&&(t={}),!Object.keys(t).length)return e;for(var i in e){var n=e[i];if(n.sidx){var r=n.sidx.uri+"-"+(o=(s=n.sidx.byterange).offset+s.length-1,s.offset+"-"+o),a=t[r]&&t[r].sidx;n.sidx&&a&&Se(n,a,n.sidx.resolvedUri);}}var s,o;return e},Le=function(e){var t,i=e.attributes,n=e.segments,r=e.sidx,a={attributes:(t={NAME:i.id,BANDWIDTH:i.bandwidth,CODECS:i.codecs},t["PROGRAM-ID"]=1,t),uri:"",endList:"static"===(i.type||"static"),timeline:i.periodIndex,resolvedUri:"",targetDuration:i.duration,segments:n,mediaSequence:n.length?n[0].number:1};return i.contentProtection&&(a.contentProtection=i.contentProtection),r&&(a.sidx=r),a},Ee=function(e){var t,i=e.attributes,n=e.segments;void 0===n&&(n=[{uri:i.baseUrl,timeline:i.periodIndex,resolvedUri:i.baseUrl||"",duration:i.sourceDuration,number:0}],i.duration=i.sourceDuration);var r=((t={NAME:i.id,BANDWIDTH:i.bandwidth})["PROGRAM-ID"]=1,t);return i.codecs&&(r.CODECS=i.codecs),{attributes:r,uri:"",endList:"static"===(i.type||"static"),timeline:i.periodIndex,resolvedUri:i.baseUrl||"",targetDuration:i.duration,segments:n,mediaSequence:n.length?n[0].number:1}},we=function(e){var t,i=e.attributes,n=e.segments,r=e.sidx,a={attributes:(t={NAME:i.id,AUDIO:"audio",SUBTITLES:"subs",RESOLUTION:{width:i.width,height:i.height},CODECS:i.codecs,BANDWIDTH:i.bandwidth},t["PROGRAM-ID"]=1,t),uri:"",endList:"static"===(i.type||"static"),timeline:i.periodIndex,resolvedUri:"",targetDuration:i.duration,segments:n,mediaSequence:n.length?n[0].number:1};return i.contentProtection&&(a.contentProtection=i.contentProtection),r&&(a.sidx=r),a},ke=function(e,t,i){var n=e.NOW,r=e.clientOffset,a=e.availabilityStartTime,s=e.timescale,o=void 0===s?1:s,u=e.start,d=void 0===u?0:u,l=e.minimumUpdatePeriod,h=(n+r)/1e3+(void 0===l?0:l)-(a+d);return Math.ceil((h*o-t)/i)},Oe=function(e,t){for(var i=e.type,n=void 0===i?"static":i,r=e.minimumUpdatePeriod,a=void 0===r?0:r,s=e.media,o=void 0===s?"":s,u=e.sourceDuration,d=e.timescale,l=void 0===d?1:d,h=e.startNumber,c=void 0===h?1:h,f=e.periodIndex,m=[],p=-1,g=0;g<t.length;g++){var y=t[g],_=y.d,v=y.r||0,b=y.t||0;p<0&&(p=b),b&&b>p&&(p=b);var T=void 0;if(v<0){var S=g+1;T=S===t.length?"dynamic"===n&&a>0&&o.indexOf("$Number$")>0?ke(e,p,_):(u*l-p)/_:(t[S].t-p)/_;}else T=v+1;for(var I=c+m.length+T,A=c+m.length;A<I;)m.push({number:A,duration:_/l,time:p,timeline:f}),p+=_,A++;}return m},Ue=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,Ce=function(e,t){return e.replace(Ue,function(e){return function(t,i,n,r){if("$$"===t)return "$";if(void 0===e[i])return t;var a=""+e[i];return "RepresentationID"===i?a:(r=n?parseInt(r,10):1,a.length>=r?a:""+new Array(r-a.length+1).join("0")+a)}}(t))},Pe=function(e,t){var i={RepresentationID:e.id,Bandwidth:e.bandwidth||0},n=e.initialization,r=void 0===n?{sourceURL:"",range:""}:n,a=_e({baseUrl:e.baseUrl,source:Ce(r.sourceURL,i),range:r.range});return function(e,t){return e.duration||t?e.duration?be(e):Oe(e,t):[{number:e.startNumber||1,duration:e.sourceDuration,time:0,timeline:e.periodIndex}]}(e,t).map((function(t){i.Number=t.number,i.Time=t.time;var n=Ce(e.media||"",i);return {uri:n,timeline:t.timeline,duration:t.duration,resolvedUri:c(e.baseUrl||"",n),map:a,number:t.number}}))},De=function(e,t){var i=e.duration,n=e.segmentUrls,r=void 0===n?[]:n;if(!i&&!t||i&&t)throw new Error("SEGMENT_TIME_UNSPECIFIED");var a,s=r.map((function(t){return function(e,t){var i=e.baseUrl,n=e.initialization,r=void 0===n?{}:n,a=_e({baseUrl:i,source:r.sourceURL,range:r.range}),s=_e({baseUrl:i,source:t.media,range:t.mediaRange});return s.map=a,s}(e,t)}));return i&&(a=be(e)),t&&(a=Oe(e,t)),a.map((function(e,t){if(s[t]){var i=s[t];return i.timeline=e.timeline,i.duration=e.duration,i.number=e.number,i}})).filter((function(e){return e}))},xe=function(e){var t,i,n=e.attributes,r=e.segmentInfo;r.template?(i=Pe,t=pe(n,r.template)):r.base?(i=Te,t=pe(n,r.base)):r.list&&(i=De,t=pe(n,r.list));var a={attributes:n};if(!i)return a;var s=i(t,r.timeline);if(t.duration){var o=t,u=o.duration,d=o.timescale,l=void 0===d?1:d;t.duration=u/l;}else s.length?t.duration=s.reduce((function(e,t){return Math.max(e,Math.ceil(t.duration))}),0):t.duration=0;return a.attributes=t,a.segments=s,r.base&&t.indexRange&&(a.sidx=s[0],a.segments=[]),a},Re=function(e,t){return ye(e.childNodes).filter((function(e){return e.tagName===t}))},Me=function(e){return e.textContent.trim()},Be=function(e){var t=/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(e);if(!t)return 0;var i=t.slice(1),n=i[0],r=i[1],a=i[2],s=i[3],o=i[4],u=i[5];return 31536e3*parseFloat(n||0)+2592e3*parseFloat(r||0)+86400*parseFloat(a||0)+3600*parseFloat(s||0)+60*parseFloat(o||0)+parseFloat(u||0)},Fe={mediaPresentationDuration:function(e){return Be(e)},availabilityStartTime:function(e){return /^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(t=e)&&(t+="Z"),Date.parse(t)/1e3;var t;},minimumUpdatePeriod:function(e){return Be(e)},suggestedPresentationDelay:function(e){return Be(e)},type:function(e){return e},timeShiftBufferDepth:function(e){return Be(e)},start:function(e){return Be(e)},width:function(e){return parseInt(e,10)},height:function(e){return parseInt(e,10)},bandwidth:function(e){return parseInt(e,10)},startNumber:function(e){return parseInt(e,10)},timescale:function(e){return parseInt(e,10)},duration:function(e){var t=parseInt(e,10);return isNaN(t)?Be(e):t},d:function(e){return parseInt(e,10)},t:function(e){return parseInt(e,10)},r:function(e){return parseInt(e,10)},DEFAULT:function(e){return e}},Ne=function(e){return e&&e.attributes?ye(e.attributes).reduce((function(e,t){var i=Fe[t.name]||Fe.DEFAULT;return e[t.name]=i(t.value),e}),{}):{}},qe={"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"},Ve=function(e,t){return t.length?ge(e.map((function(e){return t.map((function(t){return c(e,Me(t))}))}))):e},We=function(e){var t=Re(e,"SegmentTemplate")[0],i=Re(e,"SegmentList")[0],n=i&&Re(i,"SegmentURL").map((function(e){return pe({tag:"SegmentURL"},Ne(e))})),r=Re(e,"SegmentBase")[0],a=i||t,s=a&&Re(a,"SegmentTimeline")[0],o=i||r||t,u=o&&Re(o,"Initialization")[0],d=t&&Ne(t);d&&u?d.initialization=u&&Ne(u):d&&d.initialization&&(d.initialization={sourceURL:d.initialization});var l={template:d,timeline:s&&Re(s,"S").map((function(e){return Ne(e)})),list:i&&pe(Ne(i),{segmentUrls:n,initialization:Ne(u)}),base:r&&pe(Ne(r),{initialization:Ne(u)})};return Object.keys(l).forEach((function(e){l[e]||delete l[e];})),l},He=function(e,t){return function(n,r){var a=Ve(t,Re(n,"BaseURL")),s=Ne(n),o=parseInt(s.id,10),u=i.isNaN(o)?r:o,d=pe(e,{periodIndex:u}),l=Re(n,"AdaptationSet"),h=We(n);return ge(l.map(function(e,t,i){return function(n){var r=Ne(n),a=Ve(t,Re(n,"BaseURL")),s=Re(n,"Role")[0],o={role:Ne(s)},u=pe(e,r,o),d=Re(n,"ContentProtection").reduce((function(e,t){var i=Ne(t),n=qe[i.schemeIdUri];if(n){e[n]={attributes:i};var r=Re(t,"cenc:pssh")[0];if(r){var a=Me(r),s=a&&v(a);e[n].pssh=s;}}return e}),{});Object.keys(d).length&&(u=pe(u,{contentProtection:d}));var l=We(n),h=Re(n,"Representation"),c=pe(i,l);return ge(h.map(function(e,t,i){return function(n){var r=Re(n,"BaseURL"),a=Ve(t,r),s=pe(e,Ne(n)),o=We(n);return a.map((function(e){return {segmentInfo:pe(i,o),attributes:pe(s,{baseUrl:e})}}))}}(u,a,c)))}}(d,a,h)))}},Ge=function(e){if(""===e)throw new Error("DASH_EMPTY_MANIFEST");var t=(new r.DOMParser).parseFromString(e,"application/xml"),i=t&&"MPD"===t.documentElement.tagName?t.documentElement:null;if(!i||i&&i.getElementsByTagName("parsererror").length>0)throw new Error("DASH_INVALID_XML");return i},je=function(e,t){void 0===t&&(t={});var i=function(e,t){void 0===t&&(t={});var i=t,n=i.manifestUri,r=void 0===n?"":n,a=i.NOW,s=void 0===a?Date.now():a,o=i.clientOffset,u=void 0===o?0:o,d=Re(e,"Period");if(!d.length)throw new Error("INVALID_NUMBER_OF_PERIOD");var l=Re(e,"Location"),h=Ne(e),c=Ve([r],Re(e,"BaseURL"));return h.sourceDuration=h.mediaPresentationDuration||0,h.NOW=s,h.clientOffset=u,l.length&&(h.locations=l.map(Me)),{locations:h.locations,representationInfo:ge(d.map(He(h,c)))}}(Ge(e),t);return function(e,t,i){var n;if(void 0===i&&(i={}),!e.length)return {};var r=e[0].attributes,a=r.sourceDuration,s=r.type,o=void 0===s?"static":s,u=r.suggestedPresentationDelay,d=r.minimumUpdatePeriod,l=Ie(e.filter((function(e){var t=e.attributes;return "video/mp4"===t.mimeType||"video"===t.contentType}))).map(we),h=Ie(e.filter((function(e){var t=e.attributes;return "audio/mp4"===t.mimeType||"audio"===t.contentType}))),c=e.filter((function(e){var t=e.attributes;return "text/vtt"===t.mimeType||"text"===t.contentType})),f={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:(n={AUDIO:{},VIDEO:{}},n["CLOSED-CAPTIONS"]={},n.SUBTITLES={},n),uri:"",duration:a,playlists:Ae(l,i)};return d>=0&&(f.minimumUpdatePeriod=1e3*d),t&&(f.locations=t),"dynamic"===o&&(f.suggestedPresentationDelay=u),h.length&&(f.mediaGroups.AUDIO.audio=function(e,t){var i;void 0===t&&(t={});var n=e.reduce((function(e,n){var r=n.attributes.role&&n.attributes.role.value||"",a=n.attributes.lang||"",s="main";if(a){var o=r?" ("+r+")":"";s=""+n.attributes.lang+o;}return e[s]&&e[s].playlists[0].attributes.BANDWIDTH>n.attributes.bandwidth||(e[s]={language:a,autoselect:!0,default:"main"===r,playlists:Ae([Le(n)],t),uri:""},void 0===i&&"main"===r&&((i=n).default=!0)),e}),{});return i||(n[Object.keys(n)[0]].default=!0),n}(h,i)),c.length&&(f.mediaGroups.SUBTITLES.subs=function(e,t){return void 0===t&&(t={}),e.reduce((function(e,i){var n=i.attributes.lang||"text";return e[n]||(e[n]={language:n,default:!1,autoselect:!1,playlists:Ae([Ee(i)],t),uri:""}),e}),{})}(c,i)),f}(i.representationInfo.map(xe),i.locations,t.sidxMapping)},ze=u((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var i=function(e){return e instanceof Uint8Array?e:new Uint8Array(e&&e.buffer||e,e&&e.byteOffset||0,e&&e.byteLength||0)},n=function(e){if(!e)return "";e=Array.prototype.slice.call(e);var t=String.fromCharCode.apply(null,i(e));try{return decodeURIComponent(escape(t))}catch(e){}return t},r=function(e,t){void 0===t&&(t=0);var n=(e=i(e))[t+6]<<21|e[t+7]<<14|e[t+8]<<7|e[t+9];return (16&e[t+5])>>4?n+20:n+10},a=function e(t,a){return void 0===a&&(a=0),(t=i(t)).length-a<10||"ID3"!==n(t.subarray(a,a+3))?a:e(t,a+=r(t,a))},s={aac:function(e){var t=a(e);return e.length>=t+2&&255==(255&e[t])&&224==(224&e[t+1])&&16==(22&e[t+1])},mp3:function(e){var t=a(e);return e.length>=t+2&&255==(255&e[t])&&224==(224&e[t+1])&&2==(6&e[t+1])},webm:function(e){return e.length>=4&&26==(255&e[0])&&69==(255&e[1])&&223==(255&e[2])&&163==(255&e[3])},mp4:function(e){return e.length>=8&&/^(f|s)typ$/.test(n(e.subarray(4,8)))&&!/^ftyp3g$/.test(n(e.subarray(4,10)))},"3gp":function(e){return e.length>=10&&/^ftyp3g$/.test(n(e.subarray(4,10)))},ts:function(e){if(e.length<189&&e.length>=1)return 71===e[0];for(var t=0;t+188<e.length&&t<188;){if(71===e[t]&&71===e[t+188])return !0;t+=1;}return !1},flac:function(e){return e.length>=4&&/^fLaC$/.test(n(e.subarray(0,4)))},ogg:function(e){return e.length>=4&&/^OggS$/.test(n(e.subarray(0,4)))}},o=Object.keys(s).filter((function(e){return "ts"!==e})).concat("ts");o.forEach((function(e){var t=s[e];s[e]=function(e){return t(i(e))};})),t.detectContainerForBytes=function(e){e=i(e);for(var t=0;t<o.length;t++){var n=o[t];if(s[n](e))return n}return ""},t.getId3Offset=a,t.id3Size=r,t.isLikely=s,t.isLikelyFmp4MediaSegment=function(e){e=i(e);for(var t=0;t<e.length;){var r=(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0;if("moof"===n(e.subarray(t+4,t+8)))return !0;0===r||r+t>e.length?t=e.length:t+=r;}return !1};}));o(ze);var Xe=ze.detectContainerForBytes,Qe=ze.getId3Offset,Ye=(ze.id3Size,ze.isLikely,ze.isLikelyFmp4MediaSegment),Ke=u((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var i=function(e){return e instanceof Uint8Array?e:new Uint8Array(e&&e.buffer||e,e&&e.byteOffset||0,e&&e.byteLength||0)};t.bytesToString=function(e){if(!e)return "";e=Array.prototype.slice.call(e);var t=String.fromCharCode.apply(null,i(e));try{return decodeURIComponent(escape(t))}catch(e){}return t},t.concatTypedArrays=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=t.reduce((function(e,t){return e+(t&&(t.byteLength||t.length)||0)}),0),a=new Uint8Array(r),s=0;return t.forEach((function(e){e=i(e),a.set(e,s),s+=e.byteLength;})),a},t.isTypedArray=function(e){return ArrayBuffer.isView(e)},t.stringToBytes=function(e,t){return void 0===t&&(t=!1),"string"!=typeof e&&e&&"function"==typeof e.toString&&(e=e.toString()),"string"!=typeof e?[]:(t||(e=unescape(encodeURIComponent(e))),e.split("").map((function(e){return 255&e.charCodeAt(0)})))},t.toUint8=i;}));o(Ke),Ke.bytesToString;var $e,Je=Ke.concatTypedArrays,Ze=(Ke.isTypedArray,Ke.stringToBytes),et=Ke.toUint8,tt=function(e,t){if(4===e.readyState)return t()},it=n.EventTarget,nt=n.mergeOptions,rt=function(e){var t=e.masterXml,i=e.srcUrl,n=e.clientOffset,r=e.sidxMapping,a=je(t,{manifestUri:i,clientOffset:n,sidxMapping:r});return O(a,i),a},at=function(e,t){for(var i=!0,n=nt(e,{duration:t.duration,minimumUpdatePeriod:t.minimumUpdatePeriod}),r=0;r<t.playlists.length;r++){var a=D(n,t.playlists[r]);a&&(n=a,i=!1);}return w(t,(function(e,t,r,a){if(e.playlists&&e.playlists.length){var s=e.playlists[0].id,o=D(n,e.playlists[0]);o&&((n=o).mediaGroups[t][r][a].playlists[0]=n.playlists[s],i=!1);}})),t.minimumUpdatePeriod!==e.minimumUpdatePeriod&&(i=!1),i?null:n},st=function(e){var t=e.byterange.offset+e.byterange.length-1;return e.uri+"-"+e.byterange.offset+"-"+t},ot=function(e,t){var i,n,r={};for(var a in e){var s=e[a].sidx;if(s){var o=st(s);if(!t[o])break;i=t[o].sidxInfo,n=s,(Boolean(!i.map&&!n.map)||Boolean(i.map&&n.map&&i.map.byterange.offset===n.map.byterange.offset&&i.map.byterange.length===n.map.byterange.length))&&i.uri===n.uri&&i.byterange.offset===n.byterange.offset&&i.byterange.length===n.byterange.length&&(r[o]=t[o]);}}return r},ut=function(e,t,i,r,a,s){var o={uri:m(a.handleManifestRedirects,t.resolvedUri),byterange:t.byterange,playlist:i},u=n.mergeOptions(o,{responseType:"arraybuffer",headers:ne(o)});return function(e,t,i){var n,r=[],a=!1,s=function(e,t,n,r){return t.abort(),a=!0,i(e,t,n,r)},o=function(e,t){if(!a){if(e)return s(e,t,"",r);var i=t.responseText.substring(r&&r.byteLength||0,t.responseText.length);if(r=Je(r,Ze(i,!0)),n=n||Qe(r),r.length<10||n&&r.length<n+2)return tt(t,(function(){return s(e,t,"",r)}));var o=Xe(r);return "ts"===o&&r.length<188||!o&&r.length<376?tt(t,(function(){return s(e,t,"",r)})):s(null,t,o,r)}},u=t({uri:e,beforeSend:function(e){e.overrideMimeType("text/plain; charset=x-user-defined"),e.addEventListener("progress",(function(t){return t.total,t.loaded,te(e,null,{statusCode:e.status},o)}));}},(function(e,t){return te(u,e,t,o)}));return u}(o.uri,r,(function(t,n,a,d){if(t)return s(t,n);if(!a||"mp4"!==a)return s({status:n.status,message:"Unsupported "+(a||"unknown")+" container type for sidx segment at URL: "+o.uri,response:"",playlist:i,internal:!0,blacklistDuration:1/0,code:2},n);var l=o.byterange,h=l.offset,c=l.length;if(d.length>=c+h)return s(t,{response:d.subarray(h,h+c),status:n.status,uri:n.uri});e.request=r(u,s);}))},dt=function(e){function t(t,i,n,r){var s;void 0===n&&(n={}),s=e.call(this)||this;var o=n,u=o.withCredentials,d=void 0!==u&&u,l=o.handleManifestRedirects,h=void 0!==l&&l;if(s.vhs_=i,s.withCredentials=d,s.handleManifestRedirects=h,!t)throw new Error("A non-empty playlist URL or object is required");return s.on("minimumUpdatePeriod",(function(){s.refreshXml_();})),s.on("mediaupdatetimeout",(function(){s.refreshMedia_(s.media().id);})),s.state="HAVE_NOTHING",s.loadedPlaylists_={},"string"==typeof t?(s.srcUrl=t,s.sidxMapping_={},a(s)):(s.setupChildLoader(r,t),s)}s(t,e);var n=t.prototype;return n.setupChildLoader=function(e,t){this.masterPlaylistLoader_=e,this.childPlaylist_=t;},n.dispose=function(){this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},i.clearTimeout(this.minimumUpdatePeriodTimeout_),i.clearTimeout(this.mediaRequest_),i.clearTimeout(this.mediaUpdateTimeout),this.off();},n.hasPendingRequest=function(){return this.request||this.mediaRequest_},n.stopRequest=function(){if(this.request){var e=this.request;this.request=null,e.onreadystatechange=null,e.abort();}},n.sidxRequestFinished_=function(e,t,i,n){var r=this;return function(a,s){if(r.request){if(r.request=null,a)return r.error="object"==typeof a?a:{status:s.status,message:"DASH playlist request error at URL: "+e.uri,response:s.response,code:2},i&&(r.state=i),void r.trigger("error");var o=function(e){var t,i=new DataView(e.buffer,e.byteOffset,e.byteLength),n={version:e[0],flags:new Uint8Array(e.subarray(1,4)),references:[],referenceId:i.getUint32(4),timescale:i.getUint32(8),earliestPresentationTime:i.getUint32(12),firstOffset:i.getUint32(16)},r=i.getUint16(22);for(t=24;r;t+=12,r--)n.references.push({referenceType:(128&e[t])>>>7,referencedSize:2147483647&i.getUint32(t),subsegmentDuration:i.getUint32(t+4),startsWithSap:!!(128&e[t+8]),sapType:(112&e[t+8])>>>4,sapDeltaTime:268435455&i.getUint32(t+8)});return n}(et(s.response).subarray(8));return n(t,o)}}},n.media=function(e){var t=this;if(!e)return this.media_;if("HAVE_NOTHING"===this.state)throw new Error("Cannot switch media playlist from "+this.state);var n=this.state;if("string"==typeof e){if(!this.master.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.master.playlists[e];}var r=!this.media_||e.id!==this.media_.id;if(r&&this.loadedPlaylists_[e.id]&&this.loadedPlaylists_[e.id].endList)return this.state="HAVE_METADATA",this.media_=e,void(r&&(this.trigger("mediachanging"),this.trigger("mediachange")));if(r)if(this.media_&&this.trigger("mediachanging"),e.sidx){var a,s;this.masterPlaylistLoader_?(a=this.masterPlaylistLoader_.master,s=this.masterPlaylistLoader_.sidxMapping_):(a=this.master,s=this.sidxMapping_);var o=st(e.sidx);s[o]={sidxInfo:e.sidx},this.request=ut(this,e.sidx,e,this.vhs_.xhr,{handleManifestRedirects:this.handleManifestRedirects},this.sidxRequestFinished_(e,a,n,(function(i,r){if(!i||!r)throw new Error("failed to request sidx");s[o].sidx=r,t.haveMetadata({startingState:n,playlist:i.playlists[e.id]});})));}else this.mediaRequest_=i.setTimeout(this.haveMetadata.bind(this,{startingState:n,playlist:e}),0);},n.haveMetadata=function(e){var t=e.startingState,i=e.playlist;this.state="HAVE_METADATA",this.loadedPlaylists_[i.id]=i,this.mediaRequest_=null,this.refreshMedia_(i.id),"HAVE_MASTER"===t?this.trigger("loadedmetadata"):this.trigger("mediachange");},n.pause=function(){this.stopRequest(),i.clearTimeout(this.mediaUpdateTimeout),i.clearTimeout(this.minimumUpdatePeriodTimeout_),"HAVE_NOTHING"===this.state&&(this.started=!1);},n.load=function(e){var t=this;i.clearTimeout(this.mediaUpdateTimeout),i.clearTimeout(this.minimumUpdatePeriodTimeout_);var n=this.media();if(e){var r=n?n.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=i.setTimeout((function(){return t.load()}),r);}else this.started?n&&!n.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist"):this.start();},n.start=function(){var e=this;this.started=!0,this.masterPlaylistLoader_?this.mediaRequest_=i.setTimeout(this.haveMaster_.bind(this),0):this.request=this.vhs_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},(function(t,i){if(e.request){if(e.request=null,t)return e.error={status:i.status,message:"DASH playlist request error at URL: "+e.srcUrl,responseText:i.responseText,code:2},"HAVE_NOTHING"===e.state&&(e.started=!1),e.trigger("error");e.masterXml_=i.responseText,i.responseHeaders&&i.responseHeaders.date?e.masterLoaded_=Date.parse(i.responseHeaders.date):e.masterLoaded_=Date.now(),e.srcUrl=m(e.handleManifestRedirects,e.srcUrl,i),e.syncClientServerClock_(e.onClientServerClockSync_.bind(e));}}));},n.syncClientServerClock_=function(e){var t,i=this,n=(t=this.masterXml_,function(e){var t=Re(e,"UTCTiming")[0];if(!t)return null;var i=Ne(t);switch(i.schemeIdUri){case"urn:mpeg:dash:utc:http-head:2014":case"urn:mpeg:dash:utc:http-head:2012":i.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":i.method="GET";break;case"urn:mpeg:dash:utc:direct:2014":case"urn:mpeg:dash:utc:direct:2012":i.method="DIRECT",i.value=Date.parse(i.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("UNSUPPORTED_UTC_TIMING_SCHEME")}return i}(Ge(t)));return null===n?(this.clientOffset_=this.masterLoaded_-Date.now(),e()):"DIRECT"===n.method?(this.clientOffset_=n.value-Date.now(),e()):void(this.request=this.vhs_.xhr({uri:f(this.srcUrl,n.value),method:n.method,withCredentials:this.withCredentials},(function(t,r){if(i.request){if(t)return i.clientOffset_=i.masterLoaded_-Date.now(),e();var a;a="HEAD"===n.method?r.responseHeaders&&r.responseHeaders.date?Date.parse(r.responseHeaders.date):i.masterLoaded_:Date.parse(r.responseText),i.clientOffset_=a-Date.now(),e();}})))},n.haveMaster_=function(){this.state="HAVE_MASTER",this.mediaRequest_=null,this.masterPlaylistLoader_?this.media_||this.media(this.childPlaylist_):(this.updateMainManifest_(rt({masterXml:this.masterXml_,srcUrl:this.srcUrl,clientOffset:this.clientOffset_,sidxMapping:this.sidxMapping_})),this.trigger("loadedplaylist"));},n.updateMinimumUpdatePeriodTimeout_=function(){var e=this;i.clearTimeout(this.minimumUpdatePeriodTimeout_);var t=function(t){e.minimumUpdatePeriodTimeout_=i.setTimeout((function(){e.trigger("minimumUpdatePeriod");}),t);},n=this.master&&this.master.minimumUpdatePeriod;n>0?t(n):0===n&&(this.media()?t(1e3*this.media().targetDuration):this.one("loadedplaylist",(function(){t(1e3*e.media().targetDuration);})));},n.onClientServerClockSync_=function(){this.haveMaster_(),this.hasPendingRequest()||this.media_||this.media(this.master.playlists[0]),this.updateMinimumUpdatePeriodTimeout_();},n.updateMainManifest_=function(e){if(this.master=e,this.master.locations&&this.master.locations.length){var t=this.master.locations[0];t!==this.srcUrl&&(this.srcUrl=t);}},n.refreshXml_=function(){var e=this;this.request=this.vhs_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},(function(t,i){if(e.request){if(e.request=null,t)return e.error={status:i.status,message:"DASH playlist request error at URL: "+e.srcUrl,responseText:i.responseText,code:2},"HAVE_NOTHING"===e.state&&(e.started=!1),e.trigger("error");e.masterXml_=i.responseText,e.sidxMapping_=function(e,t,i,n){var r=je(e,{manifestUri:t,clientOffset:i}),a=ot(r.playlists,n);return w(r,(function(e,t,i,r){if(e.playlists&&e.playlists.length){var s=e.playlists;a=nt(a,ot(s,n));}})),a}(e.masterXml_,e.srcUrl,e.clientOffset_,e.sidxMapping_);var n=rt({masterXml:e.masterXml_,srcUrl:e.srcUrl,clientOffset:e.clientOffset_,sidxMapping:e.sidxMapping_}),r=at(e.master,n),a=e.media().sidx;if(r)if(a){var s=st(a);if(!e.sidxMapping_[s]){var o=e.media();e.request=ut(e,o.sidx,o,e.vhs_.xhr,{handleManifestRedirects:e.handleManifestRedirects},e.sidxRequestFinished_(o,n,e.state,(function(t,i){if(!t||!i)throw new Error("failed to request sidx on minimumUpdatePeriod");e.sidxMapping_[s].sidx=i,e.updateMinimumUpdatePeriodTimeout_(),e.refreshMedia_(e.media().id);})));}}else e.updateMainManifest_(r),e.media_&&(e.media_=e.master.playlists[e.media_.id]);e.updateMinimumUpdatePeriodTimeout_();}}));},n.refreshMedia_=function(e){var t,n,r=this;if(!e)throw new Error("refreshMedia_ must take a media id");this.masterPlaylistLoader_?(t=this.masterPlaylistLoader_.master,n=rt({masterXml:this.masterPlaylistLoader_.masterXml_,srcUrl:this.masterPlaylistLoader_.srcUrl,clientOffset:this.masterPlaylistLoader_.clientOffset_,sidxMapping:this.masterPlaylistLoader_.sidxMapping_})):(t=this.master,n=rt({masterXml:this.masterXml_,srcUrl:this.srcUrl,clientOffset:this.clientOffset_,sidxMapping:this.sidxMapping_}));var a=at(t,n);a?(this.masterPlaylistLoader_?this.masterPlaylistLoader_.master=a:this.master=a,this.media_=a.playlists[e]):(this.media_=t.playlists[e],this.trigger("playlistunchanged")),this.media().endList||(this.mediaUpdateTimeout=i.setTimeout((function(){r.trigger("mediaupdatetimeout");}),x(this.media(),!!a))),this.trigger("loadedplaylist");},t}(it),lt={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,BACK_BUFFER_LENGTH:30,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:16,BUFFER_LOW_WATER_LINE_RATE:1,BUFFER_HIGH_WATER_LINE:30},ht=function(e){for(var t=new Uint8Array(new ArrayBuffer(e.length)),i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t.buffer},ct=[],ft=function(e){var t=e.transmuxer,i=e.bytes,n=e.audioAppendStart,r=e.gopsToAlignWith,a=e.isPartial,s=e.remux,o=e.onData,u=e.onTrackInfo,d=e.onAudioTimingInfo,l=e.onVideoTimingInfo,h=e.onVideoSegmentTimingInfo,c=e.onId3,f=e.onCaptions,m=e.onDone,p={isPartial:a,buffer:[]};if(t.onmessage=function(e){$e&&("data"===e.data.action&&function(e,t,i){var n=e.data.segment,r=n.type,a=n.initSegment,s=n.captions,o=n.captionStreams,u=n.metadata,d=n.videoFrameDtsTime,l=n.videoFramePtsTime;t.buffer.push({captions:s,captionStreams:o,metadata:u});var h=e.data.segment.boxes||{data:e.data.segment.data},c={type:r,data:new Uint8Array(h.data,h.data.byteOffset,h.data.byteLength),initSegment:new Uint8Array(a.data,a.byteOffset,a.byteLength)};void 0!==d&&(c.videoFrameDtsTime=d),void 0!==l&&(c.videoFramePtsTime=l),i(c);}(e,p,o),"trackinfo"===e.data.action&&u(e.data.trackInfo),"gopInfo"===e.data.action&&function(e,t){t.gopInfo=e.data.gopInfo;}(e,p),"audioTimingInfo"===e.data.action&&d(e.data.audioTimingInfo),"videoTimingInfo"===e.data.action&&l(e.data.videoTimingInfo),"videoSegmentTimingInfo"===e.data.action&&h(e.data.videoSegmentTimingInfo),"id3Frame"===e.data.action&&c([e.data.id3Frame],e.data.id3Frame.dispatchType),"caption"===e.data.action&&f(e.data.caption),"transmuxed"===e.data.type&&(t.onmessage=null,function(e){var t=e.transmuxedData,i=e.callback;t.buffer=[],i(t);}({transmuxedData:p,callback:m}),mt()));},n&&t.postMessage({action:"setAudioAppendStart",appendStart:n}),Array.isArray(r)&&t.postMessage({action:"alignGopsWith",gopsToAlignWith:r}),void 0!==s&&t.postMessage({action:"setRemux",remux:s}),i.byteLength){var g=i instanceof ArrayBuffer?i:i.buffer,y=i instanceof ArrayBuffer?0:i.byteOffset;t.postMessage({action:"push",data:g,byteOffset:y,byteLength:i.byteLength},[g]);}t.postMessage({action:a?"partialFlush":"flush"});},mt=function(){$e=null,ct.length&&("function"==typeof($e=ct.shift())?$e():ft($e));},pt=function(e,t){e.postMessage({action:t}),mt();},gt=function(e,t){if(!$e)return $e=e,void pt(t,e);ct.push(pt.bind(null,t,e));},yt=function(e){gt("reset",e);};var bt=function(e,t){var i=1;for(e>t&&(i=-1);Math.abs(t-e)>4294967296;)e+=8589934592*i;return e};var St=function(e){var t=31&e[1];return (t<<=8)|e[2]},It=function(e){return !!(64&e[1])},At=function(e){var t=0;return (48&e[3])>>>4>1&&(t+=e[4]+1),t},Lt=function(e){switch(e){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}},Et={parseType:function(e,t){var i=St(e);return 0===i?"pat":i===t?"pmt":t?"pes":null},parsePat:function(e){var t=It(e),i=4+At(e);return t&&(i+=e[i]+1),(31&e[i+10])<<8|e[i+11]},parsePmt:function(e){var t={},i=It(e),n=4+At(e);if(i&&(n+=e[n]+1),1&e[n+5]){var r;r=3+((15&e[n+1])<<8|e[n+2])-4;for(var a=12+((15&e[n+10])<<8|e[n+11]);a<r;){var s=n+a;t[(31&e[s+1])<<8|e[s+2]]=e[s],a+=5+((15&e[s+3])<<8|e[s+4]);}return t}},parsePayloadUnitStartIndicator:It,parsePesType:function(e,t){switch(t[St(e)]){case 27:return "video";case 15:return "audio";case 21:return "timed-metadata";default:return null}},parsePesTime:function(e){if(!It(e))return null;var t=4+At(e);if(t>=e.byteLength)return null;var i,n=null;return 192&(i=e[t+7])&&((n={}).pts=(14&e[t+9])<<27|(255&e[t+10])<<20|(254&e[t+11])<<12|(255&e[t+12])<<5|(254&e[t+13])>>>3,n.pts*=4,n.pts+=(6&e[t+13])>>>1,n.dts=n.pts,64&i&&(n.dts=(14&e[t+14])<<27|(255&e[t+15])<<20|(254&e[t+16])<<12|(255&e[t+17])<<5|(254&e[t+18])>>>3,n.dts*=4,n.dts+=(6&e[t+18])>>>1)),n},videoPacketContainsKeyFrame:function(e){for(var t=4+At(e),i=e.subarray(t),n=0,r=0,a=!1;r<i.byteLength-3;r++)if(1===i[r+2]){n=r+5;break}for(;n<i.byteLength;)switch(i[n]){case 0:if(0!==i[n-1]){n+=2;break}if(0!==i[n-2]){n++;break}r+3!==n-2&&"slice_layer_without_partitioning_rbsp_idr"===Lt(31&i[r+3])&&(a=!0);do{n++;}while(1!==i[n]&&n<i.length);r=n-2,n+=3;break;case 1:if(0!==i[n-1]||0!==i[n-2]){n+=3;break}"slice_layer_without_partitioning_rbsp_idr"===Lt(31&i[r+3])&&(a=!0),r=n-2,n+=3;break;default:n+=3;}return i=i.subarray(r),n-=r,r=0,i&&i.byteLength>3&&"slice_layer_without_partitioning_rbsp_idr"===Lt(31&i[r+3])&&(a=!0),a}},wt=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],kt=function(e,t){var i=e[t+6]<<21|e[t+7]<<14|e[t+8]<<7|e[t+9];return i=i>=0?i:0,(16&e[t+5])>>4?i+20:i+10},Ot=function(e,t){return e.length-t<10||e[t]!=="I".charCodeAt(0)||e[t+1]!=="D".charCodeAt(0)||e[t+2]!=="3".charCodeAt(0)?t:(t+=kt(e,t),Ot(e,t))},Ut=function(e){return e[0]<<21|e[1]<<14|e[2]<<7|e[3]},Ct={isLikelyAacData:function(e){var t=Ot(e,0);return e.length>=t+2&&255==(255&e[t])&&240==(240&e[t+1])&&16==(22&e[t+1])},parseId3TagSize:kt,parseAdtsSize:function(e,t){var i=(224&e[t+5])>>5,n=e[t+4]<<3;return 6144&e[t+3]|n|i},parseType:function(e,t){return e[t]==="I".charCodeAt(0)&&e[t+1]==="D".charCodeAt(0)&&e[t+2]==="3".charCodeAt(0)?"timed-metadata":!0&e[t]&&240==(240&e[t+1])?"audio":null},parseSampleRate:function(e){for(var t=0;t+5<e.length;){if(255===e[t]&&240==(246&e[t+1]))return wt[(60&e[t+2])>>>2];t++;}return null},parseAacTimestamp:function(e){var t,i,n;t=10,64&e[5]&&(t+=4,t+=Ut(e.subarray(10,14)));do{if((i=Ut(e.subarray(t+4,t+8)))<1)return null;if("PRIV"===String.fromCharCode(e[t],e[t+1],e[t+2],e[t+3])){n=e.subarray(t+10,t+i+10);for(var r=0;r<n.byteLength;r++)if(0===n[r]){if("com.apple.streaming.transportStreamTimestamp"===unescape(function(e,t,i){var n,r="";for(n=0;n<i;n++)r+="%"+("00"+e[n].toString(16)).slice(-2);return r}(n,0,r))){var a=n.subarray(r+1),s=(1&a[3])<<30|a[4]<<22|a[5]<<14|a[6]<<6|a[7]>>>2;return (s*=4)+(3&a[7])}break}}t+=10,t+=i;}while(t<e.byteLength);return null}},Pt=(9e4),Dt=bt,xt={};xt.ts=Et,xt.aac=Ct;var Rt,Mt=function(e,t,i){for(var n,r,a,s,o=0,u=188,d=!1;u<=e.byteLength;)if(71!==e[o]||71!==e[u]&&u!==e.byteLength)o++,u++;else {switch(n=e.subarray(o,u),xt.ts.parseType(n,t.pid)){case"pes":r=xt.ts.parsePesType(n,t.table),a=xt.ts.parsePayloadUnitStartIndicator(n),"audio"===r&&a&&(s=xt.ts.parsePesTime(n))&&(s.type="audio",i.audio.push(s),d=!0);}if(d)break;o+=188,u+=188;}for(o=(u=e.byteLength)-188,d=!1;o>=0;)if(71!==e[o]||71!==e[u]&&u!==e.byteLength)o--,u--;else {switch(n=e.subarray(o,u),xt.ts.parseType(n,t.pid)){case"pes":r=xt.ts.parsePesType(n,t.table),a=xt.ts.parsePayloadUnitStartIndicator(n),"audio"===r&&a&&(s=xt.ts.parsePesTime(n))&&(s.type="audio",i.audio.push(s),d=!0);}if(d)break;o-=188,u-=188;}},Bt=function(e,t,i){for(var n,r,a,s,o,u,d,l=0,h=188,c=!1,f={data:[],size:0};h<e.byteLength;)if(71!==e[l]||71!==e[h])l++,h++;else {switch(n=e.subarray(l,h),xt.ts.parseType(n,t.pid)){case"pes":if(r=xt.ts.parsePesType(n,t.table),a=xt.ts.parsePayloadUnitStartIndicator(n),"video"===r&&(a&&!c&&(s=xt.ts.parsePesTime(n))&&(s.type="video",i.video.push(s),c=!0),!i.firstKeyFrame)){if(a&&0!==f.size){for(o=new Uint8Array(f.size),u=0;f.data.length;)d=f.data.shift(),o.set(d,u),u+=d.byteLength;if(xt.ts.videoPacketContainsKeyFrame(o)){var m=xt.ts.parsePesTime(o);m?(i.firstKeyFrame=m,i.firstKeyFrame.type="video"):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.");}f.size=0;}f.data.push(n),f.size+=n.byteLength;}}if(c&&i.firstKeyFrame)break;l+=188,h+=188;}for(l=(h=e.byteLength)-188,c=!1;l>=0;)if(71!==e[l]||71!==e[h])l--,h--;else {switch(n=e.subarray(l,h),xt.ts.parseType(n,t.pid)){case"pes":r=xt.ts.parsePesType(n,t.table),a=xt.ts.parsePayloadUnitStartIndicator(n),"video"===r&&a&&(s=xt.ts.parsePesTime(n))&&(s.type="video",i.video.push(s),c=!0);}if(c)break;l-=188,h-=188;}},Ft=function(e,t){var i;return (i=xt.aac.isLikelyAacData(e)?function(e){for(var t,i=!1,n=0,r=null,a=null,s=0,o=0;e.length-o>=3;){switch(xt.aac.parseType(e,o)){case"timed-metadata":if(e.length-o<10){i=!0;break}if((s=xt.aac.parseId3TagSize(e,o))>e.length){i=!0;break}null===a&&(t=e.subarray(o,o+s),a=xt.aac.parseAacTimestamp(t)),o+=s;break;case"audio":if(e.length-o<7){i=!0;break}if((s=xt.aac.parseAdtsSize(e,o))>e.length){i=!0;break}null===r&&(t=e.subarray(o,o+s),r=xt.aac.parseSampleRate(t)),n++,o+=s;break;default:o++;}if(i)return null}if(null===r||null===a)return null;var u=9e4/r;return {audio:[{type:"audio",dts:a,pts:a},{type:"audio",dts:a+1024*n*u,pts:a+1024*n*u}]}}(e):function(e){var t={pid:null,table:null},i={};for(var n in function(e,t){for(var i,n=0,r=188;r<e.byteLength;)if(71!==e[n]||71!==e[r])n++,r++;else {switch(i=e.subarray(n,r),xt.ts.parseType(i,t.pid)){case"pat":t.pid||(t.pid=xt.ts.parsePat(i));break;case"pmt":t.table||(t.table=xt.ts.parsePmt(i));}if(t.pid&&t.table)return;n+=188,r+=188;}}(e,t),t.table)if(t.table.hasOwnProperty(n))switch(t.table[n]){case 27:i.video=[],Bt(e,t,i),0===i.video.length&&delete i.video;break;case 15:i.audio=[],Mt(e,t,i),0===i.audio.length&&delete i.audio;}return i}(e))&&(i.audio||i.video)?(function(e,t){if(e.audio&&e.audio.length){var i=t;void 0===i&&(i=e.audio[0].dts),e.audio.forEach((function(e){e.dts=Dt(e.dts,i),e.pts=Dt(e.pts,i),e.dtsTime=e.dts/9e4,e.ptsTime=e.pts/9e4;}));}if(e.video&&e.video.length){var n=t;if(void 0===n&&(n=e.video[0].dts),e.video.forEach((function(e){e.dts=Dt(e.dts,n),e.pts=Dt(e.pts,n),e.dtsTime=e.dts/9e4,e.ptsTime=e.pts/9e4;})),e.firstKeyFrame){var r=e.firstKeyFrame;r.dts=Dt(r.dts,n),r.pts=Dt(r.pts,n),r.dtsTime=r.dts/9e4,r.ptsTime=r.dts/9e4;}}}(i,t),i):null},Nt=function(e){return e>>>0},qt=function(e){var t="";return t+=String.fromCharCode(e[0]),t+=String.fromCharCode(e[1]),(t+=String.fromCharCode(e[2]))+String.fromCharCode(e[3])},Vt=Nt,Wt=function(e,t){var i,n,r,a,s,o=[];if(!t.length)return null;for(i=0;i<e.byteLength;)n=Vt(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]),r=qt(e.subarray(i+4,i+8)),a=n>1?i+n:e.byteLength,r===t[0]&&(1===t.length?o.push(e.subarray(i+8,a)):(s=Wt(e.subarray(i+8,a),t.slice(1))).length&&(o=o.concat(s))),i=a;return o},Ht=Wt,Gt=Nt,jt=function(e){return ("00"+e.toString(16)).slice(-2)},zt=function(e,t){var i,n,r;return i=Ht(t,["moof","traf"]),n=[].concat.apply([],i.map((function(t){return Ht(t,["tfhd"]).map((function(i){var n,r;return n=Gt(i[4]<<24|i[5]<<16|i[6]<<8|i[7]),r=e[n]||9e4,(Ht(t,["tfdt"]).map((function(e){var t,i;return t=e[0],i=Gt(e[4]<<24|e[5]<<16|e[6]<<8|e[7]),1===t&&(i*=Math.pow(2,32),i+=Gt(e[8]<<24|e[9]<<16|e[10]<<8|e[11])),i}))[0]||1/0)/r}))}))),r=Math.min.apply(null,n),isFinite(r)?r:0},Xt=function(e){var t=Ht(e,["moov","trak"]),i=[];return t.forEach((function(e){var t,n,r={},a=Ht(e,["tkhd"])[0];a&&(n=(t=new DataView(a.buffer,a.byteOffset,a.byteLength)).getUint8(0),r.id=0===n?t.getUint32(12):t.getUint32(20));var s=Ht(e,["mdia","hdlr"])[0];if(s){var o=qt(s.subarray(8,12));r.type="vide"===o?"video":"soun"===o?"audio":o;}var u=Ht(e,["mdia","minf","stbl","stsd"])[0];if(u){var d=u.subarray(8);r.codec=qt(d.subarray(4,8));var l,h=Ht(d,[r.codec])[0];h&&(/^[a-z]vc[1-9]$/i.test(r.codec)?(l=h.subarray(78),"avcC"===qt(l.subarray(4,8))&&l.length>11?(r.codec+=".",r.codec+=jt(l[9]),r.codec+=jt(l[10]),r.codec+=jt(l[11])):r.codec="avc1.4d400d"):/^mp4[a,v]$/i.test(r.codec)&&(l=h.subarray(28),"esds"===qt(l.subarray(4,8))&&l.length>20&&0!==l[19]?(r.codec+="."+jt(l[19]),r.codec+="."+jt(l[20]>>>2&63).replace(/^0/,"")):r.codec="mp4a.40.2"));}var c=Ht(e,["mdia","mdhd"])[0];c&&(r.timescale=Rt(c)),i.push(r);})),i},Qt=(Rt=function(e){var t=0===e[0]?12:20;return Gt(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])},2),Yt=function(e){e.forEach((function(e){e.abort();}));},Kt=function(e,t){return t.timedout?{status:t.status,message:"HLS request timed-out at URL: "+t.uri,code:-101,xhr:t}:t.aborted?{status:t.status,message:"HLS request aborted at URL: "+t.uri,code:-102,xhr:t}:e?{status:t.status,message:"HLS request errored at URL: "+t.uri,code:Qt,xhr:t}:null},$t=function(e){var t=e.segment,i=e.bytes,n=e.isPartial,r=e.trackInfoFn,a=e.timingInfoFn,s=e.videoSegmentTimingInfoFn,o=e.id3Fn,u=e.captionsFn,d=e.dataFn,l=e.doneFn,h=t.map&&t.map.tracks||{},c=Boolean(h.audio&&h.video),f=a.bind(null,t,"audio","start"),m=a.bind(null,t,"audio","end"),p=a.bind(null,t,"video","start"),g=a.bind(null,t,"video","end");if(!n&&!t.lastReachedChar){var y=function(e,t){var i=Ft(e,t*Pt);if(!i)return null;var n={hasVideo:i.video&&2===i.video.length||!1,hasAudio:i.audio&&2===i.audio.length||!1};return n.hasVideo&&(n.videoStart=i.video[0].ptsTime),n.hasAudio&&(n.audioStart=i.audio[0].ptsTime),n}(i,t.baseStartTime);y&&(r(t,{hasAudio:y.hasAudio,hasVideo:y.hasVideo,isMuxed:c}),r=null,y.hasAudio&&!c&&f(y.audioStart),y.hasVideo&&p(y.videoStart),f=null,p=null);}!function(e){if(!$e)return $e=e,void ft(e);ct.push(e);}({bytes:i,transmuxer:t.transmuxer,audioAppendStart:t.audioAppendStart,gopsToAlignWith:t.gopsToAlignWith,isPartial:n,remux:c,onData:function(e){e.type="combined"===e.type?"video":e.type,d(t,e);},onTrackInfo:function(e){r&&(c&&(e.isMuxed=!0),r(t,e));},onAudioTimingInfo:function(e){f&&void 0!==e.start&&(f(e.start),f=null),m&&void 0!==e.end&&m(e.end);},onVideoTimingInfo:function(e){p&&void 0!==e.start&&(p(e.start),p=null),g&&void 0!==e.end&&g(e.end);},onVideoSegmentTimingInfo:function(e){s(e);},onId3:function(e,i){o(t,e,i);},onCaptions:function(e){u(t,[e]);},onDone:function(e){l&&!n&&(e.type="combined"===e.type?"video":e.type,l(null,t,e));}});},Jt=function(e){var t=e.segment,i=e.bytes,n=e.isPartial,r=e.trackInfoFn,a=e.timingInfoFn,s=e.videoSegmentTimingInfoFn,o=e.id3Fn,u=e.captionsFn,d=e.dataFn,l=e.doneFn,h=new Uint8Array(i);if(Ye(h)){t.isFmp4=!0;var c=t.map.tracks,f={isFmp4:!0,hasVideo:!!c.video,hasAudio:!!c.audio};c.audio&&c.audio.codec&&"enca"!==c.audio.codec&&(f.audioCodec=c.audio.codec),c.video&&c.video.codec&&"encv"!==c.video.codec&&(f.videoCodec=c.video.codec),c.video&&c.audio&&(f.isMuxed=!0),r(t,f);var m=zt(t.map.timescales,h);f.hasAudio&&!f.isMuxed&&a(t,"audio","start",m),f.hasVideo&&a(t,"video","start",m);var p=function(e){d(t,{data:i,type:f.hasAudio&&!f.isMuxed?"audio":"video"}),e&&e.length&&u(t,e),l(null,t,{});};if(!c.video||!i.byteLength||!t.transmuxer)return void p();var g=i instanceof ArrayBuffer?i:i.buffer,y=i instanceof ArrayBuffer?0:i.byteOffset;return t.transmuxer.addEventListener("message",(function e(n){if("mp4Captions"===n.data.action){t.transmuxer.removeEventListener("message",e);var r=n.data.data;t.bytes=i=new Uint8Array(r,r.byteOffset||0,r.byteLength),p(n.data.captions);}})),void t.transmuxer.postMessage({action:"pushMp4Captions",timescales:t.map.timescales,trackIds:[c.video.id],data:g,byteOffset:y,byteLength:i.byteLength},[g])}if(t.transmuxer){if(void 0===t.container&&(t.container=Xe(h)),"ts"!==t.container&&"aac"!==t.container)return r(t,{hasAudio:!1,hasVideo:!1}),void l(null,t,{});$t({segment:t,bytes:i,isPartial:n,trackInfoFn:r,timingInfoFn:a,videoSegmentTimingInfoFn:s,id3Fn:o,captionsFn:u,dataFn:d,doneFn:l});}else l(null,t,{});},Zt=function(e){var t=e.xhr,i=e.xhrOptions,r=e.decryptionWorker,a=e.segment,s=e.abortFn,o=e.progressFn,u=e.trackInfoFn,d=e.timingInfoFn,l=e.videoSegmentTimingInfoFn,h=e.id3Fn,c=e.captionsFn,f=e.dataFn,m=e.doneFn,p=e.handlePartialData,g=[],y=function(e){var t=e.activeXhrs,i=e.decryptionWorker,n=e.trackInfoFn,r=e.timingInfoFn,a=e.videoSegmentTimingInfoFn,s=e.id3Fn,o=e.captionsFn,u=e.dataFn,d=e.doneFn,l=0,h=!1;return function(e,c){if(!h){if(e)return h=!0,Yt(t),d(e,c);if((l+=1)===t.length){if(c.endOfAllRequests=Date.now(),c.encryptedBytes)return function(e){var t,i=e.decryptionWorker,n=e.segment,r=e.trackInfoFn,a=e.timingInfoFn,s=e.videoSegmentTimingInfoFn,o=e.id3Fn,u=e.captionsFn,d=e.dataFn,l=e.doneFn;i.addEventListener("message",(function e(t){if(t.data.source===n.requestId){i.removeEventListener("message",e);var h=t.data.decrypted;n.bytes=new Uint8Array(h.bytes,h.byteOffset,h.byteLength),Jt({segment:n,bytes:n.bytes,isPartial:!1,trackInfoFn:r,timingInfoFn:a,videoSegmentTimingInfoFn:s,id3Fn:o,captionsFn:u,dataFn:d,doneFn:l});}})),t=n.key.bytes.slice?n.key.bytes.slice():new Uint32Array(Array.prototype.slice.call(n.key.bytes)),i.postMessage(de({source:n.requestId,encrypted:n.encryptedBytes,key:t,iv:n.key.iv}),[n.encryptedBytes.buffer,t.buffer]);}({decryptionWorker:i,segment:c,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:a,id3Fn:s,captionsFn:o,dataFn:u,doneFn:d});Jt({segment:c,bytes:c.bytes,isPartial:!1,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:a,id3Fn:s,captionsFn:o,dataFn:u,doneFn:d});}}}}({activeXhrs:g,decryptionWorker:r,trackInfoFn:u,timingInfoFn:d,videoSegmentTimingInfoFn:l,id3Fn:h,captionsFn:c,dataFn:f,doneFn:m});if(a.key&&!a.key.bytes){var _=t(n.mergeOptions(i,{uri:a.key.resolvedUri,responseType:"arraybuffer"}),function(e,t){return function(i,n){var r=n.response,a=Kt(i,n);if(a)return t(a,e);if(16!==r.byteLength)return t({status:n.status,message:"Invalid HLS key at URL: "+n.uri,code:Qt,xhr:n},e);var s=new DataView(r);return e.key.bytes=new Uint32Array([s.getUint32(0),s.getUint32(4),s.getUint32(8),s.getUint32(12)]),t(null,e)}}(a,y));g.push(_);}if(a.map&&!a.map.bytes){var v=t(n.mergeOptions(i,{uri:a.map.resolvedUri,responseType:"arraybuffer",headers:ne(a.map)}),function(e){var t=e.segment,i=e.finishProcessingFn;return function(e,n){var r=n.response,a=Kt(e,n);if(a)return i(a,t);if(0===r.byteLength)return i({status:n.status,message:"Empty HLS segment content at URL: "+n.uri,code:Qt,xhr:n},t);t.map.bytes=new Uint8Array(n.response);var s=Xe(t.map.bytes);return "mp4"!==s?i({status:n.status,message:"Found unsupported "+(s||"unknown")+" container for initialization segment at URL: "+n.uri,code:Qt,internal:!0,xhr:n},t):(Xt(t.map.bytes).forEach((function(e){t.map.tracks=t.map.tracks||{},t.map.tracks[e.type]||(t.map.tracks[e.type]=e,e.id&&e.timescale&&(t.map.timescales=t.map.timescales||{},t.map.timescales[e.id]=e.timescale));})),i(null,t))}}({segment:a,finishProcessingFn:y}));g.push(v);}var b=n.mergeOptions(i,{uri:a.resolvedUri,responseType:"arraybuffer",headers:ne(a)});p&&(b.responseType="text",b.beforeSend=function(e){e.overrideMimeType("text/plain; charset=x-user-defined");});var T=t(b,function(e){var t=e.segment,i=e.finishProcessingFn,n=e.responseType;return function(e,r){var a=r.response,s=Kt(e,r);if(s)return i(s,t);var o="arraybuffer"!==n&&r.responseText?ht(r.responseText.substring(t.lastReachedChar||0)):r.response;return 0===a.byteLength?i({status:r.status,message:"Empty HLS segment content at URL: "+r.uri,code:Qt,xhr:r},t):(t.stats=function(e){return {bandwidth:e.bandwidth,bytesReceived:e.bytesReceived||0,roundTripTime:e.roundTripTime||0}}(r),t.key?t.encryptedBytes=new Uint8Array(o):t.bytes=new Uint8Array(o),i(null,t))}}({segment:a,finishProcessingFn:y,responseType:b.responseType}));T.addEventListener("progress",function(e){var t=e.segment,i=e.progressFn,r=e.trackInfoFn,a=e.timingInfoFn,s=e.videoSegmentTimingInfoFn,o=e.id3Fn,u=e.captionsFn,d=e.dataFn,l=e.handlePartialData;return function(e){var h=e.target;if(!h.aborted){if(l&&!t.key&&h.responseText&&h.responseText.length>=8){var c=ht(h.responseText.substring(t.lastReachedChar||0));!t.lastReachedChar&&Ye(new Uint8Array(c))||(t.lastReachedChar=h.responseText.length,Jt({segment:t,bytes:c,isPartial:!0,trackInfoFn:r,timingInfoFn:a,videoSegmentTimingInfoFn:s,id3Fn:o,captionsFn:u,dataFn:d}));}return t.stats=n.mergeOptions(t.stats,function(e){var t=e.target,i={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-t.requestTime||0};return i.bytesReceived=e.loaded,i.bandwidth=Math.floor(i.bytesReceived/i.roundTripTime*8*1e3),i}(e)),!t.stats.firstBytesReceivedAt&&t.stats.bytesReceived&&(t.stats.firstBytesReceivedAt=Date.now()),i(e,t)}}}({segment:a,progressFn:o,trackInfoFn:u,timingInfoFn:d,videoSegmentTimingInfoFn:l,id3Fn:h,captionsFn:c,dataFn:f,handlePartialData:p})),g.push(T);var S={};return g.forEach((function(e){e.addEventListener("loadend",function(e){var t=e.loadendState,i=e.abortFn;return function(e){e.target.aborted&&i&&!t.calledAbortFn&&(i(),t.calledAbortFn=!0);}}({loadendState:S,abortFn:s}));})),function(){return Yt(g)}},ei="undefined"!=typeof window?window:{},ti="undefined"==typeof Symbol?"__target":Symbol(),ii=ei.BlobBuilder||ei.WebKitBlobBuilder||ei.MozBlobBuilder||ei.MSBlobBuilder,ni=ei.URL||ei.webkitURL||ni&&ni.msURL,ri=ei.Worker;function ai(e,t){return function(i){var n=this;if(!t)return new ri(e);if(ri&&!i){var r=di(t.toString().replace(/^function.+?{/,"").slice(0,-1));return this[ti]=new ri(r),function(e,t){if(e&&t){var i=e.terminate;e.objURL=t,e.terminate=function(){e.objURL&&ni.revokeObjectURL(e.objURL),i.call(e);};}}(this[ti],r),this[ti]}var a={postMessage:function(e){n.onmessage&&setTimeout((function(){n.onmessage({data:e,target:a});}));}};t.call(a),this.postMessage=function(e){setTimeout((function(){a.onmessage({data:e,target:n});}));},this.isThisThread=!0;}}if(ri){var si,oi=di("self.onmessage = function () {}"),ui=new Uint8Array(1);try{(si=new ri(oi)).postMessage(ui,[ui.buffer]);}catch(e){ri=null;}finally{ni.revokeObjectURL(oi),si&&si.terminate();}}function di(e){try{return ni.createObjectURL(new Blob([e],{type:"application/javascript"}))}catch(i){var t=new ii;return t.append(e),ni.createObjectURL(t.getBlob(type))}}var li=new ai("./transmuxer-worker.worker.js",(function(e,t){var i=this;
|
||
/*! @name @videojs/http-streaming @version 2.3.1 @license Apache-2.0 */!function(){var e=function(){this.init=function(){var e={};this.on=function(t,i){e[t]||(e[t]=[]),e[t]=e[t].concat(i);},this.off=function(t,i){var n;return !!e[t]&&(n=e[t].indexOf(i),e[t]=e[t].slice(),e[t].splice(n,1),n>-1)},this.trigger=function(t){var i,n,r,a;if(i=e[t])if(2===arguments.length)for(r=i.length,n=0;n<r;++n)i[n].call(this,arguments[1]);else {for(a=[],n=arguments.length,n=1;n<arguments.length;++n)a.push(arguments[n]);for(r=i.length,n=0;n<r;++n)i[n].apply(this,a);}},this.dispose=function(){e={};};};};e.prototype.pipe=function(e){return this.on("data",(function(t){e.push(t);})),this.on("done",(function(t){e.flush(t);})),this.on("partialdone",(function(t){e.partialFlush(t);})),this.on("endedtimeline",(function(t){e.endTimeline(t);})),this.on("reset",(function(t){e.reset(t);})),e},e.prototype.push=function(e){this.trigger("data",e);},e.prototype.flush=function(e){this.trigger("done",e);},e.prototype.partialFlush=function(e){this.trigger("partialdone",e);},e.prototype.endTimeline=function(e){this.trigger("endedtimeline",e);},e.prototype.reset=function(e){this.trigger("reset",e);};var t,n,r,a,s,o,u,d,l,h,c,f,m,p,g,y,_,v,b,T,S,I,A,L,E,w,k,O,U,C,P,D,x,R,M,B,F,N,q,V,W=e,H=Math.pow(2,32)-1;!function(){var e;if(I={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:[]},"undefined"!=typeof Uint8Array){for(e in I)I.hasOwnProperty(e)&&(I[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);A=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]),E=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]),L=new Uint8Array([0,0,0,1]),w=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]),k=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]),O={video:w,audio:k},P=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),C=new Uint8Array([0,0,0,0,0,0,0,0]),D=new Uint8Array([0,0,0,0,0,0,0,0]),x=D,R=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),M=D,U=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]);}}(),t=function(e){var t,i,n=[],r=0;for(t=1;t<arguments.length;t++)n.push(arguments[t]);for(t=n.length;t--;)r+=n[t].byteLength;for(i=new Uint8Array(r+8),new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,i.byteLength),i.set(e,4),t=0,r=8;t<n.length;t++)i.set(n[t],r),r+=n[t].byteLength;return i},n=function(){return t(I.dinf,t(I.dref,P))},r=function(e){return t(I.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,e.audioobjecttype<<3|e.samplingfrequencyindex>>>1,e.samplingfrequencyindex<<7|e.channelcount<<3,6,1,2]))},g=function(e){return t(I.hdlr,O[e])},p=function(e){var i=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,e.duration>>>24&255,e.duration>>>16&255,e.duration>>>8&255,255&e.duration,85,196,0,0]);return e.samplerate&&(i[12]=e.samplerate>>>24&255,i[13]=e.samplerate>>>16&255,i[14]=e.samplerate>>>8&255,i[15]=255&e.samplerate),t(I.mdhd,i)},m=function(e){return t(I.mdia,p(e),g(e.type),o(e))},s=function(e){return t(I.mfhd,new Uint8Array([0,0,0,0,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e]))},o=function(e){return t(I.minf,"video"===e.type?t(I.vmhd,U):t(I.smhd,C),n(),_(e))},u=function(e,i){for(var n=[],r=i.length;r--;)n[r]=b(i[r]);return t.apply(null,[I.moof,s(e)].concat(n))},d=function(e){for(var i=e.length,n=[];i--;)n[i]=c(e[i]);return t.apply(null,[I.moov,h(4294967295)].concat(n).concat(l(e)))},l=function(e){for(var i=e.length,n=[];i--;)n[i]=T(e[i]);return t.apply(null,[I.mvex].concat(n))},h=function(e){var i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e,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 t(I.mvhd,i)},y=function(e){var i,n,r=e.samples||[],a=new Uint8Array(4+r.length);for(n=0;n<r.length;n++)i=r[n].flags,a[n+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return t(I.sdtp,a)},_=function(e){return t(I.stbl,v(e),t(I.stts,M),t(I.stsc,x),t(I.stsz,R),t(I.stco,D))},v=function(e){return t(I.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),"video"===e.type?B(e):F(e))},B=function(e){var i,n,r=e.sps||[],a=e.pps||[],s=[],o=[];for(i=0;i<r.length;i++)s.push((65280&r[i].byteLength)>>>8),s.push(255&r[i].byteLength),s=s.concat(Array.prototype.slice.call(r[i]));for(i=0;i<a.length;i++)o.push((65280&a[i].byteLength)>>>8),o.push(255&a[i].byteLength),o=o.concat(Array.prototype.slice.call(a[i]));if(n=[I.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,(65280&e.width)>>8,255&e.width,(65280&e.height)>>8,255&e.height,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]),t(I.avcC,new Uint8Array([1,e.profileIdc,e.profileCompatibility,e.levelIdc,255].concat([r.length],s,[a.length],o))),t(I.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],e.sarRatio){var u=e.sarRatio[0],d=e.sarRatio[1];n.push(t(I.pasp,new Uint8Array([(4278190080&u)>>24,(16711680&u)>>16,(65280&u)>>8,255&u,(4278190080&d)>>24,(16711680&d)>>16,(65280&d)>>8,255&d])));}return t.apply(null,n)},F=function(e){return t(I.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(65280&e.channelcount)>>8,255&e.channelcount,(65280&e.samplesize)>>8,255&e.samplesize,0,0,0,0,(65280&e.samplerate)>>8,255&e.samplerate,0,0]),r(e))},f=function(e){var i=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,0,(4278190080&e.duration)>>24,(16711680&e.duration)>>16,(65280&e.duration)>>8,255&e.duration,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,(65280&e.width)>>8,255&e.width,0,0,(65280&e.height)>>8,255&e.height,0,0]);return t(I.tkhd,i)},b=function(e){var i,n,r,a,s,o;return i=t(I.tfhd,new Uint8Array([0,0,0,58,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),s=Math.floor(e.baseMediaDecodeTime/(H+1)),o=Math.floor(e.baseMediaDecodeTime%(H+1)),n=t(I.tfdt,new Uint8Array([1,0,0,0,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o>>>24&255,o>>>16&255,o>>>8&255,255&o])),"audio"===e.type?(r=S(e,92),t(I.traf,i,n,r)):(a=y(e),r=S(e,a.length+92),t(I.traf,i,n,r,a))},c=function(e){return e.duration=e.duration||4294967295,t(I.trak,f(e),m(e))},T=function(e){var i=new Uint8Array([0,0,0,0,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return "video"!==e.type&&(i[i.length-1]=0),t(I.trex,i)},V=function(e,t){var i=0,n=0,r=0,a=0;return e.length&&(void 0!==e[0].duration&&(i=1),void 0!==e[0].size&&(n=2),void 0!==e[0].flags&&(r=4),void 0!==e[0].compositionTimeOffset&&(a=8)),[0,0,i|n|r|a,1,(4278190080&e.length)>>>24,(16711680&e.length)>>>16,(65280&e.length)>>>8,255&e.length,(4278190080&t)>>>24,(16711680&t)>>>16,(65280&t)>>>8,255&t]},q=function(e,i){var n,r,a,s,o,u;for(i+=20+16*(s=e.samples||[]).length,a=V(s,i),(r=new Uint8Array(a.length+16*s.length)).set(a),n=a.length,u=0;u<s.length;u++)o=s[u],r[n++]=(4278190080&o.duration)>>>24,r[n++]=(16711680&o.duration)>>>16,r[n++]=(65280&o.duration)>>>8,r[n++]=255&o.duration,r[n++]=(4278190080&o.size)>>>24,r[n++]=(16711680&o.size)>>>16,r[n++]=(65280&o.size)>>>8,r[n++]=255&o.size,r[n++]=o.flags.isLeading<<2|o.flags.dependsOn,r[n++]=o.flags.isDependedOn<<6|o.flags.hasRedundancy<<4|o.flags.paddingValue<<1|o.flags.isNonSyncSample,r[n++]=61440&o.flags.degradationPriority,r[n++]=15&o.flags.degradationPriority,r[n++]=(4278190080&o.compositionTimeOffset)>>>24,r[n++]=(16711680&o.compositionTimeOffset)>>>16,r[n++]=(65280&o.compositionTimeOffset)>>>8,r[n++]=255&o.compositionTimeOffset;return t(I.trun,r)},N=function(e,i){var n,r,a,s,o,u;for(i+=20+8*(s=e.samples||[]).length,a=V(s,i),(n=new Uint8Array(a.length+8*s.length)).set(a),r=a.length,u=0;u<s.length;u++)o=s[u],n[r++]=(4278190080&o.duration)>>>24,n[r++]=(16711680&o.duration)>>>16,n[r++]=(65280&o.duration)>>>8,n[r++]=255&o.duration,n[r++]=(4278190080&o.size)>>>24,n[r++]=(16711680&o.size)>>>16,n[r++]=(65280&o.size)>>>8,n[r++]=255&o.size;return t(I.trun,n)},S=function(e,t){return "audio"===e.type?N(e,t):q(e,t)},a=function(){return t(I.ftyp,A,L,A,E)};var G,j,z,X,Q,Y,K,$,J=function(e){return t(I.mdat,e)},Z=u,ee=function(e){var t,i=a(),n=d(e);return (t=new Uint8Array(i.byteLength+n.byteLength)).set(i),t.set(n,i.byteLength),t},te=function(e,t){var i={size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}};return i.dataOffset=t,i.compositionTimeOffset=e.pts-e.dts,i.duration=e.duration,i.size=4*e.length,i.size+=e.byteLength,e.keyFrame&&(i.flags.dependsOn=2,i.flags.isNonSyncSample=0),i},ie=function(e){var t,i,n=[],r=[];for(r.byteLength=0,r.nalCount=0,r.duration=0,n.byteLength=0,t=0;t<e.length;t++)"access_unit_delimiter_rbsp"===(i=e[t]).nalUnitType?(n.length&&(n.duration=i.dts-n.dts,r.byteLength+=n.byteLength,r.nalCount+=n.length,r.duration+=n.duration,r.push(n)),(n=[i]).byteLength=i.data.byteLength,n.pts=i.pts,n.dts=i.dts):("slice_layer_without_partitioning_rbsp_idr"===i.nalUnitType&&(n.keyFrame=!0),n.duration=i.dts-n.dts,n.byteLength+=i.data.byteLength,n.push(i));return r.length&&(!n.duration||n.duration<=0)&&(n.duration=r[r.length-1].duration),r.byteLength+=n.byteLength,r.nalCount+=n.length,r.duration+=n.duration,r.push(n),r},ne=function(e){var t,i,n=[],r=[];for(n.byteLength=0,n.nalCount=0,n.duration=0,n.pts=e[0].pts,n.dts=e[0].dts,r.byteLength=0,r.nalCount=0,r.duration=0,r.pts=e[0].pts,r.dts=e[0].dts,t=0;t<e.length;t++)(i=e[t]).keyFrame?(n.length&&(r.push(n),r.byteLength+=n.byteLength,r.nalCount+=n.nalCount,r.duration+=n.duration),(n=[i]).nalCount=i.length,n.byteLength=i.byteLength,n.pts=i.pts,n.dts=i.dts,n.duration=i.duration):(n.duration+=i.duration,n.nalCount+=i.length,n.byteLength+=i.byteLength,n.push(i));return r.length&&n.duration<=0&&(n.duration=r[r.length-1].duration),r.byteLength+=n.byteLength,r.nalCount+=n.nalCount,r.duration+=n.duration,r.push(n),r},re=function(e){var t;return !e[0][0].keyFrame&&e.length>1&&(t=e.shift(),e.byteLength-=t.byteLength,e.nalCount-=t.nalCount,e[0][0].dts=t.dts,e[0][0].pts=t.pts,e[0][0].duration+=t.duration),e},ae=function(e,t){var i,n=[];return i=te(e,t||0),n.push(i),n},se=function(e){var t,i,n=0,r=e.byteLength,a=e.length,s=new Uint8Array(r+4*a),o=new DataView(s.buffer);for(t=0;t<e.length;t++)i=e[t],o.setUint32(n,i.data.byteLength),n+=4,s.set(i.data,n),n+=i.data.byteLength;return s},oe=[33,16,5,32,164,27],ue=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],de=function(e){for(var t=[];e--;)t.push(0);return t};Y=function(e,t){return j(Q(e,t))},K=function(e,t){return z(X(e),t)},$=function(e,t,i){return X(i?e:e-t)};var le=(z=function(e,t){return e*t},X=function(e){return e/9e4}),he=(Q=function(e,t){return e/t},Y),ce=K,fe=$,me=j=function(e){return 9e4*e},pe=le,ge=function(e,t,i,n){var r,a,s,o,u,d=0,l=0,h=0;if(t.length&&(r=he(e.baseMediaDecodeTime,e.samplerate),a=Math.ceil(9e4/(e.samplerate/1024)),i&&n&&(d=r-Math.max(i,n),h=(l=Math.floor(d/a))*a),!(l<1||h>45e3))){for((s=function(){if(!G){var e={96e3:[oe,[227,64],de(154),[56]],88200:[oe,[231],de(170),[56]],64e3:[oe,[248,192],de(240),[56]],48e3:[oe,[255,192],de(268),[55,148,128],de(54),[112]],44100:[oe,[255,192],de(268),[55,163,128],de(84),[112]],32e3:[oe,[255,192],de(268),[55,234],de(226),[112]],24e3:[oe,[255,192],de(268),[55,255,128],de(268),[111,112],de(126),[224]],16e3:[oe,[255,192],de(268),[55,255,128],de(268),[111,255],de(269),[223,108],de(195),[1,192]],12e3:[ue,de(268),[3,127,248],de(268),[6,255,240],de(268),[13,255,224],de(268),[27,253,128],de(259),[56]],11025:[ue,de(268),[3,127,248],de(268),[6,255,240],de(268),[13,255,224],de(268),[27,255,192],de(268),[55,175,128],de(108),[112]],8e3:[ue,de(268),[3,121,16],de(47),[7]]};t=e,G=Object.keys(t).reduce((function(e,i){return e[i]=new Uint8Array(t[i].reduce((function(e,t){return e.concat(t)}),[])),e}),{});}var t;return G}()[e.samplerate])||(s=t[0].data),o=0;o<l;o++)u=t[0],t.splice(0,0,{data:s,dts:u.dts-a,pts:u.pts-a});e.baseMediaDecodeTime-=Math.floor(ce(h,e.samplerate));}},ye=function(e,t,i){return t.minSegmentDts>=i?e:(t.minSegmentDts=1/0,e.filter((function(e){return e.dts>=i&&(t.minSegmentDts=Math.min(t.minSegmentDts,e.dts),t.minSegmentPts=t.minSegmentDts,!0)})))},_e=function(e){var t,i,n=[];for(t=0;t<e.length;t++)i=e[t],n.push({size:i.data.byteLength,duration:1024});return n},ve=function(e){var t,i,n=0,r=new Uint8Array(function(e){var t,i=0;for(t=0;t<e.length;t++)i+=e[t].data.byteLength;return i}(e));for(t=0;t<e.length;t++)i=e[t],r.set(i.data,n),n+=i.data.byteLength;return r},be=function(e){delete e.minSegmentDts,delete e.maxSegmentDts,delete e.minSegmentPts,delete e.maxSegmentPts;},Te=function(e,t){var i,n=e.minSegmentDts;return t||(n-=e.timelineStartInfo.dts),i=e.timelineStartInfo.baseMediaDecodeTime,i+=n,i=Math.max(0,i),"audio"===e.type&&(i*=e.samplerate/9e4,i=Math.floor(i)),i},Se=function(e,t){"number"==typeof t.pts&&(void 0===e.timelineStartInfo.pts&&(e.timelineStartInfo.pts=t.pts),void 0===e.minSegmentPts?e.minSegmentPts=t.pts:e.minSegmentPts=Math.min(e.minSegmentPts,t.pts),void 0===e.maxSegmentPts?e.maxSegmentPts=t.pts:e.maxSegmentPts=Math.max(e.maxSegmentPts,t.pts)),"number"==typeof t.dts&&(void 0===e.timelineStartInfo.dts&&(e.timelineStartInfo.dts=t.dts),void 0===e.minSegmentDts?e.minSegmentDts=t.dts:e.minSegmentDts=Math.min(e.minSegmentDts,t.dts),void 0===e.maxSegmentDts?e.maxSegmentDts=t.dts:e.maxSegmentDts=Math.max(e.maxSegmentDts,t.dts));},Ie=function e(){e.prototype.init.call(this),this.captionPackets_=[],this.ccStreams_=[new ke(0,0),new ke(0,1),new ke(1,0),new ke(1,1)],this.reset(),this.ccStreams_.forEach((function(e){e.on("data",this.trigger.bind(this,"data")),e.on("partialdone",this.trigger.bind(this,"partialdone")),e.on("done",this.trigger.bind(this,"done"));}),this);};(Ie.prototype=new W).push=function(e){var t,i,n;if("sei_rbsp"===e.nalUnitType&&4===(t=function(e){for(var t=0,i={payloadType:-1,payloadSize:0},n=0,r=0;t<e.byteLength&&128!==e[t];){for(;255===e[t];)n+=255,t++;for(n+=e[t++];255===e[t];)r+=255,t++;if(r+=e[t++],!i.payload&&4===n){if("GA94"===String.fromCharCode(e[t+3],e[t+4],e[t+5],e[t+6])){i.payloadType=n,i.payloadSize=r,i.payload=e.subarray(t,t+r);break}i.payload=void 0;}t+=r,n=0,r=0;}return i}(e.escapedRBSP)).payloadType&&(i=function(e){return 181!==e.payload[0]||49!=(e.payload[1]<<8|e.payload[2])||"GA94"!==String.fromCharCode(e.payload[3],e.payload[4],e.payload[5],e.payload[6])||3!==e.payload[7]?null:e.payload.subarray(8,e.payload.length-1)}(t)))if(e.dts<this.latestDts_)this.ignoreNextEqualDts_=!0;else {if(e.dts===this.latestDts_&&this.ignoreNextEqualDts_)return this.numSameDts_--,void(this.numSameDts_||(this.ignoreNextEqualDts_=!1));n=function(e,t){var i,n,r,a,s=[];if(!(64&t[0]))return s;for(n=31&t[0],i=0;i<n;i++)a={type:3&t[2+(r=3*i)],pts:e},4&t[r+2]&&(a.ccData=t[r+3]<<8|t[r+4],s.push(a));return s}(e.pts,i),this.captionPackets_=this.captionPackets_.concat(n),this.latestDts_!==e.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=e.dts;}},Ie.prototype.flushCCStreams=function(e){this.ccStreams_.forEach((function(t){return "flush"===e?t.flush():t.partialFlush()}),this);},Ie.prototype.flushStream=function(e){this.captionPackets_.length?(this.captionPackets_.forEach((function(e,t){e.presortIndex=t;})),this.captionPackets_.sort((function(e,t){return e.pts===t.pts?e.presortIndex-t.presortIndex:e.pts-t.pts})),this.captionPackets_.forEach((function(e){e.type<2&&this.dispatchCea608Packet(e);}),this),this.captionPackets_.length=0,this.flushCCStreams(e)):this.flushCCStreams(e);},Ie.prototype.flush=function(){return this.flushStream("flush")},Ie.prototype.partialFlush=function(){return this.flushStream("partialFlush")},Ie.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach((function(e){e.reset();}));},Ie.prototype.dispatchCea608Packet=function(e){this.setsTextOrXDSActive(e)?this.activeCea608Channel_[e.type]=null:this.setsChannel1Active(e)?this.activeCea608Channel_[e.type]=0:this.setsChannel2Active(e)&&(this.activeCea608Channel_[e.type]=1),null!==this.activeCea608Channel_[e.type]&&this.ccStreams_[(e.type<<1)+this.activeCea608Channel_[e.type]].push(e);},Ie.prototype.setsChannel1Active=function(e){return 4096==(30720&e.ccData)},Ie.prototype.setsChannel2Active=function(e){return 6144==(30720&e.ccData)},Ie.prototype.setsTextOrXDSActive=function(e){return 256==(28928&e.ccData)||4138==(30974&e.ccData)||6186==(30974&e.ccData)};var Ae={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},Le=function(e){return null===e?"":(e=Ae[e]||e,String.fromCharCode(e))},Ee=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],we=function(){for(var e=[],t=15;t--;)e.push("");return e},ke=function e(t,i){e.prototype.init.call(this),this.field_=t||0,this.dataChannel_=i||0,this.name_="CC"+(1+(this.field_<<1|this.dataChannel_)),this.setConstants(),this.reset(),this.push=function(e){var t,i,n,r,a;if((t=32639&e.ccData)!==this.lastControlCode_){if(4096==(61440&t)?this.lastControlCode_=t:t!==this.PADDING_&&(this.lastControlCode_=null),n=t>>>8,r=255&t,t!==this.PADDING_)if(t===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(t===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(e.pts),this.flushDisplayed(e.pts),i=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=i,this.startPts_=e.pts;else if(t===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(e.pts);else if(t===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(e.pts);else if(t===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(e.pts);else if(t===this.CARRIAGE_RETURN_)this.clearFormatting(e.pts),this.flushDisplayed(e.pts),this.shiftRowsUp_(),this.startPts_=e.pts;else if(t===this.BACKSPACE_)"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1);else if(t===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(e.pts),this.displayed_=we();else if(t===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=we();else if(t===this.RESUME_DIRECT_CAPTIONING_)"paintOn"!==this.mode_&&(this.flushDisplayed(e.pts),this.displayed_=we()),this.mode_="paintOn",this.startPts_=e.pts;else if(this.isSpecialCharacter(n,r))a=Le((n=(3&n)<<8)|r),this[this.mode_](e.pts,a),this.column_++;else if(this.isExtCharacter(n,r))"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1),a=Le((n=(3&n)<<8)|r),this[this.mode_](e.pts,a),this.column_++;else if(this.isMidRowCode(n,r))this.clearFormatting(e.pts),this[this.mode_](e.pts," "),this.column_++,14==(14&r)&&this.addFormatting(e.pts,["i"]),1==(1&r)&&this.addFormatting(e.pts,["u"]);else if(this.isOffsetControlCode(n,r))this.column_+=3&r;else if(this.isPAC(n,r)){var s=Ee.indexOf(7968&t);"rollUp"===this.mode_&&(s-this.rollUpRows_+1<0&&(s=this.rollUpRows_-1),this.setRollUp(e.pts,s)),s!==this.row_&&(this.clearFormatting(e.pts),this.row_=s),1&r&&-1===this.formatting_.indexOf("u")&&this.addFormatting(e.pts,["u"]),16==(16&t)&&(this.column_=4*((14&t)>>1)),this.isColorPAC(r)&&14==(14&r)&&this.addFormatting(e.pts,["i"]);}else this.isNormalChar(n)&&(0===r&&(r=null),a=Le(n),a+=Le(r),this[this.mode_](e.pts,a),this.column_+=a.length);}else this.lastControlCode_=null;};};ke.prototype=new W,ke.prototype.flushDisplayed=function(e){var t=this.displayed_.map((function(e){try{return e.trim()}catch(e){return console.error("Skipping malformed caption."),""}})).join("\n").replace(/^\n+|\n+$/g,"");t.length&&this.trigger("data",{startPts:this.startPts_,endPts:e,text:t,stream:this.name_});},ke.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=we(),this.nonDisplayed_=we(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.rollUpRows_=2,this.formatting_=[];},ke.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_;},ke.prototype.isSpecialCharacter=function(e,t){return e===this.EXT_&&t>=48&&t<=63},ke.prototype.isExtCharacter=function(e,t){return (e===this.EXT_+1||e===this.EXT_+2)&&t>=32&&t<=63},ke.prototype.isMidRowCode=function(e,t){return e===this.EXT_&&t>=32&&t<=47},ke.prototype.isOffsetControlCode=function(e,t){return e===this.OFFSET_&&t>=33&&t<=35},ke.prototype.isPAC=function(e,t){return e>=this.BASE_&&e<this.BASE_+8&&t>=64&&t<=127},ke.prototype.isColorPAC=function(e){return e>=64&&e<=79||e>=96&&e<=127},ke.prototype.isNormalChar=function(e){return e>=32&&e<=127},ke.prototype.setRollUp=function(e,t){if("rollUp"!==this.mode_&&(this.row_=14,this.mode_="rollUp",this.flushDisplayed(e),this.nonDisplayed_=we(),this.displayed_=we()),void 0!==t&&t!==this.row_)for(var i=0;i<this.rollUpRows_;i++)this.displayed_[t-i]=this.displayed_[this.row_-i],this.displayed_[this.row_-i]="";void 0===t&&(t=this.row_),this.topRow_=t-this.rollUpRows_+1;},ke.prototype.addFormatting=function(e,t){this.formatting_=this.formatting_.concat(t);var i=t.reduce((function(e,t){return e+"<"+t+">"}),"");this[this.mode_](e,i);},ke.prototype.clearFormatting=function(e){if(this.formatting_.length){var t=this.formatting_.reverse().reduce((function(e,t){return e+"</"+t+">"}),"");this.formatting_=[],this[this.mode_](e,t);}},ke.prototype.popOn=function(e,t){var i=this.nonDisplayed_[this.row_];i+=t,this.nonDisplayed_[this.row_]=i;},ke.prototype.rollUp=function(e,t){var i=this.displayed_[this.row_];i+=t,this.displayed_[this.row_]=i;},ke.prototype.shiftRowsUp_=function(){var e;for(e=0;e<this.topRow_;e++)this.displayed_[e]="";for(e=this.row_+1;e<15;e++)this.displayed_[e]="";for(e=this.topRow_;e<this.row_;e++)this.displayed_[e]=this.displayed_[e+1];this.displayed_[this.row_]="";},ke.prototype.paintOn=function(e,t){var i=this.displayed_[this.row_];i+=t,this.displayed_[this.row_]=i;};var Oe={CaptionStream:Ie,Cea608Stream:ke},Ue={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},Ce=function(e,t){var i=1;for(e>t&&(i=-1);Math.abs(t-e)>4294967296;)e+=8589934592*i;return e},Pe=function e(t){var i,n;e.prototype.init.call(this),this.type_=t||"shared",this.push=function(e){"shared"!==this.type_&&e.type!==this.type_||(void 0===n&&(n=e.dts),e.dts=Ce(e.dts,n),e.pts=Ce(e.pts,n),i=e.dts,this.trigger("data",e));},this.flush=function(){n=i,this.trigger("done");},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline");},this.discontinuity=function(){n=void 0,i=void 0;},this.reset=function(){this.discontinuity(),this.trigger("reset");};};Pe.prototype=new W;var De,xe=Pe,Re=function(e,t,i){var n,r="";for(n=t;n<i;n++)r+="%"+("00"+e[n].toString(16)).slice(-2);return r},Me=function(e,t,i){return decodeURIComponent(Re(e,t,i))},Be=function(e){return e[0]<<21|e[1]<<14|e[2]<<7|e[3]},Fe={TXXX:function(e){var t;if(3===e.data[0]){for(t=1;t<e.data.length;t++)if(0===e.data[t]){e.description=Me(e.data,1,t),e.value=Me(e.data,t+1,e.data.length).replace(/\0*$/,"");break}e.data=e.value;}},WXXX:function(e){var t;if(3===e.data[0])for(t=1;t<e.data.length;t++)if(0===e.data[t]){e.description=Me(e.data,1,t),e.url=Me(e.data,t+1,e.data.length);break}},PRIV:function(e){var t,i;for(t=0;t<e.data.length;t++)if(0===e.data[t]){e.owner=(i=e.data,unescape(Re(i,0,t)));break}e.privateData=e.data.subarray(t+1),e.data=e.privateData;}};(De=function(e){var t,i={debug:!(!e||!e.debug),descriptor:e&&e.descriptor},n=0,r=[],a=0;if(De.prototype.init.call(this),this.dispatchType=Ue.METADATA_STREAM_TYPE.toString(16),i.descriptor)for(t=0;t<i.descriptor.length;t++)this.dispatchType+=("00"+i.descriptor[t].toString(16)).slice(-2);this.push=function(e){var t,s,o,u,d;if("timed-metadata"===e.type)if(e.dataAlignmentIndicator&&(a=0,r.length=0),0===r.length&&(e.data.length<10||e.data[0]!=="I".charCodeAt(0)||e.data[1]!=="D".charCodeAt(0)||e.data[2]!=="3".charCodeAt(0)))i.debug&&console.log("Skipping unrecognized metadata packet");else if(r.push(e),a+=e.data.byteLength,1===r.length&&(n=Be(e.data.subarray(6,10)),n+=10),!(a<n)){for(t={data:new Uint8Array(n),frames:[],pts:r[0].pts,dts:r[0].dts},d=0;d<n;)t.data.set(r[0].data.subarray(0,n-d),d),d+=r[0].data.byteLength,a-=r[0].data.byteLength,r.shift();s=10,64&t.data[5]&&(s+=4,s+=Be(t.data.subarray(10,14)),n-=Be(t.data.subarray(16,20)));do{if((o=Be(t.data.subarray(s+4,s+8)))<1)return console.log("Malformed ID3 frame encountered. Skipping metadata parsing.");if((u={id:String.fromCharCode(t.data[s],t.data[s+1],t.data[s+2],t.data[s+3]),data:t.data.subarray(s+10,s+o+10)}).key=u.id,Fe[u.id]&&(Fe[u.id](u),"com.apple.streaming.transportStreamTimestamp"===u.owner)){var l=u.data,h=(1&l[3])<<30|l[4]<<22|l[5]<<14|l[6]<<6|l[7]>>>2;h*=4,h+=3&l[7],u.timeStamp=h,void 0===t.pts&&void 0===t.dts&&(t.pts=u.timeStamp,t.dts=u.timeStamp),this.trigger("timestamp",u);}t.frames.push(u),s+=10,s+=o;}while(s<n);this.trigger("data",t);}};}).prototype=new W;var Ne,qe,Ve,We=De,He=xe;(Ne=function(){var e=new Uint8Array(188),t=0;Ne.prototype.init.call(this),this.push=function(i){var n,r=0,a=188;for(t?((n=new Uint8Array(i.byteLength+t)).set(e.subarray(0,t)),n.set(i,t),t=0):n=i;a<n.byteLength;)71!==n[r]||71!==n[a]?(r++,a++):(this.trigger("data",n.subarray(r,a)),r+=188,a+=188);r<n.byteLength&&(e.set(n.subarray(r),0),t=n.byteLength-r);},this.flush=function(){188===t&&71===e[0]&&(this.trigger("data",e),t=0),this.trigger("done");},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline");},this.reset=function(){t=0,this.trigger("reset");};}).prototype=new W,(qe=function(){var e,t,i,n;qe.prototype.init.call(this),n=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,e=function(e,n){var r=0;n.payloadUnitStartIndicator&&(r+=e[r]+1),"pat"===n.type?t(e.subarray(r),n):i(e.subarray(r),n);},t=function(e,t){t.section_number=e[7],t.last_section_number=e[8],n.pmtPid=(31&e[10])<<8|e[11],t.pmtPid=n.pmtPid;},i=function(e,t){var i,r;if(1&e[5]){for(n.programMapTable={video:null,audio:null,"timed-metadata":{}},i=3+((15&e[1])<<8|e[2])-4,r=12+((15&e[10])<<8|e[11]);r<i;){var a=e[r],s=(31&e[r+1])<<8|e[r+2];a===Ue.H264_STREAM_TYPE&&null===n.programMapTable.video?n.programMapTable.video=s:a===Ue.ADTS_STREAM_TYPE&&null===n.programMapTable.audio?n.programMapTable.audio=s:a===Ue.METADATA_STREAM_TYPE&&(n.programMapTable["timed-metadata"][s]=a),r+=5+((15&e[r+3])<<8|e[r+4]);}t.programMapTable=n.programMapTable;}},this.push=function(t){var i={},n=4;if(i.payloadUnitStartIndicator=!!(64&t[1]),i.pid=31&t[1],i.pid<<=8,i.pid|=t[2],(48&t[3])>>>4>1&&(n+=t[n]+1),0===i.pid)i.type="pat",e(t.subarray(n),i),this.trigger("data",i);else if(i.pid===this.pmtPid)for(i.type="pmt",e(t.subarray(n),i),this.trigger("data",i);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else void 0===this.programMapTable?this.packetsWaitingForPmt.push([t,n,i]):this.processPes_(t,n,i);},this.processPes_=function(e,t,i){i.pid===this.programMapTable.video?i.streamType=Ue.H264_STREAM_TYPE:i.pid===this.programMapTable.audio?i.streamType=Ue.ADTS_STREAM_TYPE:i.streamType=this.programMapTable["timed-metadata"][i.pid],i.type="pes",i.data=e.subarray(t),this.trigger("data",i);};}).prototype=new W,qe.STREAM_TYPES={h264:27,adts:15},(Ve=function(){var e,t=this,i={data:[],size:0},n={data:[],size:0},r={data:[],size:0},a=function(e,i,n){var r,a,s=new Uint8Array(e.size),o={type:i},u=0,d=0;if(e.data.length&&!(e.size<9)){for(o.trackId=e.data[0].pid,u=0;u<e.data.length;u++)a=e.data[u],s.set(a.data,d),d+=a.data.byteLength;var l,h,c;l=s,(h=o).packetLength=6+(l[4]<<8|l[5]),h.dataAlignmentIndicator=0!=(4&l[6]),192&(c=l[7])&&(h.pts=(14&l[9])<<27|(255&l[10])<<20|(254&l[11])<<12|(255&l[12])<<5|(254&l[13])>>>3,h.pts*=4,h.pts+=(6&l[13])>>>1,h.dts=h.pts,64&c&&(h.dts=(14&l[14])<<27|(255&l[15])<<20|(254&l[16])<<12|(255&l[17])<<5|(254&l[18])>>>3,h.dts*=4,h.dts+=(6&l[18])>>>1)),h.data=l.subarray(9+l[8]),r="video"===i||o.packetLength<=e.size,(n||r)&&(e.size=0,e.data.length=0),r&&t.trigger("data",o);}};Ve.prototype.init.call(this),this.push=function(s){({pat:function(){},pes:function(){var e,t;switch(s.streamType){case Ue.H264_STREAM_TYPE:e=i,t="video";break;case Ue.ADTS_STREAM_TYPE:e=n,t="audio";break;case Ue.METADATA_STREAM_TYPE:e=r,t="timed-metadata";break;default:return}s.payloadUnitStartIndicator&&a(e,t,!0),e.data.push(s),e.size+=s.data.byteLength;},pmt:function(){var i={type:"metadata",tracks:[]};null!==(e=s.programMapTable).video&&i.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+e.video,codec:"avc",type:"video"}),null!==e.audio&&i.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+e.audio,codec:"adts",type:"audio"}),t.trigger("data",i);}})[s.type]();},this.reset=function(){i.size=0,i.data.length=0,n.size=0,n.data.length=0,this.trigger("reset");},this.flushStreams_=function(){a(i,"video"),a(n,"audio"),a(r,"timed-metadata");},this.flush=function(){this.flushStreams_(),this.trigger("done");};}).prototype=new W;var Ge={PAT_PID:0,MP2T_PACKET_LENGTH:188,TransportPacketStream:Ne,TransportParseStream:qe,ElementaryStream:Ve,TimestampRolloverStream:He,CaptionStream:Oe.CaptionStream,Cea608Stream:Oe.Cea608Stream,MetadataStream:We};for(var je in Ue)Ue.hasOwnProperty(je)&&(Ge[je]=Ue[je]);var ze,Xe=Ge,Qe=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];(ze=function(e){var t,i=0;ze.prototype.init.call(this),this.push=function(n){var r,a,s,o,u,d,l=0;if(e||(i=0),"audio"===n.type)for(t?(o=t,(t=new Uint8Array(o.byteLength+n.data.byteLength)).set(o),t.set(n.data,o.byteLength)):t=n.data;l+5<t.length;)if(255===t[l]&&240==(246&t[l+1])){if(a=2*(1&~t[l+1]),r=(3&t[l+3])<<11|t[l+4]<<3|(224&t[l+5])>>5,d=9e4*(u=1024*(1+(3&t[l+6])))/Qe[(60&t[l+2])>>>2],s=l+r,t.byteLength<s)return;if(this.trigger("data",{pts:n.pts+i*d,dts:n.dts+i*d,sampleCount:u,audioobjecttype:1+(t[l+2]>>>6&3),channelcount:(1&t[l+2])<<2|(192&t[l+3])>>>6,samplerate:Qe[(60&t[l+2])>>>2],samplingfrequencyindex:(60&t[l+2])>>>2,samplesize:16,data:t.subarray(l+7+a,s)}),i++,t.byteLength===s)return void(t=void 0);t=t.subarray(s);}else l++;},this.flush=function(){i=0,this.trigger("done");},this.reset=function(){t=void 0,this.trigger("reset");},this.endTimeline=function(){t=void 0,this.trigger("endedtimeline");};}).prototype=new W;var Ye,Ke,$e,Je=ze,Ze=function(e){var t=e.byteLength,i=0,n=0;this.length=function(){return 8*t},this.bitsAvailable=function(){return 8*t+n},this.loadWord=function(){var r=e.byteLength-t,a=new Uint8Array(4),s=Math.min(4,t);if(0===s)throw new Error("no bytes available");a.set(e.subarray(r,r+s)),i=new DataView(a.buffer).getUint32(0),n=8*s,t-=s;},this.skipBits=function(e){var r;n>e?(i<<=e,n-=e):(e-=n,e-=8*(r=Math.floor(e/8)),t-=r,this.loadWord(),i<<=e,n-=e);},this.readBits=function(e){var r=Math.min(n,e),a=i>>>32-r;return (n-=r)>0?i<<=r:t>0&&this.loadWord(),(r=e-r)>0?a<<r|this.readBits(r):a},this.skipLeadingZeros=function(){var e;for(e=0;e<n;++e)if(0!=(i&2147483648>>>e))return i<<=e,n-=e,e;return this.loadWord(),e+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros());},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros());},this.readUnsignedExpGolomb=function(){var e=this.skipLeadingZeros();return this.readBits(e+1)-1},this.readExpGolomb=function(){var e=this.readUnsignedExpGolomb();return 1&e?1+e>>>1:-1*(e>>>1)},this.readBoolean=function(){return 1===this.readBits(1)},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord();};(Ke=function(){var e,t,i=0;Ke.prototype.init.call(this),this.push=function(n){var r;t?((r=new Uint8Array(t.byteLength+n.data.byteLength)).set(t),r.set(n.data,t.byteLength),t=r):t=n.data;for(var a=t.byteLength;i<a-3;i++)if(1===t[i+2]){e=i+5;break}for(;e<a;)switch(t[e]){case 0:if(0!==t[e-1]){e+=2;break}if(0!==t[e-2]){e++;break}i+3!==e-2&&this.trigger("data",t.subarray(i+3,e-2));do{e++;}while(1!==t[e]&&e<a);i=e-2,e+=3;break;case 1:if(0!==t[e-1]||0!==t[e-2]){e+=3;break}this.trigger("data",t.subarray(i+3,e-2)),i=e-2,e+=3;break;default:e+=3;}t=t.subarray(i),e-=i,i=0;},this.reset=function(){t=null,i=0,this.trigger("reset");},this.flush=function(){t&&t.byteLength>3&&this.trigger("data",t.subarray(i+3)),t=null,i=0,this.trigger("done");},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline");};}).prototype=new W,$e={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},(Ye=function(){var e,t,i,n,r,a,s,o=new Ke;Ye.prototype.init.call(this),e=this,this.push=function(e){"video"===e.type&&(t=e.trackId,i=e.pts,n=e.dts,o.push(e));},o.on("data",(function(s){var o={trackId:t,pts:i,dts:n,data:s};switch(31&s[0]){case 5:o.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:o.nalUnitType="sei_rbsp",o.escapedRBSP=r(s.subarray(1));break;case 7:o.nalUnitType="seq_parameter_set_rbsp",o.escapedRBSP=r(s.subarray(1)),o.config=a(o.escapedRBSP);break;case 8:o.nalUnitType="pic_parameter_set_rbsp";break;case 9:o.nalUnitType="access_unit_delimiter_rbsp";}e.trigger("data",o);})),o.on("done",(function(){e.trigger("done");})),o.on("partialdone",(function(){e.trigger("partialdone");})),o.on("reset",(function(){e.trigger("reset");})),o.on("endedtimeline",(function(){e.trigger("endedtimeline");})),this.flush=function(){o.flush();},this.partialFlush=function(){o.partialFlush();},this.reset=function(){o.reset();},this.endTimeline=function(){o.endTimeline();},s=function(e,t){var i,n=8,r=8;for(i=0;i<e;i++)0!==r&&(r=(n+t.readExpGolomb()+256)%256),n=0===r?n:r;},r=function(e){for(var t,i,n=e.byteLength,r=[],a=1;a<n-2;)0===e[a]&&0===e[a+1]&&3===e[a+2]?(r.push(a+2),a+=2):a++;if(0===r.length)return e;t=n-r.length,i=new Uint8Array(t);var s=0;for(a=0;a<t;s++,a++)s===r[0]&&(s++,r.shift()),i[a]=e[s];return i},a=function(e){var t,i,n,r,a,o,u,d,l,h,c,f,m,p=0,g=0,y=0,_=0,v=1;if(i=(t=new Ze(e)).readUnsignedByte(),r=t.readUnsignedByte(),n=t.readUnsignedByte(),t.skipUnsignedExpGolomb(),$e[i]&&(3===(a=t.readUnsignedExpGolomb())&&t.skipBits(1),t.skipUnsignedExpGolomb(),t.skipUnsignedExpGolomb(),t.skipBits(1),t.readBoolean()))for(c=3!==a?8:12,m=0;m<c;m++)t.readBoolean()&&s(m<6?16:64,t);if(t.skipUnsignedExpGolomb(),0===(o=t.readUnsignedExpGolomb()))t.readUnsignedExpGolomb();else if(1===o)for(t.skipBits(1),t.skipExpGolomb(),t.skipExpGolomb(),u=t.readUnsignedExpGolomb(),m=0;m<u;m++)t.skipExpGolomb();if(t.skipUnsignedExpGolomb(),t.skipBits(1),d=t.readUnsignedExpGolomb(),l=t.readUnsignedExpGolomb(),0===(h=t.readBits(1))&&t.skipBits(1),t.skipBits(1),t.readBoolean()&&(p=t.readUnsignedExpGolomb(),g=t.readUnsignedExpGolomb(),y=t.readUnsignedExpGolomb(),_=t.readUnsignedExpGolomb()),t.readBoolean()&&t.readBoolean()){switch(t.readUnsignedByte()){case 1:f=[1,1];break;case 2:f=[12,11];break;case 3:f=[10,11];break;case 4:f=[16,11];break;case 5:f=[40,33];break;case 6:f=[24,11];break;case 7:f=[20,11];break;case 8:f=[32,11];break;case 9:f=[80,33];break;case 10:f=[18,11];break;case 11:f=[15,11];break;case 12:f=[64,33];break;case 13:f=[160,99];break;case 14:f=[4,3];break;case 15:f=[3,2];break;case 16:f=[2,1];break;case 255:f=[t.readUnsignedByte()<<8|t.readUnsignedByte(),t.readUnsignedByte()<<8|t.readUnsignedByte()];}f&&(v=f[0]/f[1]);}return {profileIdc:i,levelIdc:n,profileCompatibility:r,width:Math.ceil((16*(d+1)-2*p-2*g)*v),height:(2-h)*(l+1)*16-2*y-2*_,sarRatio:f}};}).prototype=new W;var et,tt={H264Stream:Ye,NalByteStream:Ke},it=function(e,t){var i=e[t+6]<<21|e[t+7]<<14|e[t+8]<<7|e[t+9];return i=i>=0?i:0,(16&e[t+5])>>4?i+20:i+10},nt=function(e){var t=function e(t,i){return t.length-i<10||t[i]!=="I".charCodeAt(0)||t[i+1]!=="D".charCodeAt(0)||t[i+2]!=="3".charCodeAt(0)?i:e(t,i+=it(t,i))}(e,0);return e.length>=t+2&&255==(255&e[t])&&240==(240&e[t+1])&&16==(22&e[t+1])},rt=it,at=function(e,t){var i=(224&e[t+5])>>5,n=e[t+4]<<3;return 6144&e[t+3]|n|i};(et=function(){var e=new Uint8Array,t=0;et.prototype.init.call(this),this.setTimestamp=function(e){t=e;},this.push=function(i){var n,r,a,s,o=0,u=0;for(e.length?(s=e.length,(e=new Uint8Array(i.byteLength+s)).set(e.subarray(0,s)),e.set(i,s)):e=i;e.length-u>=3;)if(e[u]!=="I".charCodeAt(0)||e[u+1]!=="D".charCodeAt(0)||e[u+2]!=="3".charCodeAt(0))if(255!=(255&e[u])||240!=(240&e[u+1]))u++;else {if(e.length-u<7)break;if(u+(o=at(e,u))>e.length)break;a={type:"audio",data:e.subarray(u,u+o),pts:t,dts:t},this.trigger("data",a),u+=o;}else {if(e.length-u<10)break;if(u+(o=rt(e,u))>e.length)break;r={type:"timed-metadata",data:e.subarray(u,u+o)},this.trigger("data",r),u+=o;}n=e.length-u,e=n>0?e.subarray(u):new Uint8Array;},this.reset=function(){e=new Uint8Array,this.trigger("reset");},this.endTimeline=function(){e=new Uint8Array,this.trigger("endedtimeline");};}).prototype=new W;var st,ot,ut,dt,lt=et,ht=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],ct=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],ft=tt.H264Stream,mt=nt,pt=function(e,t){var i;if(e.length!==t.length)return !1;for(i=0;i<e.length;i++)if(e[i]!==t[i])return !1;return !0},gt=function(e,t,i,n,r,a){return {start:{dts:e,pts:e+(i-t)},end:{dts:e+(n-t),pts:e+(r-i)},prependedContentDuration:a,baseMediaDecodeTime:e}};(ot=function(e,t){var i=[],n=0,r=0,a=0,s=1/0;t=t||{},ot.prototype.init.call(this),this.push=function(t){Se(e,t),e&&ht.forEach((function(i){e[i]=t[i];})),i.push(t);},this.setEarliestDts=function(e){r=e;},this.setVideoBaseMediaDecodeTime=function(e){s=e;},this.setAudioAppendStart=function(e){a=e;},this.flush=function(){var o,u,d,l,h;0!==i.length?(o=ye(i,e,r),e.baseMediaDecodeTime=Te(e,t.keepOriginalTimestamps),ge(e,o,a,s),e.samples=_e(o),d=J(ve(o)),i=[],u=Z(n,[e]),l=new Uint8Array(u.byteLength+d.byteLength),n++,l.set(u),l.set(d,u.byteLength),be(e),h=Math.ceil(9216e4/e.samplerate),o.length&&this.trigger("timingInfo",{start:o[0].pts,end:o[0].pts+o.length*h}),this.trigger("data",{track:e,boxes:l}),this.trigger("done","AudioSegmentStream")):this.trigger("done","AudioSegmentStream");},this.reset=function(){be(e),i=[],this.trigger("reset");};}).prototype=new W,(st=function(e,t){var i,n,r=0,a=[],s=[];t=t||{},st.prototype.init.call(this),delete e.minPTS,this.gopCache_=[],this.push=function(t){Se(e,t),"seq_parameter_set_rbsp"!==t.nalUnitType||i||(i=t.config,e.sps=[t.data],ct.forEach((function(t){e[t]=i[t];}),this)),"pic_parameter_set_rbsp"!==t.nalUnitType||n||(n=t.data,e.pps=[t.data]),a.push(t);},this.flush=function(){for(var i,n,o,u,d,l,h,c,f=0;a.length&&"access_unit_delimiter_rbsp"!==a[0].nalUnitType;)a.shift();if(0===a.length)return this.resetStream_(),void this.trigger("done","VideoSegmentStream");if(i=ie(a),(o=ne(i))[0][0].keyFrame||((n=this.getGopForFusion_(a[0],e))?(f=n.duration,o.unshift(n),o.byteLength+=n.byteLength,o.nalCount+=n.nalCount,o.pts=n.pts,o.dts=n.dts,o.duration+=n.duration):o=re(o)),s.length){var m;if(!(m=t.alignGopsAtEnd?this.alignGopsAtEnd_(o):this.alignGopsAtStart_(o)))return this.gopCache_.unshift({gop:o.pop(),pps:e.pps,sps:e.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),a=[],this.resetStream_(),void this.trigger("done","VideoSegmentStream");be(e),o=m;}Se(e,o),e.samples=function(e,t){var i,n,r,a,s,o=t||0,u=[];for(i=0;i<e.length;i++)for(a=e[i],n=0;n<a.length;n++)s=a[n],o+=(r=te(s,o)).size,u.push(r);return u}(o),d=J(function(e){var t,i,n,r,a,s,o=0,u=e.byteLength,d=e.nalCount,l=new Uint8Array(u+4*d),h=new DataView(l.buffer);for(t=0;t<e.length;t++)for(r=e[t],i=0;i<r.length;i++)for(a=r[i],n=0;n<a.length;n++)s=a[n],h.setUint32(o,s.data.byteLength),o+=4,l.set(s.data,o),o+=s.data.byteLength;return l}(o)),e.baseMediaDecodeTime=Te(e,t.keepOriginalTimestamps),this.trigger("processedGopsInfo",o.map((function(e){return {pts:e.pts,dts:e.dts,byteLength:e.byteLength}}))),h=o[0],c=o[o.length-1],this.trigger("segmentTimingInfo",gt(e.baseMediaDecodeTime,h.dts,h.pts,c.dts+c.duration,c.pts+c.duration,f)),this.trigger("timingInfo",{start:o[0].pts,end:o[o.length-1].pts+o[o.length-1].duration}),this.gopCache_.unshift({gop:o.pop(),pps:e.pps,sps:e.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),a=[],this.trigger("baseMediaDecodeTime",e.baseMediaDecodeTime),this.trigger("timelineStartInfo",e.timelineStartInfo),u=Z(r,[e]),l=new Uint8Array(u.byteLength+d.byteLength),r++,l.set(u),l.set(d,u.byteLength),this.trigger("data",{track:e,boxes:l}),this.resetStream_(),this.trigger("done","VideoSegmentStream");},this.reset=function(){this.resetStream_(),a=[],this.gopCache_.length=0,s.length=0,this.trigger("reset");},this.resetStream_=function(){be(e),i=void 0,n=void 0;},this.getGopForFusion_=function(t){var i,n,r,a,s,o=1/0;for(s=0;s<this.gopCache_.length;s++)r=(a=this.gopCache_[s]).gop,e.pps&&pt(e.pps[0],a.pps[0])&&e.sps&&pt(e.sps[0],a.sps[0])&&(r.dts<e.timelineStartInfo.dts||(i=t.dts-r.dts-r.duration)>=-1e4&&i<=45e3&&(!n||o>i)&&(n=a,o=i));return n?n.gop:null},this.alignGopsAtStart_=function(e){var t,i,n,r,a,o,u,d;for(a=e.byteLength,o=e.nalCount,u=e.duration,t=i=0;t<s.length&&i<e.length&&(n=s[t],r=e[i],n.pts!==r.pts);)r.pts>n.pts?t++:(i++,a-=r.byteLength,o-=r.nalCount,u-=r.duration);return 0===i?e:i===e.length?null:((d=e.slice(i)).byteLength=a,d.duration=u,d.nalCount=o,d.pts=d[0].pts,d.dts=d[0].dts,d)},this.alignGopsAtEnd_=function(e){var t,i,n,r,a,o,u;for(t=s.length-1,i=e.length-1,a=null,o=!1;t>=0&&i>=0;){if(n=s[t],r=e[i],n.pts===r.pts){o=!0;break}n.pts>r.pts?t--:(t===s.length-1&&(a=i),i--);}if(!o&&null===a)return null;if(0===(u=o?i:a))return e;var d=e.slice(u),l=d.reduce((function(e,t){return e.byteLength+=t.byteLength,e.duration+=t.duration,e.nalCount+=t.nalCount,e}),{byteLength:0,duration:0,nalCount:0});return d.byteLength=l.byteLength,d.duration=l.duration,d.nalCount=l.nalCount,d.pts=d[0].pts,d.dts=d[0].dts,d},this.alignGopsWith=function(e){s=e;};}).prototype=new W,(dt=function(e,t){this.numberOfTracks=0,this.metadataStream=t,void 0!==(e=e||{}).remux?this.remuxTracks=!!e.remux:this.remuxTracks=!0,"boolean"==typeof e.keepOriginalTimestamps?this.keepOriginalTimestamps=e.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,dt.prototype.init.call(this),this.push=function(e){return e.text?this.pendingCaptions.push(e):e.frames?this.pendingMetadata.push(e):(this.pendingTracks.push(e.track),this.pendingBytes+=e.boxes.byteLength,"video"===e.track.type&&(this.videoTrack=e.track,this.pendingBoxes.push(e.boxes)),void("audio"===e.track.type&&(this.audioTrack=e.track,this.pendingBoxes.unshift(e.boxes))))};}).prototype=new W,dt.prototype.flush=function(e){var t,i,n,r,a=0,s={captions:[],captionStreams:{},metadata:[],info:{}},o=0;if(this.pendingTracks.length<this.numberOfTracks){if("VideoSegmentStream"!==e&&"AudioSegmentStream"!==e)return;if(this.remuxTracks)return;if(0===this.pendingTracks.length)return this.emittedTracks++,void(this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0))}if(this.videoTrack?(o=this.videoTrack.timelineStartInfo.pts,ct.forEach((function(e){s.info[e]=this.videoTrack[e];}),this)):this.audioTrack&&(o=this.audioTrack.timelineStartInfo.pts,ht.forEach((function(e){s.info[e]=this.audioTrack[e];}),this)),this.videoTrack||this.audioTrack){for(1===this.pendingTracks.length?s.type=this.pendingTracks[0].type:s.type="combined",this.emittedTracks+=this.pendingTracks.length,n=ee(this.pendingTracks),s.initSegment=new Uint8Array(n.byteLength),s.initSegment.set(n),s.data=new Uint8Array(this.pendingBytes),r=0;r<this.pendingBoxes.length;r++)s.data.set(this.pendingBoxes[r],a),a+=this.pendingBoxes[r].byteLength;for(r=0;r<this.pendingCaptions.length;r++)(t=this.pendingCaptions[r]).startTime=fe(t.startPts,o,this.keepOriginalTimestamps),t.endTime=fe(t.endPts,o,this.keepOriginalTimestamps),s.captionStreams[t.stream]=!0,s.captions.push(t);for(r=0;r<this.pendingMetadata.length;r++)(i=this.pendingMetadata[r]).cueTime=fe(i.pts,o,this.keepOriginalTimestamps),s.metadata.push(i);for(s.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",s),r=0;r<s.captions.length;r++)t=s.captions[r],this.trigger("caption",t);for(r=0;r<s.metadata.length;r++)i=s.metadata[r],this.trigger("id3Frame",i);}this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0);},dt.prototype.setRemux=function(e){this.remuxTracks=e;},(ut=function(e){var t,i,n=this,r=!0;ut.prototype.init.call(this),e=e||{},this.baseMediaDecodeTime=e.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var r={};this.transmuxPipeline_=r,r.type="aac",r.metadataStream=new Xe.MetadataStream,r.aacStream=new lt,r.audioTimestampRolloverStream=new Xe.TimestampRolloverStream("audio"),r.timedMetadataTimestampRolloverStream=new Xe.TimestampRolloverStream("timed-metadata"),r.adtsStream=new Je,r.coalesceStream=new dt(e,r.metadataStream),r.headOfPipeline=r.aacStream,r.aacStream.pipe(r.audioTimestampRolloverStream).pipe(r.adtsStream),r.aacStream.pipe(r.timedMetadataTimestampRolloverStream).pipe(r.metadataStream).pipe(r.coalesceStream),r.metadataStream.on("timestamp",(function(e){r.aacStream.setTimestamp(e.timeStamp);})),r.aacStream.on("data",(function(a){"timed-metadata"!==a.type&&"audio"!==a.type||r.audioSegmentStream||(i=i||{timelineStartInfo:{baseMediaDecodeTime:n.baseMediaDecodeTime},codec:"adts",type:"audio"},r.coalesceStream.numberOfTracks++,r.audioSegmentStream=new ot(i,e),r.audioSegmentStream.on("timingInfo",n.trigger.bind(n,"audioTimingInfo")),r.adtsStream.pipe(r.audioSegmentStream).pipe(r.coalesceStream),n.trigger("trackinfo",{hasAudio:!!i,hasVideo:!!t}));})),r.coalesceStream.on("data",this.trigger.bind(this,"data")),r.coalesceStream.on("done",this.trigger.bind(this,"done"));},this.setupTsPipeline=function(){var r={};this.transmuxPipeline_=r,r.type="ts",r.metadataStream=new Xe.MetadataStream,r.packetStream=new Xe.TransportPacketStream,r.parseStream=new Xe.TransportParseStream,r.elementaryStream=new Xe.ElementaryStream,r.timestampRolloverStream=new Xe.TimestampRolloverStream,r.adtsStream=new Je,r.h264Stream=new ft,r.captionStream=new Xe.CaptionStream,r.coalesceStream=new dt(e,r.metadataStream),r.headOfPipeline=r.packetStream,r.packetStream.pipe(r.parseStream).pipe(r.elementaryStream).pipe(r.timestampRolloverStream),r.timestampRolloverStream.pipe(r.h264Stream),r.timestampRolloverStream.pipe(r.adtsStream),r.timestampRolloverStream.pipe(r.metadataStream).pipe(r.coalesceStream),r.h264Stream.pipe(r.captionStream).pipe(r.coalesceStream),r.elementaryStream.on("data",(function(a){var s;if("metadata"===a.type){for(s=a.tracks.length;s--;)t||"video"!==a.tracks[s].type?i||"audio"!==a.tracks[s].type||((i=a.tracks[s]).timelineStartInfo.baseMediaDecodeTime=n.baseMediaDecodeTime):(t=a.tracks[s]).timelineStartInfo.baseMediaDecodeTime=n.baseMediaDecodeTime;t&&!r.videoSegmentStream&&(r.coalesceStream.numberOfTracks++,r.videoSegmentStream=new st(t,e),r.videoSegmentStream.on("timelineStartInfo",(function(t){i&&!e.keepOriginalTimestamps&&(i.timelineStartInfo=t,r.audioSegmentStream.setEarliestDts(t.dts-n.baseMediaDecodeTime));})),r.videoSegmentStream.on("processedGopsInfo",n.trigger.bind(n,"gopInfo")),r.videoSegmentStream.on("segmentTimingInfo",n.trigger.bind(n,"videoSegmentTimingInfo")),r.videoSegmentStream.on("baseMediaDecodeTime",(function(e){i&&r.audioSegmentStream.setVideoBaseMediaDecodeTime(e);})),r.videoSegmentStream.on("timingInfo",n.trigger.bind(n,"videoTimingInfo")),r.h264Stream.pipe(r.videoSegmentStream).pipe(r.coalesceStream)),i&&!r.audioSegmentStream&&(r.coalesceStream.numberOfTracks++,r.audioSegmentStream=new ot(i,e),r.audioSegmentStream.on("timingInfo",n.trigger.bind(n,"audioTimingInfo")),r.adtsStream.pipe(r.audioSegmentStream).pipe(r.coalesceStream)),n.trigger("trackinfo",{hasAudio:!!i,hasVideo:!!t});}})),r.coalesceStream.on("data",this.trigger.bind(this,"data")),r.coalesceStream.on("id3Frame",(function(e){e.dispatchType=r.metadataStream.dispatchType,n.trigger("id3Frame",e);})),r.coalesceStream.on("caption",this.trigger.bind(this,"caption")),r.coalesceStream.on("done",this.trigger.bind(this,"done"));},this.setBaseMediaDecodeTime=function(n){var r=this.transmuxPipeline_;e.keepOriginalTimestamps||(this.baseMediaDecodeTime=n),i&&(i.timelineStartInfo.dts=void 0,i.timelineStartInfo.pts=void 0,be(i),r.audioTimestampRolloverStream&&r.audioTimestampRolloverStream.discontinuity()),t&&(r.videoSegmentStream&&(r.videoSegmentStream.gopCache_=[]),t.timelineStartInfo.dts=void 0,t.timelineStartInfo.pts=void 0,be(t),r.captionStream.reset()),r.timestampRolloverStream&&r.timestampRolloverStream.discontinuity();},this.setAudioAppendStart=function(e){i&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(e);},this.setRemux=function(t){var i=this.transmuxPipeline_;e.remux=t,i&&i.coalesceStream&&i.coalesceStream.setRemux(t);},this.alignGopsWith=function(e){t&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(e);},this.push=function(e){if(r){var t=mt(e);t&&"aac"!==this.transmuxPipeline_.type?this.setupAacPipeline():t||"ts"===this.transmuxPipeline_.type||this.setupTsPipeline(),r=!1;}this.transmuxPipeline_.headOfPipeline.push(e);},this.flush=function(){r=!0,this.transmuxPipeline_.headOfPipeline.flush();},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline();},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset();},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset();};}).prototype=new W;var yt={Transmuxer:ut,VideoSegmentStream:st,AudioSegmentStream:ot,AUDIO_PROPERTIES:ht,VIDEO_PROPERTIES:ct,generateVideoSegmentTimingInfo:gt}.Transmuxer,_t={Adts:Je,h264:tt},vt=function e(t,i){var n=[],r=0,a=0,s=0,o=1/0,u=null,d=null;i=i||{},e.prototype.init.call(this),this.push=function(e){Se(t,e),t&&ht.forEach((function(i){t[i]=e[i];})),n.push(e);},this.setEarliestDts=function(e){a=e;},this.setVideoBaseMediaDecodeTime=function(e){o=e;},this.setAudioAppendStart=function(e){s=e;},this.processFrames_=function(){var e,l,h,c,f;0!==n.length&&0!==(e=ye(n,t,a)).length&&(t.baseMediaDecodeTime=Te(t,i.keepOriginalTimestamps),ge(t,e,s,o),t.samples=_e(e),h=J(ve(e)),n=[],l=Z(r,[t]),r++,t.initSegment=ee([t]),(c=new Uint8Array(l.byteLength+h.byteLength)).set(l),c.set(h,l.byteLength),be(t),null===u&&(d=u=e[0].pts),d+=e.length*(9216e4/t.samplerate),f={start:u},this.trigger("timingInfo",f),this.trigger("data",{track:t,boxes:c}));},this.flush=function(){this.processFrames_(),this.trigger("timingInfo",{start:u,end:d}),this.resetTiming_(),this.trigger("done","AudioSegmentStream");},this.partialFlush=function(){this.processFrames_(),this.trigger("partialdone","AudioSegmentStream");},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline","AudioSegmentStream");},this.resetTiming_=function(){be(t),u=null,d=null;},this.reset=function(){this.resetTiming_(),n=[],this.trigger("reset");};};vt.prototype=new W;var bt=vt,Tt=function e(t,i){var n,r,a,s=0,o=[],u=[],d=null,l=null,h=!0;i=i||{},e.prototype.init.call(this),this.push=function(e){Se(t,e),void 0===t.timelineStartInfo.dts&&(t.timelineStartInfo.dts=e.dts),"seq_parameter_set_rbsp"!==e.nalUnitType||n||(n=e.config,t.sps=[e.data],ct.forEach((function(e){t[e]=n[e];}),this)),"pic_parameter_set_rbsp"!==e.nalUnitType||r||(r=e.data,t.pps=[e.data]),o.push(e);},this.processNals_=function(e){var n;for(o=u.concat(o);o.length&&"access_unit_delimiter_rbsp"!==o[0].nalUnitType;)o.shift();if(0!==o.length){var r=ie(o);if(r.length)if(u=r[r.length-1],e&&(r.pop(),r.duration-=u.duration,r.nalCount-=u.length,r.byteLength-=u.byteLength),r.length){if(this.trigger("timelineStartInfo",t.timelineStartInfo),h){if(!(a=ne(r))[0][0].keyFrame){if(!(a=re(a))[0][0].keyFrame)return o=[].concat.apply([],r).concat(u),void(u=[]);(r=[].concat.apply([],a)).duration=a.duration;}h=!1;}for(null===d&&(d=r[0].pts,l=d),l+=r.duration,this.trigger("timingInfo",{start:d,end:l}),n=0;n<r.length;n++){var c=r[n];t.samples=ae(c);var f=J(se(c));be(t),Se(t,c),t.baseMediaDecodeTime=Te(t,i.keepOriginalTimestamps);var m=Z(s,[t]);s++,t.initSegment=ee([t]);var p=new Uint8Array(m.byteLength+f.byteLength);p.set(m),p.set(f,m.byteLength),this.trigger("data",{track:t,boxes:p,sequence:s,videoFrameDts:c.dts,videoFramePts:c.pts});}o=[];}else o=[];}},this.resetTimingAndConfig_=function(){n=void 0,r=void 0,d=null,l=null;},this.partialFlush=function(){this.processNals_(!0),this.trigger("partialdone","VideoSegmentStream");},this.flush=function(){this.processNals_(!1),this.resetTimingAndConfig_(),this.trigger("done","VideoSegmentStream");},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline","VideoSegmentStream");},this.reset=function(){this.resetTimingAndConfig_(),u=[],o=[],h=!0,this.trigger("reset");};};Tt.prototype=new W;var St=Tt,It=nt,At=function(e){return e.prototype=new W,e.prototype.init.call(e),e},Lt=function(e,t){e.on("data",t.trigger.bind(t,"data")),e.on("done",t.trigger.bind(t,"done")),e.on("partialdone",t.trigger.bind(t,"partialdone")),e.on("endedtimeline",t.trigger.bind(t,"endedtimeline")),e.on("audioTimingInfo",t.trigger.bind(t,"audioTimingInfo")),e.on("videoTimingInfo",t.trigger.bind(t,"videoTimingInfo")),e.on("trackinfo",t.trigger.bind(t,"trackinfo")),e.on("id3Frame",(function(i){i.dispatchType=e.metadataStream.dispatchType,i.cueTime=le(i.pts),t.trigger("id3Frame",i);})),e.on("caption",(function(e){t.trigger("caption",e);}));},Et=function e(t){var i=null,n=!0;t=t||{},e.prototype.init.call(this),t.baseMediaDecodeTime=t.baseMediaDecodeTime||0,this.push=function(e){if(n){var r=It(e);!r||i&&"aac"===i.type?r||i&&"ts"===i.type||(i=function(e){var t={type:"ts",tracks:{audio:null,video:null},packet:new Xe.TransportPacketStream,parse:new Xe.TransportParseStream,elementary:new Xe.ElementaryStream,timestampRollover:new Xe.TimestampRolloverStream,adts:new _t.Adts,h264:new _t.h264.H264Stream,captionStream:new Xe.CaptionStream,metadataStream:new Xe.MetadataStream};return t.headOfPipeline=t.packet,t.packet.pipe(t.parse).pipe(t.elementary).pipe(t.timestampRollover),t.timestampRollover.pipe(t.h264),t.h264.pipe(t.captionStream),t.timestampRollover.pipe(t.metadataStream),t.timestampRollover.pipe(t.adts),t.elementary.on("data",(function(i){if("metadata"===i.type){for(var n=0;n<i.tracks.length;n++)t.tracks[i.tracks[n].type]||(t.tracks[i.tracks[n].type]=i.tracks[n],t.tracks[i.tracks[n].type].timelineStartInfo.baseMediaDecodeTime=e.baseMediaDecodeTime);t.tracks.video&&!t.videoSegmentStream&&(t.videoSegmentStream=new St(t.tracks.video,e),t.videoSegmentStream.on("timelineStartInfo",(function(i){t.tracks.audio&&!e.keepOriginalTimestamps&&t.audioSegmentStream.setEarliestDts(i.dts-e.baseMediaDecodeTime);})),t.videoSegmentStream.on("timingInfo",t.trigger.bind(t,"videoTimingInfo")),t.videoSegmentStream.on("data",(function(e){t.trigger("data",{type:"video",data:e});})),t.videoSegmentStream.on("done",t.trigger.bind(t,"done")),t.videoSegmentStream.on("partialdone",t.trigger.bind(t,"partialdone")),t.videoSegmentStream.on("endedtimeline",t.trigger.bind(t,"endedtimeline")),t.h264.pipe(t.videoSegmentStream)),t.tracks.audio&&!t.audioSegmentStream&&(t.audioSegmentStream=new bt(t.tracks.audio,e),t.audioSegmentStream.on("data",(function(e){t.trigger("data",{type:"audio",data:e});})),t.audioSegmentStream.on("done",t.trigger.bind(t,"done")),t.audioSegmentStream.on("partialdone",t.trigger.bind(t,"partialdone")),t.audioSegmentStream.on("endedtimeline",t.trigger.bind(t,"endedtimeline")),t.audioSegmentStream.on("timingInfo",t.trigger.bind(t,"audioTimingInfo")),t.adts.pipe(t.audioSegmentStream)),t.trigger("trackinfo",{hasAudio:!!t.tracks.audio,hasVideo:!!t.tracks.video});}})),t.captionStream.on("data",(function(i){var n;n=t.tracks.video&&t.tracks.video.timelineStartInfo.pts||0,i.startTime=fe(i.startPts,n,e.keepOriginalTimestamps),i.endTime=fe(i.endPts,n,e.keepOriginalTimestamps),t.trigger("caption",i);})),(t=At(t)).metadataStream.on("data",t.trigger.bind(t,"id3Frame")),t}(t),Lt(i,this)):(i=function(e){var t={type:"aac",tracks:{audio:null},metadataStream:new Xe.MetadataStream,aacStream:new lt,audioRollover:new Xe.TimestampRolloverStream("audio"),timedMetadataRollover:new Xe.TimestampRolloverStream("timed-metadata"),adtsStream:new Je(!0)};return t.headOfPipeline=t.aacStream,t.aacStream.pipe(t.audioRollover).pipe(t.adtsStream),t.aacStream.pipe(t.timedMetadataRollover).pipe(t.metadataStream),t.metadataStream.on("timestamp",(function(e){t.aacStream.setTimestamp(e.timeStamp);})),t.aacStream.on("data",(function(i){"timed-metadata"!==i.type&&"audio"!==i.type||t.audioSegmentStream||(t.tracks.audio=t.tracks.audio||{timelineStartInfo:{baseMediaDecodeTime:e.baseMediaDecodeTime},codec:"adts",type:"audio"},t.audioSegmentStream=new bt(t.tracks.audio,e),t.audioSegmentStream.on("data",(function(e){t.trigger("data",{type:"audio",data:e});})),t.audioSegmentStream.on("partialdone",t.trigger.bind(t,"partialdone")),t.audioSegmentStream.on("done",t.trigger.bind(t,"done")),t.audioSegmentStream.on("endedtimeline",t.trigger.bind(t,"endedtimeline")),t.audioSegmentStream.on("timingInfo",t.trigger.bind(t,"audioTimingInfo")),t.adtsStream.pipe(t.audioSegmentStream),t.trigger("trackinfo",{hasAudio:!!t.tracks.audio,hasVideo:!!t.tracks.video}));})),(t=At(t)).metadataStream.on("data",t.trigger.bind(t,"id3Frame")),t}(t),Lt(i,this)),n=!1;}i.headOfPipeline.push(e);},this.flush=function(){i&&(n=!0,i.headOfPipeline.flush());},this.partialFlush=function(){i&&i.headOfPipeline.partialFlush();},this.endTimeline=function(){i&&i.headOfPipeline.endTimeline();},this.reset=function(){i&&i.headOfPipeline.reset();},this.setBaseMediaDecodeTime=function(e){t.keepOriginalTimestamps||(t.baseMediaDecodeTime=e),i&&(i.tracks.audio&&(i.tracks.audio.timelineStartInfo.dts=void 0,i.tracks.audio.timelineStartInfo.pts=void 0,be(i.tracks.audio),i.audioRollover&&i.audioRollover.discontinuity()),i.tracks.video&&(i.videoSegmentStream&&(i.videoSegmentStream.gopCache_=[]),i.tracks.video.timelineStartInfo.dts=void 0,i.tracks.video.timelineStartInfo.pts=void 0,be(i.tracks.video)),i.timestampRollover&&i.timestampRollover.discontinuity());},this.setRemux=function(e){t.remux=e,i&&i.coalesceStream&&i.coalesceStream.setRemux(e);},this.setAudioAppendStart=function(e){i&&i.tracks.audio&&i.audioSegmentStream&&i.audioSegmentStream.setAudioAppendStart(e);},this.alignGopsWith=function(e){};};Et.prototype=new W;var wt=Et,kt=function(e){return e>>>0},Ot=kt,Ut=function e(t,i){var n,r,a,s,o,u,d,l=[];if(!i.length)return null;for(n=0;n<t.byteLength;)r=Ot(t[n]<<24|t[n+1]<<16|t[n+2]<<8|t[n+3]),u=t.subarray(n+4,n+8),d=void 0,d="",d+=String.fromCharCode(u[0]),d+=String.fromCharCode(u[1]),a=(d+=String.fromCharCode(u[2]))+String.fromCharCode(u[3]),s=r>1?n+r:t.byteLength,a===i[0]&&(1===i.length?l.push(t.subarray(n+8,s)):(o=e(t.subarray(n+8,s),i.slice(1))).length&&(l=l.concat(o))),n=s;return l},Ct=kt,Pt=function(e){return {isLeading:(12&e[0])>>>2,dependsOn:3&e[0],isDependedOn:(192&e[1])>>>6,hasRedundancy:(48&e[1])>>>4,paddingValue:(14&e[1])>>>1,isNonSyncSample:1&e[1],degradationPriority:e[2]<<8|e[3]}},Dt=function(e){for(var t,i,n=e.byteLength,r=[],a=1;a<n-2;)0===e[a]&&0===e[a+1]&&3===e[a+2]?(r.push(a+2),a+=2):a++;if(0===r.length)return e;t=n-r.length,i=new Uint8Array(t);var s=0;for(a=0;a<t;s++,a++)s===r[0]&&(s++,r.shift()),i[a]=e[s];return i},xt=Oe.CaptionStream,Rt=function(e,t){for(var i=e,n=0;n<t.length;n++){var r=t[n];if(i<r.size)return r;i-=r.size;}return null},Mt=function(e,t){var i=Ut(e,["moof","traf"]),n=Ut(e,["mdat"]),r={},a=[];return n.forEach((function(e,t){var n=i[t];a.push({mdat:e,traf:n});})),a.forEach((function(e){var i,n,a,s,o,u,d,l,h,c,f,m,p=e.mdat,g=e.traf,y=Ut(g,["tfhd"]),_=(n=y[0],s=new DataView(n.buffer,n.byteOffset,n.byteLength),o={version:n[0],flags:new Uint8Array(n.subarray(1,4)),trackId:s.getUint32(4)},u=1&o.flags[2],d=2&o.flags[2],l=8&o.flags[2],h=16&o.flags[2],c=32&o.flags[2],f=65536&o.flags[0],m=131072&o.flags[0],a=8,u&&(a+=4,o.baseDataOffset=s.getUint32(12),a+=4),d&&(o.sampleDescriptionIndex=s.getUint32(a),a+=4),l&&(o.defaultSampleDuration=s.getUint32(a),a+=4),h&&(o.defaultSampleSize=s.getUint32(a),a+=4),c&&(o.defaultSampleFlags=s.getUint32(a)),f&&(o.durationIsEmpty=!0),!u&&m&&(o.baseDataOffsetIsMoof=!0),o),v=_.trackId,b=Ut(g,["tfdt"]),T=b.length>0?function(e){var t={version:e[0],flags:new Uint8Array(e.subarray(1,4)),baseMediaDecodeTime:Ct(e[4]<<24|e[5]<<16|e[6]<<8|e[7])};return 1===t.version&&(t.baseMediaDecodeTime*=Math.pow(2,32),t.baseMediaDecodeTime+=Ct(e[8]<<24|e[9]<<16|e[10]<<8|e[11])),t}(b[0]).baseMediaDecodeTime:0,S=Ut(g,["trun"]);t===v&&S.length>0&&(i=function(e,t,i){var n,r,a,s,o=new DataView(e.buffer,e.byteOffset,e.byteLength),u=[];for(r=0;r+4<e.length;r+=a)if(a=o.getUint32(r),r+=4,!(a<=0))switch(31&e[r]){case 6:var d=e.subarray(r+1,r+1+a),l=Rt(r,t);if(n={nalUnitType:"sei_rbsp",size:a,data:d,escapedRBSP:Dt(d),trackId:i},l)n.pts=l.pts,n.dts=l.dts,s=l;else {if(!s){console.log("We've encountered a nal unit without data. See mux.js#233.");break}n.pts=s.pts,n.dts=s.dts;}u.push(n);}return u}(p,function(e,t,i){var n=t,r=i.defaultSampleDuration||0,a=i.defaultSampleSize||0,s=i.trackId,o=[];return e.forEach((function(e){var t=function(e){var t,i={version:e[0],flags:new Uint8Array(e.subarray(1,4)),samples:[]},n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=1&i.flags[2],a=4&i.flags[2],s=1&i.flags[1],o=2&i.flags[1],u=4&i.flags[1],d=8&i.flags[1],l=n.getUint32(4),h=8;for(r&&(i.dataOffset=n.getInt32(h),h+=4),a&&l&&(t={flags:Pt(e.subarray(h,h+4))},h+=4,s&&(t.duration=n.getUint32(h),h+=4),o&&(t.size=n.getUint32(h),h+=4),d&&(1===i.version?t.compositionTimeOffset=n.getInt32(h):t.compositionTimeOffset=n.getUint32(h),h+=4),i.samples.push(t),l--);l--;)t={},s&&(t.duration=n.getUint32(h),h+=4),o&&(t.size=n.getUint32(h),h+=4),u&&(t.flags=Pt(e.subarray(h,h+4)),h+=4),d&&(1===i.version?t.compositionTimeOffset=n.getInt32(h):t.compositionTimeOffset=n.getUint32(h),h+=4),i.samples.push(t);return i}(e).samples;t.forEach((function(e){void 0===e.duration&&(e.duration=r),void 0===e.size&&(e.size=a),e.trackId=s,e.dts=n,void 0===e.compositionTimeOffset&&(e.compositionTimeOffset=0),e.pts=n+e.compositionTimeOffset,n+=e.duration;})),o=o.concat(t);})),o}(S,T,_),v),r[v]||(r[v]=[]),r[v]=r[v].concat(i));})),r},Bt=function(){var e,t,i,n,r,a,s=!1;this.isInitialized=function(){return s},this.init=function(t){e=new xt,s=!0,a=!!t&&t.isPartial,e.on("data",(function(e){e.startTime=e.startPts/n,e.endTime=e.endPts/n,r.captions.push(e),r.captionStreams[e.stream]=!0;}));},this.isNewInit=function(e,t){return !(e&&0===e.length||t&&"object"==typeof t&&0===Object.keys(t).length||i===e[0]&&n===t[i])},this.parse=function(e,a,s){var o;if(!this.isInitialized())return null;if(!a||!s)return null;if(this.isNewInit(a,s))i=a[0],n=s[i];else if(null===i||!n)return t.push(e),null;for(;t.length>0;){var u=t.shift();this.parse(u,a,s);}return null!==(o=function(e,t,i){return null===t?null:{seiNals:Mt(e,t)[t],timescale:i}}(e,i,n))&&o.seiNals?(this.pushNals(o.seiNals),this.flushStream(),r):null},this.pushNals=function(t){if(!this.isInitialized()||!t||0===t.length)return null;t.forEach((function(t){e.push(t);}));},this.flushStream=function(){if(!this.isInitialized())return null;a?e.partialFlush():e.flush();},this.clearParsedCaptions=function(){r.captions=[],r.captionStreams={};},this.resetCaptionStream=function(){if(!this.isInitialized())return null;e.reset();},this.clearAllCaptions=function(){this.clearParsedCaptions(),this.resetCaptionStream();},this.reset=function(){t=[],i=null,n=null,r?this.clearParsedCaptions():r={captions:[],captionStreams:{}},this.resetCaptionStream();},this.reset();},Ft=function(e){return "AudioSegmentStream"===e?"audio":"VideoSegmentStream"===e?"video":""},Nt=function(){function e(e,t){this.options=t||{},this.self=e,this.init();}var t=e.prototype;return t.init=function(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=this.options.handlePartialData?new wt(this.options):new yt(this.options),this.options.handlePartialData?function(e,t){t.on("data",(function(t){var i={data:t.data.track.initSegment.buffer,byteOffset:t.data.track.initSegment.byteOffset,byteLength:t.data.track.initSegment.byteLength},n={boxes:{data:t.data.boxes.buffer,byteOffset:t.data.boxes.byteOffset,byteLength:t.data.boxes.byteLength},initSegment:i,type:t.type,sequence:t.data.sequence};void 0!==t.data.videoFrameDts&&(n.videoFrameDtsTime=pe(t.data.videoFrameDts)),void 0!==t.data.videoFramePts&&(n.videoFramePtsTime=pe(t.data.videoFramePts)),e.postMessage({action:"data",segment:n},[n.boxes.data,n.initSegment.data]);})),t.on("id3Frame",(function(t){e.postMessage({action:"id3Frame",id3Frame:t});})),t.on("caption",(function(t){e.postMessage({action:"caption",caption:t});})),t.on("done",(function(t){e.postMessage({action:"done",type:Ft(t)});})),t.on("partialdone",(function(t){e.postMessage({action:"partialdone",type:Ft(t)});})),t.on("endedsegment",(function(t){e.postMessage({action:"endedSegment",type:Ft(t)});})),t.on("trackinfo",(function(t){e.postMessage({action:"trackinfo",trackInfo:t});})),t.on("audioTimingInfo",(function(t){if(null!==t.start){var i={start:pe(t.start)};t.end&&(i.end=pe(t.end)),e.postMessage({action:"audioTimingInfo",audioTimingInfo:i});}else e.postMessage({action:"audioTimingInfo",audioTimingInfo:t});})),t.on("videoTimingInfo",(function(t){var i={start:pe(t.start)};t.end&&(i.end=pe(t.end)),e.postMessage({action:"videoTimingInfo",videoTimingInfo:i});}));}(this.self,this.transmuxer):function(e,t){t.on("data",(function(t){var i=t.initSegment;t.initSegment={data:i.buffer,byteOffset:i.byteOffset,byteLength:i.byteLength};var n=t.data;t.data=n.buffer,e.postMessage({action:"data",segment:t,byteOffset:n.byteOffset,byteLength:n.byteLength},[t.data]);})),t.on("done",(function(t){e.postMessage({action:"done"});})),t.on("gopInfo",(function(t){e.postMessage({action:"gopInfo",gopInfo:t});})),t.on("videoSegmentTimingInfo",(function(t){var i={start:{decode:pe(t.start.dts),presentation:pe(t.start.pts)},end:{decode:pe(t.end.dts),presentation:pe(t.end.pts)},baseMediaDecodeTime:pe(t.baseMediaDecodeTime)};t.prependedContentDuration&&(i.prependedContentDuration=pe(t.prependedContentDuration)),e.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:i});})),t.on("id3Frame",(function(t){e.postMessage({action:"id3Frame",id3Frame:t});})),t.on("caption",(function(t){e.postMessage({action:"caption",caption:t});})),t.on("trackinfo",(function(t){e.postMessage({action:"trackinfo",trackInfo:t});})),t.on("audioTimingInfo",(function(t){e.postMessage({action:"audioTimingInfo",audioTimingInfo:{start:pe(t.start),end:pe(t.end)}});})),t.on("videoTimingInfo",(function(t){e.postMessage({action:"videoTimingInfo",videoTimingInfo:{start:pe(t.start),end:pe(t.end)}});}));}(this.self,this.transmuxer);},t.pushMp4Captions=function(e){this.captionParser||(this.captionParser=new Bt,this.captionParser.init());var t=new Uint8Array(e.data,e.byteOffset,e.byteLength),i=this.captionParser.parse(t,e.trackIds,e.timescales);this.self.postMessage({action:"mp4Captions",captions:i&&i.captions||[],data:t.buffer},[t.buffer]);},t.clearAllMp4Captions=function(){this.captionParser&&this.captionParser.clearAllCaptions();},t.clearParsedMp4Captions=function(){this.captionParser&&this.captionParser.clearParsedCaptions();},t.push=function(e){var t=new Uint8Array(e.data,e.byteOffset,e.byteLength);this.transmuxer.push(t);},t.reset=function(){this.transmuxer.reset();},t.setTimestampOffset=function(e){var t=e.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(me(t)));},t.setAudioAppendStart=function(e){this.transmuxer.setAudioAppendStart(Math.ceil(me(e.appendStart)));},t.setRemux=function(e){this.transmuxer.setRemux(e.remux);},t.flush=function(e){this.transmuxer.flush(),i.postMessage({action:"done",type:"transmuxed"});},t.partialFlush=function(e){this.transmuxer.partialFlush(),i.postMessage({action:"partialdone",type:"transmuxed"});},t.endTimeline=function(){this.transmuxer.endTimeline(),i.postMessage({action:"endedtimeline",type:"transmuxed"});},t.alignGopsWith=function(e){this.transmuxer.alignGopsWith(e.gopsToAlignWith.slice());},e}();new function(e){e.onmessage=function(t){"init"===t.data.action&&t.data.options?this.messageHandlers=new Nt(e,t.data.options):(this.messageHandlers||(this.messageHandlers=new Nt(e)),t.data&&t.data.action&&"init"!==t.data.action&&this.messageHandlers[t.data.action]&&this.messageHandlers[t.data.action](t.data));};}(i);}();})),hi=u((function(e,t){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var r=n(i),a={mp4:/^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v)/,webm:/^(vp0?[89]|av0?1|opus|vorbis)/,ogg:/^(vp0?[89]|theora|flac|opus|vorbis)/,video:/^(av0?1|avc0?[1234]|vp0?[89]|hvc1|hev1|theora|mp4v)/,audio:/^(mp4a|flac|vorbis|opus|ac-[34]|ec-3|alac|mp3)/,muxerVideo:/^(avc0?1)/,muxerAudio:/^(mp4a)/},s=function(e){return e?e.replace(/avc1\.(\d+)\.(\d+)/i,(function(e,t,i){return "avc1."+("00"+Number(t).toString(16)).slice(-2)+"00"+("00"+Number(i).toString(16)).slice(-2)})):e},o=function(e){return e.map(s)},u=function(e){void 0===e&&(e="");var t=e.split(","),i={};return t.forEach((function(e){e=e.trim(),["video","audio"].forEach((function(t){var n=a[t].exec(e.toLowerCase());if(n&&!(n.length<=1)){var r=e.substring(0,n[1].length),s=e.replace(r,"");i[t]={type:r,details:s};}}));})),i},d=function(e){return void 0===e&&(e=""),a.audio.test(e.trim().toLowerCase())},l=function(e){if(e&&"string"==typeof e){var t=e.toLowerCase().split(",").map((function(e){return s(e.trim())})),i="video";1===t.length&&d(t[0])&&(i="audio");var n="mp4";return t.every((function(e){return a.mp4.test(e)}))?n="mp4":t.every((function(e){return a.webm.test(e)}))?n="webm":t.every((function(e){return a.ogg.test(e)}))&&(n="ogg"),i+"/"+n+';codecs="'+e+'"'}};t.DEFAULT_AUDIO_CODEC="mp4a.40.2",t.DEFAULT_VIDEO_CODEC="avc1.4d400d",t.browserSupportsCodec=function(e){return void 0===e&&(e=""),r.default.MediaSource&&r.default.MediaSource.isTypeSupported&&r.default.MediaSource.isTypeSupported(l(e))||!1},t.codecsFromDefault=function(e,t){if(!e.mediaGroups.AUDIO||!t)return null;var i=e.mediaGroups.AUDIO[t];if(!i)return null;for(var n in i){var r=i[n];if(r.default&&r.playlists)return u(r.playlists[0].attributes.CODECS)}return null},t.getMimeForCodec=l,t.isAudioCodec=d,t.isVideoCodec=function(e){return void 0===e&&(e=""),a.video.test(e.trim().toLowerCase())},t.mapLegacyAvcCodecs=function(e){return e.replace(/avc1\.(\d+)\.(\d+)/i,(function(e){return o([e])[0]}))},t.muxerSupportsCodec=function(e){return void 0===e&&(e=""),e.toLowerCase().split(",").every((function(e){return e=e.trim(),a.muxerVideo.test(e)||a.muxerAudio.test(e)}))},t.parseCodecs=u,t.translateLegacyCodec=s,t.translateLegacyCodecs=o;}));o(hi);var ci=hi.DEFAULT_AUDIO_CODEC,fi=hi.DEFAULT_VIDEO_CODEC,mi=hi.browserSupportsCodec,pi=hi.codecsFromDefault,gi=hi.getMimeForCodec,yi=hi.isAudioCodec,_i=hi.isVideoCodec,vi=(hi.mapLegacyAvcCodecs,hi.muxerSupportsCodec),bi=hi.parseCodecs,Ti=hi.translateLegacyCodec,Si=(hi.translateLegacyCodecs,function(e,t){var i=t.attributes||{};return e&&e.mediaGroups&&e.mediaGroups.AUDIO&&i.AUDIO&&e.mediaGroups.AUDIO[i.AUDIO]}),Ii=function(e,t){var i=t.attributes||{},n=function(e){var t=e.attributes||{};if(t.CODECS)return bi(t.CODECS)}(t)||{};if(Si(e,t)&&!n.audio&&!function(e,t){if(!Si(e,t))return !0;var i=t.attributes||{},n=e.mediaGroups.AUDIO[i.AUDIO];for(var r in n)if(!n[r].uri&&!n[r].playlists)return !0;return !1}(e,t)){var r=pi(e,i.AUDIO);r&&(n.audio=r.audio);}var a={};return n.video&&(a.video=Ti(""+n.video.type+n.video.details)),n.audio&&(a.audio=Ti(""+n.audio.type+n.audio.details)),a},Ai=function(e){return n.log.debug?n.log.debug.bind(n,"VHS:",e+" >"):function(){}},Li=Ai("PlaylistSelector"),Ei=function(e){if(e&&e.playlist){var t=e.playlist;return JSON.stringify({id:t.id,bandwidth:e.bandwidth,width:e.width,height:e.height,codecs:t.attributes&&t.attributes.CODECS||""})}},wi=function(e,t){if(!e)return "";var n=i.getComputedStyle(e);return n?n[t]:""},ki=function(e,t){var i=e.slice();e.sort((function(e,n){var r=t(e,n);return 0===r?i.indexOf(e)-i.indexOf(n):r}));},Oi=function(e,t){var n,r;return e.attributes.BANDWIDTH&&(n=e.attributes.BANDWIDTH),n=n||i.Number.MAX_VALUE,t.attributes.BANDWIDTH&&(r=t.attributes.BANDWIDTH),n-(r||i.Number.MAX_VALUE)},Ui=function(e,t,n,r,a){var s={bandwidth:t,width:n,height:r,limitRenditionByPlayerDimensions:a},o=e.playlists.map((function(e){var t=e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width,n=e.attributes.RESOLUTION&&e.attributes.RESOLUTION.height;return {bandwidth:e.attributes.BANDWIDTH||i.Number.MAX_VALUE,width:t,height:n,playlist:e}}));ki(o,(function(e,t){return e.bandwidth-t.bandwidth}));var u=(o=o.filter((function(e){return !J.isIncompatible(e.playlist)}))).filter((function(e){return J.isEnabled(e.playlist)}));u.length||(u=o.filter((function(e){return !J.isDisabled(e.playlist)})));var d=u.filter((function(e){return e.bandwidth*lt.BANDWIDTH_VARIANCE<t})),l=d[d.length-1],h=d.filter((function(e){return e.bandwidth===l.bandwidth}))[0];if(!1===a){var c=h||u[0]||o[0];if(c&&c.playlist){var f="sortedPlaylistReps";return h&&(f="bandwidthBestRep"),u[0]&&(f="enabledPlaylistReps"),Li("choosing "+Ei(c)+" using "+f+" with options",s),c.playlist}return Li("could not choose a playlist with options",s),null}var m=d.filter((function(e){return e.width&&e.height}));ki(m,(function(e,t){return e.width-t.width}));var p=m.filter((function(e){return e.width===n&&e.height===r}));l=p[p.length-1];var g,y,_,v=p.filter((function(e){return e.bandwidth===l.bandwidth}))[0];v||(y=(g=m.filter((function(e){return e.width>n||e.height>r}))).filter((function(e){return e.width===g[0].width&&e.height===g[0].height})),l=y[y.length-1],_=y.filter((function(e){return e.bandwidth===l.bandwidth}))[0]);var b=_||v||h||u[0]||o[0];if(b&&b.playlist){var T="sortedPlaylistReps";return _?T="resolutionPlusOneRep":v?T="resolutionBestRep":h?T="bandwidthBestRep":u[0]&&(T="enabledPlaylistReps"),Li("choosing "+Ei(b)+" using "+T+" with options",s),b.playlist}return Li("could not choose a playlist with options",s),null},Ci=function(){var e=this.useDevicePixelRatio&&i.devicePixelRatio||1;return Ui(this.playlists.master,this.systemBandwidth,parseInt(wi(this.tech_.el(),"width"),10)*e,parseInt(wi(this.tech_.el(),"height"),10)*e,this.limitRenditionByPlayerDimensions)},Pi=function(e,t,i){var n,r;if(i&&i.cues)for(n=i.cues.length;n--;)(r=i.cues[n]).startTime>=e&&r.endTime<=t&&i.removeCue(r);},Di=function(e){return "number"==typeof e&&isFinite(e)},xi=function(e){return e+"TimingInfo"},Ri=function(e){var t=e.segmentTimeline,i=e.currentTimeline,n=e.startOfSegment,r=e.buffered;return e.overrideCheck||t!==i?r.length?r.end(r.length-1):n:null},Mi=function(e){var t=e.timelineChangeController,i=e.currentTimeline,n=e.segmentTimeline,r=e.loaderType,a=e.audioDisabled;if(i===n)return !1;if("audio"===r){var s=t.lastTimelineChange({type:"main"});return !s||s.to!==n}if("main"===r&&a){var o=t.pendingTimelineChange({type:"audio"});return !o||o.to!==n}return !1},Bi=function(e){function t(t,i){var r;if(r=e.call(this)||this,!t)throw new TypeError("Initialization settings are required");if("function"!=typeof t.currentTime)throw new TypeError("No currentTime getter specified");if(!t.mediaSource)throw new TypeError("No MediaSource specified");return r.bandwidth=t.bandwidth,r.throughput={rate:0,count:0},r.roundTrip=NaN,r.resetStats_(),r.mediaIndex=null,r.hasPlayed_=t.hasPlayed,r.currentTime_=t.currentTime,r.seekable_=t.seekable,r.seeking_=t.seeking,r.duration_=t.duration,r.mediaSource_=t.mediaSource,r.vhs_=t.vhs,r.loaderType_=t.loaderType,r.currentMediaInfo_=void 0,r.startingMediaInfo_=void 0,r.segmentMetadataTrack_=t.segmentMetadataTrack,r.goalBufferLength_=t.goalBufferLength,r.sourceType_=t.sourceType,r.sourceUpdater_=t.sourceUpdater,r.inbandTextTracks_=t.inbandTextTracks,r.state_="INIT",r.handlePartialData_=t.handlePartialData,r.timelineChangeController_=t.timelineChangeController,r.shouldSaveSegmentTimingInfo_=!0,r.checkBufferTimeout_=null,r.error_=void 0,r.currentTimeline_=-1,r.pendingSegment_=null,r.xhrOptions_=null,r.pendingSegments_=[],r.audioDisabled_=!1,r.isPendingTimestampOffset_=!1,r.gopBuffer_=[],r.timeMapping_=0,r.safeAppend_=n.browser.IE_VERSION>=11,r.appendInitSegment_={audio:!0,video:!0},r.playlistOfLastInitSegment_={audio:null,video:null},r.callQueue_=[],r.loadQueue_=[],r.metadataQueue_={id3:[],caption:[]},r.activeInitSegmentId_=null,r.initSegments_={},r.cacheEncryptionKeys_=t.cacheEncryptionKeys,r.keyCache_={},r.decrypter_=t.decrypter,r.syncController_=t.syncController,r.syncPoint_={segmentIndex:0,time:0},r.transmuxer_=r.createTransmuxer_(),r.triggerSyncInfoUpdate_=function(){return r.trigger("syncinfoupdate")},r.syncController_.on("syncinfoupdate",r.triggerSyncInfoUpdate_),r.mediaSource_.addEventListener("sourceopen",(function(){r.isEndOfStream_()||(r.ended_=!1);})),r.fetchAtBuffer_=!1,r.logger_=Ai("SegmentLoader["+r.loaderType_+"]"),Object.defineProperty(a(r),"state",{get:function(){return this.state_},set:function(e){e!==this.state_&&(this.logger_(this.state_+" -> "+e),this.state_=e,this.trigger("statechange"));}}),r.sourceUpdater_.on("ready",(function(){r.hasEnoughInfoToAppend_()&&r.processCallQueue_();})),"main"===r.loaderType_&&r.timelineChangeController_.on("pendingtimelinechange",(function(){r.hasEnoughInfoToAppend_()&&r.processCallQueue_();})),"audio"===r.loaderType_&&r.timelineChangeController_.on("timelinechange",(function(){r.hasEnoughInfoToLoad_()&&r.processLoadQueue_(),r.hasEnoughInfoToAppend_()&&r.processCallQueue_();})),r}s(t,e);var r=t.prototype;return r.createTransmuxer_=function(){var e=new li;return e.postMessage({action:"init",options:{remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,handlePartialData:this.handlePartialData_}}),e},r.resetStats_=function(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0;},r.dispose=function(){this.trigger("dispose"),this.state="DISPOSED",this.pause(),this.abort_(),this.transmuxer_&&(this.transmuxer_.terminate(),$e=null,ct.length=0),this.resetStats_(),this.checkBufferTimeout_&&i.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_),this.off();},r.setAudio=function(e){this.audioDisabled_=!e,e?this.appendInitSegment_.audio=!0:this.sourceUpdater_.removeAudio(0,this.duration_());},r.abort=function(){"WAITING"===this.state?(this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()):this.pendingSegment_&&(this.pendingSegment_=null);},r.abort_=function(){this.pendingSegment_&&this.pendingSegment_.abortRequests&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_);},r.checkForAbort_=function(e){return "APPENDING"!==this.state||this.pendingSegment_?!this.pendingSegment_||this.pendingSegment_.requestId!==e:(this.state="READY",!0)},r.error=function(e){return void 0!==e&&(this.logger_("error occurred:",e),this.error_=e),this.pendingSegment_=null,this.error_},r.endOfStream=function(){this.ended_=!0,this.transmuxer_&&yt(this.transmuxer_),this.gopBuffer_.length=0,this.pause(),this.trigger("ended");},r.buffered_=function(){if(!this.sourceUpdater_||!this.startingMediaInfo_)return n.createTimeRanges();if("main"===this.loaderType_){var e=this.startingMediaInfo_,t=e.hasAudio,i=e.hasVideo,r=e.isMuxed;if(i&&t&&!this.audioDisabled_&&!r)return this.sourceUpdater_.buffered();if(i)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()},r.initSegmentForMap=function(e,t){if(void 0===t&&(t=!1),!e)return null;var i=le(e),n=this.initSegments_[i];return t&&!n&&e.bytes&&(this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,tracks:e.tracks,timescales:e.timescales}),n||e},r.segmentKey=function(e,t){if(void 0===t&&(t=!1),!e)return null;var i=he(e),n=this.keyCache_[i];this.cacheEncryptionKeys_&&t&&!n&&e.bytes&&(this.keyCache_[i]=n={resolvedUri:e.resolvedUri,bytes:e.bytes});var r={resolvedUri:(n||e).resolvedUri};return n&&(r.bytes=n.bytes),r},r.couldBeginLoading_=function(){return this.playlist_&&!this.paused()},r.load=function(){if(this.monitorBuffer_(),this.playlist_){if(this.syncController_.setDateTimeMapping(this.playlist_),"INIT"===this.state&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||"READY"!==this.state&&"INIT"!==this.state||(this.state="READY");}},r.init_=function(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()},r.playlist=function(e,t){if(void 0===t&&(t={}),e){var i=this.playlist_,n=this.pendingSegment_;this.playlist_=e,this.xhrOptions_=t,"INIT"===this.state&&(e.syncInfo={mediaSequence:e.mediaSequence,time:0});var r=null;if(i&&(i.id?r=i.id:i.uri&&(r=i.uri)),this.logger_("playlist update ["+r+" => "+(e.id||e.uri)+"]"),this.trigger("syncinfoupdate"),"INIT"===this.state&&this.couldBeginLoading_())return this.init_();if(!i||i.uri!==e.uri)return (null!==this.mediaIndex||this.handlePartialData_)&&this.resyncLoader(),this.currentMediaInfo_=void 0,void this.trigger("playlistupdate");var a=e.mediaSequence-i.mediaSequence;this.logger_("live window shift ["+a+"]"),null!==this.mediaIndex&&(this.mediaIndex-=a),n&&(n.mediaIndex-=a,n.mediaIndex>=0&&(n.segment=e.segments[n.mediaIndex])),this.syncController_.saveExpiredSegmentInfo(i,e);}},r.pause=function(){this.checkBufferTimeout_&&(i.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null);},r.paused=function(){return null===this.checkBufferTimeout_},r.resetEverything=function(e){this.ended_=!1,this.appendInitSegment_={audio:!0,video:!0},this.resetLoader(),this.remove(0,1/0,e),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearAllMp4Captions"});},r.resetLoader=function(){this.fetchAtBuffer_=!1,this.resyncLoader();},r.resyncLoader=function(){this.transmuxer_&&yt(this.transmuxer_),this.mediaIndex=null,this.syncPoint_=null,this.isPendingTimestampOffset_=!1,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.abort(),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"});},r.remove=function(e,t,i){if(void 0===i&&(i=function(){}),t===1/0&&(t=this.duration_()),this.sourceUpdater_&&this.currentMediaInfo_){var n=1,r=function(){0==--n&&i();};for(var a in this.audioDisabled_||(n++,this.sourceUpdater_.removeAudio(e,t,r)),"main"===this.loaderType_&&this.currentMediaInfo_&&this.currentMediaInfo_.hasVideo&&(this.gopBuffer_=function(e,t,i,n){for(var r=Math.ceil((t-n)*Pt),a=Math.ceil((i-n)*Pt),s=e.slice(),o=e.length;o--&&!(e[o].pts<=a););if(-1===o)return s;for(var u=o+1;u--&&!(e[u].pts<=r););return u=Math.max(u,0),s.splice(u,o-u+1),s}(this.gopBuffer_,e,t,this.timeMapping_),n++,this.sourceUpdater_.removeVideo(e,t,r)),this.inbandTextTracks_)Pi(e,t,this.inbandTextTracks_[a]);Pi(e,t,this.segmentMetadataTrack_),r();}},r.monitorBuffer_=function(){this.checkBufferTimeout_&&i.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=i.setTimeout(this.monitorBufferTick_.bind(this),1);},r.monitorBufferTick_=function(){"READY"===this.state&&this.fillBuffer_(),this.checkBufferTimeout_&&i.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=i.setTimeout(this.monitorBufferTick_.bind(this),500);},r.fillBuffer_=function(){if(!this.sourceUpdater_.updating()){this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var e=this.buffered_(),t=this.checkBuffer_(e,this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);t&&(t.timestampOffset=Ri({segmentTimeline:t.timeline,currentTimeline:this.currentTimeline_,startOfSegment:t.startOfSegment,buffered:e,overrideCheck:this.isPendingTimestampOffset_}),this.isPendingTimestampOffset_=!1,"number"==typeof t.timestampOffset&&this.timelineChangeController_.pendingTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:t.timeline}),this.loadSegment_(t));}},r.isEndOfStream_=function(e,t){if(void 0===e&&(e=this.mediaIndex),void 0===t&&(t=this.playlist_),!t||!this.mediaSource_)return !1;var i=e+1===t.segments.length;return t.endList&&"open"===this.mediaSource_.readyState&&i},r.checkBuffer_=function(e,t,i,n,r,a){var s=0;e.length&&(s=e.end(e.length-1));var o=Math.max(0,s-r);if(!t.segments.length)return null;if(o>=this.goalBufferLength_())return null;if(!n&&o>=1)return null;var u,d=null,l=!1;if(null===a)d=this.getSyncSegmentCandidate_(t),l=!0;else if(null!==i){var h=t.segments[i];u=h&&h.end?h.end:s,d=i+1;}else if(this.fetchAtBuffer_){var c=J.getMediaInfoForTime(t,s,a.segmentIndex,a.time);d=c.mediaIndex,u=c.startTime;}else {var f=J.getMediaInfoForTime(t,r,a.segmentIndex,a.time);d=f.mediaIndex,u=f.startTime;}var m=this.generateSegmentInfo_(t,d,u,l);return !m||this.mediaSource_&&this.playlist_&&m.mediaIndex===this.playlist_.segments.length-1&&"ended"===this.mediaSource_.readyState&&!this.seeking_()?void 0:(this.logger_("checkBuffer_ returning "+m.uri,{segmentInfo:m,playlist:t,currentMediaIndex:i,nextMediaIndex:d,startOfSegment:u,isSyncRequest:l}),m)},r.getSyncSegmentCandidate_=function(e){var t=this;if(-1===this.currentTimeline_)return 0;var i=e.segments.map((function(e,t){return {timeline:e.timeline,segmentIndex:t}})).filter((function(e){return e.timeline===t.currentTimeline_}));return i.length?i[Math.min(i.length-1,1)].segmentIndex:Math.max(e.segments.length-1,0)},r.generateSegmentInfo_=function(e,t,i,n){if(t<0||t>=e.segments.length)return null;var r,a,s=e.segments[t],o=this.sourceUpdater_.audioBuffered(),u=this.sourceUpdater_.videoBuffered();return o.length&&(r=o.end(o.length-1)-this.sourceUpdater_.audioTimestampOffset()),u.length&&(a=function(e,t,i){if(null==t||!e.length)return [];var n,r=Math.ceil((t-i+3)*Pt);for(n=0;n<e.length&&!(e[n].pts>r);n++);return e.slice(n)}(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_)),{requestId:"segment-loader-"+Math.random(),uri:s.resolvedUri,mediaIndex:t,isSyncRequest:n,startOfSegment:i,playlist:e,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:s.timeline,duration:s.duration,segment:s,byteLength:0,transmuxer:this.transmuxer_,audioAppendStart:r,gopsToAlignWith:a}},r.earlyAbortWhenNeeded_=function(e){if(!this.vhs_.tech_.paused()&&this.xhrOptions_.timeout&&this.playlist_.attributes.BANDWIDTH&&!(Date.now()-(e.firstBytesReceivedAt||Date.now())<1e3)){var t=this.currentTime_(),i=e.bandwidth,n=this.pendingSegment_.duration,r=J.estimateSegmentRequestTime(n,i,this.playlist_,e.bytesReceived),a=function(e,t,i){return void 0===i&&(i=1),((e.length?e.end(e.length-1):0)-t)/i}(this.buffered_(),t,this.vhs_.tech_.playbackRate())-1;if(!(r<=a)){var s=function(e){var t=e.currentTime,i=e.bandwidth,n=e.duration,r=e.segmentDuration,a=e.timeUntilRebuffer,s=e.currentTimeline,o=e.syncController,u=e.master.playlists.filter((function(e){return !J.isIncompatible(e)})),d=u.filter(J.isEnabled);d.length||(d=u.filter((function(e){return !J.isDisabled(e)})));var l=d.filter(J.hasAttribute.bind(null,"BANDWIDTH")).map((function(e){var u=o.getSyncPoint(e,n,s,t)?1:2;return {playlist:e,rebufferingImpact:J.estimateSegmentRequestTime(r,i,e)*u-a}})),h=l.filter((function(e){return e.rebufferingImpact<=0}));return ki(h,(function(e,t){return Oi(t.playlist,e.playlist)})),h.length?h[0]:(ki(l,(function(e,t){return e.rebufferingImpact-t.rebufferingImpact})),l[0]||null)}({master:this.vhs_.playlists.master,currentTime:t,bandwidth:i,duration:this.duration_(),segmentDuration:n,timeUntilRebuffer:a,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(s){var o=r-a-s.rebufferingImpact,u=.5;a<=1/30&&(u=1),!s.playlist||s.playlist.uri===this.playlist_.uri||o<u||(this.bandwidth=s.playlist.attributes.BANDWIDTH*lt.BANDWIDTH_VARIANCE+1,this.trigger("earlyabort"));}}}},r.handleAbort_=function(){this.mediaRequestsAborted+=1;},r.handleProgress_=function(e,t){this.earlyAbortWhenNeeded_(t.stats),this.checkForAbort_(t.requestId)||this.trigger("progress");},r.handleTrackInfo_=function(e,t){this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId)||this.checkForIllegalMediaSwitch(t)||(t=t||{},function(e,t){if(!e&&!t||!e&&t||e&&!t)return !1;if(e===t)return !0;var i=Object.keys(e).sort(),n=Object.keys(t).sort();if(i.length!==n.length)return !1;for(var r=0;r<i.length;r++){var a=i[r];if(a!==n[r])return !1;if(e[a]!==t[a])return !1}return !0}(this.currentMediaInfo_,t)||(this.appendInitSegment_={audio:!0,video:!0},this.startingMediaInfo_=t,this.currentMediaInfo_=t,this.logger_("trackinfo update",t),this.trigger("trackinfo")),this.checkForAbort_(e.requestId)||(this.pendingSegment_.trackInfo=t,this.hasEnoughInfoToAppend_()&&this.processCallQueue_()));},r.handleTimingInfo_=function(e,t,i,n){if(this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId)){var r=this.pendingSegment_,a=xi(t);r[a]=r[a]||{},r[a][i]=n,this.logger_("timinginfo: "+t+" - "+i+" - "+n),this.hasEnoughInfoToAppend_()&&this.processCallQueue_();}},r.handleCaptions_=function(e,t){var n=this;if(this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId))if(0!==t.length)if(this.pendingSegment_.hasAppendedData_){var r=null===this.sourceUpdater_.videoTimestampOffset()?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset(),a={};t.forEach((function(e){a[e.stream]=a[e.stream]||{startTime:1/0,captions:[],endTime:0};var t=a[e.stream];t.startTime=Math.min(t.startTime,e.startTime+r),t.endTime=Math.max(t.endTime,e.endTime+r),t.captions.push(e);})),Object.keys(a).forEach((function(e){var t=a[e],s=t.startTime,o=t.endTime,u=t.captions,d=n.inbandTextTracks_;n.logger_("adding cues from "+s+" -> "+o+" for "+e),function(e,t,i){if(!e[i]){t.trigger({type:"usage",name:"vhs-608"}),t.trigger({type:"usage",name:"hls-608"});var n=t.textTracks().getTrackById(i);e[i]=n||t.addRemoteTextTrack({kind:"captions",id:i,label:i},!1).track;}}(d,n.vhs_.tech_,e),Pi(s,o,d[e]),function(e){var t=e.inbandTextTracks,n=e.captionArray,r=e.timestampOffset;if(n){var a=i.WebKitDataCue||i.VTTCue;n.forEach((function(e){var i=e.stream;t[i].addCue(new a(e.startTime+r,e.endTime+r,e.text));}));}}({captionArray:u,inbandTextTracks:d,timestampOffset:r});})),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"});}else this.metadataQueue_.caption.push(this.handleCaptions_.bind(this,e,t));else this.logger_("SegmentLoader received no captions from a caption event");},r.handleId3_=function(e,t,r){if(this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId))if(this.pendingSegment_.hasAppendedData_){var a=null===this.sourceUpdater_.videoTimestampOffset()?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset();!function(e,t,i){e.metadataTrack_||(e.metadataTrack_=i.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,e.metadataTrack_.inBandMetadataTrackDispatchType=t);}(this.inbandTextTracks_,r,this.vhs_.tech_),function(e){var t=e.inbandTextTracks,r=e.metadataArray,a=e.timestampOffset,s=e.videoDuration;if(r){var o=i.WebKitDataCue||i.VTTCue,u=t.metadataTrack_;if(u&&(r.forEach((function(e){var t=e.cueTime+a;!("number"!=typeof t||i.isNaN(t)||t<0)&&t<1/0&&e.frames.forEach((function(e){var i=new o(t,t,e.value||e.url||e.data||"");i.frame=e,i.value=e,function(e){Object.defineProperties(e.frame,{id:{get:function(){return n.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),e.value.key}},value:{get:function(){return n.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),e.value.data}},privateData:{get:function(){return n.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),e.value.data}}});}(i),u.addCue(i);}));})),u.cues&&u.cues.length)){for(var d=u.cues,l=[],h=0;h<d.length;h++)d[h]&&l.push(d[h]);var c=l.reduce((function(e,t){var i=e[t.startTime]||[];return i.push(t),e[t.startTime]=i,e}),{}),f=Object.keys(c).sort((function(e,t){return Number(e)-Number(t)}));f.forEach((function(e,t){var i=c[e],n=Number(f[t+1])||s;i.forEach((function(e){e.endTime=n;}));}));}}}({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:a,videoDuration:this.duration_()});}else this.metadataQueue_.id3.push(this.handleId3_.bind(this,e,t,r));},r.processMetadataQueue_=function(){this.metadataQueue_.id3.forEach((function(e){return e()})),this.metadataQueue_.caption.forEach((function(e){return e()})),this.metadataQueue_.id3=[],this.metadataQueue_.caption=[];},r.processCallQueue_=function(){var e=this.callQueue_;this.callQueue_=[],e.forEach((function(e){return e()}));},r.processLoadQueue_=function(){var e=this.loadQueue_;this.loadQueue_=[],e.forEach((function(e){return e()}));},r.hasEnoughInfoToLoad_=function(){if("audio"!==this.loaderType_)return !0;var e=this.pendingSegment_;return !(!e||this.currentMediaInfo_&&Mi({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))},r.hasEnoughInfoToAppend_=function(){if(!this.sourceUpdater_.ready())return !1;var e=this.pendingSegment_;if(!e||!e.trackInfo)return !1;if(!this.handlePartialData_){var t=this.currentMediaInfo_,i=t.hasAudio,n=t.hasVideo,r=t.isMuxed;if(n&&!e.videoTimingInfo)return !1;if(i&&!this.audioDisabled_&&!r&&!e.audioTimingInfo)return !1}return !Mi({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_})},r.handleData_=function(e,t){if(this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId))if(!this.callQueue_.length&&this.hasEnoughInfoToAppend_()){var i=this.pendingSegment_;if(this.setTimeMapping_(i.timeline),this.updateMediaSecondsLoaded_(i.segment),"closed"!==this.mediaSource_.readyState){if(e.map&&(e.map=this.initSegmentForMap(e.map,!0),i.segment.map=e.map),e.key&&this.segmentKey(e.key,!0),i.isFmp4=e.isFmp4,i.timingInfo=i.timingInfo||{},i.isFmp4)this.trigger("fmp4"),i.timingInfo.start=i[xi(t.type)].start;else {var n,r="main"===this.loaderType_&&this.currentMediaInfo_.hasVideo;r&&(n=this.handlePartialData_?t.videoFramePtsTime:i.videoTimingInfo.start),i.timingInfo.start=this.trueSegmentStart_({currentStart:i.timingInfo.start,playlist:i.playlist,mediaIndex:i.mediaIndex,currentVideoTimestampOffset:this.sourceUpdater_.videoTimestampOffset(),useVideoTimingInfo:r,firstVideoFrameTimeForData:n,videoTimingInfo:i.videoTimingInfo,audioTimingInfo:i.audioTimingInfo});}this.updateAppendInitSegmentStatus(i,t.type),this.updateSourceBufferTimestampOffset_(i),i.hasAppendedData_=!0,this.processMetadataQueue_(),this.appendData_(i,t);}}else this.callQueue_.push(this.handleData_.bind(this,e,t));},r.updateAppendInitSegmentStatus=function(e,t){"main"!==this.loaderType_||"number"!=typeof e.timestampOffset||e.changedTimestampOffset||(this.appendInitSegment_={audio:!0,video:!0}),this.playlistOfLastInitSegment_[t]!==e.playlist&&(this.appendInitSegment_[t]=!0);},r.getInitSegmentAndUpdateState_=function(e){var t=e.type,i=e.initSegment,n=e.map,r=e.playlist;if(n){var a=le(n);if(this.activeInitSegmentId_===a)return null;i=this.initSegmentForMap(n,!0).bytes,this.activeInitSegmentId_=a;}return i&&this.appendInitSegment_[t]?(this.playlistOfLastInitSegment_[t]=r,this.appendInitSegment_[t]=!!n,this.activeInitSegmentId_=null,i):null},r.appendToSourceBuffer_=function(e){var t=this,i=e.segmentInfo,n=e.type,r=e.initSegment,a=e.data,s=[a],o=a.byteLength;r&&(s.unshift(r),o+=r.byteLength);var u,d,l,h=(l=0,(u={bytes:o,segments:s}).bytes&&(d=new Uint8Array(u.bytes),u.segments.forEach((function(e){d.set(e,l),l+=e.byteLength;}))),d);this.sourceUpdater_.appendBuffer({segmentInfo:i,type:n,bytes:h},(function(e){e&&(t.error(n+" append of "+h.length+"b failed for segment #"+i.mediaIndex+" in playlist "+i.playlist.id),t.trigger("appenderror"));}));},r.handleVideoSegmentTimingInfo_=function(e,t){if(this.pendingSegment_&&e===this.pendingSegment_.requestId){var i=this.pendingSegment_.segment;i.videoTimingInfo||(i.videoTimingInfo={}),i.videoTimingInfo.transmuxerPrependedSeconds=t.prependedContentDuration||0,i.videoTimingInfo.transmuxedPresentationStart=t.start.presentation,i.videoTimingInfo.transmuxedPresentationEnd=t.end.presentation,i.videoTimingInfo.baseMediaDecodeTime=t.baseMediaDecodeTime;}},r.appendData_=function(e,t){var i=t.type,n=t.data;if(n&&n.byteLength&&("audio"!==i||!this.audioDisabled_)){var r=this.getInitSegmentAndUpdateState_({type:i,initSegment:t.initSegment,playlist:e.playlist,map:e.isFmp4?e.segment.map:null});this.appendToSourceBuffer_({segmentInfo:e,type:i,initSegment:r,data:n});}},r.loadSegment_=function(e){var t=this;this.state="WAITING",this.pendingSegment_=e,this.trimBackBuffer_(e),"number"==typeof e.timestampOffset&&this.transmuxer_&&this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),this.hasEnoughInfoToLoad_()?this.updateTransmuxerAndRequestSegment_(e):this.loadQueue_.push((function(){var i=t.buffered_();"number"==typeof e.timestampOffset&&(e.timestampOffset=Ri({segmentTimeline:e.timeline,currentTimeline:t.currentTimeline_,startOfSegment:e.startOfSegment,buffered:i,overrideCheck:!0})),delete e.audioAppendStart;var n=t.sourceUpdater_.audioBuffered();n.length&&(e.audioAppendStart=n.end(n.length-1)-t.sourceUpdater_.audioTimestampOffset()),t.updateTransmuxerAndRequestSegment_(e);}));},r.updateTransmuxerAndRequestSegment_=function(e){this.shouldUpdateTransmuxerTimestampOffset_(e.timestampOffset)&&(this.gopBuffer_.length=0,e.gopsToAlignWith=[],this.timeMapping_=0,this.transmuxer_.postMessage({action:"reset"}),this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:e.timestampOffset}));var t=this.createSimplifiedSegmentObj_(e);e.abortRequests=Zt({xhr:this.vhs_.xhr,xhrOptions:this.xhrOptions_,decryptionWorker:this.decrypter_,segment:t,handlePartialData:this.handlePartialData_,abortFn:this.handleAbort_.bind(this),progressFn:this.handleProgress_.bind(this),trackInfoFn:this.handleTrackInfo_.bind(this),timingInfoFn:this.handleTimingInfo_.bind(this),videoSegmentTimingInfoFn:this.handleVideoSegmentTimingInfo_.bind(this,e.requestId),captionsFn:this.handleCaptions_.bind(this),id3Fn:this.handleId3_.bind(this),dataFn:this.handleData_.bind(this),doneFn:this.segmentRequestFinished_.bind(this)});},r.trimBackBuffer_=function(e){var t=function(e,t,i){var n=t-lt.BACK_BUFFER_LENGTH;e.length&&(n=Math.max(n,e.start(0)));var r=t-i;return Math.min(r,n)}(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);t>0&&this.remove(0,t);},r.createSimplifiedSegmentObj_=function(e){var t=e.segment,i={resolvedUri:t.resolvedUri,byterange:t.byterange,requestId:e.requestId,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith},n=e.playlist.segments[e.mediaIndex];if(n&&n.end&&n.timeline===t.timeline&&(i.baseStartTime=n.end+e.timestampOffset),t.key){var r=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);i.key=this.segmentKey(t.key),i.key.iv=r;}return t.map&&(i.map=this.initSegmentForMap(t.map)),i},r.saveTransferStats_=function(e){this.mediaRequests+=1,e&&(this.mediaBytesTransferred+=e.bytesReceived,this.mediaTransferDuration+=e.roundTripTime);},r.saveBandwidthRelatedStats_=function(e){this.bandwidth=e.bandwidth,this.roundTrip=e.roundTripTime,this.pendingSegment_.byteLength=e.bytesReceived;},r.handleTimeout_=function(){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger("bandwidthupdate");},r.segmentRequestFinished_=function(e,t,i){if(this.callQueue_.length)this.callQueue_.push(this.segmentRequestFinished_.bind(this,e,t,i));else if(this.saveTransferStats_(t.stats),this.pendingSegment_&&t.requestId===this.pendingSegment_.requestId){if(e){if(this.pendingSegment_=null,this.state="READY",-102===e.code)return;return this.pause(),-101===e.code?void this.handleTimeout_():(this.mediaRequestsErrored+=1,this.error(e),void this.trigger("error"))}this.saveBandwidthRelatedStats_(t.stats);var n=this.pendingSegment_;n.endOfAllRequests=t.endOfAllRequests,i.gopInfo&&(this.gopBuffer_=function(e,t,i){if(!t.length)return e;if(i)return t.slice();for(var n=t[0].pts,r=0;r<e.length&&!(e[r].pts>=n);r++);return e.slice(0,r).concat(t)}(this.gopBuffer_,i.gopInfo,this.safeAppend_)),this.state="APPENDING";var r=this.isEndOfStream_(n.mediaIndex,n.playlist),a=null!==this.mediaIndex,s=n.timeline!==this.currentTimeline_&&n.timeline>0;!n.isFmp4&&(r||a&&s)&&(o=this.transmuxer_,gt("endTimeline",o)),this.trigger("appending"),this.waitForAppendsToComplete_(n);}var o;},r.setTimeMapping_=function(e){var t=this.syncController_.mappingForTimeline(e);null!==t&&(this.timeMapping_=t);},r.updateMediaSecondsLoaded_=function(e){"number"==typeof e.start&&"number"==typeof e.end?this.mediaSecondsLoaded+=e.end-e.start:this.mediaSecondsLoaded+=e.duration;},r.shouldUpdateTransmuxerTimestampOffset_=function(e){return null!==e&&("main"===this.loaderType_&&e!==this.sourceUpdater_.videoTimestampOffset()||!this.audioDisabled_&&e!==this.sourceUpdater_.audioTimestampOffset())},r.trueSegmentStart_=function(e){var t=e.currentStart,i=e.playlist,n=e.mediaIndex,r=e.firstVideoFrameTimeForData,a=e.currentVideoTimestampOffset,s=e.useVideoTimingInfo,o=e.videoTimingInfo,u=e.audioTimingInfo;if(void 0!==t)return t;if(!s)return u.start;var d=i.segments[n-1];return 0!==n&&d&&void 0!==d.start&&d.end===r+a?o.start:r},r.waitForAppendsToComplete_=function(e){if(!this.currentMediaInfo_)return this.error({message:"No starting media returned, likely due to an unsupported media format.",blacklistDuration:1/0}),void this.trigger("error");var t=this.currentMediaInfo_,i=t.hasAudio,n=t.hasVideo,r=t.isMuxed,a="main"===this.loaderType_&&n,s=!this.audioDisabled_&&i&&!r;if(e.waitingOnAppends=0,!e.hasAppendedData_)return e.timingInfo||"number"!=typeof e.timestampOffset||(this.isPendingTimestampOffset_=!0),e.timingInfo={start:0},e.waitingOnAppends++,this.isPendingTimestampOffset_||(this.updateSourceBufferTimestampOffset_(e),this.processMetadataQueue_()),void this.checkAppendsDone_(e);a&&e.waitingOnAppends++,s&&e.waitingOnAppends++,a&&this.sourceUpdater_.videoQueueCallback(this.checkAppendsDone_.bind(this,e)),s&&this.sourceUpdater_.audioQueueCallback(this.checkAppendsDone_.bind(this,e));},r.checkAppendsDone_=function(e){this.checkForAbort_(e.requestId)||(e.waitingOnAppends--,0===e.waitingOnAppends&&this.handleAppendsDone_());},r.checkForIllegalMediaSwitch=function(e){var t=function(e,t,i){return "main"===e&&t&&i?i.hasAudio||i.hasVideo?t.hasVideo&&!i.hasVideo?"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.":!t.hasVideo&&i.hasVideo?"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.":null:"Neither audio nor video found in segment.":null}(this.loaderType_,this.currentMediaInfo_,e);return !!t&&(this.error({message:t,blacklistDuration:1/0}),this.trigger("error"),!0)},r.updateSourceBufferTimestampOffset_=function(e){if(null!==e.timestampOffset&&"number"==typeof e.timingInfo.start&&!e.changedTimestampOffset&&"main"===this.loaderType_){var t=!1;e.timestampOffset-=e.timingInfo.start,e.changedTimestampOffset=!0,e.timestampOffset!==this.sourceUpdater_.videoTimestampOffset()&&(this.sourceUpdater_.videoTimestampOffset(e.timestampOffset),t=!0),e.timestampOffset!==this.sourceUpdater_.audioTimestampOffset()&&(this.sourceUpdater_.audioTimestampOffset(e.timestampOffset),t=!0),t&&this.trigger("timestampoffset");}},r.updateTimingInfoEnd_=function(e){e.timingInfo=e.timingInfo||{};var t="main"===this.loaderType_&&this.currentMediaInfo_.hasVideo&&e.videoTimingInfo?e.videoTimingInfo:e.audioTimingInfo;t&&(e.timingInfo.end="number"==typeof t.end?t.end:t.start+e.duration);},r.handleAppendsDone_=function(){if(this.pendingSegment_&&this.trigger("appendsdone"),!this.pendingSegment_)return this.state="READY",void(this.paused()||this.monitorBuffer_());var e=this.pendingSegment_;if(this.updateTimingInfoEnd_(e),this.shouldSaveSegmentTimingInfo_&&this.syncController_.saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:"main"===this.loaderType_}),this.logger_(function(e){var t=e.segment,i=t.start,n=t.end,r=e.playlist,a=r.mediaSequence,s=r.id,o=r.segments,u=void 0===o?[]:o,d=e.mediaIndex,l=e.timeline;return ["appending ["+d+"] of ["+a+", "+(a+u.length)+"] from playlist ["+s+"]","["+i+" => "+n+"] in timeline ["+l+"]"].join(" ")}(e)),this.recordThroughput_(e),this.pendingSegment_=null,this.state="READY",e.isSyncRequest)this.trigger("syncinfoupdate");else {this.addSegmentMetadataCue_(e),this.fetchAtBuffer_=!0,this.currentTimeline_!==e.timeline&&(this.timelineChangeController_.lastTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline}),"main"!==this.loaderType_||this.audioDisabled_||this.timelineChangeController_.lastTimelineChange({type:"audio",from:this.currentTimeline_,to:e.timeline})),this.currentTimeline_=e.timeline,this.trigger("syncinfoupdate");var t=e.segment;t.end&&this.currentTime_()-t.end>3*e.playlist.targetDuration?this.resetEverything():(null!==this.mediaIndex&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.mediaIndex=e.mediaIndex,this.isEndOfStream_(e.mediaIndex,e.playlist)&&this.endOfStream(),this.trigger("appended"),this.paused()||this.monitorBuffer_());}},r.recordThroughput_=function(e){var t=this.throughput.rate,i=Date.now()-e.endOfAllRequests+1,n=Math.floor(e.byteLength/i*8*1e3);this.throughput.rate+=(n-t)/++this.throughput.count;},r.addSegmentMetadataCue_=function(e){if(this.segmentMetadataTrack_){var t=e.segment,n=t.start,r=t.end;if(Di(n)&&Di(r)){Pi(n,r,this.segmentMetadataTrack_);var a=i.WebKitDataCue||i.VTTCue,s={custom:t.custom,dateTimeObject:t.dateTimeObject,dateTimeString:t.dateTimeString,bandwidth:e.playlist.attributes.BANDWIDTH,resolution:e.playlist.attributes.RESOLUTION,codecs:e.playlist.attributes.CODECS,byteLength:e.byteLength,uri:e.uri,timeline:e.timeline,playlist:e.playlist.id,start:n,end:r},o=new a(n,r,JSON.stringify(s));o.value=s,this.segmentMetadataTrack_.addCue(o);}}},t}(n.EventTarget);function Fi(){}var Ni,qi=function(e){return "string"!=typeof e?e:e.replace(/./,(function(e){return e.toUpperCase()}))},Vi=["video","audio"],Wi=function(e,t){var i=t[e+"Buffer"];return i&&i.updating||t.queuePending[e]},Hi=function e(t,i){if(0!==i.queue.length){var n=0,r=i.queue[n];if("mediaSource"!==r.type){if("mediaSource"!==t&&i.started_&&"closed"!==i.mediaSource.readyState&&!Wi(t,i)){if(r.type!==t){if(null===(n=function(e,t){for(var i=0;i<t.length;i++){var n=t[i];if("mediaSource"===n.type)return null;if(n.type===e)return i}return null}(t,i.queue)))return;r=i.queue[n];}i.queue.splice(n,1),r.action(t,i),r.doneFn?i.queuePending[t]=r:e(t,i);}}else i.updating()||"closed"===i.mediaSource.readyState||(i.queue.shift(),r.action(i),r.doneFn&&r.doneFn(),e("audio",i),e("video",i));}},Gi=function(e,t){var i=t[e+"Buffer"],n=qi(e);i&&(i.removeEventListener("updateend",t["on"+n+"UpdateEnd_"]),i.removeEventListener("error",t["on"+n+"Error_"]),t.codecs[e]=null,t[e+"Buffer"]=null);},ji=function(e,t){return e&&t&&-1!==Array.prototype.indexOf.call(e.sourceBuffers,t)},zi=function(e,t){return function(i,n){var r=n[i+"Buffer"];ji(n.mediaSource,r)&&(n.logger_("Appending segment "+t.mediaIndex+"'s "+e.length+" bytes to "+i+"Buffer"),r.appendBuffer(e));}},Xi=function(e,t){return function(i,n){var r=n[i+"Buffer"];ji(n.mediaSource,r)&&(n.logger_("Removing "+e+" to "+t+" from "+i+"Buffer"),r.remove(e,t));}},Qi=function(e){return function(t,i){var n=i[t+"Buffer"];ji(i.mediaSource,n)&&(i.logger_("Setting "+t+"timestampOffset to "+e),n.timestampOffset=e);}},Yi=function(e){return function(t,i){e();}},Ki=function(e){return function(t){if("open"===t.mediaSource.readyState){t.logger_("Calling mediaSource endOfStream("+(e||"")+")");try{t.mediaSource.endOfStream(e);}catch(e){n.log.warn("Failed to call media source endOfStream",e);}}}},$i=function(e,t){return function(i){var n=qi(e),r=gi(t);i.logger_("Adding "+e+"Buffer with codec "+t+" to mediaSource");var a=i.mediaSource.addSourceBuffer(r);a.addEventListener("updateend",i["on"+n+"UpdateEnd_"]),a.addEventListener("error",i["on"+n+"Error_"]),i.codecs[e]=t,i[e+"Buffer"]=a;}},Ji=function(e){return function(t){var i=t[e+"Buffer"];if(Gi(e,t),ji(t.mediaSource,i)){t.logger_("Removing "+e+"Buffer with codec "+t.codecs[e]+" from mediaSource");try{t.mediaSource.removeSourceBuffer(i);}catch(t){n.log.warn("Failed to removeSourceBuffer "+e+"Buffer",t);}}}},Zi=function(e){return function(t,i){var n=i[t+"Buffer"],r=gi(e);ji(i.mediaSource,n)&&i.codecs[t]!==e&&(i.logger_("changing "+t+"Buffer codec from "+i.codecs[t]+" to "+e),n.changeType(r),i.codecs[t]=e);}},en=function(e){var t=e.type,i=e.sourceUpdater,n=e.action,r=e.doneFn,a=e.name;i.queue.push({type:t,action:n,doneFn:r,name:a}),Hi(t,i);},tn=function(e,t){return function(i){if(t.queuePending[e]){var n=t.queuePending[e].doneFn;t.queuePending[e]=null,n&&n(t[e+"Error_"]);}Hi(e,t);}},nn=function(e){function t(t){var i;return (i=e.call(this)||this).mediaSource=t,i.sourceopenListener_=function(){return Hi("mediaSource",a(i))},i.mediaSource.addEventListener("sourceopen",i.sourceopenListener_),i.logger_=Ai("SourceUpdater"),i.audioTimestampOffset_=0,i.videoTimestampOffset_=0,i.queue=[],i.queuePending={audio:null,video:null},i.delayedAudioAppendQueue_=[],i.videoAppendQueued_=!1,i.codecs={},i.onVideoUpdateEnd_=tn("video",a(i)),i.onAudioUpdateEnd_=tn("audio",a(i)),i.onVideoError_=function(e){i.videoError_=e;},i.onAudioError_=function(e){i.audioError_=e;},i.started_=!1,i}s(t,e);var r=t.prototype;return r.ready=function(){return this.started_},r.createSourceBuffers=function(e){this.ready()||(this.addOrChangeSourceBuffers(e),this.started_=!0,this.trigger("ready"));},r.addSourceBuffer=function(e,t){en({type:"mediaSource",sourceUpdater:this,action:$i(e,t),name:"addSourceBuffer"});},r.abort=function(e){en({type:e,sourceUpdater:this,action:function(e,t){if("open"===t.mediaSource.readyState){var i=t[e+"Buffer"];if(ji(t.mediaSource,i)){t.logger_("calling abort on "+e+"Buffer");try{i.abort();}catch(t){n.log.warn("Failed to abort on "+e+"Buffer",t);}}}},name:"abort"});},r.removeSourceBuffer=function(e){this.canRemoveSourceBuffer()?en({type:"mediaSource",sourceUpdater:this,action:Ji(e),name:"removeSourceBuffer"}):n.log.error("removeSourceBuffer is not supported!");},r.canRemoveSourceBuffer=function(){return !n.browser.IE_VERSION&&i.MediaSource&&i.MediaSource.prototype&&"function"==typeof i.MediaSource.prototype.removeSourceBuffer},t.canChangeType=function(){return i.SourceBuffer&&i.SourceBuffer.prototype&&"function"==typeof i.SourceBuffer.prototype.changeType},r.canChangeType=function(){return this.constructor.canChangeType()},r.changeType=function(e,t){this.canChangeType()?en({type:e,sourceUpdater:this,action:Zi(t),name:"changeType"}):n.log.error("changeType is not supported!");},r.addOrChangeSourceBuffers=function(e){var t=this;if(!e||"object"!=typeof e||0===Object.keys(e).length)throw new Error("Cannot addOrChangeSourceBuffers to undefined codecs");Object.keys(e).forEach((function(i){var n=e[i];if(!t.ready())return t.addSourceBuffer(i,n);t.canChangeType()&&t.changeType(i,n);}));},r.appendBuffer=function(e,t){var i=this,n=e.segmentInfo,r=e.type,a=e.bytes;if(this.processedAppend_=!0,"audio"===r&&this.videoBuffer&&!this.videoAppendQueued_)return this.delayedAudioAppendQueue_.push([e,t]),void this.logger_("delayed audio append of "+a.length+" until video append");if(en({type:r,sourceUpdater:this,action:zi(a,n||{mediaIndex:-1}),doneFn:t,name:"appendBuffer"}),"video"===r){if(this.videoAppendQueued_=!0,!this.delayedAudioAppendQueue_.length)return;var s=this.delayedAudioAppendQueue_.slice();this.logger_("queuing delayed audio "+s.length+" appendBuffers"),this.delayedAudioAppendQueue_.length=0,s.forEach((function(e){i.appendBuffer.apply(i,e);}));}},r.audioBuffered=function(){return ji(this.mediaSource,this.audioBuffer)&&this.audioBuffer.buffered?this.audioBuffer.buffered:n.createTimeRange()},r.videoBuffered=function(){return ji(this.mediaSource,this.videoBuffer)&&this.videoBuffer.buffered?this.videoBuffer.buffered:n.createTimeRange()},r.buffered=function(){var e=ji(this.mediaSource,this.videoBuffer)?this.videoBuffer:null,t=ji(this.mediaSource,this.audioBuffer)?this.audioBuffer:null;return t&&!e?this.audioBuffered():e&&!t?this.videoBuffered():function(e,t){var i=null,r=null,a=0,s=[],o=[];if(!(e&&e.length&&t&&t.length))return n.createTimeRange();for(var u=e.length;u--;)s.push({time:e.start(u),type:"start"}),s.push({time:e.end(u),type:"end"});for(u=t.length;u--;)s.push({time:t.start(u),type:"start"}),s.push({time:t.end(u),type:"end"});for(s.sort((function(e,t){return e.time-t.time})),u=0;u<s.length;u++)"start"===s[u].type?2==++a&&(i=s[u].time):"end"===s[u].type&&1==--a&&(r=s[u].time),null!==i&&null!==r&&(o.push([i,r]),i=null,r=null);return n.createTimeRanges(o)}(this.audioBuffered(),this.videoBuffered())},r.setDuration=function(e,t){var i;void 0===t&&(t=Fi),en({type:"mediaSource",sourceUpdater:this,action:(i=e,function(e){e.logger_("Setting mediaSource duration to "+i);try{e.mediaSource.duration=i;}catch(e){n.log.warn("Failed to set media source duration",e);}}),name:"duration",doneFn:t});},r.endOfStream=function(e,t){void 0===e&&(e=null),void 0===t&&(t=Fi),"string"!=typeof e&&(e=void 0),en({type:"mediaSource",sourceUpdater:this,action:Ki(e),name:"endOfStream",doneFn:t});},r.removeAudio=function(e,t,i){void 0===i&&(i=Fi),this.audioBuffered().length&&0!==this.audioBuffered().end(0)?en({type:"audio",sourceUpdater:this,action:Xi(e,t),doneFn:i,name:"remove"}):i();},r.removeVideo=function(e,t,i){void 0===i&&(i=Fi),this.videoBuffered().length&&0!==this.videoBuffered().end(0)?en({type:"video",sourceUpdater:this,action:Xi(e,t),doneFn:i,name:"remove"}):i();},r.updating=function(){return !(!Wi("audio",this)&&!Wi("video",this))},r.audioTimestampOffset=function(e){return void 0!==e&&this.audioBuffer&&this.audioTimestampOffset_!==e&&(en({type:"audio",sourceUpdater:this,action:Qi(e),name:"timestampOffset"}),this.audioTimestampOffset_=e),this.audioTimestampOffset_},r.videoTimestampOffset=function(e){return void 0!==e&&this.videoBuffer&&this.videoTimestampOffset!==e&&(en({type:"video",sourceUpdater:this,action:Qi(e),name:"timestampOffset"}),this.videoTimestampOffset_=e),this.videoTimestampOffset_},r.audioQueueCallback=function(e){this.audioBuffer&&en({type:"audio",sourceUpdater:this,action:Yi(e),name:"callback"});},r.videoQueueCallback=function(e){this.videoBuffer&&en({type:"video",sourceUpdater:this,action:Yi(e),name:"callback"});},r.dispose=function(){var e=this;this.trigger("dispose"),Vi.forEach((function(t){e.abort(t),e.canRemoveSourceBuffer()?e.removeSourceBuffer(t):e[t+"QueueCallback"]((function(){return Gi(t,e)}));})),this.videoAppendQueued_=!1,this.delayedAudioAppendQueue_.length=0,this.sourceopenListener_&&this.mediaSource.removeEventListener("sourceopen",this.sourceopenListener_),this.off();},t}(n.EventTarget),rn=function(e){return decodeURIComponent(escape(String.fromCharCode.apply(null,e)))},an=new Uint8Array("\n\n".split("").map((function(e){return e.charCodeAt(0)}))),sn=function(e){function t(t,i){var n;return void 0===i&&(i={}),(n=e.call(this,t,i)||this).handlePartialData_=!1,n.mediaSource_=null,n.subtitlesTrack_=null,n.loaderType_="subtitle",n.featuresNativeTextTracks_=t.featuresNativeTextTracks,n.shouldSaveSegmentTimingInfo_=!1,n}s(t,e);var r=t.prototype;return r.createTransmuxer_=function(){return null},r.buffered_=function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length)return n.createTimeRanges();var e=this.subtitlesTrack_.cues,t=e[0].startTime,i=e[e.length-1].startTime;return n.createTimeRanges([[t,i]])},r.initSegmentForMap=function(e,t){if(void 0===t&&(t=!1),!e)return null;var i=le(e),n=this.initSegments_[i];if(t&&!n&&e.bytes){var r=an.byteLength+e.bytes.byteLength,a=new Uint8Array(r);a.set(e.bytes),a.set(an,e.bytes.byteLength),this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:a};}return n||e},r.couldBeginLoading_=function(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()},r.init_=function(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()},r.track=function(e){return void 0===e||(this.subtitlesTrack_=e,"INIT"===this.state&&this.couldBeginLoading_()&&this.init_()),this.subtitlesTrack_},r.remove=function(e,t){Pi(e,t,this.subtitlesTrack_);},r.fillBuffer_=function(){var e=this;this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var t=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(t=this.skipEmptySegments_(t)){if(null===this.syncController_.timestampOffsetForTimeline(t.timeline))return this.syncController_.one("timestampoffset",(function(){e.state="READY",e.paused()||e.monitorBuffer_();})),void(this.state="WAITING_ON_TIMELINE");this.loadSegment_(t);}},r.skipEmptySegments_=function(e){for(;e&&e.segment.empty;)e=this.generateSegmentInfo_(e.playlist,e.mediaIndex+1,e.startOfSegment+e.duration,e.isSyncRequest);return e},r.stopForError=function(e){this.error(e),this.state="READY",this.pause(),this.trigger("error");},r.segmentRequestFinished_=function(e,t,n){var r=this;if(this.subtitlesTrack_){if(this.saveTransferStats_(t.stats),!this.pendingSegment_)return this.state="READY",void(this.mediaRequestsAborted+=1);if(e)return -101===e.code&&this.handleTimeout_(),-102===e.code?this.mediaRequestsAborted+=1:this.mediaRequestsErrored+=1,void this.stopForError(e);this.saveBandwidthRelatedStats_(t.stats),this.state="APPENDING",this.trigger("appending");var a=this.pendingSegment_,s=a.segment;if(s.map&&(s.map.bytes=t.map.bytes),a.bytes=t.bytes,"function"!=typeof i.WebVTT&&this.subtitlesTrack_&&this.subtitlesTrack_.tech_){var o,u=function(){r.subtitlesTrack_.tech_.off("vttjsloaded",o),r.stopForError({message:"Error loading vtt.js"});};return o=function(){r.subtitlesTrack_.tech_.off("vttjserror",u),r.segmentRequestFinished_(e,t,n);},this.state="WAITING_ON_VTTJS",this.subtitlesTrack_.tech_.one("vttjsloaded",o),void this.subtitlesTrack_.tech_.one("vttjserror",u)}s.requested=!0;try{this.parseVTTCues_(a);}catch(e){return void this.stopForError({message:e.message})}if(this.updateTimeMapping_(a,this.syncController_.timelines[a.timeline],this.playlist_),a.cues.length?a.timingInfo={start:a.cues[0].startTime,end:a.cues[a.cues.length-1].endTime}:a.timingInfo={start:a.startOfSegment,end:a.startOfSegment+a.duration},a.isSyncRequest)return this.trigger("syncinfoupdate"),this.pendingSegment_=null,void(this.state="READY");a.byteLength=a.bytes.byteLength,this.mediaSecondsLoaded+=s.duration,a.cues.forEach((function(e){r.subtitlesTrack_.addCue(r.featuresNativeTextTracks_?new i.VTTCue(e.startTime,e.endTime,e.text):e);})),function(e){var t=e.cues;if(t)for(var i=0;i<t.length;i++){for(var n=[],r=0,a=0;a<t.length;a++)t[i].startTime===t[a].startTime&&t[i].endTime===t[a].endTime&&t[i].text===t[a].text&&++r>1&&n.push(t[a]);n.length&&n.forEach((function(t){return e.removeCue(t)}));}}(this.subtitlesTrack_),this.handleAppendsDone_();}else this.state="READY";},r.handleData_=function(){},r.updateTimingInfoEnd_=function(){},r.parseVTTCues_=function(e){var t,r=!1;"function"==typeof i.TextDecoder?t=new i.TextDecoder("utf8"):(t=i.WebVTT.StringDecoder(),r=!0);var a=new i.WebVTT.Parser(i,i.vttjs,t);if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},a.oncue=e.cues.push.bind(e.cues),a.ontimestampmap=function(t){e.timestampmap=t;},a.onparsingerror=function(e){n.log.warn("Error encountered when parsing cues: "+e.message);},e.segment.map){var s=e.segment.map.bytes;r&&(s=rn(s)),a.parse(s);}var o=e.bytes;r&&(o=rn(o)),a.parse(o),a.flush();},r.updateTimeMapping_=function(e,t,i){var n=e.segment;if(t)if(e.cues.length){var r=e.timestampmap,a=r.MPEGTS/Pt-r.LOCAL+t.mapping;if(e.cues.forEach((function(e){e.startTime+=a,e.endTime+=a;})),!i.syncInfo){var s=e.cues[0].startTime,o=e.cues[e.cues.length-1].startTime;i.syncInfo={mediaSequence:i.mediaSequence+e.mediaIndex,time:Math.min(s,o-n.duration)};}}else n.empty=!0;},t}(Bi),on=function(e,t){for(var i=e.cues,n=0;n<i.length;n++){var r=i[n];if(t>=r.adStartTime&&t<=r.adEndTime)return r}return null},un=[{name:"VOD",run:function(e,t,i,n,r){return i!==1/0?{time:0,segmentIndex:0}:null}},{name:"ProgramDateTime",run:function(e,t,i,n,r){if(!e.datetimeToDisplayTime)return null;var a=t.segments||[],s=null,o=null;r=r||0;for(var u=0;u<a.length;u++){var d=a[u];if(d.dateTimeObject){var l=d.dateTimeObject.getTime()/1e3+e.datetimeToDisplayTime,h=Math.abs(r-l);if(null!==o&&(0===h||o<h))break;o=h,s={time:l,segmentIndex:u};}}return s}},{name:"Segment",run:function(e,t,i,n,r){var a=t.segments||[],s=null,o=null;r=r||0;for(var u=0;u<a.length;u++){var d=a[u];if(d.timeline===n&&void 0!==d.start){var l=Math.abs(r-d.start);if(null!==o&&o<l)break;(!s||null===o||o>=l)&&(o=l,s={time:d.start,segmentIndex:u});}}return s}},{name:"Discontinuity",run:function(e,t,i,n,r){var a=null;if(r=r||0,t.discontinuityStarts&&t.discontinuityStarts.length)for(var s=null,o=0;o<t.discontinuityStarts.length;o++){var u=t.discontinuityStarts[o],d=t.discontinuitySequence+o+1,l=e.discontinuities[d];if(l){var h=Math.abs(r-l.time);if(null!==s&&s<h)break;(!a||null===s||s>=h)&&(s=h,a={time:l.time,segmentIndex:u});}}return a}},{name:"Playlist",run:function(e,t,i,n,r){return t.syncInfo?{time:t.syncInfo.time,segmentIndex:t.syncInfo.mediaSequence-t.mediaSequence}:null}}],dn=function(e){function t(t){var i;return (i=e.call(this)||this).timelines=[],i.discontinuities=[],i.datetimeToDisplayTime=null,i.logger_=Ai("SyncController"),i}s(t,e);var i=t.prototype;return i.getSyncPoint=function(e,t,i,n){var r=this.runStrategies_(e,t,i,n);return r.length?this.selectSyncPoint_(r,{key:"time",value:n}):null},i.getExpiredTime=function(e,t){if(!e||!e.segments)return null;var i=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!i.length)return null;var n=this.selectSyncPoint_(i,{key:"segmentIndex",value:0});return n.segmentIndex>0&&(n.time*=-1),Math.abs(n.time+G(e,n.segmentIndex,0))},i.runStrategies_=function(e,t,i,n){for(var r=[],a=0;a<un.length;a++){var s=un[a],o=s.run(this,e,t,i,n);o&&(o.strategy=s.name,r.push({strategy:s.name,syncPoint:o}));}return r},i.selectSyncPoint_=function(e,t){for(var i=e[0].syncPoint,n=Math.abs(e[0].syncPoint[t.key]-t.value),r=e[0].strategy,a=1;a<e.length;a++){var s=Math.abs(e[a].syncPoint[t.key]-t.value);s<n&&(n=s,i=e[a].syncPoint,r=e[a].strategy);}return this.logger_("syncPoint for ["+t.key+": "+t.value+"] chosen with strategy ["+r+"]: [time:"+i.time+", segmentIndex:"+i.segmentIndex+"]"),i},i.saveExpiredSegmentInfo=function(e,t){for(var i=t.mediaSequence-e.mediaSequence-1;i>=0;i--){var n=e.segments[i];if(n&&void 0!==n.start){t.syncInfo={mediaSequence:e.mediaSequence+i,time:n.start},this.logger_("playlist refresh sync: [time:"+t.syncInfo.time+", mediaSequence: "+t.syncInfo.mediaSequence+"]"),this.trigger("syncinfoupdate");break}}},i.setDateTimeMapping=function(e){if(!this.datetimeToDisplayTime&&e.segments&&e.segments.length&&e.segments[0].dateTimeObject){var t=e.segments[0].dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-t;}},i.saveSegmentTimingInfo=function(e){var t=e.segmentInfo,i=e.shouldSaveTimelineMapping;this.calculateSegmentTimeMapping_(t,t.timingInfo,i)&&(this.saveDiscontinuitySyncInfo_(t),t.playlist.syncInfo||(t.playlist.syncInfo={mediaSequence:t.playlist.mediaSequence+t.mediaIndex,time:t.segment.start}));},i.timestampOffsetForTimeline=function(e){return void 0===this.timelines[e]?null:this.timelines[e].time},i.mappingForTimeline=function(e){return void 0===this.timelines[e]?null:this.timelines[e].mapping},i.calculateSegmentTimeMapping_=function(e,t,i){var n=e.segment,r=this.timelines[e.timeline];if(null!==e.timestampOffset)r={time:e.startOfSegment,mapping:e.startOfSegment-t.start},i&&(this.timelines[e.timeline]=r,this.trigger("timestampoffset"),this.logger_("time mapping for timeline "+e.timeline+": [time: "+r.time+"] [mapping: "+r.mapping+"]")),n.start=e.startOfSegment,n.end=t.end+r.mapping;else {if(!r)return !1;n.start=t.start+r.mapping,n.end=t.end+r.mapping;}return !0},i.saveDiscontinuitySyncInfo_=function(e){var t=e.playlist,i=e.segment;if(i.discontinuity)this.discontinuities[i.timeline]={time:i.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(var n=0;n<t.discontinuityStarts.length;n++){var r=t.discontinuityStarts[n],a=t.discontinuitySequence+n+1,s=r-e.mediaIndex,o=Math.abs(s);if(!this.discontinuities[a]||this.discontinuities[a].accuracy>o){var u;u=s<0?i.start-G(t,e.mediaIndex,r):i.end+G(t,e.mediaIndex+1,r),this.discontinuities[a]={time:u,accuracy:o};}}},i.dispose=function(){this.trigger("dispose"),this.off();},t}(n.EventTarget),ln=function(e){function t(){var t;return (t=e.call(this)||this).pendingTimelineChanges_={},t.lastTimelineChanges_={},t}s(t,e);var i=t.prototype;return i.clearPendingTimelineChange=function(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange");},i.pendingTimelineChange=function(e){var t=e.type,i=e.from,n=e.to;return "number"==typeof i&&"number"==typeof n&&(this.pendingTimelineChanges_[t]={type:t,from:i,to:n},this.trigger("pendingtimelinechange")),this.pendingTimelineChanges_[t]},i.lastTimelineChange=function(e){var t=e.type,i=e.from,n=e.to;return "number"==typeof i&&"number"==typeof n&&(this.lastTimelineChanges_[t]={type:t,from:i,to:n},delete this.pendingTimelineChanges_[t],this.trigger("timelinechange")),this.lastTimelineChanges_[t]},i.dispose=function(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off();},t}(n.EventTarget),hn=new ai("./decrypter-worker.worker.js",(function(e,t){var i=this;
|
||
/*! @name @videojs/http-streaming @version 2.3.1 @license Apache-2.0 */!function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n);}}var t=function(){function e(){this.listeners={};}var t=e.prototype;return t.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t);},t.off=function(e,t){if(!this.listeners[e])return !1;var i=this.listeners[e].indexOf(t);return this.listeners[e]=this.listeners[e].slice(0),this.listeners[e].splice(i,1),i>-1},t.trigger=function(e){var t=this.listeners[e];if(t)if(2===arguments.length)for(var i=t.length,n=0;n<i;++n)t[n].call(this,arguments[1]);else for(var r=Array.prototype.slice.call(arguments,1),a=t.length,s=0;s<a;++s)t[s].apply(this,r);},t.dispose=function(){this.listeners={};},t.pipe=function(e){this.on("data",(function(t){e.push(t);}));},e}(),n=null,r=function(){function e(e){var t,i,r;n||(n=function(){var e,t,i,n,r,a,s,o,u=[[[],[],[],[],[]],[[],[],[],[],[]]],d=u[0],l=u[1],h=d[4],c=l[4],f=[],m=[];for(e=0;e<256;e++)m[(f[e]=e<<1^283*(e>>7))^e]=e;for(t=i=0;!h[t];t^=n||1,i=m[i]||1)for(a=(a=i^i<<1^i<<2^i<<3^i<<4)>>8^255&a^99,h[t]=a,c[a]=t,o=16843009*f[r=f[n=f[t]]]^65537*r^257*n^16843008*t,s=257*f[a]^16843008*a,e=0;e<4;e++)d[e][t]=s=s<<24^s>>>8,l[e][a]=o=o<<24^o>>>8;for(e=0;e<5;e++)d[e]=d[e].slice(0),l[e]=l[e].slice(0);return u}()),this._tables=[[n[0][0].slice(),n[0][1].slice(),n[0][2].slice(),n[0][3].slice(),n[0][4].slice()],[n[1][0].slice(),n[1][1].slice(),n[1][2].slice(),n[1][3].slice(),n[1][4].slice()]];var a=this._tables[0][4],s=this._tables[1],o=e.length,u=1;if(4!==o&&6!==o&&8!==o)throw new Error("Invalid aes key size");var d=e.slice(0),l=[];for(this._key=[d,l],t=o;t<4*o+28;t++)r=d[t-1],(t%o==0||8===o&&t%o==4)&&(r=a[r>>>24]<<24^a[r>>16&255]<<16^a[r>>8&255]<<8^a[255&r],t%o==0&&(r=r<<8^r>>>24^u<<24,u=u<<1^283*(u>>7))),d[t]=d[t-o]^r;for(i=0;t;i++,t--)r=d[3&i?t:t-4],l[i]=t<=4||i<4?r:s[0][a[r>>>24]]^s[1][a[r>>16&255]]^s[2][a[r>>8&255]]^s[3][a[255&r]];}return e.prototype.decrypt=function(e,t,i,n,r,a){var s,o,u,d,l=this._key[1],h=e^l[0],c=n^l[1],f=i^l[2],m=t^l[3],p=l.length/4-2,g=4,y=this._tables[1],_=y[0],v=y[1],b=y[2],T=y[3],S=y[4];for(d=0;d<p;d++)s=_[h>>>24]^v[c>>16&255]^b[f>>8&255]^T[255&m]^l[g],o=_[c>>>24]^v[f>>16&255]^b[m>>8&255]^T[255&h]^l[g+1],u=_[f>>>24]^v[m>>16&255]^b[h>>8&255]^T[255&c]^l[g+2],m=_[m>>>24]^v[h>>16&255]^b[c>>8&255]^T[255&f]^l[g+3],g+=4,h=s,c=o,f=u;for(d=0;d<4;d++)r[(3&-d)+a]=S[h>>>24]<<24^S[c>>16&255]<<16^S[f>>8&255]<<8^S[255&m]^l[g++],s=h,h=c,c=f,f=m,m=s;},e}(),a=function(e){function i(){var i;return (i=e.call(this,t)||this).jobs=[],i.delay=1,i.timeout_=null,i}var n,r;r=e,(n=i).prototype=Object.create(r.prototype),n.prototype.constructor=n,n.__proto__=r;var a=i.prototype;return a.processJob_=function(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null;},a.push=function(e){this.jobs.push(e),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay));},i}(t),s=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},o=function(){function t(e,i,n,r){var o=t.STEP,u=new Int32Array(e.buffer),d=new Uint8Array(e.byteLength),l=0;for(this.asyncStream_=new a,this.asyncStream_.push(this.decryptChunk_(u.subarray(l,l+o),i,n,d)),l=o;l<u.length;l+=o)n=new Uint32Array([s(u[l-4]),s(u[l-3]),s(u[l-2]),s(u[l-1])]),this.asyncStream_.push(this.decryptChunk_(u.subarray(l,l+o),i,n,d));this.asyncStream_.push((function(){
|
||
/*! @name pkcs7 @version 1.0.4 @license Apache-2.0 */
|
||
var e;
|
||
/*! @name aes-decrypter @version 3.1.0 @license Apache-2.0 */r(null,(e=d).subarray(0,e.byteLength-e[e.byteLength-1]));}));}return t.prototype.decryptChunk_=function(e,t,i,n){return function(){var a=function(e,t,i){var n,a,o,u,d,l,h,c,f,m=new Int32Array(e.buffer,e.byteOffset,e.byteLength>>2),p=new r(Array.prototype.slice.call(t)),g=new Uint8Array(e.byteLength),y=new Int32Array(g.buffer);for(n=i[0],a=i[1],o=i[2],u=i[3],f=0;f<m.length;f+=4)d=s(m[f]),l=s(m[f+1]),h=s(m[f+2]),c=s(m[f+3]),p.decrypt(d,l,h,c,y,f),y[f]=s(y[f]^n),y[f+1]=s(y[f+1]^a),y[f+2]=s(y[f+2]^o),y[f+3]=s(y[f+3]^u),n=d,a=l,o=h,u=c;return g}(e,t,i);n.set(a,e.byteOffset);}},i=t,o=[{key:"STEP",get:function(){return 32e3}}],(n=null)&&e(i.prototype,n),o&&e(i,o),t;var i,n,o;}();new function(e){e.onmessage=function(t){var i=t.data,n=new Uint8Array(i.encrypted.bytes,i.encrypted.byteOffset,i.encrypted.byteLength),r=new Uint32Array(i.key.bytes,i.key.byteOffset,i.key.byteLength/4),a=new Uint32Array(i.iv.bytes,i.iv.byteOffset,i.iv.byteLength/4);new o(n,r,a,(function(t,n){var r,a;e.postMessage((r={source:i.source,decrypted:n},a={},Object.keys(r).forEach((function(e){var t=r[e];ArrayBuffer.isView(t)?a[e]={bytes:t.buffer,byteOffset:t.byteOffset,byteLength:t.byteLength}:a[e]=t;})),a),[n.buffer]);}));};}(i);}();})),cn=function(e){var t=e.default?"main":"alternative";return e.characteristics&&e.characteristics.indexOf("public.accessibility.describes-video")>=0&&(t="main-desc"),t},fn=function(e,t){e.abort(),e.pause(),t&&t.activePlaylistLoader&&(t.activePlaylistLoader.pause(),t.activePlaylistLoader=null);},mn=function(e,t){t.activePlaylistLoader=e,e.load();},pn={AUDIO:function(e,t){return function(){var i=t.segmentLoaders[e],r=t.mediaTypes[e],a=t.blacklistCurrentPlaylist;fn(i,r);var s=r.activeTrack(),o=r.activeGroup(),u=(o.filter((function(e){return e.default}))[0]||o[0]).id,d=r.tracks[u];if(s!==d){for(var l in n.log.warn("Problem encountered loading the alternate audio track.Switching back to default."),r.tracks)r.tracks[l].enabled=r.tracks[l]===d;r.onTrackChanged();}else a({message:"Problem encountered loading the default audio track."});}},SUBTITLES:function(e,t){return function(){var i=t.segmentLoaders[e],r=t.mediaTypes[e];n.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),fn(i,r);var a=r.activeTrack();a&&(a.mode="disabled"),r.onTrackChanged();}}},gn={AUDIO:function(e,t,i){if(t){var n=i.tech,r=i.requestOptions,a=i.segmentLoaders[e];t.on("loadedmetadata",(function(){var e=t.media();a.playlist(e,r),(!n.paused()||e.endList&&"none"!==n.preload())&&a.load();})),t.on("loadedplaylist",(function(){a.playlist(t.media(),r),n.paused()||a.load();})),t.on("error",pn[e](e,i));}},SUBTITLES:function(e,t,i){var n=i.tech,r=i.requestOptions,a=i.segmentLoaders[e],s=i.mediaTypes[e];t.on("loadedmetadata",(function(){var e=t.media();a.playlist(e,r),a.track(s.activeTrack()),(!n.paused()||e.endList&&"none"!==n.preload())&&a.load();})),t.on("loadedplaylist",(function(){a.playlist(t.media(),r),n.paused()||a.load();})),t.on("error",pn[e](e,i));}},yn={AUDIO:function(e,t){var i=t.vhs,r=t.sourceType,a=t.segmentLoaders[e],s=t.requestOptions,o=t.master,u=o.mediaGroups,d=o.playlists,l=t.mediaTypes[e],h=l.groups,c=l.tracks,f=t.masterPlaylistLoader;u[e]&&0!==Object.keys(u[e]).length||(u[e]={main:{default:{default:!0}}});var m=function(a){h[a]||(h[a]=[]);var o=d.filter((function(t){return t.attributes[e]===a})),l=function(d){var l=u[e][a][d];!o.filter((function(e){return e.resolvedUri!==l.resolvedUri})).length&&o.length&&delete l.resolvedUri;var m;if(m="vhs-json"===r&&l.playlists?new R(l.playlists[0],i,s):l.resolvedUri?new R(l.resolvedUri,i,s):l.playlists&&"dash"===r?new dt(l.playlists[0],i,s,f):null,l=n.mergeOptions({id:d,playlistLoader:m},l),gn[e](e,l.playlistLoader,t),h[a].push(l),void 0===c[d]){var p=new n.AudioTrack({id:d,kind:cn(l),enabled:!1,language:l.language,default:l.default,label:d});c[d]=p;}};for(var m in u[e][a])l(m);};for(var p in u[e])m(p);a.on("error",pn[e](e,t));},SUBTITLES:function(e,t){var i=t.tech,r=t.vhs,a=t.sourceType,s=t.segmentLoaders[e],o=t.requestOptions,u=t.master.mediaGroups,d=t.mediaTypes[e],l=d.groups,h=d.tracks,c=t.masterPlaylistLoader;for(var f in u[e])for(var m in l[f]||(l[f]=[]),u[e][f])if(!u[e][f][m].forced){var p=u[e][f][m],g=void 0;if("hls"===a?g=new R(p.resolvedUri,r,o):"dash"===a?g=new dt(p.playlists[0],r,o,c):"vhs-json"===a&&(g=new R(p.playlists?p.playlists[0]:p.resolvedUri,r,o)),p=n.mergeOptions({id:m,playlistLoader:g},p),gn[e](e,p.playlistLoader,t),l[f].push(p),void 0===h[m]){var y=i.addRemoteTextTrack({id:m,kind:"subtitles",default:p.default&&p.autoselect,language:p.language,label:m},!1).track;h[m]=y;}}s.on("error",pn[e](e,t));},"CLOSED-CAPTIONS":function(e,t){var i=t.tech,r=t.master.mediaGroups,a=t.mediaTypes[e],s=a.groups,o=a.tracks;for(var u in r[e])for(var d in s[u]||(s[u]=[]),r[e][u]){var l=r[e][u][d];if(l.instreamId.match(/CC\d/)&&(s[u].push(n.mergeOptions({id:d},l)),void 0===o[d])){var h=i.addRemoteTextTrack({id:l.instreamId,kind:"captions",default:l.default&&l.autoselect,language:l.language,label:d},!1).track;o[d]=h;}}}},_n={AUDIO:function(e,t){return function(){var i=t.mediaTypes[e].tracks;for(var n in i)if(i[n].enabled)return i[n];return null}},SUBTITLES:function(e,t){return function(){var i=t.mediaTypes[e].tracks;for(var n in i)if("showing"===i[n].mode||"hidden"===i[n].mode)return i[n];return null}}},vn=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],bn=function(e){return this.audioSegmentLoader_[e]+this.mainSegmentLoader_[e]},Tn=function(e){function t(t){var r;r=e.call(this)||this;var s=t.src,o=t.handleManifestRedirects,u=t.withCredentials,d=t.tech,l=t.bandwidth,h=t.externVhs,c=t.useCueTags,f=t.blacklistDuration,m=t.enableLowInitialPlaylist,p=t.sourceType,g=t.cacheEncryptionKeys,y=t.handlePartialData,_=t.experimentalBufferBasedABR;if(!s)throw new Error("A non-empty playlist URL or JSON manifest string is required");Ni=h,r.experimentalBufferBasedABR=Boolean(_),r.withCredentials=u,r.tech_=d,r.vhs_=d.vhs,r.sourceType_=p,r.useCueTags_=c,r.blacklistDuration=f,r.enableLowInitialPlaylist=m,r.useCueTags_&&(r.cueTagsTrack_=r.tech_.addTextTrack("metadata","ad-cues"),r.cueTagsTrack_.inBandMetadataTrackDispatchType=""),r.requestOptions_={withCredentials:u,handleManifestRedirects:o,timeout:null},r.on("error",r.pauseLoading),r.mediaTypes_=function(){var e={};return ["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((function(t){e[t]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Fi,activeTrack:Fi,onGroupChanged:Fi,onTrackChanged:Fi};})),e}(),r.mediaSource=new i.MediaSource,r.handleDurationChange_=r.handleDurationChange_.bind(a(r)),r.handleSourceOpen_=r.handleSourceOpen_.bind(a(r)),r.handleSourceEnded_=r.handleSourceEnded_.bind(a(r)),r.mediaSource.addEventListener("durationchange",r.handleDurationChange_),r.mediaSource.addEventListener("sourceopen",r.handleSourceOpen_),r.mediaSource.addEventListener("sourceended",r.handleSourceEnded_),r.seekable_=n.createTimeRanges(),r.hasPlayed_=!1,r.syncController_=new dn(t),r.segmentMetadataTrack_=d.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,r.decrypter_=new hn,r.sourceUpdater_=new nn(r.mediaSource),r.inbandTextTracks_={},r.timelineChangeController_=new ln;var v={vhs:r.vhs_,mediaSource:r.mediaSource,currentTime:r.tech_.currentTime.bind(r.tech_),seekable:function(){return r.seekable()},seeking:function(){return r.tech_.seeking()},duration:function(){return r.duration()},hasPlayed:function(){return r.hasPlayed_},goalBufferLength:function(){return r.goalBufferLength()},bandwidth:l,syncController:r.syncController_,decrypter:r.decrypter_,sourceType:r.sourceType_,inbandTextTracks:r.inbandTextTracks_,cacheEncryptionKeys:g,handlePartialData:y,sourceUpdater:r.sourceUpdater_,timelineChangeController:r.timelineChangeController_};return r.masterPlaylistLoader_="dash"===r.sourceType_?new dt(s,r.vhs_,r.requestOptions_):new R(s,r.vhs_,r.requestOptions_),r.setupMasterPlaylistLoaderListeners_(),r.mainSegmentLoader_=new Bi(n.mergeOptions(v,{segmentMetadataTrack:r.segmentMetadataTrack_,loaderType:"main"}),t),r.audioSegmentLoader_=new Bi(n.mergeOptions(v,{loaderType:"audio"}),t),r.subtitleSegmentLoader_=new sn(n.mergeOptions(v,{loaderType:"vtt",featuresNativeTextTracks:r.tech_.featuresNativeTextTracks}),t),r.setupSegmentLoaderListeners_(),r.experimentalBufferBasedABR&&(r.startABRTimer_(),r.tech_.on("pause",(function(){return r.stopABRTimer_()})),r.tech_.on("play",(function(){return r.startABRTimer_()}))),vn.forEach((function(e){r[e+"_"]=bn.bind(a(r),e);})),r.logger_=Ai("MPC"),r.triggeredFmp4Usage=!1,r.masterPlaylistLoader_.load(),r}s(t,e);var r=t.prototype;return r.checkABR_=function(){var e=this.selectPlaylist();this.shouldSwitchToMedia_(e)&&this.masterPlaylistLoader_.media(e);},r.startABRTimer_=function(){var e=this;this.stopABRTimer_(),this.abrTimer_=i.setInterval((function(){return e.checkABR_()}),250);},r.stopABRTimer_=function(){this.tech_.scrubbing&&this.tech_.scrubbing()||(i.clearInterval(this.abrTimer_),this.abrTimer_=null);},r.setupMasterPlaylistLoaderListeners_=function(){var e=this;this.masterPlaylistLoader_.on("loadedmetadata",(function(){var t=e.masterPlaylistLoader_.media(),i=1.5*t.targetDuration*1e3;$(e.masterPlaylistLoader_.master,e.masterPlaylistLoader_.media())?e.requestOptions_.timeout=0:e.requestOptions_.timeout=i,t.endList&&"none"!==e.tech_.preload()&&(e.mainSegmentLoader_.playlist(t,e.requestOptions_),e.mainSegmentLoader_.load()),function(e){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((function(t){yn[t](t,e);}));var t=e.mediaTypes,i=e.masterPlaylistLoader,n=e.tech,r=e.vhs;["AUDIO","SUBTITLES"].forEach((function(i){t[i].activeGroup=function(e,t){return function(i){var n=t.masterPlaylistLoader,r=t.mediaTypes[e].groups,a=n.media();if(!a)return null;var s=null;return a.attributes[e]&&(s=r[a.attributes[e]]),s=s||r.main,void 0===i?s:null===i?null:s.filter((function(e){return e.id===i.id}))[0]||null}}(i,e),t[i].activeTrack=_n[i](i,e),t[i].onGroupChanged=function(e,t){return function(){var i=t.segmentLoaders,n=i[e],r=i.main,a=t.mediaTypes[e],s=a.activeTrack(),o=a.activeGroup(s),u=a.activePlaylistLoader;fn(n,a),o&&(o.playlistLoader?(n.resyncLoader(),mn(o.playlistLoader,a)):u&&r.resetEverything());}}(i,e),t[i].onGroupChanging=function(e,t){return function(){var i=t.segmentLoaders[e];i.abort(),i.pause();}}(i,e),t[i].onTrackChanged=function(e,t){return function(){var i=t.segmentLoaders,n=i[e],r=i.main,a=t.mediaTypes[e],s=a.activeTrack(),o=a.activeGroup(s),u=a.activePlaylistLoader;if(fn(n,a),o){if("AUDIO"===e){if(!o.playlistLoader)return r.setAudio(!0),void r.resetEverything();n.setAudio(!0),r.setAudio(!1);}u!==o.playlistLoader?(n.track&&n.track(s),n.resetEverything(),mn(o.playlistLoader,a)):mn(o.playlistLoader,a);}}}(i,e);}));var a=t.AUDIO.activeGroup();if(a){var s=(a.filter((function(e){return e.default}))[0]||a[0]).id;t.AUDIO.tracks[s].enabled=!0,t.AUDIO.onTrackChanged();}i.on("mediachange",(function(){["AUDIO","SUBTITLES"].forEach((function(e){return t[e].onGroupChanged()}));})),i.on("mediachanging",(function(){["AUDIO","SUBTITLES"].forEach((function(e){return t[e].onGroupChanging()}));}));var o=function(){t.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"vhs-audio-change"}),n.trigger({type:"usage",name:"hls-audio-change"});};for(var u in n.audioTracks().addEventListener("change",o),n.remoteTextTracks().addEventListener("change",t.SUBTITLES.onTrackChanged),r.on("dispose",(function(){n.audioTracks().removeEventListener("change",o),n.remoteTextTracks().removeEventListener("change",t.SUBTITLES.onTrackChanged);})),n.clearTracks("audio"),t.AUDIO.tracks)n.audioTracks().addTrack(t.AUDIO.tracks[u]);}({sourceType:e.sourceType_,segmentLoaders:{AUDIO:e.audioSegmentLoader_,SUBTITLES:e.subtitleSegmentLoader_,main:e.mainSegmentLoader_},tech:e.tech_,requestOptions:e.requestOptions_,masterPlaylistLoader:e.masterPlaylistLoader_,vhs:e.vhs_,master:e.master(),mediaTypes:e.mediaTypes_,blacklistCurrentPlaylist:e.blacklistCurrentPlaylist.bind(e)}),e.triggerPresenceUsage_(e.master(),t),e.setupFirstPlay(),!e.mediaTypes_.AUDIO.activePlaylistLoader||e.mediaTypes_.AUDIO.activePlaylistLoader.media()?e.trigger("selectedinitialmedia"):e.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",(function(){e.trigger("selectedinitialmedia");}));})),this.masterPlaylistLoader_.on("loadedplaylist",(function(){var t=e.masterPlaylistLoader_.media();if(!t){var i;if(e.excludeUnsupportedVariants_(),e.enableLowInitialPlaylist&&(i=e.selectInitialPlaylist()),i||(i=e.selectPlaylist()),!i||!e.shouldSwitchToMedia_(i))return;if(e.initialMedia_=i,e.masterPlaylistLoader_.media(e.initialMedia_),"vhs-json"!==e.sourceType_||!e.initialMedia_.segments)return;t=e.initialMedia_;}e.handleUpdatedMediaPlaylist(t);})),this.masterPlaylistLoader_.on("error",(function(){e.blacklistCurrentPlaylist(e.masterPlaylistLoader_.error);})),this.masterPlaylistLoader_.on("mediachanging",(function(){e.mainSegmentLoader_.abort(),e.mainSegmentLoader_.pause();})),this.masterPlaylistLoader_.on("mediachange",(function(){var t=e.masterPlaylistLoader_.media(),i=1.5*t.targetDuration*1e3;$(e.masterPlaylistLoader_.master,e.masterPlaylistLoader_.media())?e.requestOptions_.timeout=0:e.requestOptions_.timeout=i,e.mainSegmentLoader_.playlist(t,e.requestOptions_),e.mainSegmentLoader_.load(),e.tech_.trigger({type:"mediachange",bubbles:!0});})),this.masterPlaylistLoader_.on("playlistunchanged",(function(){var t=e.masterPlaylistLoader_.media();e.stuckAtPlaylistEnd_(t)&&(e.blacklistCurrentPlaylist({message:"Playlist no longer updating."}),e.tech_.trigger("playliststuck"));})),this.masterPlaylistLoader_.on("renditiondisabled",(function(){e.tech_.trigger({type:"usage",name:"vhs-rendition-disabled"}),e.tech_.trigger({type:"usage",name:"hls-rendition-disabled"});})),this.masterPlaylistLoader_.on("renditionenabled",(function(){e.tech_.trigger({type:"usage",name:"vhs-rendition-enabled"}),e.tech_.trigger({type:"usage",name:"hls-rendition-enabled"});}));},r.handleUpdatedMediaPlaylist=function(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load());},r.triggerPresenceUsage_=function(e,t){var i=e.mediaGroups||{},n=!0,r=Object.keys(i.AUDIO);for(var a in i.AUDIO)for(var s in i.AUDIO[a])i.AUDIO[a][s].uri||(n=!1);n&&(this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),this.tech_.trigger({type:"usage",name:"hls-demuxed"})),Object.keys(i.SUBTITLES).length&&(this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),this.tech_.trigger({type:"usage",name:"hls-webvtt"})),Ni.Playlist.isAes(t)&&(this.tech_.trigger({type:"usage",name:"vhs-aes"}),this.tech_.trigger({type:"usage",name:"hls-aes"})),r.length&&Object.keys(i.AUDIO[r[0]]).length>1&&(this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"}),this.tech_.trigger({type:"usage",name:"hls-alternate-audio"})),this.useCueTags_&&(this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"}),this.tech_.trigger({type:"usage",name:"hls-playlist-cue-tags"}));},r.shouldSwitchToMedia_=function(e){var t=this.masterPlaylistLoader_.media(),i=this.tech_.buffered();return function(e){var t=e.currentPlaylist,i=e.nextPlaylist,r=e.forwardBuffer,a=e.bufferLowWaterLine,s=e.bufferHighWaterLine,o=e.duration,u=e.experimentalBufferBasedABR,d=e.log;if(!i)return n.log.warn("We received no playlist to switch to. Please check your stream."),!1;var l="allowing switch "+(t&&t.id||"null")+" -> "+i.id;if(!t||!t.endList)return d(l+" as current playlist "+(t?"is live":"is not set")),!0;if(i.id===t.id)return !1;var h=u?lt.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:lt.MAX_BUFFER_LOW_WATER_LINE;if(o<h)return d(l+" as duration < max low water line ("+o+" < "+h+")"),!0;var c=i.attributes.BANDWIDTH,f=t.attributes.BANDWIDTH;if(c<f&&(!u||r<s)){var m=l+" as next bandwidth < current bandwidth ("+c+" < "+f+")";return u&&(m+=" and forwardBuffer < bufferHighWaterLine ("+r+" < "+s+")"),d(m),!0}if((!u||c>f)&&r>=a){var p=l+" as forwardBuffer >= bufferLowWaterLine ("+r+" >= "+a+")";return u&&(p+=" and next bandwidth > current bandwidth ("+c+" > "+f+")"),d(p),!0}return d("not "+l+" as no switching criteria met"),!1}({currentPlaylist:t,nextPlaylist:e,forwardBuffer:i.length?i.end(i.length-1)-this.tech_.currentTime():0,bufferLowWaterLine:this.bufferLowWaterLine(),bufferHighWaterLine:this.bufferHighWaterLine(),duration:this.duration(),experimentalBufferBasedABR:this.experimentalBufferBasedABR,log:this.logger_})},r.setupSegmentLoaderListeners_=function(){var e=this;this.experimentalBufferBasedABR||(this.mainSegmentLoader_.on("bandwidthupdate",(function(){var t=e.selectPlaylist();e.shouldSwitchToMedia_(t)&&e.masterPlaylistLoader_.media(t),e.tech_.trigger("bandwidthupdate");})),this.mainSegmentLoader_.on("progress",(function(){e.trigger("progress");}))),this.mainSegmentLoader_.on("error",(function(){e.blacklistCurrentPlaylist(e.mainSegmentLoader_.error());})),this.mainSegmentLoader_.on("appenderror",(function(){e.error=e.mainSegmentLoader_.error_,e.trigger("error");})),this.mainSegmentLoader_.on("syncinfoupdate",(function(){e.onSyncInfoUpdate_();})),this.mainSegmentLoader_.on("timestampoffset",(function(){e.tech_.trigger({type:"usage",name:"vhs-timestamp-offset"}),e.tech_.trigger({type:"usage",name:"hls-timestamp-offset"});})),this.audioSegmentLoader_.on("syncinfoupdate",(function(){e.onSyncInfoUpdate_();})),this.audioSegmentLoader_.on("appenderror",(function(){e.error=e.audioSegmentLoader_.error_,e.trigger("error");})),this.mainSegmentLoader_.on("ended",(function(){e.logger_("main segment loader ended"),e.onEndOfStream();})),this.mainSegmentLoader_.on("earlyabort",(function(t){e.experimentalBufferBasedABR||e.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},120);}));var t=function(){if(!e.sourceUpdater_.ready())return e.tryToCreateSourceBuffers_();var t=e.getCodecsOrExclude_();t&&e.sourceUpdater_.addOrChangeSourceBuffers(t);};this.mainSegmentLoader_.on("trackinfo",t),this.audioSegmentLoader_.on("trackinfo",t),this.mainSegmentLoader_.on("fmp4",(function(){e.triggeredFmp4Usage||(e.tech_.trigger({type:"usage",name:"vhs-fmp4"}),e.tech_.trigger({type:"usage",name:"hls-fmp4"}),e.triggeredFmp4Usage=!0);})),this.audioSegmentLoader_.on("fmp4",(function(){e.triggeredFmp4Usage||(e.tech_.trigger({type:"usage",name:"vhs-fmp4"}),e.tech_.trigger({type:"usage",name:"hls-fmp4"}),e.triggeredFmp4Usage=!0);})),this.audioSegmentLoader_.on("ended",(function(){e.logger_("audioSegmentLoader ended"),e.onEndOfStream();}));},r.mediaSecondsLoaded_=function(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)},r.load=function(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load();},r.smoothQualityChange_=function(e){void 0===e&&(e=this.selectPlaylist()),e!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(e),this.mainSegmentLoader_.resetLoader());},r.fastQualityChange_=function(e){var t=this;void 0===e&&(e=this.selectPlaylist()),e!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(e),this.mainSegmentLoader_.resetEverything((function(){n.browser.IE_VERSION||n.browser.IS_EDGE?t.tech_.setCurrentTime(t.tech_.currentTime()+.04):t.tech_.setCurrentTime(t.tech_.currentTime());})));},r.play=function(){if(!this.setupFirstPlay()){this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();var e=this.tech_.seekable();return this.tech_.duration()===1/0&&this.tech_.currentTime()<e.start(0)?this.tech_.setCurrentTime(e.end(e.length-1)):void 0}},r.setupFirstPlay=function(){var e=this,t=this.masterPlaylistLoader_.media();if(!t||this.tech_.paused()||this.hasPlayed_)return !1;if(!t.endList){var i=this.seekable();if(!i.length)return !1;if(n.browser.IE_VERSION&&0===this.tech_.readyState())return this.tech_.one("loadedmetadata",(function(){e.trigger("firstplay"),e.tech_.setCurrentTime(i.end(0)),e.hasPlayed_=!0;})),!1;this.trigger("firstplay"),this.tech_.setCurrentTime(i.end(0));}return this.hasPlayed_=!0,this.load(),!0},r.handleSourceOpen_=function(){if(this.tryToCreateSourceBuffers_(),this.tech_.autoplay()){var e=this.tech_.play();void 0!==e&&"function"==typeof e.then&&e.then(null,(function(e){}));}this.trigger("sourceopen");},r.handleSourceEnded_=function(){if(this.inbandTextTracks_.metadataTrack_){var e=this.inbandTextTracks_.metadataTrack_.cues;if(e&&e.length){var t=this.duration();e[e.length-1].endTime=isNaN(t)||Math.abs(t)===1/0?Number.MAX_VALUE:t;}}},r.handleDurationChange_=function(){this.tech_.trigger("durationchange");},r.onEndOfStream=function(){var e=this.mainSegmentLoader_.ended_;this.mediaTypes_.AUDIO.activePlaylistLoader&&(e=!this.mainSegmentLoader_.currentMediaInfo_||this.mainSegmentLoader_.currentMediaInfo_.hasVideo?e&&this.audioSegmentLoader_.ended_:this.audioSegmentLoader_.ended_),e&&(this.stopABRTimer_(),this.sourceUpdater_.endOfStream());},r.stuckAtPlaylistEnd_=function(e){if(!this.seekable().length)return !1;var t=this.syncController_.getExpiredTime(e,this.duration());if(null===t)return !1;var i=Ni.Playlist.playlistEnd(e,t),n=this.tech_.currentTime(),r=this.tech_.buffered();if(!r.length)return i-n<=.1;var a=r.end(r.length-1);return a-n<=.1&&i-a<=.1},r.blacklistCurrentPlaylist=function(e,t){void 0===e&&(e={});var i=e.playlist||this.masterPlaylistLoader_.media();if(t=t||e.blacklistDuration||this.blacklistDuration,!i)return this.error=e,void("open"!==this.mediaSource.readyState?this.trigger("error"):this.sourceUpdater_.endOfStream("network"));var r=this.masterPlaylistLoader_.master.playlists,a=r.filter(Y),s=1===a.length&&a[0]===i;if(1===r.length&&t!==1/0)return n.log.warn("Problem encountered with playlist "+i.id+". Trying again since it is the only playlist."),this.tech_.trigger("retryplaylist"),this.masterPlaylistLoader_.load(s);if(s){var o=!1;r.forEach((function(e){if(e!==i){var t=e.excludeUntil;void 0!==t&&t!==1/0&&(o=!0,delete e.excludeUntil);}})),o&&(n.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist"));}i.excludeUntil=Date.now()+1e3*t,this.tech_.trigger("blacklistplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-blacklisted"}),this.tech_.trigger({type:"usage",name:"hls-rendition-blacklisted"});var u=this.selectPlaylist();if(!u)return this.error="Playback cannot continue. No available working or supported playlists.",void this.trigger("error");var d=e.internal?this.logger_:n.log.warn,l=e.message?" "+e.message:"";return d((e.internal?"Internal problem":"Problem")+" encountered with playlist "+i.id+"."+l+" Switching to playlist "+u.id+"."),u.attributes.AUDIO!==i.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]),u.attributes.SUBTITLES!==i.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]),this.delegateLoaders_("main",["abort","pause"]),this.masterPlaylistLoader_.media(u,s)},r.pauseLoading=function(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_();},r.delegateLoaders_=function(e,t){var i=this,n=[],r="all"===e;(r||"main"===e)&&n.push(this.masterPlaylistLoader_);var a=[];(r||"audio"===e)&&a.push("AUDIO"),(r||"subtitle"===e)&&(a.push("CLOSED-CAPTIONS"),a.push("SUBTITLES")),a.forEach((function(e){var t=i.mediaTypes_[e]&&i.mediaTypes_[e].activePlaylistLoader;t&&n.push(t);})),["main","audio","subtitle"].forEach((function(t){var r=i[t+"SegmentLoader_"];!r||e!==t&&"all"!==e||n.push(r);})),n.forEach((function(e){return t.forEach((function(t){"function"==typeof e[t]&&e[t]();}))}));},r.setCurrentTime=function(e){var t=B(this.tech_.buffered(),e);return this.masterPlaylistLoader_&&this.masterPlaylistLoader_.media()&&this.masterPlaylistLoader_.media().segments?t&&t.length?e:(this.mainSegmentLoader_.resetEverything(),this.mainSegmentLoader_.abort(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.resetEverything(),this.audioSegmentLoader_.abort()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.resetEverything(),this.subtitleSegmentLoader_.abort()),void this.load()):0},r.duration=function(){if(!this.masterPlaylistLoader_)return 0;var e=this.masterPlaylistLoader_.media();return e?e.endList?this.mediaSource?this.mediaSource.duration:Ni.Playlist.duration(e):1/0:0},r.seekable=function(){return this.seekable_},r.onSyncInfoUpdate_=function(){var e;if(this.masterPlaylistLoader_){var t=this.masterPlaylistLoader_.media();if(t){var i=this.syncController_.getExpiredTime(t,this.duration());if(null!==i){var r=this.masterPlaylistLoader_.master.suggestedPresentationDelay,a=Ni.Playlist.seekable(t,i,r);if(0!==a.length){if(this.mediaTypes_.AUDIO.activePlaylistLoader){if(t=this.mediaTypes_.AUDIO.activePlaylistLoader.media(),null===(i=this.syncController_.getExpiredTime(t,this.duration())))return;if(0===(e=Ni.Playlist.seekable(t,i,r)).length)return}var s,o;this.seekable_&&this.seekable_.length&&(s=this.seekable_.end(0),o=this.seekable_.start(0)),e?e.start(0)>a.end(0)||a.start(0)>e.end(0)?this.seekable_=a:this.seekable_=n.createTimeRanges([[e.start(0)>a.start(0)?e.start(0):a.start(0),e.end(0)<a.end(0)?e.end(0):a.end(0)]]):this.seekable_=a,this.seekable_&&this.seekable_.length&&this.seekable_.end(0)===s&&this.seekable_.start(0)===o||(this.logger_("seekable updated ["+N(this.seekable_)+"]"),this.tech_.trigger("seekablechanged"));}}}}},r.updateDuration=function(e){if(this.updateDuration_&&(this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.updateDuration_=null),"open"!==this.mediaSource.readyState)return this.updateDuration_=this.updateDuration.bind(this,e),void this.mediaSource.addEventListener("sourceopen",this.updateDuration_);if(e){var t=this.seekable();if(!t.length)return;(isNaN(this.mediaSource.duration)||this.mediaSource.duration<t.end(t.length-1))&&this.sourceUpdater_.setDuration(t.end(t.length-1));}else {var i=this.tech_.buffered(),n=Ni.Playlist.duration(this.masterPlaylistLoader_.media());i.length>0&&(n=Math.max(n,i.end(i.length-1))),this.mediaSource.duration!==n&&this.sourceUpdater_.setDuration(n);}},r.dispose=function(){var e=this;this.trigger("dispose"),this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),["AUDIO","SUBTITLES"].forEach((function(t){var i=e.mediaTypes_[t].groups;for(var n in i)i[n].forEach((function(e){e.playlistLoader&&e.playlistLoader.dispose();}));})),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.mediaSource.removeEventListener("durationchange",this.handleDurationChange_),this.mediaSource.removeEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.removeEventListener("sourceended",this.handleSourceEnded_),this.off();},r.master=function(){return this.masterPlaylistLoader_.master},r.media=function(){return this.masterPlaylistLoader_.media()||this.initialMedia_},r.areMediaTypesKnown_=function(){var e=!!this.mediaTypes_.AUDIO.activePlaylistLoader;return !(!this.mainSegmentLoader_.currentMediaInfo_||e&&!this.audioSegmentLoader_.currentMediaInfo_)},r.getCodecsOrExclude_=function(){var e=this,t={main:this.mainSegmentLoader_.currentMediaInfo_||{},audio:this.audioSegmentLoader_.currentMediaInfo_||{}};t.video=t.main;var i=Ii(this.master(),this.media()),n={},r=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(t.main.hasVideo&&(n.video=i.video||t.main.videoCodec||fi),t.main.isMuxed&&(n.video+=","+(i.audio||t.main.audioCodec||ci)),(t.main.hasAudio&&!t.main.isMuxed||t.audio.hasAudio||r)&&(n.audio=i.audio||t.main.audioCodec||t.audio.audioCodec||ci,t.audio.isFmp4=t.main.hasAudio&&!t.main.isMuxed?t.main.isFmp4:t.audio.isFmp4),n.audio||n.video){var a,s={};if(["video","audio"].forEach((function(e){if(n.hasOwnProperty(e)&&(r=t[e].isFmp4,o=n[e],!(r?mi(o):vi(o)))){var i=t[e].isFmp4?"browser":"muxer";s[i]=s[i]||[],s[i].push(n[e]),"audio"===e&&(a=i);}var r,o;})),r&&a&&this.media().attributes.AUDIO){var o=this.media().attributes.AUDIO;this.master().playlists.forEach((function(t){(t.attributes&&t.attributes.AUDIO)===o&&t!==e.media()&&(t.excludeUntil=1/0);})),this.logger_("excluding audio group "+o+" as "+a+' does not support codec(s): "'+n.audio+'"');}if(!Object.keys(s).length){if(this.sourceUpdater_.ready()&&!this.sourceUpdater_.canChangeType()){var u=[];if(["video","audio"].forEach((function(t){var i=(bi(e.sourceUpdater_.codecs[t]||"")[t]||{}).type,r=(bi(n[t]||"")[t]||{}).type;i&&r&&i.toLowerCase()!==r.toLowerCase()&&u.push('"'+e.sourceUpdater_.codecs[t]+'" -> "'+n[t]+'"');})),u.length)return void this.blacklistCurrentPlaylist({playlist:this.media(),message:"Codec switching not supported: "+u.join(", ")+".",blacklistDuration:1/0,internal:!0})}return n}var d=Object.keys(s).reduce((function(e,t){return e&&(e+=", "),e+(t+' does not support codec(s): "')+s[t].join(",")+'"'}),"")+".";this.blacklistCurrentPlaylist({playlist:this.media(),internal:!0,message:d,blacklistDuration:1/0});}else this.blacklistCurrentPlaylist({playlist:this.media(),message:"Could not determine codecs for playlist.",blacklistDuration:1/0});},r.tryToCreateSourceBuffers_=function(){if("open"===this.mediaSource.readyState&&!this.sourceUpdater_.ready()&&this.areMediaTypesKnown_()){var e=this.getCodecsOrExclude_();if(e){this.sourceUpdater_.createSourceBuffers(e);var t=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(t);}}},r.excludeUnsupportedVariants_=function(){var e=this;this.master().playlists.forEach((function(t){var i=Ii(e.master,t);!i.audio||vi(i.audio)||mi(i.audio)||(t.excludeUntil=1/0),!i.video||vi(i.video)||mi(i.video)||(t.excludeUntil=1/0);}));},r.excludeIncompatibleVariants_=function(e){var t=this,i=bi(e),n=Object.keys(i).length;this.master().playlists.forEach((function(e){if(e.excludeUntil!==1/0){var r={},a=2,s=[],o=Ii(t.masterPlaylistLoader_.master,e);if(o.audio||o.video){var u=[o.video,o.audio].filter(Boolean).join(",");r=bi(u),a=Object.keys(r).length;}a!==n&&(s.push('codec count "'+a+'" !== "'+n+'"'),e.excludeUntil=1/0),t.sourceUpdater_.canChangeType()||(r.video&&i.video&&r.video.type.toLowerCase()!==i.video.type.toLowerCase()&&(s.push('video codec "'+r.video.type+'" !== "'+i.video.type+'"'),e.excludeUntil=1/0),r.audio&&i.audio&&r.audio.type.toLowerCase()!==i.audio.type.toLowerCase()&&(e.excludeUntil=1/0,s.push('audio codec "'+r.audio.type+'" !== "'+i.audio.type+'"'))),s.length&&t.logger_("blacklisting "+e.id+": "+s.join(" && "));}}));},r.updateAdCues_=function(e){var t=0,n=this.seekable();n.length&&(t=n.start(0)),function(e,t,n){if(void 0===n&&(n=0),e.segments)for(var r,a=n,s=0;s<e.segments.length;s++){var o=e.segments[s];if(r||(r=on(t,a+o.duration/2)),r){if("cueIn"in o){r.endTime=a,r.adEndTime=a,a+=o.duration,r=null;continue}if(a<r.endTime){a+=o.duration;continue}r.endTime+=o.duration;}else if("cueOut"in o&&((r=new i.VTTCue(a,a+o.duration,o.cueOut)).adStartTime=a,r.adEndTime=a+parseFloat(o.cueOut),t.addCue(r)),"cueOutCont"in o){var u=o.cueOutCont.split("/").map(parseFloat),d=u[0],l=u[1];(r=new i.VTTCue(a,a+o.duration,"")).adStartTime=a-d,r.adEndTime=r.adStartTime+l,t.addCue(r);}a+=o.duration;}}(e,this.cueTagsTrack_,t);},r.goalBufferLength=function(){var e=this.tech_.currentTime(),t=lt.GOAL_BUFFER_LENGTH,i=lt.GOAL_BUFFER_LENGTH_RATE,n=Math.max(t,lt.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*i,n)},r.bufferLowWaterLine=function(){var e=this.tech_.currentTime(),t=lt.BUFFER_LOW_WATER_LINE,i=lt.BUFFER_LOW_WATER_LINE_RATE,n=Math.max(t,lt.MAX_BUFFER_LOW_WATER_LINE),r=Math.max(t,lt.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*i,this.experimentalBufferBasedABR?r:n)},r.bufferHighWaterLine=function(){return lt.BUFFER_HIGH_WATER_LINE},t}(n.EventTarget),Sn=function(e,t,i){var n,r,a,s=e.masterPlaylistController_,o=s[(e.options_.smoothQualityChange?"smooth":"fast")+"QualityChange_"].bind(s);if(t.attributes.RESOLUTION){var u=t.attributes.RESOLUTION;this.width=u.width,this.height=u.height;}this.bandwidth=t.attributes.BANDWIDTH,this.codecs=Ii(s.master(),t),this.playlist=t,this.id=i,this.enabled=(n=e.playlists,r=t.id,a=o,function(e){var t=n.master.playlists[r],i=Q(t),s=Y(t);return void 0===e?s:(e?delete t.disabled:t.disabled=!0,e===s||i||(a(),e?n.trigger("renditionenabled"):n.trigger("renditiondisabled")),e)});},In=["seeking","seeked","pause","playing","error"],An=function(){function e(e){var t=this;this.masterPlaylistController_=e.masterPlaylistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.media=e.media,this.consecutiveUpdates=0,this.lastRecordedTime=null,this.timer_=null,this.checkCurrentTimeTimeout_=null,this.logger_=Ai("PlaybackWatcher"),this.logger_("initialize");var n=function(){return t.monitorCurrentTime_()},r=function(){return t.techWaiting_()},a=function(){return t.cancelTimer_()},s=function(){return t.fixesBadSeeks_()},o=this.masterPlaylistController_,u=["main","subtitle","audio"],d={};u.forEach((function(e){d[e]={reset:function(){return t.resetSegmentDownloads_(e)},updateend:function(){return t.checkSegmentDownloads_(e)}},o[e+"SegmentLoader_"].on("appendsdone",d[e].updateend),o[e+"SegmentLoader_"].on("playlistupdate",d[e].reset),t.tech_.on(["seeked","seeking"],d[e].reset);})),this.tech_.on("seekablechanged",s),this.tech_.on("waiting",r),this.tech_.on(In,a),this.tech_.on("canplay",n),this.dispose=function(){t.logger_("dispose"),t.tech_.off("seekablechanged",s),t.tech_.off("waiting",r),t.tech_.off(In,a),t.tech_.off("canplay",n),u.forEach((function(e){o[e+"SegmentLoader_"].off("appendsdone",d[e].updateend),o[e+"SegmentLoader_"].off("playlistupdate",d[e].reset),t.tech_.off(["seeked","seeking"],d[e].reset);})),t.checkCurrentTimeTimeout_&&i.clearTimeout(t.checkCurrentTimeTimeout_),t.cancelTimer_();};}var t=e.prototype;return t.monitorCurrentTime_=function(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&i.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=i.setTimeout(this.monitorCurrentTime_.bind(this),250);},t.resetSegmentDownloads_=function(e){var t=this.masterPlaylistController_[e+"SegmentLoader_"];this[e+"StalledDownloads_"]>0&&this.logger_("resetting possible stalled download count for "+e+" loader"),this[e+"StalledDownloads_"]=0,this[e+"Buffered_"]=t.buffered_();},t.checkSegmentDownloads_=function(e){var t=this.masterPlaylistController_,i=t[e+"SegmentLoader_"],n=i.buffered_(),r=function(e,t){if(e===t)return !1;if(!e&&t||!t&&e)return !0;if(e.length!==t.length)return !0;for(var i=0;i<e.length;i++)if(e.start(i)!==t.start(i)||e.end(i)!==t.end(i))return !0;return !1}(this[e+"Buffered_"],n);this[e+"Buffered_"]=n,r?this.resetSegmentDownloads_(e):(this[e+"StalledDownloads_"]++,this.logger_("found #"+this[e+"StalledDownloads_"]+" "+e+" appends that did not increase buffer (possible stalled download)",{playlistId:i.playlist_&&i.playlist_.id,buffered:q(n)}),this[e+"StalledDownloads_"]<10||(this.logger_(e+" loader stalled download exclusion"),this.resetSegmentDownloads_(e),this.tech_.trigger({type:"usage",name:"vhs-"+e+"-download-exclusion"}),"subtitle"!==e&&t.blacklistCurrentPlaylist({message:"Excessive "+e+" segment downloading detected."},1/0)));},t.checkCurrentTime_=function(){if(this.tech_.seeking()&&this.fixesBadSeeks_())return this.consecutiveUpdates=0,void(this.lastRecordedTime=this.tech_.currentTime());if(!this.tech_.paused()&&!this.tech_.seeking()){var e=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===e&&(!t.length||e+.1>=t.end(t.length-1)))return this.techWaiting_();this.consecutiveUpdates>=5&&e===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):e===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=e);}},t.cancelTimer_=function(){this.consecutiveUpdates=0,this.timer_&&(this.logger_("cancelTimer_"),clearTimeout(this.timer_)),this.timer_=null;},t.fixesBadSeeks_=function(){if(!this.tech_.seeking())return !1;var e,t=this.seekable(),i=this.tech_.currentTime();if(this.afterSeekableWindow_(t,i,this.media(),this.allowSeeksWithinUnsafeLiveWindow)&&(e=t.end(t.length-1)),this.beforeSeekableWindow_(t,i)){var n=t.start(0);e=n+(n===t.end(0)?0:.1);}if(void 0!==e)return this.logger_("Trying to seek outside of seekable at time "+i+" with seekable range "+N(t)+". Seeking to "+e+"."),this.tech_.setCurrentTime(e),!0;var r=this.tech_.buffered();return !!function(e){var t=e.buffered,i=e.targetDuration,n=e.currentTime;return !(!t.length||t.end(0)-t.start(0)<2*i||n>t.start(0)||!(t.start(0)-n<i))}({buffered:r,targetDuration:this.media().targetDuration,currentTime:i})&&(e=r.start(0)+.1,this.logger_("Buffered region starts ("+r.start(0)+") just beyond seek point ("+i+"). Seeking to "+e+"."),this.tech_.setCurrentTime(e),!0)},t.waiting_=function(){if(!this.techWaiting_()){var e=this.tech_.currentTime(),t=this.tech_.buffered(),i=B(t,e);return i.length&&e+3<=i.end(0)?(this.cancelTimer_(),this.tech_.setCurrentTime(e),this.logger_("Stopped at "+e+" while inside a buffered region ["+i.start(0)+" -> "+i.end(0)+"]. Attempting to resume playback by seeking to the current time."),this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"}),void this.tech_.trigger({type:"usage",name:"hls-unknown-waiting"})):void 0}},t.techWaiting_=function(){var e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_())return !0;if(this.tech_.seeking()||null!==this.timer_)return !0;if(this.beforeSeekableWindow_(e,t)){var i=e.end(e.length-1);return this.logger_("Fell out of live window at time "+t+". Seeking to live point (seekable end) "+i),this.cancelTimer_(),this.tech_.setCurrentTime(i),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),this.tech_.trigger({type:"usage",name:"hls-live-resync"}),!0}var n=this.tech_.vhs.masterPlaylistController_.sourceUpdater_,r=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:n.audioBuffered(),videoBuffered:n.videoBuffered(),currentTime:t}))return this.cancelTimer_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),this.tech_.trigger({type:"usage",name:"hls-video-underflow"}),!0;var a=F(r,t);if(a.length>0){var s=a.start(0)-t;return this.logger_("Stopped at "+t+", setting timer for "+s+", seeking to "+a.start(0)),this.cancelTimer_(),this.timer_=setTimeout(this.skipTheGap_.bind(this),1e3*s,t),!0}return !1},t.afterSeekableWindow_=function(e,t,i,n){if(void 0===n&&(n=!1),!e.length)return !1;var r=e.end(e.length-1)+.1;return !i.endList&&n&&(r=e.end(e.length-1)+3*i.targetDuration),t>r},t.beforeSeekableWindow_=function(e,t){return !!(e.length&&e.start(0)>0&&t<e.start(0)-.1)},t.videoUnderflow_=function(e){var t=e.videoBuffered,i=e.audioBuffered,n=e.currentTime;if(t){var r;if(t.length&&i.length){var a=B(t,n-3),s=B(t,n),o=B(i,n);o.length&&!s.length&&a.length&&(r={start:a.end(0),end:o.end(0)});}else F(t,n).length||(r=this.gapFromVideoUnderflow_(t,n));return !!r&&(this.logger_("Encountered a gap in video from "+r.start+" to "+r.end+". Seeking to current time "+n),!0)}},t.skipTheGap_=function(e){var t=this.tech_.buffered(),i=this.tech_.currentTime(),n=F(t,i);this.cancelTimer_(),0!==n.length&&i===e&&(this.logger_("skipTheGap_:","currentTime:",i,"scheduled currentTime:",e,"nextRange start:",n.start(0)),this.tech_.setCurrentTime(n.start(0)+1/30),this.tech_.trigger({type:"usage",name:"vhs-gap-skip"}),this.tech_.trigger({type:"usage",name:"hls-gap-skip"}));},t.gapFromVideoUnderflow_=function(e,t){for(var i=function(e){if(e.length<2)return n.createTimeRanges();for(var t=[],i=1;i<e.length;i++){var r=e.end(i-1),a=e.start(i);t.push([r,a]);}return n.createTimeRanges(t)}(e),r=0;r<i.length;r++){var a=i.start(r),s=i.end(r);if(t-a<4&&t-a>2)return {start:a,end:s}}return null},e}(),Ln={errorInterval:30,getSource:function(e){return e(this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource())}},En=function(e){!function e(t,i){var r=0,a=0,s=n.mergeOptions(Ln,i);t.ready((function(){t.trigger({type:"usage",name:"vhs-error-reload-initialized"}),t.trigger({type:"usage",name:"hls-error-reload-initialized"});}));var o=function(){a&&t.currentTime(a);},u=function(e){null!=e&&(a=t.duration()!==1/0&&t.currentTime()||0,t.one("loadedmetadata",o),t.src(e),t.trigger({type:"usage",name:"vhs-error-reload"}),t.trigger({type:"usage",name:"hls-error-reload"}),t.play());},d=function(){return Date.now()-r<1e3*s.errorInterval?(t.trigger({type:"usage",name:"vhs-error-reload-canceled"}),void t.trigger({type:"usage",name:"hls-error-reload-canceled"})):s.getSource&&"function"==typeof s.getSource?(r=Date.now(),s.getSource.call(t,u)):void n.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!")},l=function e(){t.off("loadedmetadata",o),t.off("error",d),t.off("dispose",e);};t.on("error",d),t.on("dispose",l),t.reloadSourceOnError=function(i){l(),e(t,i);};}(this,e);},wn={PlaylistLoader:R,Playlist:J,utils:fe,STANDARD_PLAYLIST_SELECTOR:Ci,INITIAL_PLAYLIST_SELECTOR:function(){var e=this,t=this.playlists.master.playlists.filter(J.isEnabled);return ki(t,(function(e,t){return Oi(e,t)})),t.filter((function(t){return !!Ii(e.playlists.master,t).video}))[0]||null},lastBandwidthSelector:Ci,movingAverageBandwidthSelector:function(e){var t=-1;if(e<0||e>1)throw new Error("Moving average bandwidth decay must be between 0 and 1.");return function(){var n=this.useDevicePixelRatio&&i.devicePixelRatio||1;return t<0&&(t=this.systemBandwidth),t=e*this.systemBandwidth+(1-e)*t,Ui(this.playlists.master,t,parseInt(wi(this.tech_.el(),"width"),10)*n,parseInt(wi(this.tech_.el(),"height"),10)*n,this.limitRenditionByPlayerDimensions)}},comparePlaylistBandwidth:Oi,comparePlaylistResolution:function(e,t){var n,r;return e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(n=e.attributes.RESOLUTION.width),n=n||i.Number.MAX_VALUE,t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width&&(r=t.attributes.RESOLUTION.width),n===(r=r||i.Number.MAX_VALUE)&&e.attributes.BANDWIDTH&&t.attributes.BANDWIDTH?e.attributes.BANDWIDTH-t.attributes.BANDWIDTH:n-r},xhr:ie()};["GOAL_BUFFER_LENGTH","MAX_GOAL_BUFFER_LENGTH","BACK_BUFFER_LENGTH","GOAL_BUFFER_LENGTH_RATE","BUFFER_LOW_WATER_LINE","MAX_BUFFER_LOW_WATER_LINE","EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE","BUFFER_LOW_WATER_LINE_RATE","BANDWIDTH_VARIANCE"].forEach((function(e){Object.defineProperty(wn,e,{get:function(){return n.log.warn("using Vhs."+e+" is UNSAFE be sure you know what you are doing"),lt[e]},set:function(t){n.log.warn("using Vhs."+e+" is UNSAFE be sure you know what you are doing"),"number"!=typeof t||t<0?n.log.warn("value of Vhs."+e+" must be greater than or equal to 0"):lt[e]=t;}});}));var kn=function(e,t){for(var i=t.media(),n=-1,r=0;r<e.length;r++)if(e[r].id===i.id){n=r;break}e.selectedIndex_=n,e.trigger({selectedIndex:n,type:"change"});};wn.canPlaySource=function(){return n.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var On=function(e,t,i){if(!e)return e;var r={video:t&&t.attributes&&t.attributes.CODECS,audio:i&&i.attributes&&i.attributes.CODECS};!r.audio&&r.video&&r.video.split(",").length>1&&r.video.split(",").forEach((function(e){e=e.trim(),yi(e)?r.audio=e:_i(e)&&(r.video=e);}));var a=r.video?'video/mp4;codecs="'+r.video+'"':null,s=r.audio?'audio/mp4;codecs="'+r.audio+'"':null,o={};for(var u in e)o[u]={audioContentType:s,videoContentType:a},t.contentProtection&&t.contentProtection[u]&&t.contentProtection[u].pssh&&(o[u].pssh=t.contentProtection[u].pssh),"string"==typeof e[u]&&(o[u].url=e[u]);return n.mergeOptions(e,o)},Un=function(e,t){return e.reduce((function(e,i){if(!i.contentProtection)return e;var n=t.reduce((function(e,t){var n=i.contentProtection[t];return n&&n.pssh&&(e[t]={pssh:n.pssh}),e}),{});return Object.keys(n).length&&e.push(n),e}),[])},Cn=function(e){var t=e.player,i=e.sourceKeySystems,r=e.media,a=e.audioMedia,s=e.mainPlaylists,o=On(i,r,a);if(o)if(t.currentSource().keySystems=o,!o||t.eme){if(11!==n.browser.IE_VERSION&&t.eme.initializeMediaKeys){var u=a?s.concat([a]):s;Un(u,Object.keys(i)).forEach((function(e){t.eme.initializeMediaKeys({keySystems:e});}));}}else n.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin");},Pn=function(){if(!i.localStorage)return null;var e=i.localStorage.getItem("videojs-vhs");if(!e)return null;try{return JSON.parse(e)}catch(e){return null}},Dn=function(e){return 0===e.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")?JSON.parse(e.substring(e.indexOf(",")+1)):e};wn.supportsNativeHls=function(){if(!t||!t.createElement)return !1;var e=t.createElement("video");return !!n.getTech("Html5").isSupported()&&["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some((function(t){return /maybe|probably/i.test(e.canPlayType(t))}))}(),wn.supportsNativeDash=!!(t&&t.createElement&&n.getTech("Html5").isSupported())&&/maybe|probably/i.test(t.createElement("video").canPlayType("application/dash+xml")),wn.supportsTypeNatively=function(e){return "hls"===e?wn.supportsNativeHls:"dash"===e&&wn.supportsNativeDash},wn.isSupported=function(){return n.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var xn=function(e){function r(i,r,s){var o;if(o=e.call(this,r,n.mergeOptions(s.hls,s.vhs))||this,s.hls&&Object.keys(s.hls).length&&n.log.warn("Using hls options is deprecated. Use vhs instead."),r.options_&&r.options_.playerId){var u=n(r.options_.playerId);u.hasOwnProperty("hls")||Object.defineProperty(u,"hls",{get:function(){return n.log.warn("player.hls is deprecated. Use player.tech().vhs instead."),r.trigger({type:"usage",name:"hls-player-access"}),a(o)},configurable:!0}),u.hasOwnProperty("vhs")||Object.defineProperty(u,"vhs",{get:function(){return n.log.warn("player.vhs is deprecated. Use player.tech().vhs instead."),r.trigger({type:"usage",name:"vhs-player-access"}),a(o)},configurable:!0}),u.hasOwnProperty("dash")||Object.defineProperty(u,"dash",{get:function(){return n.log.warn("player.dash is deprecated. Use player.tech().vhs instead."),a(o)},configurable:!0}),o.player_=u;}if(o.tech_=r,o.source_=i,o.stats={},o.ignoreNextSeekingEvent_=!1,o.setOptions_(),o.options_.overrideNative&&r.overrideNativeAudioTracks&&r.overrideNativeVideoTracks)r.overrideNativeAudioTracks(!0),r.overrideNativeVideoTracks(!0);else if(o.options_.overrideNative&&(r.featuresNativeVideoTracks||r.featuresNativeAudioTracks))throw new Error("Overriding native HLS requires emulated tracks. See https://git.io/vMpjB");return o.on(t,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],(function(e){var i=t.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement;i&&i.contains(o.tech_.el())&&o.masterPlaylistController_.smoothQualityChange_();})),o.on(o.tech_,"seeking",(function(){this.ignoreNextSeekingEvent_?this.ignoreNextSeekingEvent_=!1:this.setCurrentTime(this.tech_.currentTime());})),o.on(o.tech_,"error",(function(){this.tech_.error()&&this.masterPlaylistController_&&this.masterPlaylistController_.pauseLoading();})),o.on(o.tech_,"play",o.play),o}s(r,e);var o=r.prototype;return o.setOptions_=function(){var e=this;if(this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.handleManifestRedirects=!1!==this.options_.handleManifestRedirects,this.options_.limitRenditionByPlayerDimensions=!1!==this.options_.limitRenditionByPlayerDimensions,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.smoothQualityChange=this.options_.smoothQualityChange||!1,this.options_.useBandwidthFromLocalStorage=void 0!==this.source_.useBandwidthFromLocalStorage?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.handlePartialData=this.options_.handlePartialData||!1,"number"!=typeof this.options_.blacklistDuration&&(this.options_.blacklistDuration=300),"number"!=typeof this.options_.bandwidth&&this.options_.useBandwidthFromLocalStorage){var t=Pn();t&&t.bandwidth&&(this.options_.bandwidth=t.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"}),this.tech_.trigger({type:"usage",name:"hls-bandwidth-from-local-storage"})),t&&t.throughput&&(this.options_.throughput=t.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"}),this.tech_.trigger({type:"usage",name:"hls-throughput-from-local-storage"}));}"number"!=typeof this.options_.bandwidth&&(this.options_.bandwidth=lt.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===lt.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","limitRenditionByPlayerDimensions","bandwidth","smoothQualityChange","customTagParsers","customTagMappers","handleManifestRedirects","cacheEncryptionKeys","handlePartialData","playlistSelector","initialPlaylistSelector","experimentalBufferBasedABR"].forEach((function(t){void 0!==e.source_[t]&&(e.options_[t]=e.source_[t]);})),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio;},o.src=function(e,t){var r=this;if(e){this.setOptions_(),this.options_.src=Dn(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=wn,this.options_.sourceType=ae(t),this.options_.seekTo=function(e){r.tech_.setCurrentTime(e);},this.masterPlaylistController_=new Tn(this.options_),this.playbackWatcher_=new An(n.mergeOptions(this.options_,{seekable:function(){return r.seekable()},media:function(){return r.masterPlaylistController_.media()},masterPlaylistController:this.masterPlaylistController_})),this.masterPlaylistController_.on("error",(function(){var e=n.players[r.tech_.options_.playerId],t=r.masterPlaylistController_.error;"object"!=typeof t||t.code?"string"==typeof t&&(t={message:t,code:3}):t.code=3,e.error(t);}));var a=this.options_.experimentalBufferBasedABR?wn.movingAverageBandwidthSelector(.55):wn.STANDARD_PLAYLIST_SELECTOR;this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):a.bind(this),this.masterPlaylistController_.selectInitialPlaylist=wn.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.masterPlaylistController_.masterPlaylistLoader_,this.mediaSource=this.masterPlaylistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get:function(){return this.masterPlaylistController_.selectPlaylist},set:function(e){this.masterPlaylistController_.selectPlaylist=e.bind(this);}},throughput:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.throughput.rate},set:function(e){this.masterPlaylistController_.mainSegmentLoader_.throughput.rate=e,this.masterPlaylistController_.mainSegmentLoader_.throughput.count=1;}},bandwidth:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.bandwidth},set:function(e){this.masterPlaylistController_.mainSegmentLoader_.bandwidth=e,this.masterPlaylistController_.mainSegmentLoader_.throughput={rate:0,count:0};}},systemBandwidth:{get:function(){var e,t=1/(this.bandwidth||1);return e=this.throughput>0?1/this.throughput:0,Math.floor(1/(t+e))},set:function(){n.log.error('The "systemBandwidth" property is read-only');}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:function(){return r.bandwidth||0},enumerable:!0},mediaRequests:{get:function(){return r.masterPlaylistController_.mediaRequests_()||0},enumerable:!0},mediaRequestsAborted:{get:function(){return r.masterPlaylistController_.mediaRequestsAborted_()||0},enumerable:!0},mediaRequestsTimedout:{get:function(){return r.masterPlaylistController_.mediaRequestsTimedout_()||0},enumerable:!0},mediaRequestsErrored:{get:function(){return r.masterPlaylistController_.mediaRequestsErrored_()||0},enumerable:!0},mediaTransferDuration:{get:function(){return r.masterPlaylistController_.mediaTransferDuration_()||0},enumerable:!0},mediaBytesTransferred:{get:function(){return r.masterPlaylistController_.mediaBytesTransferred_()||0},enumerable:!0},mediaSecondsLoaded:{get:function(){return r.masterPlaylistController_.mediaSecondsLoaded_()||0},enumerable:!0},buffered:{get:function(){return q(r.tech_.buffered())},enumerable:!0},currentTime:{get:function(){return r.tech_.currentTime()},enumerable:!0},currentSource:{get:function(){return r.tech_.currentSource_},enumerable:!0},currentTech:{get:function(){return r.tech_.name_},enumerable:!0},duration:{get:function(){return r.tech_.duration()},enumerable:!0},master:{get:function(){return r.playlists.master},enumerable:!0},playerDimensions:{get:function(){return r.tech_.currentDimensions()},enumerable:!0},seekable:{get:function(){return q(r.tech_.seekable())},enumerable:!0},timestamp:{get:function(){return Date.now()},enumerable:!0},videoPlaybackQuality:{get:function(){return r.tech_.getVideoPlaybackQuality()},enumerable:!0}}),this.tech_.one("canplay",this.masterPlaylistController_.setupFirstPlay.bind(this.masterPlaylistController_)),this.tech_.on("bandwidthupdate",(function(){r.options_.useBandwidthFromLocalStorage&&function(e){if(!i.localStorage)return !1;var t=Pn();t=t?n.mergeOptions(t,e):e;try{i.localStorage.setItem("videojs-vhs",JSON.stringify(t));}catch(e){return !1}}({bandwidth:r.bandwidth,throughput:Math.round(r.throughput)});})),this.masterPlaylistController_.on("selectedinitialmedia",(function(){var e,t;t=(e=r).playlists,e.representations=function(){return t&&t.master&&t.master.playlists?t.master.playlists.filter((function(e){return !Q(e)})).map((function(t,i){return new Sn(e,t,t.id)})):[]};})),this.masterPlaylistController_.sourceUpdater_.on("ready",(function(){var e=r.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader;Cn({player:r.player_,sourceKeySystems:r.source_.keySystems,media:r.playlists.media(),audioMedia:e&&e.media(),mainPlaylists:r.playlists.master.playlists});})),this.on(this.masterPlaylistController_,"progress",(function(){this.tech_.trigger("progress");})),this.on(this.masterPlaylistController_,"firstplay",(function(){this.ignoreNextSeekingEvent_=!0;})),this.setupQualityLevels_(),this.tech_.el()&&(this.mediaSourceUrl_=i.URL.createObjectURL(this.masterPlaylistController_.mediaSource),this.tech_.src(this.mediaSourceUrl_));}},o.setupQualityLevels_=function(){var e=this,t=n.players[this.tech_.options_.playerId];t&&t.qualityLevels&&!this.qualityLevels_&&(this.qualityLevels_=t.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",(function(){var t,i;t=e.qualityLevels_,(i=e).representations().forEach((function(e){t.addQualityLevel(e);})),kn(t,i.playlists);})),this.playlists.on("mediachange",(function(){kn(e.qualityLevels_,e.playlists);})));},r.version=function(){return {"@videojs/http-streaming":"2.3.1","mux.js":"5.6.7","mpd-parser":"0.14.0","m3u8-parser":"4.5.0","aes-decrypter":"3.1.0"}},o.version=function(){return this.constructor.version()},o.canChangeType=function(){return nn.canChangeType()},o.play=function(){this.masterPlaylistController_.play();},o.setCurrentTime=function(e){this.masterPlaylistController_.setCurrentTime(e);},o.duration=function(){return this.masterPlaylistController_.duration()},o.seekable=function(){return this.masterPlaylistController_.seekable()},o.dispose=function(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.masterPlaylistController_&&this.masterPlaylistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.player_&&(delete this.player_.vhs,delete this.player_.dash,delete this.player_.hls),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.tech_&&delete this.tech_.hls,this.mediaSourceUrl_&&i.URL.revokeObjectURL&&(i.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),e.prototype.dispose.call(this);},o.convertToProgramTime=function(e,t){return function(e){var t=e.playlist,i=e.time,n=void 0===i?void 0:i,r=e.callback;if(!r)throw new Error("getProgramTime: callback must be provided");if(!t||void 0===n)return r({message:"getProgramTime: playlist and time must be provided"});var a=function(e,t){if(!t||!t.segments||0===t.segments.length)return null;for(var i,n=0,r=0;r<t.segments.length&&!(e<=(n=(i=t.segments[r]).videoTimingInfo?i.videoTimingInfo.transmuxedPresentationEnd:n+i.duration));r++);var a=t.segments[t.segments.length-1];if(a.videoTimingInfo&&a.videoTimingInfo.transmuxedPresentationEnd<e)return null;if(e>n){if(e>n+.25*a.duration)return null;i=a;}return {segment:i,estimatedStart:i.videoTimingInfo?i.videoTimingInfo.transmuxedPresentationStart:n-i.duration,type:i.videoTimingInfo?"accurate":"estimate"}}(n,t);if(!a)return r({message:"valid programTime was not found"});if("estimate"===a.type)return r({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:a.estimatedStart});var s={mediaSeconds:n},o=function(e,t){if(!t.dateTimeObject)return null;var i=t.videoTimingInfo.transmuxerPrependedSeconds,n=e-(t.videoTimingInfo.transmuxedPresentationStart+i);return new Date(t.dateTimeObject.getTime()+1e3*n)}(n,a.segment);return o&&(s.programDateTime=o.toISOString()),r(null,s)}({playlist:this.masterPlaylistController_.media(),time:e,callback:t})},o.seekToProgramTime=function(e,t,i,n){return void 0===i&&(i=!0),void 0===n&&(n=2),function e(t){var i=t.programTime,n=t.playlist,r=t.retryCount,a=void 0===r?2:r,s=t.seekTo,o=t.pauseAfterSeek,u=void 0===o||o,d=t.tech,l=t.callback;if(!l)throw new Error("seekToProgramTime: callback must be provided");if(void 0===i||!n||!s)return l({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!n.endList&&!d.hasStarted_)return l({message:"player must be playing a live stream to start buffering"});if(!function(e){if(!e.segments||0===e.segments.length)return !1;for(var t=0;t<e.segments.length;t++)if(!e.segments[t].dateTimeObject)return !1;return !0}(n))return l({message:"programDateTime tags must be provided in the manifest "+n.resolvedUri});var h=function(e,t){var i;try{i=new Date(e);}catch(e){return null}if(!t||!t.segments||0===t.segments.length)return null;var n=t.segments[0];if(i<n.dateTimeObject)return null;for(var r=0;r<t.segments.length-1&&(n=t.segments[r],!(i<t.segments[r+1].dateTimeObject));r++);var a,s=t.segments[t.segments.length-1],o=s.dateTimeObject,u=s.videoTimingInfo?(a=s.videoTimingInfo).transmuxedPresentationEnd-a.transmuxedPresentationStart-a.transmuxerPrependedSeconds:s.duration+.25*s.duration;return i>new Date(o.getTime()+1e3*u)?null:(i>o&&(n=s),{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:J.duration(t,t.mediaSequence+t.segments.indexOf(n)),type:n.videoTimingInfo?"accurate":"estimate"})}(i,n);if(!h)return l({message:i+" was not found in the stream"});var c=h.segment,f=function(e,t){var i,n;try{i=new Date(e),n=new Date(t);}catch(e){}var r=i.getTime();return (n.getTime()-r)/1e3}(c.dateTimeObject,i);if("estimate"===h.type)return 0===a?l({message:i+" is not buffered yet. Try again"}):(s(h.estimatedStart+f),void d.one("seeked",(function(){e({programTime:i,playlist:n,retryCount:a-1,seekTo:s,pauseAfterSeek:u,tech:d,callback:l});})));var m=c.start+f;d.one("seeked",(function(){return l(null,d.currentTime())})),u&&d.pause(),s(m);}({programTime:e,playlist:this.masterPlaylistController_.media(),retryCount:n,pauseAfterSeek:i,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})},r}(n.getComponent("Component")),Rn={name:"videojs-http-streaming",VERSION:"2.3.1",canHandleSource:function(e,t){void 0===t&&(t={});var i=n.mergeOptions(n.options,t);return Rn.canPlayType(e.type,i)},handleSource:function(e,t,i){void 0===i&&(i={});var r=n.mergeOptions(n.options,i);return t.vhs=new xn(e,t,r),n.hasOwnProperty("hls")||Object.defineProperty(t,"hls",{get:function(){return n.log.warn("player.tech().hls is deprecated. Use player.tech().vhs instead."),t.vhs},configurable:!0}),t.vhs.xhr=ie(),t.vhs.src(e.src,e.type),t.vhs},canPlayType:function(e,t){void 0===t&&(t={});var i=n.mergeOptions(n.options,t).vhs.overrideNative,r=void 0===i?!n.browser.IS_ANY_SAFARI:i,a=ae(e);return !a||wn.supportsTypeNatively(a)&&!r?"":"maybe"}};mi("avc1.4d400d,mp4a.40.2")&&n.getTech("Html5").registerSourceHandler(Rn,0),n.VhsHandler=xn,Object.defineProperty(n,"HlsHandler",{get:function(){return n.log.warn("videojs.HlsHandler is deprecated. Use videojs.VhsHandler instead."),xn},configurable:!0}),n.VhsSourceHandler=Rn,Object.defineProperty(n,"HlsSourceHandler",{get:function(){return n.log.warn("videojs.HlsSourceHandler is deprecated. Use videojs.VhsSourceHandler instead."),Rn},configurable:!0}),n.Vhs=wn,Object.defineProperty(n,"Hls",{get:function(){return n.log.warn("videojs.Hls is deprecated. Use videojs.Vhs instead."),wn},configurable:!0}),n.use||(n.registerComponent("Hls",wn),n.registerComponent("Vhs",wn)),n.options.vhs=n.options.vhs||{},n.options.hls=n.options.hls||{},n.registerPlugin?n.registerPlugin("reloadSourceOnError",En):n.plugin("reloadSourceOnError",En),e.LOCAL_STORAGE_KEY="videojs-vhs",e.Vhs=wn,e.VhsHandler=xn,e.VhsSourceHandler=Rn,e.emeKeySystems=On,e.expandDataUri=Dn,e.getAllPsshKeySystemsOptions=Un,e.setupEmeOptions=Cn,e.simpleTypeFromSourceType=ae,Object.defineProperty(e,"__esModule",{value:!0});}));
|
||
});
|
||
|
||
var videojsHttpStreaming_min$1 = /*@__PURE__*/getDefaultExportFromCjs(videojsHttpStreaming_min);
|
||
|
||
export default videojsHttpStreaming_min$1;
|