13 lines
257 KiB
JavaScript
13 lines
257 KiB
JavaScript
typeof window!="undefined"&&function(R,T){typeof exports=="object"&&typeof module=="object"?module.exports=T():typeof define=="function"&&define.amd?define([],T):typeof exports=="object"?exports.Hls=T():R.Hls=T()}(this,function(){return function(w){var R={};function T(_){if(R[_])return R[_].exports;var A=R[_]={i:_,l:!1,exports:{}};return w[_].call(A.exports,A,A.exports,T),A.l=!0,A.exports}return T.m=w,T.c=R,T.d=function(_,A,m){T.o(_,A)||Object.defineProperty(_,A,{enumerable:!0,get:m})},T.r=function(_){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(_,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(_,"__esModule",{value:!0})},T.t=function(_,A){if(A&1&&(_=T(_)),A&8||A&4&&typeof _=="object"&&_&&_.__esModule)return _;var m=Object.create(null);if(T.r(m),Object.defineProperty(m,"default",{enumerable:!0,value:_}),A&2&&typeof _!="string")for(var y in _)T.d(m,y,function(f){return _[f]}.bind(null,y));return m},T.n=function(_){var A=_&&_.__esModule?function(){return _.default}:function(){return _};return T.d(A,"a",A),A},T.o=function(_,A){return Object.prototype.hasOwnProperty.call(_,A)},T.p="/dist/",T(T.s="./src/hls.js")}({"./node_modules/eventemitter3/index.js":function(w,R,T){"use strict";var _=Object.prototype.hasOwnProperty,A="~";function m(){}Object.create&&(m.prototype=Object.create(null),new m().__proto__||(A=!1));function y(c,a,o){this.fn=c,this.context=a,this.once=o||!1}function f(c,a,o,r,i){if(typeof o!="function")throw new TypeError("The listener must be a function");var t=new y(o,r||c,i),e=A?A+a:a;return c._events[e]?c._events[e].fn?c._events[e]=[c._events[e],t]:c._events[e].push(t):(c._events[e]=t,c._eventsCount++),c}function u(c,a){--c._eventsCount==0?c._events=new m:delete c._events[a]}function p(){this._events=new m,this._eventsCount=0}p.prototype.eventNames=function(){var a=[],o,r;if(this._eventsCount===0)return a;for(r in o=this._events)_.call(o,r)&&a.push(A?r.slice(1):r);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(o)):a},p.prototype.listeners=function(a){var o=A?A+a:a,r=this._events[o];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,t=r.length,e=new Array(t);i<t;i++)e[i]=r[i].fn;return e},p.prototype.listenerCount=function(a){var o=A?A+a:a,r=this._events[o];return r?r.fn?1:r.length:0},p.prototype.emit=function(a,o,r,i,t,e){var n=A?A+a:a;if(!this._events[n])return!1;var d=this._events[n],g=arguments.length,v,s;if(d.fn){switch(d.once&&this.removeListener(a,d.fn,void 0,!0),g){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,o),!0;case 3:return d.fn.call(d.context,o,r),!0;case 4:return d.fn.call(d.context,o,r,i),!0;case 5:return d.fn.call(d.context,o,r,i,t),!0;case 6:return d.fn.call(d.context,o,r,i,t,e),!0}for(s=1,v=new Array(g-1);s<g;s++)v[s-1]=arguments[s];d.fn.apply(d.context,v)}else{var l=d.length,x;for(s=0;s<l;s++)switch(d[s].once&&this.removeListener(a,d[s].fn,void 0,!0),g){case 1:d[s].fn.call(d[s].context);break;case 2:d[s].fn.call(d[s].context,o);break;case 3:d[s].fn.call(d[s].context,o,r);break;case 4:d[s].fn.call(d[s].context,o,r,i);break;default:if(!v)for(x=1,v=new Array(g-1);x<g;x++)v[x-1]=arguments[x];d[s].fn.apply(d[s].context,v)}}return!0},p.prototype.on=function(a,o,r){return f(this,a,o,r,!1)},p.prototype.once=function(a,o,r){return f(this,a,o,r,!0)},p.prototype.removeListener=function(a,o,r,i){var t=A?A+a:a;if(!this._events[t])return this;if(!o)return u(this,t),this;var e=this._events[t];if(e.fn)e.fn===o&&(!i||e.once)&&(!r||e.context===r)&&u(this,t);else{for(var n=0,d=[],g=e.length;n<g;n++)(e[n].fn!==o||i&&!e[n].once||r&&e[n].context!==r)&&d.push(e[n]);d.length?this._events[t]=d.length===1?d[0]:d:u(this,t)}return this},p.prototype.removeAllListeners=function(a){var o;return a?(o=A?A+a:a,this._events[o]&&u(this,o)):(this._events=new m,this._eventsCount=0),this},p.prototype.off=p.prototype.removeListener,p.prototype.addListener=p.prototype.on,p.prefixed=A,p.EventEmitter=p,w.exports=p},"./node_modules/node-libs-browser/node_modules/events/events.js":function(w,R){function T(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}w.exports=T,T.EventEmitter=T,T.prototype._events=void 0,T.prototype._maxListeners=void 0,T.defaultMaxListeners=10,T.prototype.setMaxListeners=function(f){if(!A(f)||f<0||isNaN(f))throw TypeError("n must be a positive number");return this._maxListeners=f,this},T.prototype.emit=function(f){var u,p,c,a,o,r;if(this._events||(this._events={}),f==="error"&&(!this._events.error||m(this._events.error)&&!this._events.error.length)){if(u=arguments[1],u instanceof Error)throw u;var i=new Error('Uncaught, unspecified "error" event. ('+u+")");throw i.context=u,i}if(p=this._events[f],y(p))return!1;if(_(p))switch(arguments.length){case 1:p.call(this);break;case 2:p.call(this,arguments[1]);break;case 3:p.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),p.apply(this,a)}else if(m(p))for(a=Array.prototype.slice.call(arguments,1),r=p.slice(),c=r.length,o=0;o<c;o++)r[o].apply(this,a);return!0},T.prototype.addListener=function(f,u){var p;if(!_(u))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",f,_(u.listener)?u.listener:u),this._events[f]?m(this._events[f])?this._events[f].push(u):this._events[f]=[this._events[f],u]:this._events[f]=u,m(this._events[f])&&!this._events[f].warned&&(y(this._maxListeners)?p=T.defaultMaxListeners:p=this._maxListeners,p&&p>0&&this._events[f].length>p&&(this._events[f].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[f].length),typeof console.trace=="function"&&console.trace())),this},T.prototype.on=T.prototype.addListener,T.prototype.once=function(f,u){if(!_(u))throw TypeError("listener must be a function");var p=!1;function c(){this.removeListener(f,c),p||(p=!0,u.apply(this,arguments))}return c.listener=u,this.on(f,c),this},T.prototype.removeListener=function(f,u){var p,c,a,o;if(!_(u))throw TypeError("listener must be a function");if(!this._events||!this._events[f])return this;if(p=this._events[f],a=p.length,c=-1,p===u||_(p.listener)&&p.listener===u)delete this._events[f],this._events.removeListener&&this.emit("removeListener",f,u);else if(m(p)){for(o=a;o-- >0;)if(p[o]===u||p[o].listener&&p[o].listener===u){c=o;break}if(c<0)return this;p.length===1?(p.length=0,delete this._events[f]):p.splice(c,1),this._events.removeListener&&this.emit("removeListener",f,u)}return this},T.prototype.removeAllListeners=function(f){var u,p;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[f]&&delete this._events[f],this;if(arguments.length===0){for(u in this._events)u!=="removeListener"&&this.removeAllListeners(u);return this.removeAllListeners("removeListener"),this._events={},this}if(p=this._events[f],_(p))this.removeListener(f,p);else if(p)for(;p.length;)this.removeListener(f,p[p.length-1]);return delete this._events[f],this},T.prototype.listeners=function(f){var u;return!this._events||!this._events[f]?u=[]:_(this._events[f])?u=[this._events[f]]:u=this._events[f].slice(),u},T.prototype.listenerCount=function(f){if(this._events){var u=this._events[f];if(_(u))return 1;if(u)return u.length}return 0},T.listenerCount=function(f,u){return f.listenerCount(u)};function _(f){return typeof f=="function"}function A(f){return typeof f=="number"}function m(f){return typeof f=="object"&&f!==null}function y(f){return f===void 0}},"./node_modules/url-toolkit/src/url-toolkit.js":function(w,R,T){(function(_){var A=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,m=/^([^\/?#]*)(.*)$/,y=/(?:\/|^)\.(?=\/)/g,f=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,u={buildAbsoluteURL:function(p,c,a){if(a=a||{},p=p.trim(),c=c.trim(),!c){if(!a.alwaysNormalize)return p;var o=u.parseURL(p);if(!o)throw new Error("Error trying to parse base URL.");return o.path=u.normalizePath(o.path),u.buildURLFromParts(o)}var r=u.parseURL(c);if(!r)throw new Error("Error trying to parse relative URL.");if(r.scheme)return a.alwaysNormalize?(r.path=u.normalizePath(r.path),u.buildURLFromParts(r)):c;var i=u.parseURL(p);if(!i)throw new Error("Error trying to parse base URL.");if(!i.netLoc&&i.path&&i.path[0]!=="/"){var t=m.exec(i.path);i.netLoc=t[1],i.path=t[2]}i.netLoc&&!i.path&&(i.path="/");var e={scheme:i.scheme,netLoc:r.netLoc,path:null,params:r.params,query:r.query,fragment:r.fragment};if(!r.netLoc&&(e.netLoc=i.netLoc,r.path[0]!=="/"))if(!r.path)e.path=i.path,r.params||(e.params=i.params,r.query||(e.query=i.query));else{var n=i.path,d=n.substring(0,n.lastIndexOf("/")+1)+r.path;e.path=u.normalizePath(d)}return e.path===null&&(e.path=a.alwaysNormalize?u.normalizePath(r.path):r.path),u.buildURLFromParts(e)},parseURL:function(p){var c=A.exec(p);return c?{scheme:c[1]||"",netLoc:c[2]||"",path:c[3]||"",params:c[4]||"",query:c[5]||"",fragment:c[6]||""}:null},normalizePath:function(p){for(p=p.split("").reverse().join("").replace(y,"");p.length!==(p=p.replace(f,"")).length;);return p.split("").reverse().join("")},buildURLFromParts:function(p){return p.scheme+p.netLoc+p.path+p.params+p.query+p.fragment}};w.exports=u})(this)},"./node_modules/webworkify-webpack/index.js":function(w,R,T){function _(a){var o={};function r(t){if(o[t])return o[t].exports;var e=o[t]={i:t,l:!1,exports:{}};return a[t].call(e.exports,e,e.exports,r),e.l=!0,e.exports}r.m=a,r.c=o,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/",r.oe=function(t){throw console.error(t),t};var i=r(r.s=ENTRY_MODULE);return i.default||i}var A="[\\.|\\-|\\+|\\w|/|@]+",m="\\((/\\*.*?\\*/)?s?.*?("+A+").*?\\)";function y(a){return(a+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function f(a){return!isNaN(1*a)}function u(a,o,r){var i={};i[r]=[];var t=o.toString(),e=t.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!e)return i;for(var n=e[1],d=new RegExp("(\\\\n|\\W)"+y(n)+m,"g"),g;g=d.exec(t);)g[3]!=="dll-reference"&&i[r].push(g[3]);for(d=new RegExp("\\("+y(n)+'\\("(dll-reference\\s('+A+'))"\\)\\)'+m,"g");g=d.exec(t);)a[g[2]]||(i[r].push(g[1]),a[g[2]]=T(g[1]).m),i[g[2]]=i[g[2]]||[],i[g[2]].push(g[4]);for(var v=Object.keys(i),s=0;s<v.length;s++)for(var l=0;l<i[v[s]].length;l++)f(i[v[s]][l])&&(i[v[s]][l]=1*i[v[s]][l]);return i}function p(a){var o=Object.keys(a);return o.reduce(function(r,i){return r||a[i].length>0},!1)}function c(a,o){for(var r={main:[o]},i={main:[]},t={main:{}};p(r);)for(var e=Object.keys(r),n=0;n<e.length;n++){var d=e[n],g=r[d],v=g.pop();if(t[d]=t[d]||{},!(t[d][v]||!a[d][v])){t[d][v]=!0,i[d]=i[d]||[],i[d].push(v);for(var s=u(a,a[d][v],d),l=Object.keys(s),x=0;x<l.length;x++)r[l[x]]=r[l[x]]||[],r[l[x]]=r[l[x]].concat(s[l[x]])}}return i}w.exports=function(a,o){o=o||{};var r={main:T.m},i=o.all?{main:Object.keys(r.main)}:c(r,a),t="";Object.keys(i).filter(function(v){return v!=="main"}).forEach(function(v){for(var s=0;i[v][s];)s++;i[v].push(s),r[v][s]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",t=t+"var "+v+" = ("+_.toString().replace("ENTRY_MODULE",JSON.stringify(s))+")({"+i[v].map(function(l){return""+JSON.stringify(l)+": "+r[v][l].toString()}).join(",")+`});
|
|
`}),t=t+"new (("+_.toString().replace("ENTRY_MODULE",JSON.stringify(a))+")({"+i.main.map(function(v){return""+JSON.stringify(v)+": "+r.main[v].toString()}).join(",")+"}))(self);";var e=new window.Blob([t],{type:"text/javascript"});if(o.bare)return e;var n=window.URL||window.webkitURL||window.mozURL||window.msURL,d=n.createObjectURL(e),g=new window.Worker(d);return g.objectURL=d,g}},"./src/config.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/controller/abr-controller.js"),A=T("./src/controller/buffer-controller.js"),m=T("./src/controller/cap-level-controller.js"),y=T("./src/controller/fps-controller.js"),f=T("./src/utils/xhr-loader.js"),u=T("./src/controller/audio-track-controller.js"),p=T("./src/controller/audio-stream-controller.js"),c=T("./src/utils/cues.js"),a=T("./src/controller/timeline-controller.js"),o=T("./src/controller/subtitle-track-controller.js"),r=T("./src/controller/subtitle-stream-controller.js"),i=T("./src/controller/eme-controller.js"),t=T("./src/utils/mediakeys-helper.js");R.hlsDefaultConfig={autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,maxBufferSize:60*1e3*1e3,maxBufferHole:.5,lowBufferWatchdogPeriod:.5,highBufferWatchdogPeriod:3,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:Infinity,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,liveDurationInfinity:!1,liveBackBufferLength:Infinity,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:f.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,abrController:_.default,bufferController:A.default,capLevelController:m.default,fpsController:y.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,requestMediaKeySystemAccessFunc:t.requestMediaKeySystemAccess},R.hlsDefaultConfig.subtitleStreamController=r.SubtitleStreamController,R.hlsDefaultConfig.subtitleTrackController=o.default,R.hlsDefaultConfig.timelineController=a.default,R.hlsDefaultConfig.cueHandler=c,R.hlsDefaultConfig.enableCEA708Captions=!0,R.hlsDefaultConfig.enableWebVTT=!0,R.hlsDefaultConfig.captionsTextTrack1Label="English",R.hlsDefaultConfig.captionsTextTrack1LanguageCode="en",R.hlsDefaultConfig.captionsTextTrack2Label="Spanish",R.hlsDefaultConfig.captionsTextTrack2LanguageCode="es",R.hlsDefaultConfig.audioStreamController=p.default,R.hlsDefaultConfig.audioTrackController=u.default,R.hlsDefaultConfig.emeController=i.default},"./src/controller/abr-controller.js":function(w,R,T){"use strict";(function(_){var A=this&&this.__extends||function(){var r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,t){i.__proto__=t}||function(i,t){for(var e in t)t.hasOwnProperty(e)&&(i[e]=t[e])};return function(i,t){r(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}}();Object.defineProperty(R,"__esModule",{value:!0});var m=T("./src/events.js"),y=T("./src/event-handler.js"),f=T("./src/utils/buffer-helper.js"),u=T("./src/errors.js"),p=T("./src/utils/logger.js"),c=T("./src/utils/ewma-bandwidth-estimator.js"),a=window.performance,o=function(r){A(i,r);function i(t){var e=r.call(this,t,m.default.FRAG_LOADING,m.default.FRAG_LOADED,m.default.FRAG_BUFFERED,m.default.ERROR)||this;return e.lastLoadedFragLevel=0,e._nextAutoLevel=-1,e.hls=t,e.timer=null,e._bwEstimator=null,e.onCheck=e._abandonRulesCheck.bind(e),e}return i.prototype.destroy=function(){this.clearTimer(),y.default.prototype.destroy.call(this)},i.prototype.onFragLoading=function(t){var e=t.frag;if(e.type==="main"&&(this.timer||(this.fragCurrent=e,this.timer=setInterval(this.onCheck,100)),!this._bwEstimator)){var n=this.hls,d=n.config,g=e.level,v=n.levels[g].details.live,s=void 0,l=void 0;v?(s=d.abrEwmaFastLive,l=d.abrEwmaSlowLive):(s=d.abrEwmaFastVoD,l=d.abrEwmaSlowVoD),this._bwEstimator=new c.default(n,l,s,d.abrEwmaDefaultEstimate)}},i.prototype._abandonRulesCheck=function(){var t=this.hls,e=t.media,n=this.fragCurrent;if(!!n){var d=n.loader,g=t.minAutoLevel;if(!d||d.stats&&d.stats.aborted){p.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}var v=d.stats;if(e&&v&&(!e.paused&&e.playbackRate!==0||!e.readyState)&&n.autoLevel&&n.level){var s=a.now()-v.trequest,l=Math.abs(e.playbackRate);if(s>500*n.duration/l){var x=t.levels,h=Math.max(1,v.bw?v.bw/8:v.loaded*1e3/s),E=x[n.level],S=E.realBitrate?Math.max(E.realBitrate,E.bitrate):E.bitrate,b=v.total?v.total:Math.max(v.loaded,Math.round(n.duration*S/8)),I=e.currentTime,L=(b-v.loaded)/h,D=(f.BufferHelper.bufferInfo(e,I,t.config.maxBufferHole).end-I)/l;if(D<2*n.duration/l&&L>D){var O=void 0,F=void 0;for(F=n.level-1;F>g;F--){var C=x[F].realBitrate?Math.max(x[F].realBitrate,x[F].bitrate):x[F].bitrate;if(O=n.duration*C/(8*.8*h),O<D)break}O<L&&(p.logger.warn("loading too slow, abort fragment loading and switch to level "+F+":fragLoadedDelay["+F+"]<fragLoadedDelay["+(n.level-1)+"];bufferStarvationDelay:"+O.toFixed(1)+"<"+L.toFixed(1)+":"+D.toFixed(1)),t.nextLoadLevel=F,this._bwEstimator.sample(s,v.loaded),d.abort(),this.clearTimer(),t.trigger(m.default.FRAG_LOAD_EMERGENCY_ABORTED,{frag:n,stats:v}))}}}}},i.prototype.onFragLoaded=function(t){var e=t.frag;if(e.type==="main"&&_.isFinite(e.sn)){if(this.clearTimer(),this.lastLoadedFragLevel=e.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var n=this.hls.levels[e.level],d=(n.loaded?n.loaded.bytes:0)+t.stats.loaded,g=(n.loaded?n.loaded.duration:0)+t.frag.duration;n.loaded={bytes:d,duration:g},n.realBitrate=Math.round(8*d/g)}if(t.frag.bitrateTest){var v=t.stats;v.tparsed=v.tbuffered=v.tload,this.onFragBuffered(t)}}},i.prototype.onFragBuffered=function(t){var e=t.stats,n=t.frag;if(e.aborted!==!0&&n.type==="main"&&_.isFinite(n.sn)&&(!n.bitrateTest||e.tload===e.tbuffered)){var d=e.tparsed-e.trequest;p.logger.log("latency/loading/parsing/append/kbps:"+Math.round(e.tfirst-e.trequest)+"/"+Math.round(e.tload-e.tfirst)+"/"+Math.round(e.tparsed-e.tload)+"/"+Math.round(e.tbuffered-e.tparsed)+"/"+Math.round(8*e.loaded/(e.tbuffered-e.trequest))),this._bwEstimator.sample(d,e.loaded),e.bwEstimate=this._bwEstimator.getEstimate(),n.bitrateTest?this.bitrateTestDelay=d/1e3:this.bitrateTestDelay=0}},i.prototype.onError=function(t){switch(t.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},i.prototype.clearTimer=function(){clearInterval(this.timer),this.timer=null},Object.defineProperty(i.prototype,"nextAutoLevel",{get:function(){var t=this._nextAutoLevel,e=this._bwEstimator;if(t!==-1&&(!e||!e.canEstimate()))return t;var n=this._nextABRAutoLevel;return t!==-1&&(n=Math.min(t,n)),n},set:function(t){this._nextAutoLevel=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"_nextABRAutoLevel",{get:function(){var t=this.hls,e=t.maxAutoLevel,n=t.levels,d=t.config,g=t.minAutoLevel,v=t.media,s=this.lastLoadedFragLevel,l=this.fragCurrent?this.fragCurrent.duration:0,x=v?v.currentTime:0,h=v&&v.playbackRate!==0?Math.abs(v.playbackRate):1,E=this._bwEstimator?this._bwEstimator.getEstimate():d.abrEwmaDefaultEstimate,S=(f.BufferHelper.bufferInfo(v,x,d.maxBufferHole).end-x)/h,b=this._findBestLevel(s,l,E,g,e,S,d.abrBandWidthFactor,d.abrBandWidthUpFactor,n);if(b>=0)return b;p.logger.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var I=l?Math.min(l,d.maxStarvationDelay):d.maxStarvationDelay,L=d.abrBandWidthFactor,D=d.abrBandWidthUpFactor;if(S===0){var O=this.bitrateTestDelay;if(O){var F=l?Math.min(l,d.maxLoadingDelay):d.maxLoadingDelay;I=F-O,p.logger.trace("bitrate test took "+Math.round(1e3*O)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*I)+" ms"),L=D=1}}return b=this._findBestLevel(s,l,E,g,e,S+I,L,D,n),Math.max(b,0)},enumerable:!0,configurable:!0}),i.prototype._findBestLevel=function(t,e,n,d,g,v,s,l,x){for(var h=g;h>=d;h--){var E=x[h];if(!!E){var S=E.details,b=S?S.totalduration/S.fragments.length:e,I=S?S.live:!1,L=void 0;h<=t?L=s*n:L=l*n;var D=x[h].realBitrate?Math.max(x[h].realBitrate,x[h].bitrate):x[h].bitrate,O=D*b/L;if(p.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+h+"/"+Math.round(L)+"/"+D+"/"+b+"/"+v+"/"+O),L>D&&(!O||I&&!this.bitrateTestDelay||O<v))return h}}return-1},i}(y.default);R.default=o}).call(this,T("./src/polyfills/number.js").Number)},"./src/controller/audio-stream-controller.js":function(w,R,T){"use strict";(function(_){var A=this&&this.__extends||function(){var v=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(s,l){s.__proto__=l}||function(s,l){for(var x in l)l.hasOwnProperty(x)&&(s[x]=l[x])};return function(s,l){v(s,l);function x(){this.constructor=s}s.prototype=l===null?Object.create(l):(x.prototype=l.prototype,new x)}}();Object.defineProperty(R,"__esModule",{value:!0});var m=T("./src/utils/binary-search.js"),y=T("./src/utils/buffer-helper.js"),f=T("./src/demux/demuxer.js"),u=T("./src/events.js"),p=T("./src/controller/level-helper.js"),c=T("./src/utils/time-ranges.js"),a=T("./src/errors.js"),o=T("./src/utils/logger.js"),r=T("./src/utils/discontinuities.js"),i=T("./src/controller/fragment-tracker.js"),t=T("./src/loader/fragment.js"),e=T("./src/controller/base-stream-controller.js"),n=window.performance,d=100,g=function(v){A(s,v);function s(l,x){var h=v.call(this,l,u.default.MEDIA_ATTACHED,u.default.MEDIA_DETACHING,u.default.AUDIO_TRACKS_UPDATED,u.default.AUDIO_TRACK_SWITCHING,u.default.AUDIO_TRACK_LOADED,u.default.KEY_LOADED,u.default.FRAG_LOADED,u.default.FRAG_PARSING_INIT_SEGMENT,u.default.FRAG_PARSING_DATA,u.default.FRAG_PARSED,u.default.ERROR,u.default.BUFFER_RESET,u.default.BUFFER_CREATED,u.default.BUFFER_APPENDED,u.default.BUFFER_FLUSHED,u.default.INIT_PTS_FOUND)||this;return h.fragmentTracker=x,h.config=l.config,h.audioCodecSwap=!1,h._state=e.State.STOPPED,h.initPTS=[],h.waitingFragment=null,h.videoTrackCC=null,h}return s.prototype.onInitPtsFound=function(l){var x=l.id,h=l.frag.cc,E=l.initPTS;x==="main"&&(this.initPTS[h]=E,this.videoTrackCC=h,o.logger.log("InitPTS for cc: "+h+" found from video track: "+E),this.state===e.State.WAITING_INIT_PTS&&this.tick())},s.prototype.startLoad=function(l){if(this.tracks){var x=this.lastCurrentTime;this.stopLoad(),this.setInterval(d),this.fragLoadError=0,x>0&&l===-1?(o.logger.log("audio:override startPosition with lastCurrentTime @"+x.toFixed(3)),this.state=e.State.IDLE):(this.lastCurrentTime=this.startPosition?this.startPosition:l,this.state=e.State.STARTING),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else this.startPosition=l,this.state=e.State.STOPPED},Object.defineProperty(s.prototype,"state",{get:function(){return this._state},set:function(l){if(this.state!==l){var x=this.state;this._state=l,o.logger.log("audio stream:"+x+"->"+l)}},enumerable:!0,configurable:!0}),s.prototype.doTick=function(){var l,x,h,E=this.hls,S=E.config;switch(this.state){case e.State.ERROR:case e.State.PAUSED:case e.State.BUFFER_FLUSHING:break;case e.State.STARTING:this.state=e.State.WAITING_TRACK,this.loadedmetadata=!1;break;case e.State.IDLE:var b=this.tracks;if(!b||!this.media&&(this.startFragRequested||!S.startFragPrefetch))break;if(this.loadedmetadata)l=this.media.currentTime;else if(l=this.nextLoadPosition,l===void 0)break;var I=this.mediaBuffer?this.mediaBuffer:this.media,L=this.videoBuffer?this.videoBuffer:this.media,D=y.BufferHelper.bufferInfo(I,l,S.maxBufferHole),O=y.BufferHelper.bufferInfo(L,l,S.maxBufferHole),F=D.len,C=D.end,P=this.fragPrevious,k=Math.min(S.maxBufferLength,S.maxMaxBufferLength),B=Math.max(k,O.len),M=this.audioSwitch,N=this.trackId;if((F<B||M)&&N<b.length){if(h=b[N].details,typeof h=="undefined"){this.state=e.State.WAITING_TRACK;break}if(!M&&this._streamEnded(D,h)){this.hls.trigger(u.default.BUFFER_EOS,{type:"audio"}),this.state=e.State.ENDED;return}var j=h.fragments,K=j.length,G=j[0].start,W=j[K-1].start+j[K-1].duration,U=void 0;if(M){if(h.live&&!h.PTSKnown)o.logger.log("switching audiotrack, live stream, unknown PTS,load first fragment"),C=0;else if(C=l,h.PTSKnown&&l<G)if(D.end>G||D.nextStart)o.logger.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=G+.05;else return}if(h.initSegment&&!h.initSegment.data)U=h.initSegment;else if(C<=G){if(U=j[0],this.videoTrackCC!==null&&U.cc!==this.videoTrackCC&&(U=r.findFragWithCC(j,this.videoTrackCC)),h.live&&U.loadIdx&&U.loadIdx===this.fragLoadIdx){var V=D.nextStart?D.nextStart:G;o.logger.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(V+.05)),this.media.currentTime=V+.05;return}}else{var H=void 0,Y=S.maxFragLookUpTolerance,z=P?j[P.sn-j[0].sn+1]:void 0,X=function(q){var Q=Math.min(Y,q.duration);return q.start+q.duration-Q<=C?1:q.start-Q>C&&q.start?-1:0};C<W?(C>W-Y&&(Y=0),z&&!X(z)?H=z:H=m.default.search(j,X)):H=j[K-1],H&&(U=H,G=H.start,P&&U.level===P.level&&U.sn===P.sn&&(U.sn<h.endSN?(U=j[U.sn+1-h.startSN],o.logger.log("SN just loaded, load next one: "+U.sn)):U=null))}U&&(U.encrypted?(o.logger.log("Loading key for "+U.sn+" of ["+h.startSN+" ,"+h.endSN+"],track "+N),this.state=e.State.KEY_LOADING,E.trigger(u.default.KEY_LOADING,{frag:U})):(o.logger.log("Loading "+U.sn+", cc: "+U.cc+" of ["+h.startSN+" ,"+h.endSN+"],track "+N+", currentTime:"+l+",bufferEnd:"+C.toFixed(3)),this.fragCurrent=U,(M||this.fragmentTracker.getState(U)===i.FragmentState.NOT_LOADED)&&(this.startFragRequested=!0,_.isFinite(U.sn)&&(this.nextLoadPosition=U.start+U.duration),E.trigger(u.default.FRAG_LOADING,{frag:U}),this.state=e.State.FRAG_LOADING)))}break;case e.State.WAITING_TRACK:x=this.tracks[this.trackId],x&&x.details&&(this.state=e.State.IDLE);break;case e.State.FRAG_LOADING_WAITING_RETRY:var ee=n.now(),te=this.retryDate;I=this.media;var re=I&&I.seeking;(!te||ee>=te||re)&&(o.logger.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=e.State.IDLE);break;case e.State.WAITING_INIT_PTS:var $=this.videoTrackCC;if(this.initPTS[$]===void 0)break;var Z=this.waitingFragment;if(Z){var ie=Z.frag.cc;$!==ie?(x=this.tracks[this.trackId],x.details&&x.details.live&&(o.logger.warn("Waiting fragment CC ("+ie+") does not match video track CC ("+$+")"),this.waitingFragment=null,this.state=e.State.IDLE)):(this.state=e.State.FRAG_LOADING,this.onFragLoaded(this.waitingFragment),this.waitingFragment=null)}else this.state=e.State.IDLE;break;case e.State.STOPPED:case e.State.FRAG_LOADING:case e.State.PARSING:case e.State.PARSED:case e.State.ENDED:break;default:break}},s.prototype.onMediaAttached=function(l){var x=this.media=this.mediaBuffer=l.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),x.addEventListener("seeking",this.onvseeking),x.addEventListener("ended",this.onvended);var h=this.config;this.tracks&&h.autoStartLoad&&this.startLoad(h.startPosition)},s.prototype.onMediaDetaching=function(){var l=this.media;l&&l.ended&&(o.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),l&&(l.removeEventListener("seeking",this.onvseeking),l.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1,this.stopLoad()},s.prototype.onAudioTracksUpdated=function(l){o.logger.log("audio tracks updated"),this.tracks=l.audioTracks},s.prototype.onAudioTrackSwitching=function(l){var x=!!l.url;this.trackId=l.id,this.fragCurrent=null,this.state=e.State.PAUSED,this.waitingFragment=null,x?this.setInterval(d):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),x&&(this.audioSwitch=!0,this.state=e.State.IDLE),this.tick()},s.prototype.onAudioTrackLoaded=function(l){var x=l.details,h=l.id,E=this.tracks[h],S=x.totalduration,b=0;if(o.logger.log("track "+h+" loaded ["+x.startSN+","+x.endSN+"],duration:"+S),x.live){var I=E.details;I&&x.fragments.length>0?(p.mergeDetails(I,x),b=x.fragments[0].start,x.PTSKnown?o.logger.log("live audio playlist sliding:"+b.toFixed(3)):o.logger.log("live audio playlist - outdated PTS, unknown sliding")):(x.PTSKnown=!1,o.logger.log("live audio playlist - first load, unknown sliding"))}else x.PTSKnown=!1;if(E.details=x,!this.startFragRequested){if(this.startPosition===-1){var L=x.startTimeOffset;_.isFinite(L)?(o.logger.log("start time offset found in playlist, adjust startPosition to "+L),this.startPosition=L):this.startPosition=0}this.nextLoadPosition=this.startPosition}this.state===e.State.WAITING_TRACK&&(this.state=e.State.IDLE),this.tick()},s.prototype.onKeyLoaded=function(){this.state===e.State.KEY_LOADING&&(this.state=e.State.IDLE,this.tick())},s.prototype.onFragLoaded=function(l){var x=this.fragCurrent,h=l.frag;if(this.state===e.State.FRAG_LOADING&&x&&h.type==="audio"&&h.level===x.level&&h.sn===x.sn){var E=this.tracks[this.trackId],S=E.details,b=S.totalduration,I=x.level,L=x.sn,D=x.cc,O=this.config.defaultAudioCodec||E.audioCodec||"mp4a.40.2",F=this.stats=l.stats;if(L==="initSegment")this.state=e.State.IDLE,F.tparsed=F.tbuffered=n.now(),S.initSegment.data=l.payload,this.hls.trigger(u.default.FRAG_BUFFERED,{stats:F,frag:x,id:"audio"}),this.tick();else{this.state=e.State.PARSING,this.appended=!1,this.demuxer||(this.demuxer=new f.default(this.hls,"audio"));var C=this.initPTS[D],P=S.initSegment?S.initSegment.data:[];if(S.initSegment||C!==void 0){this.pendingBuffering=!0,o.logger.log("Demuxing "+L+" of ["+S.startSN+" ,"+S.endSN+"],track "+I);var k=!1;this.demuxer.push(l.payload,P,O,null,x,b,k,C)}else o.logger.log("unknown video PTS for continuity counter "+D+", waiting for video PTS before demuxing audio frag "+L+" of ["+S.startSN+" ,"+S.endSN+"],track "+I),this.waitingFragment=l,this.state=e.State.WAITING_INIT_PTS}}this.fragLoadError=0},s.prototype.onFragParsingInitSegment=function(l){var x=this.fragCurrent,h=l.frag;if(x&&l.id==="audio"&&h.sn===x.sn&&h.level===x.level&&this.state===e.State.PARSING){var E=l.tracks,S=void 0;if(E.video&&delete E.video,S=E.audio,S){S.levelCodec=S.codec,S.id=l.id,this.hls.trigger(u.default.BUFFER_CODECS,E),o.logger.log("audio track:audio,container:"+S.container+",codecs[level/parsed]=["+S.levelCodec+"/"+S.codec+"]");var b=S.initSegment;if(b){var I={type:"audio",data:b,parent:"audio",content:"initSegment"};this.audioSwitch?this.pendingData=[I]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(u.default.BUFFER_APPENDING,I))}this.tick()}}},s.prototype.onFragParsingData=function(l){var x=this,h=this.fragCurrent,E=l.frag;if(h&&l.id==="audio"&&l.type==="audio"&&E.sn===h.sn&&E.level===h.level&&this.state===e.State.PARSING){var S=this.trackId,b=this.tracks[S],I=this.hls;_.isFinite(l.endPTS)||(l.endPTS=l.startPTS+h.duration,l.endDTS=l.startDTS+h.duration),h.addElementaryStream(t.default.ElementaryStreamTypes.AUDIO),o.logger.log("parsed "+l.type+",PTS:["+l.startPTS.toFixed(3)+","+l.endPTS.toFixed(3)+"],DTS:["+l.startDTS.toFixed(3)+"/"+l.endDTS.toFixed(3)+"],nb:"+l.nb),p.updateFragPTSDTS(b.details,h,l.startPTS,l.endPTS);var L=this.audioSwitch,D=this.media,O=!1;if(L&&D)if(D.readyState){var F=D.currentTime;o.logger.log("switching audio track : currentTime:"+F),F>=l.startPTS&&(o.logger.log("switching audio track : flushing all audio"),this.state=e.State.BUFFER_FLUSHING,I.trigger(u.default.BUFFER_FLUSHING,{startOffset:0,endOffset:_.POSITIVE_INFINITY,type:"audio"}),O=!0,this.audioSwitch=!1,I.trigger(u.default.AUDIO_TRACK_SWITCHED,{id:S}))}else this.audioSwitch=!1,I.trigger(u.default.AUDIO_TRACK_SWITCHED,{id:S});var C=this.pendingData;if(!C){o.logger.warn("Apparently attempt to enqueue media payload without codec initialization data upfront"),I.trigger(u.default.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:null,fatal:!0});return}this.audioSwitch||([l.data1,l.data2].forEach(function(P){P&&P.length&&C.push({type:l.type,data:P,parent:"audio",content:"data"})}),!O&&C.length&&(C.forEach(function(P){x.state===e.State.PARSING&&(x.pendingBuffering=!0,x.hls.trigger(u.default.BUFFER_APPENDING,P))}),this.pendingData=[],this.appended=!0)),this.tick()}},s.prototype.onFragParsed=function(l){var x=this.fragCurrent,h=l.frag;x&&l.id==="audio"&&h.sn===x.sn&&h.level===x.level&&this.state===e.State.PARSING&&(this.stats.tparsed=n.now(),this.state=e.State.PARSED,this._checkAppendedParsed())},s.prototype.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},s.prototype.onBufferCreated=function(l){var x=l.tracks.audio;x&&(this.mediaBuffer=x.buffer,this.loadedmetadata=!0),l.tracks.video&&(this.videoBuffer=l.tracks.video.buffer)},s.prototype.onBufferAppended=function(l){if(l.parent==="audio"){var x=this.state;(x===e.State.PARSING||x===e.State.PARSED)&&(this.pendingBuffering=l.pending>0,this._checkAppendedParsed())}},s.prototype._checkAppendedParsed=function(){if(this.state===e.State.PARSED&&(!this.appended||!this.pendingBuffering)){var l=this.fragCurrent,x=this.stats,h=this.hls;if(l){this.fragPrevious=l,x.tbuffered=n.now(),h.trigger(u.default.FRAG_BUFFERED,{stats:x,frag:l,id:"audio"});var E=this.mediaBuffer?this.mediaBuffer:this.media;o.logger.log("audio buffered : "+c.default.toString(E.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,h.trigger(u.default.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=e.State.IDLE}this.tick()}},s.prototype.onError=function(l){var x=l.frag;if(!(x&&x.type!=="audio"))switch(l.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:var h=l.frag;if(h&&h.type!=="audio")break;if(!l.fatal){var E=this.fragLoadError;E?E++:E=1;var S=this.config;if(E<=S.fragLoadingMaxRetry){this.fragLoadError=E;var b=Math.min(Math.pow(2,E-1)*S.fragLoadingRetryDelay,S.fragLoadingMaxRetryTimeout);o.logger.warn("AudioStreamController: frag loading failed, retry in "+b+" ms"),this.retryDate=n.now()+b,this.state=e.State.FRAG_LOADING_WAITING_RETRY}else o.logger.error("AudioStreamController: "+l.details+" reaches max retry, redispatch as fatal ..."),l.fatal=!0,this.state=e.State.ERROR}break;case a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case a.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case a.ErrorDetails.KEY_LOAD_ERROR:case a.ErrorDetails.KEY_LOAD_TIMEOUT:this.state!==e.State.ERROR&&(this.state=l.fatal?e.State.ERROR:e.State.IDLE,o.logger.warn("AudioStreamController: "+l.details+" while loading frag, now switching to "+this.state+" state ..."));break;case a.ErrorDetails.BUFFER_FULL_ERROR:if(l.parent==="audio"&&(this.state===e.State.PARSING||this.state===e.State.PARSED)){var I=this.mediaBuffer,L=this.media.currentTime,D=I&&y.BufferHelper.isBuffered(I,L)&&y.BufferHelper.isBuffered(I,L+.5);if(D){var S=this.config;S.maxMaxBufferLength>=S.maxBufferLength&&(S.maxMaxBufferLength/=2,o.logger.warn("AudioStreamController: reduce max buffer length to "+S.maxMaxBufferLength+"s")),this.state=e.State.IDLE}else o.logger.warn("AudioStreamController: buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=e.State.BUFFER_FLUSHING,this.hls.trigger(u.default.BUFFER_FLUSHING,{startOffset:0,endOffset:_.POSITIVE_INFINITY,type:"audio"})}break;default:break}},s.prototype.onBufferFlushed=function(){var l=this,x=this.pendingData;x&&x.length?(o.logger.log("AudioStreamController: appending pending audio data after buffer flushed"),x.forEach(function(h){l.hls.trigger(u.default.BUFFER_APPENDING,h)}),this.appended=!0,this.pendingData=[],this.state=e.State.PARSED):(this.state=e.State.IDLE,this.fragPrevious=null,this.tick())},s}(e.default);R.default=g}).call(this,T("./src/polyfills/number.js").Number)},"./src/controller/audio-track-controller.js":function(w,R,T){"use strict";var _=this&&this.__extends||function(){var p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(c,a){c.__proto__=a}||function(c,a){for(var o in a)a.hasOwnProperty(o)&&(c[o]=a[o])};return function(c,a){p(c,a);function o(){this.constructor=c}c.prototype=a===null?Object.create(a):(o.prototype=a.prototype,new o)}}();Object.defineProperty(R,"__esModule",{value:!0});var A=T("./src/events.js"),m=T("./src/task-loop.js"),y=T("./src/utils/logger.js"),f=T("./src/errors.js"),u=function(p){_(c,p);function c(a){var o=p.call(this,a,A.default.MANIFEST_LOADING,A.default.MANIFEST_PARSED,A.default.AUDIO_TRACK_LOADED,A.default.AUDIO_TRACK_SWITCHED,A.default.LEVEL_LOADED,A.default.ERROR)||this;return o._trackId=-1,o._selectDefaultTrack=!0,o.tracks=[],o.trackIdBlacklist=Object.create(null),o.audioGroupId=null,o}return c.prototype.onManifestLoading=function(){this.tracks=[],this._trackId=-1,this._selectDefaultTrack=!0},c.prototype.onManifestParsed=function(a){var o=this.tracks=a.audioTracks||[];this.hls.trigger(A.default.AUDIO_TRACKS_UPDATED,{audioTracks:o})},c.prototype.onAudioTrackLoaded=function(a){if(a.id>=this.tracks.length){y.logger.warn("Invalid audio track id:",a.id);return}if(y.logger.log("audioTrack "+a.id+" loaded"),this.tracks[a.id].details=a.details,a.details.live&&!this.hasInterval()){var o=a.details.targetduration*1e3;this.setInterval(o)}!a.details.live&&this.hasInterval()&&this.clearInterval()},c.prototype.onAudioTrackSwitched=function(a){var o=this.tracks[a.id].groupId;o&&this.audioGroupId!==o&&(this.audioGroupId=o)},c.prototype.onLevelLoaded=function(a){var o=this.hls.levels[a.level];if(!!o.audioGroupIds){var r=o.audioGroupIds[o.urlId];this.audioGroupId!==r&&(this.audioGroupId=r,this._selectInitialAudioTrack())}},c.prototype.onError=function(a){a.type===f.ErrorTypes.NETWORK_ERROR&&(a.fatal&&this.clearInterval(),a.details===f.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&(y.logger.warn("Network failure on audio-track id:",a.context.id),this._handleLoadError()))},Object.defineProperty(c.prototype,"audioTracks",{get:function(){return this.tracks},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"audioTrack",{get:function(){return this._trackId},set:function(a){this._setAudioTrack(a),this._selectDefaultTrack=!1},enumerable:!0,configurable:!0}),c.prototype._setAudioTrack=function(a){if(this._trackId===a&&this.tracks[this._trackId].details){y.logger.debug("Same id as current audio-track passed, and track details available -> no-op");return}if(a<0||a>=this.tracks.length){y.logger.warn("Invalid id passed to audio-track controller");return}var o=this.tracks[a];y.logger.log("Now switching to audio-track index "+a),this.clearInterval(),this._trackId=a;var r=o.url,i=o.type,t=o.id;this.hls.trigger(A.default.AUDIO_TRACK_SWITCHING,{id:t,type:i,url:r}),this._loadTrackDetailsIfNeeded(o)},c.prototype.doTick=function(){this._updateTrack(this._trackId)},c.prototype._selectInitialAudioTrack=function(){var a=this,o=this.tracks;if(!!o.length){var r=this.tracks[this._trackId],i=null;if(r&&(i=r.name),this._selectDefaultTrack){var t=o.filter(function(d){return d.default});t.length?o=t:y.logger.warn("No default audio tracks defined")}var e=!1,n=function(){o.forEach(function(d){e||(!a.audioGroupId||d.groupId===a.audioGroupId)&&(!i||i===d.name)&&(a._setAudioTrack(d.id),e=!0)})};n(),e||(i=null,n()),e||(y.logger.error("No track found for running audio group-ID: "+this.audioGroupId),this.hls.trigger(A.default.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))}},c.prototype._needsTrackLoading=function(a){var o=a.details,r=a.url;return!o||o.live?!!r:!1},c.prototype._loadTrackDetailsIfNeeded=function(a){if(this._needsTrackLoading(a)){var o=a.url,r=a.id;y.logger.log("loading audio-track playlist for id: "+r),this.hls.trigger(A.default.AUDIO_TRACK_LOADING,{url:o,id:r})}},c.prototype._updateTrack=function(a){if(!(a<0||a>=this.tracks.length)){this.clearInterval(),this._trackId=a,y.logger.log("trying to update audio-track "+a);var o=this.tracks[a];this._loadTrackDetailsIfNeeded(o)}},c.prototype._handleLoadError=function(){this.trackIdBlacklist[this._trackId]=!0;var a=this._trackId,o=this.tracks[a],r=o.name,i=o.language,t=o.groupId;y.logger.warn("Loading failed on audio track id: "+a+", group-id: "+t+', name/language: "'+r+'" / "'+i+'"');for(var e=a,n=0;n<this.tracks.length;n++)if(!this.trackIdBlacklist[n]){var d=this.tracks[n];if(d.name===r){e=n;break}}if(e===a){y.logger.warn('No fallback audio-track found for name/language: "'+r+'" / "'+i+'"');return}y.logger.log("Attempting audio-track fallback id:",e,"group-id:",this.tracks[e].groupId),this._setAudioTrack(e)},c}(m.default);R.default=u},"./src/controller/base-stream-controller.js":function(w,R,T){"use strict";(function(_){var A=this&&this.__extends||function(){var c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,o){a.__proto__=o}||function(a,o){for(var r in o)o.hasOwnProperty(r)&&(a[r]=o[r])};return function(a,o){c(a,o);function r(){this.constructor=a}a.prototype=o===null?Object.create(o):(r.prototype=o.prototype,new r)}}();Object.defineProperty(R,"__esModule",{value:!0});var m=T("./src/task-loop.js"),y=T("./src/controller/fragment-tracker.js"),f=T("./src/utils/buffer-helper.js"),u=T("./src/utils/logger.js");R.State={STOPPED:"STOPPED",STARTING:"STARTING",IDLE:"IDLE",PAUSED:"PAUSED",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BUFFER_FLUSHING:"BUFFER_FLUSHING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};var p=function(c){A(a,c);function a(){return c!==null&&c.apply(this,arguments)||this}return a.prototype.doTick=function(){},a.prototype.startLoad=function(){},a.prototype.stopLoad=function(){var o=this.fragCurrent;o&&(o.loader&&o.loader.abort(),this.fragmentTracker.removeFragment(o)),this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=R.State.STOPPED},a.prototype._streamEnded=function(o,r){var i=this,t=i.fragCurrent,e=i.fragmentTracker;if(!r.live&&t&&!t.backtracked&&t.sn===r.endSN&&!o.nextStart){var n=e.getState(t);return n===y.FragmentState.PARTIAL||n===y.FragmentState.OK}return!1},a.prototype.onMediaSeeking=function(){var o=this,r=o.config,i=o.media,t=o.mediaBuffer,e=o.state,n=i?i.currentTime:null,d=f.BufferHelper.bufferInfo(t||i,n,this.config.maxBufferHole);if(_.isFinite(n)&&u.logger.log("media seeking to "+n.toFixed(3)),e===R.State.FRAG_LOADING){var g=this.fragCurrent;if(d.len===0&&g){var v=r.maxFragLookUpTolerance,s=g.start-v,l=g.start+g.duration+v;n<s||n>l?(g.loader&&(u.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),g.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=R.State.IDLE):u.logger.log("seeking outside of buffer but within currently loaded fragment range")}}else e===R.State.ENDED&&(d.len===0&&(this.fragPrevious=null,this.fragCurrent=null),this.state=R.State.IDLE);i&&(this.lastCurrentTime=n),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=n),this.tick()},a.prototype.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.prototype.onHandlerDestroying=function(){this.stopLoad(),c.prototype.onHandlerDestroying.call(this)},a.prototype.onHandlerDestroyed=function(){this.state=R.State.STOPPED,this.fragmentTracker=null},a}(m.default);R.default=p}).call(this,T("./src/polyfills/number.js").Number)},"./src/controller/buffer-controller.js":function(w,R,T){"use strict";(function(_){var A=this&&this.__extends||function(){var o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var t in i)i.hasOwnProperty(t)&&(r[t]=i[t])};return function(r,i){o(r,i);function t(){this.constructor=r}r.prototype=i===null?Object.create(i):(t.prototype=i.prototype,new t)}}();Object.defineProperty(R,"__esModule",{value:!0});var m=T("./src/events.js"),y=T("./src/event-handler.js"),f=T("./src/utils/logger.js"),u=T("./src/errors.js"),p=T("./src/utils/mediasource-helper.js"),c=p.getMediaSource(),a=function(o){A(r,o);function r(i){var t=o.call(this,i,m.default.MEDIA_ATTACHING,m.default.MEDIA_DETACHING,m.default.MANIFEST_PARSED,m.default.BUFFER_RESET,m.default.BUFFER_APPENDING,m.default.BUFFER_CODECS,m.default.BUFFER_EOS,m.default.BUFFER_FLUSHING,m.default.LEVEL_PTS_UPDATED,m.default.LEVEL_UPDATED)||this;return t._msDuration=null,t._levelDuration=null,t._levelTargetDuration=10,t._live=null,t._objectUrl=null,t.bufferCodecEventsExpected=0,t.onsbue=t.onSBUpdateEnd.bind(t),t.onsbe=t.onSBUpdateError.bind(t),t.pendingTracks={},t.tracks={},t}return r.prototype.destroy=function(){y.default.prototype.destroy.call(this)},r.prototype.onLevelPtsUpdated=function(i){var t=i.type,e=this.tracks.audio;if(t==="audio"&&e&&e.container==="audio/mpeg"){var n=this.sourceBuffer.audio,d=Math.abs(n.timestampOffset-i.start);if(d>.1){var g=n.updating;try{n.abort()}catch(v){f.logger.warn("can not abort audio buffer: "+v)}g?this.audioTimestampOffset=i.start:(f.logger.warn("change mpeg audio timestamp offset from "+n.timestampOffset+" to "+i.start),n.timestampOffset=i.start)}}},r.prototype.onManifestParsed=function(i){this.bufferCodecEventsExpected=i.altAudio?2:1,f.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},r.prototype.onMediaAttaching=function(i){var t=this.media=i.media;if(t){var e=this.mediaSource=new c;this.onmso=this.onMediaSourceOpen.bind(this),this.onmse=this.onMediaSourceEnded.bind(this),this.onmsc=this.onMediaSourceClose.bind(this),e.addEventListener("sourceopen",this.onmso),e.addEventListener("sourceended",this.onmse),e.addEventListener("sourceclose",this.onmsc),t.src=window.URL.createObjectURL(e),this._objectUrl=t.src}},r.prototype.onMediaDetaching=function(){f.logger.log("media source detaching");var i=this.mediaSource;if(i){if(i.readyState==="open")try{i.endOfStream()}catch(t){f.logger.warn("onMediaDetaching:"+t.message+" while calling endOfStream")}i.removeEventListener("sourceopen",this.onmso),i.removeEventListener("sourceended",this.onmse),i.removeEventListener("sourceclose",this.onmsc),this.media&&(window.URL.revokeObjectURL(this._objectUrl),this.media.src===this._objectUrl?(this.media.removeAttribute("src"),this.media.load()):f.logger.warn("media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.pendingTracks={},this.tracks={},this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0}this.onmso=this.onmse=this.onmsc=null,this.hls.trigger(m.default.MEDIA_DETACHED)},r.prototype.onMediaSourceOpen=function(){f.logger.log("media source opened"),this.hls.trigger(m.default.MEDIA_ATTACHED,{media:this.media});var i=this.mediaSource;i&&i.removeEventListener("sourceopen",this.onmso),this.checkPendingTracks()},r.prototype.checkPendingTracks=function(){var i=this,t=i.bufferCodecEventsExpected,e=i.pendingTracks,n=Object.keys(e).length;(n&&!t||n===2)&&(this.createSourceBuffers(e),this.pendingTracks={},this.doAppending())},r.prototype.onMediaSourceClose=function(){f.logger.log("media source closed")},r.prototype.onMediaSourceEnded=function(){f.logger.log("media source ended")},r.prototype.onSBUpdateEnd=function(){if(this.audioTimestampOffset){var i=this.sourceBuffer.audio;f.logger.warn("change mpeg audio timestamp offset from "+i.timestampOffset+" to "+this.audioTimestampOffset),i.timestampOffset=this.audioTimestampOffset,delete this.audioTimestampOffset}this._needsFlush&&this.doFlush(),this._needsEos&&this.checkEos(),this.appending=!1;var t=this.parent,e=this.segments.reduce(function(v,s){return s.parent===t?v+1:v},0),n={},d=this.sourceBuffer;for(var g in d)n[g]=d[g].buffered;this.hls.trigger(m.default.BUFFER_APPENDED,{parent:t,pending:e,timeRanges:n}),this._needsFlush||this.doAppending(),this.updateMediaElementDuration(),e===0&&this.flushLiveBackBuffer()},r.prototype.onSBUpdateError=function(i){f.logger.error("sourceBuffer error:",i),this.hls.trigger(m.default.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:u.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})},r.prototype.onBufferReset=function(){var i=this.sourceBuffer;for(var t in i){var e=i[t];try{this.mediaSource.removeSourceBuffer(e),e.removeEventListener("updateend",this.onsbue),e.removeEventListener("error",this.onsbe)}catch(n){}}this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0},r.prototype.onBufferCodecs=function(i){var t=this;if(!Object.keys(this.sourceBuffer).length){Object.keys(i).forEach(function(n){t.pendingTracks[n]=i[n]});var e=this.mediaSource;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),e&&e.readyState==="open"&&this.checkPendingTracks()}},r.prototype.createSourceBuffers=function(i){var t=this.sourceBuffer,e=this.mediaSource;for(var n in i)if(!t[n]){var d=i[n],g=d.levelCodec||d.codec,v=d.container+";codecs="+g;f.logger.log("creating sourceBuffer("+v+")");try{var s=t[n]=e.addSourceBuffer(v);s.addEventListener("updateend",this.onsbue),s.addEventListener("error",this.onsbe),this.tracks[n]={codec:g,container:d.container},d.buffer=s}catch(l){f.logger.error("error while trying to add sourceBuffer:"+l.message),this.hls.trigger(m.default.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:u.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:l,mimeType:v})}}this.hls.trigger(m.default.BUFFER_CREATED,{tracks:i})},r.prototype.onBufferAppending=function(i){this._needsFlush||(this.segments?this.segments.push(i):this.segments=[i],this.doAppending())},r.prototype.onBufferAppendFail=function(i){f.logger.error("sourceBuffer error:",i.event),this.hls.trigger(m.default.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:u.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})},r.prototype.onBufferEos=function(i){var t=this.sourceBuffer,e=i.type;for(var n in t)(!e||n===e)&&(t[n].ended||(t[n].ended=!0,f.logger.log(n+" sourceBuffer now EOS")));this.checkEos()},r.prototype.checkEos=function(){var i=this.sourceBuffer,t=this.mediaSource;if(!t||t.readyState!=="open"){this._needsEos=!1;return}for(var e in i){var n=i[e];if(!n.ended)return;if(n.updating){this._needsEos=!0;return}}f.logger.log("all media data are available, signal endOfStream() to MediaSource and stop loading fragment");try{t.endOfStream()}catch(d){f.logger.warn("exception while calling mediaSource.endOfStream()")}this._needsEos=!1},r.prototype.onBufferFlushing=function(i){this.flushRange.push({start:i.startOffset,end:i.endOffset,type:i.type}),this.flushBufferCounter=0,this.doFlush()},r.prototype.flushLiveBackBuffer=function(){if(!!this._live){var i=this.hls.config.liveBackBufferLength;if(!(!isFinite(i)||i<0))for(var t=this.media.currentTime,e=this.sourceBuffer,n=Object.keys(e),d=t-Math.max(i,this._levelTargetDuration),g=n.length-1;g>=0;g--){var v=n[g],s=e[v].buffered;s.length>0&&d>s.start(0)&&this.removeBufferRange(v,e[v],0,d)}}},r.prototype.onLevelUpdated=function(i){var t=i.details;t.fragments.length>0&&(this._levelDuration=t.totalduration+t.fragments[0].start,this._levelTargetDuration=t.averagetargetduration||t.targetduration||10,this._live=t.live,this.updateMediaElementDuration())},r.prototype.updateMediaElementDuration=function(){var i=this.hls.config,t;if(!(this._levelDuration===null||!this.media||!this.mediaSource||!this.sourceBuffer||this.media.readyState===0||this.mediaSource.readyState!=="open")){for(var e in this.sourceBuffer)if(this.sourceBuffer[e].updating===!0)return;t=this.media.duration,this._msDuration===null&&(this._msDuration=this.mediaSource.duration),this._live===!0&&i.liveDurationInfinity===!0?(f.logger.log("Media Source duration is set to Infinity"),this._msDuration=this.mediaSource.duration=Infinity):(this._levelDuration>this._msDuration&&this._levelDuration>t||!_.isFinite(t))&&(f.logger.log("Updating Media Source duration to "+this._levelDuration.toFixed(3)),this._msDuration=this.mediaSource.duration=this._levelDuration)}},r.prototype.doFlush=function(){for(;this.flushRange.length;){var i=this.flushRange[0];if(this.flushBuffer(i.start,i.end,i.type))this.flushRange.shift(),this.flushBufferCounter=0;else{this._needsFlush=!0;return}}if(this.flushRange.length===0){this._needsFlush=!1;var t=0,e=this.sourceBuffer;try{for(var n in e)t+=e[n].buffered.length}catch(d){f.logger.error("error while accessing sourceBuffer.buffered")}this.appended=t,this.hls.trigger(m.default.BUFFER_FLUSHED)}},r.prototype.doAppending=function(){var i=this,t=i.hls,e=i.segments,n=i.sourceBuffer;if(Object.keys(n).length){if(this.media.error){this.segments=[],f.logger.error("trying to append although a media error occured, flush segment and abort");return}if(this.appending)return;if(e&&e.length){var d=e.shift();try{var g=d.type,v=n[g];v?v.updating?e.unshift(d):(v.ended=!1,this.parent=d.parent,v.appendBuffer(d.data),this.appendError=0,this.appended++,this.appending=!0):this.onSBUpdateEnd()}catch(l){f.logger.error("error while trying to append buffer:"+l.message),e.unshift(d);var s={type:u.ErrorTypes.MEDIA_ERROR,parent:d.parent};l.code!==22?(this.appendError?this.appendError++:this.appendError=1,s.details=u.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>t.config.appendErrorMaxRetry?(f.logger.log("fail "+t.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),this.segments=[],s.fatal=!0,t.trigger(m.default.ERROR,s)):(s.fatal=!1,t.trigger(m.default.ERROR,s))):(this.segments=[],s.details=u.ErrorDetails.BUFFER_FULL_ERROR,s.fatal=!1,t.trigger(m.default.ERROR,s))}}}},r.prototype.flushBuffer=function(i,t,e){var n,d=this.sourceBuffer;if(Object.keys(d).length){if(f.logger.log("flushBuffer,pos/start/end: "+this.media.currentTime.toFixed(3)+"/"+i+"/"+t),this.flushBufferCounter<this.appended){for(var g in d)if(!(e&&g!==e)){if(n=d[g],n.ended=!1,n.updating)return f.logger.warn("cannot flush, sb updating in progress"),!1;if(this.removeBufferRange(g,n,i,t))return this.flushBufferCounter++,!1}}else f.logger.warn("abort flushing too many retries");f.logger.log("buffer flushed")}return!0},r.prototype.removeBufferRange=function(i,t,e,n){try{for(var d=0;d<t.buffered.length;d++){var g=t.buffered.start(d),v=t.buffered.end(d),s=Math.max(g,e),l=Math.min(v,n);if(Math.min(l,v)-s>.5)return f.logger.log("sb remove "+i+" ["+s+","+l+"], of ["+g+","+v+"], pos:"+this.media.currentTime),t.remove(s,l),!0}}catch(x){f.logger.warn("removeBufferRange failed",x)}return!1},r}(y.default);R.default=a}).call(this,T("./src/polyfills/number.js").Number)},"./src/controller/cap-level-controller.js":function(w,R,T){"use strict";(function(_){var A=this&&this.__extends||function(){var u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,c){p.__proto__=c}||function(p,c){for(var a in c)c.hasOwnProperty(a)&&(p[a]=c[a])};return function(p,c){u(p,c);function a(){this.constructor=p}p.prototype=c===null?Object.create(c):(a.prototype=c.prototype,new a)}}();Object.defineProperty(R,"__esModule",{value:!0});var m=T("./src/events.js"),y=T("./src/event-handler.js"),f=function(u){A(p,u);function p(c){var a=u.call(this,c,m.default.FPS_DROP_LEVEL_CAPPING,m.default.MEDIA_ATTACHING,m.default.MANIFEST_PARSED,m.default.BUFFER_CODECS,m.default.MEDIA_DETACHING)||this;return a.autoLevelCapping=_.POSITIVE_INFINITY,a.firstLevel=null,a.levels=[],a.media=null,a.restrictedLevels=[],a.timer=null,a}return p.prototype.destroy=function(){this.hls.config.capLevelToPlayerSize&&(this.media=null,this._stopCapping())},p.prototype.onFpsDropLevelCapping=function(c){p.isLevelAllowed(c.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(c.droppedLevel)},p.prototype.onMediaAttaching=function(c){this.media=c.media instanceof window.HTMLVideoElement?c.media:null},p.prototype.onManifestParsed=function(c){var a=this.hls;this.restrictedLevels=[],this.levels=c.levels,this.firstLevel=c.firstLevel,a.config.capLevelToPlayerSize&&c.video&&this._startCapping()},p.prototype.onBufferCodecs=function(c){var a=this.hls;a.config.capLevelToPlayerSize&&c.video&&this._startCapping()},p.prototype.onLevelsUpdated=function(c){this.levels=c.levels},p.prototype.onMediaDetaching=function(){this._stopCapping()},p.prototype.detectPlayerSize=function(){if(this.media){var c=this.levels?this.levels.length:0;if(c){var a=this.hls;a.autoLevelCapping=this.getMaxLevel(c-1),a.autoLevelCapping>this.autoLevelCapping&&a.streamController.nextLevelSwitch(),this.autoLevelCapping=a.autoLevelCapping}}},p.prototype.getMaxLevel=function(c){var a=this;if(!this.levels)return-1;var o=this.levels.filter(function(r,i){return p.isLevelAllowed(i,a.restrictedLevels)&&i<=c});return p.getMaxLevelByMediaSize(o,this.mediaWidth,this.mediaHeight)},p.prototype._startCapping=function(){this.timer||(this.autoLevelCapping=_.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),clearInterval(this.timer),this.timer=setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},p.prototype._stopCapping=function(){this.restrictedLevels=[],this.firstLevel=null,this.autoLevelCapping=_.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer),this.timer=null)},Object.defineProperty(p.prototype,"mediaWidth",{get:function(){var c,a=this.media;return a&&(c=a.width||a.clientWidth||a.offsetWidth,c*=p.contentScaleFactor),c},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"mediaHeight",{get:function(){var c,a=this.media;return a&&(c=a.height||a.clientHeight||a.offsetHeight,c*=p.contentScaleFactor),c},enumerable:!0,configurable:!0}),Object.defineProperty(p,"contentScaleFactor",{get:function(){var c=1;try{c=window.devicePixelRatio}catch(a){}return c},enumerable:!0,configurable:!0}),p.isLevelAllowed=function(c,a){return a===void 0&&(a=[]),a.indexOf(c)===-1},p.getMaxLevelByMediaSize=function(c,a,o){if(!c||c&&!c.length)return-1;for(var r=function(n,d){return d?n.width!==d.width||n.height!==d.height:!0},i=c.length-1,t=0;t<c.length;t+=1){var e=c[t];if((e.width>=a||e.height>=o)&&r(e,c[t+1])){i=t;break}}return i},p}(y.default);R.default=f}).call(this,T("./src/polyfills/number.js").Number)},"./src/controller/eme-controller.js":function(w,R,T){"use strict";var _=this&&this.__extends||function(){var i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(t,e){i(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}}();Object.defineProperty(R,"__esModule",{value:!0});var A=T("./src/event-handler.js"),m=T("./src/events.js"),y=T("./src/errors.js"),f=T("./src/utils/logger.js"),u=window.XMLHttpRequest,p=3,c={WIDEVINE:"com.widevine.alpha",PLAYREADY:"com.microsoft.playready"},a=function(i,t,e){var n={videoCapabilities:[]};return t.forEach(function(d){n.videoCapabilities.push({contentType:'video/mp4; codecs="'+d+'"'})}),[n]},o=function(i,t,e){switch(i){case c.WIDEVINE:return a(t,e);default:throw Error("Unknown key-system: "+i)}},r=function(i){_(t,i);function t(e){var n=i.call(this,e,m.default.MEDIA_ATTACHED,m.default.MANIFEST_PARSED)||this;return n._widevineLicenseUrl=e.config.widevineLicenseUrl,n._licenseXhrSetup=e.config.licenseXhrSetup,n._emeEnabled=e.config.emeEnabled,n._requestMediaKeySystemAccess=e.config.requestMediaKeySystemAccessFunc,n._mediaKeysList=[],n._media=null,n._hasSetMediaKeys=!1,n._isMediaEncrypted=!1,n._requestLicenseFailureCount=0,n}return t.prototype.getLicenseServerUrl=function(e){var n;switch(e){case c.WIDEVINE:n=this._widevineLicenseUrl;break;default:n=null;break}return n||(f.logger.error('No license server URL configured for key-system "'+e+'"'),this.hls.trigger(m.default.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})),n},t.prototype._attemptKeySystemAccess=function(e,n,d){var g=this,v=o(e,n,d);if(!v){f.logger.warn("Can not create config for key-system (maybe because platform is not supported):",e);return}f.logger.log("Requesting encrypted media key-system access"),this.requestMediaKeySystemAccess(e,v).then(function(s){g._onMediaKeySystemAccessObtained(e,s)}).catch(function(s){f.logger.error('Failed to obtain key-system "'+e+'" access:',s)})},Object.defineProperty(t.prototype,"requestMediaKeySystemAccess",{get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess},enumerable:!0,configurable:!0}),t.prototype._onMediaKeySystemAccessObtained=function(e,n){var d=this;f.logger.log('Access for key-system "'+e+'" obtained');var g={mediaKeys:null,mediaKeysSession:null,mediaKeysSessionInitialized:!1,mediaKeySystemAccess:n,mediaKeySystemDomain:e};this._mediaKeysList.push(g),n.createMediaKeys().then(function(v){g.mediaKeys=v,f.logger.log('Media-keys created for key-system "'+e+'"'),d._onMediaKeysCreated()}).catch(function(v){f.logger.error("Failed to create media-keys:",v)})},t.prototype._onMediaKeysCreated=function(){var e=this;this._mediaKeysList.forEach(function(n){n.mediaKeysSession||(n.mediaKeysSession=n.mediaKeys.createSession(),e._onNewMediaKeySession(n.mediaKeysSession))})},t.prototype._onNewMediaKeySession=function(e){var n=this;f.logger.log("New key-system session "+e.sessionId),e.addEventListener("message",function(d){n._onKeySessionMessage(e,d.message)},!1)},t.prototype._onKeySessionMessage=function(e,n){f.logger.log("Got EME message event, creating license request"),this._requestLicense(n,function(d){f.logger.log("Received license data, updating key-session"),e.update(d)})},t.prototype._onMediaEncrypted=function(e,n){f.logger.log('Media is encrypted using "'+e+'" init data type'),this._isMediaEncrypted=!0,this._mediaEncryptionInitDataType=e,this._mediaEncryptionInitData=n,this._attemptSetMediaKeys(),this._generateRequestWithPreferredKeySession()},t.prototype._attemptSetMediaKeys=function(){if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys){f.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(m.default.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}f.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},t.prototype._generateRequestWithPreferredKeySession=function(){var e=this,n=this._mediaKeysList[0];if(!n){f.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(m.default.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(n.mediaKeysSessionInitialized){f.logger.warn("Key-Session already initialized but requested again");return}var d=n.mediaKeysSession;d||(f.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(m.default.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0}));var g=this._mediaEncryptionInitDataType,v=this._mediaEncryptionInitData;f.logger.log('Generating key-session request for "'+g+'" init data type'),n.mediaKeysSessionInitialized=!0,d.generateRequest(g,v).then(function(){f.logger.debug("Key-session generation succeeded")}).catch(function(s){f.logger.error("Error generating key-session request:",s),e.hls.trigger(m.default.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},t.prototype._createLicenseXhr=function(e,n,d){var g=new u,v=this._licenseXhrSetup;try{if(v)try{v(g,e)}catch(s){g.open("POST",e,!0),v(g,e)}g.readyState||g.open("POST",e,!0)}catch(s){f.logger.error("Error setting up key-system license XHR",s),this.hls.trigger(m.default.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}return g.responseType="arraybuffer",g.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,g,e,n,d),g},t.prototype._onLicenseRequestReadyStageChange=function(e,n,d,g){switch(e.readyState){case 4:if(e.status===200)this._requestLicenseFailureCount=0,f.logger.log("License request succeeded"),g(e.response);else{if(f.logger.error("License Request XHR failed ("+n+"). Status: "+e.status+" ("+e.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount<=p){var v=p-this._requestLicenseFailureCount+1;f.logger.warn("Retrying license request, "+v+" attempts left"),this._requestLicense(d,g);return}this.hls.trigger(m.default.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}break}},t.prototype._generateLicenseRequestChallenge=function(e,n){var d;return e.mediaKeySystemDomain===c.PLAYREADY?f.logger.error("PlayReady is not supported (yet)"):e.mediaKeySystemDomain===c.WIDEVINE?d=n:f.logger.error("Unsupported key-system:",e.mediaKeySystemDomain),d},t.prototype._requestLicense=function(e,n){f.logger.log("Requesting content license for key-system");var d=this._mediaKeysList[0];if(!d){f.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(m.default.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}var g=this.getLicenseServerUrl(d.mediaKeySystemDomain),v=this._createLicenseXhr(g,e,n);f.logger.log("Sending license request to URL: "+g),v.send(this._generateLicenseRequestChallenge(d,e))},t.prototype.onMediaAttached=function(e){var n=this;if(!!this._emeEnabled){var d=e.media;this._media=d,d.addEventListener("encrypted",function(g){n._onMediaEncrypted(g.initDataType,g.initData)})}},t.prototype.onManifestParsed=function(e){if(!!this._emeEnabled){var n=e.levels.map(function(g){return g.audioCodec}),d=e.levels.map(function(g){return g.videoCodec});this._attemptKeySystemAccess(c.WIDEVINE,n,d)}},t}(A.default);R.default=r},"./src/controller/fps-controller.js":function(w,R,T){"use strict";var _=this&&this.__extends||function(){var p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(c,a){c.__proto__=a}||function(c,a){for(var o in a)a.hasOwnProperty(o)&&(c[o]=a[o])};return function(c,a){p(c,a);function o(){this.constructor=c}c.prototype=a===null?Object.create(a):(o.prototype=a.prototype,new o)}}();Object.defineProperty(R,"__esModule",{value:!0});var A=T("./src/events.js"),m=T("./src/event-handler.js"),y=T("./src/utils/logger.js"),f=window.performance,u=function(p){_(c,p);function c(a){return p.call(this,a,A.default.MEDIA_ATTACHING)||this}return c.prototype.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},c.prototype.onMediaAttaching=function(a){var o=this.hls.config;if(o.capLevelOnFPSDrop){var r=this.video=a.media instanceof window.HTMLVideoElement?a.media:null;typeof r.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),o.fpsDroppedMonitoringPeriod)}},c.prototype.checkFPS=function(a,o,r){var i=f.now();if(o){if(this.lastTime){var t=i-this.lastTime,e=r-this.lastDroppedFrames,n=o-this.lastDecodedFrames,d=1e3*e/t,g=this.hls;if(g.trigger(A.default.FPS_DROP,{currentDropped:e,currentDecoded:n,totalDroppedFrames:r}),d>0&&e>g.config.fpsDroppedMonitoringThreshold*n){var v=g.currentLevel;y.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+v),v>0&&(g.autoLevelCapping===-1||g.autoLevelCapping>=v)&&(v=v-1,g.trigger(A.default.FPS_DROP_LEVEL_CAPPING,{level:v,droppedLevel:g.currentLevel}),g.autoLevelCapping=v,g.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=o}},c.prototype.checkFPSInterval=function(){var a=this.video;if(a)if(this.isVideoPlaybackQualityAvailable){var o=a.getVideoPlaybackQuality();this.checkFPS(a,o.totalVideoFrames,o.droppedVideoFrames)}else this.checkFPS(a,a.webkitDecodedFrameCount,a.webkitDroppedFrameCount)},c}(m.default);R.default=u},"./src/controller/fragment-finders.js":function(w,R,T){"use strict";(function(_){Object.defineProperty(R,"__esModule",{value:!0});var A=T("./src/utils/binary-search.js");function m(p,c,a){if(!Array.isArray(p)||!p.length||!_.isFinite(c)||c<p[0].programDateTime||c>=p[p.length-1].endProgramDateTime)return null;a=a||0;for(var o=0;o<p.length;++o){var r=p[o];if(u(c,a,r))return r}return null}R.findFragmentByPDT=m;function y(p,c,a,o){a===void 0&&(a=0),o===void 0&&(o=0);var r=p?c[p.sn-c[0].sn+1]:null;return r&&!f(a,o,r)?r:A.default.search(c,f.bind(null,a,o))}R.findFragmentByPTS=y;function f(p,c,a){p===void 0&&(p=0),c===void 0&&(c=0);var o=Math.min(c,a.duration+(a.deltaPTS?a.deltaPTS:0));return a.start+a.duration-o<=p?1:a.start-o>p&&a.start?-1:0}R.fragmentWithinToleranceTest=f;function u(p,c,a){var o=Math.min(c,a.duration+(a.deltaPTS?a.deltaPTS:0))*1e3;return a.endProgramDateTime-o>p}R.pdtWithinToleranceTest=u}).call(this,T("./src/polyfills/number.js").Number)},"./src/controller/fragment-tracker.js":function(w,R,T){"use strict";(function(_){var A=this&&this.__extends||function(){var u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,c){p.__proto__=c}||function(p,c){for(var a in c)c.hasOwnProperty(a)&&(p[a]=c[a])};return function(p,c){u(p,c);function a(){this.constructor=p}p.prototype=c===null?Object.create(c):(a.prototype=c.prototype,new a)}}();Object.defineProperty(R,"__esModule",{value:!0});var m=T("./src/event-handler.js"),y=T("./src/events.js");R.FragmentState={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};var f=function(u){A(p,u);function p(c){var a=u.call(this,c,y.default.BUFFER_APPENDED,y.default.FRAG_BUFFERED,y.default.FRAG_LOADED)||this;return a.bufferPadding=.2,a.fragments=Object.create(null),a.timeRanges=Object.create(null),a.config=c.config,a}return p.prototype.destroy=function(){this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.config=null,m.default.prototype.destroy.call(this),u.prototype.destroy.call(this)},p.prototype.getBufferedFrag=function(c,a){var o=this.fragments,r=Object.keys(o).filter(function(t){var e=o[t];if(e.body.type!==a||!e.buffered)return!1;var n=e.body;return n.startPTS<=c&&c<=n.endPTS});if(r.length===0)return null;var i=r.pop();return o[i].body},p.prototype.detectEvictedFragments=function(c,a){var o=this,r,i;Object.keys(this.fragments).forEach(function(t){var e=o.fragments[t];if(e.buffered===!0){var n=e.range[c];if(n){r=n.time;for(var d=0;d<r.length;d++)if(i=r[d],o.isTimeBuffered(i.startPTS,i.endPTS,a)===!1){o.removeFragment(e.body);break}}}})},p.prototype.detectPartialFragments=function(c){var a=this,o=this.getFragmentKey(c),r=this.fragments[o];r&&(r.buffered=!0,Object.keys(this.timeRanges).forEach(function(i){if(c.hasElementaryStream(i)){var t=a.timeRanges[i];r.range[i]=a.getBufferedTimes(c.startPTS,c.endPTS,t)}}))},p.prototype.getBufferedTimes=function(c,a,o){for(var r=[],i,t,e=!1,n=0;n<o.length;n++)if(i=o.start(n)-this.bufferPadding,t=o.end(n)+this.bufferPadding,c>=i&&a<=t){r.push({startPTS:Math.max(c,o.start(n)),endPTS:Math.min(a,o.end(n))});break}else if(c<t&&a>i)r.push({startPTS:Math.max(c,o.start(n)),endPTS:Math.min(a,o.end(n))}),e=!0;else if(a<=i)break;return{time:r,partial:e}},p.prototype.getFragmentKey=function(c){return c.type+"_"+c.level+"_"+c.urlId+"_"+c.sn},p.prototype.getPartialFragment=function(c){var a=this,o,r,i,t=null,e=0;return Object.keys(this.fragments).forEach(function(n){var d=a.fragments[n];a.isPartial(d)&&(r=d.body.startPTS-a.bufferPadding,i=d.body.endPTS+a.bufferPadding,c>=r&&c<=i&&(o=Math.min(c-r,i-c),e<=o&&(t=d.body,e=o)))}),t},p.prototype.getState=function(c){var a=this.getFragmentKey(c),o=this.fragments[a],r=R.FragmentState.NOT_LOADED;return o!==void 0&&(o.buffered?this.isPartial(o)===!0?r=R.FragmentState.PARTIAL:r=R.FragmentState.OK:r=R.FragmentState.APPENDING),r},p.prototype.isPartial=function(c){return c.buffered===!0&&(c.range.video!==void 0&&c.range.video.partial===!0||c.range.audio!==void 0&&c.range.audio.partial===!0)},p.prototype.isTimeBuffered=function(c,a,o){for(var r,i,t=0;t<o.length;t++){if(r=o.start(t)-this.bufferPadding,i=o.end(t)+this.bufferPadding,c>=r&&a<=i)return!0;if(a<=r)return!1}return!1},p.prototype.onFragLoaded=function(c){var a=c.frag;!_.isFinite(a.sn)||a.bitrateTest||(this.fragments[this.getFragmentKey(a)]={body:a,range:Object.create(null),buffered:!1})},p.prototype.onBufferAppended=function(c){var a=this;this.timeRanges=c.timeRanges,Object.keys(this.timeRanges).forEach(function(o){var r=a.timeRanges[o];a.detectEvictedFragments(o,r)})},p.prototype.onFragBuffered=function(c){this.detectPartialFragments(c.frag)},p.prototype.hasFragment=function(c){var a=this.getFragmentKey(c);return this.fragments[a]!==void 0},p.prototype.removeFragment=function(c){var a=this.getFragmentKey(c);delete this.fragments[a]},p.prototype.removeAllFragments=function(){this.fragments=Object.create(null)},p}(m.default);R.FragmentTracker=f}).call(this,T("./src/polyfills/number.js").Number)},"./src/controller/gap-controller.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/utils/buffer-helper.js"),A=T("./src/errors.js"),m=T("./src/events.js"),y=T("./src/utils/logger.js"),f=1e3,u=.5,p=function(){function c(a,o,r,i){this.config=a,this.media=o,this.fragmentTracker=r,this.hls=i,this.stallReported=!1}return c.prototype.poll=function(a,o){var r=this,i=r.config,t=r.media,e=t.currentTime,n=window.performance.now();if(e!==a){this.stallReported&&(y.logger.warn("playback not stuck anymore @"+e+", after "+Math.round(n-this.stalled)+"ms"),this.stallReported=!1),this.stalled=null,this.nudgeRetry=0;return}if(!(t.ended||!t.buffered.length||t.readyState>2)&&!(t.seeking&&_.BufferHelper.isBuffered(t,e))){var d=n-this.stalled,g=_.BufferHelper.bufferInfo(t,e,i.maxBufferHole);if(this.stalled)d>=f&&this._reportStall(g.len);else{this.stalled=n;return}this._tryFixBufferStall(g,d)}},c.prototype._tryFixBufferStall=function(a,o){var r=this,i=r.config,t=r.fragmentTracker,e=r.media,n=e.currentTime,d=t.getPartialFragment(n);d&&this._trySkipBufferHole(d),a.len>u&&o>i.highBufferWatchdogPeriod*1e3&&(this.stalled=null,this._tryNudgeBuffer())},c.prototype._reportStall=function(a){var o=this,r=o.hls,i=o.media,t=o.stallReported;t||(this.stallReported=!0,y.logger.warn("Playback stalling at @"+i.currentTime+" due to low buffer"),r.trigger(m.default.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:a}))},c.prototype._trySkipBufferHole=function(a){for(var o=this,r=o.hls,i=o.media,t=i.currentTime,e=0,n=0;n<i.buffered.length;n++){var d=i.buffered.start(n);if(t>=e&&t<d){i.currentTime=Math.max(d,i.currentTime+.1),y.logger.warn("skipping hole, adjusting currentTime from "+t+" to "+i.currentTime),this.stalled=null,r.trigger(m.default.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+t+" to "+i.currentTime,frag:a});return}e=i.buffered.end(n)}},c.prototype._tryNudgeBuffer=function(){var a=this,o=a.config,r=a.hls,i=a.media,t=i.currentTime,e=(this.nudgeRetry||0)+1;if(this.nudgeRetry=e,e<o.nudgeMaxRetry){var n=t+e*o.nudgeOffset;y.logger.log("adjust currentTime from "+t+" to "+n),i.currentTime=n,r.trigger(m.default.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else y.logger.error("still stuck in high buffer @"+t+" after "+o.nudgeMaxRetry+", raise fatal error"),r.trigger(m.default.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},c}();R.default=p},"./src/controller/id3-track-controller.js":function(w,R,T){"use strict";var _=this&&this.__extends||function(){var p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(c,a){c.__proto__=a}||function(c,a){for(var o in a)a.hasOwnProperty(o)&&(c[o]=a[o])};return function(c,a){p(c,a);function o(){this.constructor=c}c.prototype=a===null?Object.create(a):(o.prototype=a.prototype,new o)}}();Object.defineProperty(R,"__esModule",{value:!0});var A=T("./src/events.js"),m=T("./src/event-handler.js"),y=T("./src/demux/id3.js"),f=T("./src/utils/texttrack-utils.js"),u=function(p){_(c,p);function c(a){var o=p.call(this,a,A.default.MEDIA_ATTACHED,A.default.MEDIA_DETACHING,A.default.FRAG_PARSING_METADATA)||this;return o.id3Track=void 0,o.media=void 0,o}return c.prototype.destroy=function(){m.default.prototype.destroy.call(this)},c.prototype.onMediaAttached=function(a){this.media=a.media,!this.media},c.prototype.onMediaDetaching=function(){f.clearCurrentCues(this.id3Track),this.id3Track=void 0,this.media=void 0},c.prototype.getID3Track=function(a){for(var o=0;o<a.length;o++){var r=a[o];if(r.kind==="metadata"&&r.label==="id3")return f.sendAddTrackEvent(r,this.media),r}return this.media.addTextTrack("metadata","id3")},c.prototype.onFragParsingMetadata=function(a){var o=a.frag,r=a.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var i=window.WebKitDataCue||window.VTTCue||window.TextTrackCue,t=0;t<r.length;t++){var e=y.default.getID3Frames(r[t].data);if(e){var n=r[t].pts,d=t<r.length-1?r[t+1].pts:o.endPTS;n===d&&(d+=1e-4);for(var g=0;g<e.length;g++){var v=e[g];if(!y.default.isTimeStampFrame(v)){var s=new i(n,d,"");s.value=v,this.id3Track.addCue(s)}}}}},c}(m.default);R.default=u},"./src/controller/level-controller.js":function(w,R,T){"use strict";var _=this&&this.__extends||function(){var r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,t){i.__proto__=t}||function(i,t){for(var e in t)t.hasOwnProperty(e)&&(i[e]=t[e])};return function(i,t){r(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}}();Object.defineProperty(R,"__esModule",{value:!0});var A=T("./src/events.js"),m=T("./src/event-handler.js"),y=T("./src/utils/logger.js"),f=T("./src/errors.js"),u=T("./src/utils/codecs.js"),p=T("./src/controller/level-helper.js"),c=window.performance,a,o=function(r){_(i,r);function i(t){var e=r.call(this,t,A.default.MANIFEST_LOADED,A.default.LEVEL_LOADED,A.default.AUDIO_TRACK_SWITCHED,A.default.FRAG_LOADED,A.default.ERROR)||this;return e.canload=!1,e.currentLevelIndex=null,e.manualLevelIndex=-1,e.timer=null,a=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),e}return i.prototype.onHandlerDestroying=function(){this.clearTimer(),this.manualLevelIndex=-1},i.prototype.clearTimer=function(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)},i.prototype.startLoad=function(){var t=this._levels;this.canload=!0,this.levelRetryCount=0,t&&t.forEach(function(e){e.loadError=0;var n=e.details;n&&n.live&&(e.details=void 0)}),this.timer!==null&&this.loadLevel()},i.prototype.stopLoad=function(){this.canload=!1},i.prototype.onManifestLoaded=function(t){var e=[],n=[],d,g={},v=null,s=!1,l=!1;if(t.levels.forEach(function(h){var E=h.attrs;h.loadError=0,h.fragmentError=!1,s=s||!!h.videoCodec,l=l||!!h.audioCodec,a&&h.audioCodec&&h.audioCodec.indexOf("mp4a.40.34")!==-1&&(h.audioCodec=void 0),v=g[h.bitrate],v?v.url.push(h.url):(h.url=[h.url],h.urlId=0,g[h.bitrate]=h,e.push(h)),E&&(E.AUDIO&&(l=!0,p.addGroupId(v||h,"audio",E.AUDIO)),E.SUBTITLES&&p.addGroupId(v||h,"text",E.SUBTITLES))}),s&&l&&(e=e.filter(function(h){var E=h.videoCodec;return!!E})),e=e.filter(function(h){var E=h.audioCodec,S=h.videoCodec;return(!E||u.isCodecSupportedInMp4(E,"audio"))&&(!S||u.isCodecSupportedInMp4(S,"video"))}),t.audioTracks&&(n=t.audioTracks.filter(function(h){return!h.audioCodec||u.isCodecSupportedInMp4(h.audioCodec,"audio")}),n.forEach(function(h,E){h.id=E})),e.length>0){d=e[0].bitrate,e.sort(function(h,E){return h.bitrate-E.bitrate}),this._levels=e;for(var x=0;x<e.length;x++)if(e[x].bitrate===d){this._firstLevel=x,y.logger.log("manifest loaded,"+e.length+" level(s) found, first bitrate:"+d);break}this.hls.trigger(A.default.MANIFEST_PARSED,{levels:e,audioTracks:n,firstLevel:this._firstLevel,stats:t.stats,audio:l,video:s,altAudio:n.some(function(h){return!!h.url})})}else this.hls.trigger(A.default.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:this.hls.url,reason:"no level with compatible codecs found in manifest"})},Object.defineProperty(i.prototype,"levels",{get:function(){return this._levels},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"level",{get:function(){return this.currentLevelIndex},set:function(t){var e=this._levels;e&&(t=Math.min(t,e.length-1),(this.currentLevelIndex!==t||!e[t].details)&&this.setLevelInternal(t))},enumerable:!0,configurable:!0}),i.prototype.setLevelInternal=function(t){var e=this._levels,n=this.hls;if(t>=0&&t<e.length){if(this.clearTimer(),this.currentLevelIndex!==t){y.logger.log("switching to level "+t),this.currentLevelIndex=t;var d=e[t];d.level=t,n.trigger(A.default.LEVEL_SWITCHING,d)}var g=e[t],v=g.details;if(!v||v.live){var s=g.urlId;n.trigger(A.default.LEVEL_LOADING,{url:g.url[s],level:t,id:s})}}else n.trigger(A.default.ERROR,{type:f.ErrorTypes.OTHER_ERROR,details:f.ErrorDetails.LEVEL_SWITCH_ERROR,level:t,fatal:!1,reason:"invalid level idx"})},Object.defineProperty(i.prototype,"manualLevel",{get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"firstLevel",{get:function(){return this._firstLevel},set:function(t){this._firstLevel=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"startLevel",{get:function(){if(this._startLevel===void 0){var t=this.hls.config.startLevel;return t!==void 0?t:this._firstLevel}else return this._startLevel},set:function(t){this._startLevel=t},enumerable:!0,configurable:!0}),i.prototype.onError=function(t){if(t.fatal){t.type===f.ErrorTypes.NETWORK_ERROR&&this.clearTimer();return}var e=!1,n=!1,d;switch(t.details){case f.ErrorDetails.FRAG_LOAD_ERROR:case f.ErrorDetails.FRAG_LOAD_TIMEOUT:case f.ErrorDetails.KEY_LOAD_ERROR:case f.ErrorDetails.KEY_LOAD_TIMEOUT:d=t.frag.level,n=!0;break;case f.ErrorDetails.LEVEL_LOAD_ERROR:case f.ErrorDetails.LEVEL_LOAD_TIMEOUT:d=t.context.level,e=!0;break;case f.ErrorDetails.REMUX_ALLOC_ERROR:d=t.level,e=!0;break}d!==void 0&&this.recoverLevel(t,d,e,n)},i.prototype.recoverLevel=function(t,e,n,d){var g=this,v=this.hls.config,s=t.details,l=this._levels[e],x,h,E;if(l.loadError++,l.fragmentError=d,n)if(this.levelRetryCount+1<=v.levelLoadingMaxRetry)h=Math.min(Math.pow(2,this.levelRetryCount)*v.levelLoadingRetryDelay,v.levelLoadingMaxRetryTimeout),this.timer=setTimeout(function(){return g.loadLevel()},h),t.levelRetry=!0,this.levelRetryCount++,y.logger.warn("level controller, "+s+", retry in "+h+" ms, current retry count is "+this.levelRetryCount);else{y.logger.error("level controller, cannot recover from "+s+" error"),this.currentLevelIndex=null,this.clearTimer(),t.fatal=!0;return}(n||d)&&(x=l.url.length,x>1&&l.loadError<x?(l.urlId=(l.urlId+1)%x,l.details=void 0,y.logger.warn("level controller, "+s+" for level "+e+": switching to redundant URL-id "+l.urlId)):this.manualLevelIndex===-1?(E=e===0?this._levels.length-1:e-1,y.logger.warn("level controller, "+s+": switch to "+E),this.hls.nextAutoLevel=this.currentLevelIndex=E):d&&(y.logger.warn("level controller, "+s+": reload a fragment"),this.currentLevelIndex=null))},i.prototype.onFragLoaded=function(t){var e=t.frag;if(e!==void 0&&e.type==="main"){var n=this._levels[e.level];n!==void 0&&(n.fragmentError=!1,n.loadError=0,this.levelRetryCount=0)}},i.prototype.onLevelLoaded=function(t){var e=this,n=t.level,d=t.details;if(n===this.currentLevelIndex){var g=this._levels[n];if(g.fragmentError||(g.loadError=0,this.levelRetryCount=0),d.live){var v=p.computeReloadInterval(g.details,d,t.stats.trequest);y.logger.log("live playlist, reload in "+Math.round(v)+" ms"),this.timer=setTimeout(function(){return e.loadLevel()},v)}else this.clearTimer()}},i.prototype.onAudioTrackSwitched=function(t){var e=this.hls.audioTracks[t.id].groupId,n=this.hls.levels[this.currentLevelIndex];if(!!n&&n.audioGroupIds){for(var d=-1,g=0;g<n.audioGroupIds.length;g++)if(n.audioGroupIds[g]===e){d=g;break}d!==n.urlId&&(n.urlId=d,this.startLoad())}},i.prototype.loadLevel=function(){if(y.logger.debug("call to loadLevel"),this.currentLevelIndex!==null&&this.canload){var t=this._levels[this.currentLevelIndex];if(typeof t=="object"&&t.url.length>0){var e=this.currentLevelIndex,n=t.urlId,d=t.url[n];y.logger.log("Attempt loading level index "+e+" with URL-id "+n),this.hls.trigger(A.default.LEVEL_LOADING,{url:d,level:e,id:n})}}},Object.defineProperty(i.prototype,"nextLoadLevel",{get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)},enumerable:!0,configurable:!0}),i}(m.default);R.default=o},"./src/controller/level-helper.js":function(w,R,T){"use strict";(function(_){Object.defineProperty(R,"__esModule",{value:!0});var A=T("./src/utils/logger.js");function m(r,i,t){switch(i){case"audio":r.audioGroupIds||(r.audioGroupIds=[]),r.audioGroupIds.push(t);break;case"text":r.textGroupIds||(r.textGroupIds=[]),r.textGroupIds.push(t);break}}R.addGroupId=m;function y(r,i,t){var e=r[i],n=r[t],d=n.startPTS;_.isFinite(d)?t>i?(e.duration=d-e.start,e.duration<0&&A.logger.warn("negative duration computed for frag "+e.sn+",level "+e.level+", there should be some duration drift between playlist and fragment!")):(n.duration=e.start-d,n.duration<0&&A.logger.warn("negative duration computed for frag "+n.sn+",level "+n.level+", there should be some duration drift between playlist and fragment!")):t>i?n.start=e.start+e.duration:n.start=Math.max(e.start-n.duration,0)}R.updatePTS=y;function f(r,i,t,e,n,d){var g=t;if(_.isFinite(i.startPTS)){var v=Math.abs(i.startPTS-t);_.isFinite(i.deltaPTS)?i.deltaPTS=Math.max(v,i.deltaPTS):i.deltaPTS=v,g=Math.max(t,i.startPTS),t=Math.min(t,i.startPTS),e=Math.max(e,i.endPTS),n=Math.min(n,i.startDTS),d=Math.max(d,i.endDTS)}var s=t-i.start;i.start=i.startPTS=t,i.maxStartPTS=g,i.endPTS=e,i.startDTS=n,i.endDTS=d,i.duration=e-t;var l=i.sn;if(!r||l<r.startSN||l>r.endSN)return 0;var x,h,E;for(x=l-r.startSN,h=r.fragments,h[x]=i,E=x;E>0;E--)y(h,E,E-1);for(E=x;E<h.length-1;E++)y(h,E,E+1);return r.PTSKnown=!0,s}R.updateFragPTSDTS=f;function u(r,i){i.initSegment&&r.initSegment&&(i.initSegment=r.initSegment);var t=0,e;if(c(r,i,function(g,v){t=g.cc-v.cc,_.isFinite(g.startPTS)&&(v.start=v.startPTS=g.startPTS,v.endPTS=g.endPTS,v.duration=g.duration,v.backtracked=g.backtracked,v.dropped=g.dropped,e=v),i.PTSKnown=!0}),!!i.PTSKnown){if(t){A.logger.log("discontinuity sliding from playlist, take drift into account");for(var n=i.fragments,d=0;d<n.length;d++)n[d].cc+=t}e?f(i,e,e.startPTS,e.endPTS,e.startDTS,e.endDTS):a(r,i),i.PTSKnown=r.PTSKnown}}R.mergeDetails=u;function p(r,i,t){t===void 0&&(t=0);var e=-1;c(r,i,function(g,v,s){v.start=g.start,e=s});var n=i.fragments;if(e<0){n.forEach(function(g){g.start+=t});return}for(var d=e+1;d<n.length;d++)n[d].start=n[d-1].start+n[d-1].duration}R.mergeSubtitlePlaylists=p;function c(r,i,t){if(!(!r||!i))for(var e=Math.max(r.startSN,i.startSN)-i.startSN,n=Math.min(r.endSN,i.endSN)-i.startSN,d=i.startSN-r.startSN,g=e;g<=n;g++){var v=r.fragments[d+g],s=i.fragments[g];if(!v||!s)break;t(v,s,g)}}R.mapFragmentIntersection=c;function a(r,i){var t=i.startSN-r.startSN,e=r.fragments,n=i.fragments;if(!(t<0||t>e.length))for(var d=0;d<n.length;d++)n[d].start+=e[t].start}R.adjustSliding=a;function o(r,i,t){var e=1e3*(i.averagetargetduration?i.averagetargetduration:i.targetduration),n=e/2;return r&&i.endSN===r.endSN&&(e=n),t&&(e=Math.max(n,e-(window.performance.now()-t))),Math.round(e)}R.computeReloadInterval=o}).call(this,T("./src/polyfills/number.js").Number)},"./src/controller/stream-controller.js":function(w,R,T){"use strict";(function(_){var A=this&&this.__extends||function(){var l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,h){x.__proto__=h}||function(x,h){for(var E in h)h.hasOwnProperty(E)&&(x[E]=h[E])};return function(x,h){l(x,h);function E(){this.constructor=x}x.prototype=h===null?Object.create(h):(E.prototype=h.prototype,new E)}}();Object.defineProperty(R,"__esModule",{value:!0});var m=T("./src/utils/binary-search.js"),y=T("./src/utils/buffer-helper.js"),f=T("./src/demux/demuxer.js"),u=T("./src/events.js"),p=T("./src/controller/fragment-tracker.js"),c=T("./src/loader/fragment.js"),a=T("./src/loader/playlist-loader.js"),o=T("./src/controller/level-helper.js"),r=T("./src/utils/time-ranges.js"),i=T("./src/errors.js"),t=T("./src/utils/logger.js"),e=T("./src/utils/discontinuities.js"),n=T("./src/controller/fragment-finders.js"),d=T("./src/controller/gap-controller.js"),g=T("./src/controller/base-stream-controller.js"),v=100,s=function(l){A(x,l);function x(h,E){var S=l.call(this,h,u.default.MEDIA_ATTACHED,u.default.MEDIA_DETACHING,u.default.MANIFEST_LOADING,u.default.MANIFEST_PARSED,u.default.LEVEL_LOADED,u.default.KEY_LOADED,u.default.FRAG_LOADED,u.default.FRAG_LOAD_EMERGENCY_ABORTED,u.default.FRAG_PARSING_INIT_SEGMENT,u.default.FRAG_PARSING_DATA,u.default.FRAG_PARSED,u.default.ERROR,u.default.AUDIO_TRACK_SWITCHING,u.default.AUDIO_TRACK_SWITCHED,u.default.BUFFER_CREATED,u.default.BUFFER_APPENDED,u.default.BUFFER_FLUSHED)||this;return S.fragmentTracker=E,S.config=h.config,S.audioCodecSwap=!1,S._state=g.State.STOPPED,S.stallReported=!1,S.gapController=null,S}return x.prototype.startLoad=function(h){if(this.levels){var E=this.lastCurrentTime,S=this.hls;if(this.stopLoad(),this.setInterval(v),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var b=S.startLevel;b===-1&&(b=0,this.bitrateTest=!0),this.level=S.nextLoadLevel=b,this.loadedmetadata=!1}E>0&&h===-1&&(t.logger.log("override startPosition with lastCurrentTime @"+E.toFixed(3)),h=E),this.state=g.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=h,this.tick()}else this.forceStartLoad=!0,this.state=g.State.STOPPED},x.prototype.stopLoad=function(){this.forceStartLoad=!1,l.prototype.stopLoad.call(this)},x.prototype.doTick=function(){switch(this.state){case g.State.BUFFER_FLUSHING:this.fragLoadError=0;break;case g.State.IDLE:this._doTickIdle();break;case g.State.WAITING_LEVEL:var h=this.levels[this.level];h&&h.details&&(this.state=g.State.IDLE);break;case g.State.FRAG_LOADING_WAITING_RETRY:var E=window.performance.now(),S=this.retryDate;(!S||E>=S||this.media&&this.media.seeking)&&(t.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=g.State.IDLE);break;case g.State.ERROR:case g.State.STOPPED:case g.State.FRAG_LOADING:case g.State.PARSING:case g.State.PARSED:case g.State.ENDED:break;default:break}this._checkBuffer(),this._checkFragmentChanged()},x.prototype._doTickIdle=function(){var h=this.hls,E=h.config,S=this.media;if(!(this.levelLastLoaded===void 0||!S&&(this.startFragRequested||!E.startFragPrefetch))){var b;this.loadedmetadata?b=S.currentTime:b=this.nextLoadPosition;var I=h.nextLoadLevel,L=this.levels[I];if(!!L){var D=L.bitrate,O;D?O=Math.max(8*E.maxBufferSize/D,E.maxBufferLength):O=E.maxBufferLength,O=Math.min(O,E.maxMaxBufferLength);var F=y.BufferHelper.bufferInfo(this.mediaBuffer?this.mediaBuffer:S,b,E.maxBufferHole),C=F.len;if(!(C>=O)){t.logger.trace("buffer length of "+C.toFixed(3)+" is below max of "+O.toFixed(3)+". checking for more payload ..."),this.level=h.nextLoadLevel=I;var P=L.details;if(!P||P.live&&this.levelLastLoaded!==I){this.state=g.State.WAITING_LEVEL;return}if(this._streamEnded(F,P)){var k={};this.altAudio&&(k.type="video"),this.hls.trigger(u.default.BUFFER_EOS,k),this.state=g.State.ENDED;return}this._fetchPayloadOrEos(b,F,P)}}}},x.prototype._fetchPayloadOrEos=function(h,E,S){var b=this.fragPrevious,I=this.level,L=S.fragments,D=L.length;if(D!==0){var O=L[0].start,F=L[D-1].start+L[D-1].duration,C=E.end,P;if(S.initSegment&&!S.initSegment.data)P=S.initSegment;else if(S.live){var k=this.config.initialLiveManifestSize;if(D<k){t.logger.warn("Can not start playback of a level, reason: not enough fragments "+D+" < "+k);return}if(P=this._ensureFragmentAtLivePoint(S,C,O,F,b,L,D),P===null)return}else C<O&&(P=L[0]);P||(P=this._findFragment(O,b,D,L,C,F,S)),P&&(P.encrypted?(t.logger.log("Loading key for "+P.sn+" of ["+S.startSN+" ,"+S.endSN+"],level "+I),this._loadKey(P)):(t.logger.log("Loading "+P.sn+" of ["+S.startSN+" ,"+S.endSN+"],level "+I+", currentTime:"+h.toFixed(3)+",bufferEnd:"+C.toFixed(3)),this._loadFragment(P)))}},x.prototype._ensureFragmentAtLivePoint=function(h,E,S,b,I,L,D){var O=this.hls.config,F=this.media,C,P=O.liveMaxLatencyDuration!==void 0?O.liveMaxLatencyDuration:O.liveMaxLatencyDurationCount*h.targetduration;if(E<Math.max(S-O.maxFragLookUpTolerance,b-P)){var k=this.liveSyncPosition=this.computeLivePosition(S,h);t.logger.log("buffer end: "+E.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+k.toFixed(3)),E=k,F&&F.readyState&&F.duration>k&&(F.currentTime=k),this.nextLoadPosition=k}if(h.PTSKnown&&E>b&&F&&F.readyState)return null;if(this.startFragRequested&&!h.PTSKnown){if(I)if(h.hasProgramDateTime)t.logger.log("live playlist, switching playlist, load frag with same PDT: "+I.programDateTime),C=n.findFragmentByPDT(L,I.endProgramDateTime,O.maxFragLookUpTolerance);else{var B=I.sn+1;if(B>=h.startSN&&B<=h.endSN){var M=L[B-h.startSN];I.cc===M.cc&&(C=M,t.logger.log("live playlist, switching playlist, load frag with next SN: "+C.sn))}C||(C=m.default.search(L,function(N){return I.cc-N.cc}),C&&t.logger.log("live playlist, switching playlist, load frag with same CC: "+C.sn))}C||(C=L[Math.min(D-1,Math.round(D/2))],t.logger.log("live playlist, switching playlist, unknown, load middle frag : "+C.sn))}return C},x.prototype._findFragment=function(h,E,S,b,I,L,D){var O=this.hls.config,F;if(I<L){var C=I>L-O.maxFragLookUpTolerance?0:O.maxFragLookUpTolerance;F=n.findFragmentByPTS(E,b,I,C)}else F=b[S-1];if(F){var P=F.sn-D.startSN,k=E&&F.level===E.level,B=b[P-1],M=b[P+1];if(E&&F.sn===E.sn)if(k&&!F.backtracked)if(F.sn<D.endSN){var N=E.deltaPTS;N&&N>O.maxBufferHole&&E.dropped&&P?(F=B,t.logger.warn("SN just loaded, with large PTS gap between audio and video, maybe frag is not starting with a keyframe ? load previous one to try to overcome this")):(F=M,t.logger.log("SN just loaded, load next one: "+F.sn,F))}else F=null;else F.backtracked&&(M&&M.backtracked?(t.logger.warn("Already backtracked from fragment "+M.sn+", will not backtrack to fragment "+F.sn+". Loading fragment "+M.sn),F=M):(t.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),F.dropped=0,B?(F=B,F.backtracked=!0):P&&(F=null)))}return F},x.prototype._loadKey=function(h){this.state=g.State.KEY_LOADING,this.hls.trigger(u.default.KEY_LOADING,{frag:h})},x.prototype._loadFragment=function(h){var E=this.fragmentTracker.getState(h);this.fragCurrent=h,this.startFragRequested=!0,_.isFinite(h.sn)&&!h.bitrateTest&&(this.nextLoadPosition=h.start+h.duration),h.backtracked||E===p.FragmentState.NOT_LOADED||E===p.FragmentState.PARTIAL?(h.autoLevel=this.hls.autoLevelEnabled,h.bitrateTest=this.bitrateTest,this.hls.trigger(u.default.FRAG_LOADING,{frag:h}),this.demuxer||(this.demuxer=new f.default(this.hls,"main")),this.state=g.State.FRAG_LOADING):E===p.FragmentState.APPENDING&&this._reduceMaxBufferLength(h.duration)&&this.fragmentTracker.removeFragment(h)},Object.defineProperty(x.prototype,"state",{get:function(){return this._state},set:function(h){if(this.state!==h){var E=this.state;this._state=h,t.logger.log("main stream:"+E+"->"+h),this.hls.trigger(u.default.STREAM_STATE_TRANSITION,{previousState:E,nextState:h})}},enumerable:!0,configurable:!0}),x.prototype.getBufferedFrag=function(h){return this.fragmentTracker.getBufferedFrag(h,a.default.LevelType.MAIN)},Object.defineProperty(x.prototype,"currentLevel",{get:function(){var h=this.media;if(h){var E=this.getBufferedFrag(h.currentTime);if(E)return E.level}return-1},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"nextBufferedFrag",{get:function(){var h=this.media;return h?this.followingBufferedFrag(this.getBufferedFrag(h.currentTime)):null},enumerable:!0,configurable:!0}),x.prototype.followingBufferedFrag=function(h){return h?this.getBufferedFrag(h.endPTS+.5):null},Object.defineProperty(x.prototype,"nextLevel",{get:function(){var h=this.nextBufferedFrag;return h?h.level:-1},enumerable:!0,configurable:!0}),x.prototype._checkFragmentChanged=function(){var h,E,S=this.media;if(S&&S.readyState&&S.seeking===!1&&(E=S.currentTime,E>this.lastCurrentTime&&(this.lastCurrentTime=E),y.BufferHelper.isBuffered(S,E)?h=this.getBufferedFrag(E):y.BufferHelper.isBuffered(S,E+.1)&&(h=this.getBufferedFrag(E+.1)),h)){var b=h;if(b!==this.fragPlaying){this.hls.trigger(u.default.FRAG_CHANGED,{frag:b});var I=b.level;(!this.fragPlaying||this.fragPlaying.level!==I)&&this.hls.trigger(u.default.LEVEL_SWITCHED,{level:I}),this.fragPlaying=b}}},x.prototype.immediateLevelSwitch=function(){if(t.logger.log("immediateLevelSwitch"),!this.immediateSwitch){this.immediateSwitch=!0;var h=this.media,E=void 0;h?(E=h.paused,h.pause()):E=!0,this.previouslyPaused=E}var S=this.fragCurrent;S&&S.loader&&S.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(0,_.POSITIVE_INFINITY)},x.prototype.immediateLevelSwitchEnd=function(){var h=this.media;h&&h.buffered.length&&(this.immediateSwitch=!1,y.BufferHelper.isBuffered(h,h.currentTime)&&(h.currentTime-=1e-4),this.previouslyPaused||h.play())},x.prototype.nextLevelSwitch=function(){var h=this.media;if(h&&h.readyState){var E=void 0,S=void 0,b=void 0;if(S=this.getBufferedFrag(h.currentTime),S&&S.startPTS>1&&this.flushMainBuffer(0,S.startPTS-1),h.paused)E=0;else{var I=this.hls.nextLoadLevel,L=this.levels[I],D=this.fragLastKbps;D&&this.fragCurrent?E=this.fragCurrent.duration*L.bitrate/(1e3*D)+1:E=0}if(b=this.getBufferedFrag(h.currentTime+E),b&&(b=this.followingBufferedFrag(b),b)){var O=this.fragCurrent;O&&O.loader&&O.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(b.maxStartPTS,_.POSITIVE_INFINITY)}}},x.prototype.flushMainBuffer=function(h,E){this.state=g.State.BUFFER_FLUSHING;var S={startOffset:h,endOffset:E};this.altAudio&&(S.type="video"),this.hls.trigger(u.default.BUFFER_FLUSHING,S)},x.prototype.onMediaAttached=function(h){var E=this.media=this.mediaBuffer=h.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),E.addEventListener("seeking",this.onvseeking),E.addEventListener("seeked",this.onvseeked),E.addEventListener("ended",this.onvended);var S=this.config;this.levels&&S.autoStartLoad&&this.hls.startLoad(S.startPosition),this.gapController=new d.default(S,E,this.fragmentTracker,this.hls)},x.prototype.onMediaDetaching=function(){var h=this.media;h&&h.ended&&(t.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var E=this.levels;E&&E.forEach(function(S){S.details&&S.details.fragments.forEach(function(b){b.backtracked=void 0})}),h&&(h.removeEventListener("seeking",this.onvseeking),h.removeEventListener("seeked",this.onvseeked),h.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.stopLoad()},x.prototype.onMediaSeeked=function(){var h=this.media,E=h?h.currentTime:void 0;_.isFinite(E)&&t.logger.log("media seeked to "+E.toFixed(3)),this.tick()},x.prototype.onManifestLoading=function(){t.logger.log("trigger BUFFER_RESET"),this.hls.trigger(u.default.BUFFER_RESET),this.fragmentTracker.removeAllFragments(),this.stalled=!1,this.startPosition=this.lastCurrentTime=0},x.prototype.onManifestParsed=function(h){var E=!1,S=!1,b;h.levels.forEach(function(L){b=L.audioCodec,b&&(b.indexOf("mp4a.40.2")!==-1&&(E=!0),b.indexOf("mp4a.40.5")!==-1&&(S=!0))}),this.audioCodecSwitch=E&&S,this.audioCodecSwitch&&t.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=h.levels,this.startFragRequested=!1;var I=this.config;(I.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(I.startPosition)},x.prototype.onLevelLoaded=function(h){var E=h.details,S=h.level,b=this.levels[this.levelLastLoaded],I=this.levels[S],L=E.totalduration,D=0;if(t.logger.log("level "+S+" loaded ["+E.startSN+","+E.endSN+"],duration:"+L),E.live){var O=I.details;O&&E.fragments.length>0?(o.mergeDetails(O,E),D=E.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(D,O),E.PTSKnown&&_.isFinite(D)?t.logger.log("live playlist sliding:"+D.toFixed(3)):(t.logger.log("live playlist - outdated PTS, unknown sliding"),e.alignStream(this.fragPrevious,b,E))):(t.logger.log("live playlist - first load, unknown sliding"),E.PTSKnown=!1,e.alignStream(this.fragPrevious,b,E))}else E.PTSKnown=!1;if(I.details=E,this.levelLastLoaded=S,this.hls.trigger(u.default.LEVEL_UPDATED,{details:E,level:S}),this.startFragRequested===!1){if(this.startPosition===-1||this.lastCurrentTime===-1){var F=E.startTimeOffset;_.isFinite(F)?(F<0&&(t.logger.log("negative start time offset "+F+", count from end of last fragment"),F=D+L+F),t.logger.log("start time offset found in playlist, adjust startPosition to "+F),this.startPosition=F):E.live?(this.startPosition=this.computeLivePosition(D,E),t.logger.log("configure startPosition to "+this.startPosition)):this.startPosition=0,this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===g.State.WAITING_LEVEL&&(this.state=g.State.IDLE),this.tick()},x.prototype.onKeyLoaded=function(){this.state===g.State.KEY_LOADING&&(this.state=g.State.IDLE,this.tick())},x.prototype.onFragLoaded=function(h){var E=this,S=E.fragCurrent,b=E.hls,I=E.levels,L=E.media,D=h.frag;if(this.state===g.State.FRAG_LOADING&&S&&D.type==="main"&&D.level===S.level&&D.sn===S.sn){var O=h.stats,F=I[S.level],C=F.details;if(this.bitrateTest=!1,this.stats=O,t.logger.log("Loaded "+S.sn+" of ["+C.startSN+" ,"+C.endSN+"],level "+S.level),D.bitrateTest&&b.nextLoadLevel)this.state=g.State.IDLE,this.startFragRequested=!1,O.tparsed=O.tbuffered=window.performance.now(),b.trigger(u.default.FRAG_BUFFERED,{stats:O,frag:S,id:"main"}),this.tick();else if(D.sn==="initSegment")this.state=g.State.IDLE,O.tparsed=O.tbuffered=window.performance.now(),C.initSegment.data=h.payload,b.trigger(u.default.FRAG_BUFFERED,{stats:O,frag:S,id:"main"}),this.tick();else{t.logger.log("Parsing "+S.sn+" of ["+C.startSN+" ,"+C.endSN+"],level "+S.level+", cc "+S.cc),this.state=g.State.PARSING,this.pendingBuffering=!0,this.appended=!1,D.bitrateTest&&(D.bitrateTest=!1,this.fragmentTracker.onFragLoaded({frag:D}));var P=!(L&&L.seeking)&&(C.PTSKnown||!C.live),k=C.initSegment?C.initSegment.data:[],B=this._getAudioCodec(F),M=this.demuxer=this.demuxer||new f.default(this.hls,"main");M.push(h.payload,k,B,F.videoCodec,S,C.totalduration,P)}}this.fragLoadError=0},x.prototype.onFragParsingInitSegment=function(h){var E=this.fragCurrent,S=h.frag;if(E&&h.id==="main"&&S.sn===E.sn&&S.level===E.level&&this.state===g.State.PARSING){var b=h.tracks,I=void 0,L=void 0;if(b.audio&&this.altAudio&&delete b.audio,L=b.audio,L){var D=this.levels[this.level].audioCodec,O=navigator.userAgent.toLowerCase();D&&this.audioCodecSwap&&(t.logger.log("swapping playlist audio codec"),D.indexOf("mp4a.40.5")!==-1?D="mp4a.40.2":D="mp4a.40.5"),this.audioCodecSwitch&&L.metadata.channelCount!==1&&O.indexOf("firefox")===-1&&(D="mp4a.40.5"),O.indexOf("android")!==-1&&L.container!=="audio/mpeg"&&(D="mp4a.40.2",t.logger.log("Android: force audio codec to "+D)),L.levelCodec=D,L.id=h.id}L=b.video,L&&(L.levelCodec=this.levels[this.level].videoCodec,L.id=h.id),this.hls.trigger(u.default.BUFFER_CODECS,b);for(I in b){L=b[I],t.logger.log("main track:"+I+",container:"+L.container+",codecs[level/parsed]=["+L.levelCodec+"/"+L.codec+"]");var F=L.initSegment;F&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(u.default.BUFFER_APPENDING,{type:I,data:F,parent:"main",content:"initSegment"}))}this.tick()}},x.prototype.onFragParsingData=function(h){var E=this,S=this.fragCurrent,b=h.frag;if(S&&h.id==="main"&&b.sn===S.sn&&b.level===S.level&&!(h.type==="audio"&&this.altAudio)&&this.state===g.State.PARSING){var I=this.levels[this.level],L=S;if(_.isFinite(h.endPTS)||(h.endPTS=h.startPTS+S.duration,h.endDTS=h.startDTS+S.duration),h.hasAudio===!0&&L.addElementaryStream(c.default.ElementaryStreamTypes.AUDIO),h.hasVideo===!0&&L.addElementaryStream(c.default.ElementaryStreamTypes.VIDEO),t.logger.log("Parsed "+h.type+",PTS:["+h.startPTS.toFixed(3)+","+h.endPTS.toFixed(3)+"],DTS:["+h.startDTS.toFixed(3)+"/"+h.endDTS.toFixed(3)+"],nb:"+h.nb+",dropped:"+(h.dropped||0)),h.type==="video")if(L.dropped=h.dropped,L.dropped)if(L.backtracked)t.logger.warn("Already backtracked on this fragment, appending with the gap",L.sn);else{var D=I.details;if(D&&L.sn===D.startSN)t.logger.warn("missing video frame(s) on first frag, appending with gap",L.sn);else{t.logger.warn("missing video frame(s), backtracking fragment",L.sn),this.fragmentTracker.removeFragment(L),L.backtracked=!0,this.nextLoadPosition=h.startPTS,this.state=g.State.IDLE,this.fragPrevious=L,this.tick();return}}else L.backtracked=!1;var O=o.updateFragPTSDTS(I.details,L,h.startPTS,h.endPTS,h.startDTS,h.endDTS),F=this.hls;F.trigger(u.default.LEVEL_PTS_UPDATED,{details:I.details,level:this.level,drift:O,type:h.type,start:h.startPTS,end:h.endPTS}),[h.data1,h.data2].forEach(function(C){C&&C.length&&E.state===g.State.PARSING&&(E.appended=!0,E.pendingBuffering=!0,F.trigger(u.default.BUFFER_APPENDING,{type:h.type,data:C,parent:"main",content:"data"}))}),this.tick()}},x.prototype.onFragParsed=function(h){var E=this.fragCurrent,S=h.frag;E&&h.id==="main"&&S.sn===E.sn&&S.level===E.level&&this.state===g.State.PARSING&&(this.stats.tparsed=window.performance.now(),this.state=g.State.PARSED,this._checkAppendedParsed())},x.prototype.onAudioTrackSwitching=function(h){var E=!!h.url,S=h.id;if(!E){if(this.mediaBuffer!==this.media){t.logger.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var b=this.fragCurrent;b.loader&&(t.logger.log("switching to main audio track, cancel main fragment load"),b.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=g.State.IDLE}var I=this.hls;I.trigger(u.default.BUFFER_FLUSHING,{startOffset:0,endOffset:_.POSITIVE_INFINITY,type:"audio"}),I.trigger(u.default.AUDIO_TRACK_SWITCHED,{id:S}),this.altAudio=!1}},x.prototype.onAudioTrackSwitched=function(h){var E=h.id,S=!!this.hls.audioTracks[E].url;if(S){var b=this.videoBuffer;b&&this.mediaBuffer!==b&&(t.logger.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=b)}this.altAudio=S,this.tick()},x.prototype.onBufferCreated=function(h){var E=h.tracks,S,b,I=!1;for(var L in E){var D=E[L];D.id==="main"?(b=L,S=D,L==="video"&&(this.videoBuffer=E[L].buffer)):I=!0}I&&S?(t.logger.log("alternate track found, use "+b+".buffered to schedule main fragment loading"),this.mediaBuffer=S.buffer):this.mediaBuffer=this.media},x.prototype.onBufferAppended=function(h){if(h.parent==="main"){var E=this.state;(E===g.State.PARSING||E===g.State.PARSED)&&(this.pendingBuffering=h.pending>0,this._checkAppendedParsed())}},x.prototype._checkAppendedParsed=function(){if(this.state===g.State.PARSED&&(!this.appended||!this.pendingBuffering)){var h=this.fragCurrent;if(h){var E=this.mediaBuffer?this.mediaBuffer:this.media;t.logger.log("main buffered : "+r.default.toString(E.buffered)),this.fragPrevious=h;var S=this.stats;S.tbuffered=window.performance.now(),this.fragLastKbps=Math.round(8*S.total/(S.tbuffered-S.tfirst)),this.hls.trigger(u.default.FRAG_BUFFERED,{stats:S,frag:h,id:"main"}),this.state=g.State.IDLE}this.tick()}},x.prototype.onError=function(h){var E=h.frag||this.fragCurrent;if(!(E&&E.type!=="main")){var S=!!this.media&&y.BufferHelper.isBuffered(this.media,this.media.currentTime)&&y.BufferHelper.isBuffered(this.media,this.media.currentTime+.5);switch(h.details){case i.ErrorDetails.FRAG_LOAD_ERROR:case i.ErrorDetails.FRAG_LOAD_TIMEOUT:case i.ErrorDetails.KEY_LOAD_ERROR:case i.ErrorDetails.KEY_LOAD_TIMEOUT:if(!h.fatal)if(this.fragLoadError+1<=this.config.fragLoadingMaxRetry){var b=Math.min(Math.pow(2,this.fragLoadError)*this.config.fragLoadingRetryDelay,this.config.fragLoadingMaxRetryTimeout);t.logger.warn("mediaController: frag loading failed, retry in "+b+" ms"),this.retryDate=window.performance.now()+b,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.fragLoadError++,this.state=g.State.FRAG_LOADING_WAITING_RETRY}else t.logger.error("mediaController: "+h.details+" reaches max retry, redispatch as fatal ..."),h.fatal=!0,this.state=g.State.ERROR;break;case i.ErrorDetails.LEVEL_LOAD_ERROR:case i.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==g.State.ERROR&&(h.fatal?(this.state=g.State.ERROR,t.logger.warn("streamController: "+h.details+",switch to "+this.state+" state ...")):!h.levelRetry&&this.state===g.State.WAITING_LEVEL&&(this.state=g.State.IDLE));break;case i.ErrorDetails.BUFFER_FULL_ERROR:h.parent==="main"&&(this.state===g.State.PARSING||this.state===g.State.PARSED)&&(S?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=g.State.IDLE):(t.logger.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.flushMainBuffer(0,_.POSITIVE_INFINITY)));break;default:break}}},x.prototype._reduceMaxBufferLength=function(h){var E=this.config;return E.maxMaxBufferLength>=h?(E.maxMaxBufferLength/=2,t.logger.warn("main:reduce max buffer length to "+E.maxMaxBufferLength+"s"),!0):!1},x.prototype._checkBuffer=function(){var h=this.media;if(!(!h||h.readyState===0)){var E=this.mediaBuffer?this.mediaBuffer:h,S=E.buffered;!this.loadedmetadata&&S.length?(this.loadedmetadata=!0,this._seekToStartPos()):this.immediateSwitch?this.immediateLevelSwitchEnd():this.gapController.poll(this.lastCurrentTime,S)}},x.prototype.onFragLoadEmergencyAborted=function(){this.state=g.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},x.prototype.onBufferFlushed=function(){var h=this.mediaBuffer?this.mediaBuffer:this.media;h&&this.fragmentTracker.detectEvictedFragments(c.default.ElementaryStreamTypes.VIDEO,h.buffered),this.state=g.State.IDLE,this.fragPrevious=null},x.prototype.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},x.prototype.computeLivePosition=function(h,E){var S=this.config.liveSyncDuration!==void 0?this.config.liveSyncDuration:this.config.liveSyncDurationCount*E.targetduration;return h+Math.max(0,E.totalduration-S)},x.prototype._seekToStartPos=function(){var h=this.media,E=h.currentTime,S=h.seeking?E:this.startPosition;E!==S&&(t.logger.log("target start position not buffered, seek to buffered.start(0) "+S+" from current time "+E+" "),h.currentTime=S)},x.prototype._getAudioCodec=function(h){var E=this.config.defaultAudioCodec||h.audioCodec;return this.audioCodecSwap&&(t.logger.log("swapping playlist audio codec"),E&&(E.indexOf("mp4a.40.5")!==-1?E="mp4a.40.2":E="mp4a.40.5")),E},Object.defineProperty(x.prototype,"liveSyncPosition",{get:function(){return this._liveSyncPosition},set:function(h){this._liveSyncPosition=h},enumerable:!0,configurable:!0}),x}(g.default);R.default=s}).call(this,T("./src/polyfills/number.js").Number)},"./src/controller/subtitle-stream-controller.js":function(w,R,T){"use strict";var _=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var d in n)n.hasOwnProperty(d)&&(e[d]=n[d])};return function(e,n){t(e,n);function d(){this.constructor=e}e.prototype=n===null?Object.create(n):(d.prototype=n.prototype,new d)}}();Object.defineProperty(R,"__esModule",{value:!0});var A=T("./src/events.js"),m=T("./src/utils/logger.js"),y=T("./src/crypt/decrypter.js"),f=T("./src/utils/buffer-helper.js"),u=T("./src/controller/fragment-finders.js"),p=T("./src/controller/fragment-tracker.js"),c=T("./src/controller/base-stream-controller.js"),a=T("./src/controller/level-helper.js"),o=window.performance,r=500,i=function(t){_(e,t);function e(n,d){var g=t.call(this,n,A.default.MEDIA_ATTACHED,A.default.MEDIA_DETACHING,A.default.ERROR,A.default.KEY_LOADED,A.default.FRAG_LOADED,A.default.SUBTITLE_TRACKS_UPDATED,A.default.SUBTITLE_TRACK_SWITCH,A.default.SUBTITLE_TRACK_LOADED,A.default.SUBTITLE_FRAG_PROCESSED,A.default.LEVEL_UPDATED)||this;return g.fragmentTracker=d,g.config=n.config,g.state=c.State.STOPPED,g.tracks=[],g.tracksBuffered=[],g.currentTrackId=-1,g.decrypter=new y.default(n,n.config),g.lastAVStart=0,g._onMediaSeeking=g.onMediaSeeking.bind(g),g}return e.prototype.onSubtitleFragProcessed=function(n){var d=n.frag,g=n.success;if(this.fragPrevious=d,this.state=c.State.IDLE,!!g){var v=this.tracksBuffered[this.currentTrackId];if(!!v){for(var s,l=d.start,x=0;x<v.length;x++)if(l>=v[x].start&&l<=v[x].end){s=v[x];break}var h=d.start+d.duration;s?s.end=h:(s={start:l,end:h},v.push(s))}}},e.prototype.onMediaAttached=function(n){var d=n.media;this.media=d,d.addEventListener("seeking",this._onMediaSeeking),this.state=c.State.IDLE},e.prototype.onMediaDetaching=function(){this.media.removeEventListener("seeking",this._onMediaSeeking),this.media=null,this.state=c.State.STOPPED},e.prototype.onError=function(n){var d=n.frag;!d||d.type!=="subtitle"||(this.state=c.State.IDLE)},e.prototype.onSubtitleTracksUpdated=function(n){var d=this;m.logger.log("subtitle tracks updated"),this.tracksBuffered=[],this.tracks=n.subtitleTracks,this.tracks.forEach(function(g){d.tracksBuffered[g.id]=[]})},e.prototype.onSubtitleTrackSwitch=function(n){if(this.currentTrackId=n.id,!this.tracks||this.currentTrackId===-1){this.clearInterval();return}var d=this.tracks[this.currentTrackId];d&&d.details&&this.setInterval(r)},e.prototype.onSubtitleTrackLoaded=function(n){var d=n.id,g=n.details,v=this,s=v.currentTrackId,l=v.tracks,x=l[s];d>=l.length||d!==s||!x||(g.live&&a.mergeSubtitlePlaylists(x.details,g,this.lastAVStart),x.details=g,this.setInterval(r))},e.prototype.onKeyLoaded=function(){this.state===c.State.KEY_LOADING&&(this.state=c.State.IDLE)},e.prototype.onFragLoaded=function(n){var d=this.fragCurrent,g=n.frag.decryptdata,v=n.frag,s=this.hls;if(this.state===c.State.FRAG_LOADING&&d&&n.frag.type==="subtitle"&&d.sn===n.frag.sn&&n.payload.byteLength>0&&g&&g.key&&g.method==="AES-128"){var l=o.now();this.decrypter.decrypt(n.payload,g.key.buffer,g.iv.buffer,function(x){var h=o.now();s.trigger(A.default.FRAG_DECRYPTED,{frag:v,payload:x,stats:{tstart:l,tdecrypt:h}})})}},e.prototype.onLevelUpdated=function(n){var d=n.details,g=d.fragments;this.lastAVStart=g.length?g[0].start:0},e.prototype.doTick=function(){if(!this.media){this.state=c.State.IDLE;return}switch(this.state){case c.State.IDLE:{var n=this,d=n.config,g=n.currentTrackId,v=n.fragmentTracker,s=n.media,l=n.tracks;if(!l||!l[g]||!l[g].details)break;var x=d.maxBufferHole,h=d.maxFragLookUpTolerance,E=Math.min(d.maxBufferLength,d.maxMaxBufferLength),S=f.BufferHelper.bufferedInfo(this._getBuffered(),s.currentTime,x),b=S.end,I=S.len,L=l[g].details,D=L.fragments,O=D.length,F=D[O-1].start+D[O-1].duration;if(I>E)return;var C=void 0,P=this.fragPrevious;b<F?(P&&L.hasProgramDateTime&&(C=u.findFragmentByPDT(D,P.endProgramDateTime,h)),C||(C=u.findFragmentByPTS(P,D,b,h))):C=D[O-1],C&&C.encrypted?(m.logger.log("Loading key for "+C.sn),this.state=c.State.KEY_LOADING,this.hls.trigger(A.default.KEY_LOADING,{frag:C})):C&&v.getState(C)===p.FragmentState.NOT_LOADED&&(this.fragCurrent=C,this.state=c.State.FRAG_LOADING,this.hls.trigger(A.default.FRAG_LOADING,{frag:C}))}}},e.prototype.stopLoad=function(){this.lastAVStart=0,t.prototype.stopLoad.call(this)},e.prototype._getBuffered=function(){return this.tracksBuffered[this.currentTrackId]||[]},e.prototype.onMediaSeeking=function(){this.fragPrevious=null},e}(c.default);R.SubtitleStreamController=i},"./src/controller/subtitle-track-controller.js":function(w,R,T){"use strict";(function(_){var A=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,r){o.__proto__=r}||function(o,r){for(var i in r)r.hasOwnProperty(i)&&(o[i]=r[i])};return function(o,r){a(o,r);function i(){this.constructor=o}o.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}}();Object.defineProperty(R,"__esModule",{value:!0});var m=T("./src/events.js"),y=T("./src/event-handler.js"),f=T("./src/utils/logger.js"),u=T("./src/controller/level-helper.js"),p=function(a){A(o,a);function o(r){var i=a.call(this,r,m.default.MEDIA_ATTACHED,m.default.MEDIA_DETACHING,m.default.MANIFEST_LOADED,m.default.SUBTITLE_TRACK_LOADED)||this;return i.tracks=[],i.trackId=-1,i.media=null,i.stopped=!0,i.subtitleDisplay=!0,i}return o.prototype.destroy=function(){y.default.prototype.destroy.call(this)},o.prototype.onMediaAttached=function(r){var i=this;this.media=r.media,!!this.media&&(this.queuedDefaultTrack&&(this.subtitleTrack=this.queuedDefaultTrack,delete this.queuedDefaultTrack),this.trackChangeListener=this._onTextTracksChanged.bind(this),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.subtitlePollingInterval=setInterval(function(){i.trackChangeListener()},500):this.media.textTracks.addEventListener("change",this.trackChangeListener))},o.prototype.onMediaDetaching=function(){!this.media||(this.useTextTrackPolling?clearInterval(this.subtitlePollingInterval):this.media.textTracks.removeEventListener("change",this.trackChangeListener),this.media=null)},o.prototype.onManifestLoaded=function(r){var i=this,t=r.subtitles||[];this.tracks=t,this.hls.trigger(m.default.SUBTITLE_TRACKS_UPDATED,{subtitleTracks:t}),t.forEach(function(e){e.default&&(i.media?i.subtitleTrack=e.id:i.queuedDefaultTrack=e.id)})},o.prototype.onSubtitleTrackLoaded=function(r){var i=this,t=r.id,e=r.details,n=this,d=n.trackId,g=n.tracks,v=g[d];if(t>=g.length||t!==d||!v||this.stopped){this._clearReloadTimer();return}if(f.logger.log("subtitle track "+t+" loaded"),e.live){var s=u.computeReloadInterval(v.details,e,r.stats.trequest);f.logger.log("Reloading live subtitle playlist in "+s+"ms"),this.timer=setTimeout(function(){i._loadCurrentTrack()},s)}else this._clearReloadTimer()},o.prototype.startLoad=function(){this.stopped=!1,this._loadCurrentTrack()},o.prototype.stopLoad=function(){this.stopped=!0,this._clearReloadTimer()},Object.defineProperty(o.prototype,"subtitleTracks",{get:function(){return this.tracks},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"subtitleTrack",{get:function(){return this.trackId},set:function(r){this.trackId!==r&&(this._toggleTrackModes(r),this._setSubtitleTrackInternal(r))},enumerable:!0,configurable:!0}),o.prototype._clearReloadTimer=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},o.prototype._loadCurrentTrack=function(){var r=this,i=r.trackId,t=r.tracks,e=r.hls,n=t[i];i<0||!n||n.details&&!n.details.live||(f.logger.log("Loading subtitle track "+i),e.trigger(m.default.SUBTITLE_TRACK_LOADING,{url:n.url,id:i}))},o.prototype._toggleTrackModes=function(r){var i=this,t=i.media,e=i.subtitleDisplay,n=i.trackId;if(!!t){var d=c(t.textTracks);if(r===-1)[].slice.call(d).forEach(function(s){s.mode="disabled"});else{var g=d[n];g&&(g.mode="disabled")}var v=d[r];v&&(v.mode=e?"showing":"hidden")}},o.prototype._setSubtitleTrackInternal=function(r){var i=this,t=i.hls,e=i.tracks;!_.isFinite(r)||r<-1||r>=e.length||(this.trackId=r,f.logger.log("Switching to subtitle track "+r),t.trigger(m.default.SUBTITLE_TRACK_SWITCH,{id:r}),this._loadCurrentTrack())},o.prototype._onTextTracksChanged=function(){if(!!this.media){for(var r=-1,i=c(this.media.textTracks),t=0;t<i.length;t++)if(i[t].mode==="hidden")r=t;else if(i[t].mode==="showing"){r=t;break}this.subtitleTrack=r}},o}(y.default);function c(a){for(var o=[],r=0;r<a.length;r++){var i=a[r];i.kind==="subtitles"&&i.label&&o.push(a[r])}return o}R.default=p}).call(this,T("./src/polyfills/number.js").Number)},"./src/controller/timeline-controller.js":function(w,R,T){"use strict";(function(_){var A=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var d in n)n.hasOwnProperty(d)&&(e[d]=n[d])};return function(e,n){t(e,n);function d(){this.constructor=e}e.prototype=n===null?Object.create(n):(d.prototype=n.prototype,new d)}}();Object.defineProperty(R,"__esModule",{value:!0});var m=T("./src/events.js"),y=T("./src/event-handler.js"),f=T("./src/utils/cea-608-parser.js"),u=T("./src/utils/output-filter.js"),p=T("./src/utils/webvtt-parser.js"),c=T("./src/utils/logger.js"),a=T("./src/utils/texttrack-utils.js");function o(t,e){return t&&t.label===e.name&&!(t.textTrack1||t.textTrack2)}function r(t,e,n,d){return Math.min(e,d)-Math.max(t,n)}var i=function(t){A(e,t);function e(n){var d=t.call(this,n,m.default.MEDIA_ATTACHING,m.default.MEDIA_DETACHING,m.default.FRAG_PARSING_USERDATA,m.default.FRAG_DECRYPTED,m.default.MANIFEST_LOADING,m.default.MANIFEST_LOADED,m.default.FRAG_LOADED,m.default.LEVEL_SWITCHING,m.default.INIT_PTS_FOUND)||this;if(d.hls=n,d.config=n.config,d.enabled=!0,d.Cues=n.config.cueHandler,d.textTracks=[],d.tracks=[],d.unparsedVttFrags=[],d.initPTS=[],d.cueRanges=[],d.captionsTracks={},d.captionsProperties={textTrack1:{label:d.config.captionsTextTrack1Label,languageCode:d.config.captionsTextTrack1LanguageCode},textTrack2:{label:d.config.captionsTextTrack2Label,languageCode:d.config.captionsTextTrack2LanguageCode}},d.config.enableCEA708Captions){var g=new u.default(d,"textTrack1"),v=new u.default(d,"textTrack2");d.cea608Parser=new f.default(0,g,v)}return d}return e.prototype.addCues=function(n,d,g,v){for(var s=this.cueRanges,l=!1,x=s.length;x--;){var h=s[x],E=r(h[0],h[1],d,g);if(E>=0&&(h[0]=Math.min(h[0],d),h[1]=Math.max(h[1],g),l=!0,E/(g-d)>.5))return}l||s.push([d,g]),this.Cues.newCue(this.captionsTracks[n],d,g,v)},e.prototype.onInitPtsFound=function(n){var d=this;if(n.id==="main"&&(this.initPTS[n.frag.cc]=n.initPTS),this.unparsedVttFrags.length){var g=this.unparsedVttFrags;this.unparsedVttFrags=[],g.forEach(function(v){d.onFragLoaded(v)})}},e.prototype.getExistingTrack=function(n){var d=this.media;if(d)for(var g=0;g<d.textTracks.length;g++){var v=d.textTracks[g];if(v[n])return v}return null},e.prototype.createCaptionsTrack=function(n){var d=this.captionsProperties[n],g=d.label,v=d.languageCode,s=this.captionsTracks;if(!s[n]){var l=this.getExistingTrack(n);if(l)s[n]=l,a.clearCurrentCues(s[n]),a.sendAddTrackEvent(s[n],this.media);else{var x=this.createTextTrack("captions",g,v);x&&(x[n]=!0,s[n]=x)}}},e.prototype.createTextTrack=function(n,d,g){var v=this.media;if(v)return v.addTextTrack(n,d,g)},e.prototype.destroy=function(){y.default.prototype.destroy.call(this)},e.prototype.onMediaAttaching=function(n){this.media=n.media,this._cleanTracks()},e.prototype.onMediaDetaching=function(){var n=this.captionsTracks;Object.keys(n).forEach(function(d){a.clearCurrentCues(n[d]),delete n[d]})},e.prototype.onManifestLoading=function(){this.lastSn=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this._cleanTracks()},e.prototype._cleanTracks=function(){var n=this.media;if(n){var d=n.textTracks;if(d)for(var g=0;g<d.length;g++)a.clearCurrentCues(d[g])}},e.prototype.onManifestLoaded=function(n){var d=this;if(this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.cueRanges=[],this.config.enableWebVTT){this.tracks=n.subtitles||[];var g=this.media?this.media.textTracks:[];this.tracks.forEach(function(v,s){var l;if(s<g.length){for(var x=null,h=0;h<g.length;h++)if(o(g[h],v)){x=g[h];break}x&&(l=x)}l||(l=d.createTextTrack("subtitles",v.name,v.lang)),v.default?l.mode=d.hls.subtitleDisplay?"showing":"hidden":l.mode="disabled",d.textTracks.push(l)})}},e.prototype.onLevelSwitching=function(){this.enabled=this.hls.currentLevel.closedCaptions!=="NONE"},e.prototype.onFragLoaded=function(n){var d=n.frag,g=n.payload;if(d.type==="main"){var v=d.sn;if(v!==this.lastSn+1){var s=this.cea608Parser;s&&s.reset()}this.lastSn=v}else if(d.type==="subtitle")if(g.byteLength){if(!_.isFinite(this.initPTS[d.cc])){this.unparsedVttFrags.push(n),this.initPTS.length&&this.hls.trigger(m.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d});return}var l=d.decryptdata;(l==null||l.key==null||l.method!=="AES-128")&&this._parseVTTs(d,g)}else this.hls.trigger(m.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d})},e.prototype._parseVTTs=function(n,d){var g=this.vttCCs;g[n.cc]||(g[n.cc]={start:n.start,prevCC:this.prevCC,new:!0},this.prevCC=n.cc);var v=this.textTracks,s=this.hls;p.default.parse(d,this.initPTS[n.cc],g,n.cc,function(l){var x=v[n.level];if(x.mode==="disabled"){s.trigger(m.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n});return}l.forEach(function(h){if(!x.cues.getCueById(h.id))try{x.addCue(h)}catch(S){var E=new window.TextTrackCue(h.startTime,h.endTime,h.text);E.id=h.id,x.addCue(E)}}),s.trigger(m.default.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})},function(l){c.logger.log("Failed to parse VTT cue: "+l),s.trigger(m.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n})})},e.prototype.onFragDecrypted=function(n){var d=n.payload,g=n.frag;if(g.type==="subtitle"){if(!_.isFinite(this.initPTS[g.cc])){this.unparsedVttFrags.push(n);return}this._parseVTTs(g,d)}},e.prototype.onFragParsingUserdata=function(n){if(this.enabled&&this.config.enableCEA708Captions)for(var d=0;d<n.samples.length;d++){var g=this.extractCea608Data(n.samples[d].bytes);this.cea608Parser.addData(n.samples[d].pts,g)}},e.prototype.extractCea608Data=function(n){for(var d=n[0]&31,g=2,v,s,l,x,h,E=[],S=0;S<d;S++)v=n[g++],s=127&n[g++],l=127&n[g++],x=(4&v)!=0,h=3&v,!(s===0&&l===0)&&x&&h===0&&(E.push(s),E.push(l));return E},e}(y.default);R.default=i}).call(this,T("./src/polyfills/number.js").Number)},"./src/crypt/aes-crypto.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=function(){function A(m,y){this.subtle=m,this.aesIV=y}return A.prototype.decrypt=function(m,y){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},y,m)},A}();R.default=_},"./src/crypt/aes-decryptor.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});function _(m){var y=m.byteLength,f=y&&new DataView(m).getUint8(y-1);return f?m.slice(0,y-f):m}R.removePadding=_;var A=function(){function m(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.initTable()}return m.prototype.uint8ArrayToUint32Array_=function(y){for(var f=new DataView(y),u=new Uint32Array(4),p=0;p<4;p++)u[p]=f.getUint32(p*4);return u},m.prototype.initTable=function(){var y=this.sBox,f=this.invSBox,u=this.subMix,p=u[0],c=u[1],a=u[2],o=u[3],r=this.invSubMix,i=r[0],t=r[1],e=r[2],n=r[3],d=new Uint32Array(256),g=0,v=0,s=0;for(s=0;s<256;s++)s<128?d[s]=s<<1:d[s]=s<<1^283;for(s=0;s<256;s++){var l=v^v<<1^v<<2^v<<3^v<<4;l=l>>>8^l&255^99,y[g]=l,f[l]=g;var x=d[g],h=d[x],E=d[h],S=d[l]*257^l*16843008;p[g]=S<<24|S>>>8,c[g]=S<<16|S>>>16,a[g]=S<<8|S>>>24,o[g]=S,S=E*16843009^h*65537^x*257^g*16843008,i[l]=S<<24|S>>>8,t[l]=S<<16|S>>>16,e[l]=S<<8|S>>>24,n[l]=S,g?(g=x^d[d[d[E^x]]],v^=d[d[v]]):g=v=1}},m.prototype.expandKey=function(y){for(var f=this.uint8ArrayToUint32Array_(y),u=!0,p=0;p<f.length&&u;)u=f[p]===this.key[p],p++;if(!u){this.key=f;var c=this.keySize=f.length;if(c!==4&&c!==6&&c!==8)throw new Error("Invalid aes key size="+c);var a=this.ksRows=(c+6+1)*4,o,r,i=this.keySchedule=new Uint32Array(a),t=this.invKeySchedule=new Uint32Array(a),e=this.sBox,n=this.rcon,d=this.invSubMix,g=d[0],v=d[1],s=d[2],l=d[3],x,h;for(o=0;o<a;o++){if(o<c){x=i[o]=f[o];continue}h=x,o%c==0?(h=h<<8|h>>>24,h=e[h>>>24]<<24|e[h>>>16&255]<<16|e[h>>>8&255]<<8|e[h&255],h^=n[o/c|0]<<24):c>6&&o%c==4&&(h=e[h>>>24]<<24|e[h>>>16&255]<<16|e[h>>>8&255]<<8|e[h&255]),i[o]=x=(i[o-c]^h)>>>0}for(r=0;r<a;r++)o=a-r,r&3?h=i[o]:h=i[o-4],r<4||o<=4?t[r]=h:t[r]=g[e[h>>>24]]^v[e[h>>>16&255]]^s[e[h>>>8&255]]^l[e[h&255]],t[r]=t[r]>>>0}},m.prototype.networkToHostOrderSwap=function(y){return y<<24|(y&65280)<<8|(y&16711680)>>8|y>>>24},m.prototype.decrypt=function(y,f,u,p){for(var c=this.keySize+6,a=this.invKeySchedule,o=this.invSBox,r=this.invSubMix,i=r[0],t=r[1],e=r[2],n=r[3],d=this.uint8ArrayToUint32Array_(u),g=d[0],v=d[1],s=d[2],l=d[3],x=new Int32Array(y),h=new Int32Array(x.length),E,S,b,I,L,D,O,F,C,P,k,B,M,N,j=this.networkToHostOrderSwap;f<x.length;){for(C=j(x[f]),P=j(x[f+1]),k=j(x[f+2]),B=j(x[f+3]),L=C^a[0],D=B^a[1],O=k^a[2],F=P^a[3],M=4,N=1;N<c;N++)E=i[L>>>24]^t[D>>16&255]^e[O>>8&255]^n[F&255]^a[M],S=i[D>>>24]^t[O>>16&255]^e[F>>8&255]^n[L&255]^a[M+1],b=i[O>>>24]^t[F>>16&255]^e[L>>8&255]^n[D&255]^a[M+2],I=i[F>>>24]^t[L>>16&255]^e[D>>8&255]^n[O&255]^a[M+3],L=E,D=S,O=b,F=I,M=M+4;E=o[L>>>24]<<24^o[D>>16&255]<<16^o[O>>8&255]<<8^o[F&255]^a[M],S=o[D>>>24]<<24^o[O>>16&255]<<16^o[F>>8&255]<<8^o[L&255]^a[M+1],b=o[O>>>24]<<24^o[F>>16&255]<<16^o[L>>8&255]<<8^o[D&255]^a[M+2],I=o[F>>>24]<<24^o[L>>16&255]<<16^o[D>>8&255]<<8^o[O&255]^a[M+3],M=M+3,h[f]=j(E^g),h[f+1]=j(I^v),h[f+2]=j(b^s),h[f+3]=j(S^l),g=C,v=P,s=k,l=B,f=f+4}return p?_(h.buffer):h.buffer},m.prototype.destroy=function(){this.key=void 0,this.keySize=void 0,this.ksRows=void 0,this.sBox=void 0,this.invSBox=void 0,this.subMix=void 0,this.invSubMix=void 0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.rcon=void 0},m}();R.default=A},"./src/crypt/decrypter.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/crypt/aes-crypto.js"),A=T("./src/crypt/fast-aes-key.js"),m=T("./src/crypt/aes-decryptor.js"),y=T("./src/errors.js"),f=T("./src/utils/logger.js"),u=T("./src/events.js"),p=T("./src/utils/get-self-scope.js"),c=p.getSelfScope(),a=function(){function o(r,i,t){var e=(t===void 0?{}:t).removePKCS7Padding,n=e===void 0?!0:e;if(this.logEnabled=!0,this.observer=r,this.config=i,this.removePKCS7Padding=n,n)try{var d=c.crypto;d&&(this.subtle=d.subtle||d.webkitSubtle)}catch(g){}this.disableWebCrypto=!this.subtle}return o.prototype.isSync=function(){return this.disableWebCrypto&&this.config.enableSoftwareAES},o.prototype.decrypt=function(r,i,t,e){var n=this;if(this.disableWebCrypto&&this.config.enableSoftwareAES){this.logEnabled&&(f.logger.log("JS AES decrypt"),this.logEnabled=!1);var d=this.decryptor;d||(this.decryptor=d=new m.default),d.expandKey(i),e(d.decrypt(r,0,t,this.removePKCS7Padding))}else{this.logEnabled&&(f.logger.log("WebCrypto AES decrypt"),this.logEnabled=!1);var g=this.subtle;this.key!==i&&(this.key=i,this.fastAesKey=new A.default(g,i)),this.fastAesKey.expandKey().then(function(v){var s=new _.default(g,t);s.decrypt(r,v).catch(function(l){n.onWebCryptoError(l,r,i,t,e)}).then(function(l){e(l)})}).catch(function(v){n.onWebCryptoError(v,r,i,t,e)})}},o.prototype.onWebCryptoError=function(r,i,t,e,n){this.config.enableSoftwareAES?(f.logger.log("WebCrypto Error, disable WebCrypto API"),this.disableWebCrypto=!0,this.logEnabled=!0,this.decrypt(i,t,e,n)):(f.logger.error("decrypting error : "+r.message),this.observer.trigger(u.default.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!0,reason:r.message}))},o.prototype.destroy=function(){var r=this.decryptor;r&&(r.destroy(),this.decryptor=void 0)},o}();R.default=a},"./src/crypt/fast-aes-key.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=function(){function A(m,y){this.subtle=m,this.key=y}return A.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},A}();R.default=_},"./src/demux/aacdemuxer.js":function(w,R,T){"use strict";(function(_){Object.defineProperty(R,"__esModule",{value:!0});var A=T("./src/demux/adts.js"),m=T("./src/utils/logger.js"),y=T("./src/demux/id3.js"),f=function(){function u(p,c,a){this.observer=p,this.config=a,this.remuxer=c}return u.prototype.resetInitSegment=function(p,c,a,o){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:c,duration:o,inputTimeScale:9e4}},u.prototype.resetTimeStamp=function(){},u.probe=function(p){if(!p)return!1;for(var c=y.default.getID3Data(p,0)||[],a=c.length,o=p.length;a<o;a++)if(A.probe(p,a))return m.logger.log("ADTS sync word found !"),!0;return!1},u.prototype.append=function(p,c,a,o){for(var r=this._audioTrack,i=y.default.getID3Data(p,0)||[],t=y.default.getTimeStamp(i),e=_.isFinite(t)?t*90:c*9e4,n=0,d=e,g=p.length,v=i.length,s=[{pts:d,dts:d,data:i}];v<g-1;)if(A.isHeader(p,v)&&v+5<g){A.initTrackConfig(r,this.observer,p,v,r.manifestCodec);var l=A.appendFrame(r,p,v,e,n);if(l)v+=l.length,d=l.sample.pts,n++;else{m.logger.log("Unable to parse AAC frame");break}}else y.default.isHeader(p,v)?(i=y.default.getID3Data(p,v),s.push({pts:d,dts:d,data:i}),v+=i.length):v++;this.remuxer.remux(r,{samples:[]},{samples:s,inputTimeScale:9e4},{samples:[]},c,a,o)},u.prototype.destroy=function(){},u}();R.default=f}).call(this,T("./src/polyfills/number.js").Number)},"./src/demux/adts.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/utils/logger.js"),A=T("./src/errors.js"),m=T("./src/events.js");function y(e,n,d,g){var v,s,l,x,h,E=navigator.userAgent.toLowerCase(),S=g,b=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];if(v=((n[d+2]&192)>>>6)+1,s=(n[d+2]&60)>>>2,s>b.length-1){e.trigger(m.default.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+s});return}return x=(n[d+2]&1)<<2,x|=(n[d+3]&192)>>>6,_.logger.log("manifest codec:"+g+",ADTS data:type:"+v+",sampleingIndex:"+s+"["+b[s]+"Hz],channelConfig:"+x),/firefox/i.test(E)?s>=6?(v=5,h=new Array(4),l=s-3):(v=2,h=new Array(2),l=s):E.indexOf("android")!==-1?(v=2,h=new Array(2),l=s):(v=5,h=new Array(4),g&&(g.indexOf("mp4a.40.29")!==-1||g.indexOf("mp4a.40.5")!==-1)||!g&&s>=6?l=s-3:((g&&g.indexOf("mp4a.40.2")!==-1&&(s>=6&&x===1||/vivaldi/i.test(E))||!g&&x===1)&&(v=2,h=new Array(2)),l=s)),h[0]=v<<3,h[0]|=(s&14)>>1,h[1]|=(s&1)<<7,h[1]|=x<<3,v===5&&(h[1]|=(l&14)>>1,h[2]=(l&1)<<7,h[2]|=2<<2,h[3]=0),{config:h,samplerate:b[s],channelCount:x,codec:"mp4a.40."+v,manifestCodec:S}}R.getAudioConfig=y;function f(e,n){return e[n]===255&&(e[n+1]&246)==240}R.isHeaderPattern=f;function u(e,n){return e[n+1]&1?7:9}R.getHeaderLength=u;function p(e,n){return(e[n+3]&3)<<11|e[n+4]<<3|(e[n+5]&224)>>>5}R.getFullFrameLength=p;function c(e,n){return!!(n+1<e.length&&f(e,n))}R.isHeader=c;function a(e,n){if(n+1<e.length&&f(e,n)){var d=u(e,n),g=d;n+5<e.length&&(g=p(e,n));var v=n+g;if(v===e.length||v+1<e.length&&f(e,v))return!0}return!1}R.probe=a;function o(e,n,d,g,v){if(!e.samplerate){var s=y(n,d,g,v);e.config=s.config,e.samplerate=s.samplerate,e.channelCount=s.channelCount,e.codec=s.codec,e.manifestCodec=s.manifestCodec,_.logger.log("parsed codec:"+e.codec+",rate:"+s.samplerate+",nb channel:"+s.channelCount)}}R.initTrackConfig=o;function r(e){return 1024*9e4/e}R.getFrameDuration=r;function i(e,n,d,g,v){var s,l,x,h=e.length;if(s=u(e,n),l=p(e,n),l-=s,l>0&&n+s+l<=h)return x=d+g*v,{headerLength:s,frameLength:l,stamp:x}}R.parseFrameHeader=i;function t(e,n,d,g,v){var s=r(e.samplerate),l=i(n,d,g,v,s);if(l){var x=l.stamp,h=l.headerLength,E=l.frameLength,S={unit:n.subarray(d+h,d+h+E),pts:x,dts:x};return e.samples.push(S),e.len+=E,{sample:S,length:E+h}}}R.appendFrame=t},"./src/demux/demuxer-inline.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/events.js"),A=T("./src/errors.js"),m=T("./src/crypt/decrypter.js"),y=T("./src/demux/aacdemuxer.js"),f=T("./src/demux/mp4demuxer.js"),u=T("./src/demux/tsdemuxer.js"),p=T("./src/demux/mp3demuxer.js"),c=T("./src/remux/mp4-remuxer.js"),a=T("./src/remux/passthrough-remuxer.js"),o=T("./src/utils/get-self-scope.js"),r=T("./src/utils/logger.js"),i=o.getSelfScope(),t;try{t=i.performance.now.bind(i.performance)}catch(n){r.logger.debug("Unable to use Performance API on this environment"),t=i.Date.now}var e=function(){function n(d,g,v,s){this.observer=d,this.typeSupported=g,this.config=v,this.vendor=s}return n.prototype.destroy=function(){var d=this.demuxer;d&&d.destroy()},n.prototype.push=function(d,g,v,s,l,x,h,E,S,b,I,L){var D=this;if(d.byteLength>0&&g!=null&&g.key!=null&&g.method==="AES-128"){var O=this.decrypter;O==null&&(O=this.decrypter=new m.default(this.observer,this.config));var F=t();O.decrypt(d,g.key.buffer,g.iv.buffer,function(C){var P=t();D.observer.trigger(_.default.FRAG_DECRYPTED,{stats:{tstart:F,tdecrypt:P}}),D.pushDecrypted(new Uint8Array(C),g,new Uint8Array(v),s,l,x,h,E,S,b,I,L)})}else this.pushDecrypted(new Uint8Array(d),g,new Uint8Array(v),s,l,x,h,E,S,b,I,L)},n.prototype.pushDecrypted=function(d,g,v,s,l,x,h,E,S,b,I,L){var D=this.demuxer;if(!D||(h||E)&&!this.probe(d)){for(var O=this.observer,F=this.typeSupported,C=this.config,P=[{demux:u.default,remux:c.default},{demux:f.default,remux:a.default},{demux:y.default,remux:c.default},{demux:p.default,remux:c.default}],k=0,B=P.length;k<B;k++){var M=P[k],N=M.demux.probe;if(N(d)){var j=this.remuxer=new M.remux(O,C,F,this.vendor);D=new M.demux(O,j,C,F),this.probe=N;break}}if(!D){O.trigger(_.default.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});return}this.demuxer=D}var K=this.remuxer;(h||E)&&(D.resetInitSegment(v,s,l,b),K.resetInitSegment()),h&&(D.resetTimeStamp(L),K.resetTimeStamp(L)),typeof D.setDecryptData=="function"&&D.setDecryptData(g),D.append(d,x,S,I)},n}();R.default=e},"./src/demux/demuxer-worker.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/demux/demuxer-inline.js"),A=T("./src/events.js"),m=T("./src/utils/logger.js"),y=T("./node_modules/node-libs-browser/node_modules/events/events.js"),f=function(u){var p=new y.EventEmitter;p.trigger=function(o){for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];p.emit.apply(p,[o,o].concat(r))},p.off=function(o){for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];p.removeListener.apply(p,[o].concat(r))};var c=function(a,o){u.postMessage({event:a,data:o})};u.addEventListener("message",function(a){var o=a.data;switch(o.cmd){case"init":var r=JSON.parse(o.config);u.demuxer=new _.default(p,o.typeSupported,r,o.vendor),m.enableLogs(r.debug),c("init",null);break;case"demux":u.demuxer.push(o.data,o.decryptdata,o.initSegment,o.audioCodec,o.videoCodec,o.timeOffset,o.discontinuity,o.trackSwitch,o.contiguous,o.duration,o.accurateTimeOffset,o.defaultInitPTS);break;default:break}}),p.on(A.default.FRAG_DECRYPTED,c),p.on(A.default.FRAG_PARSING_INIT_SEGMENT,c),p.on(A.default.FRAG_PARSED,c),p.on(A.default.ERROR,c),p.on(A.default.FRAG_PARSING_METADATA,c),p.on(A.default.FRAG_PARSING_USERDATA,c),p.on(A.default.INIT_PTS_FOUND,c),p.on(A.default.FRAG_PARSING_DATA,function(a,o){var r=[],i={event:a,data:o};o.data1&&(i.data1=o.data1.buffer,r.push(o.data1.buffer),delete o.data1),o.data2&&(i.data2=o.data2.buffer,r.push(o.data2.buffer),delete o.data2),u.postMessage(i,r)})};R.default=f},"./src/demux/demuxer.js":function(w,R,T){"use strict";(function(_){Object.defineProperty(R,"__esModule",{value:!0});var A=T("./node_modules/webworkify-webpack/index.js"),m=T("./src/events.js"),y=T("./src/demux/demuxer-inline.js"),f=T("./src/utils/logger.js"),u=T("./src/errors.js"),p=T("./src/utils/mediasource-helper.js"),c=T("./src/utils/get-self-scope.js"),a=T("./src/observer.js"),o=c.getSelfScope(),r=p.getMediaSource(),i=function(){function t(e,n){var d=this;this.hls=e,this.id=n;var g=this.observer=new a.Observer,v=e.config,s=function(E,S){S=S||{},S.frag=d.frag,S.id=d.id,e.trigger(E,S)};g.on(m.default.FRAG_DECRYPTED,s),g.on(m.default.FRAG_PARSING_INIT_SEGMENT,s),g.on(m.default.FRAG_PARSING_DATA,s),g.on(m.default.FRAG_PARSED,s),g.on(m.default.ERROR,s),g.on(m.default.FRAG_PARSING_METADATA,s),g.on(m.default.FRAG_PARSING_USERDATA,s),g.on(m.default.INIT_PTS_FOUND,s);var l={mp4:r.isTypeSupported("video/mp4"),mpeg:r.isTypeSupported("audio/mpeg"),mp3:r.isTypeSupported('audio/mp4; codecs="mp3"')},x=navigator.vendor;if(v.enableWorker&&typeof Worker!="undefined"){f.logger.log("demuxing in webworker");var h=void 0;try{h=this.w=A("./src/demux/demuxer-worker.js"),this.onwmsg=this.onWorkerMessage.bind(this),h.addEventListener("message",this.onwmsg),h.onerror=function(E){e.trigger(m.default.ERROR,{type:u.ErrorTypes.OTHER_ERROR,details:u.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",err:{message:E.message+" ("+E.filename+":"+E.lineno+")"}})},h.postMessage({cmd:"init",typeSupported:l,vendor:x,id:n,config:JSON.stringify(v)})}catch(E){f.logger.warn("Error in worker:",E),f.logger.error("Error while initializing DemuxerWorker, fallback on DemuxerInline"),h&&o.URL.revokeObjectURL(h.objectURL),this.demuxer=new y.default(g,l,v,x),this.w=void 0}}else this.demuxer=new y.default(g,l,v,x)}return t.prototype.destroy=function(){var e=this.w;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.w=null;else{var n=this.demuxer;n&&(n.destroy(),this.demuxer=null)}var d=this.observer;d&&(d.removeAllListeners(),this.observer=null)},t.prototype.push=function(e,n,d,g,v,s,l,x){var h=this.w,E=_.isFinite(v.startPTS)?v.startPTS:v.start,S=v.decryptdata,b=this.frag,I=!(b&&v.cc===b.cc),L=!(b&&v.level===b.level),D=b&&v.sn===b.sn+1,O=!L&&D;if(I&&f.logger.log(this.id+":discontinuity detected"),L&&f.logger.log(this.id+":switch detected"),this.frag=v,h)h.postMessage({cmd:"demux",data:e,decryptdata:S,initSegment:n,audioCodec:d,videoCodec:g,timeOffset:E,discontinuity:I,trackSwitch:L,contiguous:O,duration:s,accurateTimeOffset:l,defaultInitPTS:x},e instanceof ArrayBuffer?[e]:[]);else{var F=this.demuxer;F&&F.push(e,S,n,d,g,E,I,L,O,s,l,x)}},t.prototype.onWorkerMessage=function(e){var n=e.data,d=this.hls;switch(n.event){case"init":o.URL.revokeObjectURL(this.w.objectURL);break;case m.default.FRAG_PARSING_DATA:n.data.data1=new Uint8Array(n.data1),n.data2&&(n.data.data2=new Uint8Array(n.data2));default:n.data=n.data||{},n.data.frag=this.frag,n.data.id=this.id,d.trigger(n.event,n.data);break}},t}();R.default=i}).call(this,T("./src/polyfills/number.js").Number)},"./src/demux/exp-golomb.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/utils/logger.js"),A=function(){function m(y){this.data=y,this.bytesAvailable=y.byteLength,this.word=0,this.bitsAvailable=0}return m.prototype.loadWord=function(){var y=this.data,f=this.bytesAvailable,u=y.byteLength-f,p=new Uint8Array(4),c=Math.min(4,f);if(c===0)throw new Error("no bytes available");p.set(y.subarray(u,u+c)),this.word=new DataView(p.buffer).getUint32(0),this.bitsAvailable=c*8,this.bytesAvailable-=c},m.prototype.skipBits=function(y){var f;this.bitsAvailable>y?(this.word<<=y,this.bitsAvailable-=y):(y-=this.bitsAvailable,f=y>>3,y-=f>>3,this.bytesAvailable-=f,this.loadWord(),this.word<<=y,this.bitsAvailable-=y)},m.prototype.readBits=function(y){var f=Math.min(this.bitsAvailable,y),u=this.word>>>32-f;return y>32&&_.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=f,this.bitsAvailable>0?this.word<<=f:this.bytesAvailable>0&&this.loadWord(),f=y-f,f>0&&this.bitsAvailable?u<<f|this.readBits(f):u},m.prototype.skipLZ=function(){var y;for(y=0;y<this.bitsAvailable;++y)if((this.word&2147483648>>>y)!=0)return this.word<<=y,this.bitsAvailable-=y,y;return this.loadWord(),y+this.skipLZ()},m.prototype.skipUEG=function(){this.skipBits(1+this.skipLZ())},m.prototype.skipEG=function(){this.skipBits(1+this.skipLZ())},m.prototype.readUEG=function(){var y=this.skipLZ();return this.readBits(y+1)-1},m.prototype.readEG=function(){var y=this.readUEG();return 1&y?1+y>>>1:-1*(y>>>1)},m.prototype.readBoolean=function(){return this.readBits(1)===1},m.prototype.readUByte=function(){return this.readBits(8)},m.prototype.readUShort=function(){return this.readBits(16)},m.prototype.readUInt=function(){return this.readBits(32)},m.prototype.skipScalingList=function(y){var f=8,u=8,p,c;for(p=0;p<y;p++)u!==0&&(c=this.readEG(),u=(f+c+256)%256),f=u===0?f:u},m.prototype.readSPS=function(){var y=0,f=0,u=0,p=0,c,a,o,r,i,t,e,n,d,g=this.readUByte.bind(this),v=this.readBits.bind(this),s=this.readUEG.bind(this),l=this.readBoolean.bind(this),x=this.skipBits.bind(this),h=this.skipEG.bind(this),E=this.skipUEG.bind(this),S=this.skipScalingList.bind(this);if(g(),c=g(),a=v(5),x(3),o=g(),E(),c===100||c===110||c===122||c===244||c===44||c===83||c===86||c===118||c===128){var b=s();if(b===3&&x(1),E(),E(),x(1),l())for(n=b!==3?8:12,d=0;d<n;d++)l()&&(d<6?S(16):S(64))}E();var I=s();if(I===0)s();else if(I===1)for(x(1),h(),h(),r=s(),d=0;d<r;d++)h();E(),x(1),i=s(),t=s(),e=v(1),e===0&&x(1),x(1),l()&&(y=s(),f=s(),u=s(),p=s());var L=[1,1];if(l()&&l()){var D=g();switch(D){case 1:L=[1,1];break;case 2:L=[12,11];break;case 3:L=[10,11];break;case 4:L=[16,11];break;case 5:L=[40,33];break;case 6:L=[24,11];break;case 7:L=[20,11];break;case 8:L=[32,11];break;case 9:L=[80,33];break;case 10:L=[18,11];break;case 11:L=[15,11];break;case 12:L=[64,33];break;case 13:L=[160,99];break;case 14:L=[4,3];break;case 15:L=[3,2];break;case 16:L=[2,1];break;case 255:{L=[g()<<8|g(),g()<<8|g()];break}}}return{width:Math.ceil((i+1)*16-y*2-f*2),height:(2-e)*(t+1)*16-(e?2:4)*(u+p),pixelRatio:L}},m.prototype.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},m}();R.default=A},"./src/demux/id3.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=function(){function m(){}return m.isHeader=function(y,f){return f+10<=y.length&&y[f]===73&&y[f+1]===68&&y[f+2]===51&&y[f+3]<255&&y[f+4]<255&&y[f+6]<128&&y[f+7]<128&&y[f+8]<128&&y[f+9]<128},m.isFooter=function(y,f){return f+10<=y.length&&y[f]===51&&y[f+1]===68&&y[f+2]===73&&y[f+3]<255&&y[f+4]<255&&y[f+6]<128&&y[f+7]<128&&y[f+8]<128&&y[f+9]<128},m.getID3Data=function(y,f){for(var u=f,p=0;m.isHeader(y,f);){p+=10;var c=m._readSize(y,f+6);p+=c,m.isFooter(y,f+10)&&(p+=10),f+=p}if(p>0)return y.subarray(u,u+p)},m._readSize=function(y,f){var u=0;return u=(y[f]&127)<<21,u|=(y[f+1]&127)<<14,u|=(y[f+2]&127)<<7,u|=y[f+3]&127,u},m.getTimeStamp=function(y){for(var f=m.getID3Frames(y),u=0;u<f.length;u++){var p=f[u];if(m.isTimeStampFrame(p))return m._readTimeStamp(p)}},m.isTimeStampFrame=function(y){return y&&y.key==="PRIV"&&y.info==="com.apple.streaming.transportStreamTimestamp"},m._getFrameData=function(y){var f=String.fromCharCode(y[0],y[1],y[2],y[3]),u=m._readSize(y,4),p=10;return{type:f,size:u,data:y.subarray(p,p+u)}},m.getID3Frames=function(y){for(var f=0,u=[];m.isHeader(y,f);){var p=m._readSize(y,f+6);f+=10;for(var c=f+p;f+8<c;){var a=m._getFrameData(y.subarray(f)),o=m._decodeFrame(a);o&&u.push(o),f+=a.size+10}m.isFooter(y,f)&&(f+=10)}return u},m._decodeFrame=function(y){if(y.type==="PRIV")return m._decodePrivFrame(y);if(y.type[0]==="T")return m._decodeTextFrame(y);if(y.type[0]==="W")return m._decodeURLFrame(y)},m._readTimeStamp=function(y){if(y.data.byteLength===8){var f=new Uint8Array(y.data),u=f[3]&1,p=(f[4]<<23)+(f[5]<<15)+(f[6]<<7)+f[7];return p/=45,u&&(p+=4772185884e-2),Math.round(p)}},m._decodePrivFrame=function(y){if(!(y.size<2)){var f=m._utf8ArrayToStr(y.data,!0),u=new Uint8Array(y.data.subarray(f.length+1));return{key:y.type,info:f,data:u.buffer}}},m._decodeTextFrame=function(y){if(!(y.size<2))if(y.type==="TXXX"){var f=1,u=m._utf8ArrayToStr(y.data.subarray(f));f+=u.length+1;var p=m._utf8ArrayToStr(y.data.subarray(f));return{key:y.type,info:u,data:p}}else{var c=m._utf8ArrayToStr(y.data.subarray(1));return{key:y.type,data:c}}},m._decodeURLFrame=function(y){if(y.type==="WXXX"){if(y.size<2)return;var f=1,u=m._utf8ArrayToStr(y.data.subarray(f));f+=u.length+1;var p=m._utf8ArrayToStr(y.data.subarray(f));return{key:y.type,info:u,data:p}}else{var c=m._utf8ArrayToStr(y.data);return{key:y.type,data:c}}},m._utf8ArrayToStr=function(y,f){f===void 0&&(f=!1);for(var u=y.length,p,c,a,o="",r=0;r<u;){if(p=y[r++],p===0&&f)return o;if(p===0||p===3)continue;switch(p>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(p);break;case 12:case 13:c=y[r++],o+=String.fromCharCode((p&31)<<6|c&63);break;case 14:c=y[r++],a=y[r++],o+=String.fromCharCode((p&15)<<12|(c&63)<<6|(a&63)<<0);break;default:}}return o},m}(),A=_._utf8ArrayToStr;R.utf8ArrayToStr=A,R.default=_},"./src/demux/mp3demuxer.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/demux/id3.js"),A=T("./src/utils/logger.js"),m=T("./src/demux/mpegaudio.js"),y=function(){function f(u,p,c){this.observer=u,this.config=c,this.remuxer=p}return f.prototype.resetInitSegment=function(u,p,c,a){this._audioTrack={container:"audio/mpeg",type:"audio",id:-1,sequenceNumber:0,isAAC:!1,samples:[],len:0,manifestCodec:p,duration:a,inputTimeScale:9e4}},f.prototype.resetTimeStamp=function(){},f.probe=function(u){var p,c,a=_.default.getID3Data(u,0);if(a&&_.default.getTimeStamp(a)!==void 0){for(p=a.length,c=Math.min(u.length-1,p+100);p<c;p++)if(m.default.probe(u,p))return A.logger.log("MPEG Audio sync word found !"),!0}return!1},f.prototype.append=function(u,p,c,a){for(var o=_.default.getID3Data(u,0),r=_.default.getTimeStamp(o),i=r?90*r:p*9e4,t=o.length,e=u.length,n=0,d=0,g=this._audioTrack,v=[{pts:i,dts:i,data:o}];t<e;)if(m.default.isHeader(u,t)){var s=m.default.appendFrame(g,u,t,i,n);if(s)t+=s.length,d=s.sample.pts,n++;else break}else _.default.isHeader(u,t)?(o=_.default.getID3Data(u,t),v.push({pts:d,dts:d,data:o}),t+=o.length):t++;this.remuxer.remux(g,{samples:[]},{samples:v,inputTimeScale:9e4},{samples:[]},p,c,a)},f.prototype.destroy=function(){},f}();R.default=y},"./src/demux/mp4demuxer.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/utils/logger.js"),A=T("./src/events.js"),m=Math.pow(2,32)-1,y=function(){function f(u,p){this.observer=u,this.remuxer=p}return f.prototype.resetTimeStamp=function(u){this.initPTS=u},f.prototype.resetInitSegment=function(u,p,c,a){if(u&&u.byteLength){var o=this.initData=f.parseInitSegment(u);p==null&&(p="mp4a.40.5"),c==null&&(c="avc1.42e01e");var r={};o.audio&&o.video?r.audiovideo={container:"video/mp4",codec:p+","+c,initSegment:a?u:null}:(o.audio&&(r.audio={container:"audio/mp4",codec:p,initSegment:a?u:null}),o.video&&(r.video={container:"video/mp4",codec:c,initSegment:a?u:null})),this.observer.trigger(A.default.FRAG_PARSING_INIT_SEGMENT,{tracks:r})}else p&&(this.audioCodec=p),c&&(this.videoCodec=c)},f.probe=function(u){return f.findBox({data:u,start:0,end:Math.min(u.length,16384)},["moof"]).length>0},f.bin2str=function(u){return String.fromCharCode.apply(null,u)},f.readUint16=function(u,p){u.data&&(p+=u.start,u=u.data);var c=u[p]<<8|u[p+1];return c<0?65536+c:c},f.readUint32=function(u,p){u.data&&(p+=u.start,u=u.data);var c=u[p]<<24|u[p+1]<<16|u[p+2]<<8|u[p+3];return c<0?4294967296+c:c},f.writeUint32=function(u,p,c){u.data&&(p+=u.start,u=u.data),u[p]=c>>24,u[p+1]=c>>16&255,u[p+2]=c>>8&255,u[p+3]=c&255},f.findBox=function(u,p){var c=[],a,o,r,i,t,e,n;if(u.data?(e=u.start,i=u.end,u=u.data):(e=0,i=u.byteLength),!p.length)return null;for(a=e;a<i;)o=f.readUint32(u,a),r=f.bin2str(u.subarray(a+4,a+8)),n=o>1?a+o:i,r===p[0]&&(p.length===1?c.push({data:u,start:a+8,end:n}):(t=f.findBox({data:u,start:a+8,end:n},p.slice(1)),t.length&&(c=c.concat(t)))),a=n;return c},f.parseSegmentIndex=function(u){var p=f.findBox(u,["moov"])[0],c=p?p.end:null,a=0,o=f.findBox(u,["sidx"]),r;if(!o||!o[0])return null;r=[],o=o[0];var i=o.data[0];a=i===0?8:16;var t=f.readUint32(o,a);a+=4;var e=0,n=0;i===0?a+=8:a+=16,a+=2;var d=o.end+n,g=f.readUint16(o,a);a+=2;for(var v=0;v<g;v++){var s=a,l=f.readUint32(o,s);s+=4;var x=l&2147483647,h=(l&2147483648)>>>31;if(h===1){console.warn("SIDX has hierarchical references (not supported)");return}var E=f.readUint32(o,s);s+=4,r.push({referenceSize:x,subsegmentDuration:E,info:{duration:E/t,start:d,end:d+x-1}}),d+=x,s+=4,a=s}return{earliestPresentationTime:e,timescale:t,version:i,referencesCount:g,references:r,moovEndOffset:c}},f.parseInitSegment=function(u){var p=[],c=f.findBox(u,["moov","trak"]);return c.forEach(function(a){var o=f.findBox(a,["tkhd"])[0];if(o){var r=o.data[o.start],i=r===0?12:20,t=f.readUint32(o,i),e=f.findBox(a,["mdia","mdhd"])[0];if(e){r=e.data[e.start],i=r===0?12:20;var n=f.readUint32(e,i),d=f.findBox(a,["mdia","hdlr"])[0];if(d){var g=f.bin2str(d.data.subarray(d.start+8,d.start+12)),v={soun:"audio",vide:"video"}[g];if(v){var s=f.findBox(a,["mdia","minf","stbl","stsd"]);if(s.length){s=s[0];var l=f.bin2str(s.data.subarray(s.start+12,s.start+16));_.logger.log("MP4Demuxer:"+v+":"+l+" found")}p[t]={timescale:n,type:v},p[v]={timescale:n,id:t}}}}}}),p},f.getStartDTS=function(u,p){var c,a,o;return c=f.findBox(p,["moof","traf"]),a=[].concat.apply([],c.map(function(r){return f.findBox(r,["tfhd"]).map(function(i){var t,e,n;return t=f.readUint32(i,4),e=u[t].timescale||9e4,n=f.findBox(r,["tfdt"]).map(function(d){var g,v;return g=d.data[d.start],v=f.readUint32(d,4),g===1&&(v*=Math.pow(2,32),v+=f.readUint32(d,8)),v})[0],n/e})})),o=Math.min.apply(null,a),isFinite(o)?o:0},f.offsetStartDTS=function(u,p,c){f.findBox(p,["moof","traf"]).map(function(a){return f.findBox(a,["tfhd"]).map(function(o){var r=f.readUint32(o,4),i=u[r].timescale||9e4;f.findBox(a,["tfdt"]).map(function(t){var e=t.data[t.start],n=f.readUint32(t,4);if(e===0)f.writeUint32(t,4,n-c*i);else{n*=Math.pow(2,32),n+=f.readUint32(t,8),n-=c*i,n=Math.max(n,0);var d=Math.floor(n/(m+1)),g=Math.floor(n%(m+1));f.writeUint32(t,4,d),f.writeUint32(t,8,g)}})})})},f.prototype.append=function(u,p,c,a){var o=this.initData;o||(this.resetInitSegment(u,this.audioCodec,this.videoCodec,!1),o=this.initData);var r,i=this.initPTS;if(i===void 0){var t=f.getStartDTS(o,u);this.initPTS=i=t-p,this.observer.trigger(A.default.INIT_PTS_FOUND,{initPTS:i})}f.offsetStartDTS(o,u,i),r=f.getStartDTS(o,u),this.remuxer.remux(o.audio,o.video,null,null,r,c,a,u)},f.prototype.destroy=function(){},f}();R.default=y},"./src/demux/mpegaudio.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _={BitratesMap:[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],SamplingRateMap:[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],SamplesCoefficients:[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],BytesInSlot:[0,1,1,4],appendFrame:function(A,m,y,f,u){if(!(y+24>m.length)){var p=this.parseHeader(m,y);if(p&&y+p.frameLength<=m.length){var c=p.samplesPerFrame*9e4/p.sampleRate,a=f+u*c,o={unit:m.subarray(y,y+p.frameLength),pts:a,dts:a};return A.config=[],A.channelCount=p.channelCount,A.samplerate=p.sampleRate,A.samples.push(o),A.len+=p.frameLength,{sample:o,length:p.frameLength}}}},parseHeader:function(A,m){var y=A[m+1]>>3&3,f=A[m+1]>>1&3,u=A[m+2]>>4&15,p=A[m+2]>>2&3,c=A[m+2]>>1&1;if(y!==1&&u!==0&&u!==15&&p!==3){var a=y===3?3-f:f===3?3:4,o=_.BitratesMap[a*14+u-1]*1e3,r=y===3?0:y===2?1:2,i=_.SamplingRateMap[r*3+p],t=A[m+3]>>6==3?1:2,e=_.SamplesCoefficients[y][f],n=_.BytesInSlot[f],d=e*8*n,g=parseInt(e*o/i+c,10)*n;return{sampleRate:i,channelCount:t,frameLength:g,samplesPerFrame:d}}},isHeaderPattern:function(A,m){return A[m]===255&&(A[m+1]&224)==224&&(A[m+1]&6)!=0},isHeader:function(A,m){return!!(m+1<A.length&&this.isHeaderPattern(A,m))},probe:function(A,m){if(m+1<A.length&&this.isHeaderPattern(A,m)){var y=4,f=this.parseHeader(A,m),u=y;f&&f.frameLength&&(u=f.frameLength);var p=m+u;if(p===A.length||p+1<A.length&&this.isHeaderPattern(A,p))return!0}return!1}};R.default=_},"./src/demux/sample-aes.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/crypt/decrypter.js"),A=function(){function m(y,f,u,p){this.decryptdata=u,this.discardEPB=p,this.decrypter=new _.default(y,f,{removePKCS7Padding:!1})}return m.prototype.decryptBuffer=function(y,f){this.decrypter.decrypt(y,this.decryptdata.key.buffer,this.decryptdata.iv.buffer,f)},m.prototype.decryptAacSample=function(y,f,u,p){var c=y[f].unit,a=c.subarray(16,c.length-c.length%16),o=a.buffer.slice(a.byteOffset,a.byteOffset+a.length),r=this;this.decryptBuffer(o,function(i){i=new Uint8Array(i),c.set(i,16),p||r.decryptAacSamples(y,f+1,u)})},m.prototype.decryptAacSamples=function(y,f,u){for(;;f++){if(f>=y.length){u();return}if(!(y[f].unit.length<32)){var p=this.decrypter.isSync();if(this.decryptAacSample(y,f,u,p),!p)return}}},m.prototype.getAvcEncryptedData=function(y){for(var f=Math.floor((y.length-48)/160)*16+16,u=new Int8Array(f),p=0,c=32;c<=y.length-16;c+=160,p+=16)u.set(y.subarray(c,c+16),p);return u},m.prototype.getAvcDecryptedUnit=function(y,f){f=new Uint8Array(f);for(var u=0,p=32;p<=y.length-16;p+=160,u+=16)y.set(f.subarray(u,u+16),p);return y},m.prototype.decryptAvcSample=function(y,f,u,p,c,a){var o=this.discardEPB(c.data),r=this.getAvcEncryptedData(o),i=this;this.decryptBuffer(r.buffer,function(t){c.data=i.getAvcDecryptedUnit(o,t),a||i.decryptAvcSamples(y,f,u+1,p)})},m.prototype.decryptAvcSamples=function(y,f,u,p){for(;;f++,u=0){if(f>=y.length){p();return}for(var c=y[f].units;!(u>=c.length);u++){var a=c[u];if(!(a.length<=48||a.type!==1&&a.type!==5)){var o=this.decrypter.isSync();if(this.decryptAvcSample(y,f,u,p,a,o),!o)return}}}},m}();R.default=A},"./src/demux/tsdemuxer.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/demux/adts.js"),A=T("./src/demux/mpegaudio.js"),m=T("./src/events.js"),y=T("./src/demux/exp-golomb.js"),f=T("./src/demux/sample-aes.js"),u=T("./src/utils/logger.js"),p=T("./src/errors.js"),c={video:1,audio:2,id3:3,text:4},a=function(){function o(r,i,t,e){this.observer=r,this.config=t,this.typeSupported=e,this.remuxer=i,this.sampleAes=null}return o.prototype.setDecryptData=function(r){r!=null&&r.key!=null&&r.method==="SAMPLE-AES"?this.sampleAes=new f.default(this.observer,this.config,r,this.discardEPB):this.sampleAes=null},o.probe=function(r){var i=o._syncOffset(r);return i<0?!1:(i&&u.logger.warn("MPEG2-TS detected but first sync word found @ offset "+i+", junk ahead ?"),!0)},o._syncOffset=function(r){for(var i=Math.min(1e3,r.length-3*188),t=0;t<i;){if(r[t]===71&&r[t+188]===71&&r[t+2*188]===71)return t;t++}return-1},o.createTrack=function(r,i){return{container:r==="video"||r==="audio"?"video/mp2t":void 0,type:r,id:c[r],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],len:0,dropped:r==="video"?0:void 0,isAAC:r==="audio"?!0:void 0,duration:r==="audio"?i:void 0}},o.prototype.resetInitSegment=function(r,i,t,e){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=o.createTrack("video",e),this._audioTrack=o.createTrack("audio",e),this._id3Track=o.createTrack("id3",e),this._txtTrack=o.createTrack("text",e),this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=i,this.videoCodec=t,this._duration=e},o.prototype.resetTimeStamp=function(){},o.prototype.append=function(r,i,t,e){var n,d=r.length,g,v,s,l,x,h=!1;this.contiguous=t;var E=this.pmtParsed,S=this._avcTrack,b=this._audioTrack,I=this._id3Track,L=S.pid,D=b.pid,O=I.pid,F=this._pmtId,C=S.pesData,P=b.pesData,k=I.pesData,B=this._parsePAT,M=this._parsePMT,N=this._parsePES,j=this._parseAVCPES.bind(this),K=this._parseAACPES.bind(this),G=this._parseMPEGPES.bind(this),W=this._parseID3PES.bind(this),U=o._syncOffset(r);for(d-=(d+U)%188,n=U;n<d;n+=188)if(r[n]===71){if(g=!!(r[n+1]&64),v=((r[n+1]&31)<<8)+r[n+2],s=(r[n+3]&48)>>4,s>1){if(l=n+5+r[n+4],l===n+188)continue}else l=n+4;switch(v){case L:g&&(C&&(x=N(C))&&x.pts!==void 0&&j(x,!1),C={data:[],size:0}),C&&(C.data.push(r.subarray(l,n+188)),C.size+=n+188-l);break;case D:g&&(P&&(x=N(P))&&x.pts!==void 0&&(b.isAAC?K(x):G(x)),P={data:[],size:0}),P&&(P.data.push(r.subarray(l,n+188)),P.size+=n+188-l);break;case O:g&&(k&&(x=N(k))&&x.pts!==void 0&&W(x),k={data:[],size:0}),k&&(k.data.push(r.subarray(l,n+188)),k.size+=n+188-l);break;case 0:g&&(l+=r[l]+1),F=this._pmtId=B(r,l);break;case F:g&&(l+=r[l]+1);var V=M(r,l,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,this.sampleAes!=null);L=V.avc,L>0&&(S.pid=L),D=V.audio,D>0&&(b.pid=D,b.isAAC=V.isAAC),O=V.id3,O>0&&(I.pid=O),h&&!E&&(u.logger.log("reparse from beginning"),h=!1,n=U-188),E=this.pmtParsed=!0;break;case 17:case 8191:break;default:h=!0;break}}else this.observer.trigger(m.default.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});C&&(x=N(C))&&x.pts!==void 0?(j(x,!0),S.pesData=null):S.pesData=C,P&&(x=N(P))&&x.pts!==void 0?(b.isAAC?K(x):G(x),b.pesData=null):(P&&P.size&&u.logger.log("last AAC PES packet truncated,might overlap between fragments"),b.pesData=P),k&&(x=N(k))&&x.pts!==void 0?(W(x),I.pesData=null):I.pesData=k,this.sampleAes==null?this.remuxer.remux(b,S,I,this._txtTrack,i,t,e):this.decryptAndRemux(b,S,I,this._txtTrack,i,t,e)},o.prototype.decryptAndRemux=function(r,i,t,e,n,d,g){if(r.samples&&r.isAAC){var v=this;this.sampleAes.decryptAacSamples(r.samples,0,function(){v.decryptAndRemuxAvc(r,i,t,e,n,d,g)})}else this.decryptAndRemuxAvc(r,i,t,e,n,d,g)},o.prototype.decryptAndRemuxAvc=function(r,i,t,e,n,d,g){if(i.samples){var v=this;this.sampleAes.decryptAvcSamples(i.samples,0,0,function(){v.remuxer.remux(r,i,t,e,n,d,g)})}else this.remuxer.remux(r,i,t,e,n,d,g)},o.prototype.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},o.prototype._parsePAT=function(r,i){return(r[i+10]&31)<<8|r[i+11]},o.prototype._parsePMT=function(r,i,t,e){var n,d,g,v,s={audio:-1,avc:-1,id3:-1,isAAC:!0};for(n=(r[i+1]&15)<<8|r[i+2],d=i+3+n-4,g=(r[i+10]&15)<<8|r[i+11],i+=12+g;i<d;){switch(v=(r[i+1]&31)<<8|r[i+2],r[i]){case 207:if(!e){u.logger.log("unkown stream type:"+r[i]);break}case 15:s.audio===-1&&(s.audio=v);break;case 21:s.id3===-1&&(s.id3=v);break;case 219:if(!e){u.logger.log("unkown stream type:"+r[i]);break}case 27:s.avc===-1&&(s.avc=v);break;case 3:case 4:t?s.audio===-1&&(s.audio=v,s.isAAC=!1):u.logger.log("MPEG audio found, not supported in this browser for now");break;case 36:u.logger.warn("HEVC stream type found, not supported for now");break;default:u.logger.log("unkown stream type:"+r[i]);break}i+=((r[i+3]&15)<<8|r[i+4])+5}return s},o.prototype._parsePES=function(r){var i=0,t,e,n,d,g,v,s,l,x,h=r.data;if(!r||r.size===0)return null;for(;h[0].length<19&&h.length>1;){var E=new Uint8Array(h[0].length+h[1].length);E.set(h[0]),E.set(h[1],h[0].length),h[0]=E,h.splice(1,1)}if(t=h[0],n=(t[0]<<16)+(t[1]<<8)+t[2],n===1){if(d=(t[4]<<8)+t[5],d&&d>r.size-6)return null;e=t[7],e&192&&(s=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,s>4294967295&&(s-=8589934592),e&64?(l=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,l>4294967295&&(l-=8589934592),s-l>60*9e4&&(u.logger.warn(Math.round((s-l)/9e4)+"s delta between PTS and DTS, align them"),s=l)):l=s),g=t[8],x=g+9,r.size-=x,v=new Uint8Array(r.size);for(var S=0,b=h.length;S<b;S++){t=h[S];var I=t.byteLength;if(x)if(x>I){x-=I;continue}else t=t.subarray(x),I-=x,x=0;v.set(t,i),i+=I}return d&&(d-=g+3),{data:v,pts:s,dts:l,len:d}}else return null},o.prototype.pushAccesUnit=function(r,i){if(r.units.length&&r.frame){var t=i.samples,e=t.length;!this.config.forceKeyFrameOnDiscontinuity||r.key===!0||i.sps&&(e||this.contiguous)?(r.id=e,t.push(r)):i.dropped++}r.debug.length&&u.logger.log(r.pts+"/"+r.dts+":"+r.debug)},o.prototype._parseAVCPES=function(r,i){var t=this,e=this._avcTrack,n=this._parseAVCNALu(r.data),d=!1,g,v=this.avcSample,s,l=!1,x,h=this.pushAccesUnit.bind(this),E=function(S,b,I,L){return{key:S,pts:b,dts:I,units:[],debug:L}};r.data=null,v&&n.length&&!e.audFound&&(h(v,e),v=this.avcSample=E(!1,r.pts,r.dts,"")),n.forEach(function(S){switch(S.type){case 1:s=!0,v||(v=t.avcSample=E(!0,r.pts,r.dts,"")),d&&(v.debug+="NDR "),v.frame=!0;var b=S.data;if(l&&b.length>4){var I=new y.default(b).readSliceType();(I===2||I===4||I===7||I===9)&&(v.key=!0)}break;case 5:s=!0,v||(v=t.avcSample=E(!0,r.pts,r.dts,"")),d&&(v.debug+="IDR "),v.key=!0,v.frame=!0;break;case 6:s=!0,d&&v&&(v.debug+="SEI "),g=new y.default(t.discardEPB(S.data)),g.readUByte();for(var L=0,D=0,O=!1,F=0;!O&&g.bytesAvailable>1;){L=0;do F=g.readUByte(),L+=F;while(F===255);D=0;do F=g.readUByte(),D+=F;while(F===255);if(L===4&&g.bytesAvailable!==0){O=!0;var C=g.readUByte();if(C===181){var P=g.readUShort();if(P===49){var k=g.readUInt();if(k===1195456820){var B=g.readUByte();if(B===3){var M=g.readUByte(),N=g.readUByte(),j=31&M,K=[M,N];for(x=0;x<j;x++)K.push(g.readUByte()),K.push(g.readUByte()),K.push(g.readUByte());t._insertSampleInOrder(t._txtTrack.samples,{type:3,pts:r.pts,bytes:K})}}}}}else if(D<g.bytesAvailable)for(x=0;x<D;x++)g.readUByte()}break;case 7:if(s=!0,l=!0,d&&v&&(v.debug+="SPS "),!e.sps){g=new y.default(S.data);var G=g.readSPS();e.width=G.width,e.height=G.height,e.pixelRatio=G.pixelRatio,e.sps=[S.data],e.duration=t._duration;var W=S.data.subarray(1,4),U="avc1.";for(x=0;x<3;x++){var V=W[x].toString(16);V.length<2&&(V="0"+V),U+=V}e.codec=U}break;case 8:s=!0,d&&v&&(v.debug+="PPS "),e.pps||(e.pps=[S.data]);break;case 9:s=!1,e.audFound=!0,v&&h(v,e),v=t.avcSample=E(!1,r.pts,r.dts,d?"AUD ":"");break;case 12:s=!1;break;default:s=!1,v&&(v.debug+="unknown NAL "+S.type+" ");break}if(v&&s){var H=v.units;H.push(S)}}),i&&v&&(h(v,e),this.avcSample=null)},o.prototype._insertSampleInOrder=function(r,i){var t=r.length;if(t>0){if(i.pts>=r[t-1].pts)r.push(i);else for(var e=t-1;e>=0;e--)if(i.pts<r[e].pts){r.splice(e,0,i);break}}else r.push(i)},o.prototype._getLastNalUnit=function(){var r=this.avcSample,i;if(!r||r.units.length===0){var t=this._avcTrack,e=t.samples;r=e[e.length-1]}if(r){var n=r.units;i=n[n.length-1]}return i},o.prototype._parseAVCNALu=function(r){var i=0,t=r.byteLength,e,n,d=this._avcTrack,g=d.naluState||0,v=g,s=[],l,x,h=-1,E;for(g===-1&&(h=0,E=r[0]&31,g=0,i=1);i<t;){if(e=r[i++],!g){g=e?0:1;continue}if(g===1){g=e?0:2;continue}if(!e)g=3;else if(e===1){if(h>=0)l={data:r.subarray(h,i-g-1),type:E},s.push(l);else{var S=this._getLastNalUnit();if(S&&(v&&i<=4-v&&S.state&&(S.data=S.data.subarray(0,S.data.byteLength-v)),n=i-g-1,n>0)){var b=new Uint8Array(S.data.byteLength+n);b.set(S.data,0),b.set(r.subarray(0,n),S.data.byteLength),S.data=b}}i<t?(x=r[i]&31,h=i,E=x,g=0):g=-1}else g=0}if(h>=0&&g>=0&&(l={data:r.subarray(h,t),type:E,state:g},s.push(l)),s.length===0){var S=this._getLastNalUnit();if(S){var b=new Uint8Array(S.data.byteLength+r.byteLength);b.set(S.data,0),b.set(r,S.data.byteLength),S.data=b}}return d.naluState=g,s},o.prototype.discardEPB=function(r){for(var i=r.byteLength,t=[],e=1,n,d;e<i-2;)r[e]===0&&r[e+1]===0&&r[e+2]===3?(t.push(e+2),e+=2):e++;if(t.length===0)return r;n=i-t.length,d=new Uint8Array(n);var g=0;for(e=0;e<n;g++,e++)g===t[0]&&(g++,t.shift()),d[e]=r[g];return d},o.prototype._parseAACPES=function(r){var i=this._audioTrack,t=r.data,e=r.pts,n=0,d=this.aacOverFlow,g=this.aacLastPTS,v,s,l,x,h;if(d){var E=new Uint8Array(d.byteLength+t.byteLength);E.set(d,0),E.set(t,d.byteLength),t=E}for(l=n,h=t.length;l<h-1&&!_.isHeader(t,l);l++);if(l){var S=void 0,b=void 0;if(l<h-1?(S="AAC PES did not start with ADTS header,offset:"+l,b=!1):(S="no ADTS header found in AAC PES",b=!0),u.logger.warn("parsing error:"+S),this.observer.trigger(m.default.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.FRAG_PARSING_ERROR,fatal:b,reason:S}),b)return}if(_.initTrackConfig(i,this.observer,t,l,this.audioCodec),s=0,v=_.getFrameDuration(i.samplerate),d&&g){var I=g+v;Math.abs(I-e)>1&&(u.logger.log("AAC: align PTS for overlapping frames by "+Math.round((I-e)/90)),e=I)}for(;l<h;)if(_.isHeader(t,l)&&l+5<h){var L=_.appendFrame(i,t,l,e,s);if(L)l+=L.length,x=L.sample.pts,s++;else break}else l++;l<h?d=t.subarray(l,h):d=null,this.aacOverFlow=d,this.aacLastPTS=x},o.prototype._parseMPEGPES=function(r){for(var i=r.data,t=i.length,e=0,n=0,d=r.pts;n<t;)if(A.default.isHeader(i,n)){var g=A.default.appendFrame(this._audioTrack,i,n,d,e);if(g)n+=g.length,e++;else break}else n++},o.prototype._parseID3PES=function(r){this._id3Track.samples.push(r)},o}();R.default=a},"./src/errors.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0}),R.ErrorTypes={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",KEY_SYSTEM_ERROR:"keySystemError",MUX_ERROR:"muxError",OTHER_ERROR:"otherError"},R.ErrorDetails={KEY_SYSTEM_NO_KEYS:"keySystemNoKeys",KEY_SYSTEM_NO_ACCESS:"keySystemNoAccess",KEY_SYSTEM_NO_SESSION:"keySystemNoSession",KEY_SYSTEM_LICENSE_REQUEST_FAILED:"keySystemLicenseRequestFailed",MANIFEST_LOAD_ERROR:"manifestLoadError",MANIFEST_LOAD_TIMEOUT:"manifestLoadTimeOut",MANIFEST_PARSING_ERROR:"manifestParsingError",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"manifestIncompatibleCodecsError",LEVEL_LOAD_ERROR:"levelLoadError",LEVEL_LOAD_TIMEOUT:"levelLoadTimeOut",LEVEL_SWITCH_ERROR:"levelSwitchError",AUDIO_TRACK_LOAD_ERROR:"audioTrackLoadError",AUDIO_TRACK_LOAD_TIMEOUT:"audioTrackLoadTimeOut",FRAG_LOAD_ERROR:"fragLoadError",FRAG_LOAD_TIMEOUT:"fragLoadTimeOut",FRAG_DECRYPT_ERROR:"fragDecryptError",FRAG_PARSING_ERROR:"fragParsingError",REMUX_ALLOC_ERROR:"remuxAllocError",KEY_LOAD_ERROR:"keyLoadError",KEY_LOAD_TIMEOUT:"keyLoadTimeOut",BUFFER_ADD_CODEC_ERROR:"bufferAddCodecError",BUFFER_APPEND_ERROR:"bufferAppendError",BUFFER_APPENDING_ERROR:"bufferAppendingError",BUFFER_STALLED_ERROR:"bufferStalledError",BUFFER_FULL_ERROR:"bufferFullError",BUFFER_SEEK_OVER_HOLE:"bufferSeekOverHole",BUFFER_NUDGE_ON_STALL:"bufferNudgeOnStall",INTERNAL_EXCEPTION:"internalException"}},"./src/event-handler.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/utils/logger.js"),A=T("./src/errors.js"),m=T("./src/events.js"),y={hlsEventGeneric:!0,hlsHandlerDestroying:!0,hlsHandlerDestroyed:!0},f=function(){function u(p){for(var c=[],a=1;a<arguments.length;a++)c[a-1]=arguments[a];this.hls=p,this.onEvent=this.onEvent.bind(this),this.handledEvents=c,this.useGenericHandler=!0,this.registerListeners()}return u.prototype.destroy=function(){this.onHandlerDestroying(),this.unregisterListeners(),this.onHandlerDestroyed()},u.prototype.onHandlerDestroying=function(){},u.prototype.onHandlerDestroyed=function(){},u.prototype.isEventHandler=function(){return typeof this.handledEvents=="object"&&this.handledEvents.length&&typeof this.onEvent=="function"},u.prototype.registerListeners=function(){this.isEventHandler()&&this.handledEvents.forEach(function(p){if(y[p])throw new Error("Forbidden event-name: "+p);this.hls.on(p,this.onEvent)},this)},u.prototype.unregisterListeners=function(){this.isEventHandler()&&this.handledEvents.forEach(function(p){this.hls.off(p,this.onEvent)},this)},u.prototype.onEvent=function(p,c){this.onEventGeneric(p,c)},u.prototype.onEventGeneric=function(p,c){var a=function(o,r){var i="on"+o.replace("hls","");if(typeof this[i]!="function")throw new Error("Event "+o+" has no generic handler in this "+this.constructor.name+" class (tried "+i+")");return this[i].bind(this,r)};try{a.call(this,p,c).call()}catch(o){_.logger.error("An internal error happened while handling event "+p+'. Error message: "'+o.message+'". Here is a stacktrace:',o),this.hls.trigger(m.default.ERROR,{type:A.ErrorTypes.OTHER_ERROR,details:A.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:p,err:o})}},u}();R.default=f},"./src/events.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_CREATED:"hlsBufferCreated",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",AUDIO_TRACK_SWITCHING:"hlsAudioTrackSwitching",AUDIO_TRACK_SWITCHED:"hlsAudioTrackSwitched",AUDIO_TRACK_LOADING:"hlsAudioTrackLoading",AUDIO_TRACK_LOADED:"hlsAudioTrackLoaded",SUBTITLE_TRACKS_UPDATED:"hlsSubtitleTracksUpdated",SUBTITLE_TRACK_SWITCH:"hlsSubtitleTrackSwitch",SUBTITLE_TRACK_LOADING:"hlsSubtitleTrackLoading",SUBTITLE_TRACK_LOADED:"hlsSubtitleTrackLoaded",SUBTITLE_FRAG_PROCESSED:"hlsSubtitleFragProcessed",INIT_PTS_FOUND:"hlsInitPtsFound",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_DECRYPTED:"hlsFragDecrypted",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",FPS_DROP_LEVEL_CAPPING:"hlsFpsDropLevelCapping",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded",STREAM_STATE_TRANSITION:"hlsStreamStateTransition"};R.default=_},"./src/hls.js":function(w,R,T){"use strict";var _=this&&this.__extends||function(){var g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,s){v.__proto__=s}||function(v,s){for(var l in s)s.hasOwnProperty(l)&&(v[l]=s[l])};return function(v,s){g(v,s);function l(){this.constructor=v}v.prototype=s===null?Object.create(s):(l.prototype=s.prototype,new l)}}();Object.defineProperty(R,"__esModule",{value:!0});var A=T("./node_modules/url-toolkit/src/url-toolkit.js"),m=T("./src/errors.js"),y=T("./src/loader/playlist-loader.js"),f=T("./src/loader/fragment-loader.js"),u=T("./src/loader/key-loader.js"),p=T("./src/controller/fragment-tracker.js"),c=T("./src/controller/stream-controller.js"),a=T("./src/controller/level-controller.js"),o=T("./src/controller/id3-track-controller.js"),r=T("./src/is-supported.js"),i=T("./src/utils/logger.js"),t=T("./src/config.js"),e=T("./src/events.js"),n=T("./src/observer.js"),d=function(g){_(v,g);function v(s){s===void 0&&(s={});var l=g.call(this)||this,x=v.DefaultConfig;if((s.liveSyncDurationCount||s.liveMaxLatencyDurationCount)&&(s.liveSyncDuration||s.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");for(var h in x)h in s||(s[h]=x[h]);if(s.liveMaxLatencyDurationCount!==void 0&&s.liveMaxLatencyDurationCount<=s.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');if(s.liveMaxLatencyDuration!==void 0&&(s.liveMaxLatencyDuration<=s.liveSyncDuration||s.liveSyncDuration===void 0))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be gt "liveSyncDuration"');i.enableLogs(s.debug),l.config=s,l._autoLevelCapping=-1;var E=l.abrController=new s.abrController(l),S=new s.bufferController(l),b=new s.capLevelController(l),I=new s.fpsController(l),L=new y.default(l),D=new f.default(l),O=new u.default(l),F=new o.default(l),C=l.levelController=new a.default(l),P=new p.FragmentTracker(l),k=l.streamController=new c.default(l,P),B=[C,k],M=s.audioStreamController;M&&B.push(new M(l,P)),l.networkControllers=B;var N=[L,D,O,E,S,b,I,F,P];if(M=s.audioTrackController,M){var j=new M(l);l.audioTrackController=j,N.push(j)}if(M=s.subtitleTrackController,M){var K=new M(l);l.subtitleTrackController=K,B.push(K)}if(M=s.emeController,M){var G=new M(l);l.emeController=G,N.push(G)}return M=s.subtitleStreamController,M&&B.push(new M(l,P)),M=s.timelineController,M&&N.push(new M(l)),l.coreComponents=N,l}return Object.defineProperty(v,"version",{get:function(){return"0.12.4"},enumerable:!0,configurable:!0}),v.isSupported=function(){return r.isSupported()},Object.defineProperty(v,"Events",{get:function(){return e.default},enumerable:!0,configurable:!0}),Object.defineProperty(v,"ErrorTypes",{get:function(){return m.ErrorTypes},enumerable:!0,configurable:!0}),Object.defineProperty(v,"ErrorDetails",{get:function(){return m.ErrorDetails},enumerable:!0,configurable:!0}),Object.defineProperty(v,"DefaultConfig",{get:function(){return v.defaultConfig?v.defaultConfig:t.hlsDefaultConfig},set:function(s){v.defaultConfig=s},enumerable:!0,configurable:!0}),v.prototype.destroy=function(){i.logger.log("destroy"),this.trigger(e.default.DESTROYING),this.detachMedia(),this.coreComponents.concat(this.networkControllers).forEach(function(s){s.destroy()}),this.url=null,this.removeAllListeners(),this._autoLevelCapping=-1},v.prototype.attachMedia=function(s){i.logger.log("attachMedia"),this.media=s,this.trigger(e.default.MEDIA_ATTACHING,{media:s})},v.prototype.detachMedia=function(){i.logger.log("detachMedia"),this.trigger(e.default.MEDIA_DETACHING),this.media=null},v.prototype.loadSource=function(s){s=A.buildAbsoluteURL(window.location.href,s,{alwaysNormalize:!0}),i.logger.log("loadSource:"+s),this.url=s,this.trigger(e.default.MANIFEST_LOADING,{url:s})},v.prototype.startLoad=function(s){s===void 0&&(s=-1),i.logger.log("startLoad("+s+")"),this.networkControllers.forEach(function(l){l.startLoad(s)})},v.prototype.stopLoad=function(){i.logger.log("stopLoad"),this.networkControllers.forEach(function(s){s.stopLoad()})},v.prototype.swapAudioCodec=function(){i.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},v.prototype.recoverMediaError=function(){i.logger.log("recoverMediaError");var s=this.media;this.detachMedia(),this.attachMedia(s)},Object.defineProperty(v.prototype,"levels",{get:function(){return this.levelController.levels},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"currentLevel",{get:function(){return this.streamController.currentLevel},set:function(s){i.logger.log("set currentLevel:"+s),this.loadLevel=s,this.streamController.immediateLevelSwitch()},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"nextLevel",{get:function(){return this.streamController.nextLevel},set:function(s){i.logger.log("set nextLevel:"+s),this.levelController.manualLevel=s,this.streamController.nextLevelSwitch()},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"loadLevel",{get:function(){return this.levelController.level},set:function(s){i.logger.log("set loadLevel:"+s),this.levelController.manualLevel=s},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"nextLoadLevel",{get:function(){return this.levelController.nextLoadLevel},set:function(s){this.levelController.nextLoadLevel=s},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"firstLevel",{get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(s){i.logger.log("set firstLevel:"+s),this.levelController.firstLevel=s},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"startLevel",{get:function(){return this.levelController.startLevel},set:function(s){i.logger.log("set startLevel:"+s);var l=this;s!==-1&&(s=Math.max(s,l.minAutoLevel)),l.levelController.startLevel=s},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"autoLevelCapping",{get:function(){return this._autoLevelCapping},set:function(s){i.logger.log("set autoLevelCapping:"+s),this._autoLevelCapping=s},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"autoLevelEnabled",{get:function(){return this.levelController.manualLevel===-1},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"manualLevel",{get:function(){return this.levelController.manualLevel},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"minAutoLevel",{get:function(){for(var s=this,l=s.levels,x=s.config.minAutoBitrate,h=l?l.length:0,E=0;E<h;E++){var S=l[E].realBitrate?Math.max(l[E].realBitrate,l[E].bitrate):l[E].bitrate;if(S>x)return E}return 0},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"maxAutoLevel",{get:function(){var s=this,l=s.levels,x=s.autoLevelCapping,h;return x===-1&&l&&l.length?h=l.length-1:h=x,h},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"nextAutoLevel",{get:function(){var s=this;return Math.min(Math.max(s.abrController.nextAutoLevel,s.minAutoLevel),s.maxAutoLevel)},set:function(s){var l=this;l.abrController.nextAutoLevel=Math.max(l.minAutoLevel,s)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"audioTracks",{get:function(){var s=this.audioTrackController;return s?s.audioTracks:[]},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"audioTrack",{get:function(){var s=this.audioTrackController;return s?s.audioTrack:-1},set:function(s){var l=this.audioTrackController;l&&(l.audioTrack=s)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"liveSyncPosition",{get:function(){return this.streamController.liveSyncPosition},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"subtitleTracks",{get:function(){var s=this.subtitleTrackController;return s?s.subtitleTracks:[]},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"subtitleTrack",{get:function(){var s=this.subtitleTrackController;return s?s.subtitleTrack:-1},set:function(s){var l=this.subtitleTrackController;l&&(l.subtitleTrack=s)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"subtitleDisplay",{get:function(){var s=this.subtitleTrackController;return s?s.subtitleDisplay:!1},set:function(s){var l=this.subtitleTrackController;l&&(l.subtitleDisplay=s)},enumerable:!0,configurable:!0}),v}(n.Observer);R.default=d},"./src/is-supported.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/utils/mediasource-helper.js");function A(){var m=_.getMediaSource(),y=window.SourceBuffer||window.WebKitSourceBuffer,f=m&&typeof m.isTypeSupported=="function"&&m.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),u=!y||y.prototype&&typeof y.prototype.appendBuffer=="function"&&typeof y.prototype.remove=="function";return!!f&&!!u}R.isSupported=A},"./src/loader/fragment-loader.js":function(w,R,T){"use strict";(function(_){var A=this&&this.__extends||function(){var c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,o){a.__proto__=o}||function(a,o){for(var r in o)o.hasOwnProperty(r)&&(a[r]=o[r])};return function(a,o){c(a,o);function r(){this.constructor=a}a.prototype=o===null?Object.create(o):(r.prototype=o.prototype,new r)}}();Object.defineProperty(R,"__esModule",{value:!0});var m=T("./src/events.js"),y=T("./src/event-handler.js"),f=T("./src/errors.js"),u=T("./src/utils/logger.js"),p=function(c){A(a,c);function a(o){var r=c.call(this,o,m.default.FRAG_LOADING)||this;return r.loaders={},r}return a.prototype.destroy=function(){var o=this.loaders;for(var r in o){var i=o[r];i&&i.destroy()}this.loaders={},c.prototype.destroy.call(this)},a.prototype.onFragLoading=function(o){var r=o.frag,i=r.type,t=this.loaders,e=this.hls.config,n=e.fLoader,d=e.loader;r.loaded=0;var g=t[i];g&&(u.logger.warn("abort previous fragment loader for type: "+i),g.abort()),g=t[i]=r.loader=e.fLoader?new n(e):new d(e);var v,s,l;v={url:r.url,frag:r,responseType:"arraybuffer",progressData:!1};var x=r.byteRangeStartOffset,h=r.byteRangeEndOffset;_.isFinite(x)&&_.isFinite(h)&&(v.rangeStart=x,v.rangeEnd=h),s={timeout:e.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:e.fragLoadingMaxRetryTimeout},l={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},g.load(v,s,l)},a.prototype.loadsuccess=function(o,r,i,t){t===void 0&&(t=null);var e=o.data,n=i.frag;n.loader=void 0,this.loaders[n.type]=void 0,this.hls.trigger(m.default.FRAG_LOADED,{payload:e,frag:n,stats:r,networkDetails:t})},a.prototype.loaderror=function(o,r,i){i===void 0&&(i=null);var t=r.frag,e=t.loader;e&&e.abort(),this.loaders[t.type]=void 0,this.hls.trigger(m.default.ERROR,{type:f.ErrorTypes.NETWORK_ERROR,details:f.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:r.frag,response:o,networkDetails:i})},a.prototype.loadtimeout=function(o,r,i){i===void 0&&(i=null);var t=r.frag,e=t.loader;e&&e.abort(),this.loaders[t.type]=void 0,this.hls.trigger(m.default.ERROR,{type:f.ErrorTypes.NETWORK_ERROR,details:f.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:r.frag,networkDetails:i})},a.prototype.loadprogress=function(o,r,i,t){t===void 0&&(t=null);var e=r.frag;e.loaded=o.loaded,this.hls.trigger(m.default.FRAG_LOAD_PROGRESS,{frag:e,stats:o,networkDetails:t})},a}(y.default);R.default=p}).call(this,T("./src/polyfills/number.js").Number)},"./src/loader/fragment.js":function(w,R,T){"use strict";(function(_){Object.defineProperty(R,"__esModule",{value:!0});var A=T("./node_modules/url-toolkit/src/url-toolkit.js"),m=T("./src/loader/level-key.js"),y=function(){function f(){var u;this._url=null,this._byteRange=null,this._decryptdata=null,this.tagList=[],this.programDateTime=null,this.rawProgramDateTime=null,this._elementaryStreams=(u={},u[f.ElementaryStreamTypes.AUDIO]=!1,u[f.ElementaryStreamTypes.VIDEO]=!1,u)}return Object.defineProperty(f,"ElementaryStreamTypes",{get:function(){return{AUDIO:"audio",VIDEO:"video"}},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"url",{get:function(){return!this._url&&this.relurl&&(this._url=A.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(u){this._url=u},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"byteRange",{get:function(){if(!this._byteRange&&!this.rawByteRange)return[];if(this._byteRange)return this._byteRange;var u=[];if(this.rawByteRange){var p=this.rawByteRange.split("@",2);if(p.length===1){var c=this.lastByteRangeEndOffset;u[0]=c||0}else u[0]=parseInt(p[1]);u[1]=parseInt(p[0])+u[0],this._byteRange=u}return u},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"byteRangeStartOffset",{get:function(){return this.byteRange[0]},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"byteRangeEndOffset",{get:function(){return this.byteRange[1]},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"decryptdata",{get:function(){return this._decryptdata||(this._decryptdata=this.fragmentDecryptdataFromLevelkey(this.levelkey,this.sn)),this._decryptdata},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"endProgramDateTime",{get:function(){if(!_.isFinite(this.programDateTime))return null;var u=_.isFinite(this.duration)?this.duration:0;return this.programDateTime+u*1e3},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"encrypted",{get:function(){return!!(this.decryptdata&&this.decryptdata.uri!==null&&this.decryptdata.key===null)},enumerable:!0,configurable:!0}),f.prototype.addElementaryStream=function(u){this._elementaryStreams[u]=!0},f.prototype.hasElementaryStream=function(u){return this._elementaryStreams[u]===!0},f.prototype.createInitializationVector=function(u){for(var p=new Uint8Array(16),c=12;c<16;c++)p[c]=u>>8*(15-c)&255;return p},f.prototype.fragmentDecryptdataFromLevelkey=function(u,p){var c=u;return u&&u.method&&u.uri&&!u.iv&&(c=new m.default,c.method=u.method,c.baseuri=u.baseuri,c.reluri=u.reluri,c.iv=this.createInitializationVector(p)),c},f}();R.default=y}).call(this,T("./src/polyfills/number.js").Number)},"./src/loader/key-loader.js":function(w,R,T){"use strict";var _=this&&this.__extends||function(){var p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(c,a){c.__proto__=a}||function(c,a){for(var o in a)a.hasOwnProperty(o)&&(c[o]=a[o])};return function(c,a){p(c,a);function o(){this.constructor=c}c.prototype=a===null?Object.create(a):(o.prototype=a.prototype,new o)}}();Object.defineProperty(R,"__esModule",{value:!0});var A=T("./src/events.js"),m=T("./src/event-handler.js"),y=T("./src/errors.js"),f=T("./src/utils/logger.js"),u=function(p){_(c,p);function c(a){var o=p.call(this,a,A.default.KEY_LOADING)||this;return o.loaders={},o.decryptkey=null,o.decrypturl=null,o}return c.prototype.destroy=function(){for(var a in this.loaders){var o=this.loaders[a];o&&o.destroy()}this.loaders={},m.default.prototype.destroy.call(this)},c.prototype.onKeyLoading=function(a){var o=a.frag,r=o.type,i=this.loaders[r],t=o.decryptdata,e=t.uri;if(e!==this.decrypturl||this.decryptkey===null){var n=this.hls.config;i&&(f.logger.warn("abort previous key loader for type:"+r),i.abort()),o.loader=this.loaders[r]=new n.loader(n),this.decrypturl=e,this.decryptkey=null;var d=void 0,g=void 0,v=void 0;d={url:e,frag:o,responseType:"arraybuffer"},g={timeout:n.fragLoadingTimeOut,maxRetry:0,retryDelay:n.fragLoadingRetryDelay,maxRetryDelay:n.fragLoadingMaxRetryTimeout},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},o.loader.load(d,g,v)}else this.decryptkey&&(t.key=this.decryptkey,this.hls.trigger(A.default.KEY_LOADED,{frag:o}))},c.prototype.loadsuccess=function(a,o,r){var i=r.frag;this.decryptkey=i.decryptdata.key=new Uint8Array(a.data),i.loader=void 0,this.loaders[i.type]=void 0,this.hls.trigger(A.default.KEY_LOADED,{frag:i})},c.prototype.loaderror=function(a,o){var r=o.frag,i=r.loader;i&&i.abort(),this.loaders[o.type]=void 0,this.hls.trigger(A.default.ERROR,{type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:r,response:a})},c.prototype.loadtimeout=function(a,o){var r=o.frag,i=r.loader;i&&i.abort(),this.loaders[o.type]=void 0,this.hls.trigger(A.default.ERROR,{type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})},c}(m.default);R.default=u},"./src/loader/level-key.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./node_modules/url-toolkit/src/url-toolkit.js"),A=function(){function m(){this.method=null,this.key=null,this.iv=null,this._uri=null}return Object.defineProperty(m.prototype,"uri",{get:function(){return!this._uri&&this.reluri&&(this._uri=_.buildAbsoluteURL(this.baseuri,this.reluri,{alwaysNormalize:!0})),this._uri},enumerable:!0,configurable:!0}),m}();R.default=A},"./src/loader/level.js":function(w,R,T){"use strict";(function(_){Object.defineProperty(R,"__esModule",{value:!0});var A=function(){function m(y){this.endCC=0,this.endSN=0,this.fragments=[],this.initSegment=null,this.live=!0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=y,this.version=null}return Object.defineProperty(m.prototype,"hasProgramDateTime",{get:function(){return!!(this.fragments[0]&&_.isFinite(this.fragments[0].programDateTime))},enumerable:!0,configurable:!0}),m}();R.default=A}).call(this,T("./src/polyfills/number.js").Number)},"./src/loader/m3u8-parser.js":function(w,R,T){"use strict";(function(_){Object.defineProperty(R,"__esModule",{value:!0});var A=T("./node_modules/url-toolkit/src/url-toolkit.js"),m=T("./src/loader/fragment.js"),y=T("./src/loader/level.js"),f=T("./src/loader/level-key.js"),u=T("./src/utils/attr-list.js"),p=T("./src/utils/logger.js"),c=T("./src/utils/codecs.js"),a=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g,o=/#EXT-X-MEDIA:(.*)/g,r=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)([\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),i=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(VERSION):(\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)([^:]*):(.*))|(?:(#)(.*))(?:.*)\r?\n?/,t=/\.(mp4|m4s|m4v|m4a)$/i,e=function(){function g(){}return g.findGroup=function(v,s){if(!v)return null;for(var l=null,x=0;x<v.length;x++){var h=v[x];h.id===s&&(l=h)}return l},g.convertAVC1ToAVCOTI=function(v){var s,l=v.split(".");return l.length>2?(s=l.shift()+".",s+=parseInt(l.shift()).toString(16),s+=("000"+parseInt(l.shift()).toString(16)).substr(-4)):s=v,s},g.resolve=function(v,s){return A.buildAbsoluteURL(s,v,{alwaysNormalize:!0})},g.parseMasterPlaylist=function(v,s){var l=[],x;a.lastIndex=0;function h(I,L){["video","audio"].forEach(function(D){var O=I.filter(function(C){return c.isCodecType(C,D)});if(O.length){var F=O.filter(function(C){return C.lastIndexOf("avc1",0)===0||C.lastIndexOf("mp4a",0)===0});L[D+"Codec"]=F.length>0?F[0]:O[0],I=I.filter(function(C){return O.indexOf(C)===-1})}}),L.unknownCodecs=I}for(;(x=a.exec(v))!=null;){var E={},S=E.attrs=new u.default(x[1]);E.url=g.resolve(x[2],s);var b=S.decimalResolution("RESOLUTION");b&&(E.width=b.width,E.height=b.height),E.bitrate=S.decimalInteger("AVERAGE-BANDWIDTH")||S.decimalInteger("BANDWIDTH"),E.name=S.NAME,h([].concat((S.CODECS||"").split(/[ ,]+/)),E),E.videoCodec&&E.videoCodec.indexOf("avc1")!==-1&&(E.videoCodec=g.convertAVC1ToAVCOTI(E.videoCodec)),l.push(E)}return l},g.parseMasterPlaylistMedia=function(v,s,l,x){x===void 0&&(x=[]);var h,E=[],S=0;for(o.lastIndex=0;(h=o.exec(v))!==null;){var b={},I=new u.default(h[1]);if(I.TYPE===l){if(b.groupId=I["GROUP-ID"],b.name=I.NAME,b.type=l,b.default=I.DEFAULT==="YES",b.autoselect=I.AUTOSELECT==="YES",b.forced=I.FORCED==="YES",I.URI&&(b.url=g.resolve(I.URI,s)),b.lang=I.LANGUAGE,b.name||(b.name=b.lang),x.length){var L=g.findGroup(x,b.groupId);b.audioCodec=L?L.codec:x[0].codec}b.id=S++,E.push(b)}}return E},g.parseLevelPlaylist=function(v,s,l,x,h){var E=0,S=0,b=new y.default(s),I=new f.default,L=0,D=null,O=new m.default,F,C,P=null;for(r.lastIndex=0;(F=r.exec(v))!==null;){var k=F[1];if(k){O.duration=parseFloat(k);var B=(" "+F[2]).slice(1);O.title=B||null,O.tagList.push(B?["INF",k,B]:["INF",k])}else if(F[3]){if(_.isFinite(O.duration)){var M=E++;O.type=x,O.start=S,O.levelkey=I,O.sn=M,O.level=l,O.cc=L,O.urlId=h,O.baseurl=s,O.relurl=(" "+F[3]).slice(1),d(O,D),b.fragments.push(O),D=O,S+=O.duration,O=new m.default}}else if(F[4]){if(O.rawByteRange=(" "+F[4]).slice(1),D){var N=D.byteRangeEndOffset;N&&(O.lastByteRangeEndOffset=N)}}else if(F[5])O.rawProgramDateTime=(" "+F[5]).slice(1),O.tagList.push(["PROGRAM-DATE-TIME",O.rawProgramDateTime]),P===null&&(P=b.fragments.length);else{for(F=F[0].match(i),C=1;C<F.length&&F[C]===void 0;C++);var j=(" "+F[C+1]).slice(1),K=(" "+F[C+2]).slice(1);switch(F[C]){case"#":O.tagList.push(K?[j,K]:[j]);break;case"PLAYLIST-TYPE":b.type=j.toUpperCase();break;case"MEDIA-SEQUENCE":E=b.startSN=parseInt(j);break;case"TARGETDURATION":b.targetduration=parseFloat(j);break;case"VERSION":b.version=parseInt(j);break;case"EXTM3U":break;case"ENDLIST":b.live=!1;break;case"DIS":L++,O.tagList.push(["DIS"]);break;case"DISCONTINUITY-SEQ":L=parseInt(j);break;case"KEY":var G=j,W=new u.default(G),U=W.enumeratedString("METHOD"),V=W.URI,H=W.hexadecimalInteger("IV");U&&(I=new f.default,V&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(U)>=0&&(I.method=U,I.baseuri=s,I.reluri=V,I.key=null,I.iv=H));break;case"START":var Y=j,z=new u.default(Y),X=z.decimalFloatingPoint("TIME-OFFSET");_.isFinite(X)&&(b.startTimeOffset=X);break;case"MAP":var ee=new u.default(j);O.relurl=ee.URI,O.rawByteRange=ee.BYTERANGE,O.baseurl=s,O.level=l,O.type=x,O.sn="initSegment",b.initSegment=O,O=new m.default,O.rawProgramDateTime=b.initSegment.rawProgramDateTime;break;default:p.logger.warn("line parsed but not handled: "+F);break}}}return O=D,O&&!O.relurl&&(b.fragments.pop(),S-=O.duration),b.totalduration=S,b.averagetargetduration=S/b.fragments.length,b.endSN=E-1,b.startCC=b.fragments[0]?b.fragments[0].cc:0,b.endCC=L,!b.initSegment&&b.fragments.length&&b.fragments.every(function(te){return t.test(te.relurl)})&&(p.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),O=new m.default,O.relurl=b.fragments[0].relurl,O.baseurl=s,O.level=l,O.type=x,O.sn="initSegment",b.initSegment=O,b.needSidxRanges=!0),P&&n(b.fragments,P),b},g}();R.default=e;function n(g,v){for(var s=g[v],l=v-1;l>=0;l--){var x=g[l];x.programDateTime=s.programDateTime-x.duration*1e3,s=x}}function d(g,v){g.rawProgramDateTime?g.programDateTime=Date.parse(g.rawProgramDateTime):v&&v.programDateTime&&(g.programDateTime=v.endProgramDateTime),_.isFinite(g.programDateTime)||(g.programDateTime=null,g.rawProgramDateTime=null)}}).call(this,T("./src/polyfills/number.js").Number)},"./src/loader/playlist-loader.js":function(w,R,T){"use strict";(function(_){var A=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var d in n)n.hasOwnProperty(d)&&(e[d]=n[d])};return function(e,n){t(e,n);function d(){this.constructor=e}e.prototype=n===null?Object.create(n):(d.prototype=n.prototype,new d)}}();Object.defineProperty(R,"__esModule",{value:!0});var m=T("./src/events.js"),y=T("./src/event-handler.js"),f=T("./src/errors.js"),u=T("./src/utils/logger.js"),p=T("./src/demux/mp4demuxer.js"),c=T("./src/loader/m3u8-parser.js"),a=window.performance,o={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},r={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},i=function(t){A(e,t);function e(n){var d=t.call(this,n,m.default.MANIFEST_LOADING,m.default.LEVEL_LOADING,m.default.AUDIO_TRACK_LOADING,m.default.SUBTITLE_TRACK_LOADING)||this;return d.loaders={},d}return Object.defineProperty(e,"ContextType",{get:function(){return o},enumerable:!0,configurable:!0}),Object.defineProperty(e,"LevelType",{get:function(){return r},enumerable:!0,configurable:!0}),e.canHaveQualityLevels=function(n){return n!==o.AUDIO_TRACK&&n!==o.SUBTITLE_TRACK},e.mapContextToLevelType=function(n){var d=n.type;switch(d){case o.AUDIO_TRACK:return r.AUDIO;case o.SUBTITLE_TRACK:return r.SUBTITLE;default:return r.MAIN}},e.getResponseUrl=function(n,d){var g=n.url;return(g===void 0||g.indexOf("data:")===0)&&(g=d.url),g},e.prototype.createInternalLoader=function(n){var d=this.hls.config,g=d.pLoader,v=d.loader,s=g||v,l=new s(d);return n.loader=l,this.loaders[n.type]=l,l},e.prototype.getInternalLoader=function(n){return this.loaders[n.type]},e.prototype.resetInternalLoader=function(n){this.loaders[n]&&delete this.loaders[n]},e.prototype.destroyInternalLoaders=function(){for(var n in this.loaders){var d=this.loaders[n];d&&d.destroy(),this.resetInternalLoader(n)}},e.prototype.destroy=function(){this.destroyInternalLoaders(),t.prototype.destroy.call(this)},e.prototype.onManifestLoading=function(n){this.load(n.url,{type:o.MANIFEST,level:0,id:null})},e.prototype.onLevelLoading=function(n){this.load(n.url,{type:o.LEVEL,level:n.level,id:n.id})},e.prototype.onAudioTrackLoading=function(n){this.load(n.url,{type:o.AUDIO_TRACK,level:null,id:n.id})},e.prototype.onSubtitleTrackLoading=function(n){this.load(n.url,{type:o.SUBTITLE_TRACK,level:null,id:n.id})},e.prototype.load=function(n,d){var g=this.hls.config;u.logger.debug("Loading playlist of type "+d.type+", level: "+d.level+", id: "+d.id);var v=this.getInternalLoader(d);if(v){var s=v.context;if(s&&s.url===n)return u.logger.trace("playlist request ongoing"),!1;u.logger.warn("aborting previous loader for type: "+d.type),v.abort()}var l,x,h,E;switch(d.type){case o.MANIFEST:l=g.manifestLoadingMaxRetry,x=g.manifestLoadingTimeOut,h=g.manifestLoadingRetryDelay,E=g.manifestLoadingMaxRetryTimeout;break;case o.LEVEL:l=0,x=g.levelLoadingTimeOut;break;default:l=g.levelLoadingMaxRetry,x=g.levelLoadingTimeOut,h=g.levelLoadingRetryDelay,E=g.levelLoadingMaxRetryTimeout;break}v=this.createInternalLoader(d),d.url=n,d.responseType=d.responseType||"";var S={timeout:x,maxRetry:l,retryDelay:h,maxRetryDelay:E},b={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};return u.logger.debug("Calling internal loader delegate for URL: "+n),v.load(d,S,b),!0},e.prototype.loadsuccess=function(n,d,g,v){if(v===void 0&&(v=null),g.isSidxRequest){this._handleSidxRequest(n,g),this._handlePlaylistLoaded(n,d,g,v);return}this.resetInternalLoader(g.type);var s=n.data;if(d.tload=a.now(),s.indexOf("#EXTM3U")!==0){this._handleManifestParsingError(n,g,"no EXTM3U delimiter",v);return}s.indexOf("#EXTINF:")>0||s.indexOf("#EXT-X-TARGETDURATION:")>0?this._handleTrackOrLevelPlaylist(n,d,g,v):this._handleMasterPlaylist(n,d,g,v)},e.prototype.loaderror=function(n,d,g){g===void 0&&(g=null),this._handleNetworkError(d,g,!1,n)},e.prototype.loadtimeout=function(n,d,g){g===void 0&&(g=null),this._handleNetworkError(d,g,!0)},e.prototype._handleMasterPlaylist=function(n,d,g,v){var s=this.hls,l=n.data,x=e.getResponseUrl(n,g),h=c.default.parseMasterPlaylist(l,x);if(!h.length){this._handleManifestParsingError(n,g,"no level found in manifest",v);return}var E=h.map(function(L){return{id:L.attrs.AUDIO,codec:L.audioCodec}}),S=c.default.parseMasterPlaylistMedia(l,x,"AUDIO",E),b=c.default.parseMasterPlaylistMedia(l,x,"SUBTITLES");if(S.length){var I=!1;S.forEach(function(L){L.url||(I=!0)}),I===!1&&h[0].audioCodec&&!h[0].attrs.AUDIO&&(u.logger.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),S.unshift({type:"main",name:"main"}))}s.trigger(m.default.MANIFEST_LOADED,{levels:h,audioTracks:S,subtitles:b,url:x,stats:d,networkDetails:v})},e.prototype._handleTrackOrLevelPlaylist=function(n,d,g,v){var s=this.hls,l=g.id,x=g.level,h=g.type,E=e.getResponseUrl(n,g),S=_.isFinite(l)?l:0,b=_.isFinite(x)?x:S,I=e.mapContextToLevelType(g),L=c.default.parseLevelPlaylist(n.data,E,b,I,S);if(L.tload=d.tload,h===o.MANIFEST){var D={url:E,details:L};s.trigger(m.default.MANIFEST_LOADED,{levels:[D],audioTracks:[],url:E,stats:d,networkDetails:v})}if(d.tparsed=a.now(),L.needSidxRanges){var O=L.initSegment.url;this.load(O,{isSidxRequest:!0,type:h,level:x,levelDetails:L,id:l,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer"});return}g.levelDetails=L,this._handlePlaylistLoaded(n,d,g,v)},e.prototype._handleSidxRequest=function(n,d){var g=p.default.parseSegmentIndex(new Uint8Array(n.data));if(!!g){var v=g.references,s=d.levelDetails;v.forEach(function(l,x){var h=l.info,E=s.fragments[x];E.byteRange.length===0&&(E.rawByteRange=String(1+h.end-h.start)+"@"+String(h.start))}),s.initSegment.rawByteRange=String(g.moovEndOffset)+"@0"}},e.prototype._handleManifestParsingError=function(n,d,g,v){this.hls.trigger(m.default.ERROR,{type:f.ErrorTypes.NETWORK_ERROR,details:f.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:n.url,reason:g,networkDetails:v})},e.prototype._handleNetworkError=function(n,d,g,v){g===void 0&&(g=!1),v===void 0&&(v=null),u.logger.info("A network error occured while loading a "+n.type+"-type playlist");var s,l,x=this.getInternalLoader(n);switch(n.type){case o.MANIFEST:s=g?f.ErrorDetails.MANIFEST_LOAD_TIMEOUT:f.ErrorDetails.MANIFEST_LOAD_ERROR,l=!0;break;case o.LEVEL:s=g?f.ErrorDetails.LEVEL_LOAD_TIMEOUT:f.ErrorDetails.LEVEL_LOAD_ERROR,l=!1;break;case o.AUDIO_TRACK:s=g?f.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:f.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,l=!1;break;default:l=!1}x&&(x.abort(),this.resetInternalLoader(n.type));var h={type:f.ErrorTypes.NETWORK_ERROR,details:s,fatal:l,url:x.url,loader:x,context:n,networkDetails:d};v&&(h.response=v),this.hls.trigger(m.default.ERROR,h)},e.prototype._handlePlaylistLoaded=function(n,d,g,v){var s=g.type,l=g.level,x=g.id,h=g.levelDetails;if(!h.targetduration){this._handleManifestParsingError(n,g,"invalid target duration",v);return}var E=e.canHaveQualityLevels(g.type);if(E)this.hls.trigger(m.default.LEVEL_LOADED,{details:h,level:l||0,id:x||0,stats:d,networkDetails:v});else switch(s){case o.AUDIO_TRACK:this.hls.trigger(m.default.AUDIO_TRACK_LOADED,{details:h,id:x,stats:d,networkDetails:v});break;case o.SUBTITLE_TRACK:this.hls.trigger(m.default.SUBTITLE_TRACK_LOADED,{details:h,id:x,stats:d,networkDetails:v});break}},e}(y.default);R.default=i}).call(this,T("./src/polyfills/number.js").Number)},"./src/observer.js":function(w,R,T){"use strict";var _=this&&this.__extends||function(){var y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,u){f.__proto__=u}||function(f,u){for(var p in u)u.hasOwnProperty(p)&&(f[p]=u[p])};return function(f,u){y(f,u);function p(){this.constructor=f}f.prototype=u===null?Object.create(u):(p.prototype=u.prototype,new p)}}();Object.defineProperty(R,"__esModule",{value:!0});var A=T("./node_modules/eventemitter3/index.js"),m=function(y){_(f,y);function f(){return y!==null&&y.apply(this,arguments)||this}return f.prototype.trigger=function(u){for(var p=[],c=1;c<arguments.length;c++)p[c-1]=arguments[c];this.emit.apply(this,[u,u].concat(p))},f}(A.EventEmitter);R.Observer=m},"./src/polyfills/number.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/utils/get-self-scope.js"),A=_.getSelfScope(),m=A.Number;R.Number=m,m.isFinite=m.isFinite||function(y){return typeof y=="number"&&isFinite(y)}},"./src/remux/aac-helper.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=function(){function A(){}return A.getSilentFrame=function(m,y){switch(m){case"mp4a.40.2":if(y===1)return new Uint8Array([0,200,0,128,35,128]);if(y===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(y===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(y===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(y===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(y===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(y===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(y===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(y===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return null},A}();R.default=_},"./src/remux/mp4-generator.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=Math.pow(2,32)-1,A=function(){function m(){}return m.init=function(){m.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var y;for(y in m.types)m.types.hasOwnProperty(y)&&(m.types[y]=[y.charCodeAt(0),y.charCodeAt(1),y.charCodeAt(2),y.charCodeAt(3)]);var f=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),u=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);m.HDLR_TYPES={video:f,audio:u};var p=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),c=new Uint8Array([0,0,0,0,0,0,0,0]);m.STTS=m.STSC=m.STCO=c,m.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),m.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),m.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),m.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),r=new Uint8Array([0,0,0,1]);m.FTYP=m.box(m.types.ftyp,a,r,a,o),m.DINF=m.box(m.types.dinf,m.box(m.types.dref,p))},m.box=function(y){for(var f=Array.prototype.slice.call(arguments,1),u=8,p=f.length,c=p,a;p--;)u+=f[p].byteLength;for(a=new Uint8Array(u),a[0]=u>>24&255,a[1]=u>>16&255,a[2]=u>>8&255,a[3]=u&255,a.set(y,4),p=0,u=8;p<c;p++)a.set(f[p],u),u+=f[p].byteLength;return a},m.hdlr=function(y){return m.box(m.types.hdlr,m.HDLR_TYPES[y])},m.mdat=function(y){return m.box(m.types.mdat,y)},m.mdhd=function(y,f){f*=y;var u=Math.floor(f/(_+1)),p=Math.floor(f%(_+1));return m.box(m.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,y>>24&255,y>>16&255,y>>8&255,y&255,u>>24,u>>16&255,u>>8&255,u&255,p>>24,p>>16&255,p>>8&255,p&255,85,196,0,0]))},m.mdia=function(y){return m.box(m.types.mdia,m.mdhd(y.timescale,y.duration),m.hdlr(y.type),m.minf(y))},m.mfhd=function(y){return m.box(m.types.mfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255]))},m.minf=function(y){return y.type==="audio"?m.box(m.types.minf,m.box(m.types.smhd,m.SMHD),m.DINF,m.stbl(y)):m.box(m.types.minf,m.box(m.types.vmhd,m.VMHD),m.DINF,m.stbl(y))},m.moof=function(y,f,u){return m.box(m.types.moof,m.mfhd(y),m.traf(u,f))},m.moov=function(y){for(var f=y.length,u=[];f--;)u[f]=m.trak(y[f]);return m.box.apply(null,[m.types.moov,m.mvhd(y[0].timescale,y[0].duration)].concat(u).concat(m.mvex(y)))},m.mvex=function(y){for(var f=y.length,u=[];f--;)u[f]=m.trex(y[f]);return m.box.apply(null,[m.types.mvex].concat(u))},m.mvhd=function(y,f){f*=y;var u=Math.floor(f/(_+1)),p=Math.floor(f%(_+1)),c=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,y>>24&255,y>>16&255,y>>8&255,y&255,u>>24,u>>16&255,u>>8&255,u&255,p>>24,p>>16&255,p>>8&255,p&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return m.box(m.types.mvhd,c)},m.sdtp=function(y){var f=y.samples||[],u=new Uint8Array(4+f.length),p,c;for(c=0;c<f.length;c++)p=f[c].flags,u[c+4]=p.dependsOn<<4|p.isDependedOn<<2|p.hasRedundancy;return m.box(m.types.sdtp,u)},m.stbl=function(y){return m.box(m.types.stbl,m.stsd(y),m.box(m.types.stts,m.STTS),m.box(m.types.stsc,m.STSC),m.box(m.types.stsz,m.STSZ),m.box(m.types.stco,m.STCO))},m.avc1=function(y){var f=[],u=[],p,c,a;for(p=0;p<y.sps.length;p++)c=y.sps[p],a=c.byteLength,f.push(a>>>8&255),f.push(a&255),f=f.concat(Array.prototype.slice.call(c));for(p=0;p<y.pps.length;p++)c=y.pps[p],a=c.byteLength,u.push(a>>>8&255),u.push(a&255),u=u.concat(Array.prototype.slice.call(c));var o=m.box(m.types.avcC,new Uint8Array([1,f[3],f[4],f[5],252|3,224|y.sps.length].concat(f).concat([y.pps.length]).concat(u))),r=y.width,i=y.height,t=y.pixelRatio[0],e=y.pixelRatio[1];return m.box(m.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,r>>8&255,r&255,i>>8&255,i&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,m.box(m.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),m.box(m.types.pasp,new Uint8Array([t>>24,t>>16&255,t>>8&255,t&255,e>>24,e>>16&255,e>>8&255,e&255])))},m.esds=function(y){var f=y.config.length;return new Uint8Array([0,0,0,0,3,23+f,0,1,0,4,15+f,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([f]).concat(y.config).concat([6,1,2]))},m.mp4a=function(y){var f=y.samplerate;return m.box(m.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,y.channelCount,0,16,0,0,0,0,f>>8&255,f&255,0,0]),m.box(m.types.esds,m.esds(y)))},m.mp3=function(y){var f=y.samplerate;return m.box(m.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,y.channelCount,0,16,0,0,0,0,f>>8&255,f&255,0,0]))},m.stsd=function(y){return y.type==="audio"?!y.isAAC&&y.codec==="mp3"?m.box(m.types.stsd,m.STSD,m.mp3(y)):m.box(m.types.stsd,m.STSD,m.mp4a(y)):m.box(m.types.stsd,m.STSD,m.avc1(y))},m.tkhd=function(y){var f=y.id,u=y.duration*y.timescale,p=y.width,c=y.height,a=Math.floor(u/(_+1)),o=Math.floor(u%(_+1));return m.box(m.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,f>>24&255,f>>16&255,f>>8&255,f&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,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,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,p>>8&255,p&255,0,0,c>>8&255,c&255,0,0]))},m.traf=function(y,f){var u=m.sdtp(y),p=y.id,c=Math.floor(f/(_+1)),a=Math.floor(f%(_+1));return m.box(m.types.traf,m.box(m.types.tfhd,new Uint8Array([0,0,0,0,p>>24,p>>16&255,p>>8&255,p&255])),m.box(m.types.tfdt,new Uint8Array([1,0,0,0,c>>24,c>>16&255,c>>8&255,c&255,a>>24,a>>16&255,a>>8&255,a&255])),m.trun(y,u.length+16+20+8+16+8+8),u)},m.trak=function(y){return y.duration=y.duration||4294967295,m.box(m.types.trak,m.tkhd(y),m.mdia(y))},m.trex=function(y){var f=y.id;return m.box(m.types.trex,new Uint8Array([0,0,0,0,f>>24,f>>16&255,f>>8&255,f&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},m.trun=function(y,f){var u=y.samples||[],p=u.length,c=12+16*p,a=new Uint8Array(c),o,r,i,t,e,n;for(f+=8+c,a.set([0,0,15,1,p>>>24&255,p>>>16&255,p>>>8&255,p&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255],0),o=0;o<p;o++)r=u[o],i=r.duration,t=r.size,e=r.flags,n=r.cts,a.set([i>>>24&255,i>>>16&255,i>>>8&255,i&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,n>>>24&255,n>>>16&255,n>>>8&255,n&255],12+16*o);return m.box(m.types.trun,a)},m.initSegment=function(y){m.types||m.init();var f=m.moov(y),u;return u=new Uint8Array(m.FTYP.byteLength+f.byteLength),u.set(m.FTYP),u.set(f,m.FTYP.byteLength),u},m}();R.default=A},"./src/remux/mp4-remuxer.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/remux/aac-helper.js"),A=T("./src/remux/mp4-generator.js"),m=T("./src/events.js"),y=T("./src/errors.js"),f=T("./src/utils/logger.js"),u=10*1e3,p=function(){function c(a,o,r,i){this.observer=a,this.config=o,this.typeSupported=r;var t=navigator.userAgent;this.isSafari=i&&i.indexOf("Apple")>-1&&t&&!t.match("CriOS"),this.ISGenerated=!1}return c.prototype.destroy=function(){},c.prototype.resetTimeStamp=function(a){this._initPTS=this._initDTS=a},c.prototype.resetInitSegment=function(){this.ISGenerated=!1},c.prototype.remux=function(a,o,r,i,t,e,n){if(this.ISGenerated||this.generateIS(a,o,t),this.ISGenerated){var d=a.samples.length,g=o.samples.length,v=t,s=t;if(d&&g){var l=(a.samples[0].pts-o.samples[0].pts)/o.inputTimeScale;v+=Math.max(0,l),s+=Math.max(0,-l)}if(d){a.timescale||(f.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(a,o,t));var x=this.remuxAudio(a,v,e,n);if(g){var h=void 0;x&&(h=x.endPTS-x.startPTS),o.timescale||(f.logger.warn("regenerate InitSegment as video detected"),this.generateIS(a,o,t)),this.remuxVideo(o,s,e,h,n)}}else if(g){var E=this.remuxVideo(o,s,e,0,n);E&&a.codec&&this.remuxEmptyAudio(a,v,e,E)}}r.samples.length&&this.remuxID3(r,t),i.samples.length&&this.remuxText(i,t),this.observer.trigger(m.default.FRAG_PARSED)},c.prototype.generateIS=function(a,o,r){var i=this.observer,t=a.samples,e=o.samples,n=this.typeSupported,d="audio/mp4",g={},v={tracks:g},s=this._initPTS===void 0,l,x;if(s&&(l=x=Infinity),a.config&&t.length&&(a.timescale=a.samplerate,f.logger.log("audio sampling rate : "+a.samplerate),a.isAAC||(n.mpeg?(d="audio/mpeg",a.codec=""):n.mp3&&(a.codec="mp3")),g.audio={container:d,codec:a.codec,initSegment:!a.isAAC&&n.mpeg?new Uint8Array:A.default.initSegment([a]),metadata:{channelCount:a.channelCount}},s&&(l=x=t[0].pts-a.inputTimeScale*r)),o.sps&&o.pps&&e.length){var h=o.inputTimeScale;o.timescale=h,g.video={container:"video/mp4",codec:o.codec,initSegment:A.default.initSegment([o]),metadata:{width:o.width,height:o.height}},s&&(l=Math.min(l,e[0].pts-h*r),x=Math.min(x,e[0].dts-h*r),this.observer.trigger(m.default.INIT_PTS_FOUND,{initPTS:l}))}Object.keys(g).length?(i.trigger(m.default.FRAG_PARSING_INIT_SEGMENT,v),this.ISGenerated=!0,s&&(this._initPTS=l,this._initDTS=x)):i.trigger(m.default.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})},c.prototype.remuxVideo=function(a,o,r,i,t){var e=8,n,d,g,v,s,l,x,h=a.timescale,E=a.samples,S=[],b=E.length,I=this._PTSNormalize,L=this._initPTS,D=this.nextAvcDts,O=this.isSafari;if(b!==0){O&&(r|=E.length&&D&&(t&&Math.abs(o-D/h)<.1||Math.abs(E[0].pts-D-L)<h/5)),r||(D=o*h),E.forEach(function(J){J.pts=I(J.pts-L,D),J.dts=I(J.dts-L,D)}),E.sort(function(J,ne){var le=J.dts-ne.dts,ue=J.pts-ne.pts;return le||ue||J.id-ne.id});var F=E.reduce(function(J,ne){return Math.max(Math.min(J,ne.pts-ne.dts),-18e3)},0);if(F<0){f.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Math.round(F/90)+" ms to overcome this issue");for(var C=0;C<E.length;C++)E[C].dts+=F}var P=E[0];s=Math.max(P.dts,0),v=Math.max(P.pts,0);var k=Math.round((s-D)/90);r&&k&&(k>1?f.logger.log("AVC:"+k+" ms hole between fragments detected,filling it"):k<-1&&f.logger.log("AVC:"+-k+" ms overlapping between fragments detected"),s=D,E[0].dts=s,v=Math.max(v-k,D),E[0].pts=v,f.logger.log("Video/PTS/DTS adjusted: "+Math.round(v/90)+"/"+Math.round(s/90)+",delta:"+k+" ms")),P=E[E.length-1],x=Math.max(P.dts,0),l=Math.max(P.pts,0,x),O&&(n=Math.round((x-s)/(E.length-1)));for(var B=0,M=0,C=0;C<b;C++){for(var N=E[C],j=N.units,K=j.length,G=0,W=0;W<K;W++)G+=j[W].data.length;M+=G,B+=K,N.length=G,O?N.dts=s+C*n:N.dts=Math.max(N.dts,s),N.pts=Math.max(N.pts,N.dts)}var U=M+4*B+8;try{d=new Uint8Array(U)}catch(J){this.observer.trigger(m.default.ERROR,{type:y.ErrorTypes.MUX_ERROR,details:y.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:U,reason:"fail allocating video mdat "+U});return}var V=new DataView(d.buffer);V.setUint32(0,U),d.set(A.default.types.mdat,4);for(var C=0;C<b;C++){for(var H=E[C],Y=H.units,z=0,X=void 0,W=0,K=Y.length;W<K;W++){var ee=Y[W],te=ee.data,re=ee.data.byteLength;V.setUint32(e,re),e+=4,d.set(te,e),e+=re,z+=4+re}if(O)X=Math.max(0,n*Math.round((H.pts-H.dts)/n));else{if(C<b-1)n=E[C+1].dts-H.dts;else{var $=this.config,Z=H.dts-E[C>0?C-1:C].dts;if($.stretchShortVideoTrack){var ie=$.maxBufferHole,q=Math.floor(ie*h),Q=(i?v+i*h:this.nextAudioPts)-H.pts;Q>q?(n=Q-Z,n<0&&(n=Z),f.logger.log("It is approximately "+Q/90+" ms to the next segment; using duration "+n/90+" ms for the last video frame.")):n=Z}else n=Z}X=Math.round(H.pts-H.dts)}S.push({size:z,duration:n,cts:X,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:H.key?2:1,isNonSync:H.key?0:1}})}this.nextAvcDts=x+n;var oe=a.dropped;if(a.len=0,a.nbNalu=0,a.dropped=0,S.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var ae=S[0].flags;ae.dependsOn=2,ae.isNonSync=0}a.samples=S,g=A.default.moof(a.sequenceNumber++,s,a),a.samples=[];var se={data1:g,data2:d,startPTS:v/h,endPTS:(l+n)/h,startDTS:s/h,endDTS:this.nextAvcDts/h,type:"video",hasAudio:!1,hasVideo:!0,nb:S.length,dropped:oe};return this.observer.trigger(m.default.FRAG_PARSING_DATA,se),se}},c.prototype.remuxAudio=function(a,o,r,i){var t=a.inputTimeScale,e=a.timescale,n=t/e,d=a.isAAC?1024:1152,g=d*n,v=this._PTSNormalize,s=this._initPTS,l=!a.isAAC&&this.typeSupported.mpeg,x,h,E,S,b,I,L,D=a.samples,O=[],F=this.nextAudioPts;if(r|=D.length&&F&&(i&&Math.abs(o-F/t)<.1||Math.abs(D[0].pts-F-s)<20*g),D.forEach(function(Q){Q.pts=Q.dts=v(Q.pts-s,o*t)}),D=D.filter(function(Q){return Q.pts>=0}),D.length!==0){if(r||(i?F=o*t:F=D[0].pts),a.isAAC)for(var C=this.config.maxAudioFramesDrift,P=0,k=F;P<D.length;){var B=D[P],M,N=B.pts;M=N-k;var j=Math.abs(1e3*M/t);if(M<=-C*g)f.logger.warn("Dropping 1 audio frame @ "+(k/t).toFixed(3)+"s due to "+Math.round(j)+" ms overlap."),D.splice(P,1),a.len-=B.unit.length;else if(M>=C*g&&j<u&&k){var K=Math.round(M/g);f.logger.warn("Injecting "+K+" audio frame @ "+(k/t).toFixed(3)+"s due to "+Math.round(1e3*M/t)+" ms gap.");for(var G=0;G<K;G++){var W=Math.max(k,0);E=_.default.getSilentFrame(a.manifestCodec||a.codec,a.channelCount),E||(f.logger.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),E=B.unit.subarray()),D.splice(P,0,{unit:E,pts:W,dts:W}),a.len+=E.length,k+=g,P++}B.pts=B.dts=k,k+=g,P++}else Math.abs(M)>.1*g,B.pts=B.dts=k,k+=g,P++}for(var G=0,U=D.length;G<U;G++){var V=D[G],H=V.unit,N=V.pts;if(L!==void 0)h.duration=Math.round((N-L)/n);else{var Y=Math.round(1e3*(N-F)/t),z=0;if(r&&a.isAAC&&Y){if(Y>0&&Y<u)z=Math.round((N-F)/g),f.logger.log(Y+" ms hole between AAC samples detected,filling it"),z>0&&(E=_.default.getSilentFrame(a.manifestCodec||a.codec,a.channelCount),E||(E=H.subarray()),a.len+=z*E.length);else if(Y<-12){f.logger.log("drop overlapping AAC sample, expected/parsed/delta:"+(F/t).toFixed(3)+"s/"+(N/t).toFixed(3)+"s/"+-Y+"ms"),a.len-=H.byteLength;continue}N=F}if(I=N,a.len>0){var X=l?a.len:a.len+8;x=l?0:8;try{S=new Uint8Array(X)}catch(ae){this.observer.trigger(m.default.ERROR,{type:y.ErrorTypes.MUX_ERROR,details:y.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:X,reason:"fail allocating audio mdat "+X});return}if(!l){var ee=new DataView(S.buffer);ee.setUint32(0,X),S.set(A.default.types.mdat,4)}}else return;for(var P=0;P<z;P++)E=_.default.getSilentFrame(a.manifestCodec||a.codec,a.channelCount),E||(f.logger.log("Unable to get silent frame for given audio codec; duplicating this frame instead."),E=H.subarray()),S.set(E,x),x+=E.byteLength,h={size:E.byteLength,cts:0,duration:1024,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},O.push(h)}S.set(H,x);var te=H.byteLength;x+=te,h={size:te,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},O.push(h),L=N}var re=0,$=O.length;if($>=2&&(re=O[$-2].duration,h.duration=re),$){this.nextAudioPts=F=L+n*re,a.len=0,a.samples=O,l?b=new Uint8Array:b=A.default.moof(a.sequenceNumber++,I/n,a),a.samples=[];var Z=I/t,ie=F/t,q={data1:b,data2:S,startPTS:Z,endPTS:ie,startDTS:Z,endDTS:ie,type:"audio",hasAudio:!0,hasVideo:!1,nb:$};return this.observer.trigger(m.default.FRAG_PARSING_DATA,q),q}return null}},c.prototype.remuxEmptyAudio=function(a,o,r,i){var t=a.inputTimeScale,e=a.samplerate?a.samplerate:t,n=t/e,d=this.nextAudioPts,g=(d!==void 0?d:i.startDTS*t)+this._initDTS,v=i.endDTS*t+this._initDTS,s=1024,l=n*s,x=Math.ceil((v-g)/l),h=_.default.getSilentFrame(a.manifestCodec||a.codec,a.channelCount);if(f.logger.warn("remux empty Audio"),!h){f.logger.trace("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!");return}for(var E=[],S=0;S<x;S++){var b=g+S*l;E.push({unit:h,pts:b,dts:b}),a.len+=h.length}a.samples=E,this.remuxAudio(a,o,r)},c.prototype.remuxID3=function(a){var o=a.samples.length,r,i=a.inputTimeScale,t=this._initPTS,e=this._initDTS;if(o){for(var n=0;n<o;n++)r=a.samples[n],r.pts=(r.pts-t)/i,r.dts=(r.dts-e)/i;this.observer.trigger(m.default.FRAG_PARSING_METADATA,{samples:a.samples})}a.samples=[]},c.prototype.remuxText=function(a){a.samples.sort(function(n,d){return n.pts-d.pts});var o=a.samples.length,r,i=a.inputTimeScale,t=this._initPTS;if(o){for(var e=0;e<o;e++)r=a.samples[e],r.pts=(r.pts-t)/i;this.observer.trigger(m.default.FRAG_PARSING_USERDATA,{samples:a.samples})}a.samples=[]},c.prototype._PTSNormalize=function(a,o){var r;if(o===void 0)return a;for(o<a?r=-8589934592:r=8589934592;Math.abs(a-o)>4294967296;)a+=r;return a},c}();R.default=p},"./src/remux/passthrough-remuxer.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/events.js"),A=function(){function m(y){this.observer=y}return m.prototype.destroy=function(){},m.prototype.resetTimeStamp=function(){},m.prototype.resetInitSegment=function(){},m.prototype.remux=function(y,f,u,p,c,a,o,r){var i=this.observer,t="";y&&(t+="audio"),f&&(t+="video"),i.trigger(_.default.FRAG_PARSING_DATA,{data1:r,startPTS:c,startDTS:c,type:t,hasAudio:!!y,hasVideo:!!f,nb:1,dropped:0}),i.trigger(_.default.FRAG_PARSED)},m}();R.default=A},"./src/task-loop.js":function(w,R,T){"use strict";var _=this&&this.__extends||function(){var y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,u){f.__proto__=u}||function(f,u){for(var p in u)u.hasOwnProperty(p)&&(f[p]=u[p])};return function(f,u){y(f,u);function p(){this.constructor=f}f.prototype=u===null?Object.create(u):(p.prototype=u.prototype,new p)}}();Object.defineProperty(R,"__esModule",{value:!0});var A=T("./src/event-handler.js"),m=function(y){_(f,y);function f(u){for(var p=[],c=1;c<arguments.length;c++)p[c-1]=arguments[c];var a=y.apply(this,[u].concat(p))||this;return a._tickInterval=null,a._tickTimer=null,a._tickCallCount=0,a._boundTick=a.tick.bind(a),a}return f.prototype.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},f.prototype.hasInterval=function(){return!!this._tickInterval},f.prototype.hasNextTick=function(){return!!this._tickTimer},f.prototype.setInterval=function(u){return this._tickInterval?!1:(this._tickInterval=setInterval(this._boundTick,u),!0)},f.prototype.clearInterval=function(){return this._tickInterval?(clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},f.prototype.clearNextTick=function(){return this._tickTimer?(clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},f.prototype.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&(this.clearNextTick(),this._tickTimer=setTimeout(this._boundTick,0)),this._tickCallCount=0)},f.prototype.doTick=function(){},f}(A.default);R.default=m},"./src/utils/attr-list.js":function(w,R,T){"use strict";(function(_){Object.defineProperty(R,"__esModule",{value:!0});var A=/^(\d+)x(\d+)$/,m=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,y=function(){function f(u){typeof u=="string"&&(u=f.parseAttrList(u));for(var p in u)u.hasOwnProperty(p)&&(this[p]=u[p])}return f.prototype.decimalInteger=function(u){var p=parseInt(this[u],10);return p>_.MAX_SAFE_INTEGER?Infinity:p},f.prototype.hexadecimalInteger=function(u){if(this[u]){var p=(this[u]||"0x").slice(2);p=(p.length&1?"0":"")+p;for(var c=new Uint8Array(p.length/2),a=0;a<p.length/2;a++)c[a]=parseInt(p.slice(a*2,a*2+2),16);return c}else return null},f.prototype.hexadecimalIntegerAsNumber=function(u){var p=parseInt(this[u],16);return p>_.MAX_SAFE_INTEGER?Infinity:p},f.prototype.decimalFloatingPoint=function(u){return parseFloat(this[u])},f.prototype.enumeratedString=function(u){return this[u]},f.prototype.decimalResolution=function(u){var p=A.exec(this[u]);if(p!==null)return{width:parseInt(p[1],10),height:parseInt(p[2],10)}},f.parseAttrList=function(u){var p,c={};for(m.lastIndex=0;(p=m.exec(u))!==null;){var a=p[2],o='"';a.indexOf(o)===0&&a.lastIndexOf(o)===a.length-1&&(a=a.slice(1,-1)),c[p[1]]=a}return c},f}();R.default=y}).call(this,T("./src/polyfills/number.js").Number)},"./src/utils/binary-search.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _={search:function(A,m){for(var y=0,f=A.length-1,u=null,p=null;y<=f;){u=(y+f)/2|0,p=A[u];var c=m(p);if(c>0)y=u+1;else if(c<0)f=u-1;else return p}return null}};R.default=_},"./src/utils/buffer-helper.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=function(){function A(){}return A.isBuffered=function(m,y){try{if(m){for(var f=m.buffered,u=0;u<f.length;u++)if(y>=f.start(u)&&y<=f.end(u))return!0}}catch(p){}return!1},A.bufferInfo=function(m,y,f){try{if(m){var u=m.buffered,p=[],c=void 0;for(c=0;c<u.length;c++)p.push({start:u.start(c),end:u.end(c)});return this.bufferedInfo(p,y,f)}}catch(a){}return{len:0,start:y,end:y,nextStart:void 0}},A.bufferedInfo=function(m,y,f){var u=[],p,c,a,o,r;for(m.sort(function(d,g){var v=d.start-g.start;return v||g.end-d.end}),r=0;r<m.length;r++){var i=u.length;if(i){var t=u[i-1].end;m[r].start-t<f?m[r].end>t&&(u[i-1].end=m[r].end):u.push(m[r])}else u.push(m[r])}for(r=0,p=0,c=a=y;r<u.length;r++){var e=u[r].start,n=u[r].end;if(y+f>=e&&y<n)c=e,a=n,p=a-y;else if(y+f<e){o=e;break}}return{len:p,start:c,end:a,nextStart:o}},A}();R.BufferHelper=_},"./src/utils/cea-608-parser.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},A=function(v){var s=v;return _.hasOwnProperty(v)&&(s=_[v]),String.fromCharCode(s)},m=15,y=100,f={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},u={17:2,18:4,21:6,22:8,23:10,19:13,20:15},p={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},c={25:2,26:4,29:6,30:8,31:10,27:13,28:15},a=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],o={verboseFilter:{DATA:3,DEBUG:3,INFO:2,WARNING:2,TEXT:1,ERROR:0},time:null,verboseLevel:0,setTime:function(v){this.time=v},log:function(v,s){var l=this.verboseFilter[v];this.verboseLevel>=l}},r=function(v){for(var s=[],l=0;l<v.length;l++)s.push(v[l].toString(16));return s},i=function(){function v(s,l,x,h,E){this.foreground=s||"white",this.underline=l||!1,this.italics=x||!1,this.background=h||"black",this.flash=E||!1}return v.prototype.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},v.prototype.setStyles=function(s){for(var l=["foreground","underline","italics","background","flash"],x=0;x<l.length;x++){var h=l[x];s.hasOwnProperty(h)&&(this[h]=s[h])}},v.prototype.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},v.prototype.equals=function(s){return this.foreground===s.foreground&&this.underline===s.underline&&this.italics===s.italics&&this.background===s.background&&this.flash===s.flash},v.prototype.copy=function(s){this.foreground=s.foreground,this.underline=s.underline,this.italics=s.italics,this.background=s.background,this.flash=s.flash},v.prototype.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},v}(),t=function(){function v(s,l,x,h,E,S){this.uchar=s||" ",this.penState=new i(l,x,h,E,S)}return v.prototype.reset=function(){this.uchar=" ",this.penState.reset()},v.prototype.setChar=function(s,l){this.uchar=s,this.penState.copy(l)},v.prototype.setPenState=function(s){this.penState.copy(s)},v.prototype.equals=function(s){return this.uchar===s.uchar&&this.penState.equals(s.penState)},v.prototype.copy=function(s){this.uchar=s.uchar,this.penState.copy(s.penState)},v.prototype.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},v}(),e=function(){function v(){this.chars=[];for(var s=0;s<y;s++)this.chars.push(new t);this.pos=0,this.currPenState=new i}return v.prototype.equals=function(s){for(var l=!0,x=0;x<y;x++)if(!this.chars[x].equals(s.chars[x])){l=!1;break}return l},v.prototype.copy=function(s){for(var l=0;l<y;l++)this.chars[l].copy(s.chars[l])},v.prototype.isEmpty=function(){for(var s=!0,l=0;l<y;l++)if(!this.chars[l].isEmpty()){s=!1;break}return s},v.prototype.setCursor=function(s){this.pos!==s&&(this.pos=s),this.pos<0?(o.log("ERROR","Negative cursor position "+this.pos),this.pos=0):this.pos>y&&(o.log("ERROR","Too large cursor position "+this.pos),this.pos=y)},v.prototype.moveCursor=function(s){var l=this.pos+s;if(s>1)for(var x=this.pos+1;x<l+1;x++)this.chars[x].setPenState(this.currPenState);this.setCursor(l)},v.prototype.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},v.prototype.insertChar=function(s){s>=144&&this.backSpace();var l=A(s);if(this.pos>=y){o.log("ERROR","Cannot insert "+s.toString(16)+" ("+l+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(l,this.currPenState),this.moveCursor(1)},v.prototype.clearFromPos=function(s){var l;for(l=s;l<y;l++)this.chars[l].reset()},v.prototype.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},v.prototype.clearToEndOfRow=function(){this.clearFromPos(this.pos)},v.prototype.getTextString=function(){for(var s=[],l=!0,x=0;x<y;x++){var h=this.chars[x].uchar;h!==" "&&(l=!1),s.push(h)}return l?"":s.join("")},v.prototype.setPenStyles=function(s){this.currPenState.setStyles(s);var l=this.chars[this.pos];l.setPenState(this.currPenState)},v}(),n=function(){function v(){this.rows=[];for(var s=0;s<m;s++)this.rows.push(new e);this.currRow=m-1,this.nrRollUpRows=null,this.reset()}return v.prototype.reset=function(){for(var s=0;s<m;s++)this.rows[s].clear();this.currRow=m-1},v.prototype.equals=function(s){for(var l=!0,x=0;x<m;x++)if(!this.rows[x].equals(s.rows[x])){l=!1;break}return l},v.prototype.copy=function(s){for(var l=0;l<m;l++)this.rows[l].copy(s.rows[l])},v.prototype.isEmpty=function(){for(var s=!0,l=0;l<m;l++)if(!this.rows[l].isEmpty()){s=!1;break}return s},v.prototype.backSpace=function(){var s=this.rows[this.currRow];s.backSpace()},v.prototype.clearToEndOfRow=function(){var s=this.rows[this.currRow];s.clearToEndOfRow()},v.prototype.insertChar=function(s){var l=this.rows[this.currRow];l.insertChar(s)},v.prototype.setPen=function(s){var l=this.rows[this.currRow];l.setPenStyles(s)},v.prototype.moveCursor=function(s){var l=this.rows[this.currRow];l.moveCursor(s)},v.prototype.setCursor=function(s){o.log("INFO","setCursor: "+s);var l=this.rows[this.currRow];l.setCursor(s)},v.prototype.setPAC=function(s){o.log("INFO","pacData = "+JSON.stringify(s));var l=s.row-1;if(this.nrRollUpRows&&l<this.nrRollUpRows-1&&(l=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==l){for(var x=0;x<m;x++)this.rows[x].clear();var h=this.currRow+1-this.nrRollUpRows,E=this.lastOutputScreen;if(E){var S=E.rows[h].cueStartTime;if(S&&S<o.time)for(var x=0;x<this.nrRollUpRows;x++)this.rows[l-this.nrRollUpRows+x+1].copy(E.rows[h+x])}}this.currRow=l;var b=this.rows[this.currRow];if(s.indent!==null){var I=s.indent,L=Math.max(I-1,0);b.setCursor(s.indent),s.color=b.chars[L].penState.foreground}var D={foreground:s.color,underline:s.underline,italics:s.italics,background:"black",flash:!1};this.setPen(D)},v.prototype.setBkgData=function(s){o.log("INFO","bkgData = "+JSON.stringify(s)),this.backSpace(),this.setPen(s),this.insertChar(32)},v.prototype.setRollUpRows=function(s){this.nrRollUpRows=s},v.prototype.rollUp=function(){if(this.nrRollUpRows===null){o.log("DEBUG","roll_up but nrRollUpRows not set yet");return}o.log("TEXT",this.getDisplayText());var s=this.currRow+1-this.nrRollUpRows,l=this.rows.splice(s,1)[0];l.clear(),this.rows.splice(this.currRow,0,l),o.log("INFO","Rolling up")},v.prototype.getDisplayText=function(s){s=s||!1;for(var l=[],x="",h=-1,E=0;E<m;E++){var S=this.rows[E].getTextString();S&&(h=E+1,s?l.push("Row "+h+": '"+S+"'"):l.push(S.trim()))}return l.length>0&&(s?x="["+l.join(" | ")+"]":x=l.join(`
|
|
`)),x},v.prototype.getTextAndFormat=function(){return this.rows},v}(),d=function(){function v(s,l){this.chNr=s,this.outputFilter=l,this.mode=null,this.verbose=0,this.displayedMemory=new n,this.nonDisplayedMemory=new n,this.lastOutputScreen=new n,this.currRollUpRow=this.displayedMemory.rows[m-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}return v.prototype.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.currRollUpRow=this.displayedMemory.rows[m-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.lastCueEndTime=null},v.prototype.getHandler=function(){return this.outputFilter},v.prototype.setHandler=function(s){this.outputFilter=s},v.prototype.setPAC=function(s){this.writeScreen.setPAC(s)},v.prototype.setBkgData=function(s){this.writeScreen.setBkgData(s)},v.prototype.setMode=function(s){s!==this.mode&&(this.mode=s,o.log("INFO","MODE="+s),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=s)},v.prototype.insertChars=function(s){for(var l=0;l<s.length;l++)this.writeScreen.insertChar(s[l]);var x=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";o.log("INFO",x+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(o.log("TEXT","DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},v.prototype.ccRCL=function(){o.log("INFO","RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},v.prototype.ccBS=function(){o.log("INFO","BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},v.prototype.ccAOF=function(){},v.prototype.ccAON=function(){},v.prototype.ccDER=function(){o.log("INFO","DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},v.prototype.ccRU=function(s){o.log("INFO","RU("+s+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(s)},v.prototype.ccFON=function(){o.log("INFO","FON - Flash On"),this.writeScreen.setPen({flash:!0})},v.prototype.ccRDC=function(){o.log("INFO","RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},v.prototype.ccTR=function(){o.log("INFO","TR"),this.setMode("MODE_TEXT")},v.prototype.ccRTD=function(){o.log("INFO","RTD"),this.setMode("MODE_TEXT")},v.prototype.ccEDM=function(){o.log("INFO","EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},v.prototype.ccCR=function(){o.log("CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},v.prototype.ccENM=function(){o.log("INFO","ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},v.prototype.ccEOC=function(){if(o.log("INFO","EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var s=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=s,this.writeScreen=this.nonDisplayedMemory,o.log("TEXT","DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},v.prototype.ccTO=function(s){o.log("INFO","TO("+s+") - Tab Offset"),this.writeScreen.moveCursor(s)},v.prototype.ccMIDROW=function(s){var l={flash:!1};if(l.underline=s%2==1,l.italics=s>=46,l.italics)l.foreground="white";else{var x=Math.floor(s/2)-16,h=["white","green","blue","cyan","red","yellow","magenta"];l.foreground=h[x]}o.log("INFO","MIDROW: "+JSON.stringify(l)),this.writeScreen.setPen(l)},v.prototype.outputDataUpdate=function(s){s===void 0&&(s=!1);var l=o.time;l!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=l:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue&&(this.outputFilter.newCue(this.cueStartTime,l,this.lastOutputScreen),s===!0&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue()),this.cueStartTime=this.displayedMemory.isEmpty()?null:l),this.lastOutputScreen.copy(this.displayedMemory))},v.prototype.cueSplitAtTime=function(s){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,s,this.displayedMemory),this.cueStartTime=s))},v}(),g=function(){function v(s,l,x){this.field=s||1,this.outputs=[l,x],this.channels=[new d(1,l),new d(2,x)],this.currChNr=-1,this.lastCmdA=null,this.lastCmdB=null,this.bufferedData=[],this.startTime=null,this.lastTime=null,this.dataCounters={padding:0,char:0,cmd:0,other:0}}return v.prototype.getHandler=function(s){return this.channels[s].getHandler()},v.prototype.setHandler=function(s,l){this.channels[s].setHandler(l)},v.prototype.addData=function(s,l){var x,h,E,S=!1;this.lastTime=s,o.setTime(s);for(var b=0;b<l.length;b+=2){if(h=l[b]&127,E=l[b+1]&127,h===0&&E===0){this.dataCounters.padding+=2;continue}else o.log("DATA","["+r([l[b],l[b+1]])+"] -> ("+r([h,E])+")");if(x=this.parseCmd(h,E),x||(x=this.parseMidrow(h,E)),x||(x=this.parsePAC(h,E)),x||(x=this.parseBackgroundAttributes(h,E)),!x&&(S=this.parseChars(h,E),S))if(this.currChNr&&this.currChNr>=0){var I=this.channels[this.currChNr-1];I.insertChars(S)}else o.log("WARNING","No channel found yet. TEXT-MODE?");x?this.dataCounters.cmd+=2:S?this.dataCounters.char+=2:(this.dataCounters.other+=2,o.log("WARNING","Couldn't parse cleaned data "+r([h,E])+" orig: "+r([l[b],l[b+1]])))}},v.prototype.parseCmd=function(s,l){var x=null,h=(s===20||s===28)&&l>=32&&l<=47,E=(s===23||s===31)&&l>=33&&l<=35;if(!(h||E))return!1;if(s===this.lastCmdA&&l===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,o.log("DEBUG","Repeated command ("+r([s,l])+") is dropped"),!0;s===20||s===23?x=1:x=2;var S=this.channels[x-1];return s===20||s===28?l===32?S.ccRCL():l===33?S.ccBS():l===34?S.ccAOF():l===35?S.ccAON():l===36?S.ccDER():l===37?S.ccRU(2):l===38?S.ccRU(3):l===39?S.ccRU(4):l===40?S.ccFON():l===41?S.ccRDC():l===42?S.ccTR():l===43?S.ccRTD():l===44?S.ccEDM():l===45?S.ccCR():l===46?S.ccENM():l===47&&S.ccEOC():S.ccTO(l-32),this.lastCmdA=s,this.lastCmdB=l,this.currChNr=x,!0},v.prototype.parseMidrow=function(s,l){var x=null;if((s===17||s===25)&&l>=32&&l<=47){if(s===17?x=1:x=2,x!==this.currChNr)return o.log("ERROR","Mismatch channel in midrow parsing"),!1;var h=this.channels[x-1];return h.ccMIDROW(l),o.log("DEBUG","MIDROW ("+r([s,l])+")"),!0}return!1},v.prototype.parsePAC=function(s,l){var x=null,h=null,E=(s>=17&&s<=23||s>=25&&s<=31)&&l>=64&&l<=127,S=(s===16||s===24)&&l>=64&&l<=95;if(!(E||S))return!1;if(s===this.lastCmdA&&l===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,!0;x=s<=23?1:2,l>=64&&l<=95?h=x===1?f[s]:p[s]:h=x===1?u[s]:c[s];var b=this.interpretPAC(h,l),I=this.channels[x-1];return I.setPAC(b),this.lastCmdA=s,this.lastCmdB=l,this.currChNr=x,!0},v.prototype.interpretPAC=function(s,l){var x=l,h={color:null,italics:!1,indent:null,underline:!1,row:s};return l>95?x=l-96:x=l-64,h.underline=(x&1)==1,x<=13?h.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(x/2)]:x<=15?(h.italics=!0,h.color="white"):h.indent=Math.floor((x-16)/2)*4,h},v.prototype.parseChars=function(s,l){var x=null,h=null,E=null;if(s>=25?(x=2,E=s-8):(x=1,E=s),E>=17&&E<=19){var S=l;E===17?S=l+80:E===18?S=l+112:S=l+144,o.log("INFO","Special char '"+A(S)+"' in channel "+x),h=[S]}else s>=32&&s<=127&&(h=l===0?[s]:[s,l]);if(h){var b=r(h);o.log("DEBUG","Char codes = "+b.join(",")),this.lastCmdA=null,this.lastCmdB=null}return h},v.prototype.parseBackgroundAttributes=function(s,l){var x,h,E,S,b=(s===16||s===24)&&l>=32&&l<=47,I=(s===23||s===31)&&l>=45&&l<=47;return b||I?(x={},s===16||s===24?(h=Math.floor((l-32)/2),x.background=a[h],l%2==1&&(x.background=x.background+"_semi")):l===45?x.background="transparent":(x.foreground="black",l===47&&(x.underline=!0)),E=s<24?1:2,S=this.channels[E-1],S.setBkgData(x),this.lastCmdA=null,this.lastCmdB=null,!0):!1},v.prototype.reset=function(){for(var s=0;s<this.channels.length;s++)this.channels[s]&&this.channels[s].reset();this.lastCmdA=null,this.lastCmdB=null},v.prototype.cueSplitAtTime=function(s){for(var l=0;l<this.channels.length;l++)this.channels[l]&&this.channels[l].cueSplitAtTime(s)},v}();R.default=g},"./src/utils/codecs.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0}};function A(y,f){var u=_[f];return!!u&&u[y.slice(0,4)]===!0}R.isCodecType=A;function m(y,f){return window.MediaSource.isTypeSupported((f||"video")+'/mp4;codecs="'+y+'"')}R.isCodecSupportedInMp4=m},"./src/utils/cues.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/utils/vttparser.js");function A(m,y,f,u){for(var p,c,a,o,r,i=window.VTTCue||window.TextTrackCue,t=0;t<u.rows.length;t++)if(p=u.rows[t],a=!0,o=0,r="",!p.isEmpty()){for(var e=0;e<p.chars.length;e++)p.chars[e].uchar.match(/\s/)&&a?o++:(r+=p.chars[e].uchar,a=!1);p.cueStartTime=y,y===f&&(f+=1e-4),c=new i(y,f,_.fixLineBreaks(r.trim())),o>=16?o--:o++,navigator.userAgent.match(/Firefox\//)?c.line=t+1:c.line=t>7?t-2:t+1,c.align="left",c.position=Math.max(0,Math.min(100,100*(o/32)+(navigator.userAgent.match(/Firefox\//)?50:0))),m.addCue(c)}}R.newCue=A},"./src/utils/discontinuities.js":function(w,R,T){"use strict";(function(_){Object.defineProperty(R,"__esModule",{value:!0});var A=T("./src/utils/binary-search.js"),m=T("./src/utils/logger.js");function y(i,t){for(var e=null,n=0;n<i.length;n+=1){var d=i[n];if(d&&d.cc===t){e=d;break}}return e}R.findFirstFragWithCC=y;function f(i,t){return A.default.search(i,function(e){return e.cc<t?1:e.cc>t?-1:0})}R.findFragWithCC=f;function u(i,t,e){var n=!1;return t&&t.details&&e&&(e.endCC>e.startCC||i&&i.cc<e.startCC)&&(n=!0),n}R.shouldAlignOnDiscontinuities=u;function p(i,t){var e=i.fragments,n=t.fragments;if(!n.length||!e.length){m.logger.log("No fragments to align");return}var d=y(e,n[0].cc);if(!d||d&&!d.startPTS){m.logger.log("No frag in previous level to align on");return}return d}R.findDiscontinuousReferenceFrag=p;function c(i,t){t.fragments.forEach(function(e){if(e){var n=e.start+i;e.start=e.startPTS=n,e.endPTS=n+e.duration}}),t.PTSKnown=!0}R.adjustPts=c;function a(i,t,e){o(i,e,t),!e.PTSKnown&&t&&r(e,t.details)}R.alignStream=a;function o(i,t,e){if(u(i,e,t)){var n=p(e.details,t);n&&(m.logger.log("Adjusting PTS using last level due to CC increase within current level"),c(n.start,t))}}R.alignDiscontinuities=o;function r(i,t){if(t&&t.fragments.length){if(!i.hasProgramDateTime||!t.hasProgramDateTime)return;var e=t.fragments[0].programDateTime,n=i.fragments[0].programDateTime,d=(n-e)/1e3+t.fragments[0].start;_.isFinite(d)&&(m.logger.log("adjusting PTS using programDateTime delta, sliding:"+d.toFixed(3)),c(d,i))}}R.alignPDT=r}).call(this,T("./src/polyfills/number.js").Number)},"./src/utils/ewma-bandwidth-estimator.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/utils/ewma.js"),A=function(){function m(y,f,u,p){this.hls=y,this.defaultEstimate_=p,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new _.default(f),this.fast_=new _.default(u)}return m.prototype.sample=function(y,f){y=Math.max(y,this.minDelayMs_);var u=8e3*f/y,p=y/1e3;this.fast_.sample(p,u),this.slow_.sample(p,u)},m.prototype.canEstimate=function(){var y=this.fast_;return y&&y.getTotalWeight()>=this.minWeight_},m.prototype.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},m.prototype.destroy=function(){},m}();R.default=A},"./src/utils/ewma.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=function(){function A(m){this.alpha_=m?Math.exp(Math.log(.5)/m):0,this.estimate_=0,this.totalWeight_=0}return A.prototype.sample=function(m,y){var f=Math.pow(this.alpha_,m);this.estimate_=y*(1-f)+f*this.estimate_,this.totalWeight_+=m},A.prototype.getTotalWeight=function(){return this.totalWeight_},A.prototype.getEstimate=function(){if(this.alpha_){var m=1-Math.pow(this.alpha_,this.totalWeight_);return this.estimate_/m}else return this.estimate_},A}();R.default=_},"./src/utils/get-self-scope.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});function _(){return typeof window=="undefined"?self:window}R.getSelfScope=_},"./src/utils/logger.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/utils/get-self-scope.js");function A(){}var m={trace:A,debug:A,log:A,warn:A,info:A,error:A},y=m;function f(a,o){return o="["+a+"] > "+o,o}var u=_.getSelfScope();function p(a){var o=u.console[a];return o?function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];r[0]&&(r[0]=f(a,r[0])),o.apply(u.console,r)}:A}function c(a){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];o.forEach(function(i){y[i]=a[i]?a[i].bind(a):p(i)})}R.enableLogs=function(a){if(a===!0||typeof a=="object"){c(a,"debug","log","info","warn","error");try{y.log()}catch(o){y=m}}else y=m},R.logger=y},"./src/utils/mediakeys-helper.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=function(){return typeof window!="undefined"&&window.navigator&&window.navigator.requestMediaKeySystemAccess?window.navigator.requestMediaKeySystemAccess.bind(window.navigator):null}();R.requestMediaKeySystemAccess=_},"./src/utils/mediasource-helper.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});function _(){if(typeof window!="undefined")return window.MediaSource||window.WebKitMediaSource}R.getMediaSource=_},"./src/utils/output-filter.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=function(){function A(m,y){this.timelineController=m,this.trackName=y,this.startTime=null,this.endTime=null,this.screen=null}return A.prototype.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen),this.startTime=null)},A.prototype.newCue=function(m,y,f){(this.startTime===null||this.startTime>m)&&(this.startTime=m),this.endTime=y,this.screen=f,this.timelineController.createCaptionsTrack(this.trackName)},A}();R.default=_},"./src/utils/texttrack-utils.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});function _(m,y){var f=null;try{f=new window.Event("addtrack")}catch(u){f=document.createEvent("Event"),f.initEvent("addtrack",!1,!1)}f.track=m,y.dispatchEvent(f)}R.sendAddTrackEvent=_;function A(m){if(m&&m.cues)for(;m.cues.length>0;)m.removeCue(m.cues[0])}R.clearCurrentCues=A},"./src/utils/time-ranges.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _={toString:function(A){for(var m="",y=A.length,f=0;f<y;f++)m+="["+A.start(f).toFixed(3)+","+A.end(f).toFixed(3)+"]";return m}};R.default=_},"./src/utils/vttcue.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0}),R.default=function(){if(typeof window!="undefined"&&window.VTTCue)return window.VTTCue;var _="auto",A={"":!0,lr:!0,rl:!0},m={start:!0,middle:!0,end:!0,left:!0,right:!0};function y(c){if(typeof c!="string")return!1;var a=A[c.toLowerCase()];return a?c.toLowerCase():!1}function f(c){if(typeof c!="string")return!1;var a=m[c.toLowerCase()];return a?c.toLowerCase():!1}function u(c){for(var a=1;a<arguments.length;a++){var o=arguments[a];for(var r in o)c[r]=o[r]}return c}function p(c,a,o){var r=this,i=function(){if(typeof navigator!="undefined")return/MSIE\s8\.0/.test(navigator.userAgent)}(),t={};i?r=document.createElement("custom"):t.enumerable=!0,r.hasBeenReset=!1;var e="",n=!1,d=c,g=a,v=o,s=null,l="",x=!0,h="auto",E="start",S=50,b="middle",I=50,L="middle";if(Object.defineProperty(r,"id",u({},t,{get:function(){return e},set:function(D){e=""+D}})),Object.defineProperty(r,"pauseOnExit",u({},t,{get:function(){return n},set:function(D){n=!!D}})),Object.defineProperty(r,"startTime",u({},t,{get:function(){return d},set:function(D){if(typeof D!="number")throw new TypeError("Start time must be set to a number.");d=D,this.hasBeenReset=!0}})),Object.defineProperty(r,"endTime",u({},t,{get:function(){return g},set:function(D){if(typeof D!="number")throw new TypeError("End time must be set to a number.");g=D,this.hasBeenReset=!0}})),Object.defineProperty(r,"text",u({},t,{get:function(){return v},set:function(D){v=""+D,this.hasBeenReset=!0}})),Object.defineProperty(r,"region",u({},t,{get:function(){return s},set:function(D){s=D,this.hasBeenReset=!0}})),Object.defineProperty(r,"vertical",u({},t,{get:function(){return l},set:function(D){var O=y(D);if(O===!1)throw new SyntaxError("An invalid or illegal string was specified.");l=O,this.hasBeenReset=!0}})),Object.defineProperty(r,"snapToLines",u({},t,{get:function(){return x},set:function(D){x=!!D,this.hasBeenReset=!0}})),Object.defineProperty(r,"line",u({},t,{get:function(){return h},set:function(D){if(typeof D!="number"&&D!==_)throw new SyntaxError("An invalid number or illegal string was specified.");h=D,this.hasBeenReset=!0}})),Object.defineProperty(r,"lineAlign",u({},t,{get:function(){return E},set:function(D){var O=f(D);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");E=O,this.hasBeenReset=!0}})),Object.defineProperty(r,"position",u({},t,{get:function(){return S},set:function(D){if(D<0||D>100)throw new Error("Position must be between 0 and 100.");S=D,this.hasBeenReset=!0}})),Object.defineProperty(r,"positionAlign",u({},t,{get:function(){return b},set:function(D){var O=f(D);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");b=O,this.hasBeenReset=!0}})),Object.defineProperty(r,"size",u({},t,{get:function(){return I},set:function(D){if(D<0||D>100)throw new Error("Size must be between 0 and 100.");I=D,this.hasBeenReset=!0}})),Object.defineProperty(r,"align",u({},t,{get:function(){return L},set:function(D){var O=f(D);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");L=O,this.hasBeenReset=!0}})),r.displayState=void 0,i)return r}return p.prototype.getCueAsHTML=function(){var c=window.WebVTT;return c.convertCueToDOMTree(window,this.text)},p}()},"./src/utils/vttparser.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/utils/vttcue.js"),A=function(){return{decode:function(i){if(!i)return"";if(typeof i!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(i))}}};function m(){this.window=window,this.state="INITIAL",this.buffer="",this.decoder=new A,this.regionList=[]}function y(r){function i(e,n,d,g){return(e|0)*3600+(n|0)*60+(d|0)+(g|0)/1e3}var t=r.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return t?t[3]?i(t[1],t[2],t[3].replace(":",""),t[4]):t[1]>59?i(t[1],t[2],0,t[4]):i(0,t[1],t[2],t[4]):null}function f(){this.values=Object.create(null)}f.prototype={set:function(r,i){!this.get(r)&&i!==""&&(this.values[r]=i)},get:function(r,i,t){return t?this.has(r)?this.values[r]:i[t]:this.has(r)?this.values[r]:i},has:function(r){return r in this.values},alt:function(r,i,t){for(var e=0;e<t.length;++e)if(i===t[e]){this.set(r,i);break}},integer:function(r,i){/^-?\d+$/.test(i)&&this.set(r,parseInt(i,10))},percent:function(r,i){var t;return(t=i.match(/^([\d]{1,3})(\.[\d]*)?%$/))&&(i=parseFloat(i),i>=0&&i<=100)?(this.set(r,i),!0):!1}};function u(r,i,t,e){var n=e?r.split(e):[r];for(var d in n)if(typeof n[d]=="string"){var g=n[d].split(t);if(g.length===2){var v=g[0],s=g[1];i(v,s)}}}var p=new _.default(0,0,0),c=p.align==="middle"?"middle":"center";function a(r,i,t){var e=r;function n(){var v=y(r);if(v===null)throw new Error("Malformed timestamp: "+e);return r=r.replace(/^[^\sa-zA-Z-]+/,""),v}function d(v,s){var l=new f;u(v,function(E,S){switch(E){case"region":for(var b=t.length-1;b>=0;b--)if(t[b].id===S){l.set(E,t[b].region);break}break;case"vertical":l.alt(E,S,["rl","lr"]);break;case"line":var I=S.split(","),L=I[0];l.integer(E,L),l.percent(E,L)&&l.set("snapToLines",!1),l.alt(E,L,["auto"]),I.length===2&&l.alt("lineAlign",I[1],["start",c,"end"]);break;case"position":I=S.split(","),l.percent(E,I[0]),I.length===2&&l.alt("positionAlign",I[1],["start",c,"end","line-left","line-right","auto"]);break;case"size":l.percent(E,S);break;case"align":l.alt(E,S,["start",c,"end","left","right"]);break}},/:/,/\s/),s.region=l.get("region",null),s.vertical=l.get("vertical","");var x=l.get("line","auto");x==="auto"&&p.line===-1&&(x=-1),s.line=x,s.lineAlign=l.get("lineAlign","start"),s.snapToLines=l.get("snapToLines",!0),s.size=l.get("size",100),s.align=l.get("align",c);var h=l.get("position","auto");h==="auto"&&p.position===50&&(h=s.align==="start"||s.align==="left"?0:s.align==="end"||s.align==="right"?100:50),s.position=h}function g(){r=r.replace(/^\s+/,"")}if(g(),i.startTime=n(),g(),r.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+e);r=r.substr(3),g(),i.endTime=n(),g(),d(r,i)}function o(r){return r.replace(/<br(?: \/)?>/gi,`
|
|
`)}R.fixLineBreaks=o,m.prototype={parse:function(r){var i=this;r&&(i.buffer+=i.decoder.decode(r,{stream:!0}));function t(){var s=i.buffer,l=0;for(s=o(s);l<s.length&&s[l]!=="\r"&&s[l]!==`
|
|
`;)++l;var x=s.substr(0,l);return s[l]==="\r"&&++l,s[l]===`
|
|
`&&++l,i.buffer=s.substr(l),x}function e(s){u(s,function(l,x){switch(l){case"Region":break}},/:/)}try{var n=void 0;if(i.state==="INITIAL"){if(!/\r\n|\n/.test(i.buffer))return this;n=t();var d=n.match(/^()?WEBVTT([ \t].*)?$/);if(!d||!d[0])throw new Error("Malformed WebVTT signature.");i.state="HEADER"}for(var g=!1;i.buffer;){if(!/\r\n|\n/.test(i.buffer))return this;switch(g?g=!1:n=t(),i.state){case"HEADER":/:/.test(n)?e(n):n||(i.state="ID");continue;case"NOTE":n||(i.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){i.state="NOTE";break}if(!n)continue;if(i.cue=new _.default(0,0,""),i.state="CUE",n.indexOf("-->")===-1){i.cue.id=n;continue}case"CUE":try{a(n,i.cue,i.regionList)}catch(s){i.cue=null,i.state="BADCUE";continue}i.state="CUETEXT";continue;case"CUETEXT":var v=n.indexOf("-->")!==-1;if(!n||v&&(g=!0)){i.oncue&&i.oncue(i.cue),i.cue=null,i.state="ID";continue}i.cue.text&&(i.cue.text+=`
|
|
`),i.cue.text+=n;continue;case"BADCUE":n||(i.state="ID");continue}}}catch(s){i.state==="CUETEXT"&&i.cue&&i.oncue&&i.oncue(i.cue),i.cue=null,i.state=i.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},flush:function(){var r=this;try{if(r.buffer+=r.decoder.decode(),(r.cue||r.state==="HEADER")&&(r.buffer+=`
|
|
|
|
`,r.parse()),r.state==="INITIAL")throw new Error("Malformed WebVTT signature.")}catch(i){throw i}return r.onflush&&r.onflush(),this}},R.default=m},"./src/utils/webvtt-parser.js":function(w,R,T){"use strict";(function(_){Object.defineProperty(R,"__esModule",{value:!0});var A=T("./src/utils/vttparser.js"),m=T("./src/demux/id3.js"),y=function(a,o,r){return a.substr(r||0,o.length)===o},f=function(a){var o=parseInt(a.substr(-3)),r=parseInt(a.substr(-6,2)),i=parseInt(a.substr(-9,2)),t=a.length>9?parseInt(a.substr(0,a.indexOf(":"))):0;return!_.isFinite(o)||!_.isFinite(r)||!_.isFinite(i)||!_.isFinite(t)?-1:(o+=1e3*r,o+=60*1e3*i,o+=60*60*1e3*t,o)},u=function(a){for(var o=5381,r=a.length;r;)o=o*33^a.charCodeAt(--r);return(o>>>0).toString()},p=function(a,o,r){var i=a[o],t=a[i.prevCC];if(!t||!t.new&&i.new){a.ccOffset=a.presentationOffset=i.start,i.new=!1;return}for(;t&&t.new;)a.ccOffset+=i.start-t.start,i.new=!1,i=t,t=a[i.prevCC];a.presentationOffset=r},c={parse:function(a,o,r,i,t,e){var n=/\r\n|\n\r|\n|\r/g,d=m.utf8ArrayToStr(new Uint8Array(a)).trim().replace(n,`
|
|
`).split(`
|
|
`),g="00:00.000",v=0,s=0,l=0,x=[],h,E=!0,S=new A.default;S.oncue=function(b){var I=r[i],L=r.ccOffset;I&&I.new&&(s!==void 0?L=r.ccOffset=I.start:p(r,i,l)),l&&(L=l-r.presentationOffset),b.startTime+=L-s,b.endTime+=L-s,b.id=u(b.startTime.toString())+u(b.endTime.toString())+u(b.text),b.text=decodeURIComponent(encodeURIComponent(b.text)),b.endTime>0&&x.push(b)},S.onparsingerror=function(b){h=b},S.onflush=function(){if(h&&e){e(h);return}t(x)},d.forEach(function(b){if(E)if(y(b,"X-TIMESTAMP-MAP=")){E=!1,b.substr(16).split(",").forEach(function(I){y(I,"LOCAL:")?g=I.substr(6):y(I,"MPEGTS:")&&(v=parseInt(I.substr(7)))});try{o+(r[i].start*9e4||0)<0&&(o+=8589934592),v-=o,s=f(g)/1e3,l=v/9e4,s===-1&&(h=new Error("Malformed X-TIMESTAMP-MAP: "+b))}catch(I){h=new Error("Malformed X-TIMESTAMP-MAP: "+b)}return}else b===""&&(E=!1);S.parse(b+`
|
|
`)}),S.flush()}};R.default=c}).call(this,T("./src/polyfills/number.js").Number)},"./src/utils/xhr-loader.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/utils/logger.js"),A=window.performance,m=window.XMLHttpRequest,y=function(){function f(u){u&&u.xhrSetup&&(this.xhrSetup=u.xhrSetup)}return f.prototype.destroy=function(){this.abort(),this.loader=null},f.prototype.abort=function(){var u=this.loader;u&&u.readyState!==4&&(this.stats.aborted=!0,u.abort()),window.clearTimeout(this.requestTimeout),this.requestTimeout=null,window.clearTimeout(this.retryTimeout),this.retryTimeout=null},f.prototype.load=function(u,p,c){this.context=u,this.config=p,this.callbacks=c,this.stats={trequest:A.now(),retry:0},this.retryDelay=p.retryDelay,this.loadInternal()},f.prototype.loadInternal=function(){var u,p=this.context;u=this.loader=new m;var c=this.stats;c.tfirst=0,c.loaded=0;var a=this.xhrSetup;try{if(a)try{a(u,p.url)}catch(o){u.open("GET",p.url,!0),a(u,p.url)}u.readyState||u.open("GET",p.url,!0)}catch(o){this.callbacks.onError({code:u.status,text:o.message},p,u);return}p.rangeEnd&&u.setRequestHeader("Range","bytes="+p.rangeStart+"-"+(p.rangeEnd-1)),u.onreadystatechange=this.readystatechange.bind(this),u.onprogress=this.loadprogress.bind(this),u.responseType=p.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),u.send()},f.prototype.readystatechange=function(u){var p=u.currentTarget,c=p.readyState,a=this.stats,o=this.context,r=this.config;if(!a.aborted&&c>=2)if(window.clearTimeout(this.requestTimeout),a.tfirst===0&&(a.tfirst=Math.max(A.now(),a.trequest)),c===4){var i=p.status;if(i>=200&&i<300){a.tload=Math.max(a.tfirst,A.now());var t=void 0,e=void 0;o.responseType==="arraybuffer"?(t=p.response,e=t.byteLength):(t=p.responseText,e=t.length),a.loaded=a.total=e;var n={url:p.responseURL,data:t};this.callbacks.onSuccess(n,a,o,p)}else a.retry>=r.maxRetry||i>=400&&i<499?(_.logger.error(i+" while loading "+o.url),this.callbacks.onError({code:i,text:p.statusText},o,p)):(_.logger.warn(i+" while loading "+o.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,r.maxRetryDelay),a.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),r.timeout)},f.prototype.loadtimeout=function(){_.logger.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)},f.prototype.loadprogress=function(u){var p=u.currentTarget,c=this.stats;c.loaded=u.loaded,u.lengthComputable&&(c.total=u.total);var a=this.callbacks.onProgress;a&&a(c,this.context,null,p)},f}();R.default=y}}).default});
|