diff --git a/build/javascript/package-lock.json b/build/javascript/package-lock.json index ef66a2c01..8df313980 100644 --- a/build/javascript/package-lock.json +++ b/build/javascript/package-lock.json @@ -159,9 +159,9 @@ "integrity": "sha512-dW1B1WHTfrWmEzXb/tp8xsZqQHAyMB9JwLwbBqkIQVzmNUI02R7lJqxUpKFM114ygNZHKA1r74oPugCAiYHt1A==" }, "@videojs/http-streaming": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/@videojs/http-streaming/-/http-streaming-2.5.0.tgz", - "integrity": "sha512-UITc4z5sLLJiI0zYqjrUqRUcSsJ+pAI3qQSYrQg6kvVSFx8O8ZjF+b5Nzafs0zctbN80BqugkVioaQKNLFKjtA==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/@videojs/http-streaming/-/http-streaming-2.6.1.tgz", + "integrity": "sha512-MVXwOZpKns2qBYFFYRdeq3iRupYWUFPw2sYZCMfu/3+d9NJ0qOyEdI5CRjh5/+J2J5+nD6kR4io6yLfty2w3OQ==", "requires": { "@babel/runtime": "^7.12.5", "@videojs/vhs-utils": "^3.0.0", @@ -174,9 +174,9 @@ }, "dependencies": { "@babel/runtime": { - "version": "7.12.5", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.5.tgz", - "integrity": "sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg==", + "version": "7.12.18", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.18.tgz", + "integrity": "sha512-BogPQ7ciE6SYAUPtlm9tWbgI9+2AgqSam6QivMgXgAT+fKbgppaj4ZX15MHeLC1PVF5sNk70huBu20XxWOs8Cg==", "requires": { "regenerator-runtime": "^0.13.4" } diff --git a/build/javascript/package.json b/build/javascript/package.json index ec03acdb5..69500ef88 100644 --- a/build/javascript/package.json +++ b/build/javascript/package.json @@ -6,7 +6,7 @@ "dependencies": { "@joeattardi/emoji-button": "^4.6.0", "@justinribeiro/lite-youtube": "^0.9.1", - "@videojs/http-streaming": "2.5.0", + "@videojs/http-streaming": "2.6.1", "@videojs/themes": "^1.0.1", "htm": "^3.0.4", "mark.js": "^8.11.1", diff --git a/webroot/js/web_modules/@videojs/http-streaming/dist/videojs-http-streaming.min.js b/webroot/js/web_modules/@videojs/http-streaming/dist/videojs-http-streaming.min.js index 3aa6f48d6..7f9711abe 100644 --- a/webroot/js/web_modules/@videojs/http-streaming/dist/videojs-http-streaming.min.js +++ b/webroot/js/web_modules/@videojs/http-streaming/dist/videojs-http-streaming.min.js @@ -2377,14 +2377,12 @@ exports.DOMParser = DOMParser; }); var videojsHttpStreaming_min = createCommonjsModule(function (module, exports) { -/*! @name @videojs/http-streaming @version 2.5.0 @license Apache-2.0 */ -!function(e,t){t(exports,document_1,window_1,core,domParser);}(commonjsGlobal,(function(e,t,i,n,r){function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=a(t),o=a(i),u=a(n),d=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},l=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t;};function h(e,t,i){return e(i={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&i.path)}},i.exports),i.exports}var c=h((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;})),f=function(e,t){return /^[a-z]+:/i.test(t)?t:(/\/\//i.test(e)||(e=c.buildAbsoluteURL(o.default.location&&o.default.location.href||"",e)),c.buildAbsoluteURL(e,t))},m=f,p=function(e,t,i){return e&&i&&i.responseURL&&t!==i.responseURL?i.responseURL:t},g=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-1;t=this.buffer.indexOf("\n"))this.trigger("data",this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1);},t}(g),b=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},T=function(e){function t(){var t;return (t=e.call(this)||this).customParsers=[],t.tagMappers=[],t}l(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;r0&&(s.duration=e.duration),0===e.duration&&(s.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=a;},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=a,this.manifest.mediaGroups=this.manifest.mediaGroups||u,e.attributes?(s.attributes||(s.attributes={}),y(s.attributes,e.attributes)):this.trigger("warn",{message:"ignoring empty stream-inf attributes"});},media:function(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||u,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"]],(d={default:/yes/i.test(e.attributes.DEFAULT)}).default?d.autoselect=!0:d.autoselect=/yes/i.test(e.attributes.AUTOSELECT),e.attributes.LANGUAGE&&(d.language=e.attributes.LANGUAGE),e.attributes.URI&&(d.uri=e.attributes.URI),e.attributes["INSTREAM-ID"]&&(d.instreamId=e.attributes["INSTREAM-ID"]),e.attributes.CHARACTERISTICS&&(d.characteristics=e.attributes.CHARACTERISTICS),e.attributes.FORCED&&(d.forced=/yes/i.test(e.attributes.FORCED)),t[e.attributes.NAME]=d;}else this.trigger("warn",{message:"ignoring incomplete or missing media group"});},discontinuity:function(){l+=1,s.discontinuity=!0,this.manifest.discontinuityStarts.push(a.length);},"program-date-time":function(){void 0===this.manifest.dateTimeString&&(this.manifest.dateTimeString=e.dateTimeString,this.manifest.dateTimeObject=e.dateTimeObject),s.dateTimeString=e.dateTimeString,s.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(){s.cueOut=e.data;},"cue-out-cont":function(){s.cueOutCont=e.data;},"cue-in":function(){s.cueIn=e.data;}}[e.tagType]||o).call(r);},uri:function(){s.uri=e.uri,a.push(s),this.manifest.targetDuration&&!("duration"in s)&&(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),s.duration=this.manifest.targetDuration),n&&(s.key=n),s.timeline=l,i&&(s.map=i),s={};},comment:function(){},custom:function(){e.segment?(s.custom=s.custom||{},s.custom[e.customType]=e.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[e.customType]=e.data);}})[e.type].call(r);})),t}l(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}(g),I=u.default.log,w=function(e,t){return e+"-"+t},L=function(e){var t=e.manifestString,i=e.customTagParsers,n=void 0===i?[]:i,r=e.customTagMappers,a=void 0===r?[]:r,s=new S;return n.forEach((function(e){return s.addParser(e)})),a.forEach((function(e){return s.addTagMapper(e)})),s.push(t),s.end(),s.manifest},k=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);}}));},A=function(e){var t=e.playlist,i=e.uri,n=e.id;t.id=n,i&&(t.uri=i),t.attributes=t.attributes||{};},E=function(e,t){e.uri=t;for(var i=0;i=500?4:2},this.trigger("error");},i.haveMetadata=function(e){var t=this,i=e.playlistString,n=e.playlistObject,r=e.url,a=e.id;this.request=null,this.state="HAVE_METADATA";var s=n||L({manifestString:i,customTagParsers:this.customTagParsers,customTagMappers:this.customTagMappers});s.lastRequest=Date.now(),A({playlist:s,uri:r,id:a});var u=O(this.master,s);this.targetDuration=s.targetDuration,u?(this.master=u,this.media_=this.master.playlists[a]):this.trigger("playlistunchanged"),this.media().endList||(o.default.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=o.default.setTimeout((function(){t.trigger("mediaupdatetimeout");}),D(this.media(),!!u))),this.trigger("loadedplaylist");},i.dispose=function(){this.trigger("dispose"),this.stopRequest(),o.default.clearTimeout(this.mediaUpdateTimeout),o.default.clearTimeout(this.finalRenditionTimeout),this.off();},i.stopRequest=function(){if(this.request){var e=this.request;this.request=null,e.onreadystatechange=null,e.abort();}},i.media=function(e,t){var i=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(o.default.clearTimeout(this.finalRenditionTimeout),t){var n=e.targetDuration/2*1e3||5e3;this.finalRenditionTimeout=o.default.setTimeout(this.media.bind(this,e,!1),n);}else {var r=this.state,a=!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(a&&(this.trigger("mediachanging"),"HAVE_MASTER"===r?this.trigger("loadedmetadata"):this.trigger("mediachange")));if(a){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,n){if(i.request){if(e.lastRequest=Date.now(),e.resolvedUri=p(i.handleManifestRedirects,e.resolvedUri,n),t)return i.playlistRequestError(i.request,e,r);i.haveMetadata({playlistString:n.responseText,url:e.uri,id:e.id}),"HAVE_MASTER"===r?i.trigger("loadedmetadata"):i.trigger("mediachange");}}));}}},i.pause=function(){this.stopRequest(),o.default.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");},i.load=function(e){var t=this;o.default.clearTimeout(this.mediaUpdateTimeout);var i=this.media();if(e){var n=i?i.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=o.default.setTimeout((function(){return t.load()}),n);}else this.started?i&&!i.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist"):this.start();},i.start=function(){var e=this;if(this.started=!0,"object"==typeof this.src)return this.src.uri||(this.src.uri=o.default.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=p(e.handleManifestRedirects,e.src,i);var n=L({manifestString:i.responseText,customTagParsers:e.customTagParsers,customTagMappers:e.customTagMappers});e.setupInitialPlaylist(n);}}));},i.srcUri=function(){return "string"==typeof this.src?this.src:this.src.uri},i.setupInitialPlaylist=function(e){if(this.state="HAVE_MASTER",e.playlists)return this.master=e,E(this.master,this.srcUri()),e.playlists.forEach((function(e){e.segments&&e.segments.forEach((function(t){U(t,e.resolvedUri);}));})),this.trigger("loadedplaylist"),void(this.request||this.media(this.master.playlists[0]));var t=this.srcUri()||o.default.location.href;this.master=function(e,t){var i=w(0,t),n={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:o.default.location.href,resolvedUri:o.default.location.href,playlists:[{uri:t,id:i,resolvedUri:t,attributes:{}}]};return n.playlists[i]=n.playlists[0],n.playlists[t]=n.playlists[0],n}(0,t),this.haveMetadata({playlistObject:e,url:t,id:this.master.playlists[0].id}),this.trigger("loadedmetadata");},t}(C),R=1/30,M=.1,B=function(e,t){var i,n=[];if(e&&e.length)for(i=0;i=t}))},N=function(e,t){return B(e,(function(e){return e-R>=t}))},q=function(e){var t=[];if(!e||!e.length)return "";for(var i=0;i "+e.end(i));return t.join(", ")},W=function(e){for(var t=[],i=0;ii){var r=[i,t];t=r[0],i=r[1];}if(t<0){for(var a=t;a=r););return Math.max(0,i)},X=function(e,t,i,n){if(!e||!e.segments)return null;if(e.endList)return G(e);if(null===t)return null;t=t||0;var r=i?z(e,n):e.segments.length;return H(e,e.mediaSequence+r,t)},Q=function(e){return e.excludeUntil&&e.excludeUntil>Date.now()},Y=function(e){return e.excludeUntil&&e.excludeUntil===1/0},K=function(e){var t=Q(e);return !e.disabled&&!t},$=function(e,t){return t.attributes&&t.attributes[e]},J=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 !!K(e)&&(e.attributes.BANDWIDTH||0)0)for(r=i-1;r>=0;r--)if((s+=e.segments[r].duration+R)>0)return {mediaIndex:r,startTime:n-j(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=32&&e<126?String.fromCharCode(e):"."},he=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},ce=function(e){var t=e.byterange||{length:1/0,offset:0};return [t.length,t.offset,e.resolvedUri].join(",")},fe=function(e){return e.resolvedUri},me=function(e){for(var t=Array.prototype.slice.call(e),i=16,n="",r=0;rnew Date(o.getTime()+1e3*u)?null:(i>o&&(n=s),{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:Z.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);},ye=function(e){return !!e&&"object"==typeof e},ve=function e(){for(var t=arguments.length,i=new Array(t),n=0;np&&(p=b);var T=void 0;if(_<0){var S=g+1;T=S===t.length?"dynamic"===n&&a>0&&o.indexOf("$Number$")>0?Ue(e,p,v):(u*l-p)/v:(t[S].t-p)/v;}else T=_+1;for(var I=c+m.length+T,w=c+m.length;w=r?a:""+new Array(r-a.length+1).join("0")+a)}}(t))},Re=function(e,t){var i={RepresentationID:e.id,Bandwidth:e.bandwidth||0},n=e.initialization,r=void 0===n?{sourceURL:"",range:""}:n,a=Te({baseUrl:e.baseUrl,source:xe(r.sourceURL,i),range:r.range});return function(e,t){return e.duration||t?e.duration?Ie(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=xe(e.media||"",i);return {uri:n,timeline:t.timeline,duration:t.duration,resolvedUri:f(e.baseUrl||"",n),map:a,number:t.number}}))},Me=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=Te({baseUrl:i,source:r.sourceURL,range:r.range}),s=Te({baseUrl:i,source:t.media,range:t.mediaRange});return s.map=a,s}(e,t)}));return i&&(a=Ie(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}))},Be=function(e){var t,i,n=e.attributes,r=e.segmentInfo;r.template?(i=Re,t=ve(n,r.template)):r.base?(i=we,t=ve(n,r.base)):r.list&&(i=Me,t=ve(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},Fe=function(e,t){return be(e.childNodes).filter((function(e){return e.tagName===t}))},Ne=function(e){return e.textContent.trim()},qe=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)},We={mediaPresentationDuration:function(e){return qe(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 qe(e)},suggestedPresentationDelay:function(e){return qe(e)},type:function(e){return e},timeShiftBufferDepth:function(e){return qe(e)},start:function(e){return qe(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)?qe(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}},Ve=function(e){return e&&e.attributes?be(e.attributes).reduce((function(e,t){var i=We[t.name]||We.DEFAULT;return e[t.name]=i(t.value),e}),{}):{}},He={"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"},Ge=function(e,t){return t.length?_e(e.map((function(e){return t.map((function(t){return f(e,Ne(t))}))}))):e},je=function(e){var t=Fe(e,"SegmentTemplate")[0],i=Fe(e,"SegmentList")[0],n=i&&Fe(i,"SegmentURL").map((function(e){return ve({tag:"SegmentURL"},Ve(e))})),r=Fe(e,"SegmentBase")[0],a=i||t,s=a&&Fe(a,"SegmentTimeline")[0],o=i||r||t,u=o&&Fe(o,"Initialization")[0],d=t&&Ve(t);d&&u?d.initialization=u&&Ve(u):d&&d.initialization&&(d.initialization={sourceURL:d.initialization});var l={template:d,timeline:s&&Fe(s,"S").map((function(e){return Ve(e)})),list:i&&ve(Ve(i),{segmentUrls:n,initialization:Ve(u)}),base:r&&ve(Ve(r),{initialization:Ve(u)})};return Object.keys(l).forEach((function(e){l[e]||delete l[e];})),l},ze=function(e,t){return function(i,n){var r=Ge(t,Fe(i,"BaseURL")),a=Ve(i),s=parseInt(a.id,10),u=o.default.isNaN(s)?n:s,d=ve(e,{periodIndex:u}),l=Fe(i,"AdaptationSet"),h=je(i);return _e(l.map(function(e,t,i){return function(n){var r=Ve(n),a=Ge(t,Fe(n,"BaseURL")),s=Fe(n,"Role")[0],o={role:Ve(s)},u=ve(e,r,o),d=Fe(n,"ContentProtection").reduce((function(e,t){var i=Ve(t),n=He[i.schemeIdUri];if(n){e[n]={attributes:i};var r=Fe(t,"cenc:pssh")[0];if(r){var a=Ne(r),s=a&&v(a);e[n].pssh=s;}}return e}),{});Object.keys(d).length&&(u=ve(u,{contentProtection:d}));var l=je(n),h=Fe(n,"Representation"),c=ve(i,l);return _e(h.map(function(e,t,i){return function(n){var r=Fe(n,"BaseURL"),a=Ge(t,r),s=ve(e,Ve(n)),o=je(n);return a.map((function(e){return {segmentInfo:ve(i,o),attributes:ve(s,{baseUrl:e})}}))}}(u,a,c)))}}(d,r,h)))}},Xe=function(e){if(""===e)throw new Error("DASH_EMPTY_MANIFEST");var t,i,n=new r.DOMParser;try{i=(t=n.parseFromString(e,"application/xml"))&&"MPD"===t.documentElement.tagName?t.documentElement:null;}catch(e){}if(!i||i&&i.getElementsByTagName("parsererror").length>0)throw new Error("DASH_INVALID_XML");return i},Qe=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=Fe(e,"Period");if(!d.length)throw new Error("INVALID_NUMBER_OF_PERIOD");var l=Fe(e,"Location"),h=Ve(e),c=Ge([r],Fe(e,"BaseURL"));return h.sourceDuration=h.mediaPresentationDuration||0,h.NOW=s,h.clientOffset=u,l.length&&(h.locations=l.map(Ne)),{locations:h.locations,representationInfo:_e(d.map(ze(h,c)))}}(Xe(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=ke(e.filter((function(e){var t=e.attributes;return "video/mp4"===t.mimeType||"video/webm"===t.mimeType||"video"===t.contentType}))).map(Ce),h=ke(e.filter((function(e){var t=e.attributes;return "audio/mp4"===t.mimeType||"audio/webm"===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([Ee(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([Pe(i)],t),uri:""}),e}),{})}(c,i)),f}(i.representationInfo.map(Be),i.locations,t.sidxMapping)},Ye=Le,Ke=Math.pow(2,32),$e=function(e){return e instanceof Uint8Array?e:(Array.isArray(e)||(t=e,ArrayBuffer.isView(t))||e instanceof ArrayBuffer||(e="number"!=typeof e||"number"==typeof e&&e!=e?0:[e]),new Uint8Array(e&&e.buffer||e,e&&e.byteOffset||0,e&&e.byteLength||0));var t;},Je=o.default.BigInt||Number,Ze=[Je("0x1"),Je("0x100"),Je("0x10000"),Je("0x1000000"),Je("0x100000000"),Je("0x10000000000"),Je("0x1000000000000"),Je("0x100000000000000"),Je("0x10000000000000000")],et=function(e,t){var i=void 0===t?{}:t,n=i.signed,r=void 0!==n&&n,a=i.le,s=void 0!==a&&a;e=$e(e);var o=s?"reduce":"reduceRight",u=(e[o]?e[o]:Array.prototype[o]).call(e,(function(t,i,n){var r=s?n:Math.abs(n+1-e.length);return t+Je(i)*Ze[r]}),Je(0));if(r){var d=Ze[e.length]/Je(2)-Je(1);(u=Je(u))>d&&(u-=d,u-=d,u-=Je(2));}return Number(u)},tt=function(e,t){if("string"!=typeof e&&e&&"function"==typeof e.toString&&(e=e.toString()),"string"!=typeof e)return new Uint8Array;t||(e=unescape(encodeURIComponent(e)));for(var i=new Uint8Array(e.length),n=0;n=t.length&&u.call(t,(function(t,i){return t===(o[i]?o[i]&e[a+i]:e[a+i])}))},nt=$e([73,68,51]),rt=function e(t,i){return void 0===i&&(i=0),(t=$e(t)).length-i<10||!it(t,nt,{offset:i})?i:(i+=function(e,t){void 0===t&&(t=0);var i=(e=$e(e))[t+5],n=e[t+6]<<21|e[t+7]<<14|e[t+8]<<7|e[t+9];return (16&i)>>4?n+20:n+10}(t,i),e(t,i))},at=function(e){return "string"==typeof e?tt(e):e},st=function e(t,i,n){void 0===n&&(n=!1),i=function(e){return Array.isArray(e)?e.map((function(e){return at(e)})):[at(e)]}(i),t=$e(t);var r=[];if(!i.length)return r;for(var a=0;a>>0,o=t.subarray(a+4,a+8);if(0===s)break;var u=a+s;if(u>t.length){if(n)break;u=t.length;}var d=t.subarray(a+8,u);it(o,i[0])&&(1===i.length?r.push(d):r.push.apply(r,e(d,i.slice(1),n))),a=u;}return r},ot={EBML:$e([26,69,223,163]),DocType:$e([66,130]),Segment:$e([24,83,128,103]),SegmentInfo:$e([21,73,169,102]),Tracks:$e([22,84,174,107]),Track:$e([174]),TrackNumber:$e([215]),DefaultDuration:$e([35,227,131]),TrackEntry:$e([174]),TrackType:$e([131]),FlagDefault:$e([136]),CodecID:$e([134]),CodecPrivate:$e([99,162]),VideoTrack:$e([224]),AudioTrack:$e([225]),Cluster:$e([31,67,182,117]),Timestamp:$e([231]),TimestampScale:$e([42,215,177]),BlockGroup:$e([160]),BlockDuration:$e([155]),Block:$e([161]),SimpleBlock:$e([163])},ut=[128,64,32,16,8,4,2,1],dt=function(e,t,i,n){void 0===i&&(i=!0),void 0===n&&(n=!1);var r=function(e){for(var t=1,i=0;i=i.length)return i.length;var r=dt(i,n,!1);if(it(t.bytes,r.bytes))return n;var a=dt(i,n+r.length);return e(t,i,n+a.length+a.value+r.length)},ct=function e(t,i){i=function(e){return Array.isArray(e)?e.map((function(e){return lt(e)})):[lt(e)]}(i),t=$e(t);var n=[];if(!i.length)return n;for(var r=0;rt.length?t.length:o+s.value,d=t.subarray(o,u);it(i[0],a.bytes)&&(1===i.length?n.push(d):n=n.concat(e(d,i.slice(1)))),r+=a.length+s.length+d.length;}return n},ft=$e([0,0,0,1]),mt=$e([0,0,1]),pt=$e([0,0,3]),gt=function(e){for(var t=[],i=1;i>1&63),-1!==i.indexOf(u)&&(r=a+o),a+=o+("h264"===t?1:2);}else a++;}return e.subarray(0,0)},vt={webm:$e([119,101,98,109]),matroska:$e([109,97,116,114,111,115,107,97]),flac:$e([102,76,97,67]),ogg:$e([79,103,103,83]),ac3:$e([11,119]),riff:$e([82,73,70,70]),avi:$e([65,86,73]),wav:$e([87,65,86,69]),"3gp":$e([102,116,121,112,51,103]),mp4:$e([102,116,121,112]),fmp4:$e([115,116,121,112]),mov:$e([102,116,121,112,113,116])},_t={aac:function(e){var t=rt(e);return it(e,[255,16],{offset:t,mask:[255,22]})},mp3:function(e){var t=rt(e);return it(e,[255,2],{offset:t,mask:[255,6]})},webm:function(e){var t=ct(e,[ot.EBML,ot.DocType])[0];return it(t,vt.webm)},mkv:function(e){var t=ct(e,[ot.EBML,ot.DocType])[0];return it(t,vt.matroska)},mp4:function(e){return !_t["3gp"](e)&&!_t.mov(e)&&(it(e,vt.mp4,{offset:4})||it(e,vt.fmp4,{offset:4}))},mov:function(e){return it(e,vt.mov,{offset:4})},"3gp":function(e){return it(e,vt["3gp"],{offset:4})},ac3:function(e){var t=rt(e);return it(e,vt.ac3,{offset:t})},ts:function(e){if(e.length<189&&e.length>=1)return 71===e[0];for(var t=0;t+1880},Lt=function(e,t){if(4===e.readyState)return t()},kt=u.default.EventTarget,At=u.default.mergeOptions,Et=function(e){var t=e.byterange.offset+e.byterange.length-1;return e.uri+"-"+e.byterange.offset+"-"+t},Pt=function(e,t){var i,n,r={};for(var a in e){var s=e[a].sidx;if(s){var o=Et(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},Ct=function(e){function t(t,i,n,r){var a;void 0===n&&(n={}),(a=e.call(this)||this).masterPlaylistLoader_=r||d(a),r||(a.isMaster_=!0);var s=n,o=s.withCredentials,u=void 0!==o&&o,l=s.handleManifestRedirects,h=void 0!==l&&l;if(a.vhs_=i,a.withCredentials=u,a.handleManifestRedirects=h,!t)throw new Error("A non-empty playlist URL or object is required");return a.on("minimumUpdatePeriod",(function(){a.refreshXml_();})),a.on("mediaupdatetimeout",(function(){a.refreshMedia_(a.media().id);})),a.state="HAVE_NOTHING",a.loadedPlaylists_={},a.isMaster_?(a.masterPlaylistLoader_.srcUrl=t,a.masterPlaylistLoader_.sidxMapping_={}):a.childPlaylist_=t,a}l(t,e);var i=t.prototype;return i.requestErrored_=function(e,t,i){return !this.request||(this.request=null,e?(this.error="object"!=typeof e||e instanceof Error?{status:t.status,message:"DASH request error at URL: "+t.uri,response:t.response,code:2}:e,i&&(this.state=i),this.trigger("error"),!0):void 0)},i.addSidxSegments_=function(e,t,i){var n=this,r=e.sidx&&Et(e.sidx);if(e.sidx&&r&&!this.masterPlaylistLoader_.sidxMapping_[r]){var a=p(this.handleManifestRedirects,e.sidx.resolvedUri),s=this.masterPlaylistLoader_.sidxMapping_;s[r]={sidxInfo:e.sidx};var u=function(a,o){if(!n.requestErrored_(a,o,t)){var u=function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength),i={version:e[0],flags:new Uint8Array(e.subarray(1,4)),references:[],referenceId:t.getUint32(4),timescale:t.getUint32(8)},n=12;0===i.version?(i.earliestPresentationTime=t.getUint32(n),i.firstOffset=t.getUint32(n+4),n+=8):(i.earliestPresentationTime=t.getUint32(n)*Ke+t.getUint32(n+4),i.firstOffset=t.getUint32(n+8)*Ke+t.getUint32(n+12),n+=16),n+=2;var r=t.getUint16(n);for(n+=2;r>0;n+=12,r--)i.references.push({referenceType:(128&e[n])>>>7,referencedSize:2147483647&t.getUint32(n),subsegmentDuration:t.getUint32(n+4),startsWithSap:!!(128&e[n+8]),sapType:(112&e[n+8])>>>4,sapDeltaTime:268435455&t.getUint32(n+8)});return i}($e(o.response).subarray(8));return s[r].sidx=u,Ye(e,u,e.sidx.resolvedUri),i(!0)}};this.request=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=function(){for(var e=arguments.length,t=new Array(e),i=0;i=l+d)return u(t,{response:s.subarray(d,d+l),status:i.status,uri:i.uri});n.request=n.vhs_.xhr({uri:a,responseType:"arraybuffer",headers:re({byterange:e.sidx.byterange})},u);}));}else this.mediaRequest_=o.default.setTimeout((function(){return i(!1)}),0);},i.dispose=function(){this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},o.default.clearTimeout(this.minimumUpdatePeriodTimeout_),o.default.clearTimeout(this.mediaRequest_),o.default.clearTimeout(this.mediaUpdateTimeout),this.off();},i.hasPendingRequest=function(){return this.request||this.mediaRequest_},i.stopRequest=function(){if(this.request){var e=this.request;this.request=null,e.onreadystatechange=null,e.abort();}},i.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 i=this.state;if("string"==typeof e){if(!this.masterPlaylistLoader_.master.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.masterPlaylistLoader_.master.playlists[e];}var n=!this.media_||e.id!==this.media_.id;if(n&&this.loadedPlaylists_[e.id]&&this.loadedPlaylists_[e.id].endList)return this.state="HAVE_METADATA",this.media_=e,void(n&&(this.trigger("mediachanging"),this.trigger("mediachange")));n&&(this.media_&&this.trigger("mediachanging"),this.addSidxSegments_(e,i,(function(n){t.haveMetadata({startingState:i,playlist:e});})));},i.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");},i.pause=function(){this.stopRequest(),o.default.clearTimeout(this.mediaUpdateTimeout),o.default.clearTimeout(this.minimumUpdatePeriodTimeout_),"HAVE_NOTHING"===this.state&&(this.started=!1);},i.load=function(e){var t=this;o.default.clearTimeout(this.mediaUpdateTimeout),o.default.clearTimeout(this.minimumUpdatePeriodTimeout_);var i=this.media();if(e){var n=i?i.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=o.default.setTimeout((function(){return t.load()}),n);}else this.started?i&&!i.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist"):this.start();},i.start=function(){var e=this;this.started=!0,this.isMaster_?this.requestMaster_((function(t,i){e.haveMaster_(),e.hasPendingRequest()||e.media_||e.media(e.masterPlaylistLoader_.master.playlists[0]);})):this.mediaRequest_=o.default.setTimeout((function(){return e.haveMaster_()}),0);},i.requestMaster_=function(e){var t=this;this.request=this.vhs_.xhr({uri:this.masterPlaylistLoader_.srcUrl,withCredentials:this.withCredentials},(function(i,n){if(!t.requestErrored_(i,n)){var r=n.responseText!==t.masterPlaylistLoader_.masterXml_;return t.masterPlaylistLoader_.masterXml_=n.responseText,n.responseHeaders&&n.responseHeaders.date?t.masterLoaded_=Date.parse(n.responseHeaders.date):t.masterLoaded_=Date.now(),t.masterPlaylistLoader_.srcUrl=p(t.handleManifestRedirects,t.masterPlaylistLoader_.srcUrl,n),r?(t.handleMaster_(),void t.syncClientServerClock_((function(){return e(n,r)}))):e(n,r)}"HAVE_NOTHING"===t.state&&(t.started=!1);}));},i.syncClientServerClock_=function(e){var t,i=this,n=(t=this.masterPlaylistLoader_.masterXml_,function(e){var t=Fe(e,"UTCTiming")[0];if(!t)return null;var i=Ve(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}(Xe(t)));return null===n?(this.masterPlaylistLoader_.clientOffset_=this.masterLoaded_-Date.now(),e()):"DIRECT"===n.method?(this.masterPlaylistLoader_.clientOffset_=n.value-Date.now(),e()):void(this.request=this.vhs_.xhr({uri:m(this.masterPlaylistLoader_.srcUrl,n.value),method:n.method,withCredentials:this.withCredentials},(function(t,r){if(i.request){if(t)return i.masterPlaylistLoader_.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.masterPlaylistLoader_.clientOffset_=a-Date.now(),e();}})))},i.haveMaster_=function(){this.state="HAVE_MASTER",this.isMaster_?this.trigger("loadedplaylist"):this.media_||this.media(this.childPlaylist_);},i.handleMaster_=function(){this.mediaRequest_=null;var e,t,i,n=(e={masterXml:this.masterPlaylistLoader_.masterXml_,srcUrl:this.masterPlaylistLoader_.srcUrl,clientOffset:this.masterPlaylistLoader_.clientOffset_,sidxMapping:this.masterPlaylistLoader_.sidxMapping_},i=Qe(e.masterXml,{manifestUri:t=e.srcUrl,clientOffset:e.clientOffset,sidxMapping:e.sidxMapping}),E(i,t),i),r=this.masterPlaylistLoader_.master;r&&(n=function(e,t,i){for(var n=!0,r=At(e,{duration:t.duration,minimumUpdatePeriod:t.minimumUpdatePeriod}),a=0;a0?t(i):0===i&&(this.media()?t(1e3*this.media().targetDuration):this.one("loadedplaylist",(function(){t(1e3*e.media().targetDuration);})));},i.refreshXml_=function(){var e=this;this.requestMaster_((function(t,i){var n,r,a;i&&(e.media_&&(e.media_=e.masterPlaylistLoader_.master.playlists[e.media_.id]),e.masterPlaylistLoader_.sidxMapping_=(n=e.masterPlaylistLoader_.master,r=e.masterPlaylistLoader_.sidxMapping_,a=Pt(n.playlists,r),k(n,(function(e,t,i,n){if(e.playlists&&e.playlists.length){var s=e.playlists;a=At(a,Pt(s,r));}})),a),e.addSidxSegments_(e.media(),e.state,(function(t){e.refreshMedia_(e.media().id);})));}));},i.refreshMedia_=function(e){var t=this;if(!e)throw new Error("refreshMedia_ must take a media id");this.media_&&this.isMaster_&&this.handleMaster_();var i=this.masterPlaylistLoader_.master.playlists,n=!this.media_||this.media_!==i[e];n?this.media_=i[e]:this.trigger("playlistunchanged"),this.media().endList||(this.mediaUpdateTimeout=o.default.setTimeout((function(){t.trigger("mediaupdatetimeout");}),D(this.media(),Boolean(n)))),this.trigger("loadedplaylist");},t}(kt),Ut={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},Ot=function(e){for(var t=new Uint8Array(new ArrayBuffer(e.length)),i=0;it&&(i=-1);Math.abs(t-e)>4294967296;)e+=8589934592*i;return e};var Wt=function(e){var t=31&e[1];return (t<<=8)|e[2]},Vt=function(e){return !!(64&e[1])},Ht=function(e){var t=0;return (48&e[3])>>>4>1&&(t+=e[4]+1),t},Gt=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}},jt={parseType:function(e,t){var i=Wt(e);return 0===i?"pat":i===t?"pmt":t?"pes":null},parsePat:function(e){var t=Vt(e),i=4+Ht(e);return t&&(i+=e[i]+1),(31&e[i+10])<<8|e[i+11]},parsePmt:function(e){var t={},i=Vt(e),n=4+Ht(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=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+Ht(e),i=e.subarray(t),n=0,r=0,a=!1;r3&&"slice_layer_without_partitioning_rbsp_idr"===Gt(31&i[r+3])&&(a=!0),a}},zt=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],Xt=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},Qt=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+=Xt(t,i))},Yt=function(e){return e[0]<<21|e[1]<<14|e[2]<<7|e[3]},Kt={isLikelyAacData:function(e){var t=Qt(e,0);return e.length>=t+2&&255==(255&e[t])&&240==(240&e[t+1])&&16==(22&e[t+1])},parseId3TagSize:Xt,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>>2];t++;}return null},parseAacTimestamp:function(e){var t,i,n;t=10,64&e[5]&&(t+=4,t+=Yt(e.subarray(10,14)));do{if((i=Yt(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>>2;return (s*=4)+(3&a[7])}break}}t+=10,t+=i;}while(t=0;)if(e[o]!==ri||e[u]!==ri&&u!==e.byteLength)o--,u--;else {switch(n=e.subarray(o,u),ei.ts.parseType(n,t.pid)){case"pes":r=ei.ts.parsePesType(n,t.table),a=ei.ts.parsePayloadUnitStartIndicator(n),"audio"===r&&a&&(s=ei.ts.parsePesTime(n))&&(s.type="audio",i.audio.push(s),d=!0);}if(d)break;o-=ni,u-=ni;}},si=function(e,t,i){for(var n,r,a,s,o,u,d,l=0,h=ni,c=!1,f={data:[],size:0};h=0;)if(e[l]!==ri||e[h]!==ri)l--,h--;else {switch(n=e.subarray(l,h),ei.ts.parseType(n,t.pid)){case"pes":r=ei.ts.parsePesType(n,t.table),a=ei.ts.parsePayloadUnitStartIndicator(n),"video"===r&&a&&(s=ei.ts.parsePesTime(n))&&(s.type="video",i.video.push(s),c=!0);}if(c)break;l-=ni,h-=ni;}},oi=function(e,t){var i;return (i=ei.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(ei.aac.parseType(e,o)){case"timed-metadata":if(e.length-o<10){i=!0;break}if((s=ei.aac.parseId3TagSize(e,o))>e.length){i=!0;break}null===a&&(t=e.subarray(o,o+s),a=ei.aac.parseAacTimestamp(t)),o+=s;break;case"audio":if(e.length-o<7){i=!0;break}if((s=ei.aac.parseAdtsSize(e,o))>e.length){i=!0;break}null===r&&(t=e.subarray(o,o+s),r=ei.aac.parseSampleRate(t)),n++,o+=s;break;default:o++;}if(i)return null}if(null===r||null===a)return null;var u=ii/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=ni;r>>0},di=function(e){var t="";return t+=String.fromCharCode(e[0]),t+=String.fromCharCode(e[1]),(t+=String.fromCharCode(e[2]))+String.fromCharCode(e[3])},li=ui,hi=function e(t,i){var n,r,a,s,o,u=[];if(!i.length)return null;for(n=0;n1?n+r:t.byteLength,a===i[0]&&(1===i.length?u.push(t.subarray(n+8,s)):(o=e(t.subarray(n+8,s),i.slice(1))).length&&(u=u.concat(o))),n=s;return u},ci=ui,fi=function(e){return ("00"+e.toString(16)).slice(-2)},mi=function(e,t){var i,n,r;return i=hi(t,["moof","traf"]),n=[].concat.apply([],i.map((function(t){return hi(t,["tfhd"]).map((function(i){var n,r,a;return n=ci(i[4]<<24|i[5]<<16|i[6]<<8|i[7]),r=e[n]||9e4,(a="number"!=typeof(a=hi(t,["tfdt"]).map((function(e){var t,i;return t=e[0],i=ci(e[4]<<24|e[5]<<16|e[6]<<8|e[7]),1===t&&(i*=Math.pow(2,32),i+=ci(e[8]<<24|e[9]<<16|e[10]<<8|e[11])),i}))[0])||isNaN(a)?1/0:a)/r}))}))),r=Math.min.apply(null,n),isFinite(r)?r:0},pi=function(e){var t=hi(e,["moov","trak"]),i=[];return t.forEach((function(e){var t,n,r={},a=hi(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=hi(e,["mdia","hdlr"])[0];if(s){var o=di(s.subarray(8,12));r.type="vide"===o?"video":"soun"===o?"audio":o;}var u=hi(e,["mdia","minf","stbl","stsd"])[0];if(u){var d=u.subarray(8);r.codec=di(d.subarray(4,8));var l,h=hi(d,[r.codec])[0];h&&(/^[a-z]vc[1-9]$/i.test(r.codec)?(l=h.subarray(78),"avcC"===di(l.subarray(4,8))&&l.length>11?(r.codec+=".",r.codec+=fi(l[9]),r.codec+=fi(l[10]),r.codec+=fi(l[11])):r.codec="avc1.4d400d"):/^mp4[a,v]$/i.test(r.codec)?(l=h.subarray(28),"esds"===di(l.subarray(4,8))&&l.length>20&&0!==l[19]?(r.codec+="."+fi(l[19]),r.codec+="."+fi(l[20]>>>2&63).replace(/^0/,"")):r.codec="mp4a.40.2"):r.codec=r.codec.toLowerCase());}var c=hi(e,["mdia","mdhd"])[0];c&&(r.timescale=ti(c)),i.push(r);})),i},gi=(ti=function(e){var t=0===e[0]?12:20;return ci(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])},2),yi=-101,vi=-102,_i=function(e){e.forEach((function(e){e.abort();}));},bi=function(e,t){return t.timedout?{status:t.status,message:"HLS request timed-out at URL: "+t.uri,code:yi,xhr:t}:t.aborted?{status:t.status,message:"HLS request aborted at URL: "+t.uri,code:vi,xhr:t}:e?{status:t.status,message:"HLS request errored at URL: "+t.uri,code:gi,xhr:t}:null},Ti=function(e){var t=e.segment,i=e.bytes,n=e.isPartial,r=e.trackInfoFn,a=e.timingInfoFn,s=e.videoSegmentTimingInfoFn,o=e.audioSegmentTimingInfoFn,u=e.id3Fn,d=e.captionsFn,l=e.dataFn,h=e.doneFn,c=t.map&&t.map.tracks||{},f=Boolean(c.audio&&c.video),m=a.bind(null,t,"audio","start"),p=a.bind(null,t,"audio","end"),g=a.bind(null,t,"video","start"),y=a.bind(null,t,"video","end");if(!n&&!t.lastReachedChar){var v=function(e,t){var i=oi(e,t*Jt);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);v&&(r(t,{hasAudio:v.hasAudio,hasVideo:v.hasVideo,isMuxed:f}),r=null,v.hasAudio&&!f&&m(v.audioStart),v.hasVideo&&g(v.videoStart),m=null,g=null);}!function(e){if(!Tt)return Tt=e,void xt(e);Dt.push(e);}({bytes:i,transmuxer:t.transmuxer,audioAppendStart:t.audioAppendStart,gopsToAlignWith:t.gopsToAlignWith,isPartial:n,remux:f,onData:function(e){e.type="combined"===e.type?"video":e.type,l(t,e);},onTrackInfo:function(e){r&&(f&&(e.isMuxed=!0),r(t,e));},onAudioTimingInfo:function(e){m&&void 0!==e.start&&(m(e.start),m=null),p&&void 0!==e.end&&p(e.end);},onVideoTimingInfo:function(e){g&&void 0!==e.start&&(g(e.start),g=null),y&&void 0!==e.end&&y(e.end);},onVideoSegmentTimingInfo:function(e){s(e);},onAudioSegmentTimingInfo:function(e){o(e);},onId3:function(e,i){u(t,e,i);},onCaptions:function(e){d(t,[e]);},onDone:function(e){h&&!n&&(e.type="combined"===e.type?"video":e.type,h(null,t,e));}});},Si=function(e){var t=e.segment,i=e.bytes,n=e.isPartial,r=e.trackInfoFn,a=e.timingInfoFn,s=e.videoSegmentTimingInfoFn,o=e.audioSegmentTimingInfoFn,u=e.id3Fn,d=e.captionsFn,l=e.dataFn,h=e.doneFn,c=new Uint8Array(i);if(wt(c)){t.isFmp4=!0;var f=t.map.tracks,m={isFmp4:!0,hasVideo:!!f.video,hasAudio:!!f.audio};f.audio&&f.audio.codec&&"enca"!==f.audio.codec&&(m.audioCodec=f.audio.codec),f.video&&f.video.codec&&"encv"!==f.video.codec&&(m.videoCodec=f.video.codec),f.video&&f.audio&&(m.isMuxed=!0),r(t,m);var p=mi(t.map.timescales,c);m.hasAudio&&!m.isMuxed&&a(t,"audio","start",p),m.hasVideo&&a(t,"video","start",p);var g=function(e){l(t,{data:i,type:m.hasAudio&&!m.isMuxed?"audio":"video"}),e&&e.length&&d(t,e),h(null,t,{});};if(!f.video||!i.byteLength||!t.transmuxer)return void g();var y=i instanceof ArrayBuffer?i:i.buffer,v=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),g(n.data.captions);}})),void t.transmuxer.postMessage({action:"pushMp4Captions",timescales:t.map.timescales,trackIds:[f.video.id],data:y,byteOffset:v,byteLength:i.byteLength},[y])}if(t.transmuxer){if(void 0===t.container&&(t.container=It(c)),"ts"!==t.container&&"aac"!==t.container)return r(t,{hasAudio:!1,hasVideo:!1}),void h(null,t,{});Ti({segment:t,bytes:i,isPartial:n,trackInfoFn:r,timingInfoFn:a,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:o,id3Fn:u,captionsFn:d,dataFn:l,doneFn:h});}else h(null,t,{});},Ii=function(e){var t=e.xhr,i=e.xhrOptions,n=e.decryptionWorker,r=e.segment,a=e.abortFn,s=e.progressFn,o=e.trackInfoFn,d=e.timingInfoFn,l=e.videoSegmentTimingInfoFn,h=e.audioSegmentTimingInfoFn,c=e.id3Fn,f=e.captionsFn,m=e.dataFn,p=e.doneFn,g=e.handlePartialData,y=[],v=function(e){var t=e.activeXhrs,i=e.decryptionWorker,n=e.trackInfoFn,r=e.timingInfoFn,a=e.videoSegmentTimingInfoFn,s=e.audioSegmentTimingInfoFn,o=e.id3Fn,u=e.captionsFn,d=e.dataFn,l=e.doneFn,h=0,c=!1;return function(e,f){if(!c){if(e)return c=!0,_i(t),l(e,f);if((h+=1)===t.length){if(f.endOfAllRequests=Date.now(),f.encryptedBytes)return function(e){var t,i=e.decryptionWorker,n=e.segment,r=e.trackInfoFn,a=e.timingInfoFn,s=e.videoSegmentTimingInfoFn,o=e.audioSegmentTimingInfoFn,u=e.id3Fn,d=e.captionsFn,l=e.dataFn,h=e.doneFn;i.addEventListener("message",(function e(t){if(t.data.source===n.requestId){i.removeEventListener("message",e);var c=t.data.decrypted;n.bytes=new Uint8Array(c.bytes,c.byteOffset,c.byteLength),Si({segment:n,bytes:n.bytes,isPartial:!1,trackInfoFn:r,timingInfoFn:a,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:o,id3Fn:u,captionsFn:d,dataFn:l,doneFn:h});}})),t=n.key.bytes.slice?n.key.bytes.slice():new Uint32Array(Array.prototype.slice.call(n.key.bytes)),i.postMessage(he({source:n.requestId,encrypted:n.encryptedBytes,key:t,iv:n.key.iv}),[n.encryptedBytes.buffer,t.buffer]);}({decryptionWorker:i,segment:f,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:a,audioSegmentTimingInfoFn:s,id3Fn:o,captionsFn:u,dataFn:d,doneFn:l});Si({segment:f,bytes:f.bytes,isPartial:!1,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:a,audioSegmentTimingInfoFn:s,id3Fn:o,captionsFn:u,dataFn:d,doneFn:l});}}}}({activeXhrs:y,decryptionWorker:n,trackInfoFn:o,timingInfoFn:d,videoSegmentTimingInfoFn:l,audioSegmentTimingInfoFn:h,id3Fn:c,captionsFn:f,dataFn:m,doneFn:p});if(r.key&&!r.key.bytes){var _=t(u.default.mergeOptions(i,{uri:r.key.resolvedUri,responseType:"arraybuffer"}),function(e,t){return function(i,n){var r=n.response,a=bi(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:gi,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)}}(r,v));y.push(_);}if(r.map&&!r.map.bytes){var b=t(u.default.mergeOptions(i,{uri:r.map.resolvedUri,responseType:"arraybuffer",headers:re(r.map)}),function(e){var t=e.segment,i=e.finishProcessingFn;return function(e,n){var r=n.response,a=bi(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:gi,xhr:n},t);t.map.bytes=new Uint8Array(n.response);var s=It(t.map.bytes);return "mp4"!==s?i({status:n.status,message:"Found unsupported "+(s||"unknown")+" container for initialization segment at URL: "+n.uri,code:gi,internal:!0,xhr:n},t):(pi(t.map.bytes).forEach((function(e){t.map.tracks=t.map.tracks||{},t.map.tracks[e.type]||(t.map.tracks[e.type]=e,"number"==typeof e.id&&e.timescale&&(t.map.timescales=t.map.timescales||{},t.map.timescales[e.id]=e.timescale));})),i(null,t))}}({segment:r,finishProcessingFn:v}));y.push(b);}var T=u.default.mergeOptions(i,{uri:r.resolvedUri,responseType:"arraybuffer",headers:re(r)});g&&(T.responseType="text",T.beforeSend=function(e){e.overrideMimeType("text/plain; charset=x-user-defined");});var S=t(T,function(e){var t=e.segment,i=e.finishProcessingFn,n=e.responseType;return function(e,r){var a=r.response,s=bi(e,r);if(s)return i(s,t);var o="arraybuffer"!==n&&r.responseText?Ot(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:gi,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:r,finishProcessingFn:v,responseType:T.responseType}));S.addEventListener("progress",function(e){var t=e.segment,i=e.progressFn,n=e.trackInfoFn,r=e.timingInfoFn,a=e.videoSegmentTimingInfoFn,s=e.audioSegmentTimingInfoFn,o=e.id3Fn,d=e.captionsFn,l=e.dataFn,h=e.handlePartialData;return function(e){var c=e.target;if(!c.aborted){if(h&&!t.key&&c.responseText&&c.responseText.length>=8){var f=Ot(c.responseText.substring(t.lastReachedChar||0));!t.lastReachedChar&&wt(new Uint8Array(f))||(t.lastReachedChar=c.responseText.length,Si({segment:t,bytes:f,isPartial:!0,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:a,audioSegmentTimingInfoFn:s,id3Fn:o,captionsFn:d,dataFn:l}));}return t.stats=u.default.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:r,progressFn:s,trackInfoFn:o,timingInfoFn:d,videoSegmentTimingInfoFn:l,audioSegmentTimingInfoFn:h,id3Fn:c,captionsFn:f,dataFn:m,handlePartialData:g})),y.push(S);var I={};return y.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:I,abortFn:a}));})),function(){return _i(y)}},wi="undefined"!=typeof window?window:{},Li="undefined"==typeof Symbol?"__target":Symbol(),ki=wi.BlobBuilder||wi.WebKitBlobBuilder||wi.MozBlobBuilder||wi.MSBlobBuilder,Ai=wi.URL||wi.webkitURL||Ai&&Ai.msURL,Ei=wi.Worker;function Pi(e,t){return function(i){var n=this;if(!t)return new Ei(e);if(Ei&&!i){var r=Di(t.toString().replace(/^function.+?{/,"").slice(0,-1));return this[Li]=new Ei(r),function(e,t){if(e&&t){var i=e.terminate;e.objURL=t,e.terminate=function(){e.objURL&&Ai.revokeObjectURL(e.objURL),i.call(e);};}}(this[Li],r),this[Li]}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(Ei){var Ci,Ui=Di("self.onmessage = function () {}"),Oi=new Uint8Array(1);try{(Ci=new Ei(Ui)).postMessage(Oi,[Oi.buffer]);}catch(e){Ei=null;}finally{Ai.revokeObjectURL(Ui),Ci&&Ci.terminate();}}function Di(e){try{return Ai.createObjectURL(new Blob([e],{type:"application/javascript"}))}catch(i){var t=new ki;return t.append(e),Ai.createObjectURL(t.getBlob(type))}}var xi=new Pi("./transmuxer-worker.worker.js",(function(e,t){var i=this; -/*! @name @videojs/http-streaming @version 2.5.0 @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>>1,e.samplingfrequencyindex<<7|e.channelcount<<3,6,1,2]))},g=function(e){return t(I.hdlr,P[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,C):t(I.smhd,U),n(),v(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>>8),s.push(255&r[i].byteLength),s=s.concat(Array.prototype.slice.call(r[i]));for(i=0;i>>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)},W=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=W(s,i),(r=new Uint8Array(a.length+16*s.length)).set(a),n=a.length,u=0;u>>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=W(s,i),(n=new Uint8Array(a.length+8*s.length)).set(a),r=a.length,u=0;u>>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,w,L,w,k)};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;t1&&(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;t45e3))){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=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=this.virtualRowCount&&"function"==typeof this.beforeRowOverflow&&this.beforeRowOverflow(e),this.rows.length>0&&(this.rows.push(""),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--;},Ae.prototype.isEmpty=function(){return 0===this.rows.length||1===this.rows.length&&""===this.rows[0]},Ae.prototype.addText=function(e){this.rows[this.rowIdx]+=e;},Ae.prototype.backspace=function(){if(!this.isEmpty()){var e=this.rows[this.rowIdx];this.rows[this.rowIdx]=e.substr(0,e.length-1);}};var Ee=function(e){this.serviceNum=e,this.text="",this.currentWindow=new Ae(-1),this.windows=[];};Ee.prototype.init=function(e,t){this.startPts=e;for(var i=0;i<8;i++)this.windows[i]=new Ae(i),"function"==typeof t&&(this.windows[i].beforeRowOverflow=t);},Ee.prototype.setCurrentWindow=function(e){this.currentWindow=this.windows[e];};var Pe=function e(){e.prototype.init.call(this);var t=this;this.current708Packet=null,this.services={},this.push=function(e){3===e.type?(t.new708Packet(),t.add708Bytes(e)):(null===t.current708Packet&&t.new708Packet(),t.add708Bytes(e));};};Pe.prototype=new V,Pe.prototype.new708Packet=function(){null!==this.current708Packet&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]};},Pe.prototype.add708Bytes=function(e){var t=e.ccData,i=t>>>8,n=255&t;this.current708Packet.ptsVals.push(e.pts),this.current708Packet.data.push(i),this.current708Packet.data.push(n);},Pe.prototype.push708Packet=function(){var e=this.current708Packet,t=e.data,i=null,n=null,r=0,a=t[r++];for(e.seq=a>>6,e.sizeCode=63&a;r>5)&&n>0&&(i=a=t[r++]),this.pushServiceBlock(i,r,n),n>0&&(r+=n-1);},Pe.prototype.pushServiceBlock=function(e,t,i){var n,r=t,a=this.current708Packet.data,s=this.services[e];for(s||(s=this.initService(e,r));r>5,a.rowLock=(16&n)>>4,a.columnLock=(8&n)>>3,a.priority=7&n,n=i[++e],a.relativePositioning=(128&n)>>7,a.anchorVertical=127&n,n=i[++e],a.anchorHorizontal=n,n=i[++e],a.anchorPoint=(240&n)>>4,a.rowCount=15&n,n=i[++e],a.columnCount=63&n,n=i[++e],a.windowStyle=(56&n)>>3,a.penStyle=7&n,a.virtualRowCount=a.rowCount+1,e},Pe.prototype.setWindowAttributes=function(e,t){var i=this.current708Packet.data,n=i[e],r=t.currentWindow.winAttr;return n=i[++e],r.fillOpacity=(192&n)>>6,r.fillRed=(48&n)>>4,r.fillGreen=(12&n)>>2,r.fillBlue=3&n,n=i[++e],r.borderType=(192&n)>>6,r.borderRed=(48&n)>>4,r.borderGreen=(12&n)>>2,r.borderBlue=3&n,n=i[++e],r.borderType+=(128&n)>>5,r.wordWrap=(64&n)>>6,r.printDirection=(48&n)>>4,r.scrollDirection=(12&n)>>2,r.justify=3&n,n=i[++e],r.effectSpeed=(240&n)>>4,r.effectDirection=(12&n)>>2,r.displayEffect=3&n,e},Pe.prototype.flushDisplayed=function(e,t){for(var i=[],n=0;n<8;n++)t.windows[n].visible&&!t.windows[n].isEmpty()&&i.push(t.windows[n].getText());t.endPts=e,t.text=i.join("\n\n"),this.pushCaption(t),t.startPts=e;},Pe.prototype.pushCaption=function(e){""!==e.text&&(this.trigger("data",{startPts:e.startPts,endPts:e.endPts,text:e.text,stream:"cc708_"+e.serviceNum}),e.text="",e.startPts=e.endPts);},Pe.prototype.displayWindows=function(e,t){var i=this.current708Packet.data[++e],n=this.getPts(e);this.flushDisplayed(n,t);for(var r=0;r<8;r++)i&1<>4,r.offset=(12&n)>>2,r.penSize=3&n,n=i[++e],r.italics=(128&n)>>7,r.underline=(64&n)>>6,r.edgeType=(56&n)>>3,r.fontStyle=7&n,e},Pe.prototype.setPenColor=function(e,t){var i=this.current708Packet.data,n=i[e],r=t.currentWindow.penColor;return n=i[++e],r.fgOpacity=(192&n)>>6,r.fgRed=(48&n)>>4,r.fgGreen=(12&n)>>2,r.fgBlue=3&n,n=i[++e],r.bgOpacity=(192&n)>>6,r.bgRed=(48&n)>>4,r.bgGreen=(12&n)>>2,r.bgBlue=3&n,n=i[++e],r.edgeRed=(48&n)>>4,r.edgeGreen=(12&n)>>2,r.edgeBlue=3&n,e},Pe.prototype.setPenLocation=function(e,t){var i=this.current708Packet.data,n=i[e],r=t.currentWindow.penLoc;return t.currentWindow.pendingNewLine=!0,n=i[++e],r.row=15&n,n=i[++e],r.column=63&n,e},Pe.prototype.reset=function(e,t){var i=this.getPts(e);return this.flushDisplayed(i,t),this.initService(t.serviceNum,e)};var Ce={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},Ue=function(e){return null===e?"":(e=Ce[e]||e,String.fromCharCode(e))},Oe=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],De=function(){for(var e=[],t=15;t--;)e.push("");return e},xe=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_=De();else if(t===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=De();else if(t===this.RESUME_DIRECT_CAPTIONING_)"paintOn"!==this.mode_&&(this.flushDisplayed(e.pts),this.displayed_=De()),this.mode_="paintOn",this.startPts_=e.pts;else if(this.isSpecialCharacter(n,r))a=Ue((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=Ue((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=Oe.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=Ue(n),a+=Ue(r),this[this.mode_](e.pts,a),this.column_+=a.length);}else this.lastControlCode_=null;};};xe.prototype=new V,xe.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_});},xe.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=De(),this.nonDisplayed_=De(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.rollUpRows_=2,this.formatting_=[];},xe.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_;},xe.prototype.isSpecialCharacter=function(e,t){return e===this.EXT_&&t>=48&&t<=63},xe.prototype.isExtCharacter=function(e,t){return (e===this.EXT_+1||e===this.EXT_+2)&&t>=32&&t<=63},xe.prototype.isMidRowCode=function(e,t){return e===this.EXT_&&t>=32&&t<=47},xe.prototype.isOffsetControlCode=function(e,t){return e===this.OFFSET_&&t>=33&&t<=35},xe.prototype.isPAC=function(e,t){return e>=this.BASE_&&e=64&&t<=127},xe.prototype.isColorPAC=function(e){return e>=64&&e<=79||e>=96&&e<=127},xe.prototype.isNormalChar=function(e){return e>=32&&e<=127},xe.prototype.setRollUp=function(e,t){if("rollUp"!==this.mode_&&(this.row_=14,this.mode_="rollUp",this.flushDisplayed(e),this.nonDisplayed_=De(),this.displayed_=De()),void 0!==t&&t!==this.row_)for(var i=0;i"}),"");this[this.mode_](e,i);},xe.prototype.clearFormatting=function(e){if(this.formatting_.length){var t=this.formatting_.reverse().reduce((function(e,t){return e+""}),"");this.formatting_=[],this[this.mode_](e,t);}},xe.prototype.popOn=function(e,t){var i=this.nonDisplayed_[this.row_];i+=t,this.nonDisplayed_[this.row_]=i;},xe.prototype.rollUp=function(e,t){var i=this.displayed_[this.row_];i+=t,this.displayed_[this.row_]=i;},xe.prototype.shiftRowsUp_=function(){var e;for(e=0;et&&(i=-1);Math.abs(t-e)>4294967296;)e+=8589934592*i;return e},Ne=function e(t){var i,n;e.prototype.init.call(this),this.type_=t||Be,this.push=function(e){this.type_!==Be&&e.type!==this.type_||(void 0===n&&(n=e.dts),e.dts=Fe(e.dts,n),e.pts=Fe(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");};};Ne.prototype=new V;var qe,We=Ne,Ve=function(e,t,i){var n,r="";for(n=t;n>>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>>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=Me.H264_STREAM_TYPE:i.pid===this.programMapTable.audio?i.streamType=Me.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 V,Xe.STREAM_TYPES={h264:27,adts:15},(Qe=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>>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);}};Qe.prototype.init.call(this),this.push=function(s){({pat:function(){},pes:function(){var e,t;switch(s.streamType){case Me.H264_STREAM_TYPE:e=i,t="video";break;case Me.ADTS_STREAM_TYPE:e=n,t="audio";break;case Me.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 V;var Je={PAT_PID:0,MP2T_PACKET_LENGTH:$e,TransportPacketStream:ze,TransportParseStream:Xe,ElementaryStream:Qe,TimestampRolloverStream:Ke,CaptionStream:Re.CaptionStream,Cea608Stream:Re.Cea608Stream,Cea708Stream:Re.Cea708Stream,MetadataStream:Ye};for(var Ze in Me)Me.hasOwnProperty(Ze)&&(Je[Ze]=Me[Ze]);var et,tt=Je,it=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];(et=function(e){var t,i=0;et.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>5,d=9e4*(u=1024*(1+(3&t[l+6])))/it[(60&t[l+2])>>>2],s=l+r,t.byteLength>>6&3),channelcount:(1&t[l+2])<<2|(192&t[l+3])>>>6,samplerate:it[(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 V;var nt,rt,at,st=et,ot=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<>>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();};(rt=function(){var e,t,i=0;rt.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;i3&&this.trigger("data",t.subarray(i+3)),t=null,i=0,this.trigger("done");},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline");};}).prototype=new V,at={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},(nt=function(){var e,t,i,n,r,a,s,o=new rt;nt.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=0?i:0,(16&e[t+5])>>4?i+20:i+10},ht=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+=lt(t,i))},ct=function(e){var t=ht(e,0);return e.length>=t+2&&255==(255&e[t])&&240==(240&e[t+1])&&16==(22&e[t+1])},ft=lt,mt=function(e,t){var i=(224&e[t+5])>>5,n=e[t+4]<<3;return 6144&e[t+3]|n|i};(ut=function(){var e=new Uint8Array,t=0;ut.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=mt(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=ft(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 V;var pt,gt,yt,vt,_t=ut,bt=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],Tt=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],St=dt.H264Stream,It=ct,wt=function(e,t){var i;if(e.length!==t.length)return !1;for(i=0;i=-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;tn.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 V,(vt=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,vt.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 V,vt.prototype.flush=function(e){var t,i,n,r,a=0,s={captions:[],captionStreams:{},metadata:[],info:{}},o=0;if(this.pendingTracks.length=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0))}if(this.videoTrack?(o=this.videoTrack.timelineStartInfo.pts,Tt.forEach((function(e){s.info[e]=this.videoTrack[e];}),this)):this.audioTrack&&(o=this.audioTrack.timelineStartInfo.pts,bt.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.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0);},vt.prototype.setRemux=function(e){this.remuxTracks=e;},(yt=function(e){var t,i,n=this,r=!0;yt.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 tt.MetadataStream,r.aacStream=new _t,r.audioTimestampRolloverStream=new tt.TimestampRolloverStream("audio"),r.timedMetadataTimestampRolloverStream=new tt.TimestampRolloverStream("timed-metadata"),r.adtsStream=new st,r.coalesceStream=new vt(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 gt(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 tt.MetadataStream,r.packetStream=new tt.TransportPacketStream,r.parseStream=new tt.TransportParseStream,r.elementaryStream=new tt.ElementaryStream,r.timestampRolloverStream=new tt.TimestampRolloverStream,r.adtsStream=new st,r.h264Stream=new St,r.captionStream=new tt.CaptionStream(e),r.coalesceStream=new vt(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 pt(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 gt(i,e),r.audioSegmentStream.on("timingInfo",n.trigger.bind(n,"audioTimingInfo")),r.audioSegmentStream.on("segmentTimingInfo",n.trigger.bind(n,"audioSegmentTimingInfo")),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,Te(i),r.audioTimestampRolloverStream&&r.audioTimestampRolloverStream.discontinuity()),t&&(r.videoSegmentStream&&(r.videoSegmentStream.gopCache_=[]),t.timelineStartInfo.dts=void 0,t.timelineStartInfo.pts=void 0,Te(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=It(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 V;var kt={Transmuxer:yt,VideoSegmentStream:pt,AudioSegmentStream:gt,AUDIO_PROPERTIES:bt,VIDEO_PROPERTIES:Tt,generateSegmentTimingInfo:Lt},At={Adts:st,h264:dt},Et=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){Ie(t,e),t&&bt.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=ve(n,t,a)).length&&(t.baseMediaDecodeTime=Se(t,i.keepOriginalTimestamps),ye(t,e,s,o),t.samples=_e(e),h=J(be(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),Te(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(){Te(t),u=null,d=null;},this.reset=function(){this.resetTiming_(),n=[],this.trigger("reset");};};Et.prototype=new V;var Pt=Et,Ct=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){Ie(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],Tt.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>>0},Ft=Bt,Nt=function e(t,i){var n,r,a,s,o,u,d,l=[];if(!i.length)return null;for(n=0;n1?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},qt=Bt,Wt=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]}},Vt=function(e){for(var t,i,n=e.byteLength,r=[],a=1;a0?function(e){var t={version:e[0],flags:new Uint8Array(e.subarray(1,4)),baseMediaDecodeTime:qt(e[4]<<24|e[5]<<16|e[6]<<8|e[7])};return 1===t.version&&(t.baseMediaDecodeTime*=Math.pow(2,32),t.baseMediaDecodeTime+=qt(e[8]<<24|e[9]<<16|e[10]<<8|e[11])),t}(b[0]).baseMediaDecodeTime:0,S=Nt(g,["trun"]);t===_&&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+40;){var u=t.shift();this.parse(u,a,s);}return null!==(o=function(e,t,i){return null===t?null:{seiNals:jt(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();},Xt=function(e){return "AudioSegmentStream"===e?"audio":"VideoSegmentStream"===e?"video":""},Qt=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 Mt(this.options):new kt.Transmuxer(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=fe(t.data.videoFrameDts)),void 0!==t.data.videoFramePts&&(n.videoFramePtsTime=fe(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:Xt(t)});})),t.on("partialdone",(function(t){e.postMessage({action:"partialdone",type:Xt(t)});})),t.on("endedsegment",(function(t){e.postMessage({action:"endedSegment",type:Xt(t)});})),t.on("trackinfo",(function(t){e.postMessage({action:"trackinfo",trackInfo:t});})),t.on("audioTimingInfo",(function(t){if(null!==t.start){var i={start:fe(t.start)};t.end&&(i.end=fe(t.end)),e.postMessage({action:"audioTimingInfo",audioTimingInfo:i});}else e.postMessage({action:"audioTimingInfo",audioTimingInfo:t});})),t.on("videoTimingInfo",(function(t){var i={start:fe(t.start)};t.end&&(i.end=fe(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:fe(t.start.dts),presentation:fe(t.start.pts)},end:{decode:fe(t.end.dts),presentation:fe(t.end.pts)},baseMediaDecodeTime:fe(t.baseMediaDecodeTime)};t.prependedContentDuration&&(i.prependedContentDuration=fe(t.prependedContentDuration)),e.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:i});})),t.on("audioSegmentTimingInfo",(function(t){var i={start:{decode:fe(t.start.dts),presentation:fe(t.start.pts)},end:{decode:fe(t.end.dts),presentation:fe(t.end.pts)},baseMediaDecodeTime:fe(t.baseMediaDecodeTime)};t.prependedContentDuration&&(i.prependedContentDuration=fe(t.prependedContentDuration)),e.postMessage({action:"audioSegmentTimingInfo",audioSegmentTimingInfo: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:fe(t.start),end:fe(t.end)}});})),t.on("videoTimingInfo",(function(t){e.postMessage({action:"videoTimingInfo",videoTimingInfo:{start:fe(t.start),end:fe(t.end)}});}));}(this.self,this.transmuxer);},t.pushMp4Captions=function(e){this.captionParser||(this.captionParser=new zt,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(ce(t)));},t.setAudioAppendStart=function(e){this.transmuxer.setAudioAppendStart(Math.ceil(ce(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 Qt(e,t.data.options):(this.messageHandlers||(this.messageHandlers=new Qt(e)),t.data&&t.data.action&&"init"!==t.data.action&&this.messageHandlers[t.data.action]&&this.messageHandlers[t.data.action](t.data));};}(i);}();})),Ri={mp4:/^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v|stpp.ttml.im1t)/,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|speex|aac)/,text:/^(stpp.ttml.im1t)/,muxerVideo:/^(avc0?1)/,muxerAudio:/^(mp4a)/,muxerText:/a^/},Mi=["video","audio","text"],Bi=["Video","Audio","Text"],Fi=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},Ni=function(e){void 0===e&&(e="");var t=e.split(","),i=[];return t.forEach((function(e){var t;e=e.trim(),Mi.forEach((function(n){var r=Ri[n].exec(e.toLowerCase());if(r&&!(r.length<=1)){t=n;var a=e.substring(0,r[1].length),s=e.replace(a,"");i.push({type:a,details:s,mediaType:n});}})),t||i.push({type:e,details:"",mediaType:"unknown"});})),i},qi=function(e){return void 0===e&&(e=""),Ri.audio.test(e.trim().toLowerCase())},Wi=function(e){if(e&&"string"==typeof e){var t,i=e.toLowerCase().split(",").map((function(e){return Fi(e.trim())})),n="video";1===i.length&&qi(i[0])?n="audio":1===i.length&&(void 0===(t=i[0])&&(t=""),Ri.text.test(t.trim().toLowerCase()))&&(n="application");var r="mp4";return i.every((function(e){return Ri.mp4.test(e)}))?r="mp4":i.every((function(e){return Ri.webm.test(e)}))?r="webm":i.every((function(e){return Ri.ogg.test(e)}))&&(r="ogg"),n+"/"+r+';codecs="'+e+'"'}},Vi=function(e){return void 0===e&&(e=""),o.default.MediaSource&&o.default.MediaSource.isTypeSupported&&o.default.MediaSource.isTypeSupported(Wi(e))||!1},Hi=function(e){return void 0===e&&(e=""),e.toLowerCase().split(",").every((function(e){e=e.trim();for(var t=0;t"):function(){}},zi=ji("CodecUtils"),Xi=function(e,t){var i=t.attributes||{};return e&&e.mediaGroups&&e.mediaGroups.AUDIO&&i.AUDIO&&e.mediaGroups.AUDIO[i.AUDIO]},Qi=function(e){var t={};return e.forEach((function(e){var i=e.mediaType,n=e.type,r=e.details;t[i]=t[i]||[],t[i].push(Fi(""+n+r));})),Object.keys(t).forEach((function(e){if(t[e].length>1)return zi("multiple "+e+" codecs found as attributes: "+t[e].join(", ")+". Setting playlist codecs to null so that we wait for mux.js to probe segments for real codecs."),void(t[e]=null);t[e]=t[e][0];})),t},Yi=function(e){var t=0;return e.audio&&t++,e.video&&t++,t},Ki=function(e,t){var i=t.attributes||{},n=Qi(function(e){var t=e.attributes||{};if(t.CODECS)return Ni(t.CODECS)}(t)||[]);if(Xi(e,t)&&!n.audio&&!function(e,t){if(!Xi(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=Qi(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 Ni(r.playlists[0].attributes.CODECS)}return null}(e,i.AUDIO)||[]);r.audio&&(n.audio=r.audio);}return n},$i=ji("PlaylistSelector"),Ji=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||""})}},Zi=function(e,t){if(!e)return "";var i=o.default.getComputedStyle(e);return i?i[t]:""},en=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}));},tn=function(e,t){var i,n;return e.attributes.BANDWIDTH&&(i=e.attributes.BANDWIDTH),i=i||o.default.Number.MAX_VALUE,t.attributes.BANDWIDTH&&(n=t.attributes.BANDWIDTH),i-(n||o.default.Number.MAX_VALUE)},nn=function(e,t,i,n,r){if(e){var a={bandwidth:t,width:i,height:n,limitRenditionByPlayerDimensions:r},s=e.playlists.map((function(e){var t=e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width,i=e.attributes.RESOLUTION&&e.attributes.RESOLUTION.height;return {bandwidth:e.attributes.BANDWIDTH||o.default.Number.MAX_VALUE,width:t,height:i,playlist:e}}));en(s,(function(e,t){return e.bandwidth-t.bandwidth}));var u=(s=s.filter((function(e){return !Z.isIncompatible(e.playlist)}))).filter((function(e){return Z.isEnabled(e.playlist)}));u.length||(u=s.filter((function(e){return !Z.isDisabled(e.playlist)})));var d=u.filter((function(e){return e.bandwidth*Ut.BANDWIDTH_VARIANCEi||e.height>n}))).filter((function(e){return e.width===g[0].width&&e.height===g[0].height})),l=y[y.length-1],v=y.filter((function(e){return e.bandwidth===l.bandwidth}))[0]);var b=v||_||h||u[0]||s[0];if(b&&b.playlist){var T="sortedPlaylistReps";return v?T="resolutionPlusOneRep":_?T="resolutionBestRep":h?T="bandwidthBestRep":u[0]&&(T="enabledPlaylistReps"),$i("choosing "+Ji(b)+" using "+T+" with options",a),b.playlist}return $i("could not choose a playlist with options",a),null}},rn=function(){var e=this.useDevicePixelRatio&&o.default.devicePixelRatio||1;return nn(this.playlists.master,this.systemBandwidth,parseInt(Zi(this.tech_.el(),"width"),10)*e,parseInt(Zi(this.tech_.el(),"height"),10)*e,this.limitRenditionByPlayerDimensions)},an=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);},sn=function(e){return "number"==typeof e&&isFinite(e)},on=1/60,un=function(e){return e+"TimingInfo"},dn=function(e){var t=e.segmentTimeline,i=e.currentTimeline,n=e.startOfSegment,r=e.buffered;return e.overrideCheck||t!==i?ti+R},cn=function(e){function t(t,i){var n;if(n=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 n.bandwidth=t.bandwidth,n.throughput={rate:0,count:0},n.roundTrip=NaN,n.resetStats_(),n.mediaIndex=null,n.hasPlayed_=t.hasPlayed,n.currentTime_=t.currentTime,n.seekable_=t.seekable,n.seeking_=t.seeking,n.duration_=t.duration,n.mediaSource_=t.mediaSource,n.vhs_=t.vhs,n.loaderType_=t.loaderType,n.currentMediaInfo_=void 0,n.startingMediaInfo_=void 0,n.segmentMetadataTrack_=t.segmentMetadataTrack,n.goalBufferLength_=t.goalBufferLength,n.sourceType_=t.sourceType,n.sourceUpdater_=t.sourceUpdater,n.inbandTextTracks_=t.inbandTextTracks,n.state_="INIT",n.handlePartialData_=t.handlePartialData,n.timelineChangeController_=t.timelineChangeController,n.shouldSaveSegmentTimingInfo_=!0,n.parse708captions_=t.parse708captions,n.checkBufferTimeout_=null,n.error_=void 0,n.currentTimeline_=-1,n.pendingSegment_=null,n.xhrOptions_=null,n.pendingSegments_=[],n.audioDisabled_=!1,n.isPendingTimestampOffset_=!1,n.gopBuffer_=[],n.timeMapping_=0,n.safeAppend_=u.default.browser.IE_VERSION>=11,n.appendInitSegment_={audio:!0,video:!0},n.playlistOfLastInitSegment_={audio:null,video:null},n.callQueue_=[],n.loadQueue_=[],n.metadataQueue_={id3:[],caption:[]},n.activeInitSegmentId_=null,n.initSegments_={},n.cacheEncryptionKeys_=t.cacheEncryptionKeys,n.keyCache_={},n.decrypter_=t.decrypter,n.syncController_=t.syncController,n.syncPoint_={segmentIndex:0,time:0},n.transmuxer_=n.createTransmuxer_(),n.triggerSyncInfoUpdate_=function(){return n.trigger("syncinfoupdate")},n.syncController_.on("syncinfoupdate",n.triggerSyncInfoUpdate_),n.mediaSource_.addEventListener("sourceopen",(function(){n.isEndOfStream_()||(n.ended_=!1);})),n.fetchAtBuffer_=!1,n.logger_=ji("SegmentLoader["+n.loaderType_+"]"),Object.defineProperty(d(n),"state",{get:function(){return this.state_},set:function(e){e!==this.state_&&(this.logger_(this.state_+" -> "+e),this.state_=e,this.trigger("statechange"));}}),n.sourceUpdater_.on("ready",(function(){n.hasEnoughInfoToAppend_()&&n.processCallQueue_();})),"main"===n.loaderType_&&n.timelineChangeController_.on("pendingtimelinechange",(function(){n.hasEnoughInfoToAppend_()&&n.processCallQueue_();})),"audio"===n.loaderType_&&n.timelineChangeController_.on("timelinechange",(function(){n.hasEnoughInfoToLoad_()&&n.processLoadQueue_(),n.hasEnoughInfoToAppend_()&&n.processCallQueue_();})),n}l(t,e);var i=t.prototype;return i.createTransmuxer_=function(){var e=new xi;return e.postMessage({action:"init",options:{parse708captions:this.parse708captions_,remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,handlePartialData:this.handlePartialData_}}),e},i.resetStats_=function(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0;},i.dispose=function(){this.trigger("dispose"),this.state="DISPOSED",this.pause(),this.abort_(),this.transmuxer_&&(this.transmuxer_.terminate(),Tt=null,Dt.length=0),this.resetStats_(),this.checkBufferTimeout_&&o.default.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_),this.off();},i.setAudio=function(e){this.audioDisabled_=!e,e?this.appendInitSegment_.audio=!0:this.sourceUpdater_.removeAudio(0,this.duration_());},i.abort=function(){"WAITING"===this.state?(this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()):this.pendingSegment_&&(this.pendingSegment_=null);},i.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_);},i.checkForAbort_=function(e){return "APPENDING"!==this.state||this.pendingSegment_?!this.pendingSegment_||this.pendingSegment_.requestId!==e:(this.state="READY",!0)},i.error=function(e){return void 0!==e&&(this.logger_("error occurred:",e),this.error_=e),this.pendingSegment_=null,this.error_},i.endOfStream=function(){this.ended_=!0,this.transmuxer_&&Ft(this.transmuxer_),this.gopBuffer_.length=0,this.pause(),this.trigger("ended");},i.buffered_=function(){if(!this.sourceUpdater_||!this.startingMediaInfo_)return u.default.createTimeRanges();if("main"===this.loaderType_){var e=this.startingMediaInfo_,t=e.hasAudio,i=e.hasVideo,n=e.isMuxed;if(i&&t&&!this.audioDisabled_&&!n)return this.sourceUpdater_.buffered();if(i)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()},i.initSegmentForMap=function(e,t){if(void 0===t&&(t=!1),!e)return null;var i=ce(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},i.segmentKey=function(e,t){if(void 0===t&&(t=!1),!e)return null;var i=fe(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},i.couldBeginLoading_=function(){return this.playlist_&&!this.paused()},i.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");}},i.init_=function(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()},i.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);}},i.pause=function(){this.checkBufferTimeout_&&(o.default.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null);},i.paused=function(){return null===this.checkBufferTimeout_},i.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"});},i.resetLoader=function(){this.fetchAtBuffer_=!1,this.resyncLoader();},i.resyncLoader=function(){this.transmuxer_&&Ft(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"});},i.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)*Jt),a=Math.ceil((i-n)*Jt),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_)an(e,t,this.inbandTextTracks_[a]);an(e,t,this.segmentMetadataTrack_),r();}},i.monitorBuffer_=function(){this.checkBufferTimeout_&&o.default.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=o.default.setTimeout(this.monitorBufferTick_.bind(this),1);},i.monitorBufferTick_=function(){"READY"===this.state&&this.fillBuffer_(),this.checkBufferTimeout_&&o.default.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=o.default.setTimeout(this.monitorBufferTick_.bind(this),500);},i.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=dn({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));}},i.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},i.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=Z.getMediaInfoForTime(t,s,a.segmentIndex,a.time);d=c.mediaIndex,u=c.startTime;}else {var f=Z.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)},i.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)},i.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)*Jt);for(n=0;nr);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}},i.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=Z.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 !Z.isIncompatible(e)})),d=u.filter(Z.isEnabled);d.length||(d=u.filter((function(e){return !Z.isDisabled(e)})));var l=d.filter(Z.hasAttribute.bind(null,"BANDWIDTH")).map((function(e){var u=o.getSyncPoint(e,n,s,t)?1:2;return {playlist:e,rebufferingImpact:Z.estimateSegmentRequestTime(r,i,e)*u-a}})),h=l.filter((function(e){return e.rebufferingImpact<=0}));return en(h,(function(e,t){return tn(t.playlist,e.playlist)})),h.length?h[0]:(en(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<=R&&(u=1),!s.playlist||s.playlist.uri===this.playlist_.uri||o "+s+" 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,i.vhs_.tech_,e),an(a,s,d[e]),function(e){var t=e.inbandTextTracks,i=e.captionArray,n=e.timestampOffset;if(i){var r=o.default.WebKitDataCue||o.default.VTTCue;i.forEach((function(e){var i=e.stream;t[i].addCue(new r(e.startTime+n,e.endTime+n,e.text));}));}}({captionArray:u,inbandTextTracks:d,timestampOffset:n});})),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");},i.handleId3_=function(e,t,i){if(this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId))if(this.pendingSegment_.hasAppendedData_){var n=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_,i,this.vhs_.tech_),function(e){var t=e.inbandTextTracks,i=e.metadataArray,n=e.timestampOffset,r=e.videoDuration;if(i){var a=o.default.WebKitDataCue||o.default.VTTCue,s=t.metadataTrack_;if(s&&(i.forEach((function(e){var t=e.cueTime+n;!("number"!=typeof t||o.default.isNaN(t)||t<0)&&t<1/0&&e.frames.forEach((function(e){var i=new a(t,t,e.value||e.url||e.data||"");i.frame=e,i.value=e,function(e){Object.defineProperties(e.frame,{id:{get:function(){return u.default.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),e.value.key}},value:{get:function(){return u.default.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),e.value.data}},privateData:{get:function(){return u.default.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),e.value.data}}});}(i),s.addCue(i);}));})),s.cues&&s.cues.length)){for(var d=s.cues,l=[],h=0;h0&&this.remove(0,t);},i.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-1];if(n&&n.timeline===t.timeline&&(n.videoTimingInfo?i.baseStartTime=n.videoTimingInfo.transmuxedDecodeEnd:n.audioTimingInfo&&(i.baseStartTime=n.audioTimingInfo.transmuxedDecodeEnd)),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},i.saveTransferStats_=function(e){this.mediaRequests+=1,e&&(this.mediaBytesTransferred+=e.bytesReceived,this.mediaTransferDuration+=e.roundTripTime);},i.saveBandwidthRelatedStats_=function(e,t){this.pendingSegment_.byteLength=t.bytesReceived,e=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_,Bt("endTimeline",o)),this.trigger("appending"),this.waitForAppendsToComplete_(n);}var o;},i.setTimeMapping_=function(e){var t=this.syncController_.mappingForTimeline(e);null!==t&&(this.timeMapping_=t);},i.updateMediaSecondsLoaded_=function(e){"number"==typeof e.start&&"number"==typeof e.end?this.mediaSecondsLoaded+=e.end-e.start:this.mediaSecondsLoaded+=e.duration;},i.shouldUpdateTransmuxerTimestampOffset_=function(e){return null!==e&&("main"===this.loaderType_&&e!==this.sourceUpdater_.videoTimestampOffset()||!this.audioDisabled_&&e!==this.sourceUpdater_.audioTimestampOffset())},i.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},i.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));},i.checkAppendsDone_=function(e){this.checkForAbort_(e.requestId)||(e.waitingOnAppends--,0===e.waitingOnAppends&&this.handleAppendsDone_());},i.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)},i.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");}},i.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);},i.handleAppendsDone_=function(){if(this.pendingSegment_&&this.trigger("appendsdone"),!this.pendingSegment_)return this.state="READY",void(this.paused()||this.monitorBuffer_());var e=this.pendingSegment_;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));var t=function(e,t){if("hls"!==t)return null;var i,n,r,a,s=(i=e.audioTimingInfo,n=e.videoTimingInfo,r=i&&"number"==typeof i.start&&"number"==typeof i.end?i.end-i.start:0,a=n&&"number"==typeof n.start&&"number"==typeof n.end?n.end-n.start:0,Math.max(r,a));if(!s)return null;var o=e.playlist.targetDuration,u=hn({segmentDuration:s,maxDuration:2*o}),d=hn({segmentDuration:s,maxDuration:o}),l="Segment with index "+e.mediaIndex+" from playlist "+e.playlist.id+" has a duration of "+s+" when the reported duration is "+e.duration+" and the target duration is "+o+". For HLS content, a duration in excess of the target duration may result in playback issues. See the HLS specification section on EXT-X-TARGETDURATION for more details: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.1";return u||d?{severity:u?"warn":"info",message:l}:null}(e,this.sourceType_);if(t&&("warn"===t.severity?u.default.log.warn(t.message):this.logger_(t.message)),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 i=e.segment;i.end&&this.currentTime_()-i.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_());}},i.recordThroughput_=function(e){if(e.duration1&&n.push(t[a]);n.length&&n.forEach((function(t){return e.removeCue(t)}));}}(this.subtitlesTrack_),this.handleAppendsDone_();}else this.state="READY";},i.handleData_=function(){},i.updateTimingInfoEnd_=function(){},i.parseVTTCues_=function(e){var t,i=!1;"function"==typeof o.default.TextDecoder?t=new o.default.TextDecoder("utf8"):(t=o.default.WebVTT.StringDecoder(),i=!0);var n=new o.default.WebVTT.Parser(o.default,o.default.vttjs,t);if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},n.oncue=e.cues.push.bind(e.cues),n.ontimestampmap=function(t){e.timestampmap=t;},n.onparsingerror=function(e){u.default.log.warn("Error encountered when parsing cues: "+e.message);},e.segment.map){var r=e.segment.map.bytes;i&&(r=On(r)),n.parse(r);}var a=e.bytes;i&&(a=On(a)),n.parse(a),n.flush();},i.updateTimeMapping_=function(e,t,i){var n=e.segment;if(t)if(e.cues.length){var r=e.timestampmap,a=r.MPEGTS/Jt-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}(cn),Rn=function(e,t){for(var i=e.cues,n=0;n=r.adStartTime&&t<=r.adEndTime)return r}return null},Mn=[{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=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=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}}],Bn=function(e){function t(t){var i;return (i=e.call(this)||this).timelines=[],i.discontinuities=[],i.datetimeToDisplayTime=null,i.logger_=ji("SyncController"),i}l(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+j(e,n.segmentIndex,0))},i.runStrategies_=function(e,t,i,n){for(var r=[],a=0;a=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;no){var u;u=s<0?i.start-j(t,e.mediaIndex,r):i.end+j(t,e.mediaIndex+1,r),this.discontinuities[a]={time:u,accuracy:o};}}},i.dispose=function(){this.trigger("dispose"),this.off();},t}(u.default.EventTarget),Fn=function(e){function t(){var t;return (t=e.call(this)||this).pendingTimelineChanges_={},t.lastTimelineChanges_={},t}l(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}(u.default.EventTarget),Nn=new Pi("./decrypter-worker.worker.js",(function(e,t){var i=this; -/*! @name @videojs/http-streaming @version 2.5.0 @license Apache-2.0 */!function(){function e(e,t){for(var i=0;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>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],v=y[0],_=y[1],b=y[2],T=y[3],S=y[4];for(d=0;d>>24]^_[c>>16&255]^b[f>>8&255]^T[255&m]^l[g],o=v[c>>>24]^_[f>>16&255]^b[m>>8&255]^T[255&h]^l[g+1],u=v[f>>>24]^_[m>>16&255]^b[h>>8&255]^T[255&c]^l[g+2],m=v[m>>>24]^_[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"):function(){}},y=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-1;t=this.buffer.indexOf("\n"))this.trigger("data",this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1);},t}(y),b=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}l(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;r0&&(s.duration=e.duration),0===e.duration&&(s.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=a;},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:_(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=a,this.manifest.mediaGroups=this.manifest.mediaGroups||u,e.attributes?(s.attributes||(s.attributes={}),v(s.attributes,e.attributes)):this.trigger("warn",{message:"ignoring empty stream-inf attributes"});},media:function(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||u,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"]],(d={default:/yes/i.test(e.attributes.DEFAULT)}).default?d.autoselect=!0:d.autoselect=/yes/i.test(e.attributes.AUTOSELECT),e.attributes.LANGUAGE&&(d.language=e.attributes.LANGUAGE),e.attributes.URI&&(d.uri=e.attributes.URI),e.attributes["INSTREAM-ID"]&&(d.instreamId=e.attributes["INSTREAM-ID"]),e.attributes.CHARACTERISTICS&&(d.characteristics=e.attributes.CHARACTERISTICS),e.attributes.FORCED&&(d.forced=/yes/i.test(e.attributes.FORCED)),t[e.attributes.NAME]=d;}else this.trigger("warn",{message:"ignoring incomplete or missing media group"});},discontinuity:function(){l+=1,s.discontinuity=!0,this.manifest.discontinuityStarts.push(a.length);},"program-date-time":function(){void 0===this.manifest.dateTimeString&&(this.manifest.dateTimeString=e.dateTimeString,this.manifest.dateTimeObject=e.dateTimeObject),s.dateTimeString=e.dateTimeString,s.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(){s.cueOut=e.data;},"cue-out-cont":function(){s.cueOutCont=e.data;},"cue-in":function(){s.cueIn=e.data;}}[e.tagType]||o).call(r);},uri:function(){s.uri=e.uri,a.push(s),this.manifest.targetDuration&&!("duration"in s)&&(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),s.duration=this.manifest.targetDuration),n&&(s.key=n),s.timeline=l,i&&(s.map=i),s={};},comment:function(){},custom:function(){e.segment?(s.custom=s.custom||{},s.custom[e.customType]=e.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[e.customType]=e.data);}})[e.type].call(r);})),t}l(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}(y),w=u.default.log,L=function(e,t){return e+"-"+t},k=function(e){var t=e.onwarn,i=e.oninfo,n=e.manifestString,r=e.customTagParsers,a=void 0===r?[]:r,s=e.customTagMappers,o=void 0===s?[]:s,u=new I;return t&&u.on("warn",t),i&&u.on("info",i),a.forEach((function(e){return u.addParser(e)})),o.forEach((function(e){return u.addTagMapper(e)})),u.push(n),u.end(),u.manifest},A=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);}}));},E=function(e){var t=e.playlist,i=e.uri,n=e.id;t.id=n,i&&(t.uri=i),t.attributes=t.attributes||{};},P=function(e,t){e.uri=t;for(var i=0;i=500?4:2},this.trigger("error");},i.haveMetadata=function(e){var t=this,i=e.playlistString,n=e.playlistObject,r=e.url,a=e.id;this.request=null,this.state="HAVE_METADATA";var s=n||k({onwarn:function(e){var i=e.message;return t.logger_("m3u8-parser warn for "+a+": "+i)},oninfo:function(e){var i=e.message;return t.logger_("m3u8-parser info for "+a+": "+i)},manifestString:i,customTagParsers:this.customTagParsers,customTagMappers:this.customTagMappers});s.lastRequest=Date.now(),E({playlist:s,uri:r,id:a});var u=x(this.master,s);this.targetDuration=s.targetDuration,u?(this.master=u,this.media_=this.master.playlists[a]):this.trigger("playlistunchanged"),this.media().endList||(o.default.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=o.default.setTimeout((function(){t.trigger("mediaupdatetimeout");}),R(this.media(),!!u))),this.trigger("loadedplaylist");},i.dispose=function(){this.trigger("dispose"),this.stopRequest(),o.default.clearTimeout(this.mediaUpdateTimeout),o.default.clearTimeout(this.finalRenditionTimeout),this.off();},i.stopRequest=function(){if(this.request){var e=this.request;this.request=null,e.onreadystatechange=null,e.abort();}},i.media=function(e,t){var i=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(o.default.clearTimeout(this.finalRenditionTimeout),t){var n=e.targetDuration/2*1e3||5e3;this.finalRenditionTimeout=o.default.setTimeout(this.media.bind(this,e,!1),n);}else {var r=this.state,a=!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(a&&(this.trigger("mediachanging"),"HAVE_MASTER"===r?this.trigger("loadedmetadata"):this.trigger("mediachange")));if(a){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,n){if(i.request){if(e.lastRequest=Date.now(),e.resolvedUri=p(i.handleManifestRedirects,e.resolvedUri,n),t)return i.playlistRequestError(i.request,e,r);i.haveMetadata({playlistString:n.responseText,url:e.uri,id:e.id}),"HAVE_MASTER"===r?i.trigger("loadedmetadata"):i.trigger("mediachange");}}));}}},i.pause=function(){this.stopRequest(),o.default.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");},i.load=function(e){var t=this;o.default.clearTimeout(this.mediaUpdateTimeout);var i=this.media();if(e){var n=i?i.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=o.default.setTimeout((function(){return t.load()}),n);}else this.started?i&&!i.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist"):this.start();},i.start=function(){var e=this;if(this.started=!0,"object"==typeof this.src)return this.src.uri||(this.src.uri=o.default.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=p(e.handleManifestRedirects,e.src,i);var n=k({manifestString:i.responseText,customTagParsers:e.customTagParsers,customTagMappers:e.customTagMappers});e.setupInitialPlaylist(n);}}));},i.srcUri=function(){return "string"==typeof this.src?this.src:this.src.uri},i.setupInitialPlaylist=function(e){if(this.state="HAVE_MASTER",e.playlists)return this.master=e,P(this.master,this.srcUri()),e.playlists.forEach((function(e){e.segments&&e.segments.forEach((function(t){U(t,e.resolvedUri);}));})),this.trigger("loadedplaylist"),void(this.request||this.media(this.master.playlists[0]));var t=this.srcUri()||o.default.location.href;this.master=function(e,t){var i=L(0,t),n={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:o.default.location.href,resolvedUri:o.default.location.href,playlists:[{uri:t,id:i,resolvedUri:t,attributes:{}}]};return n.playlists[i]=n.playlists[0],n.playlists[t]=n.playlists[0],n}(0,t),this.haveMetadata({playlistObject:e,url:t,id:this.master.playlists[0].id}),this.trigger("loadedmetadata");},t}(C),B=1/30,F=.1,N=function(e,t){var i,n=[];if(e&&e.length)for(i=0;i=t}))},W=function(e,t){return N(e,(function(e){return e-B>=t}))},V=function(e){var t=[];if(!e||!e.length)return "";for(var i=0;i "+e.end(i));return t.join(", ")},H=function(e){for(var t=[],i=0;ii){var r=[i,t];t=r[0],i=r[1];}if(t<0){for(var a=t;a=r););return Math.max(0,i)},Y=function(e,t,i,n){if(!e||!e.segments)return null;if(e.endList)return z(e);if(null===t)return null;t=t||0;var r=i?Q(e,n):e.segments.length;return j(e,e.mediaSequence+r,t)},K=function(e){return e.excludeUntil&&e.excludeUntil>Date.now()},$=function(e){return e.excludeUntil&&e.excludeUntil===1/0},J=function(e){var t=K(e);return !e.disabled&&!t},Z=function(e,t){return t.attributes&&t.attributes[e]},ee=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 !!J(e)&&(e.attributes.BANDWIDTH||0)0)for(r=i-1;r>=0;r--)if((s+=e.segments[r].duration+B)>0)return {mediaIndex:r,startTime:n-X(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=32&&e<126?String.fromCharCode(e):"."},fe=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},me=function(e){var t=e.byterange||{length:1/0,offset:0};return [t.length,t.offset,e.resolvedUri].join(",")},pe=function(e){return e.resolvedUri},ge=function(e){for(var t=Array.prototype.slice.call(e),i=16,n="",r=0;rnew Date(o.getTime()+1e3*u)?null:(i>o&&(n=s),{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:te.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);},_e=function(e){return !!e&&"object"==typeof e},Te=function e(){for(var t=arguments.length,i=new Array(t),n=0;np&&(p=T);var b=void 0;if(_<0){var S=g+1;b=S===t.length?"dynamic"===n&&a>0&&o.indexOf("$Number$")>0?De(e,p,v):(u*l-p)/v:(t[S].t-p)/v;}else b=_+1;for(var I=c+m.length+b,w=c+m.length;w=r?a:""+new Array(r-a.length+1).join("0")+a)}}(t))},Be=function(e,t){var i={RepresentationID:e.id,Bandwidth:e.bandwidth||0},n=e.initialization,r=void 0===n?{sourceURL:"",range:""}:n,a=Ie({baseUrl:e.baseUrl,source:Me(r.sourceURL,i),range:r.range});return function(e,t){return e.duration||t?e.duration?Le(e):xe(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=Me(e.media||"",i);return {uri:n,timeline:t.timeline,duration:t.duration,resolvedUri:f(e.baseUrl||"",n),map:a,number:t.number}}))},Fe=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=Ie({baseUrl:i,source:r.sourceURL,range:r.range}),s=Ie({baseUrl:i,source:t.media,range:t.mediaRange});return s.map=a,s}(e,t)}));return i&&(a=Le(e)),t&&(a=xe(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}))},Ne=function(e){var t,i,n=e.attributes,r=e.segmentInfo;r.template?(i=Be,t=Te(n,r.template)):r.base?(i=ke,t=Te(n,r.base)):r.list&&(i=Fe,t=Te(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},qe=function(e,t){return Se(e.childNodes).filter((function(e){return e.tagName===t}))},We=function(e){return e.textContent.trim()},Ve=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)},He={mediaPresentationDuration:function(e){return Ve(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 Ve(e)},suggestedPresentationDelay:function(e){return Ve(e)},type:function(e){return e},timeShiftBufferDepth:function(e){return Ve(e)},start:function(e){return Ve(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)?Ve(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}},Ge=function(e){return e&&e.attributes?Se(e.attributes).reduce((function(e,t){var i=He[t.name]||He.DEFAULT;return e[t.name]=i(t.value),e}),{}):{}},je={"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"},ze=function(e,t){return t.length?be(e.map((function(e){return t.map((function(t){return f(e,We(t))}))}))):e},Xe=function(e){var t=qe(e,"SegmentTemplate")[0],i=qe(e,"SegmentList")[0],n=i&&qe(i,"SegmentURL").map((function(e){return Te({tag:"SegmentURL"},Ge(e))})),r=qe(e,"SegmentBase")[0],a=i||t,s=a&&qe(a,"SegmentTimeline")[0],o=i||r||t,u=o&&qe(o,"Initialization")[0],d=t&&Ge(t);d&&u?d.initialization=u&&Ge(u):d&&d.initialization&&(d.initialization={sourceURL:d.initialization});var l={template:d,timeline:s&&qe(s,"S").map((function(e){return Ge(e)})),list:i&&Te(Ge(i),{segmentUrls:n,initialization:Ge(u)}),base:r&&Te(Ge(r),{initialization:Ge(u)})};return Object.keys(l).forEach((function(e){l[e]||delete l[e];})),l},Qe=function(e,t){return function(i,n){var r=ze(t,qe(i,"BaseURL")),a=Ge(i),s=parseInt(a.id,10),u=o.default.isNaN(s)?n:s,d=Te(e,{periodIndex:u}),l=qe(i,"AdaptationSet"),h=Xe(i);return be(l.map(function(e,t,i){return function(n){var r=Ge(n),a=ze(t,qe(n,"BaseURL")),s=qe(n,"Role")[0],o={role:Ge(s)},u=Te(e,r,o),d=qe(n,"ContentProtection").reduce((function(e,t){var i=Ge(t),n=je[i.schemeIdUri];if(n){e[n]={attributes:i};var r=qe(t,"cenc:pssh")[0];if(r){var a=We(r),s=a&&_(a);e[n].pssh=s;}}return e}),{});Object.keys(d).length&&(u=Te(u,{contentProtection:d}));var l=Xe(n),h=qe(n,"Representation"),c=Te(i,l);return be(h.map(function(e,t,i){return function(n){var r=qe(n,"BaseURL"),a=ze(t,r),s=Te(e,Ge(n)),o=Xe(n);return a.map((function(e){return {segmentInfo:Te(i,o),attributes:Te(s,{baseUrl:e})}}))}}(u,a,c)))}}(d,r,h)))}},Ye=function(e){if(""===e)throw new Error("DASH_EMPTY_MANIFEST");var t,i,n=new r.DOMParser;try{i=(t=n.parseFromString(e,"application/xml"))&&"MPD"===t.documentElement.tagName?t.documentElement:null;}catch(e){}if(!i||i&&i.getElementsByTagName("parsererror").length>0)throw new Error("DASH_INVALID_XML");return i},Ke=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=qe(e,"Period");if(!d.length)throw new Error("INVALID_NUMBER_OF_PERIOD");var l=qe(e,"Location"),h=Ge(e),c=ze([r],qe(e,"BaseURL"));return h.sourceDuration=h.mediaPresentationDuration||0,h.NOW=s,h.clientOffset=u,l.length&&(h.locations=l.map(We)),{locations:h.locations,representationInfo:be(d.map(Qe(h,c)))}}(Ye(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=Ee(e.filter((function(e){var t=e.attributes;return "video/mp4"===t.mimeType||"video/webm"===t.mimeType||"video"===t.contentType}))).map(Ue),h=Ee(e.filter((function(e){var t=e.attributes;return "audio/mp4"===t.mimeType||"audio/webm"===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:Pe(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:Pe([Oe(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:Pe([Ce(i)],t),uri:""}),e}),{})}(c,i)),f}(i.representationInfo.map(Ne),i.locations,t.sidxMapping)},$e=Ae,Je=Math.pow(2,32),Ze=function(e){return e instanceof Uint8Array?e:(Array.isArray(e)||(t=e,ArrayBuffer.isView(t))||e instanceof ArrayBuffer||(e="number"!=typeof e||"number"==typeof e&&e!=e?0:[e]),new Uint8Array(e&&e.buffer||e,e&&e.byteOffset||0,e&&e.byteLength||0));var t;},et=o.default.BigInt||Number,tt=[et("0x1"),et("0x100"),et("0x10000"),et("0x1000000"),et("0x100000000"),et("0x10000000000"),et("0x1000000000000"),et("0x100000000000000"),et("0x10000000000000000")],it=function(e,t){var i=void 0===t?{}:t,n=i.signed,r=void 0!==n&&n,a=i.le,s=void 0!==a&&a;e=Ze(e);var o=s?"reduce":"reduceRight",u=(e[o]?e[o]:Array.prototype[o]).call(e,(function(t,i,n){var r=s?n:Math.abs(n+1-e.length);return t+et(i)*tt[r]}),et(0));if(r){var d=tt[e.length]/et(2)-et(1);(u=et(u))>d&&(u-=d,u-=d,u-=et(2));}return Number(u)},nt=function(e,t){if("string"!=typeof e&&e&&"function"==typeof e.toString&&(e=e.toString()),"string"!=typeof e)return new Uint8Array;t||(e=unescape(encodeURIComponent(e)));for(var i=new Uint8Array(e.length),n=0;n=t.length&&u.call(t,(function(t,i){return t===(o[i]?o[i]&e[a+i]:e[a+i])}))},at=Ze([73,68,51]),st=function e(t,i){return void 0===i&&(i=0),(t=Ze(t)).length-i<10||!rt(t,at,{offset:i})?i:(i+=function(e,t){void 0===t&&(t=0);var i=(e=Ze(e))[t+5],n=e[t+6]<<21|e[t+7]<<14|e[t+8]<<7|e[t+9];return (16&i)>>4?n+20:n+10}(t,i),e(t,i))},ot=function(e){return "string"==typeof e?nt(e):e},ut=function e(t,i,n){void 0===n&&(n=!1),i=function(e){return Array.isArray(e)?e.map((function(e){return ot(e)})):[ot(e)]}(i),t=Ze(t);var r=[];if(!i.length)return r;for(var a=0;a>>0,o=t.subarray(a+4,a+8);if(0===s)break;var u=a+s;if(u>t.length){if(n)break;u=t.length;}var d=t.subarray(a+8,u);rt(o,i[0])&&(1===i.length?r.push(d):r.push.apply(r,e(d,i.slice(1),n))),a=u;}return r},dt={EBML:Ze([26,69,223,163]),DocType:Ze([66,130]),Segment:Ze([24,83,128,103]),SegmentInfo:Ze([21,73,169,102]),Tracks:Ze([22,84,174,107]),Track:Ze([174]),TrackNumber:Ze([215]),DefaultDuration:Ze([35,227,131]),TrackEntry:Ze([174]),TrackType:Ze([131]),FlagDefault:Ze([136]),CodecID:Ze([134]),CodecPrivate:Ze([99,162]),VideoTrack:Ze([224]),AudioTrack:Ze([225]),Cluster:Ze([31,67,182,117]),Timestamp:Ze([231]),TimestampScale:Ze([42,215,177]),BlockGroup:Ze([160]),BlockDuration:Ze([155]),Block:Ze([161]),SimpleBlock:Ze([163])},lt=[128,64,32,16,8,4,2,1],ht=function(e,t,i,n){void 0===i&&(i=!0),void 0===n&&(n=!1);var r=function(e){for(var t=1,i=0;i=i.length)return i.length;var r=ht(i,n,!1);if(rt(t.bytes,r.bytes))return n;var a=ht(i,n+r.length);return e(t,i,n+a.length+a.value+r.length)},mt=function e(t,i){i=function(e){return Array.isArray(e)?e.map((function(e){return ct(e)})):[ct(e)]}(i),t=Ze(t);var n=[];if(!i.length)return n;for(var r=0;rt.length?t.length:o+s.value,d=t.subarray(o,u);rt(i[0],a.bytes)&&(1===i.length?n.push(d):n=n.concat(e(d,i.slice(1)))),r+=a.length+s.length+d.length;}return n},pt=Ze([0,0,0,1]),gt=Ze([0,0,1]),yt=Ze([0,0,3]),vt=function(e){for(var t=[],i=1;i>1&63),-1!==i.indexOf(u)&&(r=a+o),a+=o+("h264"===t?1:2);}else a++;}return e.subarray(0,0)},Tt={webm:Ze([119,101,98,109]),matroska:Ze([109,97,116,114,111,115,107,97]),flac:Ze([102,76,97,67]),ogg:Ze([79,103,103,83]),ac3:Ze([11,119]),riff:Ze([82,73,70,70]),avi:Ze([65,86,73]),wav:Ze([87,65,86,69]),"3gp":Ze([102,116,121,112,51,103]),mp4:Ze([102,116,121,112]),fmp4:Ze([115,116,121,112]),mov:Ze([102,116,121,112,113,116])},bt={aac:function(e){var t=st(e);return rt(e,[255,16],{offset:t,mask:[255,22]})},mp3:function(e){var t=st(e);return rt(e,[255,2],{offset:t,mask:[255,6]})},webm:function(e){var t=mt(e,[dt.EBML,dt.DocType])[0];return rt(t,Tt.webm)},mkv:function(e){var t=mt(e,[dt.EBML,dt.DocType])[0];return rt(t,Tt.matroska)},mp4:function(e){return !bt["3gp"](e)&&!bt.mov(e)&&(rt(e,Tt.mp4,{offset:4})||rt(e,Tt.fmp4,{offset:4}))},mov:function(e){return rt(e,Tt.mov,{offset:4})},"3gp":function(e){return rt(e,Tt["3gp"],{offset:4})},ac3:function(e){var t=st(e);return rt(e,Tt.ac3,{offset:t})},ts:function(e){if(e.length<189&&e.length>=1)return 71===e[0];for(var t=0;t+1880},kt=function(e,t){if(4===e.readyState)return t()},At=u.default.EventTarget,Et=u.default.mergeOptions,Pt=function(e,t){if(!D(e,t))return !1;if(e.sidx&&t.sidx&&(e.sidx.offset!==t.sidx.offset||e.sidx.length!==t.sidx.length))return !1;if(!e.sidx&&t.sidx||e.sidx&&!t.sidx)return !1;if(e.segments&&!t.segments||!e.segments&&t.segments)return !1;if(!e.segments&&!t.segments)return !0;for(var i=0;i0;n+=12,r--)i.references.push({referenceType:(128&e[n])>>>7,referencedSize:2147483647&t.getUint32(n),subsegmentDuration:t.getUint32(n+4),startsWithSap:!!(128&e[n+8]),sapType:(112&e[n+8])>>>4,sapDeltaTime:268435455&t.getUint32(n+8)});return i}(Ze(o.response).subarray(8));return s[r].sidx=u,$e(e,u,e.sidx.resolvedUri),i(!0)}};this.request=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=function(){for(var e=arguments.length,t=new Array(e),i=0;i=l+d)return u(t,{response:s.subarray(d,d+l),status:i.status,uri:i.uri});n.request=n.vhs_.xhr({uri:a,responseType:"arraybuffer",headers:se({byterange:e.sidx.byterange})},u);}));}else this.mediaRequest_=o.default.setTimeout((function(){return i(!1)}),0);},i.dispose=function(){this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},o.default.clearTimeout(this.minimumUpdatePeriodTimeout_),o.default.clearTimeout(this.mediaRequest_),o.default.clearTimeout(this.mediaUpdateTimeout),this.off();},i.hasPendingRequest=function(){return this.request||this.mediaRequest_},i.stopRequest=function(){if(this.request){var e=this.request;this.request=null,e.onreadystatechange=null,e.abort();}},i.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 i=this.state;if("string"==typeof e){if(!this.masterPlaylistLoader_.master.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.masterPlaylistLoader_.master.playlists[e];}var n=!this.media_||e.id!==this.media_.id;if(n&&this.loadedPlaylists_[e.id]&&this.loadedPlaylists_[e.id].endList)return this.state="HAVE_METADATA",this.media_=e,void(n&&(this.trigger("mediachanging"),this.trigger("mediachange")));n&&(this.media_&&this.trigger("mediachanging"),this.addSidxSegments_(e,i,(function(n){t.haveMetadata({startingState:i,playlist:e});})));},i.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");},i.pause=function(){this.stopRequest(),o.default.clearTimeout(this.mediaUpdateTimeout),o.default.clearTimeout(this.minimumUpdatePeriodTimeout_),"HAVE_NOTHING"===this.state&&(this.started=!1);},i.load=function(e){var t=this;o.default.clearTimeout(this.mediaUpdateTimeout),o.default.clearTimeout(this.minimumUpdatePeriodTimeout_);var i=this.media();if(e){var n=i?i.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=o.default.setTimeout((function(){return t.load()}),n);}else this.started?i&&!i.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist"):this.start();},i.start=function(){var e=this;this.started=!0,this.isMaster_?this.requestMaster_((function(t,i){e.haveMaster_(),e.hasPendingRequest()||e.media_||e.media(e.masterPlaylistLoader_.master.playlists[0]);})):this.mediaRequest_=o.default.setTimeout((function(){return e.haveMaster_()}),0);},i.requestMaster_=function(e){var t=this;this.request=this.vhs_.xhr({uri:this.masterPlaylistLoader_.srcUrl,withCredentials:this.withCredentials},(function(i,n){if(!t.requestErrored_(i,n)){var r=n.responseText!==t.masterPlaylistLoader_.masterXml_;return t.masterPlaylistLoader_.masterXml_=n.responseText,n.responseHeaders&&n.responseHeaders.date?t.masterLoaded_=Date.parse(n.responseHeaders.date):t.masterLoaded_=Date.now(),t.masterPlaylistLoader_.srcUrl=p(t.handleManifestRedirects,t.masterPlaylistLoader_.srcUrl,n),r?(t.handleMaster_(),void t.syncClientServerClock_((function(){return e(n,r)}))):e(n,r)}"HAVE_NOTHING"===t.state&&(t.started=!1);}));},i.syncClientServerClock_=function(e){var t,i=this,n=(t=this.masterPlaylistLoader_.masterXml_,function(e){var t=qe(e,"UTCTiming")[0];if(!t)return null;var i=Ge(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}(Ye(t)));return null===n?(this.masterPlaylistLoader_.clientOffset_=this.masterLoaded_-Date.now(),e()):"DIRECT"===n.method?(this.masterPlaylistLoader_.clientOffset_=n.value-Date.now(),e()):void(this.request=this.vhs_.xhr({uri:m(this.masterPlaylistLoader_.srcUrl,n.value),method:n.method,withCredentials:this.withCredentials},(function(t,r){if(i.request){if(t)return i.masterPlaylistLoader_.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.masterPlaylistLoader_.clientOffset_=a-Date.now(),e();}})))},i.haveMaster_=function(){this.state="HAVE_MASTER",this.isMaster_?this.trigger("loadedplaylist"):this.media_||this.media(this.childPlaylist_);},i.handleMaster_=function(){this.mediaRequest_=null;var e,t,i,n=(e={masterXml:this.masterPlaylistLoader_.masterXml_,srcUrl:this.masterPlaylistLoader_.srcUrl,clientOffset:this.masterPlaylistLoader_.clientOffset_,sidxMapping:this.masterPlaylistLoader_.sidxMapping_},i=Ke(e.masterXml,{manifestUri:t=e.srcUrl,clientOffset:e.clientOffset,sidxMapping:e.sidxMapping}),P(i,t),i),r=this.masterPlaylistLoader_.master;r&&(n=function(e,t,i){for(var n=!0,r=Et(e,{duration:t.duration,minimumUpdatePeriod:t.minimumUpdatePeriod}),a=0;a0?t(i):0===i&&(this.media()?t(1e3*this.media().targetDuration):this.one("loadedplaylist",(function(){t(1e3*e.media().targetDuration);})));},i.refreshXml_=function(){var e=this;this.requestMaster_((function(t,i){var n,r,a;i&&(e.media_&&(e.media_=e.masterPlaylistLoader_.master.playlists[e.media_.id]),e.masterPlaylistLoader_.sidxMapping_=(n=e.masterPlaylistLoader_.master,r=e.masterPlaylistLoader_.sidxMapping_,a=Ct(n.playlists,r),A(n,(function(e,t,i,n){if(e.playlists&&e.playlists.length){var s=e.playlists;a=Et(a,Ct(s,r));}})),a),e.addSidxSegments_(e.media(),e.state,(function(t){e.refreshMedia_(e.media().id);})));}));},i.refreshMedia_=function(e){var t=this;if(!e)throw new Error("refreshMedia_ must take a media id");this.media_&&this.isMaster_&&this.handleMaster_();var i=this.masterPlaylistLoader_.master.playlists,n=!this.media_||this.media_!==i[e];n?this.media_=i[e]:this.trigger("playlistunchanged"),this.media().endList||(this.mediaUpdateTimeout=o.default.setTimeout((function(){t.trigger("mediaupdatetimeout");}),R(this.media(),Boolean(n)))),this.trigger("loadedplaylist");},t}(At),Dt={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},xt=function(e){for(var t=new Uint8Array(new ArrayBuffer(e.length)),i=0;i-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>>1,e.samplingfrequencyindex<<7|e.channelcount<<3,6,1,2]))},p=function(e){return t(S.hdlr,E[e])},m=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(S.mdhd,i)},f=function(e){return t(S.mdia,m(e),p(e.type),s(e))},a=function(e){return t(S.mfhd,new Uint8Array([0,0,0,0,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e]))},s=function(e){return t(S.minf,"video"===e.type?t(S.vmhd,P):t(S.smhd,O),i(),y(e))},o=function(e,i){for(var n=[],r=i.length;r--;)n[r]=_(i[r]);return t.apply(null,[S.moof,a(e)].concat(n))},u=function(e){for(var i=e.length,n=[];i--;)n[i]=h(e[i]);return t.apply(null,[S.moov,l(4294967295)].concat(n).concat(d(e)))},d=function(e){for(var i=e.length,n=[];i--;)n[i]=T(e[i]);return t.apply(null,[S.mvex].concat(n))},l=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(S.mvhd,i)},g=function(e){var i,n,r=e.samples||[],a=new Uint8Array(4+r.length);for(n=0;n>>8),s.push(255&r[i].byteLength),s=s.concat(Array.prototype.slice.call(r[i]));for(i=0;i>>8),o.push(255&a[i].byteLength),o=o.concat(Array.prototype.slice.call(a[i]));if(n=[S.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(S.avcC,new Uint8Array([1,e.profileIdc,e.profileCompatibility,e.levelIdc,255].concat([r.length],s,[a.length],o))),t(S.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(S.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)},B=function(e){return t(S.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]),n(e))},c=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(S.tkhd,i)},_=function(e){var i,n,r,a,s,o;return i=t(S.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/(V+1)),o=Math.floor(e.baseMediaDecodeTime%(V+1)),n=t(S.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=b(e,92),t(S.traf,i,n,r)):(a=g(e),r=b(e,a.length+92),t(S.traf,i,n,r,a))},h=function(e){return e.duration=e.duration||4294967295,t(S.trak,c(e),f(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(S.trex,i)},q=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]},N=function(e,i){var n,r,a,s,o,u;for(i+=20+16*(s=e.samples||[]).length,a=q(s,i),(r=new Uint8Array(a.length+16*s.length)).set(a),n=a.length,u=0;u>>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(S.trun,r)},F=function(e,i){var n,r,a,s,o,u;for(i+=20+8*(s=e.samples||[]).length,a=q(s,i),(n=new Uint8Array(a.length+8*s.length)).set(a),r=a.length,u=0;u>>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(S.trun,n)},b=function(e,t){return "audio"===e.type?F(e,t):N(e,t)},r=function(){return t(S.ftyp,I,w,I,L)};var H,G,j,z,X,Q,Y,K,$=function(e){return t(S.mdat,e)},J=o,Z=function(e){var t,i=r(),n=u(e);return (t=new Uint8Array(i.byteLength+n.byteLength)).set(i),t.set(n,i.byteLength),t},ee=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},te=function(e){var t,i,n=[],r=[];for(r.byteLength=0,r.nalCount=0,r.duration=0,n.byteLength=0,t=0;t1&&(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},re=function(e,t){var i,n=[];return i=ee(e,t||0),n.push(i),n},ae=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;t45e3))){for((s=function(){if(!H){var e={96e3:[se,[227,64],ue(154),[56]],88200:[se,[231],ue(170),[56]],64e3:[se,[248,192],ue(240),[56]],48e3:[se,[255,192],ue(268),[55,148,128],ue(54),[112]],44100:[se,[255,192],ue(268),[55,163,128],ue(84),[112]],32e3:[se,[255,192],ue(268),[55,234],ue(226),[112]],24e3:[se,[255,192],ue(268),[55,255,128],ue(268),[111,112],ue(126),[224]],16e3:[se,[255,192],ue(268),[55,255,128],ue(268),[111,255],ue(269),[223,108],ue(195),[1,192]],12e3:[oe,ue(268),[3,127,248],ue(268),[6,255,240],ue(268),[13,255,224],ue(268),[27,253,128],ue(259),[56]],11025:[oe,ue(268),[3,127,248],ue(268),[6,255,240],ue(268),[13,255,224],ue(268),[27,255,192],ue(268),[55,175,128],ue(108),[112]],8e3:[oe,ue(268),[3,121,16],ue(47),[7]]};t=e,H=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 H}()[e.samplerate])||(s=t[0].data),o=0;o=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)})))},ve=function(e){var t,i,n=[];for(t=0;t=this.virtualRowCount&&"function"==typeof this.beforeRowOverflow&&this.beforeRowOverflow(e),this.rows.length>0&&(this.rows.push(""),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--;},ke.prototype.isEmpty=function(){return 0===this.rows.length||1===this.rows.length&&""===this.rows[0]},ke.prototype.addText=function(e){this.rows[this.rowIdx]+=e;},ke.prototype.backspace=function(){if(!this.isEmpty()){var e=this.rows[this.rowIdx];this.rows[this.rowIdx]=e.substr(0,e.length-1);}};var Ae=function(e){this.serviceNum=e,this.text="",this.currentWindow=new ke(-1),this.windows=[];};Ae.prototype.init=function(e,t){this.startPts=e;for(var i=0;i<8;i++)this.windows[i]=new ke(i),"function"==typeof t&&(this.windows[i].beforeRowOverflow=t);},Ae.prototype.setCurrentWindow=function(e){this.currentWindow=this.windows[e];};var Ee=function e(){e.prototype.init.call(this);var t=this;this.current708Packet=null,this.services={},this.push=function(e){3===e.type?(t.new708Packet(),t.add708Bytes(e)):(null===t.current708Packet&&t.new708Packet(),t.add708Bytes(e));};};Ee.prototype=new W,Ee.prototype.new708Packet=function(){null!==this.current708Packet&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]};},Ee.prototype.add708Bytes=function(e){var t=e.ccData,i=t>>>8,n=255&t;this.current708Packet.ptsVals.push(e.pts),this.current708Packet.data.push(i),this.current708Packet.data.push(n);},Ee.prototype.push708Packet=function(){var e=this.current708Packet,t=e.data,i=null,n=null,r=0,a=t[r++];for(e.seq=a>>6,e.sizeCode=63&a;r>5)&&n>0&&(i=a=t[r++]),this.pushServiceBlock(i,r,n),n>0&&(r+=n-1);},Ee.prototype.pushServiceBlock=function(e,t,i){var n,r=t,a=this.current708Packet.data,s=this.services[e];for(s||(s=this.initService(e,r));r>5,a.rowLock=(16&n)>>4,a.columnLock=(8&n)>>3,a.priority=7&n,n=i[++e],a.relativePositioning=(128&n)>>7,a.anchorVertical=127&n,n=i[++e],a.anchorHorizontal=n,n=i[++e],a.anchorPoint=(240&n)>>4,a.rowCount=15&n,n=i[++e],a.columnCount=63&n,n=i[++e],a.windowStyle=(56&n)>>3,a.penStyle=7&n,a.virtualRowCount=a.rowCount+1,e},Ee.prototype.setWindowAttributes=function(e,t){var i=this.current708Packet.data,n=i[e],r=t.currentWindow.winAttr;return n=i[++e],r.fillOpacity=(192&n)>>6,r.fillRed=(48&n)>>4,r.fillGreen=(12&n)>>2,r.fillBlue=3&n,n=i[++e],r.borderType=(192&n)>>6,r.borderRed=(48&n)>>4,r.borderGreen=(12&n)>>2,r.borderBlue=3&n,n=i[++e],r.borderType+=(128&n)>>5,r.wordWrap=(64&n)>>6,r.printDirection=(48&n)>>4,r.scrollDirection=(12&n)>>2,r.justify=3&n,n=i[++e],r.effectSpeed=(240&n)>>4,r.effectDirection=(12&n)>>2,r.displayEffect=3&n,e},Ee.prototype.flushDisplayed=function(e,t){for(var i=[],n=0;n<8;n++)t.windows[n].visible&&!t.windows[n].isEmpty()&&i.push(t.windows[n].getText());t.endPts=e,t.text=i.join("\n\n"),this.pushCaption(t),t.startPts=e;},Ee.prototype.pushCaption=function(e){""!==e.text&&(this.trigger("data",{startPts:e.startPts,endPts:e.endPts,text:e.text,stream:"cc708_"+e.serviceNum}),e.text="",e.startPts=e.endPts);},Ee.prototype.displayWindows=function(e,t){var i=this.current708Packet.data[++e],n=this.getPts(e);this.flushDisplayed(n,t);for(var r=0;r<8;r++)i&1<>4,r.offset=(12&n)>>2,r.penSize=3&n,n=i[++e],r.italics=(128&n)>>7,r.underline=(64&n)>>6,r.edgeType=(56&n)>>3,r.fontStyle=7&n,e},Ee.prototype.setPenColor=function(e,t){var i=this.current708Packet.data,n=i[e],r=t.currentWindow.penColor;return n=i[++e],r.fgOpacity=(192&n)>>6,r.fgRed=(48&n)>>4,r.fgGreen=(12&n)>>2,r.fgBlue=3&n,n=i[++e],r.bgOpacity=(192&n)>>6,r.bgRed=(48&n)>>4,r.bgGreen=(12&n)>>2,r.bgBlue=3&n,n=i[++e],r.edgeRed=(48&n)>>4,r.edgeGreen=(12&n)>>2,r.edgeBlue=3&n,e},Ee.prototype.setPenLocation=function(e,t){var i=this.current708Packet.data,n=i[e],r=t.currentWindow.penLoc;return t.currentWindow.pendingNewLine=!0,n=i[++e],r.row=15&n,n=i[++e],r.column=63&n,e},Ee.prototype.reset=function(e,t){var i=this.getPts(e);return this.flushDisplayed(i,t),this.initService(t.serviceNum,e)};var Pe={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},Oe=function(e){return null===e?"":(e=Pe[e]||e,String.fromCharCode(e))},Ce=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],Ue=function(){for(var e=[],t=15;t--;)e.push("");return e},De=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_=Ue();else if(t===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Ue();else if(t===this.RESUME_DIRECT_CAPTIONING_)"paintOn"!==this.mode_&&(this.flushDisplayed(e.pts),this.displayed_=Ue()),this.mode_="paintOn",this.startPts_=e.pts;else if(this.isSpecialCharacter(n,r))a=Oe((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=Oe((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=Ce.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=Oe(n),a+=Oe(r),this[this.mode_](e.pts,a),this.column_+=a.length);}else this.lastControlCode_=null;};};De.prototype=new W,De.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_});},De.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=Ue(),this.nonDisplayed_=Ue(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.rollUpRows_=2,this.formatting_=[];},De.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_;},De.prototype.isSpecialCharacter=function(e,t){return e===this.EXT_&&t>=48&&t<=63},De.prototype.isExtCharacter=function(e,t){return (e===this.EXT_+1||e===this.EXT_+2)&&t>=32&&t<=63},De.prototype.isMidRowCode=function(e,t){return e===this.EXT_&&t>=32&&t<=47},De.prototype.isOffsetControlCode=function(e,t){return e===this.OFFSET_&&t>=33&&t<=35},De.prototype.isPAC=function(e,t){return e>=this.BASE_&&e=64&&t<=127},De.prototype.isColorPAC=function(e){return e>=64&&e<=79||e>=96&&e<=127},De.prototype.isNormalChar=function(e){return e>=32&&e<=127},De.prototype.setRollUp=function(e,t){if("rollUp"!==this.mode_&&(this.row_=14,this.mode_="rollUp",this.flushDisplayed(e),this.nonDisplayed_=Ue(),this.displayed_=Ue()),void 0!==t&&t!==this.row_)for(var i=0;i"}),"");this[this.mode_](e,i);},De.prototype.clearFormatting=function(e){if(this.formatting_.length){var t=this.formatting_.reverse().reduce((function(e,t){return e+""}),"");this.formatting_=[],this[this.mode_](e,t);}},De.prototype.popOn=function(e,t){var i=this.nonDisplayed_[this.row_];i+=t,this.nonDisplayed_[this.row_]=i;},De.prototype.rollUp=function(e,t){var i=this.displayed_[this.row_];i+=t,this.displayed_[this.row_]=i;},De.prototype.shiftRowsUp_=function(){var e;for(e=0;et&&(i=-1);Math.abs(t-e)>4294967296;)e+=8589934592*i;return e},Fe=function e(t){var i,n;e.prototype.init.call(this),this.type_=t||Me,this.push=function(e){this.type_!==Me&&e.type!==this.type_||(void 0===n&&(n=e.dts),e.dts=Be(e.dts,n),e.pts=Be(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");};};Fe.prototype=new W;var Ne,qe=Fe,We=function(e,t,i){var n,r="";for(n=t;n>>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>>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=Re.H264_STREAM_TYPE:i.pid===this.programMapTable.audio?i.streamType=Re.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,ze.STREAM_TYPES={h264:27,adts:15},(Xe=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>>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);}};Xe.prototype.init.call(this),this.push=function(s){({pat:function(){},pes:function(){var e,t;switch(s.streamType){case Re.H264_STREAM_TYPE:e=i,t="video";break;case Re.ADTS_STREAM_TYPE:e=n,t="audio";break;case Re.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 $e={PAT_PID:0,MP2T_PACKET_LENGTH:Ke,TransportPacketStream:je,TransportParseStream:ze,ElementaryStream:Xe,TimestampRolloverStream:Ye,CaptionStream:xe.CaptionStream,Cea608Stream:xe.Cea608Stream,Cea708Stream:xe.Cea708Stream,MetadataStream:Qe};for(var Je in Re)Re.hasOwnProperty(Je)&&($e[Je]=Re[Je]);var Ze,et=$e,tt=[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>5,d=9e4*(u=1024*(1+(3&t[l+6])))/tt[(60&t[l+2])>>>2],s=l+r,t.byteLength>>6&3),channelcount:(1&t[l+2])<<2|(192&t[l+3])>>>6,samplerate:tt[(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 it,nt,rt,at=Ze,st=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<>>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();};(nt=function(){var e,t,i=0;nt.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;i3&&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,rt={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},(it=function(){var e,t,i,n,r,a,s,o=new nt;it.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=0?i:0,(16&e[t+5])>>4?i+20:i+10},lt=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+=dt(t,i))},ht=function(e){var t=lt(e,0);return e.length>=t+2&&255==(255&e[t])&&240==(240&e[t+1])&&16==(22&e[t+1])},ct=dt,ft=function(e,t){var i=(224&e[t+5])>>5,n=e[t+4]<<3;return 6144&e[t+3]|n|i};(ot=function(){var e=new Uint8Array,t=0;ot.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=ft(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=ct(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 mt,pt,gt,yt,vt=ot,_t=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],Tt=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],bt=ut.H264Stream,St=ht,It=function(e,t){var i;if(e.length!==t.length)return !1;for(i=0;i=-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;tn.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,(yt=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,yt.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,yt.prototype.flush=function(e){var t,i,n,r,a=0,s={captions:[],captionStreams:{},metadata:[],info:{}},o=0;if(this.pendingTracks.length=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0))}if(this.videoTrack?(o=this.videoTrack.timelineStartInfo.pts,Tt.forEach((function(e){s.info[e]=this.videoTrack[e];}),this)):this.audioTrack&&(o=this.audioTrack.timelineStartInfo.pts,_t.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=Z(this.pendingTracks),s.initSegment=new Uint8Array(n.byteLength),s.initSegment.set(n),s.data=new Uint8Array(this.pendingBytes),r=0;r=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0);},yt.prototype.setRemux=function(e){this.remuxTracks=e;},(gt=function(e){var t,i,n=this,r=!0;gt.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 et.MetadataStream,r.aacStream=new vt,r.audioTimestampRolloverStream=new et.TimestampRolloverStream("audio"),r.timedMetadataTimestampRolloverStream=new et.TimestampRolloverStream("timed-metadata"),r.adtsStream=new at,r.coalesceStream=new yt(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 pt(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 et.MetadataStream,r.packetStream=new et.TransportPacketStream,r.parseStream=new et.TransportParseStream,r.elementaryStream=new et.ElementaryStream,r.timestampRolloverStream=new et.TimestampRolloverStream,r.adtsStream=new at,r.h264Stream=new bt,r.captionStream=new et.CaptionStream(e),r.coalesceStream=new yt(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 mt(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 pt(i,e),r.audioSegmentStream.on("timingInfo",n.trigger.bind(n,"audioTimingInfo")),r.audioSegmentStream.on("segmentTimingInfo",n.trigger.bind(n,"audioSegmentTimingInfo")),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,Te(i),r.audioTimestampRolloverStream&&r.audioTimestampRolloverStream.discontinuity()),t&&(r.videoSegmentStream&&(r.videoSegmentStream.gopCache_=[]),t.timelineStartInfo.dts=void 0,t.timelineStartInfo.pts=void 0,Te(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=St(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 Lt={Transmuxer:gt,VideoSegmentStream:mt,AudioSegmentStream:pt,AUDIO_PROPERTIES:_t,VIDEO_PROPERTIES:Tt,generateSegmentTimingInfo:wt},kt={Adts:at,h264:ut},At=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&&_t.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=be(t,i.keepOriginalTimestamps),ge(t,e,s,o),t.samples=ve(e),h=$(_e(e)),n=[],l=J(r,[t]),r++,t.initSegment=Z([t]),(c=new Uint8Array(l.byteLength+h.byteLength)).set(l),c.set(h,l.byteLength),Te(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(){Te(t),u=null,d=null;},this.reset=function(){this.resetTiming_(),n=[],this.trigger("reset");};};At.prototype=new W;var Et=At,Pt=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],Tt.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=te(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=ie(r))[0][0].keyFrame){if(!(a=ne(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>>0},Bt=Mt,Ft=function e(t,i){var n,r,a,s,o,u,d,l=[];if(!i.length)return null;for(n=0;n1?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},Nt=Mt,qt=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]}},Wt=function(e){for(var t,i,n=e.byteLength,r=[],a=1;a0?function(e){var t={version:e[0],flags:new Uint8Array(e.subarray(1,4)),baseMediaDecodeTime:Nt(e[4]<<24|e[5]<<16|e[6]<<8|e[7])};return 1===t.version&&(t.baseMediaDecodeTime*=Math.pow(2,32),t.baseMediaDecodeTime+=Nt(e[8]<<24|e[9]<<16|e[10]<<8|e[11])),t}(T[0]).baseMediaDecodeTime:0,S=Ft(g,["trun"]);t===_&&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+40;){var u=t.shift();this.parse(u,a,s);}return null!==(o=function(e,t,i){return null===t?null:{seiNals:Gt(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();},zt=function(e){return "AudioSegmentStream"===e?"audio":"VideoSegmentStream"===e?"video":""},Xt=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 Rt(this.options):new Lt.Transmuxer(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=ce(t.data.videoFrameDts)),void 0!==t.data.videoFramePts&&(n.videoFramePtsTime=ce(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:zt(t)});})),t.on("partialdone",(function(t){e.postMessage({action:"partialdone",type:zt(t)});})),t.on("endedsegment",(function(t){e.postMessage({action:"endedSegment",type:zt(t)});})),t.on("trackinfo",(function(t){e.postMessage({action:"trackinfo",trackInfo:t});})),t.on("audioTimingInfo",(function(t){if(null!==t.start){var i={start:ce(t.start)};t.end&&(i.end=ce(t.end)),e.postMessage({action:"audioTimingInfo",audioTimingInfo:i});}else e.postMessage({action:"audioTimingInfo",audioTimingInfo:t});})),t.on("videoTimingInfo",(function(t){var i={start:ce(t.start)};t.end&&(i.end=ce(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:ce(t.start.dts),presentation:ce(t.start.pts)},end:{decode:ce(t.end.dts),presentation:ce(t.end.pts)},baseMediaDecodeTime:ce(t.baseMediaDecodeTime)};t.prependedContentDuration&&(i.prependedContentDuration=ce(t.prependedContentDuration)),e.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:i});})),t.on("audioSegmentTimingInfo",(function(t){var i={start:{decode:ce(t.start.dts),presentation:ce(t.start.pts)},end:{decode:ce(t.end.dts),presentation:ce(t.end.pts)},baseMediaDecodeTime:ce(t.baseMediaDecodeTime)};t.prependedContentDuration&&(i.prependedContentDuration=ce(t.prependedContentDuration)),e.postMessage({action:"audioSegmentTimingInfo",audioSegmentTimingInfo: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:ce(t.start),end:ce(t.end)}});})),t.on("videoTimingInfo",(function(t){e.postMessage({action:"videoTimingInfo",videoTimingInfo:{start:ce(t.start),end:ce(t.end)}});}));}(this.self,this.transmuxer);},t.pushMp4Captions=function(e){this.captionParser||(this.captionParser=new jt,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(he(t)));},t.setAudioAppendStart=function(e){this.transmuxer.setAudioAppendStart(Math.ceil(he(e.appendStart)));},t.setRemux=function(e){this.transmuxer.setRemux(e.remux);},t.flush=function(e){this.transmuxer.flush(),self.postMessage({action:"done",type:"transmuxed"});},t.partialFlush=function(e){this.transmuxer.partialFlush(),self.postMessage({action:"partialdone",type:"transmuxed"});},t.endTimeline=function(){this.transmuxer.endTimeline(),self.postMessage({action:"endedtimeline",type:"transmuxed"});},t.alignGopsWith=function(e){this.transmuxer.alignGopsWith(e.gopsToAlignWith.slice());},e}();self.onmessage=function(e){"init"===e.data.action&&e.data.options?this.messageHandlers=new Xt(self,e.data.options):(this.messageHandlers||(this.messageHandlers=new Xt(self)),e.data&&e.data.action&&"init"!==e.data.action&&this.messageHandlers[e.data.action]&&this.messageHandlers[e.data.action](e.data));};})))),qt=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.onAudioSegmentTimingInfo,f=e.onId3,m=e.onCaptions,p=e.onDone,g=e.onEndedTimeline,y=e.isEndOfTimeline,v={isPartial:a,buffer:[]},_=y;if(t.onmessage=function(i){t.currentTransmux===e&&("data"===i.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);}(i,v,o),"trackinfo"===i.data.action&&u(i.data.trackInfo),"gopInfo"===i.data.action&&function(e,t){t.gopInfo=e.data.gopInfo;}(i,v),"audioTimingInfo"===i.data.action&&d(i.data.audioTimingInfo),"videoTimingInfo"===i.data.action&&l(i.data.videoTimingInfo),"videoSegmentTimingInfo"===i.data.action&&h(i.data.videoSegmentTimingInfo),"audioSegmentTimingInfo"===i.data.action&&c(i.data.audioSegmentTimingInfo),"id3Frame"===i.data.action&&f([i.data.id3Frame],i.data.id3Frame.dispatchType),"caption"===i.data.action&&m(i.data.caption),"endedtimeline"===i.data.action&&(_=!1,g()),"transmuxed"===i.data.type&&(_||(t.onmessage=null,function(e){var t=e.transmuxedData,i=e.callback;t.buffer=[],i(t);}({transmuxedData:v,callback:p}),Wt(t))));},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 T=i instanceof ArrayBuffer?i:i.buffer,b=i instanceof ArrayBuffer?0:i.byteOffset;t.postMessage({action:"push",data:T,byteOffset:b,byteLength:i.byteLength},[T]);}t.postMessage({action:a?"partialFlush":"flush"}),y&&t.postMessage({action:"endTimeline"});},Wt=function(e){e.currentTransmux=null,e.transmuxQueue.length&&(e.currentTransmux=e.transmuxQueue.shift(),"function"==typeof e.currentTransmux?e.currentTransmux():qt(e.currentTransmux));},Vt=function(e,t){e.postMessage({action:t}),Wt(e);},Ht=function(e){!function(e,t){if(!t.currentTransmux)return t.currentTransmux=e,void Vt(t,e);t.transmuxQueue.push(Vt.bind(null,t,e));}("reset",e);};var jt=function(e,t){var i=1;for(e>t&&(i=-1);Math.abs(t-e)>4294967296;)e+=8589934592*i;return e};var zt=function(e){var t=31&e[1];return (t<<=8)|e[2]},Xt=function(e){return !!(64&e[1])},Qt=function(e){var t=0;return (48&e[3])>>>4>1&&(t+=e[4]+1),t},Yt=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}},Kt={parseType:function(e,t){var i=zt(e);return 0===i?"pat":i===t?"pmt":t?"pes":null},parsePat:function(e){var t=Xt(e),i=4+Qt(e);return t&&(i+=e[i]+1),(31&e[i+10])<<8|e[i+11]},parsePmt:function(e){var t={},i=Xt(e),n=4+Qt(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=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+Qt(e),i=e.subarray(t),n=0,r=0,a=!1;r3&&"slice_layer_without_partitioning_rbsp_idr"===Yt(31&i[r+3])&&(a=!0),a}},$t=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],Jt=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},Zt=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+=Jt(t,i))},ei=function(e){return e[0]<<21|e[1]<<14|e[2]<<7|e[3]},ti={isLikelyAacData:function(e){var t=Zt(e,0);return e.length>=t+2&&255==(255&e[t])&&240==(240&e[t+1])&&16==(22&e[t+1])},parseId3TagSize:Jt,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>>2];t++;}return null},parseAacTimestamp:function(e){var t,i,n;t=10,64&e[5]&&(t+=4,t+=ei(e.subarray(10,14)));do{if((i=ei(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>>2;return (s*=4)+(3&a[7])}break}}t+=10,t+=i;}while(t=0;)if(e[o]!==di||e[u]!==di&&u!==e.byteLength)o--,u--;else {switch(n=e.subarray(o,u),ai.ts.parseType(n,t.pid)){case"pes":r=ai.ts.parsePesType(n,t.table),a=ai.ts.parsePayloadUnitStartIndicator(n),"audio"===r&&a&&(s=ai.ts.parsePesTime(n))&&(s.type="audio",i.audio.push(s),d=!0);}if(d)break;o-=ui,u-=ui;}},hi=function(e,t,i){for(var n,r,a,s,o,u,d,l=0,h=ui,c=!1,f={data:[],size:0};h=0;)if(e[l]!==di||e[h]!==di)l--,h--;else {switch(n=e.subarray(l,h),ai.ts.parseType(n,t.pid)){case"pes":r=ai.ts.parsePesType(n,t.table),a=ai.ts.parsePayloadUnitStartIndicator(n),"video"===r&&a&&(s=ai.ts.parsePesTime(n))&&(s.type="video",i.video.push(s),c=!0);}if(c)break;l-=ui,h-=ui;}},ci=function(e,t){var i;return (i=ai.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(ai.aac.parseType(e,o)){case"timed-metadata":if(e.length-o<10){i=!0;break}if((s=ai.aac.parseId3TagSize(e,o))>e.length){i=!0;break}null===a&&(t=e.subarray(o,o+s),a=ai.aac.parseAacTimestamp(t)),o+=s;break;case"audio":if(e.length-o<7){i=!0;break}if((s=ai.aac.parseAdtsSize(e,o))>e.length){i=!0;break}null===r&&(t=e.subarray(o,o+s),r=ai.aac.parseSampleRate(t)),n++,o+=s;break;default:o++;}if(i)return null}if(null===r||null===a)return null;var u=oi/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=ui;r>>0},mi=function(e){var t="";return t+=String.fromCharCode(e[0]),t+=String.fromCharCode(e[1]),(t+=String.fromCharCode(e[2]))+String.fromCharCode(e[3])},pi=fi,gi=function e(t,i){var n,r,a,s,o,u=[];if(!i.length)return null;for(n=0;n1?n+r:t.byteLength,a===i[0]&&(1===i.length?u.push(t.subarray(n+8,s)):(o=e(t.subarray(n+8,s),i.slice(1))).length&&(u=u.concat(o))),n=s;return u},yi=fi,vi=function(e){return ("00"+e.toString(16)).slice(-2)},_i=function(e,t){var i,n,r;return i=gi(t,["moof","traf"]),n=[].concat.apply([],i.map((function(t){return gi(t,["tfhd"]).map((function(i){var n,r,a;return n=yi(i[4]<<24|i[5]<<16|i[6]<<8|i[7]),r=e[n]||9e4,(a="number"!=typeof(a=gi(t,["tfdt"]).map((function(e){var t,i;return t=e[0],i=yi(e[4]<<24|e[5]<<16|e[6]<<8|e[7]),1===t&&(i*=Math.pow(2,32),i+=yi(e[8]<<24|e[9]<<16|e[10]<<8|e[11])),i}))[0])||isNaN(a)?1/0:a)/r}))}))),r=Math.min.apply(null,n),isFinite(r)?r:0},Ti=function(e){var t=gi(e,["moov","trak"]),i=[];return t.forEach((function(e){var t,n,r={},a=gi(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=gi(e,["mdia","hdlr"])[0];if(s){var o=mi(s.subarray(8,12));r.type="vide"===o?"video":"soun"===o?"audio":o;}var u=gi(e,["mdia","minf","stbl","stsd"])[0];if(u){var d=u.subarray(8);r.codec=mi(d.subarray(4,8));var l,h=gi(d,[r.codec])[0];h&&(/^[a-z]vc[1-9]$/i.test(r.codec)?(l=h.subarray(78),"avcC"===mi(l.subarray(4,8))&&l.length>11?(r.codec+=".",r.codec+=vi(l[9]),r.codec+=vi(l[10]),r.codec+=vi(l[11])):r.codec="avc1.4d400d"):/^mp4[a,v]$/i.test(r.codec)?(l=h.subarray(28),"esds"===mi(l.subarray(4,8))&&l.length>20&&0!==l[19]?(r.codec+="."+vi(l[19]),r.codec+="."+vi(l[20]>>>2&63).replace(/^0/,"")):r.codec="mp4a.40.2"):r.codec=r.codec.toLowerCase());}var c=gi(e,["mdia","mdhd"])[0];c&&(r.timescale=si(c)),i.push(r);})),i},bi=(si=function(e){var t=0===e[0]?12:20;return yi(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])},2),Si=-101,Ii=-102,wi=function(e){e.forEach((function(e){e.abort();}));},Li=function(e,t){return t.timedout?{status:t.status,message:"HLS request timed-out at URL: "+t.uri,code:Si,xhr:t}:t.aborted?{status:t.status,message:"HLS request aborted at URL: "+t.uri,code:Ii,xhr:t}:e?{status:t.status,message:"HLS request errored at URL: "+t.uri,code:bi,xhr:t}:null},ki=function(e){var t=e.segment,i=e.bytes,n=e.isPartial,r=e.trackInfoFn,a=e.timingInfoFn,s=e.videoSegmentTimingInfoFn,o=e.audioSegmentTimingInfoFn,u=e.id3Fn,d=e.captionsFn,l=e.isEndOfTimeline,h=e.endedTimelineFn,c=e.dataFn,f=e.doneFn,m=t.map&&t.map.tracks||{},p=Boolean(m.audio&&m.video),g=a.bind(null,t,"audio","start"),y=a.bind(null,t,"audio","end"),v=a.bind(null,t,"video","start"),_=a.bind(null,t,"video","end");if(!n&&!t.lastReachedChar){var T=function(e,t){var i=ci(e,t*ni);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);T&&(r(t,{hasAudio:T.hasAudio,hasVideo:T.hasVideo,isMuxed:p}),r=null,T.hasAudio&&!p&&g(T.audioStart),T.hasVideo&&v(T.videoStart),g=null,v=null);}!function(e){if(!e.transmuxer.currentTransmux)return e.transmuxer.currentTransmux=e,void qt(e);e.transmuxer.transmuxQueue.push(e);}({bytes:i,transmuxer:t.transmuxer,audioAppendStart:t.audioAppendStart,gopsToAlignWith:t.gopsToAlignWith,isPartial:n,remux:p,onData:function(e){e.type="combined"===e.type?"video":e.type,c(t,e);},onTrackInfo:function(e){r&&(p&&(e.isMuxed=!0),r(t,e));},onAudioTimingInfo:function(e){g&&void 0!==e.start&&(g(e.start),g=null),y&&void 0!==e.end&&y(e.end);},onVideoTimingInfo:function(e){v&&void 0!==e.start&&(v(e.start),v=null),_&&void 0!==e.end&&_(e.end);},onVideoSegmentTimingInfo:function(e){s(e);},onAudioSegmentTimingInfo:function(e){o(e);},onId3:function(e,i){u(t,e,i);},onCaptions:function(e){d(t,[e]);},isEndOfTimeline:l&&!n,onEndedTimeline:function(){h();},onDone:function(e){f&&!n&&(e.type="combined"===e.type?"video":e.type,f(null,t,e));}});},Ai=function(e){var t=e.segment,i=e.bytes,n=e.isPartial,r=e.trackInfoFn,a=e.timingInfoFn,s=e.videoSegmentTimingInfoFn,o=e.audioSegmentTimingInfoFn,u=e.id3Fn,d=e.captionsFn,l=e.isEndOfTimeline,h=e.endedTimelineFn,c=e.dataFn,f=e.doneFn,m=new Uint8Array(i);if(Lt(m)){t.isFmp4=!0;var p=t.map.tracks,g={isFmp4:!0,hasVideo:!!p.video,hasAudio:!!p.audio};p.audio&&p.audio.codec&&"enca"!==p.audio.codec&&(g.audioCodec=p.audio.codec),p.video&&p.video.codec&&"encv"!==p.video.codec&&(g.videoCodec=p.video.codec),p.video&&p.audio&&(g.isMuxed=!0),r(t,g);var y=_i(t.map.timescales,m);g.hasAudio&&!g.isMuxed&&a(t,"audio","start",y),g.hasVideo&&a(t,"video","start",y);var v=function(e){c(t,{data:i,type:g.hasAudio&&!g.isMuxed?"audio":"video"}),e&&e.length&&d(t,e),f(null,t,{});};if(!p.video||!i.byteLength||!t.transmuxer)return void v();var _=i instanceof ArrayBuffer?i:i.buffer,T=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),v(n.data.captions);}})),void t.transmuxer.postMessage({action:"pushMp4Captions",timescales:t.map.timescales,trackIds:[p.video.id],data:_,byteOffset:T,byteLength:i.byteLength},[_])}if(t.transmuxer){if(void 0===t.container&&(t.container=wt(m)),"ts"!==t.container&&"aac"!==t.container)return r(t,{hasAudio:!1,hasVideo:!1}),void f(null,t,{});ki({segment:t,bytes:i,isPartial:n,trackInfoFn:r,timingInfoFn:a,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:o,id3Fn:u,captionsFn:d,isEndOfTimeline:l,endedTimelineFn:h,dataFn:c,doneFn:f});}else f(null,t,{});},Ei=function(e){var t=e.xhr,i=e.xhrOptions,n=e.decryptionWorker,r=e.segment,a=e.abortFn,s=e.progressFn,o=e.trackInfoFn,d=e.timingInfoFn,l=e.videoSegmentTimingInfoFn,h=e.audioSegmentTimingInfoFn,c=e.id3Fn,f=e.captionsFn,m=e.isEndOfTimeline,p=e.endedTimelineFn,g=e.dataFn,y=e.doneFn,v=e.handlePartialData,_=[],T=function(e){var t=e.activeXhrs,i=e.decryptionWorker,n=e.trackInfoFn,r=e.timingInfoFn,a=e.videoSegmentTimingInfoFn,s=e.audioSegmentTimingInfoFn,o=e.id3Fn,u=e.captionsFn,d=e.isEndOfTimeline,l=e.endedTimelineFn,h=e.dataFn,c=e.doneFn,f=0,m=!1;return function(e,p){if(!m){if(e)return m=!0,wi(t),c(e,p);if((f+=1)===t.length){if(p.endOfAllRequests=Date.now(),p.encryptedBytes)return function(e){var t,i=e.decryptionWorker,n=e.segment,r=e.trackInfoFn,a=e.timingInfoFn,s=e.videoSegmentTimingInfoFn,o=e.audioSegmentTimingInfoFn,u=e.id3Fn,d=e.captionsFn,l=e.isEndOfTimeline,h=e.endedTimelineFn,c=e.dataFn,f=e.doneFn;i.addEventListener("message",(function e(t){if(t.data.source===n.requestId){i.removeEventListener("message",e);var m=t.data.decrypted;n.bytes=new Uint8Array(m.bytes,m.byteOffset,m.byteLength),Ai({segment:n,bytes:n.bytes,isPartial:!1,trackInfoFn:r,timingInfoFn:a,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:o,id3Fn:u,captionsFn:d,isEndOfTimeline:l,endedTimelineFn:h,dataFn:c,doneFn:f});}})),t=n.key.bytes.slice?n.key.bytes.slice():new Uint32Array(Array.prototype.slice.call(n.key.bytes)),i.postMessage(fe({source:n.requestId,encrypted:n.encryptedBytes,key:t,iv:n.key.iv}),[n.encryptedBytes.buffer,t.buffer]);}({decryptionWorker:i,segment:p,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:a,audioSegmentTimingInfoFn:s,id3Fn:o,captionsFn:u,isEndOfTimeline:d,endedTimelineFn:l,dataFn:h,doneFn:c});Ai({segment:p,bytes:p.bytes,isPartial:!1,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:a,audioSegmentTimingInfoFn:s,id3Fn:o,captionsFn:u,isEndOfTimeline:d,endedTimelineFn:l,dataFn:h,doneFn:c});}}}}({activeXhrs:_,decryptionWorker:n,trackInfoFn:o,timingInfoFn:d,videoSegmentTimingInfoFn:l,audioSegmentTimingInfoFn:h,id3Fn:c,captionsFn:f,isEndOfTimeline:m,endedTimelineFn:p,dataFn:g,doneFn:y});if(r.key&&!r.key.bytes){var b=t(u.default.mergeOptions(i,{uri:r.key.resolvedUri,responseType:"arraybuffer"}),function(e,t){return function(i,n){var r=n.response,a=Li(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:bi,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)}}(r,T));_.push(b);}if(r.map&&!r.map.bytes){var S=t(u.default.mergeOptions(i,{uri:r.map.resolvedUri,responseType:"arraybuffer",headers:se(r.map)}),function(e){var t=e.segment,i=e.finishProcessingFn;return function(e,n){var r=n.response,a=Li(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:bi,xhr:n},t);t.map.bytes=new Uint8Array(n.response);var s=wt(t.map.bytes);return "mp4"!==s?i({status:n.status,message:"Found unsupported "+(s||"unknown")+" container for initialization segment at URL: "+n.uri,code:bi,internal:!0,xhr:n},t):(Ti(t.map.bytes).forEach((function(e){t.map.tracks=t.map.tracks||{},t.map.tracks[e.type]||(t.map.tracks[e.type]=e,"number"==typeof e.id&&e.timescale&&(t.map.timescales=t.map.timescales||{},t.map.timescales[e.id]=e.timescale));})),i(null,t))}}({segment:r,finishProcessingFn:T}));_.push(S);}var I=u.default.mergeOptions(i,{uri:r.resolvedUri,responseType:"arraybuffer",headers:se(r)});v&&(I.responseType="text",I.beforeSend=function(e){e.overrideMimeType("text/plain; charset=x-user-defined");});var w=t(I,function(e){var t=e.segment,i=e.finishProcessingFn,n=e.responseType;return function(e,r){var a=r.response,s=Li(e,r);if(s)return i(s,t);var o="arraybuffer"!==n&&r.responseText?xt(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:bi,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:r,finishProcessingFn:T,responseType:I.responseType}));w.addEventListener("progress",function(e){var t=e.segment,i=e.progressFn,n=e.trackInfoFn,r=e.timingInfoFn,a=e.videoSegmentTimingInfoFn,s=e.audioSegmentTimingInfoFn,o=e.id3Fn,d=e.captionsFn,l=e.isEndOfTimeline,h=e.endedTimelineFn,c=e.dataFn,f=e.handlePartialData;return function(e){var m=e.target;if(!m.aborted){if(f&&!t.key&&m.responseText&&m.responseText.length>=8){var p=xt(m.responseText.substring(t.lastReachedChar||0));!t.lastReachedChar&&Lt(new Uint8Array(p))||(t.lastReachedChar=m.responseText.length,Ai({segment:t,bytes:p,isPartial:!0,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:a,audioSegmentTimingInfoFn:s,id3Fn:o,captionsFn:d,isEndOfTimeline:l,endedTimelineFn:h,dataFn:c}));}return t.stats=u.default.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:r,progressFn:s,trackInfoFn:o,timingInfoFn:d,videoSegmentTimingInfoFn:l,audioSegmentTimingInfoFn:h,id3Fn:c,captionsFn:f,isEndOfTimeline:m,endedTimelineFn:p,dataFn:g,handlePartialData:v})),_.push(w);var L={};return _.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:L,abortFn:a}));})),function(){return wi(_)}},Pi={mp4:/^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v|stpp.ttml.im1t)/,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|speex|aac)/,text:/^(stpp.ttml.im1t)/,muxerVideo:/^(avc0?1)/,muxerAudio:/^(mp4a)/,muxerText:/a^/},Oi=["video","audio","text"],Ci=["Video","Audio","Text"],Ui=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},Di=function(e){void 0===e&&(e="");var t=e.split(","),i=[];return t.forEach((function(e){var t;e=e.trim(),Oi.forEach((function(n){var r=Pi[n].exec(e.toLowerCase());if(r&&!(r.length<=1)){t=n;var a=e.substring(0,r[1].length),s=e.replace(a,"");i.push({type:a,details:s,mediaType:n});}})),t||i.push({type:e,details:"",mediaType:"unknown"});})),i},xi=function(e){return void 0===e&&(e=""),Pi.audio.test(e.trim().toLowerCase())},Ri=function(e){if(e&&"string"==typeof e){var t,i=e.toLowerCase().split(",").map((function(e){return Ui(e.trim())})),n="video";1===i.length&&xi(i[0])?n="audio":1===i.length&&(void 0===(t=i[0])&&(t=""),Pi.text.test(t.trim().toLowerCase()))&&(n="application");var r="mp4";return i.every((function(e){return Pi.mp4.test(e)}))?r="mp4":i.every((function(e){return Pi.webm.test(e)}))?r="webm":i.every((function(e){return Pi.ogg.test(e)}))&&(r="ogg"),n+"/"+r+';codecs="'+e+'"'}},Mi=function(e){return void 0===e&&(e=""),o.default.MediaSource&&o.default.MediaSource.isTypeSupported&&o.default.MediaSource.isTypeSupported(Ri(e))||!1},Bi=function(e){return void 0===e&&(e=""),e.toLowerCase().split(",").every((function(e){e=e.trim();for(var t=0;t1)return Ni("multiple "+e+" codecs found as attributes: "+t[e].join(", ")+". Setting playlist codecs to null so that we wait for mux.js to probe segments for real codecs."),void(t[e]=null);t[e]=t[e][0];})),t},Vi=function(e){var t=0;return e.audio&&t++,e.video&&t++,t},Hi=function(e,t){var i=t.attributes||{},n=Wi(function(e){var t=e.attributes||{};if(t.CODECS)return Di(t.CODECS)}(t)||[]);if(qi(e,t)&&!n.audio&&!function(e,t){if(!qi(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=Wi(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 Di(r.playlists[0].attributes.CODECS)}return null}(e,i.AUDIO)||[]);r.audio&&(n.audio=r.audio);}return n},Gi=g("PlaylistSelector"),ji=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||""})}},zi=function(e,t){if(!e)return "";var i=o.default.getComputedStyle(e);return i?i[t]:""},Xi=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}));},Qi=function(e,t){var i,n;return e.attributes.BANDWIDTH&&(i=e.attributes.BANDWIDTH),i=i||o.default.Number.MAX_VALUE,t.attributes.BANDWIDTH&&(n=t.attributes.BANDWIDTH),i-(n||o.default.Number.MAX_VALUE)},Yi=function(e,t,i,n,r){if(e){var a={bandwidth:t,width:i,height:n,limitRenditionByPlayerDimensions:r},s=e.playlists.map((function(e){var t=e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width,i=e.attributes.RESOLUTION&&e.attributes.RESOLUTION.height;return {bandwidth:e.attributes.BANDWIDTH||o.default.Number.MAX_VALUE,width:t,height:i,playlist:e}}));Xi(s,(function(e,t){return e.bandwidth-t.bandwidth}));var u=(s=s.filter((function(e){return !te.isIncompatible(e.playlist)}))).filter((function(e){return te.isEnabled(e.playlist)}));u.length||(u=s.filter((function(e){return !te.isDisabled(e.playlist)})));var d=u.filter((function(e){return e.bandwidth*Dt.BANDWIDTH_VARIANCEi||e.height>n}))).filter((function(e){return e.width===g[0].width&&e.height===g[0].height})),l=y[y.length-1],v=y.filter((function(e){return e.bandwidth===l.bandwidth}))[0]);var T=v||_||h||u[0]||s[0];if(T&&T.playlist){var b="sortedPlaylistReps";return v?b="resolutionPlusOneRep":_?b="resolutionBestRep":h?b="bandwidthBestRep":u[0]&&(b="enabledPlaylistReps"),Gi("choosing "+ji(T)+" using "+b+" with options",a),T.playlist}return Gi("could not choose a playlist with options",a),null}},Ki=function(){var e=this.useDevicePixelRatio&&o.default.devicePixelRatio||1;return Yi(this.playlists.master,this.systemBandwidth,parseInt(zi(this.tech_.el(),"width"),10)*e,parseInt(zi(this.tech_.el(),"height"),10)*e,this.limitRenditionByPlayerDimensions)},$i=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);},Ji=function(e){return "number"==typeof e&&isFinite(e)},Zi=1/60,en=function(e){return e+"TimingInfo"},tn=function(e){var t=e.segmentTimeline,i=e.currentTimeline,n=e.startOfSegment,r=e.buffered;return e.overrideCheck||t!==i?ti+B},an=function(e){function t(t,i){var n;if(n=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 n.bandwidth=t.bandwidth,n.throughput={rate:0,count:0},n.roundTrip=NaN,n.resetStats_(),n.mediaIndex=null,n.hasPlayed_=t.hasPlayed,n.currentTime_=t.currentTime,n.seekable_=t.seekable,n.seeking_=t.seeking,n.duration_=t.duration,n.mediaSource_=t.mediaSource,n.vhs_=t.vhs,n.loaderType_=t.loaderType,n.currentMediaInfo_=void 0,n.startingMediaInfo_=void 0,n.segmentMetadataTrack_=t.segmentMetadataTrack,n.goalBufferLength_=t.goalBufferLength,n.sourceType_=t.sourceType,n.sourceUpdater_=t.sourceUpdater,n.inbandTextTracks_=t.inbandTextTracks,n.state_="INIT",n.handlePartialData_=t.handlePartialData,n.timelineChangeController_=t.timelineChangeController,n.shouldSaveSegmentTimingInfo_=!0,n.parse708captions_=t.parse708captions,n.checkBufferTimeout_=null,n.error_=void 0,n.currentTimeline_=-1,n.pendingSegment_=null,n.xhrOptions_=null,n.pendingSegments_=[],n.audioDisabled_=!1,n.isPendingTimestampOffset_=!1,n.gopBuffer_=[],n.timeMapping_=0,n.safeAppend_=u.default.browser.IE_VERSION>=11,n.appendInitSegment_={audio:!0,video:!0},n.playlistOfLastInitSegment_={audio:null,video:null},n.callQueue_=[],n.loadQueue_=[],n.metadataQueue_={id3:[],caption:[]},n.activeInitSegmentId_=null,n.initSegments_={},n.cacheEncryptionKeys_=t.cacheEncryptionKeys,n.keyCache_={},n.decrypter_=t.decrypter,n.syncController_=t.syncController,n.syncPoint_={segmentIndex:0,time:0},n.transmuxer_=n.createTransmuxer_(),n.triggerSyncInfoUpdate_=function(){return n.trigger("syncinfoupdate")},n.syncController_.on("syncinfoupdate",n.triggerSyncInfoUpdate_),n.mediaSource_.addEventListener("sourceopen",(function(){n.isEndOfStream_()||(n.ended_=!1);})),n.fetchAtBuffer_=!1,n.logger_=g("SegmentLoader["+n.loaderType_+"]"),Object.defineProperty(d(n),"state",{get:function(){return this.state_},set:function(e){e!==this.state_&&(this.logger_(this.state_+" -> "+e),this.state_=e,this.trigger("statechange"));}}),n.sourceUpdater_.on("ready",(function(){n.hasEnoughInfoToAppend_()&&n.processCallQueue_();})),"main"===n.loaderType_&&n.timelineChangeController_.on("pendingtimelinechange",(function(){n.hasEnoughInfoToAppend_()&&n.processCallQueue_();})),"audio"===n.loaderType_&&n.timelineChangeController_.on("timelinechange",(function(){n.hasEnoughInfoToLoad_()&&n.processLoadQueue_(),n.hasEnoughInfoToAppend_()&&n.processCallQueue_();})),n}l(t,e);var i=t.prototype;return i.createTransmuxer_=function(){return function(e){var t=new Nt;t.currentTransmux=null,t.transmuxQueue=[];var i=t.terminate;return t.terminate=function(){return t.currentTransmux=null,t.transmuxQueue.length=0,i.call(t)},t.postMessage({action:"init",options:e}),t}({remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,handlePartialData:this.handlePartialData_,parse708captions:this.parse708captions_})},i.resetStats_=function(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0;},i.dispose=function(){this.trigger("dispose"),this.state="DISPOSED",this.pause(),this.abort_(),this.transmuxer_&&this.transmuxer_.terminate(),this.resetStats_(),this.checkBufferTimeout_&&o.default.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_),this.off();},i.setAudio=function(e){this.audioDisabled_=!e,e?this.appendInitSegment_.audio=!0:this.sourceUpdater_.removeAudio(0,this.duration_());},i.abort=function(){"WAITING"===this.state?(this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()):this.pendingSegment_&&(this.pendingSegment_=null);},i.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_);},i.checkForAbort_=function(e){return "APPENDING"!==this.state||this.pendingSegment_?!this.pendingSegment_||this.pendingSegment_.requestId!==e:(this.state="READY",!0)},i.error=function(e){return void 0!==e&&(this.logger_("error occurred:",e),this.error_=e),this.pendingSegment_=null,this.error_},i.endOfStream=function(){this.ended_=!0,this.transmuxer_&&Ht(this.transmuxer_),this.gopBuffer_.length=0,this.pause(),this.trigger("ended");},i.buffered_=function(){if(!this.sourceUpdater_||!this.startingMediaInfo_)return u.default.createTimeRanges();if("main"===this.loaderType_){var e=this.startingMediaInfo_,t=e.hasAudio,i=e.hasVideo,n=e.isMuxed;if(i&&t&&!this.audioDisabled_&&!n)return this.sourceUpdater_.buffered();if(i)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()},i.initSegmentForMap=function(e,t){if(void 0===t&&(t=!1),!e)return null;var i=me(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},i.segmentKey=function(e,t){if(void 0===t&&(t=!1),!e)return null;var i=pe(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},i.couldBeginLoading_=function(){return this.playlist_&&!this.paused()},i.load=function(){if(this.monitorBuffer_(),this.playlist_)return "INIT"===this.state&&this.couldBeginLoading_()?this.init_():void(!this.couldBeginLoading_()||"READY"!==this.state&&"INIT"!==this.state||(this.state="READY"))},i.init_=function(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()},i.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},"main"===this.loaderType_&&this.syncController_.setDateTimeMappingForStart(e));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);}},i.pause=function(){this.checkBufferTimeout_&&(o.default.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null);},i.paused=function(){return null===this.checkBufferTimeout_},i.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"});},i.resetLoader=function(){this.fetchAtBuffer_=!1,this.resyncLoader();},i.resyncLoader=function(){this.transmuxer_&&Ht(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"});},i.remove=function(e,t,i){if(void 0===i&&(i=function(){}),t===1/0&&(t=this.duration_()),this.sourceUpdater_&&this.startingMediaInfo_){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.gopBuffer_=function(e,t,i,n){for(var r=Math.ceil((t-n)*ni),a=Math.ceil((i-n)*ni),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_)$i(e,t,this.inbandTextTracks_[a]);$i(e,t,this.segmentMetadataTrack_),r();}else this.logger_("skipping remove because no source updater or starting media info");},i.monitorBuffer_=function(){this.checkBufferTimeout_&&o.default.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=o.default.setTimeout(this.monitorBufferTick_.bind(this),1);},i.monitorBufferTick_=function(){"READY"===this.state&&this.fillBuffer_(),this.checkBufferTimeout_&&o.default.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=o.default.setTimeout(this.monitorBufferTick_.bind(this),500);},i.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=tn({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));}},i.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},i.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=te.getMediaInfoForTime(t,s,a.segmentIndex,a.time);d=c.mediaIndex,u=c.startTime;}else {var f=te.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)},i.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)},i.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)*ni);for(n=0;nr);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}},i.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=te.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 !te.isIncompatible(e)})),d=u.filter(te.isEnabled);d.length||(d=u.filter((function(e){return !te.isDisabled(e)})));var l=d.filter(te.hasAttribute.bind(null,"BANDWIDTH")).map((function(e){var u=o.getSyncPoint(e,n,s,t)?1:2;return {playlist:e,rebufferingImpact:te.estimateSegmentRequestTime(r,i,e)*u-a}})),h=l.filter((function(e){return e.rebufferingImpact<=0}));return Xi(h,(function(e,t){return Qi(t.playlist,e.playlist)})),h.length?h[0]:(Xi(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<=B&&(u=1),!s.playlist||s.playlist.uri===this.playlist_.uri||o "+s+" 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,i.vhs_.tech_,e),$i(a,s,d[e]),function(e){var t=e.inbandTextTracks,i=e.captionArray,n=e.timestampOffset;if(i){var r=o.default.WebKitDataCue||o.default.VTTCue;i.forEach((function(e){var i=e.stream;t[i].addCue(new r(e.startTime+n,e.endTime+n,e.text));}));}}({captionArray:u,inbandTextTracks:d,timestampOffset:n});})),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");},i.handleId3_=function(e,t,i){if(this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId))if(this.pendingSegment_.hasAppendedData_){var n=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_,i,this.vhs_.tech_),function(e){var t=e.inbandTextTracks,i=e.metadataArray,n=e.timestampOffset,r=e.videoDuration;if(i){var a=o.default.WebKitDataCue||o.default.VTTCue,s=t.metadataTrack_;if(s&&(i.forEach((function(e){var t=e.cueTime+n;!("number"!=typeof t||o.default.isNaN(t)||t<0)&&t<1/0&&e.frames.forEach((function(e){var i=new a(t,t,e.value||e.url||e.data||"");i.frame=e,i.value=e,function(e){Object.defineProperties(e.frame,{id:{get:function(){return u.default.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),e.value.key}},value:{get:function(){return u.default.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),e.value.data}},privateData:{get:function(){return u.default.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),e.value.data}}});}(i),s.addCue(i);}));})),s.cues&&s.cues.length)){for(var d=s.cues,l=[],h=0;h0,s=n||r&&a;e.abortRequests=Ei({xhr:this.vhs_.xhr,xhrOptions:this.xhrOptions_,decryptionWorker:this.decrypter_,segment:i,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.handleSegmentTimingInfo_.bind(this,"video",e.requestId),audioSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"audio",e.requestId),captionsFn:this.handleCaptions_.bind(this),isEndOfTimeline:s,endedTimelineFn:function(){t.logger_("received endedtimeline callback");},id3Fn:this.handleId3_.bind(this),dataFn:this.handleData_.bind(this),doneFn:this.segmentRequestFinished_.bind(this)});},i.trimBackBuffer_=function(e){var t=function(e,t,i){var n=t-Dt.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);},i.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-1];if(n&&n.timeline===t.timeline&&(n.videoTimingInfo?i.baseStartTime=n.videoTimingInfo.transmuxedDecodeEnd:n.audioTimingInfo&&(i.baseStartTime=n.audioTimingInfo.transmuxedDecodeEnd)),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},i.saveTransferStats_=function(e){this.mediaRequests+=1,e&&(this.mediaBytesTransferred+=e.bytesReceived,this.mediaTransferDuration+=e.roundTripTime);},i.saveBandwidthRelatedStats_=function(e,t){this.pendingSegment_.byteLength=t.bytesReceived,e=n);r++);return e.slice(0,r).concat(t)}(this.gopBuffer_,i.gopInfo,this.safeAppend_)),this.state="APPENDING",this.trigger("appending"),this.waitForAppendsToComplete_(n);}},i.setTimeMapping_=function(e){var t=this.syncController_.mappingForTimeline(e);null!==t&&(this.timeMapping_=t);},i.updateMediaSecondsLoaded_=function(e){"number"==typeof e.start&&"number"==typeof e.end?this.mediaSecondsLoaded+=e.end-e.start:this.mediaSecondsLoaded+=e.duration;},i.shouldUpdateTransmuxerTimestampOffset_=function(e){return null!==e&&("main"===this.loaderType_&&e!==this.sourceUpdater_.videoTimestampOffset()||!this.audioDisabled_&&e!==this.sourceUpdater_.audioTimestampOffset())},i.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},i.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));},i.checkAppendsDone_=function(e){this.checkForAbort_(e.requestId)||(e.waitingOnAppends--,0===e.waitingOnAppends&&this.handleAppendsDone_());},i.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)},i.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");}},i.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);},i.handleAppendsDone_=function(){if(this.pendingSegment_&&this.trigger("appendsdone"),!this.pendingSegment_)return this.state="READY",void(this.paused()||this.monitorBuffer_());var e=this.pendingSegment_;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));var t=function(e,t){if("hls"!==t)return null;var i,n,r,a,s=(i=e.audioTimingInfo,n=e.videoTimingInfo,r=i&&"number"==typeof i.start&&"number"==typeof i.end?i.end-i.start:0,a=n&&"number"==typeof n.start&&"number"==typeof n.end?n.end-n.start:0,Math.max(r,a));if(!s)return null;var o=e.playlist.targetDuration,u=rn({segmentDuration:s,maxDuration:2*o}),d=rn({segmentDuration:s,maxDuration:o}),l="Segment with index "+e.mediaIndex+" from playlist "+e.playlist.id+" has a duration of "+s+" when the reported duration is "+e.duration+" and the target duration is "+o+". For HLS content, a duration in excess of the target duration may result in playback issues. See the HLS specification section on EXT-X-TARGETDURATION for more details: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.1";return u||d?{severity:u?"warn":"info",message:l}:null}(e,this.sourceType_);if(t&&("warn"===t.severity?u.default.log.warn(t.message):this.logger_(t.message)),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 i=e.segment;i.end&&this.currentTime_()-i.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_());}},i.recordThroughput_=function(e){if(e.duration1&&n.push(t[a]);n.length&&n.forEach((function(t){return e.removeCue(t)}));}}(this.subtitlesTrack_),this.handleAppendsDone_();}else this.state="READY";},i.handleData_=function(){},i.updateTimingInfoEnd_=function(){},i.parseVTTCues_=function(e){var t,i=!1;"function"==typeof o.default.TextDecoder?t=new o.default.TextDecoder("utf8"):(t=o.default.WebVTT.StringDecoder(),i=!0);var n=new o.default.WebVTT.Parser(o.default,o.default.vttjs,t);if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},n.oncue=e.cues.push.bind(e.cues),n.ontimestampmap=function(t){e.timestampmap=t;},n.onparsingerror=function(e){u.default.log.warn("Error encountered when parsing cues: "+e.message);},e.segment.map){var r=e.segment.map.bytes;i&&(r=Ln(r)),n.parse(r);}var a=e.bytes;i&&(a=Ln(a)),n.parse(a),n.flush();},i.updateTimeMapping_=function(e,t,i){var n=e.segment;if(t)if(e.cues.length){var r=e.timestampmap,a=r.MPEGTS/ni-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}(an),En=function(e,t){for(var i=e.cues,n=0;n=r.adStartTime&&t<=r.adEndTime)return r}return null},Pn=[{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(!Object.keys(e.timelineToDatetimeMappings).length)return null;var a=t.segments||[],s=null,o=null;r=r||0;for(var u=0;u=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=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}}],On=function(e){function t(t){var i;return (i=e.call(this)||this).timelines=[],i.discontinuities=[],i.timelineToDatetimeMappings={},i.logger_=g("SyncController"),i}l(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+X(e,n.segmentIndex,0))},i.runStrategies_=function(e,t,i,n){for(var r=[],a=0;a=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.setDateTimeMappingForStart=function(e){if(this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject){var t=e.segments[0],i=t.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[t.timeline]=-i;}},i.saveSegmentTimingInfo=function(e){var t=e.segmentInfo,i=e.shouldSaveTimelineMapping,n=this.calculateSegmentTimeMapping_(t,t.timingInfo,i),r=t.segment;n&&(this.saveDiscontinuitySyncInfo_(t),t.playlist.syncInfo||(t.playlist.syncInfo={mediaSequence:t.playlist.mediaSequence+t.mediaIndex,time:r.start}));var a=r.dateTimeObject;r.discontinuity&&i&&a&&(this.timelineToDatetimeMappings[r.timeline]=-a.getTime()/1e3);},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("number"==typeof 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;no){var u;u=s<0?i.start-X(t,e.mediaIndex,r):i.end+X(t,e.mediaIndex+1,r),this.discontinuities[a]={time:u,accuracy:o};}}},i.dispose=function(){this.trigger("dispose"),this.off();},t}(u.default.EventTarget),Cn=function(e){function t(){var t;return (t=e.call(this)||this).pendingTimelineChanges_={},t.lastTimelineChanges_={},t}l(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}(u.default.EventTarget),Un=Mt(Bt(Ft((function(){function e(e,t){for(var i=0;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>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=[[i[0][0].slice(),i[0][1].slice(),i[0][2].slice(),i[0][3].slice(),i[0][4].slice()],[i[1][0].slice(),i[1][1].slice(),i[1][2].slice(),i[1][3].slice(),i[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(n=0;t;n++,t--)r=d[3&n?t:t-4],l[n]=t<=4||n<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],v=y[0],_=y[1],T=y[2],b=y[3],S=y[4];for(d=0;d>>24]^_[c>>16&255]^T[f>>8&255]^b[255&m]^l[g],o=v[c>>>24]^_[f>>16&255]^T[m>>8&255]^b[255&h]^l[g+1],u=v[f>>>24]^_[m>>16&255]^T[h>>8&255]^b[255&c]^l[g+2],m=v[m>>>24]^_[h>>16&255]^T[c>>8&255]^b[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}(),r=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),a=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},s=function(){function t(e,i,n,s){var o=t.STEP,u=new Int32Array(e.buffer),d=new Uint8Array(e.byteLength),l=0;for(this.asyncStream_=new r,this.asyncStream_.push(this.decryptChunk_(u.subarray(l,l+o),i,n,d)),l=o;l>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=0&&(t="main-desc"),t},Wn=function(e,t){e.abort(),e.pause(),t&&t.activePlaylistLoader&&(t.activePlaylistLoader.pause(),t.activePlaylistLoader=null);},Vn=function(e,t){t.activePlaylistLoader=e,e.load();},Hn={AUDIO:function(e,t){return function(){var i=t.segmentLoaders[e],n=t.mediaTypes[e],r=t.blacklistCurrentPlaylist;Wn(i,n);var a=n.activeTrack(),s=n.activeGroup(),o=(s.filter((function(e){return e.default}))[0]||s[0]).id,d=n.tracks[o];if(a!==d){for(var l in u.default.log.warn("Problem encountered loading the alternate audio track.Switching back to default."),n.tracks)n.tracks[l].enabled=n.tracks[l]===d;n.onTrackChanged();}else r({message:"Problem encountered loading the default audio track."});}},SUBTITLES:function(e,t){return function(){var i=t.segmentLoaders[e],n=t.mediaTypes[e];u.default.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),Wn(i,n);var r=n.activeTrack();r&&(r.mode="disabled"),n.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",Hn[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",Hn[e](e,i));}},jn={AUDIO:function(e,t){var i=t.vhs,n=t.sourceType,r=t.segmentLoaders[e],a=t.requestOptions,s=t.master,o=s.mediaGroups,d=s.playlists,l=t.mediaTypes[e],h=l.groups,c=l.tracks,f=t.masterPlaylistLoader;o[e]&&0!==Object.keys(o[e]).length||(o[e]={main:{default:{default:!0}}});var m=function(r){h[r]||(h[r]=[]);var s=d.filter((function(t){return t.attributes[e]===r})),l=function(d){var l=o[e][r][d];!s.filter((function(e){return e.resolvedUri!==l.resolvedUri})).length&&s.length&&delete l.resolvedUri;var m;if(m="vhs-json"===n&&l.playlists?new x(l.playlists[0],i,a):l.resolvedUri?new x(l.resolvedUri,i,a):l.playlists&&"dash"===n?new Ct(l.playlists[0],i,a,f):null,l=u.default.mergeOptions({id:d,playlistLoader:m},l),Gn[e](e,l.playlistLoader,t),h[r].push(l),void 0===c[d]){var p=new u.default.AudioTrack({id:d,kind:qn(l),enabled:!1,language:l.language,default:l.default,label:d});c[d]=p;}};for(var m in o[e][r])l(m);};for(var p in o[e])m(p);r.on("error",Hn[e](e,t));},SUBTITLES:function(e,t){var i=t.tech,n=t.vhs,r=t.sourceType,a=t.segmentLoaders[e],s=t.requestOptions,o=t.master.mediaGroups,d=t.mediaTypes[e],l=d.groups,h=d.tracks,c=t.masterPlaylistLoader;for(var f in o[e])for(var m in l[f]||(l[f]=[]),o[e][f])if(!o[e][f][m].forced){var p=o[e][f][m],g=void 0;if("hls"===r)g=new x(p.resolvedUri,n,s);else if("dash"===r){if(!p.playlists.filter((function(e){return e.excludeUntil!==1/0})).length)return;g=new Ct(p.playlists[0],n,s,c);}else "vhs-json"===r&&(g=new x(p.playlists?p.playlists[0]:p.resolvedUri,n,s));if(p=u.default.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;}}a.on("error",Hn[e](e,t));},"CLOSED-CAPTIONS":function(e,t){var i=t.tech,n=t.master.mediaGroups,r=t.mediaTypes[e],a=r.groups,s=r.tracks;for(var o in n[e])for(var d in a[o]||(a[o]=[]),n[e][o]){var l=n[e][o][d];if(l.instreamId.match(/CC\d/)&&(a[o].push(u.default.mergeOptions({id:d},l)),void 0===s[d])){var h=i.addRemoteTextTrack({id:l.instreamId,kind:"captions",default:l.default&&l.autoselect,language:l.language,label:d},!1).track;s[d]=h;}}}},zn={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}}},Xn=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],Qn=function(e){return this.audioSegmentLoader_[e]+this.mainSegmentLoader_[e]},Yn=function(e){function t(t){var i;i=e.call(this)||this;var n=t.src,r=t.handleManifestRedirects,a=t.withCredentials,s=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,v=t.experimentalBufferBasedABR;if(!n)throw new Error("A non-empty playlist URL or JSON manifest string is required");mn=h,i.experimentalBufferBasedABR=Boolean(v),i.withCredentials=a,i.tech_=s,i.vhs_=s.vhs,i.sourceType_=p,i.useCueTags_=c,i.blacklistDuration=f,i.enableLowInitialPlaylist=m,i.useCueTags_&&(i.cueTagsTrack_=i.tech_.addTextTrack("metadata","ad-cues"),i.cueTagsTrack_.inBandMetadataTrackDispatchType=""),i.requestOptions_={withCredentials:a,handleManifestRedirects:r,timeout:null},i.on("error",i.pauseLoading),i.mediaTypes_=function(){var e={};return ["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((function(t){e[t]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:fn,activeTrack:fn,onGroupChanged:fn,onTrackChanged:fn};})),e}(),i.mediaSource=new o.default.MediaSource,i.handleDurationChange_=i.handleDurationChange_.bind(d(i)),i.handleSourceOpen_=i.handleSourceOpen_.bind(d(i)),i.handleSourceEnded_=i.handleSourceEnded_.bind(d(i)),i.mediaSource.addEventListener("durationchange",i.handleDurationChange_),i.mediaSource.addEventListener("sourceopen",i.handleSourceOpen_),i.mediaSource.addEventListener("sourceended",i.handleSourceEnded_),i.seekable_=u.default.createTimeRanges(),i.hasPlayed_=!1,i.syncController_=new Bn(t),i.segmentMetadataTrack_=s.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,i.decrypter_=new Nn,i.sourceUpdater_=new Un(i.mediaSource),i.inbandTextTracks_={},i.timelineChangeController_=new Fn;var _={vhs:i.vhs_,parse708captions:t.parse708captions,mediaSource:i.mediaSource,currentTime:i.tech_.currentTime.bind(i.tech_),seekable:function(){return i.seekable()},seeking:function(){return i.tech_.seeking()},duration:function(){return i.duration()},hasPlayed:function(){return i.hasPlayed_},goalBufferLength:function(){return i.goalBufferLength()},bandwidth:l,syncController:i.syncController_,decrypter:i.decrypter_,sourceType:i.sourceType_,inbandTextTracks:i.inbandTextTracks_,cacheEncryptionKeys:g,handlePartialData:y,sourceUpdater:i.sourceUpdater_,timelineChangeController:i.timelineChangeController_};return i.masterPlaylistLoader_="dash"===i.sourceType_?new Ct(n,i.vhs_,i.requestOptions_):new x(n,i.vhs_,i.requestOptions_),i.setupMasterPlaylistLoaderListeners_(),i.mainSegmentLoader_=new cn(u.default.mergeOptions(_,{segmentMetadataTrack:i.segmentMetadataTrack_,loaderType:"main"}),t),i.audioSegmentLoader_=new cn(u.default.mergeOptions(_,{loaderType:"audio"}),t),i.subtitleSegmentLoader_=new xn(u.default.mergeOptions(_,{loaderType:"vtt",featuresNativeTextTracks:i.tech_.featuresNativeTextTracks}),t),i.setupSegmentLoaderListeners_(),i.experimentalBufferBasedABR&&(i.masterPlaylistLoader_.one("loadedplaylist",(function(){return i.startABRTimer_()})),i.tech_.on("pause",(function(){return i.stopABRTimer_()})),i.tech_.on("play",(function(){return i.startABRTimer_()}))),Xn.forEach((function(e){i[e+"_"]=Qn.bind(d(i),e);})),i.logger_=ji("MPC"),i.triggeredFmp4Usage=!1,i.masterPlaylistLoader_.load(),i}l(t,e);var i=t.prototype;return i.checkABR_=function(){var e=this.selectPlaylist();this.shouldSwitchToMedia_(e)&&this.masterPlaylistLoader_.media(e);},i.startABRTimer_=function(){var e=this;this.stopABRTimer_(),this.abrTimer_=o.default.setInterval((function(){return e.checkABR_()}),250);},i.stopABRTimer_=function(){this.tech_.scrubbing&&this.tech_.scrubbing()||(o.default.clearInterval(this.abrTimer_),this.abrTimer_=null);},i.setupMasterPlaylistLoaderListeners_=function(){var e=this;this.masterPlaylistLoader_.on("loadedmetadata",(function(){var t=e.masterPlaylistLoader_.media(),i=1.5*t.targetDuration*1e3;J(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){jn[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=zn[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;Wn(n,a),o&&(o.playlistLoader?(n.resyncLoader(),Vn(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(Wn(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(),Vn(o.playlistLoader,a)):Vn(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;J(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"});}));},i.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());},i.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"})),mn.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"}));},i.shouldSwitchToMedia_=function(e){var t=this.masterPlaylistLoader_.media(),i=this.tech_.buffered();return function(e){var t=e.currentPlaylist,i=e.nextPlaylist,n=e.forwardBuffer,r=e.bufferLowWaterLine,a=e.bufferHighWaterLine,s=e.duration,o=e.experimentalBufferBasedABR,d=e.log;if(!i)return u.default.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=o?Ut.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:Ut.MAX_BUFFER_LOW_WATER_LINE;if(sf)&&n>=r){var p=l+" as forwardBuffer >= bufferLowWaterLine ("+n+" >= "+r+")";return o&&(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_})},i.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.delegateLoaders_("all",["abort"]),e.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},120));}));var t=function(){if(!e.sourceUpdater_.hasCreatedSourceBuffers())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();}));},i.mediaSecondsLoaded_=function(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)},i.load=function(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load();},i.smoothQualityChange_=function(e){void 0===e&&(e=this.selectPlaylist()),e!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(e),this.mainSegmentLoader_.resetLoader());},i.fastQualityChange_=function(e){var t=this;void 0===e&&(e=this.selectPlaylist()),e!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(e),this.mainSegmentLoader_.resetEverything((function(){u.default.browser.IE_VERSION||u.default.browser.IS_EDGE?t.tech_.setCurrentTime(t.tech_.currentTime()+.04):t.tech_.setCurrentTime(t.tech_.currentTime());})));},i.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()r.end(0)||r.start(0)>e.end(0)?this.seekable_=r:this.seekable_=u.default.createTimeRanges([[e.start(0)>r.start(0)?e.start(0):r.start(0),e.end(0)0&&(n=Math.max(n,i.end(i.length-1))),this.mediaSource.duration!==n&&this.sourceUpdater_.setDuration(n);}},i.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();},i.master=function(){return this.masterPlaylistLoader_.master},i.media=function(){return this.masterPlaylistLoader_.media()||this.initialMedia_},i.areMediaTypesKnown_=function(){var e=!!this.mediaTypes_.AUDIO.activePlaylistLoader;return !(!this.mainSegmentLoader_.currentMediaInfo_||e&&!this.audioSegmentLoader_.currentMediaInfo_)},i.getCodecsOrExclude_=function(){var e=this,t={main:this.mainSegmentLoader_.currentMediaInfo_||{},audio:this.audioSegmentLoader_.currentMediaInfo_||{}};t.video=t.main;var i=Ki(this.master(),this.media()),n={},r=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(t.main.hasVideo&&(n.video=i.video||t.main.videoCodec||"avc1.4d400d"),t.main.isMuxed&&(n.video+=","+(i.audio||t.main.audioCodec||Gi)),(t.main.hasAudio&&!t.main.isMuxed||t.audio.hasAudio||r)&&(n.audio=i.audio||t.main.audioCodec||t.audio.audioCodec||Gi,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?Vi(o):Hi(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_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){var u=[];if(["video","audio"].forEach((function(t){var i=(Ni(e.sourceUpdater_.codecs[t]||"")[0]||{}).type,r=(Ni(n[t]||"")[0]||{}).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});},i.tryToCreateSourceBuffers_=function(){if("open"===this.mediaSource.readyState&&!this.sourceUpdater_.hasCreatedSourceBuffers()&&this.areMediaTypesKnown_()){var e=this.getCodecsOrExclude_();if(e){this.sourceUpdater_.createSourceBuffers(e);var t=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(t);}}},i.excludeUnsupportedVariants_=function(){var e=this,t=this.master().playlists,i=[];Object.keys(t).forEach((function(n){var r=t[n];if(-1===i.indexOf(r.id)){i.push(r.id);var a=Ki(e.master,r),s=[];!a.audio||Hi(a.audio)||Vi(a.audio)||s.push("audio codec "+a.audio),!a.video||Hi(a.video)||Vi(a.video)||s.push("video codec "+a.video),a.text&&"stpp.ttml.im1t"===a.text&&s.push("text codec "+a.text),s.length&&(r.excludeUntil=1/0,e.logger_("excluding "+r.id+" for unsupported: "+s.join(", ")));}}));},i.excludeIncompatibleVariants_=function(e){var t=this,i=[],n=this.master().playlists,r=Qi(Ni(e)),a=Yi(r),s=r.video&&Ni(r.video)[0]||null,o=r.audio&&Ni(r.audio)[0]||null;Object.keys(n).forEach((function(e){var r=n[e];if(-1===i.indexOf(r.id)&&r.excludeUntil!==1/0){i.push(r.id);var u=[],d=Ki(t.masterPlaylistLoader_.master,r),l=Yi(d);if(d.audio||d.video){if(l!==a&&u.push('codec count "'+l+'" !== "'+a+'"'),!t.sourceUpdater_.canChangeType()){var h=d.video&&Ni(d.video)[0]||null,c=d.audio&&Ni(d.audio)[0]||null;h&&s&&h.type.toLowerCase()!==s.type.toLowerCase()&&u.push('video codec "'+h.type+'" !== "'+s.type+'"'),c&&o&&c.type.toLowerCase()!==o.type.toLowerCase()&&u.push('audio codec "'+c.type+'" !== "'+o.type+'"');}u.length&&(r.excludeUntil=1/0,t.logger_("blacklisting "+r.id+": "+u.join(" && ")));}}}));},i.updateAdCues_=function(e){var t=0,i=this.seekable();i.length&&(t=i.start(0)),function(e,t,i){if(void 0===i&&(i=0),e.segments)for(var n,r=i,a=0;a0&&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=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:M);}if(void 0!==e)return this.logger_("Trying to seek outside of seekable at time "+i+" with seekable range "+q(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.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=N(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)+M;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&&t2)return {start:r,end:a}}return null},e}(),Zn={errorInterval:30,getSource:function(e){return e(this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource())}},er=function e(t,i){var n=0,r=0,a=u.default.mergeOptions(Zn,i);t.ready((function(){t.trigger({type:"usage",name:"vhs-error-reload-initialized"}),t.trigger({type:"usage",name:"hls-error-reload-initialized"});}));var s=function(){r&&t.currentTime(r);},o=function(e){null!=e&&(r=t.duration()!==1/0&&t.currentTime()||0,t.one("loadedmetadata",s),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()-n<1e3*a.errorInterval?(t.trigger({type:"usage",name:"vhs-error-reload-canceled"}),void t.trigger({type:"usage",name:"hls-error-reload-canceled"})):a.getSource&&"function"==typeof a.getSource?(n=Date.now(),a.getSource.call(t,o)):void u.default.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!")},l=function e(){t.off("loadedmetadata",s),t.off("error",d),t.off("dispose",e);};t.on("error",d),t.on("dispose",l),t.reloadSourceOnError=function(i){l(),e(t,i);};},tr=function(e){er(this,e);},ir="2.5.0",nr={PlaylistLoader:x,Playlist:Z,utils:pe,STANDARD_PLAYLIST_SELECTOR:rn,INITIAL_PLAYLIST_SELECTOR:function(){var e=this,t=this.playlists.master.playlists.filter(Z.isEnabled);return en(t,(function(e,t){return tn(e,t)})),t.filter((function(t){return !!Ki(e.playlists.master,t).video}))[0]||null},lastBandwidthSelector:rn,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 i=this.useDevicePixelRatio&&o.default.devicePixelRatio||1;return t<0&&(t=this.systemBandwidth),t=e*this.systemBandwidth+(1-e)*t,nn(this.playlists.master,t,parseInt(Zi(this.tech_.el(),"width"),10)*i,parseInt(Zi(this.tech_.el(),"height"),10)*i,this.limitRenditionByPlayerDimensions)}},comparePlaylistBandwidth:tn,comparePlaylistResolution:function(e,t){var i,n;return e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(i=e.attributes.RESOLUTION.width),i=i||o.default.Number.MAX_VALUE,t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width&&(n=t.attributes.RESOLUTION.width),i===(n=n||o.default.Number.MAX_VALUE)&&e.attributes.BANDWIDTH&&t.attributes.BANDWIDTH?e.attributes.BANDWIDTH-t.attributes.BANDWIDTH:i-n},xhr:ne()};Object.keys(Ut).forEach((function(e){Object.defineProperty(nr,e,{get:function(){return u.default.log.warn("using Vhs."+e+" is UNSAFE be sure you know what you are doing"),Ut[e]},set:function(t){u.default.log.warn("using Vhs."+e+" is UNSAFE be sure you know what you are doing"),"number"!=typeof t||t<0?u.default.log.warn("value of Vhs."+e+" must be greater than or equal to 0"):Ut[e]=t;}});}));var rr="videojs-vhs",ar=function(e,t){for(var i=t.media(),n=-1,r=0;r1&&n.video.split(",").forEach((function(e){e=e.trim(),qi(e)?n.audio=e:function(e){return void 0===e&&(e=""),Ri.video.test(e.trim().toLowerCase())}(e)&&(n.video=e);}));var r=n.video?'video/mp4;codecs="'+n.video+'"':null,a=n.audio?'audio/mp4;codecs="'+n.audio+'"':null,s={};for(var o in e)s[o]={audioContentType:a,videoContentType:r},t.contentProtection&&t.contentProtection[o]&&t.contentProtection[o].pssh&&(s[o].pssh=t.contentProtection[o].pssh),"string"==typeof e[o]&&(s[o].url=e[o]);return u.default.mergeOptions(e,s)},or=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}),[])},ur=function(e){var t=e.player,i=e.sourceKeySystems,n=e.audioMedia,r=e.mainPlaylists;if(!t.eme.initializeMediaKeys)return Promise.resolve();var a=n?r.concat([n]):r,s=or(a,Object.keys(i)),o=[],u=[];return s.forEach((function(e){u.push(new Promise((function(e,i){t.tech_.one("keysessioncreated",e);}))),o.push(new Promise((function(i,n){t.eme.initializeMediaKeys({keySystems:e},(function(e){e?n(e):i();}));})));})),Promise.race([Promise.all(o),Promise.race(u)])},dr=function(e){var t=e.player,i=e.sourceKeySystems,n=e.media,r=e.audioMedia,a=sr(i,n,r);return !(!a||(t.currentSource().keySystems=a,a&&!t.eme&&(u.default.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),1)))},lr=function(){if(!o.default.localStorage)return null;var e=o.default.localStorage.getItem(rr);if(!e)return null;try{return JSON.parse(e)}catch(e){return null}},hr=function(e){return 0===e.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")?JSON.parse(e.substring(e.indexOf(",")+1)):e};nr.supportsNativeHls=function(){if(!s.default||!s.default.createElement)return !1;var e=s.default.createElement("video");return !!u.default.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))}))}(),nr.supportsNativeDash=!!(s.default&&s.default.createElement&&u.default.getTech("Html5").isSupported())&&/maybe|probably/i.test(s.default.createElement("video").canPlayType("application/dash+xml")),nr.supportsTypeNatively=function(e){return "hls"===e?nr.supportsNativeHls:"dash"===e&&nr.supportsNativeDash},nr.isSupported=function(){return u.default.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var cr=function(e){function t(t,i,n){var r;if(r=e.call(this,i,u.default.mergeOptions(n.hls,n.vhs))||this,n.hls&&Object.keys(n.hls).length&&u.default.log.warn("Using hls options is deprecated. Use vhs instead."),r.logger_=ji("VhsHandler"),i.options_&&i.options_.playerId){var a=u.default(i.options_.playerId);a.hasOwnProperty("hls")||Object.defineProperty(a,"hls",{get:function(){return u.default.log.warn("player.hls is deprecated. Use player.tech().vhs instead."),i.trigger({type:"usage",name:"hls-player-access"}),d(r)},configurable:!0}),a.hasOwnProperty("vhs")||Object.defineProperty(a,"vhs",{get:function(){return u.default.log.warn("player.vhs is deprecated. Use player.tech().vhs instead."),i.trigger({type:"usage",name:"vhs-player-access"}),d(r)},configurable:!0}),a.hasOwnProperty("dash")||Object.defineProperty(a,"dash",{get:function(){return u.default.log.warn("player.dash is deprecated. Use player.tech().vhs instead."),d(r)},configurable:!0}),r.player_=a;}if(r.tech_=i,r.source_=t,r.stats={},r.ignoreNextSeekingEvent_=!1,r.setOptions_(),r.options_.overrideNative&&i.overrideNativeAudioTracks&&i.overrideNativeVideoTracks)i.overrideNativeAudioTracks(!0),i.overrideNativeVideoTracks(!0);else if(r.options_.overrideNative&&(i.featuresNativeVideoTracks||i.featuresNativeAudioTracks))throw new Error("Overriding native HLS requires emulated tracks. See https://git.io/vMpjB");return r.on(s.default,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],(function(e){var t=s.default.fullscreenElement||s.default.webkitFullscreenElement||s.default.mozFullScreenElement||s.default.msFullscreenElement;t&&t.contains(r.tech_.el())&&r.masterPlaylistController_.smoothQualityChange_();})),r.on(r.tech_,"seeking",(function(){this.ignoreNextSeekingEvent_?this.ignoreNextSeekingEvent_=!1:this.setCurrentTime(this.tech_.currentTime());})),r.on(r.tech_,"error",(function(){this.tech_.error()&&this.masterPlaylistController_&&this.masterPlaylistController_.pauseLoading();})),r.on(r.tech_,"play",r.play),r}l(t,e);var i=t.prototype;return i.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=lr();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=Ut.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===Ut.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","limitRenditionByPlayerDimensions","bandwidth","smoothQualityChange","customTagParsers","customTagMappers","handleManifestRedirects","cacheEncryptionKeys","handlePartialData","playlistSelector","initialPlaylistSelector","experimentalBufferBasedABR","liveRangeSafeTimeDelta"].forEach((function(t){void 0!==e.source_[t]&&(e.options_[t]=e.source_[t]);})),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio;},i.src=function(e,t){var i=this;if(e){this.setOptions_(),this.options_.src=hr(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=nr,this.options_.sourceType=oe(t),this.options_.seekTo=function(e){i.tech_.setCurrentTime(e);},this.masterPlaylistController_=new Yn(this.options_);var n=u.default.mergeOptions({liveRangeSafeTimeDelta:M},this.options_,{seekable:function(){return i.seekable()},media:function(){return i.masterPlaylistController_.media()},masterPlaylistController:this.masterPlaylistController_});this.playbackWatcher_=new Jn(n),this.masterPlaylistController_.on("error",(function(){var e=u.default.players[i.tech_.options_.playerId],t=i.masterPlaylistController_.error;"object"!=typeof t||t.code?"string"==typeof t&&(t={message:t,code:3}):t.code=3,e.error(t);}));var r=this.options_.experimentalBufferBasedABR?nr.movingAverageBandwidthSelector(.55):nr.STANDARD_PLAYLIST_SELECTOR;this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):r.bind(this),this.masterPlaylistController_.selectInitialPlaylist=nr.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(){u.default.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 i.bandwidth||0},enumerable:!0},mediaRequests:{get:function(){return i.masterPlaylistController_.mediaRequests_()||0},enumerable:!0},mediaRequestsAborted:{get:function(){return i.masterPlaylistController_.mediaRequestsAborted_()||0},enumerable:!0},mediaRequestsTimedout:{get:function(){return i.masterPlaylistController_.mediaRequestsTimedout_()||0},enumerable:!0},mediaRequestsErrored:{get:function(){return i.masterPlaylistController_.mediaRequestsErrored_()||0},enumerable:!0},mediaTransferDuration:{get:function(){return i.masterPlaylistController_.mediaTransferDuration_()||0},enumerable:!0},mediaBytesTransferred:{get:function(){return i.masterPlaylistController_.mediaBytesTransferred_()||0},enumerable:!0},mediaSecondsLoaded:{get:function(){return i.masterPlaylistController_.mediaSecondsLoaded_()||0},enumerable:!0},buffered:{get:function(){return W(i.tech_.buffered())},enumerable:!0},currentTime:{get:function(){return i.tech_.currentTime()},enumerable:!0},currentSource:{get:function(){return i.tech_.currentSource_},enumerable:!0},currentTech:{get:function(){return i.tech_.name_},enumerable:!0},duration:{get:function(){return i.tech_.duration()},enumerable:!0},master:{get:function(){return i.playlists.master},enumerable:!0},playerDimensions:{get:function(){return i.tech_.currentDimensions()},enumerable:!0},seekable:{get:function(){return W(i.tech_.seekable())},enumerable:!0},timestamp:{get:function(){return Date.now()},enumerable:!0},videoPlaybackQuality:{get:function(){return i.tech_.getVideoPlaybackQuality()},enumerable:!0}}),this.tech_.one("canplay",this.masterPlaylistController_.setupFirstPlay.bind(this.masterPlaylistController_)),this.tech_.on("bandwidthupdate",(function(){i.options_.useBandwidthFromLocalStorage&&function(e){if(!o.default.localStorage)return !1;var t=lr();t=t?u.default.mergeOptions(t,e):e;try{o.default.localStorage.setItem(rr,JSON.stringify(t));}catch(e){return !1}}({bandwidth:i.bandwidth,throughput:Math.round(i.throughput)});})),this.masterPlaylistController_.on("selectedinitialmedia",(function(){var e,t;t=(e=i).playlists,e.representations=function(){return t&&t.master&&t.master.playlists?t.master.playlists.filter((function(e){return !Y(e)})).map((function(t,i){return new Kn(e,t,t.id)})):[]};})),this.masterPlaylistController_.sourceUpdater_.on("createdsourcebuffers",(function(){i.setupEme_();})),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_=o.default.URL.createObjectURL(this.masterPlaylistController_.mediaSource),this.tech_.src(this.mediaSourceUrl_));}},i.setupEme_=function(){var e=this,t=this.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader,i=dr({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:t&&t.media()});11!==u.default.browser.IE_VERSION&&i?(this.logger_("waiting for EME key session creation"),ur({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:t&&t.media(),mainPlaylists:this.playlists.master.playlists}).then((function(){e.logger_("created EME key session"),e.masterPlaylistController_.sourceUpdater_.initializedEme();})).catch((function(t){e.logger_("error while creating EME key session",t),e.player_.error({message:"Failed to initialize media keys for EME",code:3});}))):this.masterPlaylistController_.sourceUpdater_.initializedEme();},i.setupQualityLevels_=function(){var e=this,t=u.default.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);})),ar(t,i.playlists);})),this.playlists.on("mediachange",(function(){ar(e.qualityLevels_,e.playlists);})));},t.version=function(){return {"@videojs/http-streaming":ir,"mux.js":"5.9.1","mpd-parser":"0.15.2","m3u8-parser":"4.5.2","aes-decrypter":"3.1.2"}},i.version=function(){return this.constructor.version()},i.canChangeType=function(){return Un.canChangeType()},i.play=function(){this.masterPlaylistController_.play();},i.setCurrentTime=function(e){this.masterPlaylistController_.setCurrentTime(e);},i.duration=function(){return this.masterPlaylistController_.duration()},i.seekable=function(){return this.masterPlaylistController_.seekable()},i.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_&&o.default.URL.revokeObjectURL&&(o.default.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),e.prototype.dispose.call(this);},i.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;rn){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})},i.seekToProgramTime=function(e,t,i,n){return void 0===i&&(i=!0),void 0===n&&(n=2),ge({programTime:e,playlist:this.masterPlaylistController_.media(),retryCount:n,pauseAfterSeek:i,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})},t}(u.default.getComponent("Component")),fr={name:"videojs-http-streaming",VERSION:ir,canHandleSource:function(e,t){void 0===t&&(t={});var i=u.default.mergeOptions(u.default.options,t);return fr.canPlayType(e.type,i)},handleSource:function(e,t,i){void 0===i&&(i={});var n=u.default.mergeOptions(u.default.options,i);return t.vhs=new cr(e,t,n),u.default.hasOwnProperty("hls")||Object.defineProperty(t,"hls",{get:function(){return u.default.log.warn("player.tech().hls is deprecated. Use player.tech().vhs instead."),t.vhs},configurable:!0}),t.vhs.xhr=ne(),t.vhs.src(e.src,e.type),t.vhs},canPlayType:function(e,t){void 0===t&&(t={});var i=u.default.mergeOptions(u.default.options,t).vhs.overrideNative,n=void 0===i?!u.default.browser.IS_ANY_SAFARI:i,r=oe(e);return !r||nr.supportsTypeNatively(r)&&!n?"":"maybe"}};Vi("avc1.4d400d,mp4a.40.2")&&u.default.getTech("Html5").registerSourceHandler(fr,0),u.default.VhsHandler=cr,Object.defineProperty(u.default,"HlsHandler",{get:function(){return u.default.log.warn("videojs.HlsHandler is deprecated. Use videojs.VhsHandler instead."),cr},configurable:!0}),u.default.VhsSourceHandler=fr,Object.defineProperty(u.default,"HlsSourceHandler",{get:function(){return u.default.log.warn("videojs.HlsSourceHandler is deprecated. Use videojs.VhsSourceHandler instead."),fr},configurable:!0}),u.default.Vhs=nr,Object.defineProperty(u.default,"Hls",{get:function(){return u.default.log.warn("videojs.Hls is deprecated. Use videojs.Vhs instead."),nr},configurable:!0}),u.default.use||(u.default.registerComponent("Hls",nr),u.default.registerComponent("Vhs",nr)),u.default.options.vhs=u.default.options.vhs||{},u.default.options.hls=u.default.options.hls||{},u.default.registerPlugin?u.default.registerPlugin("reloadSourceOnError",tr):u.default.plugin("reloadSourceOnError",tr),e.LOCAL_STORAGE_KEY=rr,e.Vhs=nr,e.VhsHandler=cr,e.VhsSourceHandler=fr,e.emeKeySystems=sr,e.expandDataUri=hr,e.getAllPsshKeySystemsOptions=or,e.setupEmeOptions=dr,e.simpleTypeFromSourceType=oe,e.waitForKeySessionCreation=ur,Object.defineProperty(e,"__esModule",{value:!0});})); +/*! @name aes-decrypter @version 3.1.2 @license Apache-2.0 */s(null,(e=d).subarray(0,e.byteLength-e[e.byteLength-1]));}));}return t.prototype.decryptChunk_=function(e,t,i,r){return function(){var s=function(e,t,i){var r,s,o,u,d,l,h,c,f,m=new Int32Array(e.buffer,e.byteOffset,e.byteLength>>2),p=new n(Array.prototype.slice.call(t)),g=new Uint8Array(e.byteLength),y=new Int32Array(g.buffer);for(r=i[0],s=i[1],o=i[2],u=i[3],f=0;f=0&&(t="main-desc"),t},xn=function(e,t){e.abort(),e.pause(),t&&t.activePlaylistLoader&&(t.activePlaylistLoader.pause(),t.activePlaylistLoader=null);},Rn=function(e,t){t.activePlaylistLoader=e,e.load();},Mn={AUDIO:function(e,t){return function(){var i=t.segmentLoaders[e],n=t.mediaTypes[e],r=t.blacklistCurrentPlaylist;xn(i,n);var a=n.activeTrack(),s=n.activeGroup(),o=(s.filter((function(e){return e.default}))[0]||s[0]).id,d=n.tracks[o];if(a!==d){for(var l in u.default.log.warn("Problem encountered loading the alternate audio track.Switching back to default."),n.tracks)n.tracks[l].enabled=n.tracks[l]===d;n.onTrackChanged();}else r({message:"Problem encountered loading the default audio track."});}},SUBTITLES:function(e,t){return function(){var i=t.segmentLoaders[e],n=t.mediaTypes[e];u.default.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),xn(i,n);var r=n.activeTrack();r&&(r.mode="disabled"),n.onTrackChanged();}}},Bn={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",Mn[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",Mn[e](e,i));}},Fn={AUDIO:function(e,t){var i=t.vhs,n=t.sourceType,r=t.segmentLoaders[e],a=t.requestOptions,s=t.master,o=s.mediaGroups,d=s.playlists,l=t.mediaTypes[e],h=l.groups,c=l.tracks,f=t.masterPlaylistLoader;o[e]&&0!==Object.keys(o[e]).length||(o[e]={main:{default:{default:!0}}});var m=function(r){h[r]||(h[r]=[]);var s=d.filter((function(t){return t.attributes[e]===r})),l=function(d){var l=o[e][r][d];!s.filter((function(e){return e.resolvedUri!==l.resolvedUri})).length&&s.length&&delete l.resolvedUri;var m;if(m="vhs-json"===n&&l.playlists?new M(l.playlists[0],i,a):l.resolvedUri?new M(l.resolvedUri,i,a):l.playlists&&"dash"===n?new Ut(l.playlists[0],i,a,f):null,l=u.default.mergeOptions({id:d,playlistLoader:m},l),Bn[e](e,l.playlistLoader,t),h[r].push(l),void 0===c[d]){var p=new u.default.AudioTrack({id:d,kind:Dn(l),enabled:!1,language:l.language,default:l.default,label:d});c[d]=p;}};for(var m in o[e][r])l(m);};for(var p in o[e])m(p);r.on("error",Mn[e](e,t));},SUBTITLES:function(e,t){var i=t.tech,n=t.vhs,r=t.sourceType,a=t.segmentLoaders[e],s=t.requestOptions,o=t.master.mediaGroups,d=t.mediaTypes[e],l=d.groups,h=d.tracks,c=t.masterPlaylistLoader;for(var f in o[e])for(var m in l[f]||(l[f]=[]),o[e][f])if(!o[e][f][m].forced){var p=o[e][f][m],g=void 0;if("hls"===r)g=new M(p.resolvedUri,n,s);else if("dash"===r){if(!p.playlists.filter((function(e){return e.excludeUntil!==1/0})).length)return;g=new Ut(p.playlists[0],n,s,c);}else "vhs-json"===r&&(g=new M(p.playlists?p.playlists[0]:p.resolvedUri,n,s));if(p=u.default.mergeOptions({id:m,playlistLoader:g},p),Bn[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;}}a.on("error",Mn[e](e,t));},"CLOSED-CAPTIONS":function(e,t){var i=t.tech,n=t.master.mediaGroups,r=t.mediaTypes[e],a=r.groups,s=r.tracks;for(var o in n[e])for(var d in a[o]||(a[o]=[]),n[e][o]){var l=n[e][o][d];if(l.instreamId.match(/CC\d/)&&(a[o].push(u.default.mergeOptions({id:d},l)),void 0===s[d])){var h=i.addRemoteTextTrack({id:l.instreamId,kind:"captions",default:l.default&&l.autoselect,language:l.language,label:d},!1).track;s[d]=h;}}}},Nn={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}}},qn=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],Wn=function(e){return this.audioSegmentLoader_[e]+this.mainSegmentLoader_[e]},Vn=function(e){function t(t){var i;i=e.call(this)||this;var n=t.src,r=t.handleManifestRedirects,a=t.withCredentials,s=t.tech,l=t.bandwidth,h=t.externVhs,c=t.useCueTags,f=t.blacklistDuration,m=t.enableLowInitialPlaylist,p=t.sourceType,y=t.cacheEncryptionKeys,v=t.handlePartialData,_=t.experimentalBufferBasedABR;if(!n)throw new Error("A non-empty playlist URL or JSON manifest string is required");on=h,i.experimentalBufferBasedABR=Boolean(_),i.withCredentials=a,i.tech_=s,i.vhs_=s.vhs,i.sourceType_=p,i.useCueTags_=c,i.blacklistDuration=f,i.enableLowInitialPlaylist=m,i.useCueTags_&&(i.cueTagsTrack_=i.tech_.addTextTrack("metadata","ad-cues"),i.cueTagsTrack_.inBandMetadataTrackDispatchType=""),i.requestOptions_={withCredentials:a,handleManifestRedirects:r,timeout:null},i.on("error",i.pauseLoading),i.mediaTypes_=function(){var e={};return ["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((function(t){e[t]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:sn,activeTrack:sn,onGroupChanged:sn,onTrackChanged:sn};})),e}(),i.mediaSource=new o.default.MediaSource,i.handleDurationChange_=i.handleDurationChange_.bind(d(i)),i.handleSourceOpen_=i.handleSourceOpen_.bind(d(i)),i.handleSourceEnded_=i.handleSourceEnded_.bind(d(i)),i.mediaSource.addEventListener("durationchange",i.handleDurationChange_),i.mediaSource.addEventListener("sourceopen",i.handleSourceOpen_),i.mediaSource.addEventListener("sourceended",i.handleSourceEnded_),i.seekable_=u.default.createTimeRanges(),i.hasPlayed_=!1,i.syncController_=new On(t),i.segmentMetadataTrack_=s.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,i.decrypter_=new Un,i.sourceUpdater_=new wn(i.mediaSource),i.inbandTextTracks_={},i.timelineChangeController_=new Cn;var T={vhs:i.vhs_,parse708captions:t.parse708captions,mediaSource:i.mediaSource,currentTime:i.tech_.currentTime.bind(i.tech_),seekable:function(){return i.seekable()},seeking:function(){return i.tech_.seeking()},duration:function(){return i.duration()},hasPlayed:function(){return i.hasPlayed_},goalBufferLength:function(){return i.goalBufferLength()},bandwidth:l,syncController:i.syncController_,decrypter:i.decrypter_,sourceType:i.sourceType_,inbandTextTracks:i.inbandTextTracks_,cacheEncryptionKeys:y,handlePartialData:v,sourceUpdater:i.sourceUpdater_,timelineChangeController:i.timelineChangeController_};return i.masterPlaylistLoader_="dash"===i.sourceType_?new Ut(n,i.vhs_,i.requestOptions_):new M(n,i.vhs_,i.requestOptions_),i.setupMasterPlaylistLoaderListeners_(),i.mainSegmentLoader_=new an(u.default.mergeOptions(T,{segmentMetadataTrack:i.segmentMetadataTrack_,loaderType:"main"}),t),i.audioSegmentLoader_=new an(u.default.mergeOptions(T,{loaderType:"audio"}),t),i.subtitleSegmentLoader_=new An(u.default.mergeOptions(T,{loaderType:"vtt",featuresNativeTextTracks:i.tech_.featuresNativeTextTracks}),t),i.setupSegmentLoaderListeners_(),i.experimentalBufferBasedABR&&(i.masterPlaylistLoader_.one("loadedplaylist",(function(){return i.startABRTimer_()})),i.tech_.on("pause",(function(){return i.stopABRTimer_()})),i.tech_.on("play",(function(){return i.startABRTimer_()}))),qn.forEach((function(e){i[e+"_"]=Wn.bind(d(i),e);})),i.logger_=g("MPC"),i.triggeredFmp4Usage=!1,"none"===i.tech_.preload()?(i.loadOnPlay_=function(){i.loadOnPlay_=null,i.masterPlaylistLoader_.load();},i.tech_.one("play",i.loadOnPlay_)):i.masterPlaylistLoader_.load(),i}l(t,e);var i=t.prototype;return i.checkABR_=function(){var e=this.selectPlaylist();this.shouldSwitchToMedia_(e)&&this.masterPlaylistLoader_.media(e);},i.startABRTimer_=function(){var e=this;this.stopABRTimer_(),this.abrTimer_=o.default.setInterval((function(){return e.checkABR_()}),250);},i.stopABRTimer_=function(){this.tech_.scrubbing&&this.tech_.scrubbing()||(o.default.clearInterval(this.abrTimer_),this.abrTimer_=null);},i.setupMasterPlaylistLoaderListeners_=function(){var e=this;this.masterPlaylistLoader_.on("loadedmetadata",(function(){var t=e.masterPlaylistLoader_.media(),i=1.5*t.targetDuration*1e3;ee(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){Fn[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=Nn[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;xn(n,a),o&&(o.playlistLoader?(n.resyncLoader(),Rn(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(xn(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(),Rn(o.playlistLoader,a)):Rn(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(){e.loadOnPlay_&&e.tech_.off("play",e.loadOnPlay_);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;ee(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"});}));},i.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());},i.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"})),on.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"}));},i.shouldSwitchToMedia_=function(e){var t=this.masterPlaylistLoader_.media(),i=this.tech_.buffered();return function(e){var t=e.currentPlaylist,i=e.nextPlaylist,n=e.forwardBuffer,r=e.bufferLowWaterLine,a=e.bufferHighWaterLine,s=e.duration,o=e.experimentalBufferBasedABR,d=e.log;if(!i)return u.default.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=o?Dt.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:Dt.MAX_BUFFER_LOW_WATER_LINE;if(sf)&&n>=r){var p=l+" as forwardBuffer >= bufferLowWaterLine ("+n+" >= "+r+")";return o&&(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_})},i.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.delegateLoaders_("all",["abort"]),e.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},120));}));var t=function(){if(!e.sourceUpdater_.hasCreatedSourceBuffers())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();}));},i.mediaSecondsLoaded_=function(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)},i.load=function(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load();},i.smoothQualityChange_=function(e){void 0===e&&(e=this.selectPlaylist()),e!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(e),this.mainSegmentLoader_.resetLoader());},i.fastQualityChange_=function(e){var t=this;void 0===e&&(e=this.selectPlaylist()),e!==this.masterPlaylistLoader_.media()?(this.masterPlaylistLoader_.media(e),this.mainSegmentLoader_.resetEverything((function(){u.default.browser.IE_VERSION||u.default.browser.IS_EDGE?t.tech_.setCurrentTime(t.tech_.currentTime()+.04):t.tech_.setCurrentTime(t.tech_.currentTime());}))):this.logger_("skipping fastQualityChange because new media is same as old");},i.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()r.end(0)||r.start(0)>e.end(0)?this.seekable_=r:this.seekable_=u.default.createTimeRanges([[e.start(0)>r.start(0)?e.start(0):r.start(0),e.end(0)0&&(n=Math.max(n,i.end(i.length-1))),this.mediaSource.duration!==n&&this.sourceUpdater_.setDuration(n);}},i.dispose=function(){var e=this;this.trigger("dispose"),this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_),["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();},i.master=function(){return this.masterPlaylistLoader_.master},i.media=function(){return this.masterPlaylistLoader_.media()||this.initialMedia_},i.areMediaTypesKnown_=function(){var e=!!this.mediaTypes_.AUDIO.activePlaylistLoader;return !(!this.mainSegmentLoader_.currentMediaInfo_||e&&!this.audioSegmentLoader_.currentMediaInfo_)},i.getCodecsOrExclude_=function(){var e=this,t={main:this.mainSegmentLoader_.currentMediaInfo_||{},audio:this.audioSegmentLoader_.currentMediaInfo_||{}};t.video=t.main;var i=Hi(this.master(),this.media()),n={},r=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(t.main.hasVideo&&(n.video=i.video||t.main.videoCodec||"avc1.4d400d"),t.main.isMuxed&&(n.video+=","+(i.audio||t.main.audioCodec||Fi)),(t.main.hasAudio&&!t.main.isMuxed||t.audio.hasAudio||r)&&(n.audio=i.audio||t.main.audioCodec||t.audio.audioCodec||Fi,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):Bi(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_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){var u=[];if(["video","audio"].forEach((function(t){var i=(Di(e.sourceUpdater_.codecs[t]||"")[0]||{}).type,r=(Di(n[t]||"")[0]||{}).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});},i.tryToCreateSourceBuffers_=function(){if("open"===this.mediaSource.readyState&&!this.sourceUpdater_.hasCreatedSourceBuffers()&&this.areMediaTypesKnown_()){var e=this.getCodecsOrExclude_();if(e){this.sourceUpdater_.createSourceBuffers(e);var t=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(t);}}},i.excludeUnsupportedVariants_=function(){var e=this,t=this.master().playlists,i=[];Object.keys(t).forEach((function(n){var r=t[n];if(-1===i.indexOf(r.id)){i.push(r.id);var a=Hi(e.master,r),s=[];!a.audio||Bi(a.audio)||Mi(a.audio)||s.push("audio codec "+a.audio),!a.video||Bi(a.video)||Mi(a.video)||s.push("video codec "+a.video),a.text&&"stpp.ttml.im1t"===a.text&&s.push("text codec "+a.text),s.length&&(r.excludeUntil=1/0,e.logger_("excluding "+r.id+" for unsupported: "+s.join(", ")));}}));},i.excludeIncompatibleVariants_=function(e){var t=this,i=[],n=this.master().playlists,r=Wi(Di(e)),a=Vi(r),s=r.video&&Di(r.video)[0]||null,o=r.audio&&Di(r.audio)[0]||null;Object.keys(n).forEach((function(e){var r=n[e];if(-1===i.indexOf(r.id)&&r.excludeUntil!==1/0){i.push(r.id);var u=[],d=Hi(t.masterPlaylistLoader_.master,r),l=Vi(d);if(d.audio||d.video){if(l!==a&&u.push('codec count "'+l+'" !== "'+a+'"'),!t.sourceUpdater_.canChangeType()){var h=d.video&&Di(d.video)[0]||null,c=d.audio&&Di(d.audio)[0]||null;h&&s&&h.type.toLowerCase()!==s.type.toLowerCase()&&u.push('video codec "'+h.type+'" !== "'+s.type+'"'),c&&o&&c.type.toLowerCase()!==o.type.toLowerCase()&&u.push('audio codec "'+c.type+'" !== "'+o.type+'"');}u.length&&(r.excludeUntil=1/0,t.logger_("blacklisting "+r.id+": "+u.join(" && ")));}}}));},i.updateAdCues_=function(e){var t=0,i=this.seekable();i.length&&(t=i.start(0)),function(e,t,i){if(void 0===i&&(i=0),e.segments)for(var n,r=i,a=0;a0&&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=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:F);}if(void 0!==e)return this.logger_("Trying to seek outside of seekable at time "+i+" with seekable range "+V(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.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=W(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)+F;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&&t2)return {start:r,end:a}}return null},e}(),zn={errorInterval:30,getSource:function(e){return e(this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource())}},Xn=function e(t,i){var n=0,r=0,a=u.default.mergeOptions(zn,i);t.ready((function(){t.trigger({type:"usage",name:"vhs-error-reload-initialized"}),t.trigger({type:"usage",name:"hls-error-reload-initialized"});}));var s=function(){r&&t.currentTime(r);},o=function(e){null!=e&&(r=t.duration()!==1/0&&t.currentTime()||0,t.one("loadedmetadata",s),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()-n<1e3*a.errorInterval?(t.trigger({type:"usage",name:"vhs-error-reload-canceled"}),void t.trigger({type:"usage",name:"hls-error-reload-canceled"})):a.getSource&&"function"==typeof a.getSource?(n=Date.now(),a.getSource.call(t,o)):void u.default.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!")},l=function e(){t.off("loadedmetadata",s),t.off("error",d),t.off("dispose",e);};t.on("error",d),t.on("dispose",l),t.reloadSourceOnError=function(i){l(),e(t,i);};},Qn=function(e){Xn(this,e);},Yn="2.6.1",Kn={PlaylistLoader:M,Playlist:te,utils:ye,STANDARD_PLAYLIST_SELECTOR:Ki,INITIAL_PLAYLIST_SELECTOR:function(){var e=this,t=this.playlists.master.playlists.filter(te.isEnabled);return Xi(t,(function(e,t){return Qi(e,t)})),t.filter((function(t){return !!Hi(e.playlists.master,t).video}))[0]||null},lastBandwidthSelector:Ki,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 i=this.useDevicePixelRatio&&o.default.devicePixelRatio||1;return t<0&&(t=this.systemBandwidth),t=e*this.systemBandwidth+(1-e)*t,Yi(this.playlists.master,t,parseInt(zi(this.tech_.el(),"width"),10)*i,parseInt(zi(this.tech_.el(),"height"),10)*i,this.limitRenditionByPlayerDimensions)}},comparePlaylistBandwidth:Qi,comparePlaylistResolution:function(e,t){var i,n;return e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(i=e.attributes.RESOLUTION.width),i=i||o.default.Number.MAX_VALUE,t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width&&(n=t.attributes.RESOLUTION.width),i===(n=n||o.default.Number.MAX_VALUE)&&e.attributes.BANDWIDTH&&t.attributes.BANDWIDTH?e.attributes.BANDWIDTH-t.attributes.BANDWIDTH:i-n},xhr:ae()};Object.keys(Dt).forEach((function(e){Object.defineProperty(Kn,e,{get:function(){return u.default.log.warn("using Vhs."+e+" is UNSAFE be sure you know what you are doing"),Dt[e]},set:function(t){u.default.log.warn("using Vhs."+e+" is UNSAFE be sure you know what you are doing"),"number"!=typeof t||t<0?u.default.log.warn("value of Vhs."+e+" must be greater than or equal to 0"):Dt[e]=t;}});}));var $n="videojs-vhs",Jn=function(e,t){for(var i=t.media(),n=-1,r=0;r1&&n.video.split(",").forEach((function(e){e=e.trim(),xi(e)?n.audio=e:function(e){return void 0===e&&(e=""),Pi.video.test(e.trim().toLowerCase())}(e)&&(n.video=e);}));var r=n.video?'video/mp4;codecs="'+n.video+'"':null,a=n.audio?'audio/mp4;codecs="'+n.audio+'"':null,s={};for(var o in e)s[o]={audioContentType:a,videoContentType:r},t.contentProtection&&t.contentProtection[o]&&t.contentProtection[o].pssh&&(s[o].pssh=t.contentProtection[o].pssh),"string"==typeof e[o]&&(s[o].url=e[o]);return u.default.mergeOptions(e,s)},er=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}),[])},tr=function(e){var t=e.player,i=e.sourceKeySystems,n=e.audioMedia,r=e.mainPlaylists;if(!t.eme.initializeMediaKeys)return Promise.resolve();var a=n?r.concat([n]):r,s=er(a,Object.keys(i)),o=[],u=[];return s.forEach((function(e){u.push(new Promise((function(e,i){t.tech_.one("keysessioncreated",e);}))),o.push(new Promise((function(i,n){t.eme.initializeMediaKeys({keySystems:e},(function(e){e?n(e):i();}));})));})),Promise.race([Promise.all(o),Promise.race(u)])},ir=function(e){var t=e.player,i=e.sourceKeySystems,n=e.media,r=e.audioMedia,a=Zn(i,n,r);return !(!a||(t.currentSource().keySystems=a,a&&!t.eme&&(u.default.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),1)))},nr=function(){if(!o.default.localStorage)return null;var e=o.default.localStorage.getItem($n);if(!e)return null;try{return JSON.parse(e)}catch(e){return null}},rr=function(e){return 0===e.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")?JSON.parse(e.substring(e.indexOf(",")+1)):e};Kn.supportsNativeHls=function(){if(!s.default||!s.default.createElement)return !1;var e=s.default.createElement("video");return !!u.default.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))}))}(),Kn.supportsNativeDash=!!(s.default&&s.default.createElement&&u.default.getTech("Html5").isSupported())&&/maybe|probably/i.test(s.default.createElement("video").canPlayType("application/dash+xml")),Kn.supportsTypeNatively=function(e){return "hls"===e?Kn.supportsNativeHls:"dash"===e&&Kn.supportsNativeDash},Kn.isSupported=function(){return u.default.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var ar=function(e){function t(t,i,n){var r;if(r=e.call(this,i,u.default.mergeOptions(n.hls,n.vhs))||this,n.hls&&Object.keys(n.hls).length&&u.default.log.warn("Using hls options is deprecated. Use vhs instead."),r.logger_=g("VhsHandler"),i.options_&&i.options_.playerId){var a=u.default(i.options_.playerId);a.hasOwnProperty("hls")||Object.defineProperty(a,"hls",{get:function(){return u.default.log.warn("player.hls is deprecated. Use player.tech().vhs instead."),i.trigger({type:"usage",name:"hls-player-access"}),d(r)},configurable:!0}),a.hasOwnProperty("vhs")||Object.defineProperty(a,"vhs",{get:function(){return u.default.log.warn("player.vhs is deprecated. Use player.tech().vhs instead."),i.trigger({type:"usage",name:"vhs-player-access"}),d(r)},configurable:!0}),a.hasOwnProperty("dash")||Object.defineProperty(a,"dash",{get:function(){return u.default.log.warn("player.dash is deprecated. Use player.tech().vhs instead."),d(r)},configurable:!0}),r.player_=a;}if(r.tech_=i,r.source_=t,r.stats={},r.ignoreNextSeekingEvent_=!1,r.setOptions_(),r.options_.overrideNative&&i.overrideNativeAudioTracks&&i.overrideNativeVideoTracks)i.overrideNativeAudioTracks(!0),i.overrideNativeVideoTracks(!0);else if(r.options_.overrideNative&&(i.featuresNativeVideoTracks||i.featuresNativeAudioTracks))throw new Error("Overriding native HLS requires emulated tracks. See https://git.io/vMpjB");return r.on(s.default,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],(function(e){var t=s.default.fullscreenElement||s.default.webkitFullscreenElement||s.default.mozFullScreenElement||s.default.msFullscreenElement;t&&t.contains(r.tech_.el())&&r.masterPlaylistController_.smoothQualityChange_();})),r.on(r.tech_,"seeking",(function(){this.ignoreNextSeekingEvent_?this.ignoreNextSeekingEvent_=!1:this.setCurrentTime(this.tech_.currentTime());})),r.on(r.tech_,"error",(function(){this.tech_.error()&&this.masterPlaylistController_&&this.masterPlaylistController_.pauseLoading();})),r.on(r.tech_,"play",r.play),r}l(t,e);var i=t.prototype;return i.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=nr();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=Dt.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===Dt.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","limitRenditionByPlayerDimensions","bandwidth","smoothQualityChange","customTagParsers","customTagMappers","handleManifestRedirects","cacheEncryptionKeys","handlePartialData","playlistSelector","initialPlaylistSelector","experimentalBufferBasedABR","liveRangeSafeTimeDelta"].forEach((function(t){void 0!==e.source_[t]&&(e.options_[t]=e.source_[t]);})),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio;},i.src=function(e,t){var i=this;if(e){this.setOptions_(),this.options_.src=rr(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=Kn,this.options_.sourceType=de(t),this.options_.seekTo=function(e){i.tech_.setCurrentTime(e);},this.masterPlaylistController_=new Vn(this.options_);var n=u.default.mergeOptions({liveRangeSafeTimeDelta:F},this.options_,{seekable:function(){return i.seekable()},media:function(){return i.masterPlaylistController_.media()},masterPlaylistController:this.masterPlaylistController_});this.playbackWatcher_=new jn(n),this.masterPlaylistController_.on("error",(function(){var e=u.default.players[i.tech_.options_.playerId],t=i.masterPlaylistController_.error;"object"!=typeof t||t.code?"string"==typeof t&&(t={message:t,code:3}):t.code=3,e.error(t);}));var r=this.options_.experimentalBufferBasedABR?Kn.movingAverageBandwidthSelector(.55):Kn.STANDARD_PLAYLIST_SELECTOR;this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):r.bind(this),this.masterPlaylistController_.selectInitialPlaylist=Kn.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(){u.default.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 i.bandwidth||0},enumerable:!0},mediaRequests:{get:function(){return i.masterPlaylistController_.mediaRequests_()||0},enumerable:!0},mediaRequestsAborted:{get:function(){return i.masterPlaylistController_.mediaRequestsAborted_()||0},enumerable:!0},mediaRequestsTimedout:{get:function(){return i.masterPlaylistController_.mediaRequestsTimedout_()||0},enumerable:!0},mediaRequestsErrored:{get:function(){return i.masterPlaylistController_.mediaRequestsErrored_()||0},enumerable:!0},mediaTransferDuration:{get:function(){return i.masterPlaylistController_.mediaTransferDuration_()||0},enumerable:!0},mediaBytesTransferred:{get:function(){return i.masterPlaylistController_.mediaBytesTransferred_()||0},enumerable:!0},mediaSecondsLoaded:{get:function(){return i.masterPlaylistController_.mediaSecondsLoaded_()||0},enumerable:!0},buffered:{get:function(){return H(i.tech_.buffered())},enumerable:!0},currentTime:{get:function(){return i.tech_.currentTime()},enumerable:!0},currentSource:{get:function(){return i.tech_.currentSource_},enumerable:!0},currentTech:{get:function(){return i.tech_.name_},enumerable:!0},duration:{get:function(){return i.tech_.duration()},enumerable:!0},master:{get:function(){return i.playlists.master},enumerable:!0},playerDimensions:{get:function(){return i.tech_.currentDimensions()},enumerable:!0},seekable:{get:function(){return H(i.tech_.seekable())},enumerable:!0},timestamp:{get:function(){return Date.now()},enumerable:!0},videoPlaybackQuality:{get:function(){return i.tech_.getVideoPlaybackQuality()},enumerable:!0}}),this.tech_.one("canplay",this.masterPlaylistController_.setupFirstPlay.bind(this.masterPlaylistController_)),this.tech_.on("bandwidthupdate",(function(){i.options_.useBandwidthFromLocalStorage&&function(e){if(!o.default.localStorage)return !1;var t=nr();t=t?u.default.mergeOptions(t,e):e;try{o.default.localStorage.setItem($n,JSON.stringify(t));}catch(e){return !1}}({bandwidth:i.bandwidth,throughput:Math.round(i.throughput)});})),this.masterPlaylistController_.on("selectedinitialmedia",(function(){var e,t;t=(e=i).playlists,e.representations=function(){return t&&t.master&&t.master.playlists?t.master.playlists.filter((function(e){return !$(e)})).map((function(t,i){return new Hn(e,t,t.id)})):[]};})),this.masterPlaylistController_.sourceUpdater_.on("createdsourcebuffers",(function(){i.setupEme_();})),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_=o.default.URL.createObjectURL(this.masterPlaylistController_.mediaSource),this.tech_.src(this.mediaSourceUrl_));}},i.setupEme_=function(){var e=this,t=this.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader,i=ir({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:t&&t.media()});11!==u.default.browser.IE_VERSION&&i?(this.logger_("waiting for EME key session creation"),tr({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:t&&t.media(),mainPlaylists:this.playlists.master.playlists}).then((function(){e.logger_("created EME key session"),e.masterPlaylistController_.sourceUpdater_.initializedEme();})).catch((function(t){e.logger_("error while creating EME key session",t),e.player_.error({message:"Failed to initialize media keys for EME",code:3});}))):this.masterPlaylistController_.sourceUpdater_.initializedEme();},i.setupQualityLevels_=function(){var e=this,t=u.default.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);})),Jn(t,i.playlists);})),this.playlists.on("mediachange",(function(){Jn(e.qualityLevels_,e.playlists);})));},t.version=function(){return {"@videojs/http-streaming":Yn,"mux.js":"5.9.1","mpd-parser":"0.15.2","m3u8-parser":"4.5.2","aes-decrypter":"3.1.2"}},i.version=function(){return this.constructor.version()},i.canChangeType=function(){return wn.canChangeType()},i.play=function(){this.masterPlaylistController_.play();},i.setCurrentTime=function(e){this.masterPlaylistController_.setCurrentTime(e);},i.duration=function(){return this.masterPlaylistController_.duration()},i.seekable=function(){return this.masterPlaylistController_.seekable()},i.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_&&o.default.URL.revokeObjectURL&&(o.default.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),e.prototype.dispose.call(this);},i.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;rn){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})},i.seekToProgramTime=function(e,t,i,n){return void 0===i&&(i=!0),void 0===n&&(n=2),ve({programTime:e,playlist:this.masterPlaylistController_.media(),retryCount:n,pauseAfterSeek:i,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})},t}(u.default.getComponent("Component")),sr={name:"videojs-http-streaming",VERSION:Yn,canHandleSource:function(e,t){void 0===t&&(t={});var i=u.default.mergeOptions(u.default.options,t);return sr.canPlayType(e.type,i)},handleSource:function(e,t,i){void 0===i&&(i={});var n=u.default.mergeOptions(u.default.options,i);return t.vhs=new ar(e,t,n),u.default.hasOwnProperty("hls")||Object.defineProperty(t,"hls",{get:function(){return u.default.log.warn("player.tech().hls is deprecated. Use player.tech().vhs instead."),t.vhs},configurable:!0}),t.vhs.xhr=ae(),t.vhs.src(e.src,e.type),t.vhs},canPlayType:function(e,t){void 0===t&&(t={});var i=u.default.mergeOptions(u.default.options,t).vhs.overrideNative,n=void 0===i?!u.default.browser.IS_ANY_SAFARI:i,r=de(e);return !r||Kn.supportsTypeNatively(r)&&!n?"":"maybe"}};Mi("avc1.4d400d,mp4a.40.2")&&u.default.getTech("Html5").registerSourceHandler(sr,0),u.default.VhsHandler=ar,Object.defineProperty(u.default,"HlsHandler",{get:function(){return u.default.log.warn("videojs.HlsHandler is deprecated. Use videojs.VhsHandler instead."),ar},configurable:!0}),u.default.VhsSourceHandler=sr,Object.defineProperty(u.default,"HlsSourceHandler",{get:function(){return u.default.log.warn("videojs.HlsSourceHandler is deprecated. Use videojs.VhsSourceHandler instead."),sr},configurable:!0}),u.default.Vhs=Kn,Object.defineProperty(u.default,"Hls",{get:function(){return u.default.log.warn("videojs.Hls is deprecated. Use videojs.Vhs instead."),Kn},configurable:!0}),u.default.use||(u.default.registerComponent("Hls",Kn),u.default.registerComponent("Vhs",Kn)),u.default.options.vhs=u.default.options.vhs||{},u.default.options.hls=u.default.options.hls||{},u.default.registerPlugin?u.default.registerPlugin("reloadSourceOnError",Qn):u.default.plugin("reloadSourceOnError",Qn),e.LOCAL_STORAGE_KEY=$n,e.Vhs=Kn,e.VhsHandler=ar,e.VhsSourceHandler=sr,e.emeKeySystems=Zn,e.expandDataUri=rr,e.getAllPsshKeySystemsOptions=er,e.setupEmeOptions=ir,e.simpleTypeFromSourceType=de,e.waitForKeySessionCreation=tr,Object.defineProperty(e,"__esModule",{value:!0});})); }); var videojsHttpStreaming_min$1 = /*@__PURE__*/getDefaultExportFromCjs(videojsHttpStreaming_min);