CyTube/www/js/vjs/videojs-hlsjs-plugin.js
2022-09-18 19:10:36 -07:00

9 lines
236 KiB
JavaScript

/**
* videojs-hlsjs-plugin
* v1.0.16
* 2022-01-30
* www.streamroot.io
* Copyright 2018
**/
!function(r){var i={};function a(e){if(i[e])return i[e].exports;var t=i[e]={i:e,l:!1,exports:{}};return r[e].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.m=r,a.c=i,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)a.d(r,i,function(e){return t[e]}.bind(null,i));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=0)}([function(e,t,r){"use strict";var r=r(1),r=(window.videojs&&(r.registerConfigPlugin(window.videojs),r.registerSourceHandler(window.videojs)),{register:r.registerSourceHandler}),i="hlsSourceHandler";window[i]||(window[i]=r)},function(e,t,r){"use strict";var C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I=r(2);function i(e){var t=this;e&&(t.srOptions_||(t.srOptions_={}),t.srOptions_.hlsjsConfig||(t.srOptions_.hlsjsConfig=e.hlsjsConfig),t.srOptions_.captionConfig||(t.srOptions_.captionConfig=e.captionConfig))}e.exports={registerSourceHandler:function(D){var e,O={};function r(f,a){a.name_="StreamrootHlsjs";var n,s=a.el(),i={},g=null,o=null,l=null,p=null,d=null,u=null,c=D(a.options_.playerId),h=c.qualityLevels&&c.qualityLevels(),m=(h&&c.hlsQualitySelector&&(a.hls={}),!1);function v(e){1===i[I.ErrorTypes.MEDIA_ERROR]?n.recoverMediaError():2===i[I.ErrorTypes.MEDIA_ERROR]?(n.swapAudioCodec(),n.recoverMediaError()):2<i[I.ErrorTypes.MEDIA_ERROR]&&(a.error=function(){return e},a.trigger("error"))}function t(e){n.nextLevel=e}function y(e,t){if(h){if("boolean"==typeof t){h[e]._enabled=t;for(var r=!0,i=0;i<h.length;i++)if(!h[i]._enabled){r=!1;break}if(r)n.currentLevel=-1;else{for(var a=h.length-1;0<=a&&!h[a]._enabled;a--);n.currentLevel=a}}return h[e]._enabled}return!1}function E(e,t){h&&(h.selectedIndex_=t.level,h.trigger({selectedIndex:t.level,type:"change"}))}function T(){var i,e;o&&(i=[],1<o.levels.length&&(e={id:-1,label:"auto",selected:-1===n.manualLevel},i.push(e)),o.levels.forEach(function(e,t){var r={};r.id=t,r.selected=t===n.manualLevel,r.label=(t=e).height?t.height+"p":t.width?Math.round(9*t.width/16)+"p":t.bitrate?t.bitrate/1e3+"kbps":0,i.push(r)}),a.trigger("loadedqualitydata",{qualityData:{video:i},qualitySwitchCallback:t}),s.removeEventListener("playing",T))}function b(){for(var e=a.audioTracks(),t=0;t<e.length;t++)if(e[t].enabled){n.audioTrack=t;break}}function S(){var e=n.audioTracks,t=a.audioTracks();if(1<e.length&&0===t.length){for(var r=0;r<e.length;r++)t.addTrack(new D.AudioTrack({id:r,kind:"alternative",label:e[r].name||e[r].lang,language:e[r].lang,enabled:r===n.audioTrack}));t.addEventListener("change",b)}}function _(e){return e.label||e.language}function R(e,t){return _(e)===_(t)&&e.kind===t.kind}function A(){for(var e=c.textTracks(),t=null,r=0;r<e.length;r++)if("showing"===e[r].mode){t=e[r];break}for(var i=s.textTracks,a=0;a<i.length;a++)"subtitles"!==i[a].kind&&"captions"!==i[a].kind||(i[a].mode=t&&R(i[a],t)?"showing":"disabled")}function k(){n.startLoad(-1),s.removeEventListener("play",k)}function L(){for(var e=function(e){for(var t=[],r=0;r<e.length;r++)"subtitles"!==e[r].kind&&"captions"!==e[r].kind||t.push(e[r]);return t}(s.textTracks),t=c.textTracks(),r=0;r<e.length;r++){for(var i,a=!1,n=0;n<t.length;n++)if(R(e[r],t[n])){a=!0;break}a||(i=e[r],c.addRemoteTextTrack({kind:i.kind,label:_(i),language:i.language,srclang:i.language},!1))}A(),m||(t.addEventListener("change",A),m=!0)}function w(e,t){o=t,function(){if(o&&(h=c.qualityLevels&&c.qualityLevels())){a.hls={};for(var e=0;e<o.levels.length;e++){var t=o.levels[e],r="hlsjs-"+e,r={id:r,label:r,width:t.width,height:t.height,bandwidth:t.bitrate,bitrate:t.bitrate,_enabled:!1};r.enabled=y.bind(this,e),h.addQualityLevel(r)}}}()}function e(){var h,e=c.srOptions_&&c.srOptions_.hlsjsConfig||a.options_.hlsjsConfig,e=(u=e?function(e){for(var t={},r=Object.keys(e),i=0;i<r.length;i++)t[r[i]]=e[r[i]];return t}(e):{},-1!==["","auto"].indexOf(s.preload)||s.autoplay||void 0!==u.autoStartLoad||(u.autoStartLoad=!1),c.srOptions_&&c.srOptions_.captionConfig||a.options_.captionConfig),t=(e&&(u.cueHandler=(h=e,{newCue:function(e,t,r,u){for(var i,a,n,c=window.VTTCue||window.TextTrackCue,s=0;s<u.rows.length;s++)if(n="",!(i=u.rows[s]).isEmpty()){for(var o=0;o<i.chars.length;o++)n+=i.chars[o].uchar;if(a=new c(t,r,n.trim()),null!=h&&"object"===(void 0===h?"undefined":C(h)))for(var l=Object.keys(h),d=0;d<l.length;d++)a[l[d]]=h[l[d]];e.addCue(a),r===t&&e.addCue(new c(r+5,""))}}})),!1===u.autoStartLoad&&s.addEventListener("play",k),s.addEventListener("playing",T),n=new I(u),"beforeinitialize");if(void 0!==O[t])for(var r=0;r<O[t].length;r++)O[t][r](c,n);n.on(I.Events.ERROR,function(e,t){var r={message:"HLS.js error: "+t.type+" - fatal: "+t.fatal+" - "+t.details};if(i[t.type]?i[t.type]+=1:i[t.type]=1,t.fatal)switch(t.type){case I.ErrorTypes.NETWORK_ERROR:r.code=2,a.error=function(){return r},a.trigger("error");break;case I.ErrorTypes.MEDIA_ERROR:r.code=3,v(r);break;default:n.destroy(),a.error=function(){return r},a.trigger("error")}}),n.on(I.Events.AUDIO_TRACKS_UPDATED,S),n.on(I.Events.MANIFEST_PARSED,w),n.on(I.Events.LEVEL_LOADED,function(e,t){u.liveSyncDuration?d=u.liveSyncDuration:u.liveSyncDurationCount&&(d=u.liveSyncDurationCount*t.details.targetduration),l=t.details.live,p=t.details.totalduration,g=l?1/0:t.details.totalduration}),n.once(I.Events.FRAG_LOADED,function(){a.trigger("loadedmetadata")}),n.on(I.Events.LEVEL_SWITCHED,E),n.attachMedia(s),s.textTracks.addEventListener("addtrack",L),n.loadSource(f.src)}this.duration=function(){return g||s.duration||0},this.seekable=function(){if(n.media){if(!l)return D.createTimeRanges(0,n.media.duration);var e=Math.round(n.media.duration-p),t=Math.round(n.media.duration-d);return D.createTimeRanges(e,t)}return D.createTimeRanges()},this.dispose=function(){s.removeEventListener("play",k),s.textTracks.removeEventListener("addtrack",L),s.removeEventListener("playing",T),c.textTracks().removeEventListener("change",A),m=!1,c.audioTracks().removeEventListener("change",b),n.destroy()},s.addEventListener("error",function(e){var t=e.currentTarget.error;switch(t.code){case t.MEDIA_ERR_ABORTED:0;break;case t.MEDIA_ERR_DECODE:v(t);break;case t.MEDIA_ERR_NETWORK:0;break;case t.MEDIA_ERR_SRC_NOT_SUPPORTED:0;break;default:t.message}}),e()}if(r.addHook=function(e,t){O[e]=O[e]||[],O[e].push(t)},r.removeHook=function(e,t){if(void 0===O[e])return!1;t=O[e].indexOf(t);return-1!==t&&(O[e].splice(t,1),!0)},I.isSupported()){if("function"==typeof D.getTech)e=D.getTech("Html5");else{if("function"!=typeof D.getComponent)return;e=D.getComponent("Html5")}e&&(e.registerSourceHandler({canHandleSource:function(e){e=/^application\/x-mpegURL|application\/vnd\.apple\.mpegurl$/i.test(e.type)?"probably":/\.m3u8/i.test(e.src)?"maybe":"";return e},handleSource:function(e,t){return t.hlsProvider&&t.hlsProvider.dispose(),t.hlsProvider=new r(e,t),t.hlsProvider}},0),D.Html5Hlsjs=r)}},registerConfigPlugin:function(e){(e.registerPlugin||e.plugin)("streamrootHls",i)}}},function(e,t,r){var i;"undefined"!=typeof window&&(i=function(){return i={},a.m=r={"./node_modules/eventemitter3/index.js":function(e,t,o){"use strict";var i=Object.prototype.hasOwnProperty,f="~";function r(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,i,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");r=new n(r,i||e,a),i=f?f+t:t;return e._events[i]?e._events[i].fn?e._events[i]=[e._events[i],r]:e._events[i].push(r):(e._events[i]=r,e._eventsCount++),e}function l(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(f=!1)),s.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)i.call(e,t)&&r.push(f?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},s.prototype.listeners=function(e){var e=f?f+e:e,t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var r=0,i=t.length,a=new Array(i);r<i;r++)a[r]=t[r].fn;return a},s.prototype.listenerCount=function(e){e=f?f+e:e,e=this._events[e];return e?e.fn?1:e.length:0},s.prototype.emit=function(e,t,r,i,d,u){var c=f?f+e:e;if(!this._events[c])return!1;var a,n=this._events[c],s=arguments.length;if(n.fn){switch(n.once&&this.removeListener(e,n.fn,void 0,!0),s){case 1:return n.fn.call(n.context),!0;case 2:return n.fn.call(n.context,t),!0;case 3:return n.fn.call(n.context,t,r),!0;case 4:return n.fn.call(n.context,t,r,i),!0;case 5:return n.fn.call(n.context,t,r,i,d),!0;case 6:return n.fn.call(n.context,t,r,i,d,u),!0}for(l=1,a=new Array(s-1);l<s;l++)a[l-1]=arguments[l];n.fn.apply(n.context,a)}else for(var o,h=n.length,l=0;l<h;l++)switch(n[l].once&&this.removeListener(e,n[l].fn,void 0,!0),s){case 1:n[l].fn.call(n[l].context);break;case 2:n[l].fn.call(n[l].context,t);break;case 3:n[l].fn.call(n[l].context,t,r);break;case 4:n[l].fn.call(n[l].context,t,r,i);break;default:if(!a)for(o=1,a=new Array(s-1);o<s;o++)a[o-1]=arguments[o];n[l].fn.apply(n[l].context,a)}return!0},s.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,r,i){e=f?f+e:e;if(!this._events[e])return this;if(!t)return l(this,e),this;var a=this._events[e];if(a.fn)a.fn!==t||i&&!a.once||r&&a.context!==r||l(this,e);else{for(var n=0,s=[],o=a.length;n<o;n++)(a[n].fn!==t||i&&!a[n].once||r&&a[n].context!==r)&&s.push(a[n]);s.length?this._events[e]=1===s.length?s[0]:s:l(this,e)}return this},s.prototype.removeAllListeners=function(e){return e?(e=f?f+e:e,this._events[e]&&l(this,e)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=f,e.exports=s.EventEmitter=s},"./node_modules/url-toolkit/src/url-toolkit.js":function(e,t,r){var i,n,a,s,o;i=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,n=/^([^\/?#]*)(.*)$/,a=/(?:\/|^)\.(?=\/)/g,s=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,o={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=o.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=o.normalizePath(i.path),o.buildURLFromParts(i)}i=o.parseURL(t);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return r.alwaysNormalize?(i.path=o.normalizePath(i.path),o.buildURLFromParts(i)):t;t=o.parseURL(e);if(!t)throw new Error("Error trying to parse base URL.");!t.netLoc&&t.path&&"/"!==t.path[0]&&(e=n.exec(t.path),t.netLoc=e[1],t.path=e[2]),t.netLoc&&!t.path&&(t.path="/");var a,e={scheme:t.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};return i.netLoc||(e.netLoc=t.netLoc,"/"!==i.path[0]&&(i.path?(a=(a=t.path).substring(0,a.lastIndexOf("/")+1)+i.path,e.path=o.normalizePath(a)):(e.path=t.path,i.params||(e.params=t.params,i.query||(e.query=t.query))))),null===e.path&&(e.path=r.alwaysNormalize?o.normalizePath(i.path):i.path),o.buildURLFromParts(e)},parseURL:function(e){e=i.exec(e);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(a,"");e.length!==(e=e.replace(s,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=o},"./node_modules/webworkify-webpack/index.js":function(e,t,c){function n(r){var i={};function a(e){if(i[e])return i[e].exports;var t=i[e]={i:e,l:!1,exports:{}};return r[e].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.m=r,a.c=i,a.i=function(e){return e},a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},a.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="/",a.oe=function(e){throw e};var e=a(a.s=ENTRY_MODULE);return e.default||e}var h="[\\.|\\-|\\+|\\w|/|@]+",f="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+h+").*?\\)";function g(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function p(e,t,r){var i={},a=(i[r]=[],t.toString()),t=a.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!t)return i;for(var n,t=t[1],s=new RegExp("(\\\\n|\\W)"+g(t)+f,"g");n=s.exec(a);)"dll-reference"!==n[3]&&i[r].push(n[3]);for(s=new RegExp("\\("+g(t)+'\\("(dll-reference\\s('+h+'))"\\)\\)'+f,"g");n=s.exec(a);)e[n[2]]||(i[r].push(n[1]),e[n[2]]=c(n[1]).m),i[n[2]]=i[n[2]]||[],i[n[2]].push(n[4]);for(var u,o=Object.keys(i),l=0;l<o.length;l++)for(var d=0;d<i[o[l]].length;d++)u=i[o[l]][d],isNaN(+u)||(i[o[l]][d]=+i[o[l]][d]);return i}function s(e,u){for(var t={main:[u]},r={main:[]},i={main:{}};function(r){return Object.keys(r).reduce(function(e,t){return e||0<r[t].length},!1)}(t);)for(var a=Object.keys(t),n=0;n<a.length;n++){var s=a[n],o=t[s].pop();if(i[s]=i[s]||{},!i[s][o]&&e[s][o]){i[s][o]=!0,r[s]=r[s]||[],r[s].push(o);for(var c=p(e,e[s][o],s),l=Object.keys(c),d=0;d<l.length;d++)t[l[d]]=t[l[d]]||[],t[l[d]]=t[l[d]].concat(c[l[d]])}}return r}e.exports=function(e,t){var r={main:c.m},i=(t=t||{}).all?{main:Object.keys(r.main)}:s(r,e),a="",e=(Object.keys(i).filter(function(e){return"main"!==e}).forEach(function(t){for(var e=0;i[t][e];)e++;i[t].push(e),r[t][e]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",a=a+"var "+t+" = ("+n.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+i[t].map(function(e){return JSON.stringify(e)+": "+r[t][e].toString()}).join(",")+"});\n"}),a=a+"new (("+n.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+i.main.map(function(e){return JSON.stringify(e)+": "+r.main[e].toString()}).join(",")+"}))(self);",new window.Blob([a],{type:"text/javascript"}));if(t.bare)return e;t=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(e),e=new window.Worker(t);return e.objectURL=t,e}},"./src/crypt/decrypter.js":function(r,e,t){"use strict";t.r(e);var o=function(){function e(e,t){this.subtle=e,this.aesIV=t}return e.prototype.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},e}(),l=function(){function e(e,t){this.subtle=e,this.key=t}return e.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},e}();var d=function(){function e(){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()}var t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},t.initTable=function(){for(var u=this.sBox,c=this.invSBox,e=this.subMix,h=e[0],f=e[1],g=e[2],p=e[3],e=this.invSubMix,m=e[0],v=e[1],y=e[2],E=e[3],t=new Uint32Array(256),r=0,i=0,a=0,a=0;a<256;a++)t[a]=a<128?a<<1:a<<1^283;for(a=0;a<256;a++){var n=i^i<<1^i<<2^i<<3^i<<4,s=(u[r]=n=n>>>8^255&n^99,t[c[n]=r]),o=t[s],l=t[o],d=257*t[n]^16843008*n;h[r]=d<<24|d>>>8,f[r]=d<<16|d>>>16,g[r]=d<<8|d>>>24,p[r]=d,m[n]=(d=16843009*l^65537*o^257*s^16843008*r)<<24|d>>>8,v[n]=d<<16|d>>>16,y[n]=d<<8|d>>>24,E[n]=d,r?(r=s^t[t[t[l^s]]],i^=t[t[i]]):r=i=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),u=!0,r=0;r<t.length&&u;)u=t[r]===this.key[r],r++;if(!u){this.key=t;var i=this.keySize=t.length;if(4!==i&&6!==i&&8!==i)throw new Error("Invalid aes key size="+i);for(var a,c,n,s=this.ksRows=4*(i+6+1),o=this.keySchedule=new Uint32Array(s),h=this.invKeySchedule=new Uint32Array(s),l=this.sBox,f=this.rcon,e=this.invSubMix,g=e[0],p=e[1],m=e[2],v=e[3],d=0;d<s;d++)d<i?c=o[d]=t[d]:(n=c,d%i==0?(n=l[(n=n<<8|n>>>24)>>>24]<<24|l[n>>>16&255]<<16|l[n>>>8&255]<<8|l[255&n],n^=f[d/i|0]<<24):6<i&&d%i==4&&(n=l[n>>>24]<<24|l[n>>>16&255]<<16|l[n>>>8&255]<<8|l[255&n]),o[d]=c=(o[d-i]^n)>>>0);for(a=0;a<s;a++)d=s-a,n=3&a?o[d]:o[d-4],h[a]=a<4||d<=4?n:g[l[n>>>24]]^p[l[n>>>16&255]]^m[l[n>>>8&255]]^v[l[255&n]],h[a]=h[a]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(u,e,c,h){for(var f,g,p,m,t,r,i,a,v,y,E,T,n,b,S=this.keySize+6,s=this.invKeySchedule,o=this.invSBox,l=this.invSubMix,_=l[0],R=l[1],A=l[2],k=l[3],l=this.uint8ArrayToUint32Array_(c),L=l[0],w=l[1],D=l[2],O=l[3],C=new Int32Array(u),I=new Int32Array(C.length),d=this.networkToHostOrderSwap;e<C.length;){for(v=d(C[e]),y=d(C[e+1]),E=d(C[e+2]),T=d(C[e+3]),t=v^s[0],r=T^s[1],i=E^s[2],a=y^s[3],n=4,b=1;b<S;b++)f=_[t>>>24]^R[r>>16&255]^A[i>>8&255]^k[255&a]^s[n],g=_[r>>>24]^R[i>>16&255]^A[a>>8&255]^k[255&t]^s[n+1],p=_[i>>>24]^R[a>>16&255]^A[t>>8&255]^k[255&r]^s[n+2],m=_[a>>>24]^R[t>>16&255]^A[r>>8&255]^k[255&i]^s[n+3],t=f,r=g,i=p,a=m,n+=4;f=o[t>>>24]<<24^o[r>>16&255]<<16^o[i>>8&255]<<8^o[255&a]^s[n],g=o[r>>>24]<<24^o[i>>16&255]<<16^o[a>>8&255]<<8^o[255&t]^s[n+1],p=o[i>>>24]<<24^o[a>>16&255]<<16^o[t>>8&255]<<8^o[255&r]^s[n+2],m=o[a>>>24]<<24^o[t>>16&255]<<16^o[r>>8&255]<<8^o[255&i]^s[n+3],n+=3,I[e]=d(f^L),I[e+1]=d(m^w),I[e+2]=d(p^D),I[e+3]=d(g^O),L=v,w=y,D=E,O=T,e+=4}return h?(c=I.buffer,l=c.byteLength,(u=l&&new DataView(c).getUint8(l-1))?c.slice(0,l-u):c):I.buffer},t.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},e}(),n=t("./src/errors.ts"),u=t("./src/utils/logger.js"),s=t("./src/events.js"),t=t("./src/utils/get-self-scope.js"),a=Object(t.getSelfScope)();e.default=function(){function e(e,t,r){r=(void 0===r?{}:r).removePKCS7Padding,r=void 0===r||r;if(this.logEnabled=!0,this.observer=e,this.config=t,this.removePKCS7Padding=r)try{var i=a.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch(e){}this.disableWebCrypto=!this.subtle}var t=e.prototype;return t.isSync=function(){return this.disableWebCrypto&&this.config.enableSoftwareAES},t.decrypt=function(t,r,i,a){var e,n,s=this;this.disableWebCrypto&&this.config.enableSoftwareAES?(this.logEnabled&&(u.logger.log("JS AES decrypt"),this.logEnabled=!1),(e=this.decryptor)||(this.decryptor=e=new d),e.expandKey(r),a(e.decrypt(t,0,i,this.removePKCS7Padding))):(this.logEnabled&&(u.logger.log("WebCrypto AES decrypt"),this.logEnabled=!1),n=this.subtle,this.key!==r&&(this.key=r,this.fastAesKey=new l(n,r)),this.fastAesKey.expandKey().then(function(e){new o(n,i).decrypt(t,e).catch(function(e){s.onWebCryptoError(e,t,r,i,a)}).then(function(e){a(e)})}).catch(function(e){s.onWebCryptoError(e,t,r,i,a)}))},t.onWebCryptoError=function(e,t,r,i,a){this.config.enableSoftwareAES?(u.logger.log("WebCrypto Error, disable WebCrypto API"),this.disableWebCrypto=!0,this.logEnabled=!0,this.decrypt(t,r,i,a)):(u.logger.error("decrypting error : "+e.message),this.observer.trigger(s.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!0,reason:e.message}))},t.destroy=function(){var e=this.decryptor;e&&(e.destroy(),this.decryptor=void 0)},e}()},"./src/demux/demuxer-inline.js":function(e,r,t){"use strict";t.r(r);var G=t("./src/events.js"),j=t("./src/errors.ts"),p=t("./src/crypt/decrypter.js"),m=t("./src/polyfills/number-isFinite.js"),K=t("./src/utils/logger.js"),i=t("./src/utils/get-self-scope.js");function a(e,t){return 255===e[t]&&240==(246&e[t+1])}function l(e,t){return 1&e[t+1]?7:9}function d(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function v(e,t){return!!(t+1<e.length&&a(e,t))}function y(e,t,r,i,a){e.samplerate||(t=function(e,t,r,i){var a,n,s=navigator.userAgent.toLowerCase(),u=i,o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],l=1+((192&t[r+2])>>>6),d=(60&t[r+2])>>>2;if(!(o.length-1<d))return a=(1&t[r+2])<<2,a|=(192&t[r+3])>>>6,K.logger.log("manifest codec:"+i+",ADTS data:type:"+l+",sampleingIndex:"+d+"["+o[d]+"Hz],channelConfig:"+a),t=/firefox/i.test(s)?6<=d?(l=5,n=new Array(4),d-3):(l=2,n=new Array(2),d):-1!==s.indexOf("android")?(l=2,n=new Array(2),d):(l=5,n=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&6<=d?d-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(6<=d&&1==a||/vivaldi/i.test(s))||!i&&1==a)&&(l=2,n=new Array(2)),d)),n[0]=l<<3,n[0]|=(14&d)>>1,n[1]|=(1&d)<<7,n[1]|=a<<3,5===l&&(n[1]|=(14&t)>>1,n[2]=(1&t)<<7,n[2]|=8,n[3]=0),{config:n,samplerate:o[d],channelCount:a,codec:"mp4a.40."+l,manifestCodec:u};e.trigger(G.default.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d})}(t,r,i,a),e.config=t.config,e.samplerate=t.samplerate,e.channelCount=t.channelCount,e.codec=t.codec,e.manifestCodec=t.manifestCodec,K.logger.log("parsed codec:"+e.codec+",rate:"+t.samplerate+",nb channel:"+t.channelCount))}function h(e){return 9216e4/e}function E(e,t,r,i,a){var n,i=function(e,t,r,i,a){var n=e.length,s=l(e,t),e=d(e,t);if(0<(e-=s)&&t+s+e<=n)return{headerLength:s,frameLength:e,stamp:r+i*a}}(t,r,i,a,h(e.samplerate));if(i)return a=i.stamp,n=i.headerLength,i=i.frameLength,t={unit:t.subarray(r+n,r+n+i),pts:a,dts:a},e.samples.push(t),{sample:t,length:i+n}}var A=t("./src/demux/id3.js"),_=function(){function e(e,t,r){this.observer=e,this.config=r,this.remuxer=t}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:t,duration:i,inputTimeScale:9e4}},t.resetTimeStamp=function(){},e.probe=function(e){if(!e)return!1;for(var t=(A.default.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(function(e,t){if(v(e,t)){var r=l(e,t),t=t+(r=t+5<e.length?d(e,t):r);if(t===e.length||t+1<e.length&&a(e,t))return 1}}(e,t))return K.logger.log("ADTS sync word found !"),!0;return!1},t.append=function(e,t,u,c){for(var r=this._audioTrack,i=A.default.getID3Data(e,0)||[],a=A.default.getTimeStamp(i),n=Object(m.isFiniteNumber)(a)?90*a:9e4*t,s=0,o=n,h=e.length,l=i.length,f=[{pts:o,dts:o,data:i}];l<h-1;)if(v(e,l)&&l+5<h){y(r,this.observer,e,l,r.manifestCodec);var d=E(r,e,l,n,s);if(!d){K.logger.log("Unable to parse AAC frame");break}l+=d.length,o=d.sample.pts,s++}else A.default.isHeader(e,l)?(i=A.default.getID3Data(e,l),f.push({pts:o,dts:o,data:i}),l+=i.length):l++;this.remuxer.remux(r,{samples:[]},{samples:f,inputTimeScale:9e4},{samples:[]},t,u,c)},t.destroy=function(){},e}(),R=t("./src/demux/mp4demuxer.js"),o={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(e,t,r,i,a){var n;if(!(r+24>t.length))return n=this.parseHeader(t,r),n&&r+n.frameLength<=t.length?(i=i+a*(9e4*n.samplesPerFrame/n.sampleRate),a={unit:t.subarray(r,r+n.frameLength),pts:i,dts:i},e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(a),{sample:a,length:n.frameLength}):void 0},parseHeader:function(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,a=e[t+2]>>4&15,n=e[t+2]>>2&3,s=e[t+2]>>1&1;if(1!=r&&0!=a&&15!=a&&3!=n)return a=1e3*o.BitratesMap[14*(3==r?3-i:3==i?3:4)+a-1],n=o.SamplingRateMap[3*(3==r?0:2==r?1:2)+n],e=e[t+3]>>6==3?1:2,i=8*(t=o.SamplesCoefficients[r][i])*(r=o.BytesInSlot[i]),{sampleRate:n,channelCount:e,frameLength:parseInt(t*a/n+s,10)*r,samplesPerFrame:i}},isHeaderPattern:function(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])},isHeader:function(e,t){return!!(t+1<e.length&&this.isHeaderPattern(e,t))},probe:function(e,t){if(t+1<e.length&&this.isHeaderPattern(e,t)){var r=this.parseHeader(e,t),i=4,t=t+(i=r&&r.frameLength?r.frameLength:i);if(t===e.length||t+1<e.length&&this.isHeaderPattern(e,t))return!0}return!1}},g=o,k=function(){function e(e){this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),t=Math.min(4,t);if(0===t)throw new Error("no bytes available");i.set(e.subarray(r,r+t)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*t,this.bytesAvailable-=t},t.skipBits=function(e){var t;this.bitsAvailable>e||(e=(e-=this.bitsAvailable)-((t=e>>3)>>3),this.bytesAvailable-=t,this.loadWord()),this.word<<=e,this.bitsAvailable-=e},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return 32<e&&K.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,0<this.bitsAvailable?this.word<<=t:0<this.bytesAvailable&&this.loadWord(),0<(t=e-t)&&this.bitsAvailable?r<<t|this.readBits(t):r},t.skipLZ=function(){for(var e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){for(var t=8,r=8,i=0;i<e;i++)t=0===(r=0!==r?(t+this.readEG()+256)%256:r)?t:r},t.readSPS=function(){var u,c,e,h=0,f=0,g=0,p=0,t=this.readUByte.bind(this),r=this.readBits.bind(this),i=this.readUEG.bind(this),a=this.readBoolean.bind(this),n=this.skipBits.bind(this),s=this.skipEG.bind(this),o=this.skipUEG.bind(this),m=this.skipScalingList.bind(this);if(t(),l=t(),r(5),n(3),t(),o(),100===l||110===l||122===l||244===l||44===l||83===l||86===l||118===l||128===l){var l=i();if(3===l&&n(1),o(),o(),n(1),a())for(c=3!==l?8:12,e=0;e<c;e++)a()&&m(e<6?16:64)}o();var l=i();if(0===l)i();else if(1===l)for(n(1),s(),s(),u=i(),e=0;e<u;e++)s();o(),n(1),l=i(),o=i(),0===(r=r(1))&&n(1),n(1),a()&&(h=i(),f=i(),g=i(),p=i());var d=[1,1];if(a()&&a())switch(t()){case 1:d=[1,1];break;case 2:d=[12,11];break;case 3:d=[10,11];break;case 4:d=[16,11];break;case 5:d=[40,33];break;case 6:d=[24,11];break;case 7:d=[20,11];break;case 8:d=[32,11];break;case 9:d=[80,33];break;case 10:d=[18,11];break;case 11:d=[15,11];break;case 12:d=[64,33];break;case 13:d=[160,99];break;case 14:d=[4,3];break;case 15:d=[3,2];break;case 16:d=[2,1];break;case 255:d=[t()<<8|t(),t()<<8|t()]}return{width:Math.ceil(16*(l+1)-2*h-2*f),height:(2-r)*(o+1)*16-(r?2:4)*(g+p),pixelRatio:d}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}(),s=function(){function e(e,t,r,i){this.decryptdata=r,this.discardEPB=i,this.decrypter=new p.default(e,t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e,t){this.decrypter.decrypt(e,this.decryptdata.key.buffer,this.decryptdata.iv.buffer,t)},t.decryptAacSample=function(t,r,i,a){var n=t[r].unit,e=n.subarray(16,n.length-n.length%16),e=e.buffer.slice(e.byteOffset,e.byteOffset+e.length),s=this;this.decryptBuffer(e,function(e){e=new Uint8Array(e),n.set(e,16),a||s.decryptAacSamples(t,r+1,i)})},t.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,i),!i)return}}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,a=32;a<=e.length-16;a+=160,i+=16)r.set(e.subarray(a,a+16),i);return r},t.getAvcDecryptedUnit=function(e,t){t=new Uint8Array(t);for(var r=0,i=32;i<=e.length-16;i+=160,r+=16)e.set(t.subarray(r,r+16),i);return e},t.decryptAvcSample=function(t,r,i,a,n,s){var o=this.discardEPB(n.data),e=this.getAvcEncryptedData(o),l=this;this.decryptBuffer(e.buffer,function(e){n.data=l.getAvcDecryptedUnit(o,e),s||l.decryptAvcSamples(t,r,i+1,a)})},t.decryptAvcSamples=function(e,t,r,i){for(;;t++,r=0){if(t>=e.length)return void i();for(var a=e[t].units;!(r>=a.length);r++){var n=a[r];if(!(n.length<=48||1!==n.type&&5!==n.type)){var s=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,i,n,s),!s)return}}}},e}(),u={video:1,audio:2,id3:3,text:4},L=function(){function C(e,t,r,i){this.observer=e,this.config=r,this.typeSupported=i,this.remuxer=t,this.sampleAes=null}var e=C.prototype;return e.setDecryptData=function(e){null!=e&&null!=e.key&&"SAMPLE-AES"===e.method?this.sampleAes=new s(this.observer,this.config,e,this.discardEPB):this.sampleAes=null},C.probe=function(e){e=C._syncOffset(e);return!(e<0)&&(e&&K.logger.warn("MPEG2-TS detected but first sync word found @ offset "+e+", junk ahead ?"),!0)},C._syncOffset=function(e){for(var t=Math.min(1e3,e.length-564),r=0;r<t;){if(71===e[r]&&71===e[r+188]&&71===e[r+376])return r;r++}return-1},C.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:u[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:"video"===e?0:void 0,isAAC:"audio"===e||void 0,duration:"audio"===e?t:void 0}},e.resetInitSegment=function(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=C.createTrack("video",i),this._audioTrack=C.createTrack("audio",i),this._id3Track=C.createTrack("id3",i),this._txtTrack=C.createTrack("text",i),this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=t,this.videoCodec=r,this._duration=i},e.resetTimeStamp=function(){},e.append=function(e,u,c,h){var t,f,g,r,i,p=e.length,m=!1,v=(this.contiguous=c,this.pmtParsed),a=this._avcTrack,n=this._audioTrack,s=this._id3Track,y=a.pid,E=n.pid,T=s.pid,b=this._pmtId,o=a.pesData,l=n.pesData,d=s.pesData,S=this._parsePAT,_=this._parsePMT,R=this._parsePES,A=this._parseAVCPES.bind(this),k=this._parseAACPES.bind(this),L=this._parseMPEGPES.bind(this),w=this._parseID3PES.bind(this),D=C._syncOffset(e);for(p-=(p+D)%188,t=D;t<p;t+=188)if(71===e[t]){if(f=!!(64&e[t+1]),g=((31&e[t+1])<<8)+e[t+2],1<(48&e[t+3])>>4){if((r=t+5+e[t+4])===t+188)continue}else r=t+4;switch(g){case y:f&&(o&&(i=R(o))&&A(i,!1),o={data:[],size:0}),o&&(o.data.push(e.subarray(r,t+188)),o.size+=t+188-r);break;case E:f&&(l&&(i=R(l))&&(n.isAAC?k:L)(i),l={data:[],size:0}),l&&(l.data.push(e.subarray(r,t+188)),l.size+=t+188-r);break;case T:f&&(d&&(i=R(d))&&w(i),d={data:[],size:0}),d&&(d.data.push(e.subarray(r,t+188)),d.size+=t+188-r);break;case 0:f&&(r+=e[r]+1),b=this._pmtId=S(e,r);break;case b:f&&(r+=e[r]+1);var O=_(e,r,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);0<(y=O.avc)&&(a.pid=y),0<(E=O.audio)&&(n.pid=E,n.isAAC=O.isAAC),0<(T=O.id3)&&(s.pid=T),m&&!v&&(K.logger.log("reparse from beginning"),m=!1,t=D-188),v=this.pmtParsed=!0;break;case 17:case 8191:break;default:m=!0}}else this.observer.trigger(G.default.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});o&&(i=R(o))?(A(i,!0),a.pesData=null):a.pesData=o,l&&(i=R(l))?((n.isAAC?k:L)(i),n.pesData=null):(l&&l.size&&K.logger.log("last AAC PES packet truncated,might overlap between fragments"),n.pesData=l),d&&(i=R(d))?(w(i),s.pesData=null):s.pesData=d,null==this.sampleAes?this.remuxer.remux(n,a,s,this._txtTrack,u,c,h):this.decryptAndRemux(n,a,s,this._txtTrack,u,c,h)},e.decryptAndRemux=function(e,t,r,i,a,n,s){var o;e.samples&&e.isAAC?(o=this).sampleAes.decryptAacSamples(e.samples,0,function(){o.decryptAndRemuxAvc(e,t,r,i,a,n,s)}):this.decryptAndRemuxAvc(e,t,r,i,a,n,s)},e.decryptAndRemuxAvc=function(e,t,r,i,a,n,s){var o;t.samples?(o=this).sampleAes.decryptAvcSamples(t.samples,0,0,function(){o.remuxer.remux(e,t,r,i,a,n,s)}):this.remuxer.remux(e,t,r,i,a,n,s)},e.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},e._parsePAT=function(e,t){return(31&e[t+10])<<8|e[t+11]},e._parsePMT=function(e,t,r,i){var a,n={audio:-1,avc:-1,id3:-1,isAAC:!0},s=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<s;){switch(a=(31&e[t+1])<<8|e[t+2],e[t]){case 207:if(!i){K.logger.log("unknown stream type:"+e[t]);break}case 15:-1===n.audio&&(n.audio=a);break;case 21:-1===n.id3&&(n.id3=a);break;case 219:if(!i){K.logger.log("unknown stream type:"+e[t]);break}case 27:-1===n.avc&&(n.avc=a);break;case 3:case 4:r?-1===n.audio&&(n.audio=a,n.isAAC=!1):K.logger.log("MPEG audio found, not supported in this browser for now");break;case 36:K.logger.warn("HEVC stream type found, not supported for now");break;default:K.logger.log("unknown stream type:"+e[t])}t+=5+((15&e[t+3])<<8|e[t+4])}return n},e._parsePES=function(e){var t,r,i,a,n,u=0,s=e.data;if(!e||0===e.size)return null;for(;s[0].length<19&&1<s.length;){var o=new Uint8Array(s[0].length+s[1].length);o.set(s[0]),o.set(s[1],s[0].length),s[0]=o,s.splice(1,1)}if(1!==((l=s[0])[0]<<16)+(l[1]<<8)+l[2])return null;if((t=(l[4]<<8)+l[5])&&t>e.size-6)return null;if(192&(r=l[7])&&(4294967295<(i=536870912*(14&l[9])+4194304*(255&l[10])+16384*(254&l[11])+128*(255&l[12])+(254&l[13])/2)&&(i-=8589934592),64&r?(4294967295<(a=536870912*(14&l[14])+4194304*(255&l[15])+16384*(254&l[16])+128*(255&l[17])+(254&l[18])/2)&&(a-=8589934592),54e5<i-a&&(K.logger.warn(Math.round((i-a)/9e4)+"s delta between PTS and DTS, align them"),i=a)):a=i),r=l[8],e.size<=(n=r+9))return null;e.size-=n;for(var c=new Uint8Array(e.size),h=0,f=s.length;h<f;h++){var l,d=(l=s[h]).byteLength;if(n){if(d<n){n-=d;continue}l=l.subarray(n),d-=n,n=0}c.set(l,u),u+=d}return t&&(t-=r+3),{data:c,pts:i,dts:a,len:t}},e.pushAccesUnit=function(e,t){if(e.units.length&&e.frame){var r=t.samples,i=r.length;if(isNaN(e.pts)){if(!i)return void t.dropped++;var a=r[i-1];e.pts=a.pts,e.dts=a.dts}!this.config.forceKeyFrameOnDiscontinuity||!0===e.key||t.sps&&(i||this.contiguous)?(e.id=i,r.push(e)):t.dropped++}e.debug.length&&K.logger.log(e.pts+"/"+e.dts+":"+e.debug)},e._parseAVCPES=function(p,t){function m(e,t,r,i){return{key:e,pts:t,dts:r,units:[],debug:i}}var v,y,E,T=this,b=this._avcTrack,e=this._parseAVCNALu(p.data),S=this.avcSample,R=!1,_=this.pushAccesUnit.bind(this);p.data=null,S&&e.length&&!b.audFound&&(_(S,b),S=this.avcSample=m(!1,p.pts,p.dts,"")),e.forEach(function(e){switch(e.type){case 1:y=!0,(S=S||(T.avcSample=m(!0,p.pts,p.dts,""))).frame=!0;var t=e.data;R&&4<t.length&&(2!==(t=new k(t).readSliceType())&&4!==t&&7!==t&&9!==t||(S.key=!0));break;case 5:y=!0,(S=S||(T.avcSample=m(!0,p.pts,p.dts,""))).key=!0,S.frame=!0;break;case 6:y=!0,(v=new k(T.discardEPB(e.data))).readUByte();for(var r=0,i=0,u=!1,a=0;!u&&1<v.bytesAvailable;){for(r=0;r+=a=v.readUByte(),255===a;);for(i=0;i+=a=v.readUByte(),255===a;);if(4===r&&0!==v.bytesAvailable){var u=!0,n=v.readUByte();if(181===n)if(49===v.readUShort()){n=v.readUInt();if(1195456820===n)if(3===v.readUByte()){var n=v.readUByte(),c=31&n,s=[n,v.readUByte()];for(E=0;E<c;E++)s.push(v.readUByte()),s.push(v.readUByte()),s.push(v.readUByte());T._insertSampleInOrder(T._txtTrack.samples,{type:3,pts:p.pts,bytes:s})}}}else if(5===r&&0!==v.bytesAvailable){if(u=!0,16<i){var o=[];for(E=0;E<16;E++)o.push(v.readUByte().toString(16)),3!==E&&5!==E&&7!==E&&9!==E||o.push("-");var h=i-16,l=new Uint8Array(h);for(E=0;E<h;E++)l[E]=v.readUByte();T._insertSampleInOrder(T._txtTrack.samples,{pts:p.pts,payloadType:r,uuid:o.join(""),userDataBytes:l,userData:Object(A.utf8ArrayToStr)(l.buffer)})}}else if(i<v.bytesAvailable)for(E=0;E<i;E++)v.readUByte()}break;case 7:if(R=y=!0,!b.sps){var t=(v=new k(e.data)).readSPS(),f=(b.width=t.width,b.height=t.height,b.pixelRatio=t.pixelRatio,b.sps=[e.data],b.duration=T._duration,e.data.subarray(1,4)),g="avc1.";for(E=0;E<3;E++){var d=f[E].toString(16);g+=d=d.length<2?"0"+d:d}b.codec=g}break;case 8:y=!0,b.pps||(b.pps=[e.data]);break;case 9:y=!1,b.audFound=!0,S&&_(S,b),S=T.avcSample=m(!1,p.pts,p.dts,"");break;case 12:y=!1;break;default:y=!1,S&&(S.debug+="unknown NAL "+e.type+" ")}S&&y&&S.units.push(e)}),t&&S&&(_(S,b),this.avcSample=null)},e._insertSampleInOrder=function(e,t){var r=e.length;if(0<r){if(t.pts>=e[r-1].pts)e.push(t);else for(var i=r-1;0<=i;i--)if(t.pts<e[i].pts){e.splice(i,0,t);break}}else e.push(t)},e._getLastNalUnit=function(){var e,t,r=this.avcSample;return t=(r=!r||0===r.units.length?(e=this._avcTrack.samples)[e.length-1]:r)?(e=r.units)[e.length-1]:t},e._parseAVCNALu=function(e){var u,t,r,i,c,a=0,h=e.byteLength,f=this._avcTrack,g=l=f.naluState||0,n=[],s=-1;for(-1===l&&(r=31&e[s=0],l=0,a=1);a<h;){var o,p,l,d=e[a++];l?l=1!==l?d?1===d?(0<=s?(t={data:e.subarray(s,a-l-1),type:r},n.push(t)):(o=this._getLastNalUnit())&&(g&&a<=4-g&&o.state&&(o.data=o.data.subarray(0,o.data.byteLength-g)),0<(u=a-l-1)&&((p=new Uint8Array(o.data.byteLength+u)).set(o.data,0),p.set(e.subarray(0,u),o.data.byteLength),o.data=p)),a<h?(r=31&e[s=a],0):-1):0:3:d?0:2:l=d?0:1}return 0<=s&&0<=l&&(t={data:e.subarray(s,h),type:r,state:l},n.push(t)),0!==n.length||(i=this._getLastNalUnit())&&((c=new Uint8Array(i.data.byteLength+e.byteLength)).set(i.data,0),c.set(e,i.data.byteLength),i.data=c),f.naluState=l,n},e.discardEPB=function(e){for(var t=e.byteLength,r=[],i=1;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;for(var a=t-r.length,n=new Uint8Array(a),s=0,i=0;i<a;s++,i++)s===r[0]&&(s++,r.shift()),n[i]=e[s];return n},e._parseAACPES=function(e){var t,r,u,i,a=this._audioTrack,n=e.data,s=e.pts,e=this.aacOverFlow,c=this.aacLastPTS;for(e&&((l=new Uint8Array(e.byteLength+n.byteLength)).set(e,0),l.set(n,e.byteLength),n=l),r=0,i=n.length;r<i-1&&!v(n,r);r++);if(r){var o,l=r<i-1?(o="AAC PES did not start with ADTS header,offset:"+r,!1):(o="no ADTS header found in AAC PES",!0);if(K.logger.warn("parsing error:"+o),this.observer.trigger(G.default.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.FRAG_PARSING_ERROR,fatal:l,reason:o}),l)return}for(y(a,this.observer,n,r,this.audioCodec),t=0,o=h(a.samplerate),e&&c&&(l=c+o,1<Math.abs(l-s)&&(K.logger.log("AAC: align PTS for overlapping frames by "+Math.round((l-s)/90)),s=l));r<i;){if(v(n,r)){if(r+5<i){var d=E(a,n,r,s,t);if(d){r+=d.length,u=d.sample.pts,t++;continue}}break}r++}e=r<i?n.subarray(r,i):null,this.aacOverFlow=e,this.aacLastPTS=u},e._parseMPEGPES=function(e){for(var t=e.data,r=t.length,i=0,a=0,n=e.pts;a<r;)if(g.isHeader(t,a)){var s=g.appendFrame(this._audioTrack,t,a,n,i);if(!s)break;a+=s.length,i++}else a++},e._parseID3PES=function(e){this._id3Track.samples.push(e)},C}(),w=function(){function e(e,t,r){this.observer=e,this.config=r,this.remuxer=t}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._audioTrack={container:"audio/mpeg",type:"audio",id:-1,sequenceNumber:0,isAAC:!1,samples:[],len:0,manifestCodec:t,duration:i,inputTimeScale:9e4}},t.resetTimeStamp=function(){},e.probe=function(e){var t,r,i=A.default.getID3Data(e,0);if(i&&void 0!==A.default.getTimeStamp(i))for(t=i.length,r=Math.min(e.length-1,t+100);t<r;t++)if(g.probe(e,t))return K.logger.log("MPEG Audio sync word found !"),!0;return!1},t.append=function(e,t,u,c){for(var r=A.default.getID3Data(e,0),i=A.default.getTimeStamp(r),a=i?90*i:9e4*t,n=r.length,h=e.length,s=0,o=0,l=this._audioTrack,f=[{pts:a,dts:a,data:r}];n<h;)if(g.isHeader(e,n)){var d=g.appendFrame(l,e,n,a,s);if(!d)break;n+=d.length,o=d.sample.pts,s++}else A.default.isHeader(e,n)?(r=A.default.getID3Data(e,n),f.push({pts:o,dts:o,data:r}),n+=r.length):n++;this.remuxer.remux(l,{samples:[]},{samples:f,inputTimeScale:9e4},{samples:[]},t,u,c)},t.destroy=function(){},e}(),N=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)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(6===t)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])}else{if(1===t)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(2===t)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(3===t)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])}return null},e}(),n=Math.pow(2,32)-1,H=function(){function c(){}return c.init=function(){for(var e in c.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:[]})c.types.hasOwnProperty(e)&&(c.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var t=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]),r=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]),t=(c.HDLR_TYPES={video:t,audio:r},new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),r=new Uint8Array([0,0,0,0,0,0,0,0]),r=(c.STTS=c.STSC=c.STCO=r,c.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),c.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),c.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),c.STSD=new Uint8Array([0,0,0,0,0,0,0,1]),new Uint8Array([105,115,111,109])),i=new Uint8Array([97,118,99,49]),a=new Uint8Array([0,0,0,1]);c.FTYP=c.box(c.types.ftyp,r,a,r,i),c.DINF=c.box(c.types.dinf,c.box(c.types.dref,t))},c.box=function(e){for(var t,r=Array.prototype.slice.call(arguments,1),i=8,a=r.length,n=a;a--;)i+=r[a].byteLength;for((t=new Uint8Array(i))[0]=i>>24&255,t[1]=i>>16&255,t[2]=i>>8&255,t[3]=255&i,t.set(e,4),a=0,i=8;a<n;a++)t.set(r[a],i),i+=r[a].byteLength;return t},c.hdlr=function(e){return c.box(c.types.hdlr,c.HDLR_TYPES[e])},c.mdat=function(e){return c.box(c.types.mdat,e)},c.mdhd=function(e,t){t*=e;var r=Math.floor(t/(1+n)),t=Math.floor(t%(1+n));return c.box(c.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t,85,196,0,0]))},c.mdia=function(e){return c.box(c.types.mdia,c.mdhd(e.timescale,e.duration),c.hdlr(e.type),c.minf(e))},c.mfhd=function(e){return c.box(c.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},c.minf=function(e){return"audio"===e.type?c.box(c.types.minf,c.box(c.types.smhd,c.SMHD),c.DINF,c.stbl(e)):c.box(c.types.minf,c.box(c.types.vmhd,c.VMHD),c.DINF,c.stbl(e))},c.moof=function(e,t,r){return c.box(c.types.moof,c.mfhd(e),c.traf(r,t))},c.moov=function(e){for(var t=e.length,r=[];t--;)r[t]=c.trak(e[t]);return c.box.apply(null,[c.types.moov,c.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(c.mvex(e)))},c.mvex=function(e){for(var t=e.length,r=[];t--;)r[t]=c.trex(e[t]);return c.box.apply(null,[c.types.mvex].concat(r))},c.mvhd=function(e,t){t*=e;var r=Math.floor(t/(1+n)),t=Math.floor(t%(1+n)),e=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t,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 c.box(c.types.mvhd,e)},c.sdtp=function(e){for(var t,r=e.samples||[],i=new Uint8Array(4+r.length),a=0;a<r.length;a++)t=r[a].flags,i[a+4]=t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;return c.box(c.types.sdtp,i)},c.stbl=function(e){return c.box(c.types.stbl,c.stsd(e),c.box(c.types.stts,c.STTS),c.box(c.types.stsc,c.STSC),c.box(c.types.stsz,c.STSZ),c.box(c.types.stco,c.STCO))},c.avc1=function(e){for(var t,r,i=[],a=[],n=0;n<e.sps.length;n++)r=(t=e.sps[n]).byteLength,i.push(r>>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(t));for(n=0;n<e.pps.length;n++)r=(t=e.pps[n]).byteLength,a.push(r>>>8&255),a.push(255&r),a=a.concat(Array.prototype.slice.call(t));var u=c.box(c.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|e.sps.length].concat(i).concat([e.pps.length]).concat(a))),s=e.width,o=e.height,l=e.pixelRatio[0],d=e.pixelRatio[1];return c.box(c.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,s>>8&255,255&s,o>>8&255,255&o,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]),u,c.box(c.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),c.box(c.types.pasp,new Uint8Array([l>>24,l>>16&255,l>>8&255,255&l,d>>24,d>>16&255,d>>8&255,255&d])))},c.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},c.mp4a=function(e){var t=e.samplerate;return c.box(c.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]),c.box(c.types.esds,c.esds(e)))},c.mp3=function(e){var t=e.samplerate;return c.box(c.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]))},c.stsd=function(e){return"audio"===e.type?e.isAAC||"mp3"!==e.codec?c.box(c.types.stsd,c.STSD,c.mp4a(e)):c.box(c.types.stsd,c.STSD,c.mp3(e)):c.box(c.types.stsd,c.STSD,c.avc1(e))},c.tkhd=function(e){var t=e.id,r=e.duration*e.timescale,i=e.width,e=e.height,a=Math.floor(r/(1+n)),r=Math.floor(r%(1+n));return c.box(c.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,r>>24,r>>16&255,r>>8&255,255&r,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,i>>8&255,255&i,0,0,e>>8&255,255&e,0,0]))},c.traf=function(e,t){var r=c.sdtp(e),i=e.id,a=Math.floor(t/(1+n)),t=Math.floor(t%(1+n));return c.box(c.types.traf,c.box(c.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),c.box(c.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,t>>24,t>>16&255,t>>8&255,255&t])),c.trun(e,r.length+16+20+8+16+8+8),r)},c.trak=function(e){return e.duration=e.duration||4294967295,c.box(c.types.trak,c.tkhd(e),c.mdia(e))},c.trex=function(e){e=e.id;return c.box(c.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},c.trun=function(e,t){var r,i,a,n,s,o=e.samples||[],l=o.length,e=12+16*l,d=new Uint8Array(e);for(d.set([0,0,15,1,l>>>24&255,l>>>16&255,l>>>8&255,255&l,(t+=8+e)>>>24&255,t>>>16&255,t>>>8&255,255&t],0),r=0;r<l;r++)i=(s=o[r]).duration,a=s.size,n=s.flags,s=s.cts,d.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,a>>>24&255,a>>>16&255,a>>>8&255,255&a,n.isLeading<<2|n.dependsOn,n.isDependedOn<<6|n.hasRedundancy<<4|n.paddingValue<<1|n.isNonSync,61440&n.degradPrio,15&n.degradPrio,s>>>24&255,s>>>16&255,s>>>8&255,255&s],12+16*r);return c.box(c.types.trun,d)},c.initSegment=function(e){c.types||c.init();var e=c.moov(e),t=new Uint8Array(c.FTYP.byteLength+e.byteLength);return t.set(c.FTYP),t.set(e,c.FTYP.byteLength),t},c}();function c(e,t,r,i){e=e*t*(r=void 0===r?1:r);return(i=void 0===i?!1:i)?Math.round(e):e}function V(e,t){return c(e,1e3,1/9e4,t=void 0===t?!1:t)}function f(e,t){return c(e,9e4,1/(t=void 0===t?1:t))}var T,U=f(10),Y=f(.2),D=function(){function e(e,t,r,i){this.observer=e,this.config=t,this.typeSupported=r;e=navigator.userAgent;this.isSafari=i&&-1<i.indexOf("Apple")&&e&&!e.match("CriOS"),this.ISGenerated=!1}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){this._initPTS=this._initDTS=e},t.resetInitSegment=function(){this.ISGenerated=!1},t.remux=function(e,t,u,c,r,i,a){var n,s,o,l,h,d;this.ISGenerated||this.generateIS(e,t,r),this.ISGenerated&&(d=e.samples.length,n=t.samples.length,o=s=r,d&&n&&(l=(e.samples[0].pts-t.samples[0].pts)/t.inputTimeScale,s+=Math.max(0,l),o+=Math.max(0,-l)),d?(e.timescale||(K.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(e,t,r)),l=this.remuxAudio(e,s,i,a),n&&(l&&(h=l.endPTS-l.startPTS),t.timescale||(K.logger.warn("regenerate InitSegment as video detected"),this.generateIS(e,t,r)),this.remuxVideo(t,o,i,h,a))):!n||(d=this.remuxVideo(t,o,i,0,a))&&e.codec&&this.remuxEmptyAudio(e,s,i,d)),u.samples.length&&this.remuxID3(u,r),c.samples.length&&this.remuxText(c,r),this.observer.trigger(G.default.FRAG_PARSED)},t.generateIS=function(e,t,r){var i,a,u=this.observer,c=e.samples,n=t.samples,s=this.typeSupported,o="audio/mp4",l={},h={tracks:l},d=void 0===this._initPTS;d&&(i=a=1/0),e.config&&c.length&&(e.timescale=e.samplerate,K.logger.log("audio sampling rate : "+e.samplerate),e.isAAC||(s.mpeg?(o="audio/mpeg",e.codec=""):s.mp3&&(e.codec="mp3")),l.audio={container:o,codec:e.codec,initSegment:!e.isAAC&&s.mpeg?new Uint8Array:H.initSegment([e]),metadata:{channelCount:e.channelCount}},d&&(i=a=c[0].pts-e.inputTimeScale*r)),t.sps&&t.pps&&n.length&&(o=t.inputTimeScale,t.timescale=o,l.video={container:"video/mp4",codec:t.codec,initSegment:H.initSegment([t]),metadata:{width:t.width,height:t.height}},d&&(i=Math.min(i,n[0].pts-o*r),a=Math.min(a,n[0].dts-o*r),this.observer.trigger(G.default.INIT_PTS_FOUND,{initPTS:i}))),Object.keys(l).length?(u.trigger(G.default.FRAG_PARSING_INIT_SEGMENT,h),this.ISGenerated=!0,d&&(this._initPTS=i,this._initDTS=a)):u.trigger(G.default.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})},t.remuxVideo=function(e,t,r,u,i){var a,c,h=8,n=e.timescale,s=e.samples,f=[],g=s.length,p=this._PTSNormalize,m=this._initPTS,o=this.nextAvcDts,v=this.isSafari;if(0!==g){v&&(r|=s.length&&o&&(i&&Math.abs(t-o/n)<.1||Math.abs(s[0].pts-o-m)<n/5)),r||(o=t*n),s.forEach(function(e){e.pts=p(e.pts-m,o),e.dts=p(e.dts-m,o)}),s.sort(function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i||e.id-t.id});var y=s.reduce(function(e,t){return Math.max(Math.min(e,t.pts-t.dts),-1*Y)},0);if(y<0){K.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+V(y,!0)+" ms to overcome this issue");for(var E=0;E<s.length;E++)s[E].dts+=y}for(var i=s[0],l=Math.max(i.dts,0),T=Math.max(i.pts,0),t=l-o,b=(r&&t&&(1<t?K.logger.log("AVC: "+V(t,!0)+" ms hole between fragments detected,filling it"):t<-1&&K.logger.log("AVC: "+V(-t,!0)+" ms overlapping between fragments detected"),l=o,s[0].dts=l,T=Math.max(T-t,o),s[0].pts=T,K.logger.log("Video: PTS/DTS adjusted: "+V(T,!0)+"/"+V(l,!0)+", delta: "+V(t,!0)+" ms")),i=s[s.length-1],r=Math.max(i.dts,0),t=Math.max(i.pts,0,r),v&&(a=Math.round((r-l)/(s.length-1))),0),S=0,_=0;_<g;_++){for(var R=s[_],A=R.units,k=A.length,L=0,w=0;w<k;w++)L+=A[w].data.length;S+=L,b+=k,R.length=L,R.dts=v?l+_*a:Math.max(R.dts,l),R.pts=Math.max(R.pts,R.dts)}i=S+4*b+8;try{c=new Uint8Array(i)}catch(e){return void this.observer.trigger(G.default.ERROR,{type:j.ErrorTypes.MUX_ERROR,details:j.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:i,reason:"fail allocating video mdat "+i})}var D=new DataView(c.buffer);D.setUint32(0,i),c.set(H.types.mdat,4);for(var O=0;O<g;O++){for(var C,I,d=s[O],x=d.units,P=0,F=void 0,M=0,N=x.length;M<N;M++){var U=x[M],B=U.data,U=U.data.byteLength;D.setUint32(h,U),h+=4,c.set(B,h),h+=U,P+=4+U}F=v?Math.max(0,a*Math.round((d.pts-d.dts)/a)):(O<g-1?a=s[O+1].dts-d.dts:(I=this.config,C=d.dts-s[0<O?O-1:O].dts,I.stretchShortVideoTrack?(I=I.maxBufferHole,Math.floor(I*n)<(I=(u?T+u*n:this.nextAudioPts)-d.pts)?((a=I-C)<0&&(a=C),K.logger.log("It is approximately "+V(I,!1)+" ms to the next segment; using duration "+V(a,!1)+" ms for the last video frame.")):a=C):a=C),Math.round(d.pts-d.dts)),f.push({size:P,duration:a,cts:F,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:d.key?2:1,isNonSync:d.key?0:1}})}this.nextAvcDts=r+a;i=e.dropped,e=(e.nbNalu=0,e.dropped=0,f.length&&-1<navigator.userAgent.toLowerCase().indexOf("chrome")&&((r=f[0].flags).dependsOn=2,r.isNonSync=0),e.samples=f,r=H.moof(e.sequenceNumber++,l,e),e.samples=[],{data1:r,data2:c,startPTS:T/n,endPTS:(t+a)/n,startDTS:l/n,endDTS:this.nextAvcDts/n,type:"video",hasAudio:!1,hasVideo:!0,nb:f.length,dropped:i});return this.observer.trigger(G.default.FRAG_PARSING_DATA,e),e}},t.remuxAudio=function(e,u,c,h){var f,g,p,m,v=e.inputTimeScale,t=e.timescale,y=v/t,r=(e.isAAC?1024:1152)*y,E=this._PTSNormalize,T=this._initPTS,b=!e.isAAC&&this.typeSupported.mpeg,S=b?0:8,i=e.samples,_=[],a=this.nextAudioPts;if(c|=i.length&&a&&(h&&Math.abs(u-a/v)<.1||Math.abs(i[0].pts-a-T)<20*r),i.forEach(function(e){e.pts=e.dts=E(e.pts-T,u*v)}),0!==(i=i.filter(function(e){return 0<=e.pts})).length){if(c||(a=h?u*v:i[0].pts),e.isAAC)for(var R=this.config.maxAudioFramesDrift,A=0,n=a;A<i.length;){var k=i[A],L=k.pts-n;if(L<=-R*r)K.logger.warn("Dropping 1 audio frame @ "+V(n,!0)+" ms due to "+V(L,!0)+" ms overlap."),i.splice(A,1);else if(R*r<=L&&L<U&&n){var w=Math.round(L/r);K.logger.warn("Injecting "+w+" audio frames @ "+V(n,!0)+" ms due to "+V(n,!0)+" ms gap.");for(var D=0;D<w;D++){var s,O=Math.max(n,0);(s=N.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(K.logger.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),s=k.unit.subarray()),i.splice(A,0,{unit:s,pts:O,dts:O}),n+=r,A++}k.pts=k.dts=n,n+=r,A++}else Math.abs(L),k.pts=k.dts=n,n+=r,A++}for(var C=i.length,o=0;C--;)o+=i[C].unit.byteLength;for(var I=0,x=i.length;I<x;I++){var l=i[I],P=l.unit,l=l.pts;if(void 0!==m)f.duration=Math.round((l-m)/y);else{var d=l-a,F=0;if(c&&e.isAAC&&d){if(0<d&&d<U)F=Math.round((l-a)/r),K.logger.log(V(d,!0)+" ms hole between AAC samples detected,filling it"),0<F&&(o+=F*(s=(s=N.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||P.subarray()).length);else if(d<-12){K.logger.log("drop overlapping AAC sample, expected/parsed/delta: "+V(a,!0)+" ms / "+V(l,!0)+" ms / "+V(-d,!0)+" ms"),o-=P.byteLength;continue}l=a}if(p=l,!(0<o))return;o+=S;try{g=new Uint8Array(o)}catch(e){return void this.observer.trigger(G.default.ERROR,{type:j.ErrorTypes.MUX_ERROR,details:j.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:o,reason:"fail allocating audio mdat "+o})}b||(new DataView(g.buffer).setUint32(0,o),g.set(H.types.mdat,4));for(var M=0;M<F;M++)(s=N.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(K.logger.log("Unable to get silent frame for given audio codec; duplicating this frame instead."),s=P.subarray()),g.set(s,S),S+=s.byteLength,f={size:s.byteLength,cts:0,duration:1024,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},_.push(f)}g.set(P,S);d=P.byteLength;S+=d,_.push(f={size:d,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}}),m=l}var t=0;return 2<=(C=_.length)&&(t=_[C-2].duration,f.duration=t),C?(this.nextAudioPts=a=m+y*t,e.samples=_,h=b?new Uint8Array:H.moof(e.sequenceNumber++,p/y,e),e.samples=[],this.observer.trigger(G.default.FRAG_PARSING_DATA,t={data1:h,data2:g,startPTS:t=p/v,endPTS:h=a/v,startDTS:t,endDTS:h,type:"audio",hasAudio:!0,hasVideo:!1,nb:C}),t):null}},t.remuxEmptyAudio=function(e,u,c,t){var r=e.inputTimeScale,h=e.samplerate||r,i=this.nextAudioPts,a=(void 0!==i?i:t.startDTS*r)+this._initDTS,i=t.endDTS*r+this._initDTS,n=1024*(r/h),f=Math.ceil((i-a)/n),s=N.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(K.logger.warn("remux empty Audio"),s){for(var o=[],l=0;l<f;l++){var d=a+l*n;o.push({unit:s,pts:d,dts:d})}e.samples=o,this.remuxAudio(e,u,c)}else K.logger.trace("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!")},t.remuxID3=function(e){var t,r=e.samples.length,i=e.inputTimeScale,a=this._initPTS,n=this._initDTS;if(r){for(var s=0;s<r;s++)(t=e.samples[s]).pts=(t.pts-a)/i,t.dts=(t.dts-n)/i;this.observer.trigger(G.default.FRAG_PARSING_METADATA,{samples:e.samples})}e.samples=[]},t.remuxText=function(e){e.samples.sort(function(e,t){return e.pts-t.pts});var t,r=e.samples.length,i=e.inputTimeScale,a=this._initPTS;if(r){for(var n=0;n<r;n++)(t=e.samples[n]).pts=(t.pts-a)/i;this.observer.trigger(G.default.FRAG_PARSING_USERDATA,{samples:e.samples})}e.samples=[]},t._PTSNormalize=function(e,t){var r;if(void 0===t)return e;for(r=t<e?-8589934592:8589934592;4294967296<Math.abs(e-t);)e+=r;return e},e}(),O=function(){function e(e){this.observer=e}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(){},t.resetInitSegment=function(){},t.remux=function(e,t,r,i,a,n,d,s){var o=this.observer,l="";e&&(l+="audio"),t&&(l+="video"),o.trigger(G.default.FRAG_PARSING_DATA,{data1:s,startPTS:a,startDTS:a,type:l,hasAudio:!!e,hasVideo:!!t,nb:1,dropped:0}),o.trigger(G.default.FRAG_PARSED)},e}(),t=Object(i.getSelfScope)();try{T=t.performance.now.bind(t.performance)}catch(e){K.logger.debug("Unable to use Performance API on this environment"),T=t.Date.now}r.default=function(){function e(e,t,r,i){this.observer=e,this.typeSupported=t,this.config=r,this.vendor=i}var t=e.prototype;return t.destroy=function(){var e=this.demuxer;e&&e.destroy()},t.push=function(e,r,i,a,n,s,o,l,d,u,c,h){var t,f,g=this;0<e.byteLength&&null!=r&&null!=r.key&&"AES-128"===r.method?(null==(t=this.decrypter)&&(t=this.decrypter=new p.default(this.observer,this.config)),f=T(),t.decrypt(e,r.key.buffer,r.iv.buffer,function(e){var t=T();g.observer.trigger(G.default.FRAG_DECRYPTED,{stats:{tstart:f,tdecrypt:t}}),g.pushDecrypted(new Uint8Array(e),r,new Uint8Array(i),a,n,s,o,l,d,u,c,h)})):this.pushDecrypted(new Uint8Array(e),r,new Uint8Array(i),a,n,s,o,l,d,u,c,h)},t.pushDecrypted=function(e,u,c,h,f,g,t,r,p,m,v,i){if(!(d=this.demuxer)||(t||r)&&!this.probe(e)){for(var a=this.observer,n=this.typeSupported,s=this.config,y=[{demux:L,remux:D},{demux:R.default,remux:O},{demux:_,remux:D},{demux:w,remux:D}],o=0,E=y.length;o<E;o++){var l=y[o],T=l.demux.probe;if(T(e)){var b=this.remuxer=new l.remux(a,s,n,this.vendor),d=new l.demux(a,b,s,n);this.probe=T;break}}if(!d)return void a.trigger(G.default.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});this.demuxer=d}var S=this.remuxer;(t||r)&&(d.resetInitSegment(c,h,f,m),S.resetInitSegment()),t&&(d.resetTimeStamp(i),S.resetTimeStamp(i)),"function"==typeof d.setDecryptData&&d.setDecryptData(u),d.append(e,g,p,v)},e}()},"./src/demux/demuxer-worker.js":function(e,t,r){"use strict";r.r(t);var s=r("./src/demux/demuxer-inline.js"),o=r("./src/events.js"),l=r("./src/utils/logger.js"),d=r("./node_modules/eventemitter3/index.js");t.default=function(i){function a(e,t){i.postMessage({event:e,data:t})}var n=new d.EventEmitter;n.trigger=function(e){for(var t=arguments.length,r=new Array(1<t?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];n.emit.apply(n,[e,e].concat(r))},n.off=function(e){for(var t=arguments.length,r=new Array(1<t?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];n.removeListener.apply(n,[e].concat(r))};i.addEventListener("message",function(e){var t=e.data;switch(t.cmd){case"init":var r=JSON.parse(t.config);i.demuxer=new s.default(n,t.typeSupported,r,t.vendor),Object(l.enableLogs)(r.debug),a("init",null);break;case"demux":i.demuxer.push(t.data,t.decryptdata,t.initSegment,t.audioCodec,t.videoCodec,t.timeOffset,t.discontinuity,t.trackSwitch,t.contiguous,t.duration,t.accurateTimeOffset,t.defaultInitPTS)}}),n.on(o.default.FRAG_DECRYPTED,a),n.on(o.default.FRAG_PARSING_INIT_SEGMENT,a),n.on(o.default.FRAG_PARSED,a),n.on(o.default.ERROR,a),n.on(o.default.FRAG_PARSING_METADATA,a),n.on(o.default.FRAG_PARSING_USERDATA,a),n.on(o.default.INIT_PTS_FOUND,a),n.on(o.default.FRAG_PARSING_DATA,function(e,t){var r=[],e={event:e,data:t};t.data1&&(e.data1=t.data1.buffer,r.push(t.data1.buffer),delete t.data1),t.data2&&(e.data2=t.data2.buffer,r.push(t.data2.buffer),delete t.data2),i.postMessage(e,r)})}},"./src/demux/id3.js":function(e,t,r){"use strict";r.r(t),r.d(t,"utf8ArrayToStr",function(){return i});var u,c=r("./src/utils/get-self-scope.js"),r=function(){function o(){}return o.isHeader=function(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},o.isFooter=function(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},o.getID3Data=function(e,t){for(var r=t,i=0;o.isHeader(e,t);){i=(i+=10)+o._readSize(e,t+6);o.isFooter(e,t+10)&&(i+=10),t+=i}if(0<i)return e.subarray(r,r+i)},o._readSize=function(e,t){var r=(127&e[t])<<21;return(r|=(127&e[t+1])<<14)|(127&e[t+2])<<7|127&e[t+3]},o.getTimeStamp=function(e){for(var t=o.getID3Frames(e),r=0;r<t.length;r++){var i=t[r];if(o.isTimeStampFrame(i))return o._readTimeStamp(i)}},o.isTimeStampFrame=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},o._getFrameData=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=o._readSize(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},o.getID3Frames=function(e){for(var t=0,r=[];o.isHeader(e,t);){for(var i=o._readSize(e,t+6),a=(t+=10)+i;t+8<a;){var n=o._getFrameData(e.subarray(t)),s=o._decodeFrame(n);s&&r.push(s),t+=n.size+10}o.isFooter(e,t)&&(t+=10)}return r},o._decodeFrame=function(e){return"PRIV"===e.type?o._decodePrivFrame(e):"T"===e.type[0]?o._decodeTextFrame(e):"W"===e.type[0]?o._decodeURLFrame(e):void 0},o._readTimeStamp=function(e){var t;if(8===e.data.byteLength)return t=1&(e=new Uint8Array(e.data))[3],e=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7],e/=45,t&&(e+=47721858.84),Math.round(e)},o._decodePrivFrame=function(e){var t,r;if(!(e.size<2))return t=o._utf8ArrayToStr(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1)),{key:e.type,info:t,data:r.buffer}},o._decodeTextFrame=function(e){var t,r;if(!(e.size<2))return"TXXX"===e.type?(t=1,t+=(r=o._utf8ArrayToStr(e.data.subarray(1),!0)).length+1,t=o._utf8ArrayToStr(e.data.subarray(t)),{key:e.type,info:r,data:t}):(r=o._utf8ArrayToStr(e.data.subarray(1)),{key:e.type,data:r})},o._decodeURLFrame=function(e){var t,r;return"WXXX"!==e.type?(r=o._utf8ArrayToStr(e.data),{key:e.type,data:r}):e.size<2?void 0:(r=1,r+=(t=o._utf8ArrayToStr(e.data.subarray(1))).length+1,r=o._utf8ArrayToStr(e.data.subarray(r)),{key:e.type,info:t,data:r})},o._utf8ArrayToStr=function(e,t){void 0===t&&(t=!1);var r,i=function(){var e=Object(c.getSelfScope)();u||void 0===e.TextDecoder||(u=new e.TextDecoder("utf-8"));return u}();if(i)return i=i.decode(e),t?-1!==(r=i.indexOf("\0"))?i.substring(0,r):i:i.replace(/\0/g,"");for(var a,n,s,o=e.length,l="",d=0;d<o;){if(0===(a=e[d++])&&t)return l;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(a);break;case 12:case 13:n=e[d++],l+=String.fromCharCode((31&a)<<6|63&n);break;case 14:n=e[d++],s=e[d++],l+=String.fromCharCode((15&a)<<12|(63&n)<<6|(63&s)<<0)}}return l},o}();var i=r._utf8ArrayToStr;t.default=r},"./src/demux/mp4demuxer.js":function(e,t,r){"use strict";r.r(t);var n=r("./src/utils/logger.js"),o=r("./src/events.js"),s=Math.pow(2,32)-1;t.default=function(){function h(e,t){this.observer=e,this.remuxer=t}var e=h.prototype;return e.resetTimeStamp=function(e){this.initPTS=e},e.resetInitSegment=function(e,t,r,i){var a,n;e&&e.byteLength?(null==t&&(t="mp4a.40.5"),null==r&&(r="avc1.42e01e"),n={},(a=this.initData=h.parseInitSegment(e)).audio&&a.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:i?e:null}:(a.audio&&(n.audio={container:"audio/mp4",codec:t,initSegment:i?e:null}),a.video&&(n.video={container:"video/mp4",codec:r,initSegment:i?e:null})),this.observer.trigger(o.default.FRAG_PARSING_INIT_SEGMENT,{tracks:n})):(t&&(this.audioCodec=t),r&&(this.videoCodec=r))},h.probe=function(e){return 0<h.findBox({data:e,start:0,end:Math.min(e.length,16384)},["moof"]).length},h.bin2str=function(e){return String.fromCharCode.apply(null,e)},h.readUint16=function(e,t){e.data&&(t+=e.start,e=e.data);e=e[t]<<8|e[t+1];return e<0?65536+e:e},h.readUint32=function(e,t){e.data&&(t+=e.start,e=e.data);e=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return e<0?4294967296+e:e},h.writeUint32=function(e,t,r){e.data&&(t+=e.start,e=e.data),e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r},h.findBox=function(e,t){var r,i,a,n,s,o=[];if(e.data?(n=e.start,i=e.end,e=e.data):(n=0,i=e.byteLength),!t.length)return null;for(r=n;r<i;)s=1<(s=h.readUint32(e,r))?r+s:i,h.bin2str(e.subarray(r+4,r+8))===t[0]&&(1===t.length?o.push({data:e,start:r+8,end:s}):(a=h.findBox({data:e,start:r+8,end:s},t.slice(1))).length&&(o=o.concat(a))),r=s;return o},h.parseSegmentIndex=function(e){var t=h.findBox(e,["moov"])[0],t=t?t.end:null,r=0,i=h.findBox(e,["sidx"]);if(!i||!i[0])return null;var a=[],e=(i=i[0]).data[0],r=0===e?8:16,n=h.readUint32(i,r),s=i.end+0,u=h.readUint16(i,r=(r+=4)+(0===e?8:16)+2);r+=2;for(var c=0;c<u;c++){var o=r,l=h.readUint32(i,o),d=2147483647&l;if(1==(2147483648&l)>>>31)return;l=h.readUint32(i,o+=4);o+=4,a.push({referenceSize:d,subsegmentDuration:l,info:{duration:l/n,start:s,end:s+d-1}}),s+=d,r=o+=4}return{earliestPresentationTime:0,timescale:n,version:e,referencesCount:u,references:a,moovEndOffset:t}},h.parseInitSegment=function(e){var a=[];return h.findBox(e,["moov","trak"]).forEach(function(e){var t,r,i=h.findBox(e,["tkhd"])[0];i&&(r=i.data[i.start],i=h.readUint32(i,0===r?12:20),(t=h.findBox(e,["mdia","mdhd"])[0])&&(r=t.data[t.start],t=h.readUint32(t,0===r?12:20),!(r=h.findBox(e,["mdia","hdlr"])[0])||(r={soun:"audio",vide:"video"}[h.bin2str(r.data.subarray(r.start+8,r.start+12))])&&((e=h.findBox(e,["mdia","minf","stbl","stsd"])).length&&(e=e[0],e=h.bin2str(e.data.subarray(e.start+12,e.start+16)),n.logger.log("MP4Demuxer:"+r+":"+e+" found")),a[i]={timescale:t,type:r},a[r]={timescale:t,id:i})))}),a},h.getStartDTS=function(r,e){e=h.findBox(e,["moof","traf"]),e=[].concat.apply([],e.map(function(t){return h.findBox(t,["tfhd"]).map(function(e){e=h.readUint32(e,4),e=r[e].timescale||9e4;return h.findBox(t,["tfdt"]).map(function(e){var t=e.data[e.start],r=h.readUint32(e,4);return r=1===t?(r*=Math.pow(2,32))+h.readUint32(e,8):r})[0]/e})})),e=Math.min.apply(null,e);return isFinite(e)?e:0},h.offsetStartDTS=function(r,e,a){h.findBox(e,["moof","traf"]).map(function(t){return h.findBox(t,["tfhd"]).map(function(e){var e=h.readUint32(e,4),i=r[e].timescale||9e4;h.findBox(t,["tfdt"]).map(function(e){var t=e.data[e.start],r=h.readUint32(e,4);0===t?h.writeUint32(e,4,r-a*i):(r=(r=(r*=Math.pow(2,32))+h.readUint32(e,8))-a*i,r=Math.max(r,0),t=Math.floor(r/(1+s)),r=Math.floor(r%(1+s)),h.writeUint32(e,4,t),h.writeUint32(e,8,r))})})})},e.append=function(e,t,r,i){var a=this.initData;a||(this.resetInitSegment(e,this.audioCodec,this.videoCodec,!1),a=this.initData);var n,s=this.initPTS;void 0===s&&(n=h.getStartDTS(a,e),this.initPTS=s=n-t,this.observer.trigger(o.default.INIT_PTS_FOUND,{initPTS:s})),h.offsetStartDTS(a,e,s),n=h.getStartDTS(a,e),this.remuxer.remux(a.audio,a.video,null,null,n,r,i,e)},e.destroy=function(){},h}()},"./src/errors.ts":function(e,t,r){"use strict";var i,a;r.r(t),r.d(t,"ErrorTypes",function(){return i}),r.d(t,"ErrorDetails",function(){return a}),(r=i=i||{}).NETWORK_ERROR="networkError",r.MEDIA_ERROR="mediaError",r.KEY_SYSTEM_ERROR="keySystemError",r.MUX_ERROR="muxError",r.OTHER_ERROR="otherError",(t=a=a||{}).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException"},"./src/events.js":function(e,t,r){"use strict";r.r(t);t.default={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",LIVE_BACK_BUFFER_REACHED:"hlsLiveBackBufferReached"}},"./src/hls.ts":function(t,r,e){"use strict";e.r(r);var f,s,i={},a=(e.r(i),e.d(i,"newCue",function(){return ht}),e("./node_modules/url-toolkit/src/url-toolkit.js")),d=e("./src/errors.ts"),w=e("./src/polyfills/number-isFinite.js"),E=e("./src/events.js"),D=e("./src/utils/logger.js"),o={hlsEventGeneric:!0,hlsHandlerDestroying:!0,hlsHandlerDestroyed:!0},n=function(){function e(e){this.hls=void 0,this.handledEvents=void 0,this.useGenericHandler=void 0,this.hls=e,this.onEvent=this.onEvent.bind(this);for(var t=arguments.length,r=new Array(1<t?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];this.handledEvents=r,this.useGenericHandler=!0,this.registerListeners()}var t=e.prototype;return t.destroy=function(){this.onHandlerDestroying(),this.unregisterListeners(),this.onHandlerDestroyed()},t.onHandlerDestroying=function(){},t.onHandlerDestroyed=function(){},t.isEventHandler=function(){return"object"==typeof this.handledEvents&&this.handledEvents.length&&"function"==typeof this.onEvent},t.registerListeners=function(){this.isEventHandler()&&this.handledEvents.forEach(function(e){if(o[e])throw new Error("Forbidden event-name: "+e);this.hls.on(e,this.onEvent)},this)},t.unregisterListeners=function(){this.isEventHandler()&&this.handledEvents.forEach(function(e){this.hls.off(e,this.onEvent)},this)},t.onEvent=function(e,t){this.onEventGeneric(e,t)},t.onEventGeneric=function(t,e){try{!function(e,t){var r="on"+e.replace("hls","");if("function"!=typeof this[r])throw new Error("Event "+e+" has no generic handler in this "+this.constructor.name+" class (tried "+r+")");return this[r].bind(this,t)}.call(this,t,e).call()}catch(e){D.logger.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.OTHER_ERROR,details:d.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,err:e})}},e}(),u=((W=f=f||{}).MANIFEST="manifest",W.LEVEL="level",W.AUDIO_TRACK="audioTrack",W.SUBTITLE_TRACK="subtitleTrack",(W=s=s||{}).MAIN="main",W.AUDIO="audio",W.SUBTITLE="subtitle",e("./src/demux/mp4demuxer.js"));function c(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var h,O=function(){function e(e,t){this._uri=null,this.baseuri=void 0,this.reluri=void 0,this.method=null,this.key=null,this.iv=null,this.baseuri=e,this.reluri=t}var t,r,i;return t=e,(r=[{key:"uri",get:function(){return!this._uri&&this.reluri&&(this._uri=Object(a.buildAbsoluteURL)(this.baseuri,this.reluri,{alwaysNormalize:!0})),this._uri}}])&&c(t.prototype,r),i&&c(t,i),e}();function g(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(W=h=h||{}).AUDIO="audio",W.VIDEO="video";var C=function(){function e(){var e;this._url=null,this._byteRange=null,this._decryptdata=null,this._elementaryStreams=((e={})[h.AUDIO]=!1,e[h.VIDEO]=!1,e),this.deltaPTS=0,this.rawProgramDateTime=null,this.programDateTime=null,this.title=null,this.tagList=[],this.cc=void 0,this.type=void 0,this.relurl=void 0,this.baseurl=void 0,this.duration=void 0,this.start=void 0,this.sn=0,this.urlId=0,this.level=0,this.levelkey=void 0,this.loader=void 0}var t,r,i=e.prototype;return i.setByteRange=function(e,t){var e=e.split("@",2),r=[];1===e.length?r[0]=t?t.byteRangeEndOffset:0:r[0]=parseInt(e[1]),r[1]=parseInt(e[0])+r[0],this._byteRange=r},i.addElementaryStream=function(e){this._elementaryStreams[e]=!0},i.hasElementaryStream=function(e){return!0===this._elementaryStreams[e]},i.createInitializationVector=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t},i.setDecryptDataFromLevelKey=function(e,t){var r=e;return e&&e.method&&e.uri&&!e.iv&&((r=new O(e.baseuri,e.reluri)).method=e.method,r.iv=this.createInitializationVector(t)),r},i=e,(t=[{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=Object(a.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(e){this._url=e}},{key:"byteRange",get:function(){return this._byteRange||[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"decryptdata",get:function(){return this.levelkey||this._decryptdata?(!this._decryptdata&&this.levelkey&&("number"!=typeof(e=this.sn)&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&D.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),e=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,e)),this._decryptdata):null;var e}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(w.isFiniteNumber)(this.programDateTime))return null;var e=Object(w.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){return!(!this.decryptdata||null===this.decryptdata.uri||null!==this.decryptdata.key)}}])&&g(i.prototype,t),r&&g(i,r),e}();function m(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var I=function(){function e(e){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=e,this.version=null}var t,r,i;return t=e,(r=[{key:"hasProgramDateTime",get:function(){return!(!this.fragments[0]||!Object(w.isFiniteNumber)(this.fragments[0].programDateTime))}}])&&m(t.prototype,r),i&&m(t,i),e}(),v=/^(\d+)x(\d+)$/,y=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,x=function(){function r(e){for(var t in e="string"==typeof e?r.parseAttrList(e):e)e.hasOwnProperty(t)&&(this[t]=e[t])}var e=r.prototype;return e.decimalInteger=function(e){e=parseInt(this[e],10);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.hexadecimalInteger=function(e){if(this[e]){for(var t=(1&(t=(this[e]||"0x").slice(2)).length?"0":"")+t,r=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null},e.hexadecimalIntegerAsNumber=function(e){e=parseInt(this[e],16);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.decimalFloatingPoint=function(e){return parseFloat(this[e])},e.enumeratedString=function(e){return this[e]},e.decimalResolution=function(e){e=v.exec(this[e]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},r.parseAttrList=function(e){var t,r={};for(y.lastIndex=0;null!==(t=y.exec(e));){var i=t[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1]]=i}return r},r}(),b={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 S(e,t){return MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}var _=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g,R=/#EXT-X-MEDIA:(.*)/g,P=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)([\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),F=/(?:(?:#(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?/,M=/\.(mp4|m4s|m4v|m4a)$/i,A=function(){function l(){}return l.findGroup=function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}},l.convertAVC1ToAVCOTI=function(e){var t=e.split("."),r=2<t.length?(r=t.shift()+".",(r+=parseInt(t.shift()).toString(16))+("000"+parseInt(t.shift()).toString(16)).substr(-4)):e;return r},l.resolve=function(e,t){return a.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},l.parseMasterPlaylist=function(e,t){var r=[];function i(i,a){["video","audio"].forEach(function(r){var e,t=i.filter(function(e){return e=e,!!(t=b[t=r])&&!0===t[e.slice(0,4)];var t});t.length&&(e=t.filter(function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)}),a[r+"Codec"]=(0<e.length?e:t)[0],i=i.filter(function(e){return-1===t.indexOf(e)}))}),a.unknownCodecs=i}for(_.lastIndex=0;null!=(s=_.exec(e));){var a={},n=a.attrs=new x(s[1]),s=(a.url=l.resolve(s[2],t),n.decimalResolution("RESOLUTION"));s&&(a.width=s.width,a.height=s.height),a.bitrate=n.decimalInteger("AVERAGE-BANDWIDTH")||n.decimalInteger("BANDWIDTH"),a.name=n.NAME,i([].concat((n.CODECS||"").split(/[ ,]+/)),a),a.videoCodec&&-1!==a.videoCodec.indexOf("avc1")&&(a.videoCodec=l.convertAVC1ToAVCOTI(a.videoCodec)),r.push(a)}return r},l.parseMasterPlaylistMedia=function(e,t,r,i){void 0===i&&(i=[]);var a=[],n=0;for(R.lastIndex=0;null!==(o=R.exec(e));){var s,o=new x(o[1]);o.TYPE===r&&(s={id:n++,groupId:o["GROUP-ID"],name:o.NAME||o.LANGUAGE,type:r,default:"YES"===o.DEFAULT,autoselect:"YES"===o.AUTOSELECT,forced:"YES"===o.FORCED,lang:o.LANGUAGE},o.URI&&(s.url=l.resolve(o.URI,t)),i.length&&(o=l.findGroup(i,s.groupId),s.audioCodec=(o||i[0]).codec),a.push(s))}return a},l.parseLevelPlaylist=function(u,e,c,h,f){var t,r,i,g=0,p=0,a=new I(e),m=0,v=null,n=new C,y=null;for(P.lastIndex=0;null!==(t=P.exec(u));){var s=t[1];if(s){n.duration=parseFloat(s);var E=(" "+t[2]).slice(1);n.title=E||null,n.tagList.push(E?["INF",s,E]:["INF",s])}else if(t[3])Object(w.isFiniteNumber)(n.duration)&&(E=g++,n.type=h,n.start=p,i&&(n.levelkey=i),n.sn=E,n.level=c,n.cc=m,n.urlId=f,n.baseurl=e,n.relurl=(" "+t[3]).slice(1),o=s=void 0,o=v,(s=n).rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):o&&o.programDateTime&&(s.programDateTime=o.endProgramDateTime),Object(w.isFiniteNumber)(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null),a.fragments.push(n),p+=(v=n).duration,n=new C);else if(t[4]){var o=(" "+t[4]).slice(1);v?n.setByteRange(o,v):n.setByteRange(o)}else if(t[5])n.rawProgramDateTime=(" "+t[5]).slice(1),n.tagList.push(["PROGRAM-DATE-TIME",n.rawProgramDateTime]),null===y&&(y=a.fragments.length);else if(t=t[0].match(F)){for(r=1;r<t.length&&void 0===t[r];r++);var l=(" "+t[r+1]).slice(1),T=(" "+t[r+2]).slice(1);switch(t[r]){case"#":n.tagList.push(T?[l,T]:[l]);break;case"PLAYLIST-TYPE":a.type=l.toUpperCase();break;case"MEDIA-SEQUENCE":g=a.startSN=parseInt(l);break;case"TARGETDURATION":a.targetduration=parseFloat(l);break;case"VERSION":a.version=parseInt(l);break;case"EXTM3U":break;case"ENDLIST":a.live=!1;break;case"DIS":m++,n.tagList.push(["DIS"]);break;case"DISCONTINUITY-SEQ":m=parseInt(l);break;case"KEY":var b=new x(l),d=b.enumeratedString("METHOD"),S=b.URI,b=b.hexadecimalInteger("IV");d&&(i=new O(e,S),S&&0<=["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(d)&&(i.method=d,i.key=null,i.iv=b));break;case"START":S=new x(l).decimalFloatingPoint("TIME-OFFSET");Object(w.isFiniteNumber)(S)&&(a.startTimeOffset=S);break;case"MAP":d=new x(l);n.relurl=d.URI,d.BYTERANGE&&n.setByteRange(d.BYTERANGE),n.baseurl=e,n.level=c,n.type=h,n.sn="initSegment",a.initSegment=n,(n=new C).rawProgramDateTime=a.initSegment.rawProgramDateTime;break;default:D.logger.warn("line parsed but not handled: "+t)}}else D.logger.warn("No matches on slow regex match for level playlist!")}if((n=v)&&!n.relurl&&(a.fragments.pop(),p-=n.duration),a.totalduration=p,a.averagetargetduration=p/a.fragments.length,a.endSN=g-1,a.startCC=a.fragments[0]?a.fragments[0].cc:0,a.endCC=m,!a.initSegment&&a.fragments.length&&a.fragments.every(function(e){return M.test(e.relurl)})&&(D.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(n=new C).relurl=a.fragments[0].relurl,n.baseurl=e,n.level=c,n.type=h,n.sn="initSegment",a.initSegment=n,a.needSidxRanges=!0),y)for(var _=a.fragments,R=y,A=_[R],k=R-1;0<=k;k--){var L=_[k];L.programDateTime=A.programDateTime-1e3*L.duration,A=L}return a},l}();var k=window.performance,L=function(t){var e;function h(e){e=t.call(this,e,E.default.MANIFEST_LOADING,E.default.LEVEL_LOADING,E.default.AUDIO_TRACK_LOADING,E.default.SUBTITLE_TRACK_LOADING)||this;return e.loaders={},e}e=t,(r=h).prototype=Object.create(e.prototype),(r.prototype.constructor=r).__proto__=e,h.canHaveQualityLevels=function(e){return e!==f.AUDIO_TRACK&&e!==f.SUBTITLE_TRACK},h.mapContextToLevelType=function(e){switch(e.type){case f.AUDIO_TRACK:return s.AUDIO;case f.SUBTITLE_TRACK:return s.SUBTITLE;default:return s.MAIN}},h.getResponseUrl=function(e,t){e=e.url;return e=void 0===e||0===e.indexOf("data:")?t.url:e};var r=h.prototype;return r.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,r=new(r||i)(t);return e.loader=r,this.loaders[e.type]=r},r.getInternalLoader=function(e){return this.loaders[e.type]},r.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},r.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},r.destroy=function(){this.destroyInternalLoaders(),t.prototype.destroy.call(this)},r.onManifestLoading=function(e){this.load({url:e.url,type:f.MANIFEST,level:0,id:null,responseType:"text"})},r.onLevelLoading=function(e){this.load({url:e.url,type:f.LEVEL,level:e.level,id:e.id,responseType:"text"})},r.onAudioTrackLoading=function(e){this.load({url:e.url,type:f.AUDIO_TRACK,level:null,id:e.id,responseType:"text"})},r.onSubtitleTrackLoading=function(e){this.load({url:e.url,type:f.SUBTITLE_TRACK,level:null,id:e.id,responseType:"text"})},r.load=function(e){var t,r,i,a,n=this.hls.config;if(D.logger.debug("Loading playlist of type "+e.type+", level: "+e.level+", id: "+e.id),o=this.getInternalLoader(e)){var s=o.context;if(s&&s.url===e.url)return D.logger.trace("playlist request ongoing"),!1;D.logger.warn("aborting previous loader for type: "+e.type),o.abort()}switch(e.type){case f.MANIFEST:t=n.manifestLoadingMaxRetry,r=n.manifestLoadingTimeOut,i=n.manifestLoadingRetryDelay,a=n.manifestLoadingMaxRetryTimeout;break;case f.LEVEL:i=a=t=0,r=n.levelLoadingTimeOut;break;default:t=n.levelLoadingMaxRetry,r=n.levelLoadingTimeOut,i=n.levelLoadingRetryDelay,a=n.levelLoadingMaxRetryTimeout}var o=this.createInternalLoader(e),s={timeout:r,maxRetry:t,retryDelay:i,maxRetryDelay:a},l={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};return D.logger.debug("Calling internal loader delegate for URL: "+e.url),o.load(e,s,l),!0},r.loadsuccess=function(e,t,r,i){if(void 0===i&&(i=null),r.isSidxRequest)return this._handleSidxRequest(e,r),void this._handlePlaylistLoaded(e,t,r,i);if(this.resetInternalLoader(r.type),"string"!=typeof e.data)throw new Error('expected responseType of "text" for PlaylistLoader');var a=e.data;t.tload=k.now(),0===a.indexOf("#EXTM3U")?0<a.indexOf("#EXTINF:")||0<a.indexOf("#EXT-X-TARGETDURATION:")?this._handleTrackOrLevelPlaylist(e,t,r,i):this._handleMasterPlaylist(e,t,r,i):this._handleManifestParsingError(e,r,"no EXTM3U delimiter",i)},r.loaderror=function(e,t,r){this._handleNetworkError(t,r=void 0===r?null:r,!1,e)},r.loadtimeout=function(e,t,r){this._handleNetworkError(t,r=void 0===r?null:r,!0)},r._handleMasterPlaylist=function(e,t,r,i){var a,n,s=this.hls,o=e.data,l=h.getResponseUrl(e,r),d=A.parseMasterPlaylist(o,l);d.length?(a=d.map(function(e){return{id:e.attrs.AUDIO,codec:e.audioCodec}}),a=A.parseMasterPlaylistMedia(o,l,"AUDIO",a),o=A.parseMasterPlaylistMedia(o,l,"SUBTITLES"),a.length&&(n=!1,a.forEach(function(e){e.url||(n=!0)}),!1===n&&d[0].audioCodec&&!d[0].attrs.AUDIO&&(D.logger.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),a.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1}))),s.trigger(E.default.MANIFEST_LOADED,{levels:d,audioTracks:a,subtitles:o,url:l,stats:t,networkDetails:i})):this._handleManifestParsingError(e,r,"no level found in manifest",i)},r._handleTrackOrLevelPlaylist=function(e,t,r,i){var u=this.hls,a=r.id,n=r.level,s=r.type,o=h.getResponseUrl(e,r),c=Object(w.isFiniteNumber)(a)?a:0,l=Object(w.isFiniteNumber)(n)?n:c,d=h.mapContextToLevelType(r),l=A.parseLevelPlaylist(e.data,o,l,d,c);if(l.tload=t.tload,s===f.MANIFEST&&u.trigger(E.default.MANIFEST_LOADED,{levels:[{url:o,details:l}],audioTracks:[],url:o,stats:t,networkDetails:i}),t.tparsed=k.now(),l.needSidxRanges)return d=l.initSegment.url,void this.load({url:d,isSidxRequest:!0,type:s,level:n,levelDetails:l,id:a,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer"});r.levelDetails=l,this._handlePlaylistLoaded(e,t,r,i)},r._handleSidxRequest=function(e,t){if("string"==typeof e.data)throw new Error("sidx request must be made with responseType of array buffer");var r,i,e=u.default.parseSegmentIndex(new Uint8Array(e.data));e&&(r=e.references,i=t.levelDetails,r.forEach(function(e,t){e=e.info;!i||0===(t=i.fragments[t]).byteRange.length&&t.setByteRange(String(1+e.end-e.start)+"@"+String(e.start))}),i&&i.initSegment.setByteRange(String(e.moovEndOffset)+"@0"))},r._handleManifestParsingError=function(e,t,r,i){this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.NETWORK_ERROR,details:d.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:e.url,reason:r,networkDetails:i})},r._handleNetworkError=function(e,t,r,i){void 0===r&&(r=!1),void 0===i&&(i=null),D.logger.info("A network error occured while loading a "+e.type+"-type playlist");var a,n,s=this.getInternalLoader(e);switch(e.type){case f.MANIFEST:a=r?d.ErrorDetails.MANIFEST_LOAD_TIMEOUT:d.ErrorDetails.MANIFEST_LOAD_ERROR,n=!0;break;case f.LEVEL:a=r?d.ErrorDetails.LEVEL_LOAD_TIMEOUT:d.ErrorDetails.LEVEL_LOAD_ERROR,n=!1;break;case f.AUDIO_TRACK:a=r?d.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,n=!1;break;default:n=!1}s&&(s.abort(),this.resetInternalLoader(e.type));s={type:d.ErrorTypes.NETWORK_ERROR,details:a,fatal:n,url:e.url,loader:s,context:e,networkDetails:t};i&&(s.response=i),this.hls.trigger(E.default.ERROR,s)},r._handlePlaylistLoaded=function(e,t,r,i){var a=r.type,n=r.level,s=r.id,o=r.levelDetails;if(o&&o.targetduration)if(h.canHaveQualityLevels(r.type))this.hls.trigger(E.default.LEVEL_LOADED,{details:o,level:n||0,id:s||0,stats:t,networkDetails:i});else switch(a){case f.AUDIO_TRACK:this.hls.trigger(E.default.AUDIO_TRACK_LOADED,{details:o,id:s,stats:t,networkDetails:i});break;case f.SUBTITLE_TRACK:this.hls.trigger(E.default.SUBTITLE_TRACK_LOADED,{details:o,id:s,stats:t,networkDetails:i})}else this._handleManifestParsingError(e,r,"invalid target duration",i)},h}(n);var N=function(i){var e;function t(e){e=i.call(this,e,E.default.FRAG_LOADING)||this;return e.loaders={},e}e=i,(r=t).prototype=Object.create(e.prototype),(r.prototype.constructor=r).__proto__=e;var r=t.prototype;return r.destroy=function(){var e,t=this.loaders;for(e in t){var r=t[e];r&&r.destroy()}this.loaders={},i.prototype.destroy.call(this)},r.onFragLoading=function(e){var e=e.frag,t=e.type,r=this.loaders,i=this.hls.config,a=i.fLoader,n=i.loader,s=(e.loaded=0,r[t]),t=(s&&(D.logger.warn("abort previous fragment loader for type: "+t),s.abort()),s=r[t]=e.loader=new(i.fLoader?a:n)(i),r={url:e.url,frag:e,responseType:"arraybuffer",progressData:!1},e.byteRangeStartOffset),a=e.byteRangeEndOffset;Object(w.isFiniteNumber)(t)&&Object(w.isFiniteNumber)(a)&&(r.rangeStart=t,r.rangeEnd=a),n={timeout:i.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:i.fragLoadingMaxRetryTimeout},e={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},s.load(r,n,e)},r.loadsuccess=function(e,t,r,i){void 0===i&&(i=null);e=e.data,r=r.frag;r.loader=void 0,this.loaders[r.type]=void 0,this.hls.trigger(E.default.FRAG_LOADED,{payload:e,frag:r,stats:t,networkDetails:i})},r.loaderror=function(e,t,r){void 0===r&&(r=null);var i=t.frag,a=i.loader;a&&a.abort(),this.loaders[i.type]=void 0,this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.NETWORK_ERROR,details:d.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t.frag,response:e,networkDetails:r})},r.loadtimeout=function(e,t,r){void 0===r&&(r=null);var i=t.frag,a=i.loader;a&&a.abort(),this.loaders[i.type]=void 0,this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.NETWORK_ERROR,details:d.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t.frag,networkDetails:r})},r.loadprogress=function(e,t,r,i){void 0===i&&(i=null);t=t.frag;t.loaded=e.loaded,this.hls.trigger(E.default.FRAG_LOAD_PROGRESS,{frag:t,stats:e,networkDetails:i})},t}(n);var U=function(t){var e;function r(e){e=t.call(this,e,E.default.KEY_LOADING)||this;return e.loaders={},e.decryptkey=null,e.decrypturl=null,e}e=t,(i=r).prototype=Object.create(e.prototype),(i.prototype.constructor=i).__proto__=e;var i=r.prototype;return i.destroy=function(){for(var e in this.loaders){e=this.loaders[e];e&&e.destroy()}this.loaders={},t.prototype.destroy.call(this)},i.onKeyLoading=function(e){var t,r,e=e.frag,i=e.type,a=this.loaders[i];e.decryptdata?(r=e.decryptdata.uri)!==this.decrypturl||null===this.decryptkey?(t=this.hls.config,a&&(D.logger.warn("abort previous key loader for type:"+i),a.abort()),r?(e.loader=this.loaders[i]=new t.loader(t),this.decrypturl=r,this.decryptkey=null,a={url:r,frag:e,responseType:"arraybuffer"},i={timeout:t.fragLoadingTimeOut,maxRetry:0,retryDelay:t.fragLoadingRetryDelay,maxRetryDelay:t.fragLoadingMaxRetryTimeout},r={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},e.loader.load(a,i,r)):D.logger.warn("key uri is falsy")):this.decryptkey&&(e.decryptdata.key=this.decryptkey,this.hls.trigger(E.default.KEY_LOADED,{frag:e})):D.logger.warn("Missing decryption data on fragment in onKeyLoading")},i.loadsuccess=function(e,t,r){r=r.frag;r.decryptdata?(this.decryptkey=r.decryptdata.key=new Uint8Array(e.data),r.loader=void 0,delete this.loaders[r.type],this.hls.trigger(E.default.KEY_LOADED,{frag:r})):D.logger.error("after key load, decryptdata unset")},i.loaderror=function(e,t){var t=t.frag,r=t.loader;r&&r.abort(),delete this.loaders[t.type],this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.NETWORK_ERROR,details:d.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:t,response:e})},i.loadtimeout=function(e,t){var t=t.frag,r=t.loader;r&&r.abort(),delete this.loaders[t.type],this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.NETWORK_ERROR,details:d.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:t})},r}(n);var B="NOT_LOADED",G="APPENDING",j="PARTIAL",K="OK",H=function(r){var e;function t(e){var t=r.call(this,e,E.default.BUFFER_APPENDED,E.default.FRAG_BUFFERED,E.default.FRAG_LOADED)||this;return t.bufferPadding=.2,t.fragments=Object.create(null),t.timeRanges=Object.create(null),t.config=e.config,t}e=r,(i=t).prototype=Object.create(e.prototype),(i.prototype.constructor=i).__proto__=e;var i=t.prototype;return i.destroy=function(){this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.config=null,n.prototype.destroy.call(this),r.prototype.destroy.call(this)},i.getBufferedFrag=function(t,r){var i=this.fragments,e=Object.keys(i).filter(function(e){e=i[e];if(e.body.type!==r)return!1;if(!e.buffered)return!1;e=e.body;return e.startPTS<=t&&t<=e.endPTS});return 0===e.length?null:(e=e.pop(),i[e].body)},i.detectEvictedFragments=function(i,a){var n,s,o=this;Object.keys(this.fragments).forEach(function(e){var t=o.fragments[e];if(!0===t.buffered){e=t.range[i];if(e){n=e.time;for(var r=0;r<n.length;r++)if(s=n[r],!1===o.isTimeBuffered(s.startPTS,s.endPTS,a)){o.removeFragment(t.body);break}}}})},i.detectPartialFragments=function(r){var i=this,e=this.getFragmentKey(r),a=this.fragments[e];a&&(a.buffered=!0,Object.keys(this.timeRanges).forEach(function(e){var t;r.hasElementaryStream(e)&&(t=i.timeRanges[e],a.range[e]=i.getBufferedTimes(r.startPTS,r.endPTS,t))}))},i.getBufferedTimes=function(e,t,r){for(var i,a,n=[],s=!1,o=0;o<r.length;o++){if(i=r.start(o)-this.bufferPadding,a=r.end(o)+this.bufferPadding,i<=e&&t<=a){n.push({startPTS:Math.max(e,r.start(o)),endPTS:Math.min(t,r.end(o))});break}if(e<a&&i<t)n.push({startPTS:Math.max(e,r.start(o)),endPTS:Math.min(t,r.end(o))}),s=!0;else if(t<=i)break}return{time:n,partial:s}},i.getFragmentKey=function(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn},i.getPartialFragment=function(t){var r,i,a=this,n=null,s=0;return Object.keys(this.fragments).forEach(function(e){e=a.fragments[e];a.isPartial(e)&&(r=e.body.startPTS-a.bufferPadding,i=e.body.endPTS+a.bufferPadding,r<=t&&t<=i&&(r=Math.min(t-r,i-t),s<=r&&(n=e.body,s=r)))}),n},i.getState=function(e){var e=this.getFragmentKey(e),e=this.fragments[e],t=B;return t=void 0!==e?e.buffered?!0===this.isPartial(e)?j:K:G:t},i.isPartial=function(e){return!0===e.buffered&&(void 0!==e.range.video&&!0===e.range.video.partial||void 0!==e.range.audio&&!0===e.range.audio.partial)},i.isTimeBuffered=function(e,t,r){for(var i,a,n=0;n<r.length;n++){if(i=r.start(n)-this.bufferPadding,a=r.end(n)+this.bufferPadding,i<=e&&t<=a)return!0;if(t<=i)return!1}return!1},i.onFragLoaded=function(e){e=e.frag;Object(w.isFiniteNumber)(e.sn)&&!e.bitrateTest&&(this.fragments[this.getFragmentKey(e)]={body:e,range:Object.create(null),buffered:!1})},i.onBufferAppended=function(e){var r=this;this.timeRanges=e.timeRanges,Object.keys(this.timeRanges).forEach(function(e){var t=r.timeRanges[e];r.detectEvictedFragments(e,t)})},i.onFragBuffered=function(e){this.detectPartialFragments(e.frag)},i.hasFragment=function(e){e=this.getFragmentKey(e);return void 0!==this.fragments[e]},i.removeFragment=function(e){e=this.getFragmentKey(e);delete this.fragments[e]},i.removeAllFragments=function(){this.fragments=Object.create(null)},t}(n),V={search:function(e,t){for(var r=0,i=e.length-1;r<=i;){var a,n,s=t(n=e[a=(r+i)/2|0]);if(0<s)r=1+a;else{if(!(s<0))return n;i=a-1}}return null}},Y=function(){function e(){}return e.isBuffered=function(e,t){try{if(e)for(var r=e.buffered,i=0;i<r.length;i++)if(t>=r.start(i)&&t<=r.end(i))return!0}catch(e){}return!1},e.bufferInfo=function(e,t,r){try{if(e){for(var i=e.buffered,a=[],n=0;n<i.length;n++)a.push({start:i.start(n),end:i.end(n)});return this.bufferedInfo(a,t,r)}}catch(e){}return{len:0,start:t,end:t,nextStart:void 0}},e.bufferedInfo=function(e,t,r){e.sort(function(e,t){var r=e.start-t.start;return r||t.end-e.end});var i=[];if(r)for(var a=0;a<e.length;a++){var n,s=i.length;s?(n=i[s-1].end,e[a].start-n<r?e[a].end>n&&(i[s-1].end=e[a].end):i.push(e[a])):i.push(e[a])}else i=e;for(var o,u=0,c=t,h=t,l=0;l<i.length;l++){var d=i[l].start,f=i[l].end;if(d<=t+r&&t<f)c=d,u=(h=f)-t;else if(t+r<d){o=d;break}}return{len:u,start:c,end:h,nextStart:o}},e}(),W=e("./node_modules/eventemitter3/index.js"),q=e("./node_modules/webworkify-webpack/index.js"),z=e("./src/demux/demuxer-inline.js");function X(){return window.MediaSource||window.WebKitMediaSource}var Q=e("./src/utils/get-self-scope.js");var $=function(e){var t,r;function i(){return e.apply(this,arguments)||this}return r=e,(t=i).prototype=Object.create(r.prototype),(t.prototype.constructor=t).__proto__=r,i.prototype.trigger=function(e){for(var t=arguments.length,r=new Array(1<t?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];this.emit.apply(this,[e,e].concat(r))},i}(W.EventEmitter),J=Object(Q.getSelfScope)(),Z=X()||{isTypeSupported:function(){return!1}},ee=function(){function e(r,e){function t(e,t){(t=t||{}).frag=a.frag,t.id=a.id,r.trigger(e,t)}var i,a=this,n=(this.hls=r,this.id=e,this.observer=new $),s=r.config,o=(n.on(E.default.FRAG_DECRYPTED,t),n.on(E.default.FRAG_PARSING_INIT_SEGMENT,t),n.on(E.default.FRAG_PARSING_DATA,t),n.on(E.default.FRAG_PARSED,t),n.on(E.default.ERROR,t),n.on(E.default.FRAG_PARSING_METADATA,t),n.on(E.default.FRAG_PARSING_USERDATA,t),n.on(E.default.INIT_PTS_FOUND,t),{mp4:Z.isTypeSupported("video/mp4"),mpeg:Z.isTypeSupported("audio/mpeg"),mp3:Z.isTypeSupported('audio/mp4; codecs="mp3"')}),l=navigator.vendor;if(s.enableWorker&&"undefined"!=typeof Worker){D.logger.log("demuxing in webworker");try{i=this.w=q("./src/demux/demuxer-worker.js"),this.onwmsg=this.onWorkerMessage.bind(this),i.addEventListener("message",this.onwmsg),i.onerror=function(e){r.trigger(E.default.ERROR,{type:d.ErrorTypes.OTHER_ERROR,details:d.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",err:{message:e.message+" ("+e.filename+":"+e.lineno+")"}})},i.postMessage({cmd:"init",typeSupported:o,vendor:l,id:e,config:JSON.stringify(s)})}catch(e){D.logger.warn("Error in worker:",e),D.logger.error("Error while initializing DemuxerWorker, fallback on DemuxerInline"),i&&J.URL.revokeObjectURL(i.objectURL),this.demuxer=new z.default(n,o,s,l),this.w=void 0}}else this.demuxer=new z.default(n,o,s,l)}var t=e.prototype;return t.destroy=function(){var e=this.w,e=(e?(e.removeEventListener("message",this.onwmsg),e.terminate(),this.w=null):(e=this.demuxer)&&(e.destroy(),this.demuxer=null),this.observer);e&&(e.removeAllListeners(),this.observer=null)},t.push=function(e,t,r,i,a,n,s,u){var c=this.w,h=Object(w.isFiniteNumber)(a.startPTS)?a.startPTS:a.start,f=a.decryptdata,o=this.frag,l=!(o&&a.cc===o.cc),d=!(o&&a.level===o.level),o=o&&a.sn===o.sn+1,o=!d&&o;l&&D.logger.log(this.id+":discontinuity detected"),d&&D.logger.log(this.id+":switch detected"),this.frag=a,c?c.postMessage({cmd:"demux",data:e,decryptdata:f,initSegment:t,audioCodec:r,videoCodec:i,timeOffset:h,discontinuity:l,trackSwitch:d,contiguous:o,duration:n,accurateTimeOffset:s,defaultInitPTS:u},e instanceof ArrayBuffer?[e]:[]):(a=this.demuxer)&&a.push(e,f,t,r,i,h,l,d,o,n,s,u)},t.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":J.URL.revokeObjectURL(this.w.objectURL);break;case E.default.FRAG_PARSING_DATA:t.data.data1=new Uint8Array(t.data1),t.data2&&(t.data.data2=new Uint8Array(t.data2));default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}},e}();function te(e,t,r){switch(t){case"audio":e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds.push(r);break;case"text":e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds.push(r)}}function re(e,t,r){var i=e[t],e=e[r],a=e.startPTS;Object(w.isFiniteNumber)(a)?t<r?(i.duration=a-i.start,i.duration<0&&D.logger.warn("negative duration computed for frag "+i.sn+",level "+i.level+", there should be some duration drift between playlist and fragment!")):(e.duration=i.start-a,e.duration<0&&D.logger.warn("negative duration computed for frag "+e.sn+",level "+e.level+", there should be some duration drift between playlist and fragment!")):e.start=t<r?i.start+i.duration:Math.max(i.start-e.duration,0)}function ie(e,t,r,i,a,n){var s,o,l=r,d=(Object(w.isFiniteNumber)(t.startPTS)&&(d=Math.abs(t.startPTS-r),Object(w.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(d,t.deltaPTS):t.deltaPTS=d,l=Math.max(r,t.startPTS),r=Math.min(r,t.startPTS),i=Math.max(i,t.endPTS),a=Math.min(a,t.startDTS),n=Math.max(n,t.endDTS)),r-t.start),l=(t.start=t.startPTS=r,t.maxStartPTS=l,t.endPTS=i,t.startDTS=a,t.endDTS=n,t.duration=i-r,t.sn);if(!e||l<e.startSN||l>e.endSN)return 0;for(a=l-e.startSN,(s=e.fragments)[a]=t,o=a;0<o;o--)re(s,o,o-1);for(o=a;o<s.length-1;o++)re(s,o,o+1);return e.PTSKnown=!0,d}function ae(e,r){r.initSegment&&e.initSegment&&(r.initSegment=e.initSegment);var i,a=0;if(ne(e,r,function(e,t){a=e.cc-t.cc,Object(w.isFiniteNumber)(e.startPTS)&&(t.start=t.startPTS=e.startPTS,t.endPTS=e.endPTS,t.duration=e.duration,t.backtracked=e.backtracked,t.dropped=e.dropped,i=t),r.PTSKnown=!0}),r.PTSKnown){if(a){D.logger.log("discontinuity sliding from playlist, take drift into account");for(var t=r.fragments,n=0;n<t.length;n++)t[n].cc+=a}if(i)ie(r,i,i.startPTS,i.endPTS,i.startDTS,i.endDTS);else{var s=e,o=r,l=o.startSN-s.startSN,u=s.fragments,c=o.fragments;if(!(l<0||l>u.length))for(var d=0;d<c.length;d++)c[d].start+=u[l].start}r.PTSKnown=e.PTSKnown}}function ne(e,t,r){if(e&&t)for(var i=Math.max(e.startSN,t.startSN)-t.startSN,a=Math.min(e.endSN,t.endSN)-t.startSN,n=t.startSN-e.startSN,s=i;s<=a;s++){var o=e.fragments[n+s],l=t.fragments[s];if(!o||!l)break;r(o,l,s)}}function se(e,t,r){var i=1e3*(t.averagetargetduration||t.targetduration),a=i/2;return e&&t.endSN===e.endSN&&(i=a),r&&(i=Math.max(a,i-(window.performance.now()-r))),Math.round(i)}var oe={toString:function(e){for(var t="",r=e.length,i=0;i<r;i++)t+="["+e.start(i).toFixed(3)+","+e.end(i).toFixed(3)+"]";return t}};function le(e,t){e=e.fragments,t=t.fragments;if(t.length&&e.length){e=function(e,t){for(var r=null,i=0;i<e.length;i+=1){var a=e[i];if(a&&a.cc===t){r=a;break}}return r}(e,t[0].cc);if(e&&e.startPTS)return e;D.logger.log("No frag in previous level to align on")}else D.logger.log("No fragments to align")}function de(r,e){e.fragments.forEach(function(e){var t;e&&(t=e.start+r,e.start=e.startPTS=t,e.endPTS=t+e.duration)}),e.PTSKnown=!0}function ue(e,t,r){var i,a;!function(e,t,r){var i=!1;return i=t&&t.details&&r&&(r.endCC>r.startCC||e&&e.cc<r.startCC)?!0:i}(e=e,i=t,a=r)||(e=le(i.details,a))&&(D.logger.log("Adjusting PTS using last level due to CC increase within current level"),de(e.start,a)),!r.PTSKnown&&t&&(i=r,(e=t.details)&&e.fragments.length&&i.hasProgramDateTime&&e.hasProgramDateTime&&(a=e.fragments[0].programDateTime,a=(i.fragments[0].programDateTime-a)/1e3+e.fragments[0].start,Object(w.isFiniteNumber)(a)&&(D.logger.log("adjusting PTS using programDateTime delta, sliding:"+a.toFixed(3)),de(a,i))))}function ce(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!Object(w.isFiniteNumber)(t))return null;if(t<(e[0].programDateTime||0))return null;if((e[e.length-1].endProgramDateTime||0)<=t)return null;r=r||0;for(var i=0;i<e.length;++i){var a=e[i];if(function(e,t,r){t=1e3*Math.min(t,r.duration+(r.deltaPTS||0));return(r.endProgramDateTime||0)-t>e}(t,r,a))return a}return null}function he(e,t,r,i){void 0===r&&(r=0),void 0===i&&(i=0);e=e?t[e.sn-t[0].sn+1]:null;return e&&!fe(r,i,e)?e:V.search(t,fe.bind(null,r,i))}function fe(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0);t=Math.min(t,r.duration+(r.deltaPTS||0));return r.start+r.duration-t<=e?1:r.start-t>e&&r.start?-1:0}var ge=function(){function e(e,t,r,i){this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1}var t=e.prototype;return t.poll=function(e){var t=this.config,r=this.media,i=this.stalled,a=r.currentTime,n=r.seeking,s=this.seeking&&!n,o=!this.seeking&&n;if(this.seeking=n,a!==e)return this.moved=!0,void(null!==i&&(this.stallReported&&(e=self.performance.now()-i,D.logger.warn("playback not stuck anymore @"+a+", after "+Math.round(e)+"ms"),this.stallReported=!1),this.stalled=null,this.nudgeRetry=0));if((o||s)&&(this.stalled=null),!r.paused&&!r.ended&&0!==r.playbackRate&&r.buffered.length){e=Y.bufferInfo(r,a,0),o=0<e.len,s=e.nextStart||0;if(o||s){if(n){if(2<e.len||(!s||2<s-a))return;this.moved=!1}if(!this.moved&&this.stalled){o=Math.max(s,e.start||0)-a;if(0<o&&o<=2)return void this._trySkipBufferHole(null)}s=self.performance.now();null!==i?(o=s-i,!n&&250<=o&&this._reportStall(e.len),i=Y.bufferInfo(r,a,t.maxBufferHole),this._tryFixBufferStall(i,o)):this.stalled=s}}},t._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,a=this.media.currentTime,i=i.getPartialFragment(a);if(i&&this._trySkipBufferHole(i))return;e.len>r.maxBufferHole&&t>1e3*r.highBufferWatchdogPeriod&&(D.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},t._reportStall=function(e){var t=this.hls,r=this.media;this.stallReported||(this.stallReported=!0,D.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer"),t.trigger(E.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))},t._trySkipBufferHole=function(e){for(var t=this.config,r=this.hls,i=this.media,a=i.currentTime,n=0,s=0;s<i.buffered.length;s++){var o=i.buffered.start(s);if(a+t.maxBufferHole>=n&&a<o)return o=Math.max(o+.05,i.currentTime+.1),D.logger.warn("skipping hole, adjusting currentTime from "+a+" to "+o),this.moved=!0,this.stalled=null,i.currentTime=o,e&&r.trigger(E.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+a+" to "+o,frag:e}),o;n=i.buffered.end(s)}return 0},t._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=r.currentTime,a=(this.nudgeRetry||0)+1;(this.nudgeRetry=a)<e.nudgeMaxRetry?(a=i+a*e.nudgeOffset,D.logger.warn("Nudging 'currentTime' from "+i+" to "+a),r.currentTime=a,t.trigger(E.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})):(D.logger.error("Playhead still not moving while enough data buffered @"+i+" after "+e.nudgeMaxRetry+" nudges"),t.trigger(E.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0}))},e}();W=function(a){var e;function t(e){for(var t=arguments.length,r=new Array(1<t?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return(e=a.call.apply(a,[this,e].concat(r))||this)._boundTick=void 0,e._tickTimer=null,e._tickInterval=null,e._tickCallCount=0,e._boundTick=e.tick.bind(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)),e}e=a,(r=t).prototype=Object.create(e.prototype),(r.prototype.constructor=r).__proto__=e;var r=t.prototype;return r.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},r.hasInterval=function(){return!!this._tickInterval},r.hasNextTick=function(){return!!this._tickTimer},r.setInterval=function(e){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,e),!0)},r.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),!(this._tickInterval=null))},r.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),!(this._tickTimer=null))},r.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),1<this._tickCallCount&&(this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)),this._tickCallCount=0)},r.doTick=function(){},t}(n);var pe="STOPPED",me="STARTING",T="IDLE",ve="PAUSED",ye="KEY_LOADING",Ee="FRAG_LOADING",Te="FRAG_LOADING_WAITING_RETRY",be="WAITING_TRACK",Se="PARSING",_e="PARSED",Re="BUFFER_FLUSHING",Ae="ENDED",ke="ERROR",Le="WAITING_INIT_PTS",we="WAITING_LEVEL",Q=function(e){var t;function r(){return e.apply(this,arguments)||this}t=e,(i=r).prototype=Object.create(t.prototype),(i.prototype.constructor=i).__proto__=t;var i=r.prototype;return i.doTick=function(){},i.startLoad=function(){},i.stopLoad=function(){var e=this.fragCurrent;e&&(e.loader&&e.loader.abort(),this.fragmentTracker.removeFragment(e)),this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=pe},i._streamEnded=function(e,t){var r=this.fragCurrent,i=this.fragmentTracker;return!(t.live||!r||r.backtracked||r.sn!==t.endSN||e.nextStart)&&((t=i.getState(r))===j||t===K)},i.onMediaSeeking=function(){var e,t,r=this.config,i=this.media,a=this.mediaBuffer,n=this.state,s=i?i.currentTime:null,a=Y.bufferInfo(a||i,s,this.config.maxBufferHole);Object(w.isFiniteNumber)(s)&&D.logger.log("media seeking to "+s.toFixed(3)),n===Ee?(e=this.fragCurrent,0===a.len&&e&&(r=r.maxFragLookUpTolerance,t=e.start-r,r=e.start+e.duration+r,s<t||r<s?(e.loader&&(D.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=T):D.logger.log("seeking outside of buffer but within currently loaded fragment range"))):n===Ae&&(0===a.len&&(this.fragPrevious=null,this.fragCurrent=null),this.state=T),i&&(this.lastCurrentTime=s),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=s),this.tick()},i.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},i.onHandlerDestroying=function(){this.stopLoad(),e.prototype.onHandlerDestroying.call(this)},i.onHandlerDestroyed=function(){this.state=pe,this.fragmentTracker=null},i.computeLivePosition=function(e,t){var r=void 0!==this.config.liveSyncDuration?this.config.liveSyncDuration:this.config.liveSyncDurationCount*t.targetduration;return e+Math.max(0,t.totalduration-r)},r}(W);function De(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var Oe=function(i){function e(e,t){var r=i.call(this,e,E.default.MEDIA_ATTACHED,E.default.MEDIA_DETACHING,E.default.MANIFEST_LOADING,E.default.MANIFEST_PARSED,E.default.LEVEL_LOADED,E.default.KEY_LOADED,E.default.FRAG_LOADED,E.default.FRAG_LOAD_EMERGENCY_ABORTED,E.default.FRAG_PARSING_INIT_SEGMENT,E.default.FRAG_PARSING_DATA,E.default.FRAG_PARSED,E.default.ERROR,E.default.AUDIO_TRACK_SWITCHING,E.default.AUDIO_TRACK_SWITCHED,E.default.BUFFER_CREATED,E.default.BUFFER_APPENDED,E.default.BUFFER_FLUSHED)||this;return r.fragmentTracker=t,r.config=e.config,r.audioCodecSwap=!1,r._state=pe,r.stallReported=!1,r.gapController=null,r.altAudio=!1,r}t=i,(a=e).prototype=Object.create(t.prototype),(a.prototype.constructor=a).__proto__=t;var t,r,a=e.prototype;return a.startLoad=function(e){var t,r,i;this.levels?(t=this.lastCurrentTime,r=this.hls,this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,this.startFragRequested||(-1===(i=r.startLevel)&&(this.bitrateTest=!(i=0)),this.level=r.nextLoadLevel=i,this.loadedmetadata=!1),0<t&&-1===e&&(D.logger.log("override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=T,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()):(this.forceStartLoad=!0,this.state=pe)},a.stopLoad=function(){this.forceStartLoad=!1,i.prototype.stopLoad.call(this)},a.doTick=function(){switch(this.state){case Re:this.fragLoadError=0;break;case T:this._doTickIdle();break;case we:var e=this.levels[this.level];e&&e.details&&(this.state=T);break;case Te:var e=window.performance.now(),t=this.retryDate;(!t||t<=e||this.media&&this.media.seeking)&&(D.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=T)}this._checkBuffer(),this._checkFragmentChanged()},a._doTickIdle=function(){var e=this.hls,t=e.config,r=this.media;if(void 0!==this.levelLastLoaded&&(r||!this.startFragRequested&&t.startFragPrefetch)){var i=this.loadedmetadata?r.currentTime:this.nextLoadPosition,a=e.nextLoadLevel,n=this.levels[a];if(n){var s=n.bitrate,s=s?Math.max(8*t.maxBufferSize/s,t.maxBufferLength):t.maxBufferLength,r=(s=Math.min(s,t.maxMaxBufferLength),Y.bufferInfo(this.mediaBuffer||r,i,t.maxBufferHole)),t=r.len;if(!(s<=t)){D.logger.trace("buffer length of "+t.toFixed(3)+" is below max of "+s.toFixed(3)+". checking for more payload ..."),this.level=e.nextLoadLevel=a;t=n.details;if(t&&(!t.live||this.levelLastLoaded===a))return this._streamEnded(r,t)?(s={},this.altAudio&&(s.type="video"),this.hls.trigger(E.default.BUFFER_EOS,s),void(this.state=Ae)):void this._fetchPayloadOrEos(i,r,t);this.state=we}}}},a._fetchPayloadOrEos=function(u,e,t){var r=this.fragPrevious,i=this.level,a=t.fragments,n=a.length;if(0!==n){var s,o=a[0].start,l=a[n-1].start+a[n-1].duration,e=e.end;if(t.initSegment&&!t.initSegment.data)s=t.initSegment;else if(t.live){var d=this.config.initialLiveManifestSize;if(n<d)return void D.logger.warn("Can not start playback of a level, reason: not enough fragments "+n+" < "+d);if(null===(s=this._ensureFragmentAtLivePoint(t,e,o,l,r,a,n)))return}else e<o&&(s=a[0]);(s=s||this._findFragment(o,r,n,a,e,l,t))&&(s.encrypted?(D.logger.log("Loading key for "+s.sn+" of ["+t.startSN+" ,"+t.endSN+"],level "+i),this._loadKey(s)):(D.logger.log("Loading "+s.sn+" of ["+t.startSN+" ,"+t.endSN+"],level "+i+", currentTime:"+u.toFixed(3)+",bufferEnd:"+e.toFixed(3)),this._loadFragment(s)))}},a._ensureFragmentAtLivePoint=function(e,t,r,i,a,n,u){var s,o=this.hls.config,l=this.media,d=void 0!==o.liveMaxLatencyDuration?o.liveMaxLatencyDuration:o.liveMaxLatencyDurationCount*e.targetduration;return t<Math.max(r-o.maxFragLookUpTolerance,i-d)&&(t=d=this.liveSyncPosition=this.computeLivePosition(r,e),l&&!l.paused&&l.readyState&&l.duration>d&&d>l.currentTime&&(D.logger.log("buffer end: "+t.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+d.toFixed(3)),l.currentTime=d),this.nextLoadPosition=d),e.PTSKnown&&i<t&&l&&l.readyState?null:(this.startFragRequested&&!e.PTSKnown&&(a&&(e.hasProgramDateTime?(D.logger.log("live playlist, switching playlist, load frag with same PDT: "+a.programDateTime),s=ce(n,a.endProgramDateTime,o.maxFragLookUpTolerance)):((r=a.sn+1)>=e.startSN&&r<=e.endSN&&(d=n[r-e.startSN],a.cc===d.cc&&D.logger.log("live playlist, switching playlist, load frag with next SN: "+(s=d).sn)),s||(s=V.search(n,function(e){return a.cc-e.cc}))&&D.logger.log("live playlist, switching playlist, load frag with same CC: "+s.sn))),s||(s=n[Math.min(u-1,Math.round(u/2))],D.logger.log("live playlist, switching playlist, unknown, load middle frag : "+s.sn))),s)},a._findFragment=function(e,t,r,i,a,n,s){var o,l=this.hls.config;return(a=a<n?he(t,i,a,a>n-l.maxFragLookUpTolerance?0:l.maxFragLookUpTolerance):i[r-1])&&(n=a.sn-s.startSN,r=t&&a.level===t.level,o=i[n-1],i=i[1+n],t&&a.sn===t.sn&&(r&&!a.backtracked?a.sn<s.endSN?(r=t.deltaPTS)&&r>l.maxBufferHole&&t.dropped&&n?(a=o,D.logger.warn("Previous fragment was dropped with large PTS gap between audio and video. Maybe fragment is not starting with a keyframe? Loading previous one to try to overcome this")):D.logger.log("Re-loading fragment with SN: "+(a=i).sn):a=null:a.backtracked&&(i&&i.backtracked?(D.logger.warn("Already backtracked from fragment "+i.sn+", will not backtrack to fragment "+a.sn+". Loading fragment "+i.sn),a=i):(D.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),a.dropped=0,o?(a=o).backtracked=!0:n&&(a=null))))),a},a._loadKey=function(e){this.state=ye,this.hls.trigger(E.default.KEY_LOADING,{frag:e})},a._loadFragment=function(e){var t=this.fragmentTracker.getState(e);"initSegment"!==(this.fragCurrent=e).sn&&(this.startFragRequested=!0),Object(w.isFiniteNumber)(e.sn)&&!e.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),e.backtracked||t===B||t===j?(e.autoLevel=this.hls.autoLevelEnabled,e.bitrateTest=this.bitrateTest,this.hls.trigger(E.default.FRAG_LOADING,{frag:e}),this.demuxer||(this.demuxer=new ee(this.hls,"main")),this.state=Ee):t===G&&this._reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e)},a.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,s.MAIN)},a.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.endPTS+.5):null},a._checkFragmentChanged=function(){var e,t,r=this.media;r&&r.readyState&&!1===r.seeking&&((t=r.currentTime)>this.lastCurrentTime&&(this.lastCurrentTime=t),Y.isBuffered(r,t)?e=this.getBufferedFrag(t):Y.isBuffered(r,t+.1)&&(e=this.getBufferedFrag(t+.1)),!e||(r=e)!==this.fragPlaying&&(this.hls.trigger(E.default.FRAG_CHANGED,{frag:r}),t=r.level,this.fragPlaying&&this.fragPlaying.level===t||this.hls.trigger(E.default.LEVEL_SWITCHED,{level:t}),this.fragPlaying=r))},a.immediateLevelSwitch=function(){D.logger.log("immediateLevelSwitch"),this.immediateSwitch||(this.immediateSwitch=!0,(t=this.media)?(e=t.paused,t.pause()):e=!0,this.previouslyPaused=e);var e,t=this.fragCurrent;t&&t.loader&&t.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},a.immediateLevelSwitchEnd=function(){var e=this.media;e&&e.buffered.length&&(this.immediateSwitch=!1,Y.isBuffered(e,e.currentTime)&&(e.currentTime-=1e-4),this.previouslyPaused||e.play())},a.nextLevelSwitch=function(){var e,t,r=this.media;r&&r.readyState&&((t=this.getBufferedFrag(r.currentTime))&&1<t.startPTS&&this.flushMainBuffer(0,t.startPTS-1),t=r.paused?0:(t=this.hls.nextLoadLevel,t=this.levels[t],(e=this.fragLastKbps)&&this.fragCurrent?this.fragCurrent.duration*t.bitrate/(1e3*e)+1:0),(e=(e=this.getBufferedFrag(r.currentTime+t))&&this.followingBufferedFrag(e))&&((r=this.fragCurrent)&&r.loader&&r.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(e.maxStartPTS,Number.POSITIVE_INFINITY)))},a.flushMainBuffer=function(e,t){this.state=Re;e={startOffset:e,endOffset:t};this.altAudio&&(e.type="video"),this.hls.trigger(E.default.BUFFER_FLUSHING,e)},a.onMediaAttached=function(e){var e=this.media=this.mediaBuffer=e.media,t=(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),this.config);this.levels&&t.autoStartLoad&&this.hls.startLoad(t.startPosition),this.gapController=new ge(t,e,this.fragmentTracker,this.hls)},a.onMediaDetaching=function(){var e=this.media,t=(e&&e.ended&&(D.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),this.levels);t&&t.forEach(function(e){e.details&&e.details.fragments.forEach(function(e){e.backtracked=void 0})}),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("seeked",this.onvseeked),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.fragmentTracker.removeAllFragments(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.stopLoad()},a.onMediaSeeked=function(){var e=this.media,e=e?e.currentTime:void 0;Object(w.isFiniteNumber)(e)&&D.logger.log("media seeked to "+e.toFixed(3)),this.tick()},a.onManifestLoading=function(){D.logger.log("trigger BUFFER_RESET"),this.hls.trigger(E.default.BUFFER_RESET),this.fragmentTracker.removeAllFragments(),this.stalled=!1,this.startPosition=this.lastCurrentTime=0},a.onManifestParsed=function(e){var t,r=!1,i=!1,e=(e.levels.forEach(function(e){(t=e.audioCodec)&&(-1!==t.indexOf("mp4a.40.2")&&(r=!0),-1!==t.indexOf("mp4a.40.5")&&(i=!0))}),this.audioCodecSwitch=r&&i,this.audioCodecSwitch&&D.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.altAudio=e.altAudio,this.levels=e.levels,this.startFragRequested=!1,this.config);(e.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(e.startPosition)},a.onLevelLoaded=function(e){var t,r=e.details,e=e.level,i=this.levels[this.levelLastLoaded],a=this.levels[e],n=r.totalduration,s=0;D.logger.log("level "+e+" loaded ["+r.startSN+","+r.endSN+"],duration:"+n),r.live?(t=a.details)&&0<r.fragments.length?(ae(t,r),s=r.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(s,t),r.PTSKnown&&Object(w.isFiniteNumber)(s)?D.logger.log("live playlist sliding:"+s.toFixed(3)):(D.logger.log("live playlist - outdated PTS, unknown sliding"),ue(this.fragPrevious,i,r))):(D.logger.log("live playlist - first load, unknown sliding"),r.PTSKnown=!1,ue(this.fragPrevious,i,r)):r.PTSKnown=!1,a.details=r,this.levelLastLoaded=e,this.hls.trigger(E.default.LEVEL_UPDATED,{details:r,level:e}),!1===this.startFragRequested&&(-1!==this.startPosition&&-1!==this.lastCurrentTime||(t=r.startTimeOffset,Object(w.isFiniteNumber)(t)?(t<0&&(D.logger.log("negative start time offset "+t+", count from end of last fragment"),t=s+n+t),D.logger.log("start time offset found in playlist, adjust startPosition to "+t),this.startPosition=t):r.live?(this.startPosition=this.computeLivePosition(s,r),D.logger.log("configure startPosition to "+this.startPosition)):this.startPosition=0,this.lastCurrentTime=this.startPosition),this.nextLoadPosition=this.startPosition),this.state===we&&(this.state=T),this.tick()},a.onKeyLoaded=function(){this.state===ye&&(this.state=T,this.tick())},a.onFragLoaded=function(e){var t,r,i=this.fragCurrent,a=this.hls,n=this.levels,s=this.media,o=e.frag;this.state===Ee&&i&&"main"===o.type&&o.level===i.level&&o.sn===i.sn&&(r=e.stats,t=(n=n[i.level]).details,this.bitrateTest=!1,this.stats=r,D.logger.log("Loaded "+i.sn+" of ["+t.startSN+" ,"+t.endSN+"],level "+i.level),o.bitrateTest&&a.nextLoadLevel?(this.state=T,this.startFragRequested=!1,r.tparsed=r.tbuffered=window.performance.now(),a.trigger(E.default.FRAG_BUFFERED,{stats:r,frag:i,id:"main"}),this.tick()):"initSegment"===o.sn?(this.state=T,r.tparsed=r.tbuffered=window.performance.now(),t.initSegment.data=e.payload,a.trigger(E.default.FRAG_BUFFERED,{stats:r,frag:i,id:"main"}),this.tick()):(D.logger.log("Parsing "+i.sn+" of ["+t.startSN+" ,"+t.endSN+"],level "+i.level+", cc "+i.cc),this.state=Se,this.pendingBuffering=!0,this.appended=!1,o.bitrateTest&&(o.bitrateTest=!1,this.fragmentTracker.onFragLoaded({frag:o})),a=!(s&&s.seeking)&&(t.PTSKnown||!t.live),r=t.initSegment?t.initSegment.data:[],o=this._getAudioCodec(n),(this.demuxer=this.demuxer||new ee(this.hls,"main")).push(e.payload,r,o,n.videoCodec,i,t.totalduration,a))),this.fragLoadError=0},a.onFragParsingInitSegment=function(e){var t=this.fragCurrent,r=e.frag;if(t&&"main"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===Se){var i,a,n=e.tracks;for(i in n.audio&&this.altAudio&&delete n.audio,(a=n.audio)&&(r=this.levels[this.level].audioCodec,t=navigator.userAgent.toLowerCase(),r&&this.audioCodecSwap&&(D.logger.log("swapping playlist audio codec"),r=-1!==r.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==a.metadata.channelCount&&-1===t.indexOf("firefox")&&(r="mp4a.40.5"),-1!==t.indexOf("android")&&"audio/mpeg"!==a.container&&D.logger.log("Android: force audio codec to "+(r="mp4a.40.2")),a.levelCodec=r,a.id=e.id),(a=n.video)&&(a.levelCodec=this.levels[this.level].videoCodec,a.id=e.id),this.hls.trigger(E.default.BUFFER_CODECS,n),n){a=n[i],D.logger.log("main track:"+i+",container:"+a.container+",codecs[level/parsed]=["+a.levelCodec+"/"+a.codec+"]");var s=a.initSegment;s&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(E.default.BUFFER_APPENDING,{type:i,data:s,parent:"main",content:"initSegment"}))}this.tick()}},a.onFragParsingData=function(t){var r=this,e=this.fragCurrent,i=t.frag;if(e&&"main"===t.id&&i.sn===e.sn&&i.level===e.level&&("audio"!==t.type||!this.altAudio)&&this.state===Se){var i=this.levels[this.level],a=e;if(Object(w.isFiniteNumber)(t.endPTS)||(t.endPTS=t.startPTS+e.duration,t.endDTS=t.startDTS+e.duration),!0===t.hasAudio&&a.addElementaryStream(h.AUDIO),!0===t.hasVideo&&a.addElementaryStream(h.VIDEO),D.logger.log("Parsed "+t.type+",PTS:["+t.startPTS.toFixed(3)+","+t.endPTS.toFixed(3)+"],DTS:["+t.startDTS.toFixed(3)+"/"+t.endDTS.toFixed(3)+"],nb:"+t.nb+",dropped:"+(t.dropped||0)),"video"===t.type)if(a.dropped=t.dropped,a.dropped)if(a.backtracked)D.logger.warn("Already backtracked on this fragment, appending with the gap",a.sn);else{e=i.details;if(!e||a.sn!==e.startSN)return D.logger.warn("missing video frame(s), backtracking fragment",a.sn),this.fragmentTracker.removeFragment(a),a.backtracked=!0,this.nextLoadPosition=t.startPTS,this.state=T,this.fragPrevious=a,void this.tick();D.logger.warn("missing video frame(s) on first frag, appending with gap",a.sn)}else a.backtracked=!1;var e=ie(i.details,a,t.startPTS,t.endPTS,t.startDTS,t.endDTS),n=this.hls;n.trigger(E.default.LEVEL_PTS_UPDATED,{details:i.details,level:this.level,drift:e,type:t.type,start:t.startPTS,end:t.endPTS}),[t.data1,t.data2].forEach(function(e){e&&e.length&&r.state===Se&&(r.appended=!0,r.pendingBuffering=!0,n.trigger(E.default.BUFFER_APPENDING,{type:t.type,data:e,parent:"main",content:"data"}))}),this.tick()}},a.onFragParsed=function(e){var t=this.fragCurrent,r=e.frag;t&&"main"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===Se&&(this.stats.tparsed=window.performance.now(),this.state=_e,this._checkAppendedParsed())},a.onAudioTrackSwitching=function(e){var t=!!e.url,e=e.id;t||(this.mediaBuffer!==this.media&&(D.logger.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media,(t=this.fragCurrent).loader&&(D.logger.log("switching to main audio track, cancel main fragment load"),t.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=T),(t=this.hls).trigger(E.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),t.trigger(E.default.AUDIO_TRACK_SWITCHED,{id:e}),this.altAudio=!1)},a.onAudioTrackSwitched=function(e){var t,e=e.id,e=!!this.hls.audioTracks[e].url;!e||(t=this.videoBuffer)&&this.mediaBuffer!==t&&(D.logger.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=t),this.altAudio=e,this.tick()},a.onBufferCreated=function(e){var t,r,i,a=e.tracks,n=!1;for(i in a){var s=a[i];"main"===s.id?(t=s,"video"===(r=i)&&(this.videoBuffer=a[i].buffer)):n=!0}n&&t?(D.logger.log("alternate track found, use "+r+".buffered to schedule main fragment loading"),this.mediaBuffer=t.buffer):this.mediaBuffer=this.media},a.onBufferAppended=function(e){var t;"main"===e.parent&&((t=this.state)!==Se&&t!==_e||(this.pendingBuffering=0<e.pending,this._checkAppendedParsed()))},a._checkAppendedParsed=function(){var e,t;this.state!==_e||this.appended&&this.pendingBuffering||((e=this.fragCurrent)&&(t=this.mediaBuffer||this.media,D.logger.log("main buffered : "+oe.toString(t.buffered)),this.fragPrevious=e,(t=this.stats).tbuffered=window.performance.now(),this.fragLastKbps=Math.round(8*t.total/(t.tbuffered-t.tfirst)),this.hls.trigger(E.default.FRAG_BUFFERED,{stats:t,frag:e,id:"main"}),this.state=T),this.tick())},a.onError=function(e){var t=e.frag||this.fragCurrent;if(!t||"main"===t.type){var r,i=!!this.media&&Y.isBuffered(this.media,this.media.currentTime)&&Y.isBuffered(this.media,this.media.currentTime+.5);switch(e.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:e.fatal||(this.fragLoadError+1<=this.config.fragLoadingMaxRetry?(r=Math.min(Math.pow(2,this.fragLoadError)*this.config.fragLoadingRetryDelay,this.config.fragLoadingMaxRetryTimeout),D.logger.warn("mediaController: frag loading failed, retry in "+r+" ms"),this.retryDate=window.performance.now()+r,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.fragLoadError++,this.state=Te):(D.logger.error("mediaController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=ke));break;case d.ErrorDetails.LEVEL_LOAD_ERROR:case d.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==ke&&(e.fatal?(this.state=ke,D.logger.warn("streamController: "+e.details+",switch to "+this.state+" state ...")):e.levelRetry||this.state!==we||(this.state=T));break;case d.ErrorDetails.BUFFER_FULL_ERROR:"main"!==e.parent||this.state!==Se&&this.state!==_e||(i?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=T):(D.logger.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)))}}},a._reduceMaxBufferLength=function(e){var t=this.config;return t.maxMaxBufferLength>=e&&(t.maxMaxBufferLength/=2,D.logger.warn("main:reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},a._checkBuffer=function(){var e=this.media;e&&0!==e.readyState&&(e=(this.mediaBuffer||e).buffered,!this.loadedmetadata&&e.length?(this.loadedmetadata=!0,this._seekToStartPos()):this.immediateSwitch?this.immediateLevelSwitchEnd():this.gapController.poll(this.lastCurrentTime,e))},a.onFragLoadEmergencyAborted=function(){this.state=T,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},a.onBufferFlushed=function(){var e=this.mediaBuffer||this.media;e&&this.fragmentTracker.detectEvictedFragments(h.VIDEO,e.buffered),this.state=T,this.fragPrevious=null},a.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},a._seekToStartPos=function(){var e=this.media,t=e.currentTime,r=e.seeking?t:this.startPosition;t!==r&&0<=r&&(D.logger.log("target start position not buffered, seek to buffered.start(0) "+r+" from current time "+t+" "),e.currentTime=r)},a._getAudioCodec=function(e){e=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&(D.logger.log("swapping playlist audio codec"),e=e&&(-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),e},t=e,(a=[{key:"state",set:function(e){var t;this.state!==e&&(t=this.state,this._state=e,D.logger.log("main stream-controller: "+t+"->"+e),this.hls.trigger(E.default.STREAM_STATE_TRANSITION,{previousState:t,nextState:e}))},get:function(){return this._state}},{key:"currentLevel",get:function(){var e=this.media;if(e){e=this.getBufferedFrag(e.currentTime);if(e)return e.level}return-1}},{key:"nextBufferedFrag",get:function(){var e=this.media;return e?this.followingBufferedFrag(this.getBufferedFrag(e.currentTime)):null}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"liveSyncPosition",get:function(){return this._liveSyncPosition},set:function(e){this._liveSyncPosition=e}}])&&De(t.prototype,a),r&&De(t,r),e}(Q);function Ce(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}window.performance;var Ie,xe=function(t){function e(e){e=t.call(this,e,E.default.MANIFEST_LOADED,E.default.LEVEL_LOADED,E.default.AUDIO_TRACK_SWITCHED,E.default.FRAG_LOADED,E.default.ERROR)||this;return e.canload=!1,e.currentLevelIndex=null,e.manualLevelIndex=-1,e.timer=null,Ie=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),e}r=t,(a=e).prototype=Object.create(r.prototype),(a.prototype.constructor=a).__proto__=r;var r,i,a=e.prototype;return a.onHandlerDestroying=function(){this.clearTimer(),this.manualLevelIndex=-1},a.clearTimer=function(){null!==this.timer&&(clearTimeout(this.timer),this.timer=null)},a.startLoad=function(){var e=this._levels;this.canload=!0,this.levelRetryCount=0,e&&e.forEach(function(e){e.loadError=0;var t=e.details;t&&t.live&&(e.details=void 0)}),null!==this.timer&&this.loadLevel()},a.stopLoad=function(){this.canload=!1},a.onManifestLoaded=function(e){var t,r=[],i=[],a={},n=null,s=!1,o=!1;if(e.levels.forEach(function(e){var t=e.attrs;e.loadError=0,e.fragmentError=!1,s=s||!!e.videoCodec,o=o||!!e.audioCodec,Ie&&e.audioCodec&&-1!==e.audioCodec.indexOf("mp4a.40.34")&&(e.audioCodec=void 0),(n=a[e.bitrate])?n.url.push(e.url):(e.url=[e.url],e.urlId=0,a[e.bitrate]=e,r.push(e)),t&&(t.AUDIO&&(o=!0,te(n||e,"audio",t.AUDIO)),t.SUBTITLES&&te(n||e,"text",t.SUBTITLES))}),r=(r=s&&o?r.filter(function(e){return!!e.videoCodec}):r).filter(function(e){var t=e.audioCodec,e=e.videoCodec;return(!t||S(t,"audio"))&&(!e||S(e,"video"))}),e.audioTracks&&(i=e.audioTracks.filter(function(e){return!e.audioCodec||S(e.audioCodec,"audio")})).forEach(function(e,t){e.id=t}),0<r.length){t=r[0].bitrate,r.sort(function(e,t){return e.bitrate-t.bitrate}),this._levels=r;for(var l=0;l<r.length;l++)if(r[l].bitrate===t){this._firstLevel=l,D.logger.log("manifest loaded,"+r.length+" level(s) found, first bitrate:"+t);break}this.hls.trigger(E.default.MANIFEST_PARSED,{levels:r,audioTracks:i,firstLevel:this._firstLevel,stats:e.stats,audio:o,video:s,altAudio:i.some(function(e){return!!e.url})})}else this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:this.hls.url,reason:"no level with compatible codecs found in manifest"})},a.setLevelInternal=function(e){var t,r=this._levels,i=this.hls;0<=e&&e<r.length?(this.clearTimer(),this.currentLevelIndex!==e&&(D.logger.log("switching to level "+e),(t=r[this.currentLevelIndex=e]).level=e,i.trigger(E.default.LEVEL_SWITCHING,t)),(r=(t=r[e]).details)&&!r.live||(r=t.urlId,i.trigger(E.default.LEVEL_LOADING,{url:t.url[r],level:e,id:r}))):i.trigger(E.default.ERROR,{type:d.ErrorTypes.OTHER_ERROR,details:d.ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:!1,reason:"invalid level idx"})},a.onError=function(e){if(e.fatal)e.type===d.ErrorTypes.NETWORK_ERROR&&this.clearTimer();else{var t,r=!1,i=!1;switch(e.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:t=e.frag.level,i=!0;break;case d.ErrorDetails.LEVEL_LOAD_ERROR:case d.ErrorDetails.LEVEL_LOAD_TIMEOUT:t=e.context.level,r=!0;break;case d.ErrorDetails.REMUX_ALLOC_ERROR:t=e.level,r=!0}void 0!==t&&this.recoverLevel(e,t,r,i)}},a.recoverLevel=function(e,t,r,i){var a=this,n=this.hls.config,s=e.details,o=this._levels[t];if(o.loadError++,o.fragmentError=i,r){if(!(this.levelRetryCount+1<=n.levelLoadingMaxRetry))return D.logger.error("level controller, cannot recover from "+s+" error"),this.currentLevelIndex=null,this.clearTimer(),void(e.fatal=!0);n=Math.min(Math.pow(2,this.levelRetryCount)*n.levelLoadingRetryDelay,n.levelLoadingMaxRetryTimeout),this.timer=setTimeout(function(){return a.loadLevel()},n),e.levelRetry=!0,this.levelRetryCount++,D.logger.warn("level controller, "+s+", retry in "+n+" ms, current retry count is "+this.levelRetryCount)}(r||i)&&(1<(e=o.url.length)&&o.loadError<e?(o.urlId=(o.urlId+1)%e,o.details=void 0,D.logger.warn("level controller, "+s+" for level "+t+": switching to redundant URL-id "+o.urlId)):-1===this.manualLevelIndex?(n=0===t?this._levels.length-1:t-1,D.logger.warn("level controller, "+s+": switch to "+n),this.hls.nextAutoLevel=this.currentLevelIndex=n):i&&(D.logger.warn("level controller, "+s+": reload a fragment"),this.currentLevelIndex=null))},a.onFragLoaded=function(e){var e=e.frag;void 0===e||"main"!==e.type||void 0!==(e=this._levels[e.level])&&(e.fragmentError=!1,e.loadError=0,this.levelRetryCount=0)},a.onLevelLoaded=function(e){var t=this,r=e.level,i=e.details;r===this.currentLevelIndex&&((r=this._levels[r]).fragmentError||(r.loadError=0,this.levelRetryCount=0),i.live?(r=se(r.details,i,e.stats.trequest),D.logger.log("live playlist, reload in "+Math.round(r)+" ms"),this.timer=setTimeout(function(){return t.loadLevel()},r)):this.clearTimer())},a.onAudioTrackSwitched=function(e){var t=this.hls.audioTracks[e.id].groupId,r=this.hls.levels[this.currentLevelIndex];if(r&&r.audioGroupIds){for(var i=-1,a=0;a<r.audioGroupIds.length;a++)if(r.audioGroupIds[a]===t){i=a;break}i!==r.urlId&&(r.urlId=i,this.startLoad())}},a.loadLevel=function(){var e,t,r;D.logger.debug("call to loadLevel"),null===this.currentLevelIndex||!this.canload||"object"==typeof(r=this._levels[this.currentLevelIndex])&&0<r.url.length&&(e=this.currentLevelIndex,t=r.urlId,r=r.url[t],D.logger.log("Attempt loading level index "+e+" with URL-id "+t),this.hls.trigger(E.default.LEVEL_LOADING,{url:r,level:e,id:t}))},r=e,(a=[{key:"levels",get:function(){return this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;t&&(e=Math.min(e,t.length-1),this.currentLevelIndex===e&&t[e].details||this.setLevelInternal(e))}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){var e;return void 0===this._startLevel?void 0!==(e=this.hls.config.startLevel)?e:this._firstLevel:this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}])&&Ce(r.prototype,a),i&&Ce(r,i),e}(n),Pe=e("./src/demux/id3.js");function Fe(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function Me(e){if(e&&e.cues)for(;0<e.cues.length;)e.removeCue(e.cues[0])}var Ne=function(t){var e;function r(e){e=t.call(this,e,E.default.MEDIA_ATTACHED,E.default.MEDIA_DETACHING,E.default.FRAG_PARSING_METADATA,E.default.LIVE_BACK_BUFFER_REACHED)||this;return e.id3Track=void 0,e.media=void 0,e}e=t,(i=r).prototype=Object.create(e.prototype),(i.prototype.constructor=i).__proto__=e;var i=r.prototype;return i.destroy=function(){n.prototype.destroy.call(this)},i.onMediaAttached=function(e){this.media=e.media,this.media},i.onMediaDetaching=function(){Me(this.id3Track),this.id3Track=void 0,this.media=void 0},i.getID3Track=function(e){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return Fe(r,this.media),r}return this.media.addTextTrack("metadata","id3")},i.onFragParsingMetadata=function(e){for(var t=e.frag,r=e.samples,u=(this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden"),window.WebKitDataCue||window.VTTCue||window.TextTrackCue),i=0;i<r.length;i++){var a=Pe.default.getID3Frames(r[i].data);if(a){var n=r[i].pts,s=i<r.length-1?r[i+1].pts:t.endPTS;n===s?s+=1e-4:s<n&&(D.logger.warn("detected an id3 sample with endTime < startTime, adjusting endTime to (startTime + 0.25)"),s=n+.25);for(var o=0;o<a.length;o++){var l,d=a[o];Pe.default.isTimeStampFrame(d)||((l=new u(n,s,"")).value=d,this.id3Track.addCue(l))}}}},i.onLiveBackBufferReached=function(e){var e=e.bufferEnd,t=this.id3Track;if(t&&t.cues&&t.cues.length){var r=function(e,t){if(t<e[0].endTime)return e[0];if(t>e[e.length-1].endTime)return e[e.length-1];for(var r=0,i=e.length-1;r<=i;){var a=Math.floor((i+r)/2);if(t<e[a].endTime)i=a-1;else{if(!(t>e[a].endTime))return e[a];r=a+1}}return e[r].endTime-t<t-e[i].endTime?e[r]:e[i]}(t.cues,e);if(r)for(;t.cues[0]!==r;)t.removeCue(t.cues[0])}},r}(n);var Ue=function(){function e(e){this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=0,this.totalWeight_=0}var t=e.prototype;return t.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){var e;return this.alpha_?(e=1-Math.pow(this.alpha_,this.totalWeight_),this.estimate_/e):this.estimate_},e}(),Be=function(){function e(e,t,r,i){this.hls=void 0,this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.hls=e,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Ue(t),this.fast_=new Ue(r)}var t=e.prototype;return t.sample=function(e,t){e=(e=Math.max(e,this.minDelayMs_))/1e3,t=8*t/e;this.fast_.sample(e,t),this.slow_.sample(e,t)},t.canEstimate=function(){var e=this.fast_;return e&&e.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.destroy=function(){},e}();function Ge(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var je=window.performance,Ke=function(r){function e(e){var t=r.call(this,e,E.default.FRAG_LOADING,E.default.FRAG_LOADED,E.default.FRAG_BUFFERED,E.default.ERROR)||this;return t.lastLoadedFragLevel=0,t._nextAutoLevel=-1,t.hls=e,t.timer=null,t._bwEstimator=null,t.onCheck=t._abandonRulesCheck.bind(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)),t}t=r,(a=e).prototype=Object.create(t.prototype),(a.prototype.constructor=a).__proto__=t;var t,i,a=e.prototype;return a.destroy=function(){this.clearTimer(),n.prototype.destroy.call(this)},a.onFragLoading=function(e){var t,r,i,e=e.frag;"main"===e.type&&(this.timer||(this.fragCurrent=e,this.timer=setInterval(this.onCheck,100)),this._bwEstimator||(r=(t=this.hls).config,e=e.level,e=t.levels[e].details.live?(i=r.abrEwmaFastLive,r.abrEwmaSlowLive):(i=r.abrEwmaFastVoD,r.abrEwmaSlowVoD),this._bwEstimator=new Be(t,e,i,r.abrEwmaDefaultEstimate)))},a._abandonRulesCheck=function(){var e=this.hls,t=e.media,r=this.fragCurrent;if(r){var i=r.loader,u=e.minAutoLevel;if(!i||i.stats&&i.stats.aborted)return D.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),void(this._nextAutoLevel=-1);var a=i.stats;if(t&&a&&(!t.paused&&0!==t.playbackRate||!t.readyState)&&r.autoLevel&&r.level){var n=je.now()-a.trequest,c=Math.abs(t.playbackRate);if(n>500*r.duration/c){var s=e.levels,h=Math.max(1,a.bw?a.bw/8:1e3*a.loaded/n),o=s[r.level],o=o.realBitrate?Math.max(o.realBitrate,o.bitrate):o.bitrate,o=a.total||Math.max(a.loaded,Math.round(r.duration*o/8)),f=t.currentTime,o=(o-a.loaded)/h,l=(Y.bufferInfo(t,f,e.config.maxBufferHole).end-f)/c;if(l<2*r.duration/c&&l<o){for(var d=r.level-1;u<d;d--){var g=s[d].realBitrate?Math.max(s[d].realBitrate,s[d].bitrate):s[d].bitrate;if(r.duration*g/(6.4*h)<l)break}void 0<o&&(D.logger.warn("loading too slow, abort fragment loading and switch to level "+d+":fragLoadedDelay["+d+"]<fragLoadedDelay["+(r.level-1)+"];bufferStarvationDelay:"+(void 0).toFixed(1)+"<"+o.toFixed(1)+":"+l.toFixed(1)),e.nextLoadLevel=d,this._bwEstimator.sample(n,a.loaded),i.abort(),this.clearTimer(),e.trigger(E.default.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,stats:a}))}}}}},a.onFragLoaded=function(e){var t,r,i=e.frag;"main"===i.type&&Object(w.isFiniteNumber)(i.sn)&&(this.clearTimer(),this.lastLoadedFragLevel=i.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate&&(t=((i=this.hls.levels[i.level]).loaded?i.loaded.bytes:0)+e.stats.loaded,r=(i.loaded?i.loaded.duration:0)+e.frag.duration,i.loaded={bytes:t,duration:r},i.realBitrate=Math.round(8*t/r)),e.frag.bitrateTest&&((i=e.stats).tparsed=i.tbuffered=i.tload,this.onFragBuffered(e)))},a.onFragBuffered=function(e){var t,r=e.stats,e=e.frag;!0===r.aborted||"main"!==e.type||!Object(w.isFiniteNumber)(e.sn)||e.bitrateTest&&r.tload!==r.tbuffered||(t=r.tparsed-r.trequest,D.logger.log("latency/loading/parsing/append/kbps:"+Math.round(r.tfirst-r.trequest)+"/"+Math.round(r.tload-r.tfirst)+"/"+Math.round(r.tparsed-r.tload)+"/"+Math.round(r.tbuffered-r.tparsed)+"/"+Math.round(8*r.loaded/(r.tbuffered-r.trequest))),this._bwEstimator.sample(t,r.loaded),r.bwEstimate=this._bwEstimator.getEstimate(),e.bitrateTest?this.bitrateTestDelay=t/1e3:this.bitrateTestDelay=0)},a.onError=function(e){switch(e.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},a.clearTimer=function(){clearInterval(this.timer),this.timer=null},a._findBestLevel=function(e,u,t,c,h,r,f,g,i){for(var a=h;c<=a;a--){var n=i[a];if(n){var n=n.details,s=n?n.totalduration/n.fragments.length:u,n=!!n&&n.live,o=void 0,o=a<=e?f*t:g*t,l=i[a].realBitrate?Math.max(i[a].realBitrate,i[a].bitrate):i[a].bitrate,d=l*s/o;if(D.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+a+"/"+Math.round(o)+"/"+l+"/"+s+"/"+r+"/"+d),l<o&&(!d||n&&!this.bitrateTestDelay||d<r))return a}}return-1},t=e,(a=[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this._bwEstimator;if(!(-1===e||t&&t.canEstimate()))return e;t=this._nextABRAutoLevel;return t=-1!==e?Math.min(e,t):t},set:function(e){this._nextAutoLevel=e}},{key:"_nextABRAutoLevel",get:function(){var e,t,r,i=this.hls,a=i.maxAutoLevel,n=i.levels,s=i.config,u=i.minAutoLevel,i=i.media,c=this.lastLoadedFragLevel,o=this.fragCurrent?this.fragCurrent.duration:0,l=i?i.currentTime:0,d=i&&0!==i.playbackRate?Math.abs(i.playbackRate):1,h=this._bwEstimator?this._bwEstimator.getEstimate():s.abrEwmaDefaultEstimate,i=(Y.bufferInfo(i,l,s.maxBufferHole).end-l)/d,l=this._findBestLevel(c,o,h,u,a,i,s.abrBandWidthFactor,s.abrBandWidthUpFactor,n);return 0<=l?l:(D.logger.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering"),d=o?Math.min(o,s.maxStarvationDelay):s.maxStarvationDelay,e=s.abrBandWidthFactor,t=s.abrBandWidthUpFactor,0!=i||(r=this.bitrateTestDelay)&&(d=(o?Math.min(o,s.maxLoadingDelay):s.maxLoadingDelay)-r,D.logger.trace("bitrate test took "+Math.round(1e3*r)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*d)+" ms"),e=t=1),l=this._findBestLevel(c,o,h,u,a,i+d,e,t,n),Math.max(l,0))}}])&&Ge(t.prototype,a),i&&Ge(t,i),e}(n);var He=X(),Ve=function(t){var e;function r(e){var s=t.call(this,e,E.default.MEDIA_ATTACHING,E.default.MEDIA_DETACHING,E.default.MANIFEST_PARSED,E.default.BUFFER_RESET,E.default.BUFFER_APPENDING,E.default.BUFFER_CODECS,E.default.BUFFER_EOS,E.default.BUFFER_FLUSHING,E.default.LEVEL_PTS_UPDATED,E.default.LEVEL_UPDATED)||this;return s._msDuration=null,s._levelDuration=null,s._levelTargetDuration=10,s._live=null,s._objectUrl=null,s._needsFlush=!1,s._needsEos=!1,s.config=void 0,s.audioTimestampOffset=void 0,s.bufferCodecEventsExpected=0,s._bufferCodecEventsTotal=0,s.media=null,s.mediaSource=null,s.segments=[],s.parent=void 0,s.appending=!1,s.appended=0,s.appendError=0,s.flushBufferCounter=0,s.tracks={},s.pendingTracks={},s.sourceBuffer={},s.flushRange=[],s._onMediaSourceOpen=function(){D.logger.log("media source opened"),s.hls.trigger(E.default.MEDIA_ATTACHED,{media:s.media});var e=s.mediaSource;e&&e.removeEventListener("sourceopen",s._onMediaSourceOpen),s.checkPendingTracks()},s._onMediaSourceClose=function(){D.logger.log("media source closed")},s._onMediaSourceEnded=function(){D.logger.log("media source ended")},s._onSBUpdateEnd=function(){s.audioTimestampOffset&&s.sourceBuffer.audio&&(t=s.sourceBuffer.audio,D.logger.warn("change mpeg audio timestamp offset from "+t.timestampOffset+" to "+s.audioTimestampOffset),t.timestampOffset=s.audioTimestampOffset,delete s.audioTimestampOffset),s._needsFlush&&s.doFlush(),s._needsEos&&s.checkEos(),s.appending=!1;var e,r=s.parent,t=s.segments.reduce(function(e,t){return t.parent===r?e+1:e},0),i={},a=s.sourceBuffer;for(e in a){var n=a[e];if(!n)throw Error("handling source buffer update end error: source buffer for "+e+" uninitilized and unable to update buffered TimeRanges.");i[e]=n.buffered}s.hls.trigger(E.default.BUFFER_APPENDED,{parent:r,pending:t,timeRanges:i}),s._needsFlush||s.doAppending(),s.updateMediaElementDuration(),0===t&&s.flushLiveBackBuffer()},s._onSBUpdateError=function(e){D.logger.error("sourceBuffer error:",e),s.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})},s.config=e.config,s}e=t,(i=r).prototype=Object.create(e.prototype),(i.prototype.constructor=i).__proto__=e;var i=r.prototype;return i.destroy=function(){n.prototype.destroy.call(this)},i.onLevelPtsUpdated=function(e){var t=e.type,r=this.tracks.audio;if("audio"===t&&r&&"audio/mpeg"===r.container){t=this.sourceBuffer.audio;if(!t)throw Error("Level PTS Updated and source buffer for audio uninitalized");if(.1<Math.abs(t.timestampOffset-e.start)){r=t.updating;try{t.abort()}catch(e){D.logger.warn("can not abort audio buffer: "+e)}r?this.audioTimestampOffset=e.start:(D.logger.warn("change mpeg audio timestamp offset from "+t.timestampOffset+" to "+e.start),t.timestampOffset=e.start)}}},i.onManifestParsed=function(e){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=e.altAudio?2:1,D.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},i.onMediaAttaching=function(e){var t,e=this.media=e.media;e&&He&&((t=this.mediaSource=new He).addEventListener("sourceopen",this._onMediaSourceOpen),t.addEventListener("sourceended",this._onMediaSourceEnded),t.addEventListener("sourceclose",this._onMediaSourceClose),e.src=window.URL.createObjectURL(t),this._objectUrl=e.src)},i.onMediaDetaching=function(){D.logger.log("media source detaching");var e=this.mediaSource;if(e){if("open"===e.readyState)try{e.endOfStream()}catch(e){D.logger.warn("onMediaDetaching:"+e.message+" while calling endOfStream")}e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),this.media&&(this._objectUrl&&window.URL.revokeObjectURL(this._objectUrl),this.media.src===this._objectUrl?(this.media.removeAttribute("src"),this.media.load()):D.logger.warn("media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={},this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0}this.hls.trigger(E.default.MEDIA_DETACHED)},i.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.pendingTracks,r=Object.keys(t).length;(r&&!e||2===r)&&(this.createSourceBuffers(t),this.pendingTracks={},this.doAppending())},i.onBufferReset=function(){var e,t=this.sourceBuffer;for(e in t){var r=t[e];try{r&&(this.mediaSource&&this.mediaSource.removeSourceBuffer(r),r.removeEventListener("updateend",this._onSBUpdateEnd),r.removeEventListener("error",this._onSBUpdateError))}catch(e){}}this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0},i.onBufferCodecs=function(t){var r=this;Object.keys(this.sourceBuffer).length||(Object.keys(t).forEach(function(e){r.pendingTracks[e]=t[e]}),this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},i.createSourceBuffers=function(e){var t,r=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(t in e)if(!r[t]){var a=e[t];if(!a)throw Error("source buffer exists for track "+t+", however track does not");var n=a.levelCodec||a.codec,s=a.container+";codecs="+n;D.logger.log("creating sourceBuffer("+s+")");try{var o=r[t]=i.addSourceBuffer(s);o.addEventListener("updateend",this._onSBUpdateEnd),o.addEventListener("error",this._onSBUpdateError),this.tracks[t]={buffer:o,codec:n,id:a.id,container:a.container,levelCodec:a.levelCodec}}catch(e){D.logger.error("error while trying to add sourceBuffer:"+e.message),this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:e,mimeType:s})}}this.hls.trigger(E.default.BUFFER_CREATED,{tracks:this.tracks})},i.onBufferAppending=function(e){this._needsFlush||(this.segments?this.segments.push(e):this.segments=[e],this.doAppending())},i.onBufferEos=function(e){for(var t in this.sourceBuffer){var r;e.type&&e.type!==t||(r=this.sourceBuffer[t])&&!r.ended&&(r.ended=!0,D.logger.log(t+" sourceBuffer now EOS"))}this.checkEos()},i.checkEos=function(){var e=this.sourceBuffer,t=this.mediaSource;if(t&&"open"===t.readyState){for(var r in e){r=e[r];if(r){if(!r.ended)return;if(r.updating)return void(this._needsEos=!0)}}D.logger.log("all media data are available, signal endOfStream() to MediaSource and stop loading fragment");try{t.endOfStream()}catch(e){D.logger.warn("exception while calling mediaSource.endOfStream()")}this._needsEos=!1}else this._needsEos=!1},i.onBufferFlushing=function(e){e.type?this.flushRange.push({start:e.startOffset,end:e.endOffset,type:e.type}):(this.flushRange.push({start:e.startOffset,end:e.endOffset,type:"video"}),this.flushRange.push({start:e.startOffset,end:e.endOffset,type:"audio"})),this.flushBufferCounter=0,this.doFlush()},i.flushLiveBackBuffer=function(){if(this._live){var e=this.config.liveBackBufferLength;if(isFinite(e)&&!(e<0))if(this.media)for(var t=this.media.currentTime,r=this.sourceBuffer,i=Object.keys(r),a=t-Math.max(e,this._levelTargetDuration),n=i.length-1;0<=n;n--){var s,o=i[n],l=r[o];!l||0<(s=l.buffered).length&&a>s.start(0)&&this.removeBufferRange(o,l,0,a)&&this.hls.trigger(E.default.LIVE_BACK_BUFFER_REACHED,{bufferEnd:a})}else D.logger.error("flushLiveBackBuffer called without attaching media")}},i.onLevelUpdated=function(e){e=e.details;0<e.fragments.length&&(this._levelDuration=e.totalduration+e.fragments[0].start,this._levelTargetDuration=e.averagetargetduration||e.targetduration||10,this._live=e.live,this.updateMediaElementDuration())},i.updateMediaElementDuration=function(){var e,t=this.config;if(null!==this._levelDuration&&this.media&&this.mediaSource&&this.sourceBuffer&&0!==this.media.readyState&&"open"===this.mediaSource.readyState){for(var r in this.sourceBuffer){r=this.sourceBuffer[r];if(r&&!0===r.updating)return}e=this.media.duration,null===this._msDuration&&(this._msDuration=this.mediaSource.duration),!0===this._live&&!0===t.liveDurationInfinity?(D.logger.log("Media Source duration is set to Infinity"),this._msDuration=this.mediaSource.duration=1/0):(this._levelDuration>this._msDuration&&this._levelDuration>e||!Object(w.isFiniteNumber)(e))&&(D.logger.log("Updating Media Source duration to "+this._levelDuration.toFixed(3)),this._msDuration=this.mediaSource.duration=this._levelDuration)}},i.doFlush=function(){for(;this.flushRange.length;){var e=this.flushRange[0];if(!this.flushBuffer(e.start,e.end,e.type))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var t=0,r=this.sourceBuffer;try{for(var i in r){var a=r[i];a&&(t+=a.buffered.length)}}catch(e){D.logger.error("error while accessing sourceBuffer.buffered")}this.appended=t,this.hls.trigger(E.default.BUFFER_FLUSHED)}},i.doAppending=function(){var t=this.config,r=this.hls,i=this.segments,a=this.sourceBuffer;if(Object.keys(a).length){if(!this.media||this.media.error)return this.segments=[],void D.logger.error("trying to append although a media error occured, flush segment and abort");if(!this.appending){var n=i.shift();if(n)try{var e=a[n.type];if(!e)return void this._onSBUpdateEnd();if(e.updating)return void i.unshift(n);e.ended=!1,this.parent=n.parent,e.appendBuffer(n.data),this.appendError=0,this.appended++,this.appending=!0}catch(e){D.logger.error("error while trying to append buffer:"+e.message),i.unshift(n);a={type:d.ErrorTypes.MEDIA_ERROR,parent:n.parent,details:"",fatal:!1};22===e.code?(this.segments=[],a.details=d.ErrorDetails.BUFFER_FULL_ERROR):(this.appendError++,a.details=d.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>t.appendErrorMaxRetry&&(D.logger.log("fail "+t.appendErrorMaxRetry+" times to append segment in sourceBuffer"),this.segments=[],a.fatal=!0)),r.trigger(E.default.ERROR,a)}}}},i.flushBuffer=function(e,t,r){var i=this.sourceBuffer;if(!Object.keys(i).length)return!0;var a="null";if(this.media&&(a=this.media.currentTime.toFixed(3)),D.logger.log("flushBuffer,pos/start/end: "+a+"/"+e+"/"+t),this.flushBufferCounter>=this.appended)return D.logger.warn("abort flushing too many retries"),!0;a=i[r];if(a){if(a.ended=!1,a.updating)return D.logger.warn("cannot flush, sb updating in progress"),!1;if(this.removeBufferRange(r,a,e,t))return this.flushBufferCounter++,!1}return D.logger.log("buffer flushed"),!0},i.removeBufferRange=function(e,t,r,i){try{for(var a=0;a<t.buffered.length;a++){var n,s=t.buffered.start(a),o=t.buffered.end(a),l=Math.max(s,r),d=Math.min(o,i);if(.5<Math.min(d,o)-l)return n="null",this.media&&(n=this.media.currentTime.toString()),D.logger.log("sb remove "+e+" ["+l+","+d+"], of ["+s+","+o+"], pos:"+n),t.remove(l,d),!0}}catch(e){D.logger.warn("removeBufferRange failed",e)}return!1},r}(n);function Ye(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var We=function(t){function a(e){e=t.call(this,e,E.default.FPS_DROP_LEVEL_CAPPING,E.default.MEDIA_ATTACHING,E.default.MANIFEST_PARSED,E.default.BUFFER_CODECS,E.default.MEDIA_DETACHING)||this;return e.autoLevelCapping=Number.POSITIVE_INFINITY,e.firstLevel=null,e.levels=[],e.media=null,e.restrictedLevels=[],e.timer=null,e}e=t,(i=a).prototype=Object.create(e.prototype),(i.prototype.constructor=i).__proto__=e;var e,r,i=a.prototype;return i.destroy=function(){this.hls.config.capLevelToPlayerSize&&(this.media=null,this.stopCapping())},i.onFpsDropLevelCapping=function(e){a.isLevelAllowed(e.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(e.droppedLevel)},i.onMediaAttaching=function(e){this.media=e.media instanceof window.HTMLVideoElement?e.media:null},i.onManifestParsed=function(e){var t=this.hls;this.restrictedLevels=[],this.levels=e.levels,this.firstLevel=e.firstLevel,t.config.capLevelToPlayerSize&&e.video&&this.startCapping()},i.onBufferCodecs=function(e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()},i.onLevelsUpdated=function(e){this.levels=e.levels},i.onMediaDetaching=function(){this.stopCapping()},i.detectPlayerSize=function(){var e,t;!this.media||(e=this.levels?this.levels.length:0)&&((t=this.hls).autoLevelCapping=this.getMaxLevel(e-1),t.autoLevelCapping>this.autoLevelCapping&&t.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping)},i.getMaxLevel=function(r){var i=this;if(!this.levels)return-1;var e=this.levels.filter(function(e,t){return a.isLevelAllowed(t,i.restrictedLevels)&&t<=r});return a.getMaxLevelByMediaSize(e,this.mediaWidth,this.mediaHeight)},i.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),clearInterval(this.timer),this.timer=setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},i.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=null,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer),this.timer=null)},a.isLevelAllowed=function(e,t){return-1===(t=void 0===t?[]:t).indexOf(e)},a.getMaxLevelByMediaSize=function(e,t,r){if(!e||!e.length)return-1;for(var i,a=e.length-1,n=0;n<e.length;n+=1){var s=e[n];if((s.width>=t||s.height>=r)&&(s=s,!(i=e[n+1])||(s.width!==i.width||s.height!==i.height))){a=n;break}}return a},e=a,i=[{key:"contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(e){}return e}}],(r=[{key:"mediaWidth",get:function(){var e,t=this.media;return t&&(e=t.width||t.clientWidth||t.offsetWidth,e*=a.contentScaleFactor),e}},{key:"mediaHeight",get:function(){var e,t=this.media;return t&&(e=t.height||t.clientHeight||t.offsetHeight,e*=a.contentScaleFactor),e}}])&&Ye(e.prototype,r),i&&Ye(e,i),a}(n);var qe=window.performance,ze=function(t){var e;function r(e){return t.call(this,e,E.default.MEDIA_ATTACHING)||this}e=t,(i=r).prototype=Object.create(e.prototype),(i.prototype.constructor=i).__proto__=e;var i=r.prototype;return i.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},i.onMediaAttaching=function(e){var t=this.hls.config;t.capLevelOnFPSDrop&&("function"==typeof(this.video=e.media instanceof window.HTMLVideoElement?e.media:null).getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),t.fpsDroppedMonitoringPeriod))},i.checkFPS=function(e,t,r){var i,a,n,s,o=qe.now();t&&(this.lastTime&&(s=o-this.lastTime,i=r-this.lastDroppedFrames,a=t-this.lastDecodedFrames,s=1e3*i/s,(n=this.hls).trigger(E.default.FPS_DROP,{currentDropped:i,currentDecoded:a,totalDroppedFrames:r}),0<s&&i>n.config.fpsDroppedMonitoringThreshold*a&&(s=n.currentLevel,D.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),0<s&&(-1===n.autoLevelCapping||n.autoLevelCapping>=s)&&(n.trigger(E.default.FPS_DROP_LEVEL_CAPPING,{level:s-=1,droppedLevel:n.currentLevel}),n.autoLevelCapping=s,n.streamController.nextLevelSwitch()))),this.lastTime=o,this.lastDroppedFrames=r,this.lastDecodedFrames=t)},i.checkFPSInterval=function(){var e,t=this.video;t&&(this.isVideoPlaybackQualityAvailable?(e=t.getVideoPlaybackQuality(),this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)):this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount))},r}(n),Xe=window,Qe=Xe.performance,$e=Xe.XMLHttpRequest,Xe=function(){function e(e){e&&e.xhrSetup&&(this.xhrSetup=e.xhrSetup)}var t=e.prototype;return t.destroy=function(){this.abort(),this.loader=null},t.abort=function(){var e=this.loader;e&&4!==e.readyState&&(this.stats.aborted=!0,e.abort()),window.clearTimeout(this.requestTimeout),this.requestTimeout=null,window.clearTimeout(this.retryTimeout),this.retryTimeout=null},t.load=function(e,t,r){this.context=e,this.config=t,this.callbacks=r,this.stats={trequest:Qe.now(),retry:0},this.retryDelay=t.retryDelay,this.loadInternal()},t.loadInternal=function(){var t=this.context,r=this.loader=new $e,i=this.stats,i=(i.tfirst=0,i.loaded=0,this.xhrSetup);try{if(i)try{i(r,t.url)}catch(e){r.open("GET",t.url,!0),i(r,t.url)}r.readyState||r.open("GET",t.url,!0)}catch(e){return void this.callbacks.onError({code:r.status,text:e.message},t,r)}t.rangeEnd&&r.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=t.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),r.send()},t.readystatechange=function(e){var t,r,e=e.currentTarget,i=e.readyState,a=this.stats,n=this.context,s=this.config;a.aborted||2<=i&&(window.clearTimeout(this.requestTimeout),0===a.tfirst&&(a.tfirst=Math.max(Qe.now(),a.trequest)),4===i?200<=(i=e.status)&&i<300?(a.tload=Math.max(a.tfirst,Qe.now()),r="arraybuffer"===n.responseType?(t=e.response).byteLength:(t=e.responseText).length,a.loaded=a.total=r,r={url:e.responseURL,data:t},this.callbacks.onSuccess(r,a,n,e)):a.retry>=s.maxRetry||400<=i&&i<499?(D.logger.error(i+" while loading "+n.url),this.callbacks.onError({code:i,text:e.statusText},n,e)):(D.logger.warn(i+" while loading "+n.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),a.retry++):this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),s.timeout))},t.loadtimeout=function(){D.logger.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)},t.loadprogress=function(e){var t=e.currentTarget,r=this.stats,e=(r.loaded=e.loaded,e.lengthComputable&&(r.total=e.total),this.callbacks.onProgress);e&&e(r,this.context,null,t)},e}();function Je(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}W=function(t){function e(e){e=t.call(this,e,E.default.MANIFEST_LOADING,E.default.MANIFEST_PARSED,E.default.AUDIO_TRACK_LOADED,E.default.AUDIO_TRACK_SWITCHED,E.default.LEVEL_LOADED,E.default.ERROR)||this;return e._trackId=-1,e._selectDefaultTrack=!0,e.tracks=[],e.trackIdBlacklist=Object.create(null),e.audioGroupId=null,e}r=t,(a=e).prototype=Object.create(r.prototype),(a.prototype.constructor=a).__proto__=r;var r,i,a=e.prototype;return a.onManifestLoading=function(){this.tracks=[],this._trackId=-1,this._selectDefaultTrack=!0},a.onManifestParsed=function(e){e=this.tracks=e.audioTracks||[];this.hls.trigger(E.default.AUDIO_TRACKS_UPDATED,{audioTracks:e}),this._selectAudioGroup(this.hls.nextLoadLevel)},a.onAudioTrackLoaded=function(e){var t;e.id>=this.tracks.length?D.logger.warn("Invalid audio track id:",e.id):(D.logger.log("audioTrack "+e.id+" loaded"),this.tracks[e.id].details=e.details,e.details.live&&!this.hasInterval()&&(t=1e3*e.details.targetduration,this.setInterval(t)),!e.details.live&&this.hasInterval()&&this.clearInterval())},a.onAudioTrackSwitched=function(e){e=this.tracks[e.id].groupId;e&&this.audioGroupId!==e&&(this.audioGroupId=e)},a.onLevelLoaded=function(e){this._selectAudioGroup(e.level)},a.onError=function(e){e.type===d.ErrorTypes.NETWORK_ERROR&&(e.fatal&&this.clearInterval(),e.details===d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&(D.logger.warn("Network failure on audio-track id:",e.context.id),this._handleLoadError()))},a._setAudioTrack=function(e){var t,r,i;this._trackId===e&&this.tracks[this._trackId].details?D.logger.debug("Same id as current audio-track passed, and track details available -> no-op"):e<0||e>=this.tracks.length?D.logger.warn("Invalid id passed to audio-track controller"):(t=this.tracks[e],D.logger.log("Now switching to audio-track index "+e),this.clearInterval(),this._trackId=e,e=t.url,r=t.type,i=t.id,this.hls.trigger(E.default.AUDIO_TRACK_SWITCHING,{id:i,type:r,url:e}),this._loadTrackDetailsIfNeeded(t))},a.doTick=function(){this._updateTrack(this._trackId)},a._selectAudioGroup=function(e){var e=this.hls.levels[e];e&&e.audioGroupIds&&(e=e.audioGroupIds[e.urlId],this.audioGroupId!==e&&(this.audioGroupId=e,this._selectInitialAudioTrack()))},a._selectInitialAudioTrack=function(){var t,r,e,i=this,a=this.tracks;a.length&&(e=this.tracks[this._trackId],t=null,e&&(t=e.name),this._selectDefaultTrack&&((e=a.filter(function(e){return e.default})).length?a=e:D.logger.warn("No default audio tracks defined")),r=!1,(e=function(){a.forEach(function(e){r||i.audioGroupId&&e.groupId!==i.audioGroupId||t&&t!==e.name||(i._setAudioTrack(e.id),r=!0)})})(),r||(t=null,e()),r||(D.logger.error("No track found for running audio group-ID: "+this.audioGroupId),this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0})))},a._needsTrackLoading=function(e){var t=e.details,e=e.url;return!(t&&!t.live)&&!!e},a._loadTrackDetailsIfNeeded=function(e){var t;this._needsTrackLoading(e)&&(t=e.url,e=e.id,D.logger.log("loading audio-track playlist for id: "+e),this.hls.trigger(E.default.AUDIO_TRACK_LOADING,{url:t,id:e}))},a._updateTrack=function(e){e<0||e>=this.tracks.length||(this.clearInterval(),this._trackId=e,D.logger.log("trying to update audio-track "+e),e=this.tracks[e],this._loadTrackDetailsIfNeeded(e))},a._handleLoadError=function(){this.trackIdBlacklist[this._trackId]=!0;for(var e=this._trackId,t=this.tracks[e],r=t.name,i=t.language,t=t.groupId,a=(D.logger.warn("Loading failed on audio track id: "+e+", group-id: "+t+', name/language: "'+r+'" / "'+i+'"'),e),n=0;n<this.tracks.length;n++)if(!this.trackIdBlacklist[n]&&this.tracks[n].name===r){a=n;break}a!==e?(D.logger.log("Attempting audio-track fallback id:",a,"group-id:",this.tracks[a].groupId),this._setAudioTrack(a)):D.logger.warn('No fallback audio-track found for name/language: "'+r+'" / "'+i+'"')},r=e,(a=[{key:"audioTracks",get:function(){return this.tracks}},{key:"audioTrack",get:function(){return this._trackId},set:function(e){this._setAudioTrack(e),this._selectDefaultTrack=!1}}])&&Je(r.prototype,a),i&&Je(r,i),e}(W);function Ze(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function et(){return{decode:function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}}var tt=window.performance,rt=function(i){function e(e,t){var r=i.call(this,e,E.default.MEDIA_ATTACHED,E.default.MEDIA_DETACHING,E.default.AUDIO_TRACKS_UPDATED,E.default.AUDIO_TRACK_SWITCHING,E.default.AUDIO_TRACK_LOADED,E.default.KEY_LOADED,E.default.FRAG_LOADED,E.default.FRAG_PARSING_INIT_SEGMENT,E.default.FRAG_PARSING_DATA,E.default.FRAG_PARSED,E.default.ERROR,E.default.BUFFER_RESET,E.default.BUFFER_CREATED,E.default.BUFFER_APPENDED,E.default.BUFFER_FLUSHED,E.default.INIT_PTS_FOUND)||this;return r.fragmentTracker=t,r.config=e.config,r.audioCodecSwap=!1,r._state=pe,r.initPTS=[],r.waitingFragment=null,r.videoTrackCC=null,r}t=i,(a=e).prototype=Object.create(t.prototype),(a.prototype.constructor=a).__proto__=t;var t,r,a=e.prototype;return a.onInitPtsFound=function(e){var t=e.id,r=e.frag.cc,e=e.initPTS;"main"===t&&(this.initPTS[r]=e,this.videoTrackCC=r,D.logger.log("InitPTS for cc: "+r+" found from video track: "+e),this.state===Le&&this.tick())},a.startLoad=function(e){var t;this.tracks?(t=this.lastCurrentTime,this.stopLoad(),this.setInterval(100),(this.fragLoadError=0)<t&&-1===e?(D.logger.log("audio:override startPosition with lastCurrentTime @"+t.toFixed(3)),this.state=T):(this.lastCurrentTime=this.startPosition||e,this.state=me),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()):(this.startPosition=e,this.state=pe)},a.doTick=function(){var e,u,t,c,h=this.hls,f=h.config;switch(this.state){case ke:case ve:case Re:break;case me:this.state=be,this.loadedmetadata=!1;break;case T:var r=this.tracks;if(!r)break;if(!this.media&&(this.startFragRequested||!f.startFragPrefetch))break;if(this.loadedmetadata)e=this.media.currentTime;else if(void 0===(e=this.nextLoadPosition))break;var g=this.mediaBuffer||this.media,p=this.videoBuffer||this.media,i=Y.bufferInfo(g,e,f.maxBufferHole),p=Y.bufferInfo(p,e,f.maxBufferHole),a=i.len,n=i.end,s=this.fragPrevious,o=Math.min(f.maxBufferLength,f.maxMaxBufferLength),o=Math.max(o,p.len),p=this.audioSwitch,m=this.trackId;if((a<o||p)&&m<r.length){if(void 0===(t=r[m].details)){this.state=be;break}if(!p&&this._streamEnded(i,t))return this.hls.trigger(E.default.BUFFER_EOS,{type:"audio"}),void(this.state=Ae);var a=t.fragments,o=a.length,r=a[0].start,l=a[o-1].start+a[o-1].duration;if(p)if(t.live&&!t.PTSKnown)D.logger.log("switching audiotrack, live stream, unknown PTS,load first fragment"),n=0;else if(n=e,t.PTSKnown&&e<r){if(!(i.end>r||i.nextStart))return;D.logger.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=r+.05}if(t.initSegment&&!t.initSegment.data)d=t.initSegment;else if(n<=r){var d=a[0];if(null!==this.videoTrackCC&&d.cc!==this.videoTrackCC&&(c=this.videoTrackCC,d=V.search(a,function(e){return e.cc<c?1:e.cc>c?-1:0})),t.live&&d.loadIdx&&d.loadIdx===this.fragLoadIdx)return i=i.nextStart||r,D.logger.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(i+.05)),void(this.media.currentTime=i+.05)}else{var v=f.maxFragLookUpTolerance,i=s?a[s.sn-a[0].sn+1]:void 0,y=function(e){var t=Math.min(v,e.duration);return e.start+e.duration-t<=n?1:e.start-t>n&&e.start?-1:0},l=n<l?(l-v<n&&(v=0),i&&!y(i)?i:V.search(a,y)):a[o-1];l&&(r=(d=l).start,s&&d.level===s.level&&d.sn===s.sn&&(d.sn<t.endSN?(d=a[d.sn+1-t.startSN],D.logger.log("SN just loaded, load next one: "+d.sn)):d=null))}d&&(d.encrypted?(D.logger.log("Loading key for "+d.sn+" of ["+t.startSN+" ,"+t.endSN+"],track "+m),this.state=ye,h.trigger(E.default.KEY_LOADING,{frag:d})):(D.logger.log("Loading "+d.sn+", cc: "+d.cc+" of ["+t.startSN+" ,"+t.endSN+"],track "+m+", currentTime:"+e+",bufferEnd:"+n.toFixed(3)),this.fragCurrent=d,!p&&this.fragmentTracker.getState(d)!==B||("initSegment"!==d.sn&&(this.startFragRequested=!0),Object(w.isFiniteNumber)(d.sn)&&(this.nextLoadPosition=d.start+d.duration),h.trigger(E.default.FRAG_LOADING,{frag:d}),this.state=Ee)))}break;case be:(u=this.tracks[this.trackId])&&u.details&&(this.state=T);break;case Te:i=tt.now(),y=this.retryDate,o=(g=this.media)&&g.seeking;(!y||y<=i||o)&&(D.logger.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=T);break;case Le:l=this.videoTrackCC;if(void 0===this.initPTS[l])break;r=this.waitingFragment;r?l!==(s=r.frag.cc)?(u=this.tracks[this.trackId]).details&&u.details.live&&(D.logger.warn("Waiting fragment CC ("+s+") does not match video track CC ("+l+")"),this.waitingFragment=null,this.state=T):(this.state=Ee,this.onFragLoaded(this.waitingFragment),this.waitingFragment=null):this.state=T}},a.onMediaAttached=function(e){e=this.media=this.mediaBuffer=e.media,this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),e.addEventListener("seeking",this.onvseeking),e.addEventListener("ended",this.onvended),e=this.config;this.tracks&&e.autoStartLoad&&this.startLoad(e.startPosition)},a.onMediaDetaching=function(){var e=this.media;e&&e.ended&&(D.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onAudioTracksUpdated=function(e){D.logger.log("audio tracks updated"),this.tracks=e.audioTracks},a.onAudioTrackSwitching=function(e){var t=!!e.url;this.trackId=e.id,this.fragCurrent=null,this.state=ve,this.waitingFragment=null,t?this.setInterval(100):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),t&&(this.audioSwitch=!0,this.state=T),this.tick()},a.onAudioTrackLoaded=function(e){var t=e.details,e=e.id,r=this.tracks[e],i=t.totalduration,a=0;D.logger.log("track "+e+" loaded ["+t.startSN+","+t.endSN+"],duration:"+i),t.live?(e=r.details)&&0<t.fragments.length?(ae(e,t),a=t.fragments[0].start,t.PTSKnown?D.logger.log("live audio playlist sliding:"+a.toFixed(3)):D.logger.log("live audio playlist - outdated PTS, unknown sliding")):(t.PTSKnown=!1,D.logger.log("live audio playlist - first load, unknown sliding")):t.PTSKnown=!1,r.details=t,this.startFragRequested||(-1===this.startPosition&&(i=t.startTimeOffset,Object(w.isFiniteNumber)(i)?(D.logger.log("start time offset found in playlist, adjust startPosition to "+i),this.startPosition=i):t.live?(this.startPosition=this.computeLivePosition(a,t),D.logger.log("compute startPosition for audio-track to "+this.startPosition)):this.startPosition=0),this.nextLoadPosition=this.startPosition),this.state===be&&(this.state=T),this.tick()},a.onKeyLoaded=function(){this.state===ye&&(this.state=T,this.tick())},a.onFragLoaded=function(e){var t,r,i,a,n,s,o,l=this.fragCurrent,d=e.frag;this.state===Ee&&l&&"audio"===d.type&&d.level===l.level&&d.sn===l.sn&&(r=(t=(d=this.tracks[this.trackId]).details).totalduration,i=l.level,a=l.sn,n=l.cc,d=this.config.defaultAudioCodec||d.audioCodec||"mp4a.40.2",s=this.stats=e.stats,"initSegment"===a?(this.state=T,s.tparsed=s.tbuffered=tt.now(),t.initSegment.data=e.payload,this.hls.trigger(E.default.FRAG_BUFFERED,{stats:s,frag:l,id:"audio"}),this.tick()):(this.state=Se,this.appended=!1,this.demuxer||(this.demuxer=new ee(this.hls,"audio")),s=this.initPTS[n],o=t.initSegment?t.initSegment.data:[],t.initSegment||void 0!==s?(this.pendingBuffering=!0,D.logger.log("Demuxing "+a+" of ["+t.startSN+" ,"+t.endSN+"],track "+i),this.demuxer.push(e.payload,o,d,null,l,r,!1,s)):(D.logger.log("unknown video PTS for continuity counter "+n+", waiting for video PTS before demuxing audio frag "+a+" of ["+t.startSN+" ,"+t.endSN+"],track "+i),this.waitingFragment=e,this.state=Le))),this.fragLoadError=0},a.onFragParsingInitSegment=function(e){var t=this.fragCurrent,r=e.frag;t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===Se&&((r=e.tracks).video&&delete r.video,(t=r.audio)&&(t.levelCodec=t.codec,t.id=e.id,this.hls.trigger(E.default.BUFFER_CODECS,r),D.logger.log("audio track:audio,container:"+t.container+",codecs[level/parsed]=["+t.levelCodec+"/"+t.codec+"]"),(e=t.initSegment)&&(r={type:"audio",data:e,parent:"audio",content:"initSegment"},this.audioSwitch?this.pendingData=[r]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(E.default.BUFFER_APPENDING,r))),this.tick()))},a.onFragParsingData=function(t){var r=this,e=this.fragCurrent,i=t.frag;if(e&&"audio"===t.id&&"audio"===t.type&&i.sn===e.sn&&i.level===e.level&&this.state===Se){var i=this.trackId,a=this.tracks[i],n=this.hls,a=(Object(w.isFiniteNumber)(t.endPTS)||(t.endPTS=t.startPTS+e.duration,t.endDTS=t.startDTS+e.duration),e.addElementaryStream(h.AUDIO),D.logger.log("parsed "+t.type+",PTS:["+t.startPTS.toFixed(3)+","+t.endPTS.toFixed(3)+"],DTS:["+t.startDTS.toFixed(3)+"/"+t.endDTS.toFixed(3)+"],nb:"+t.nb),ie(a.details,e,t.startPTS,t.endPTS),this.audioSwitch),e=this.media,s=!1,o=(a&&(e&&e.readyState?(a=e.currentTime,D.logger.log("switching audio track : currentTime:"+a),a>=t.startPTS&&(D.logger.log("switching audio track : flushing all audio"),this.state=Re,n.trigger(E.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),this.audioSwitch=!(s=!0),n.trigger(E.default.AUDIO_TRACK_SWITCHED,{id:i}))):(this.audioSwitch=!1,n.trigger(E.default.AUDIO_TRACK_SWITCHED,{id:i}))),this.pendingData);if(!o)return D.logger.warn("Apparently attempt to enqueue media payload without codec initialization data upfront"),void n.trigger(E.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:null,fatal:!0});this.audioSwitch||([t.data1,t.data2].forEach(function(e){e&&e.length&&o.push({type:t.type,data:e,parent:"audio",content:"data"})}),!s&&o.length&&(o.forEach(function(e){r.state===Se&&(r.pendingBuffering=!0,r.hls.trigger(E.default.BUFFER_APPENDING,e))}),this.pendingData=[],this.appended=!0)),this.tick()}},a.onFragParsed=function(e){var t=this.fragCurrent,r=e.frag;t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===Se&&(this.stats.tparsed=tt.now(),this.state=_e,this._checkAppendedParsed())},a.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},a.onBufferCreated=function(e){var t=e.tracks.audio;t&&(this.mediaBuffer=t.buffer,this.loadedmetadata=!0),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer)},a.onBufferAppended=function(e){var t;"audio"===e.parent&&((t=this.state)!==Se&&t!==_e||(this.pendingBuffering=0<e.pending,this._checkAppendedParsed()))},a._checkAppendedParsed=function(){var e,t,r;this.state!==_e||this.appended&&this.pendingBuffering||(e=this.fragCurrent,r=this.stats,t=this.hls,e&&(this.fragPrevious=e,r.tbuffered=tt.now(),t.trigger(E.default.FRAG_BUFFERED,{stats:r,frag:e,id:"audio"}),(r=this.mediaBuffer||this.media)&&D.logger.log("audio buffered : "+oe.toString(r.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,t.trigger(E.default.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=T),this.tick())},a.onError=function(e){var t=e.frag;if(!t||"audio"===t.type)switch(e.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:var r,i=e.frag;if(i&&"audio"!==i.type)break;e.fatal||((i=this.fragLoadError)?i++:i=1,i<=(r=this.config).fragLoadingMaxRetry?(this.fragLoadError=i,i=Math.min(Math.pow(2,i-1)*r.fragLoadingRetryDelay,r.fragLoadingMaxRetryTimeout),D.logger.warn("AudioStreamController: frag loading failed, retry in "+i+" ms"),this.retryDate=tt.now()+i,this.state=Te):(D.logger.error("AudioStreamController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=ke));break;case d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case d.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:this.state!==ke&&(this.state=e.fatal?ke:T,D.logger.warn("AudioStreamController: "+e.details+" while loading frag, now switching to "+this.state+" state ..."));break;case d.ErrorDetails.BUFFER_FULL_ERROR:"audio"!==e.parent||this.state!==Se&&this.state!==_e||(r=this.mediaBuffer,i=this.media.currentTime,r&&Y.isBuffered(r,i)&&Y.isBuffered(r,i+.5)?((r=this.config).maxMaxBufferLength>=r.maxBufferLength&&(r.maxMaxBufferLength/=2,D.logger.warn("AudioStreamController: reduce max buffer length to "+r.maxMaxBufferLength+"s")),this.state=T):(D.logger.warn("AudioStreamController: buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=Re,this.hls.trigger(E.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})))}},a.onBufferFlushed=function(){var t=this,e=this.pendingData;e&&e.length?(D.logger.log("AudioStreamController: appending pending audio data after buffer flushed"),e.forEach(function(e){t.hls.trigger(E.default.BUFFER_APPENDING,e)}),this.appended=!0,this.pendingData=[],this.state=_e):(this.state=T,this.fragPrevious=null,this.tick())},t=e,(a=[{key:"state",set:function(e){var t;this.state!==e&&(t=this.state,this._state=e,D.logger.log("audio stream:"+t+"->"+e))},get:function(){return this._state}}])&&Ze(t.prototype,a),r&&Ze(t,r),e}(Q),it=function(){if("undefined"!=typeof window&&window.VTTCue)return window.VTTCue;var E={"":!0,lr:!0,rl:!0},t={start:!0,middle:!0,end:!0,left:!0,right:!0};function T(e){return"string"==typeof e&&(!!t[e.toLowerCase()]&&e.toLowerCase())}function b(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)e[r]=i[r]}return e}function e(u,c,h){var e=this,t={enumerable:!0},r=(e.hasBeenReset=!1,""),i=!1,a=u,n=c,s=h,o=null,l="",d=!0,f="auto",g="start",p=50,m="middle",v=50,y="middle";Object.defineProperty(e,"id",b({},t,{get:function(){return r},set:function(e){r=""+e}})),Object.defineProperty(e,"pauseOnExit",b({},t,{get:function(){return i},set:function(e){i=!!e}})),Object.defineProperty(e,"startTime",b({},t,{get:function(){return a},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");a=e,this.hasBeenReset=!0}})),Object.defineProperty(e,"endTime",b({},t,{get:function(){return n},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");n=e,this.hasBeenReset=!0}})),Object.defineProperty(e,"text",b({},t,{get:function(){return s},set:function(e){s=""+e,this.hasBeenReset=!0}})),Object.defineProperty(e,"region",b({},t,{get:function(){return o},set:function(e){o=e,this.hasBeenReset=!0}})),Object.defineProperty(e,"vertical",b({},t,{get:function(){return l},set:function(e){e="string"==typeof(e=e)&&(!!E[e.toLowerCase()]&&e.toLowerCase());if(!1===e)throw new SyntaxError("An invalid or illegal string was specified.");l=e,this.hasBeenReset=!0}})),Object.defineProperty(e,"snapToLines",b({},t,{get:function(){return d},set:function(e){d=!!e,this.hasBeenReset=!0}})),Object.defineProperty(e,"line",b({},t,{get:function(){return f},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");f=e,this.hasBeenReset=!0}})),Object.defineProperty(e,"lineAlign",b({},t,{get:function(){return g},set:function(e){e=T(e);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");g=e,this.hasBeenReset=!0}})),Object.defineProperty(e,"position",b({},t,{get:function(){return p},set:function(e){if(e<0||100<e)throw new Error("Position must be between 0 and 100.");p=e,this.hasBeenReset=!0}})),Object.defineProperty(e,"positionAlign",b({},t,{get:function(){return m},set:function(e){e=T(e);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");m=e,this.hasBeenReset=!0}})),Object.defineProperty(e,"size",b({},t,{get:function(){return v},set:function(e){if(e<0||100<e)throw new Error("Size must be between 0 and 100.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(e,"align",b({},t,{get:function(){return y},set:function(e){e=T(e);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");y=e,this.hasBeenReset=!0}})),e.displayState=void 0}return e.prototype.getCueAsHTML=function(){return window.WebVTT.convertCueToDOMTree(window,this.text)},e}();function at(){this.window=window,this.state="INITIAL",this.buffer="",this.decoder=new et,this.regionList=[]}function nt(){this.values=Object.create(null)}function st(e,t,r,i){var a,n,s=i?e.split(i):[e];for(a in s)"string"==typeof s[a]&&(2===(n=s[a].split(r)).length&&t(n[0],n[1]))}nt.prototype={set:function(e,t){this.get(e)||""===t||(this.values[e]=t)},get:function(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t},has:function(e){return e in this.values},alt:function(e,t,r){for(var i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}},integer:function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},percent:function(e,t){return!!(t.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&0<=(t=parseFloat(t))&&t<=100)&&(this.set(e,t),!0)}};var ot=new it(0,0,0),lt="middle"===ot.align?"middle":"center";function dt(r,e,n){var t,s,i=r;function a(){var e=(e=(e=r).match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/))?e[3]?t(e[1],e[2],e[3].replace(":",""),e[4]):59<e[1]?t(e[1],e[2],0,e[4]):t(0,e[1],e[2],e[4]):null;function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+(0|i)/1e3}if(null===e)throw new Error("Malformed timestamp: "+i);return r=r.replace(/^[^\sa-zA-Z-]+/,""),e}function o(){r=r.replace(/^\s+/,"")}if(o(),e.startTime=a(),o(),"--\x3e"!==r.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);r=r.substr(3),o(),e.endTime=a(),o(),t=r,e=e,s=new nt,st(t,function(e,t){switch(e){case"region":for(var r=n.length-1;0<=r;r--)if(n[r].id===t){s.set(e,n[r].region);break}break;case"vertical":s.alt(e,t,["rl","lr"]);break;case"line":var i=t.split(","),a=i[0];s.integer(e,a),s.percent(e,a)&&s.set("snapToLines",!1),s.alt(e,a,["auto"]),2===i.length&&s.alt("lineAlign",i[1],["start",lt,"end"]);break;case"position":i=t.split(","),s.percent(e,i[0]),2===i.length&&s.alt("positionAlign",i[1],["start",lt,"end","line-left","line-right","auto"]);break;case"size":s.percent(e,t);break;case"align":s.alt(e,t,["start",lt,"end","left","right"])}},/:/,/\s/),e.region=s.get("region",null),e.vertical=s.get("vertical",""),"auto"===(t=s.get("line","auto"))&&-1===ot.line&&(t=-1),e.line=t,e.lineAlign=s.get("lineAlign","start"),e.snapToLines=s.get("snapToLines",!0),e.size=s.get("size",100),e.align=s.get("align",lt),"auto"===(t=s.get("position","auto"))&&50===ot.position&&(t="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=t}function ut(e){return e.replace(/<br(?: \/)?>/gi,"\n")}at.prototype={parse:function(e){var i=this;function t(){for(var e=0,t=ut(t=i.buffer);e<t.length&&"\r"!==t[e]&&"\n"!==t[e];)++e;var r=t.substr(0,e);return"\r"===t[e]&&++e,"\n"===t[e]&&++e,i.buffer=t.substr(e),r}e&&(i.buffer+=i.decoder.decode(e,{stream:!0}));try{if("INITIAL"===i.state){if(!/\r\n|\n/.test(i.buffer))return this;var r,a=(r=t()).match(/^()?WEBVTT([ \t].*)?$/);if(!a||!a[0])throw new Error("Malformed WebVTT signature.");i.state="HEADER"}for(var n=!1;i.buffer;){if(!/\r\n|\n/.test(i.buffer))return this;switch(n?n=!1:r=t(),i.state){case"HEADER":/:/.test(r)?st(r,function(e,t){e},/:/):r||(i.state="ID");continue;case"NOTE":r||(i.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(r)){i.state="NOTE";break}if(!r)continue;if(i.cue=new it(0,0,""),i.state="CUE",-1===r.indexOf("--\x3e")){i.cue.id=r;continue}case"CUE":try{dt(r,i.cue,i.regionList)}catch(e){i.cue=null,i.state="BADCUE";continue}i.state="CUETEXT";continue;case"CUETEXT":var s=-1!==r.indexOf("--\x3e");if(!r||s&&(n=!0)){i.oncue&&i.oncue(i.cue),i.cue=null,i.state="ID";continue}i.cue.text&&(i.cue.text+="\n"),i.cue.text+=r;continue;case"BADCUE":r||(i.state="ID");continue}}}catch(e){"CUETEXT"===i.state&&i.cue&&i.oncue&&i.oncue(i.cue),i.cue=null,i.state="INITIAL"===i.state?"BADWEBVTT":"BADCUE"}return this},flush:function(){try{if(this.buffer+=this.decoder.decode(),!this.cue&&"HEADER"!==this.state||(this.buffer+="\n\n",this.parse()),"INITIAL"===this.state)throw new Error("Malformed WebVTT signature.")}catch(e){throw e}return this.onflush&&this.onflush(),this}};var ct=at;function ht(u,e,t,r){for(var i,a,n,s,o,c=window.VTTCue||TextTrackCue,l=0;l<r.rows.length;l++)if(n=!0,s=0,o="",!(i=r.rows[l]).isEmpty()){for(var d=0;d<i.chars.length;d++)i.chars[d].uchar.match(/\s/)&&n?s++:(o+=i.chars[d].uchar,n=!1);(i.cueStartTime=e)===t&&(t+=1e-4),a=new c(e,t,ut(o.trim())),16<=s?s--:s++,navigator.userAgent.match(/Firefox\//)?a.line=l+1:a.line=7<l?l-2:l+1,a.align="left",a.position=Math.max(0,Math.min(100,s/32*100)),u.addCue(a)}}function ft(e){var t=e;return vt.hasOwnProperty(e)&&(t=vt[e]),String.fromCharCode(t)}function gt(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t}function pt(e,t,r){return e.substr(r||0,t.length)===t}function mt(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}var vt={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},yt=100,Et={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Tt={17:2,18:4,21:6,22:8,23:10,19:13,20:15},bt={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},St={25:2,26:4,29:6,30:8,31:10,27:13,28:15},_t=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],l=((xt={ERROR:0,0:"ERROR",TEXT:1,1:"TEXT",WARNING:2,2:"WARNING",INFO:2})[2]="INFO",xt[xt.DEBUG=3]="DEBUG",xt[xt.DATA=3]="DATA",{verboseFilter:{DATA:3,DEBUG:3,INFO:2,WARNING:2,TEXT:1,ERROR:0},time:null,verboseLevel:0,setTime:function(e){this.time=e},log:function(e,t){this.verboseFilter[e];this.verboseLevel}}),Rt=function(){function e(e,t,r,i,a){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=i||"black",this.flash=a||!1}var t=e.prototype;return t.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},t.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}},t.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},t.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},t.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},t.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},e}(),At=function(){function e(e,t,r,i,a,n){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new Rt(t,r,i,a,n)}var t=e.prototype;return t.reset=function(){this.uchar=" ",this.penState.reset()},t.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},t.setPenState=function(e){this.penState.copy(e)},t.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},t.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},t.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},e}(),kt=function(){function e(){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.chars=[];for(var e=0;e<yt;e++)this.chars.push(new At);this.pos=0,this.currPenState=new Rt}var t=e.prototype;return t.equals=function(e){for(var t=!0,r=0;r<yt;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<yt;t++)this.chars[t].copy(e.chars[t])},t.isEmpty=function(){for(var e=!0,t=0;t<yt;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},t.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(l.log("ERROR","Negative cursor position "+this.pos),this.pos=0):this.pos>yt&&(l.log("ERROR","Too large cursor position "+this.pos),this.pos=yt)},t.moveCursor=function(e){var t=this.pos+e;if(1<e)for(var r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)},t.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},t.insertChar=function(e){144<=e&&this.backSpace();var t=ft(e);this.pos>=yt?l.log("ERROR","Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))},t.clearFromPos=function(e){for(var t=e;t<yt;t++)this.chars[t].reset()},t.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},t.clearToEndOfRow=function(){this.clearFromPos(this.pos)},t.getTextString=function(){for(var e=[],t=!0,r=0;r<yt;r++){var i=this.chars[r].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")},t.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},e}(),Lt=function(){function e(){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.rows=[];for(var e=0;e<15;e++)this.rows.push(new kt);this.currRow=14,this.nrRollUpRows=null,this.reset()}var t=e.prototype;return t.reset=function(){for(var e=0;e<15;e++)this.rows[e].clear();this.currRow=14},t.equals=function(e){for(var t=!0,r=0;r<15;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<15;t++)this.rows[t].copy(e.rows[t])},t.isEmpty=function(){for(var e=!0,t=0;t<15;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},t.backSpace=function(){this.rows[this.currRow].backSpace()},t.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},t.insertChar=function(e){this.rows[this.currRow].insertChar(e)},t.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},t.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},t.setCursor=function(e){l.log("INFO","setCursor: "+e),this.rows[this.currRow].setCursor(e)},t.setPAC=function(e){l.log("INFO","pacData = "+JSON.stringify(e));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var r=0;r<15;r++)this.rows[r].clear();var i=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var n=a.rows[i].cueStartTime;if(n&&l.time&&n<l.time)for(var s=0;s<this.nrRollUpRows;s++)this.rows[t-this.nrRollUpRows+s+1].copy(a.rows[i+s])}}this.currRow=t;var o,n=this.rows[this.currRow],n=(null!==e.indent&&(o=e.indent,o=Math.max(o-1,0),n.setCursor(e.indent),e.color=n.chars[o].penState.foreground),{foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1});this.setPen(n)},t.setBkgData=function(e){l.log("INFO","bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)},t.setRollUpRows=function(e){this.nrRollUpRows=e},t.rollUp=function(){var e;null!==this.nrRollUpRows?(l.log("TEXT",this.getDisplayText()),e=this.currRow+1-this.nrRollUpRows,(e=this.rows.splice(e,1)[0]).clear(),this.rows.splice(this.currRow,0,e),l.log("INFO","Rolling up")):l.log("DEBUG","roll_up but nrRollUpRows not set yet")},t.getDisplayText=function(e){e=e||!1;for(var t=[],r="",i=0;i<15;i++){var a=this.rows[i].getTextString();a&&(e?t.push("Row "+(i+1)+": '"+a+"'"):t.push(a.trim()))}return r=0<t.length?e?"["+t.join(" | ")+"]":t.join("\n"):r},t.getTextAndFormat=function(){return this.rows},e}(),wt=function(){function e(e,t){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.lastCueEndTime=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Lt,this.nonDisplayedMemory=new Lt,this.lastOutputScreen=new Lt,this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}var t=e.prototype;return t.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},t.getHandler=function(){return this.outputFilter},t.setHandler=function(e){this.outputFilter=e},t.setPAC=function(e){this.writeScreen.setPAC(e)},t.setBkgData=function(e){this.writeScreen.setBkgData(e)},t.setMode=function(e){e!==this.mode&&(this.mode=e,l.log("INFO","MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)},t.insertChars=function(e){for(var t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);var r=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";l.log("INFO",r+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(l.log("TEXT","DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},t.ccRCL=function(){l.log("INFO","RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},t.ccBS=function(){l.log("INFO","BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},t.ccAOF=function(){},t.ccAON=function(){},t.ccDER=function(){l.log("INFO","DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},t.ccRU=function(e){l.log("INFO","RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},t.ccFON=function(){l.log("INFO","FON - Flash On"),this.writeScreen.setPen({flash:!0})},t.ccRDC=function(){l.log("INFO","RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},t.ccTR=function(){l.log("INFO","TR"),this.setMode("MODE_TEXT")},t.ccRTD=function(){l.log("INFO","RTD"),this.setMode("MODE_TEXT")},t.ccEDM=function(){l.log("INFO","EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},t.ccCR=function(){l.log("INFO","CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},t.ccENM=function(){l.log("INFO","ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},t.ccEOC=function(){var e;l.log("INFO","EOC - End Of Caption"),"MODE_POP-ON"===this.mode&&(e=this.displayedMemory,this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,l.log("TEXT","DISP: "+this.displayedMemory.getDisplayText())),this.outputDataUpdate(!0)},t.ccTO=function(e){l.log("INFO","TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},t.ccMIDROW=function(e){var t={flash:!1};t.underline=e%2==1,t.italics=46<=e,t.italics?t.foreground="white":(e=Math.floor(e/2)-16,t.foreground=["white","green","blue","cyan","red","yellow","magenta"][e]),l.log("INFO","MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},t.outputDataUpdate=function(e){void 0===e&&(e=!1);var t=l.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},t.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},e}(),Dt=function(){function e(e,t,r){this.field=void 0,this.outputs=void 0,this.channels=void 0,this.currChNr=void 0,this.lastCmdA=void 0,this.lastCmdB=void 0,this.lastTime=void 0,this.dataCounters=void 0,this.field=e||1,this.outputs=[t,r],this.channels=[new wt(1,t),new wt(2,r)],this.currChNr=-1,this.lastCmdA=null,this.lastCmdB=null,this.lastTime=null,this.dataCounters={padding:0,char:0,cmd:0,other:0}}var t=e.prototype;return t.getHandler=function(e){return this.channels[e].getHandler()},t.setHandler=function(e,t){this.channels[e].setHandler(t)},t.addData=function(e,t){var r,i=!1;this.lastTime=e,l.setTime(e);for(var a=0;a<t.length;a+=2){var n=127&t[a],s=127&t[a+1];0!=n||0!=s?(l.log("DATA","["+gt([t[a],t[a+1]])+"] -> ("+gt([n,s])+")"),(r=(r=(r=(r=this.parseCmd(n,s))||this.parseMidrow(n,s))||this.parsePAC(n,s))||this.parseBackgroundAttributes(n,s))||(i=this.parseChars(n,s))&&(this.currChNr&&0<=this.currChNr?this.channels[this.currChNr-1].insertChars(i):l.log("WARNING","No channel found yet. TEXT-MODE?")),r?this.dataCounters.cmd+=2:i?this.dataCounters.char+=2:(this.dataCounters.other+=2,l.log("WARNING","Couldn't parse cleaned data "+gt([n,s])+" orig: "+gt([t[a],t[a+1]])))):this.dataCounters.padding+=2}},t.parseCmd=function(e,t){var r=null;if(!((20===e||28===e)&&32<=t&&t<=47)&&!((23===e||31===e)&&33<=t&&t<=35))return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,l.log("DEBUG","Repeated command ("+gt([e,t])+") is dropped"),!0;var r=20===e||23===e?1:2,i=this.channels[r-1];return 20===e||28===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=r,!0},t.parseMidrow=function(e,t){var r=null;return(17===e||25===e)&&32<=t&&t<=47&&((r=17===e?1:2)!==this.currChNr?(l.log("ERROR","Mismatch channel in midrow parsing"),!1):(this.channels[r-1].ccMIDROW(t),l.log("DEBUG","MIDROW ("+gt([e,t])+")"),!0))},t.parsePAC=function(e,t){var r=null;if(!((17<=e&&e<=23||25<=e&&e<=31)&&64<=t&&t<=127)&&!((16===e||24===e)&&64<=t&&t<=95))return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,!(this.lastCmdB=null);var i=e<=23?1:2,r=(64<=t&&t<=95?1==i?Et:bt:1==i?Tt:St)[e],r=this.interpretPAC(r,t);return this.channels[i-1].setPAC(r),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=i,!0},t.interpretPAC=function(e,t){var r=t,e={color:null,italics:!1,indent:null,underline:!1,row:e},r=95<t?t-96:t-64;return e.underline=1==(1&r),r<=13?e.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(e.italics=!0,e.color="white"):e.indent=4*Math.floor((r-16)/2),e},t.parseChars=function(e,t){var r,i=null,a=null,n=null;return 17<=(n=25<=e?(i=2,e-8):(i=1,e))&&n<=19?(r=t,l.log("INFO","Special char '"+ft(r=17===n?t+80:18===n?t+112:t+144)+"' in channel "+i),a=[r]):32<=e&&e<=127&&(a=0===t?[e]:[e,t]),a&&(n=gt(a),l.log("DEBUG","Char codes = "+n.join(",")),this.lastCmdA=null,this.lastCmdB=null),a},t.parseBackgroundAttributes=function(e,t){var r,i;return((16===e||24===e)&&32<=t&&t<=47||(23===e||31===e)&&45<=t&&t<=47)&&(r={},16===e||24===e?(i=Math.floor((t-32)/2),r.background=_t[i],t%2==1&&(r.background=r.background+"_semi")):45===t?r.background="transparent":(r.foreground="black",47===t&&(r.underline=!0)),this.channels[(e<24?1:2)-1].setBkgData(r),this.lastCmdA=null,!(this.lastCmdB=null))},t.reset=function(){for(var e=0;e<this.channels.length;e++)this.channels[e]&&this.channels[e].reset();this.lastCmdA=null,this.lastCmdB=null},t.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++)this.channels[t]&&this.channels[t].cueSplitAtTime(e)},e}(),Ot=function(){function e(e,t){this.timelineController=void 0,this.trackName=void 0,this.startTime=void 0,this.endTime=void 0,this.screen=void 0,this.timelineController=e,this.trackName=t,this.startTime=null,this.endTime=null,this.screen=null}var t=e.prototype;return t.dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen),this.startTime=null)},t.newCue=function(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},e}(),Ct={parse:function(e,t,i,a,c,h){var r,e=Object(Pe.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(/\r\n|\n\r|\n|\r/g,"\n").split("\n"),f="00:00.000",n=0,s=0,o=0,g=[],l=!0,d=!1,u=new ct;u.oncue=function(e){var t=i[a],r=i.ccOffset;t&&t.new&&(void 0!==s?r=i.ccOffset=t.start:function(e,t,r){var i=e[t],a=e[i.prevCC];if(!a||!a.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,i.new=!1;for(;a&&a.new;)e.ccOffset+=i.start-a.start,i.new=!1,a=e[(i=a).prevCC];e.presentationOffset=r}(i,a,o)),o&&(r=o-i.presentationOffset),d&&(e.startTime+=r-s,e.endTime+=r-s),e.id=mt(e.startTime.toString())+mt(e.endTime.toString())+mt(e.text),e.text=decodeURIComponent(encodeURIComponent(e.text)),0<e.endTime&&g.push(e)},u.onparsingerror=function(e){r=e},u.onflush=function(){r&&h?h(r):c(g)},e.forEach(function(e){if(l){if(pt(e,"X-TIMESTAMP-MAP=")){d=!(l=!1),e.substr(16).split(",").forEach(function(e){pt(e,"LOCAL:")?f=e.substr(6):pt(e,"MPEGTS:")&&(n=parseInt(e.substr(7)))});try{t+(9e4*i[a].start||0)<0&&(t+=8589934592),n-=t,s=function(e){var t=parseInt(e.substr(-3)),r=parseInt(e.substr(-6,2)),i=parseInt(e.substr(-9,2)),a=9<e.length?parseInt(e.substr(0,e.indexOf(":"))):0;if(!(Object(w.isFiniteNumber)(t)&&Object(w.isFiniteNumber)(r)&&Object(w.isFiniteNumber)(i)&&Object(w.isFiniteNumber)(a)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e);return(t+=1e3*r)+6e4*i+36e5*a}(f)/1e3,o=n/9e4}catch(e){d=!1,r=e}return}""===e&&(l=!1)}u.parse(e+"\n")}),u.flush()}};function It(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var xt=function(i){var e;function t(e){var t,r=i.call(this,e,E.default.MEDIA_ATTACHING,E.default.MEDIA_DETACHING,E.default.FRAG_PARSING_USERDATA,E.default.FRAG_DECRYPTED,E.default.MANIFEST_LOADING,E.default.MANIFEST_LOADED,E.default.FRAG_LOADED,E.default.INIT_PTS_FOUND)||this;return r.media=null,r.config=void 0,r.enabled=!0,r.Cues=void 0,r.textTracks=[],r.tracks=[],r.initPTS=[],r.unparsedVttFrags=[],r.cueRanges=[],r.captionsTracks={},r.captionsProperties=void 0,r.cea608Parser=void 0,r.lastSn=-1,r.prevCC=-1,r.vttCCs=null,r.hls=e,r.config=e.config,r.Cues=e.config.cueHandler,r.captionsProperties={textTrack1:{label:r.config.captionsTextTrack1Label,languageCode:r.config.captionsTextTrack1LanguageCode},textTrack2:{label:r.config.captionsTextTrack2Label,languageCode:r.config.captionsTextTrack2LanguageCode}},r.config.enableCEA708Captions&&(e=new Ot(It(r),"textTrack1"),t=new Ot(It(r),"textTrack2"),r.cea608Parser=new Dt(0,e,t)),r}e=i,(r=t).prototype=Object.create(e.prototype),(r.prototype.constructor=r).__proto__=e;var r=t.prototype;return r.addCues=function(e,t,r,u){for(var i,a,n=this.cueRanges,s=!1,o=n.length;o--;){var l=n[o],d=(i=l[0],d=l[1],a=t,Math.min(d,r)-Math.max(i,a));if(0<=d&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],r),s=!0,.5<d/(r-t)))return}s||n.push([t,r]),this.Cues.newCue(this.captionsTracks[e],t,r,u)},r.onInitPtsFound=function(e){var t=this,r=e.frag,i=e.id,e=e.initPTS,a=this.unparsedVttFrags;"main"===i&&(this.initPTS[r.cc]=e),a.length&&(this.unparsedVttFrags=[],a.forEach(function(e){t.onFragLoaded(e)}))},r.getExistingTrack=function(e){var t=this.media;if(t)for(var r=0;r<t.textTracks.length;r++){var i=t.textTracks[r];if(i[e])return i}return null},r.createCaptionsTrack=function(e){var t,r=this.captionsProperties,i=this.captionsTracks,a=this.media,r=r[e],n=r.label,r=r.languageCode;i[e]||((t=this.getExistingTrack(e))?(i[e]=t,Me(i[e]),Fe(i[e],a)):(t=this.createTextTrack("captions",n,r))&&(t[e]=!0,i[e]=t))},r.createTextTrack=function(e,t,r){var i=this.media;if(i)return i.addTextTrack(e,t,r)},r.destroy=function(){i.prototype.destroy.call(this)},r.onMediaAttaching=function(e){this.media=e.media,this._cleanTracks()},r.onMediaDetaching=function(){var t=this.captionsTracks;Object.keys(t).forEach(function(e){Me(t[e]),delete t[e]})},r.onManifestLoading=function(){this.lastSn=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this._cleanTracks()},r._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)Me(t[r])}},r.onManifestLoaded=function(e){var o,l=this;this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.cueRanges=[],this.config.enableWebVTT&&(this.tracks=e.subtitles||[],o=this.media?this.media.textTracks:[],this.tracks.forEach(function(e,t){var r,i,a;if(t<o.length){for(var n=null,s=0;s<o.length;s++)if(i=o[s],a=e,i&&i.label===a.name&&!(i.textTrack1||i.textTrack2)){n=o[s];break}n&&(r=n)}r=r||l.createTextTrack("subtitles",e.name,e.lang),e.default?r.mode=l.hls.subtitleDisplay?"showing":"hidden":r.mode="disabled",l.textTracks.push(r)}))},r.onFragLoaded=function(e){var t=e.frag,r=e.payload,i=this.cea608Parser,a=this.initPTS,n=this.lastSn,s=this.unparsedVttFrags;if("main"===t.type){var o=t.sn;t.sn!==n+1&&i&&i.reset(),this.lastSn=o}else if("subtitle"===t.type)if(r.byteLength){if(!Object(w.isFiniteNumber)(a[t.cc]))return s.push(e),void(a.length&&this.hls.trigger(E.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t}));n=t.decryptdata;null!=n&&null!=n.key&&"AES-128"===n.method||this._parseVTTs(t,r)}else this.hls.trigger(E.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t})},r._parseVTTs=function(t,e){var r=this.hls,i=this.prevCC,a=this.textTracks,n=this.vttCCs;n[t.cc]||(n[t.cc]={start:t.start,prevCC:i,new:!0},this.prevCC=t.cc),Ct.parse(e,this.initPTS[t.cc],n,t.cc,function(e){var i=a[t.level];"disabled"!==i.mode?(e.forEach(function(t){if(!i.cues.getCueById(t.id))try{if(i.addCue(t),!i.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(e){D.logger.debug("Failed occurred on adding cues: "+e);var r=new window.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,i.addCue(r)}}),r.trigger(E.default.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})):r.trigger(E.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t})},function(e){D.logger.log("Failed to parse VTT cue: "+e),r.trigger(E.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t})})},r.onFragDecrypted=function(e){var t=e.frag,r=e.payload;"subtitle"===t.type&&(Object(w.isFiniteNumber)(this.initPTS[t.cc])?this._parseVTTs(t,r):this.unparsedVttFrags.push(e))},r.onFragParsingUserdata=function(e){if(this.enabled&&this.cea608Parser)for(var t=0;t<e.samples.length;t++){var r=e.samples[t].bytes;r&&(r=this.extractCea608Data(r),this.cea608Parser.addData(e.samples[t].pts,r))}},r.extractCea608Data=function(e){for(var t,r,i,a=31&e[0],n=2,s=[],o=0;o<a;o++)t=e[n++],r=127&e[n++],i=127&e[n++],0==r&&0==i||0!=(4&t)&&0==(3&t)&&(s.push(r),s.push(i));return s},t}(n);function Pt(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function Ft(e){for(var t=[],r=0;r<e.length;r++){var i=e[r];"subtitles"===i.kind&&i.label&&t.push(e[r])}return t}var Mt=function(t){function e(e){e=t.call(this,e,E.default.MEDIA_ATTACHED,E.default.MEDIA_DETACHING,E.default.MANIFEST_LOADED,E.default.SUBTITLE_TRACK_LOADED)||this;return e.tracks=[],e.trackId=-1,e.media=null,e.stopped=!0,e.subtitleDisplay=!0,e.queuedDefaultTrack=null,e}r=t,(a=e).prototype=Object.create(r.prototype),(a.prototype.constructor=a).__proto__=r;var r,i,a=e.prototype;return a.destroy=function(){n.prototype.destroy.call(this)},a.onMediaAttached=function(e){var t=this;this.media=e.media,this.media&&(Object(w.isFiniteNumber)(this.queuedDefaultTrack)&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=null),this.trackChangeListener=this._onTextTracksChanged.bind(this),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.subtitlePollingInterval=setInterval(function(){t.trackChangeListener()},500):this.media.textTracks.addEventListener("change",this.trackChangeListener))},a.onMediaDetaching=function(){this.media&&(this.useTextTrackPolling?clearInterval(this.subtitlePollingInterval):this.media.textTracks.removeEventListener("change",this.trackChangeListener),Object(w.isFiniteNumber)(this.subtitleTrack)&&(this.queuedDefaultTrack=this.subtitleTrack),Ft(this.media.textTracks).forEach(function(e){Me(e)}),this.subtitleTrack=-1,this.media=null)},a.onManifestLoaded=function(e){var t=this,e=e.subtitles||[];this.tracks=e,this.hls.trigger(E.default.SUBTITLE_TRACKS_UPDATED,{subtitleTracks:e}),e.forEach(function(e){e.default&&(t.media?t.subtitleTrack=e.id:t.queuedDefaultTrack=e.id)})},a.onSubtitleTrackLoaded=function(e){var t=this,r=e.id,i=e.details,a=this.trackId,n=this.tracks,s=n[a];r>=n.length||r!==a||!s||this.stopped?this._clearReloadTimer():(D.logger.log("subtitle track "+r+" loaded"),i.live?(n=se(s.details,i,e.stats.trequest),D.logger.log("Reloading live subtitle playlist in "+n+"ms"),this.timer=setTimeout(function(){t._loadCurrentTrack()},n)):this._clearReloadTimer())},a.startLoad=function(){this.stopped=!1,this._loadCurrentTrack()},a.stopLoad=function(){this.stopped=!0,this._clearReloadTimer()},a._clearReloadTimer=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},a._loadCurrentTrack=function(){var e=this.trackId,t=this.tracks,r=this.hls,t=t[e];e<0||!t||t.details&&!t.details.live||(D.logger.log("Loading subtitle track "+e),r.trigger(E.default.SUBTITLE_TRACK_LOADING,{url:t.url,id:e}))},a._toggleTrackModes=function(e){var t=this.media,r=this.subtitleDisplay,i=this.trackId;t&&(t=Ft(t.textTracks),-1===e?[].slice.call(t).forEach(function(e){e.mode="disabled"}):(i=t[i])&&(i.mode="disabled"),(i=t[e])&&(i.mode=r?"showing":"hidden"))},a._setSubtitleTrackInternal=function(e){var t=this.hls,r=this.tracks;!Object(w.isFiniteNumber)(e)||e<-1||e>=r.length||(this.trackId=e,D.logger.log("Switching to subtitle track "+e),t.trigger(E.default.SUBTITLE_TRACK_SWITCH,{id:e}),this._loadCurrentTrack())},a._onTextTracksChanged=function(){if(this.media){for(var e=-1,t=Ft(this.media.textTracks),r=0;r<t.length;r++)if("hidden"===t[r].mode)e=r;else if("showing"===t[r].mode){e=r;break}this.subtitleTrack=e}},r=e,(a=[{key:"subtitleTracks",get:function(){return this.tracks}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.trackId!==e&&(this._toggleTrackModes(e),this._setSubtitleTrackInternal(e))}}])&&Pt(r.prototype,a),i&&Pt(r,i),e}(n),Nt=e("./src/crypt/decrypter.js");var Ut,Bt=window.performance,Q=function(i){var e;function t(e,t){var r=i.call(this,e,E.default.MEDIA_ATTACHED,E.default.MEDIA_DETACHING,E.default.ERROR,E.default.KEY_LOADED,E.default.FRAG_LOADED,E.default.SUBTITLE_TRACKS_UPDATED,E.default.SUBTITLE_TRACK_SWITCH,E.default.SUBTITLE_TRACK_LOADED,E.default.SUBTITLE_FRAG_PROCESSED,E.default.LEVEL_UPDATED)||this;return r.fragmentTracker=t,r.config=e.config,r.state=pe,r.tracks=[],r.tracksBuffered=[],r.currentTrackId=-1,r.decrypter=new Nt.default(e,e.config),r.lastAVStart=0,r._onMediaSeeking=r.onMediaSeeking.bind(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r)),r}e=i,(r=t).prototype=Object.create(e.prototype),(r.prototype.constructor=r).__proto__=e;var r=t.prototype;return r.onSubtitleFragProcessed=function(e){var t=e.frag,e=e.success;if(this.fragPrevious=t,this.state=T,e){var r=this.tracksBuffered[this.currentTrackId];if(r){for(var i,a=t.start,n=0;n<r.length;n++)if(a>=r[n].start&&a<=r[n].end){i=r[n];break}e=t.start+t.duration;i?i.end=e:r.push(i={start:a,end:e})}}},r.onMediaAttached=function(e){e=e.media;(this.media=e).addEventListener("seeking",this._onMediaSeeking),this.state=T},r.onMediaDetaching=function(){var t=this;this.media&&(this.media.removeEventListener("seeking",this._onMediaSeeking),this.fragmentTracker.removeAllFragments(),this.currentTrackId=-1,this.tracks.forEach(function(e){t.tracksBuffered[e.id]=[]}),this.media=null,this.state=pe)},r.onError=function(e){e=e.frag;e&&"subtitle"===e.type&&(this.state=T)},r.onSubtitleTracksUpdated=function(e){var t=this;D.logger.log("subtitle tracks updated"),this.tracksBuffered=[],this.tracks=e.subtitleTracks,this.tracks.forEach(function(e){t.tracksBuffered[e.id]=[]})},r.onSubtitleTrackSwitch=function(e){this.currentTrackId=e.id,this.tracks&&this.tracks.length&&-1!==this.currentTrackId?(e=this.tracks[this.currentTrackId])&&e.details&&this.setInterval(500):this.clearInterval()},r.onSubtitleTrackLoaded=function(e){var t=e.id,e=e.details,r=this.currentTrackId,i=this.tracks,a=i[r];if(!(t>=i.length||t!==r)&&a){if(e.live){var i=a.details,t=e,n=this.lastAVStart,s=(void 0===n&&(n=0),-1),o=(ne(i,t,function(e,t,r){t.start=e.start,s=r}),t.fragments);if(s<0)o.forEach(function(e){e.start+=n});else for(var l=s+1;l<o.length;l++)o[l].start=o[l-1].start+o[l-1].duration}a.details=e,this.setInterval(500)}},r.onKeyLoaded=function(){this.state===ye&&(this.state=T)},r.onFragLoaded=function(e){var r,t=this.fragCurrent,i=e.frag.decryptdata,a=e.frag,n=this.hls;this.state===Ee&&t&&"subtitle"===e.frag.type&&t.sn===e.frag.sn&&0<e.payload.byteLength&&i&&i.key&&"AES-128"===i.method&&(r=Bt.now(),this.decrypter.decrypt(e.payload,i.key.buffer,i.iv.buffer,function(e){var t=Bt.now();n.trigger(E.default.FRAG_DECRYPTED,{frag:a,payload:e,stats:{tstart:r,tdecrypt:t}})}))},r.onLevelUpdated=function(e){e=e.details.fragments;this.lastAVStart=e.length?e[0].start:0},r.doTick=function(){if(this.media)switch(this.state){case T:var e=this.config,t=this.currentTrackId,r=this.fragmentTracker,i=this.media,a=this.tracks;if(!a||!a[t]||!a[t].details)break;var n=e.maxBufferHole,s=e.maxFragLookUpTolerance,e=Math.min(e.maxBufferLength,e.maxMaxBufferLength),i=Y.bufferedInfo(this._getBuffered(),i.currentTime,n),n=i.end,i=i.len,a=a[t].details,t=a.fragments,o=t.length,l=t[o-1].start+t[o-1].duration;if(e<i)return;var d,e=this.fragPrevious;(d=n<l?(d=e&&a.hasProgramDateTime?ce(t,e.endProgramDateTime,s):d)||he(e,t,n,s):t[o-1])&&d.encrypted?(D.logger.log("Loading key for "+d.sn),this.state=ye,this.hls.trigger(E.default.KEY_LOADING,{frag:d})):d&&r.getState(d)===B&&(this.fragCurrent=d,this.state=Ee,this.hls.trigger(E.default.FRAG_LOADING,{frag:d}))}else this.state=T},r.stopLoad=function(){this.lastAVStart=0,i.prototype.stopLoad.call(this)},r._getBuffered=function(){return this.tracksBuffered[this.currentTrackId]||[]},r.onMediaSeeking=function(){this.fragPrevious=null},t}(Q),Gt=((Gt=Ut=Ut||{}).WIDEVINE="com.widevine.alpha",Gt.PLAYREADY="com.microsoft.playready","undefined"!=typeof window&&window.navigator&&window.navigator.requestMediaKeySystemAccess?window.navigator.requestMediaKeySystemAccess.bind(window.navigator):null);function jt(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var Kt=function(i){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{},t=Object.keys(a);(t="function"==typeof Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(a).filter(function(e){return Object.getOwnPropertyDescriptor(a,e).enumerable})):t).forEach(function(e){var t,r;t=i,r=a[e=e],e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r})}return i}({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,maxBufferSize:6e7,maxBufferHole:.5,lowBufferWatchdogPeriod:.5,highBufferWatchdogPeriod:3,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,liveDurationInfinity:!1,liveBackBufferLength:1/0,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:Xe,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,abrController:Ke,bufferController:Ve,capLevelController:We,fpsController:ze,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:Gt},function(){0;return{cueHandler:i,enableCEA708Captions:!0,enableWebVTT:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es"}}(),{subtitleStreamController:Q,subtitleTrackController:Mt,timelineController:xt,audioStreamController:rt,audioTrackController:W,emeController:function(r){function e(e){var t=r.call(this,e,E.default.MEDIA_ATTACHED,E.default.MEDIA_DETACHED,E.default.MANIFEST_PARSED)||this;return t._widevineLicenseUrl=void 0,t._licenseXhrSetup=void 0,t._emeEnabled=void 0,t._requestMediaKeySystemAccess=void 0,t._config=void 0,t._mediaKeysList=[],t._media=null,t._hasSetMediaKeys=!1,t._requestLicenseFailureCount=0,t._onMediaEncrypted=function(e){D.logger.log('Media is encrypted using "'+e.initDataType+'" init data type'),t._attemptSetMediaKeys(),t._generateRequestWithPreferredKeySession(e.initDataType,e.initData)},t._config=e.config,t._widevineLicenseUrl=t._config.widevineLicenseUrl,t._licenseXhrSetup=t._config.licenseXhrSetup,t._emeEnabled=t._config.emeEnabled,t._requestMediaKeySystemAccess=t._config.requestMediaKeySystemAccessFunc,t}t=r,(a=e).prototype=Object.create(t.prototype),(a.prototype.constructor=a).__proto__=t;var t,i,a=e.prototype;return a.getLicenseServerUrl=function(e){switch(e){case Ut.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+e+'"')},a._attemptKeySystemAccess=function(t,e,r){var i=this,r=function(e,t){if(e!==Ut.WIDEVINE)throw new Error("Unknown key-system: "+e);return r={videoCapabilities:[]},t.forEach(function(e){r.videoCapabilities.push({contentType:'video/mp4; codecs="'+e+'"'})}),[r];var r}(t,r);D.logger.log("Requesting encrypted media key-system access"),this.requestMediaKeySystemAccess(t,r).then(function(e){i._onMediaKeySystemAccessObtained(t,e)}).catch(function(e){D.logger.error('Failed to obtain key-system "'+t+'" access:',e)})},a._onMediaKeySystemAccessObtained=function(t,e){var r=this,i=(D.logger.log('Access for key-system "'+t+'" obtained'),{mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:t});this._mediaKeysList.push(i),e.createMediaKeys().then(function(e){i.mediaKeys=e,D.logger.log('Media-keys created for key-system "'+t+'"'),r._onMediaKeysCreated()}).catch(function(e){D.logger.error("Failed to create media-keys:",e)})},a._onMediaKeysCreated=function(){var t=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),t._onNewMediaKeySession(e.mediaKeysSession))})},a._onNewMediaKeySession=function(t){var r=this;D.logger.log("New key-system session "+t.sessionId),t.addEventListener("message",function(e){r._onKeySessionMessage(t,e.message)},!1)},a._onKeySessionMessage=function(t,e){D.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(e){D.logger.log("Received license data (length: "+(e&&e.byteLength)+"), updating key-session"),t.update(e)})},a._attemptSetMediaKeys=function(){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys)return D.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.KEY_SYSTEM_ERROR,details:d.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});D.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},a._generateRequestWithPreferredKeySession=function(e,t){var r,i=this,a=this._mediaKeysList[0];if(!a)return D.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.KEY_SYSTEM_ERROR,details:d.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});{if(!a.mediaKeysSessionInitialized)return(r=a.mediaKeysSession)?t?(D.logger.log('Generating key-session request for "'+e+'" init data type'),a.mediaKeysSessionInitialized=!0,void r.generateRequest(e,t).then(function(){D.logger.debug("Key-session generation succeeded")}).catch(function(e){D.logger.error("Error generating key-session request:",e),i.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.KEY_SYSTEM_ERROR,details:d.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})):(D.logger.warn("Fatal: initData required for generating a key session is null"),void this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.KEY_SYSTEM_ERROR,details:d.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0})):(D.logger.error("Fatal: Media is encrypted but no key-session existing"),void this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.KEY_SYSTEM_ERROR,details:d.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0}));D.logger.warn("Key-Session already initialized but requested again")}},a._createLicenseXhr=function(t,e,r){var i=new XMLHttpRequest,a=this._licenseXhrSetup;try{if(a)try{a(i,t)}catch(e){i.open("POST",t,!0),a(i,t)}i.readyState||i.open("POST",t,!0)}catch(e){throw new Error("issue setting up KeySystem license XHR "+e)}return i.responseType="arraybuffer",i.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,i,t,e,r),i},a._onLicenseRequestReadyStageChange=function(e,t,r,i){if(4===e.readyState)if(200===e.status)this._requestLicenseFailureCount=0,D.logger.log("License request succeeded"),"arraybuffer"!==e.responseType&&D.logger.warn("xhr response type was not set to the expected arraybuffer for license request"),i(e.response);else{if(D.logger.error("License Request XHR failed ("+t+"). Status: "+e.status+" ("+e.statusText+")"),this._requestLicenseFailureCount++,3<this._requestLicenseFailureCount)return void this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.KEY_SYSTEM_ERROR,details:d.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});t=3-this._requestLicenseFailureCount+1;D.logger.warn("Retrying license request, "+t+" attempts left"),this._requestLicense(r,i)}},a._generateLicenseRequestChallenge=function(e,t){if(e.mediaKeySystemDomain===Ut.WIDEVINE)return t;throw new Error("unsupported key-system: "+e.mediaKeySystemDomain)},a._requestLicense=function(e,t){D.logger.log("Requesting content license for key-system");var r=this._mediaKeysList[0];if(!r)return D.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.KEY_SYSTEM_ERROR,details:d.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var i=this.getLicenseServerUrl(r.mediaKeySystemDomain),a=this._createLicenseXhr(i,e,t),n=(D.logger.log("Sending license request to URL: "+i),this._generateLicenseRequestChallenge(r,e));a.send(n)}catch(e){D.logger.error("Failure requesting DRM license: "+e),this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.KEY_SYSTEM_ERROR,details:d.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},a.onMediaAttached=function(e){this._emeEnabled&&(e=e.media,(this._media=e).addEventListener("encrypted",this._onMediaEncrypted))},a.onMediaDetached=function(){this._media&&(this._media.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null)},a.onManifestParsed=function(e){var t;this._emeEnabled&&(t=e.levels.map(function(e){return e.audioCodec}),e=e.levels.map(function(e){return e.videoCodec}),this._attemptKeySystemAccess(Ut.WIDEVINE,t,e))},t=e,(a=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&jt(t.prototype,a),i&&jt(t,i),e}(n)});function Ht(i){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{},t=Object.keys(a);(t="function"==typeof Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(a).filter(function(e){return Object.getOwnPropertyDescriptor(a,e).enumerable})):t).forEach(function(e){var t,r;t=i,r=a[e=e],e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r})}return i}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Vt(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function Yt(e,t,r){return t&&Vt(e.prototype,t),r&&Vt(e,r),e}e.d(r,"default",function(){return Wt});var Wt=function(f){var e;function g(e){void 0===e&&(e={}),(t=f.call(this)||this).config=void 0,t._autoLevelCapping=void 0,t.abrController=void 0,t.capLevelController=void 0,t.levelController=void 0,t.streamController=void 0,t.networkControllers=void 0,t.audioTrackController=void 0,t.subtitleTrackController=void 0,t.emeController=void 0,t.coreComponents=void 0,t.media=null,t.url=null;var t,r=g.DefaultConfig;if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");t.config=Ht({},r,e);r=p(t).config;if(void 0!==r.liveMaxLatencyDurationCount&&r.liveMaxLatencyDurationCount<=r.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');if(void 0!==r.liveMaxLatencyDuration&&(void 0===r.liveSyncDuration||r.liveMaxLatencyDuration<=r.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be gt "liveSyncDuration"');Object(D.enableLogs)(r.debug),t._autoLevelCapping=-1;var e=t.abrController=new r.abrController(p(t)),i=new r.bufferController(p(t)),u=t.capLevelController=new r.capLevelController(p(t)),c=new r.fpsController(p(t)),a=new L(p(t)),n=new N(p(t)),s=new U(p(t)),h=new Ne(p(t)),o=t.levelController=new xe(p(t)),l=new H(p(t)),o=[o,t.streamController=new Oe(p(t),l)],d=r.audioStreamController,a=(d&&o.push(new d(p(t),l)),t.networkControllers=o,[a,n,s,e,i,u,c,h,l]);return(d=r.audioTrackController)&&(n=new d(p(t)),t.audioTrackController=n,a.push(n)),(d=r.subtitleTrackController)&&(s=new d(p(t)),t.subtitleTrackController=s,o.push(s)),(d=r.emeController)&&(e=new d(p(t)),t.emeController=e,a.push(e)),(d=r.subtitleStreamController)&&o.push(new d(p(t),l)),(d=r.timelineController)&&a.push(new d(p(t))),t.coreComponents=a,t}e=f,(t=g).prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e,g.isSupported=function(){if(!(t=X()))return!1;var e=self.SourceBuffer||self.WebKitSourceBuffer,t=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),e=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove;return!!t&&!!e},Yt(g,null,[{key:"version",get:function(){return"0.13.2"}},{key:"Events",get:function(){return E.default}},{key:"ErrorTypes",get:function(){return d.ErrorTypes}},{key:"ErrorDetails",get:function(){return d.ErrorDetails}},{key:"DefaultConfig",get:function(){return g.defaultConfig||Kt},set:function(e){g.defaultConfig=e}}]);var t=g.prototype;return t.destroy=function(){D.logger.log("destroy"),this.trigger(E.default.DESTROYING),this.detachMedia(),this.coreComponents.concat(this.networkControllers).forEach(function(e){e.destroy()}),this.url=null,this.removeAllListeners(),this._autoLevelCapping=-1},t.attachMedia=function(e){D.logger.log("attachMedia"),this.media=e,this.trigger(E.default.MEDIA_ATTACHING,{media:e})},t.detachMedia=function(){D.logger.log("detachMedia"),this.trigger(E.default.MEDIA_DETACHING),this.media=null},t.loadSource=function(e){e=a.buildAbsoluteURL(window.location.href,e,{alwaysNormalize:!0}),D.logger.log("loadSource:"+e),this.url=e,this.trigger(E.default.MANIFEST_LOADING,{url:e})},t.startLoad=function(t){void 0===t&&(t=-1),D.logger.log("startLoad("+t+")"),this.networkControllers.forEach(function(e){e.startLoad(t)})},t.stopLoad=function(){D.logger.log("stopLoad"),this.networkControllers.forEach(function(e){e.stopLoad()})},t.swapAudioCodec=function(){D.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},t.recoverMediaError=function(){D.logger.log("recoverMediaError");var e=this.media;this.detachMedia(),e&&this.attachMedia(e)},Yt(g,[{key:"levels",get:function(){return this.levelController.levels}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){D.logger.log("set currentLevel:"+e),this.loadLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){D.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){D.logger.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){D.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){D.logger.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",set:function(e){e=!!e;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){D.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e}},{key:"bandwidthEstimate",get:function(){var e=this.abrController._bwEstimator;return e?e.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){for(var e=this.levels,t=this.config.minAutoBitrate,r=e?e.length:0,i=0;i<r;i++)if(t<(e[i].realBitrate?Math.max(e[i].realBitrate,e[i].bitrate):e[i].bitrate))return i;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping,e=-1===t&&e&&e.length?e.length-1:t;return e}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"liveSyncPosition",get:function(){return this.streamController.liveSyncPosition}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}}]),g}($);Wt.defaultConfig=void 0},"./src/polyfills/number-isFinite.js":function(e,t,r){"use strict";r.r(t),r.d(t,"isFiniteNumber",function(){return i});var i=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)}},"./src/utils/get-self-scope.js":function(e,t,r){"use strict";function i(){return"undefined"==typeof window?self:window}r.r(t),r.d(t,"getSelfScope",function(){return i})},"./src/utils/logger.js":function(d,e,t){"use strict";t.r(e),t.d(e,"enableLogs",function(){return s}),t.d(e,"logger",function(){return l});e=t("./src/utils/get-self-scope.js");function r(){}var i={trace:r,debug:r,log:r,warn:r,info:r,error:r},a=i;var o=Object(e.getSelfScope)();function n(n){var s=o.console[n];return s?function(){for(var e,t,r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];i[0]&&(i[0]=(e=n,t=i[0],t="["+e+"] > "+t)),s.apply(o.console,i)}:r}var s=function(e){if(o.console&&!0===e||"object"==typeof e){!function(t){for(var e=arguments.length,r=new Array(1<e?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];r.forEach(function(e){a[e]=t[e]?t[e].bind(t):n(e)})}(e,"debug","log","info","warn","error");try{a.log()}catch(e){a=i}}else a=i},l=a}},a.c=i,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)a.d(r,i,function(e){return t[e]}.bind(null,i));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="/dist/",a(a.s="./src/hls.ts").default;function a(e){if(i[e])return i[e].exports;var t=i[e]={i:e,l:!1,exports:{}};return r[e].call(t.exports,t,t.exports,a),t.l=!0,t.exports}var r,i},e.exports=i())}]);if (typeof module === 'object' && module.exports) { module.exports = window.hlsSourceHandler; }