-
Notifications
You must be signed in to change notification settings - Fork 10
/
hls-0.13.0.light.min.js
2 lines (2 loc) · 165 KB
/
hls-0.13.0.light.min.js
1
2
"undefined"!=typeof window&&function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Hls=t():e.Hls=t()}(this,function(){return function(e){var t={};function r(a){if(t[a])return t[a].exports;var i=t[a]={i:a,l:!1,exports:{}};return e[a].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,a){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(a,i,function(t){return e[t]}.bind(null,i));return a},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=13)}([function(e,t,r){"use strict";r.d(t,"a",function(){return d}),r.d(t,"b",function(){return u});var a=r(5);function i(){}var n={trace:i,debug:i,log:i,warn:i,info:i,error:i},s=n;var o=Object(a.a)();function l(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];r.forEach(function(t){s[t]=e[t]?e[t].bind(e):function(e){var t=o.console[e];return t?function(){for(var r=arguments.length,a=new Array(r),i=0;i<r;i++)a[i]=arguments[i];a[0]&&(a[0]=function(e,t){return t="["+e+"] > "+t}(e,a[0])),t.apply(o.console,a)}:i}(t)})}var d=function(e){if(o.console&&!0===e||"object"==typeof e){l(e,"debug","log","info","warn","error");try{s.log()}catch(e){s=n}}else s=n},u=s},function(e,t,r){"use strict";t.a={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"}},function(e,t,r){"use strict";var a,i;r.d(t,"b",function(){return a}),r.d(t,"a",function(){return i}),function(e){e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError"}(a||(a={})),function(e){e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException"}(i||(i={}))},function(e,t,r){"use strict";r.d(t,"a",function(){return a});var a=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)}},function(e,t,r){"use strict";r.d(t,"b",function(){return o});var a,i=r(5),n=function(){function e(){}return e.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},e.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},e.getID3Data=function(t,r){for(var a=r,i=0;e.isHeader(t,r);){i+=10,i+=e._readSize(t,r+6),e.isFooter(t,r+10)&&(i+=10),r+=i}if(i>0)return t.subarray(a,a+i)},e._readSize=function(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]},e.getTimeStamp=function(t){for(var r=e.getID3Frames(t),a=0;a<r.length;a++){var i=r[a];if(e.isTimeStampFrame(i))return e._readTimeStamp(i)}},e.isTimeStampFrame=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},e._getFrameData=function(t){var r=String.fromCharCode(t[0],t[1],t[2],t[3]),a=e._readSize(t,4);return{type:r,size:a,data:t.subarray(10,10+a)}},e.getID3Frames=function(t){for(var r=0,a=[];e.isHeader(t,r);){for(var i=e._readSize(t,r+6),n=(r+=10)+i;r+8<n;){var s=e._getFrameData(t.subarray(r)),o=e._decodeFrame(s);o&&a.push(o),r+=s.size+10}e.isFooter(t,r)&&(r+=10)}return a},e._decodeFrame=function(t){return"PRIV"===t.type?e._decodePrivFrame(t):"T"===t.type[0]?e._decodeTextFrame(t):"W"===t.type[0]?e._decodeURLFrame(t):void 0},e._readTimeStamp=function(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],a=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return a/=45,r&&(a+=47721858.84),Math.round(a)}},e._decodePrivFrame=function(t){if(!(t.size<2)){var r=e._utf8ArrayToStr(t.data,!0),a=new Uint8Array(t.data.subarray(r.length+1));return{key:t.type,info:r,data:a.buffer}}},e._decodeTextFrame=function(t){if(!(t.size<2)){if("TXXX"===t.type){var r=1,a=e._utf8ArrayToStr(t.data.subarray(r),!0);r+=a.length+1;var i=e._utf8ArrayToStr(t.data.subarray(r));return{key:t.type,info:a,data:i}}var n=e._utf8ArrayToStr(t.data.subarray(1));return{key:t.type,data:n}}},e._decodeURLFrame=function(t){if("WXXX"===t.type){if(t.size<2)return;var r=1,a=e._utf8ArrayToStr(t.data.subarray(r));r+=a.length+1;var i=e._utf8ArrayToStr(t.data.subarray(r));return{key:t.type,info:a,data:i}}var n=e._utf8ArrayToStr(t.data);return{key:t.type,data:n}},e._utf8ArrayToStr=function(e,t){void 0===t&&(t=!1);var r=s();if(r){var a=r.decode(e);if(t){var i=a.indexOf("\0");return-1!==i?a.substring(0,i):a}return a.replace(/\0/g,"")}for(var n,o,l,d=e.length,u="",f=0;f<d;){if(0===(n=e[f++])&&t)return u;if(0!==n&&3!==n)switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(n);break;case 12:case 13:o=e[f++],u+=String.fromCharCode((31&n)<<6|63&o);break;case 14:o=e[f++],l=e[f++],u+=String.fromCharCode((15&n)<<12|(63&o)<<6|(63&l)<<0)}}return u},e}();function s(){var e=Object(i.a)();return a||void 0===e.TextDecoder||(a=new e.TextDecoder("utf-8")),a}var o=n._utf8ArrayToStr;t.a=n},function(e,t,r){"use strict";function a(){return"undefined"==typeof window?self:window}r.d(t,"a",function(){return a})},function(e,t){e.exports=void 0},function(e,t,r){var a,i,n,s,o;a=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,i=/^([^\/?#]*)(.*)$/,n=/(?:\/|^)\.(?=\/)/g,s=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,o={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var a=o.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");return a.path=o.normalizePath(a.path),o.buildURLFromParts(a)}var n=o.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=o.normalizePath(n.path),o.buildURLFromParts(n)):t;var s=o.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var l=i.exec(s.path);s.netLoc=l[1],s.path=l[2]}s.netLoc&&!s.path&&(s.path="/");var d={scheme:s.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(d.netLoc=s.netLoc,"/"!==n.path[0]))if(n.path){var u=s.path,f=u.substring(0,u.lastIndexOf("/")+1)+n.path;d.path=o.normalizePath(f)}else d.path=s.path,n.params||(d.params=s.params,n.query||(d.query=s.query));return null===d.path&&(d.path=r.alwaysNormalize?o.normalizePath(n.path):n.path),o.buildURLFromParts(d)},parseURL:function(e){var t=a.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(n,"");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},function(e,t,r){"use strict";var a=Object.prototype.hasOwnProperty,i="~";function n(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,r,a,n){if("function"!=typeof r)throw new TypeError("The listener must be a function");var o=new s(r,a||e,n),l=i?i+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function l(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function d(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(i=!1)),d.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)a.call(e,t)&&r.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},d.prototype.listeners=function(e){var t=i?i+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var a=0,n=r.length,s=new Array(n);a<n;a++)s[a]=r[a].fn;return s},d.prototype.listenerCount=function(e){var t=i?i+e:e,r=this._events[t];return r?r.fn?1:r.length:0},d.prototype.emit=function(e,t,r,a,n,s){var o=i?i+e:e;if(!this._events[o])return!1;var l,d,u=this._events[o],f=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),f){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,a),!0;case 5:return u.fn.call(u.context,t,r,a,n),!0;case 6:return u.fn.call(u.context,t,r,a,n,s),!0}for(d=1,l=new Array(f-1);d<f;d++)l[d-1]=arguments[d];u.fn.apply(u.context,l)}else{var h,c=u.length;for(d=0;d<c;d++)switch(u[d].once&&this.removeListener(e,u[d].fn,void 0,!0),f){case 1:u[d].fn.call(u[d].context);break;case 2:u[d].fn.call(u[d].context,t);break;case 3:u[d].fn.call(u[d].context,t,r);break;case 4:u[d].fn.call(u[d].context,t,r,a);break;default:if(!l)for(h=1,l=new Array(f-1);h<f;h++)l[h-1]=arguments[h];u[d].fn.apply(u[d].context,l)}}return!0},d.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},d.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},d.prototype.removeListener=function(e,t,r,a){var n=i?i+e:e;if(!this._events[n])return this;if(!t)return l(this,n),this;var s=this._events[n];if(s.fn)s.fn!==t||a&&!s.once||r&&s.context!==r||l(this,n);else{for(var o=0,d=[],u=s.length;o<u;o++)(s[o].fn!==t||a&&!s[o].once||r&&s[o].context!==r)&&d.push(s[o]);d.length?this._events[n]=1===d.length?d[0]:d:l(this,n)}return this},d.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&l(this,t)):(this._events=new n,this._eventsCount=0),this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prefixed=i,d.EventEmitter=d,e.exports=d},function(e,t,r){"use strict";var a=r(1),i=r(2),n=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}(),s=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 o=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),a=0;a<4;a++)r[a]=t.getUint32(4*a);return r},t.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,a=r[0],i=r[1],n=r[2],s=r[3],o=this.invSubMix,l=o[0],d=o[1],u=o[2],f=o[3],h=new Uint32Array(256),c=0,v=0,p=0;for(p=0;p<256;p++)h[p]=p<128?p<<1:p<<1^283;for(p=0;p<256;p++){var g=v^v<<1^v<<2^v<<3^v<<4;g=g>>>8^255&g^99,e[c]=g,t[g]=c;var m=h[c],y=h[m],b=h[y],E=257*h[g]^16843008*g;a[c]=E<<24|E>>>8,i[c]=E<<16|E>>>16,n[c]=E<<8|E>>>24,s[c]=E,E=16843009*b^65537*y^257*m^16843008*c,l[g]=E<<24|E>>>8,d[g]=E<<16|E>>>16,u[g]=E<<8|E>>>24,f[g]=E,c?(c=m^h[h[h[b^m]]],v^=h[h[v]]):c=v=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,a=0;a<t.length&&r;)r=t[a]===this.key[a],a++;if(!r){this.key=t;var i=this.keySize=t.length;if(4!==i&&6!==i&&8!==i)throw new Error("Invalid aes key size="+i);var n,s,o,l,d=this.ksRows=4*(i+6+1),u=this.keySchedule=new Uint32Array(d),f=this.invKeySchedule=new Uint32Array(d),h=this.sBox,c=this.rcon,v=this.invSubMix,p=v[0],g=v[1],m=v[2],y=v[3];for(n=0;n<d;n++)n<i?o=u[n]=t[n]:(l=o,n%i==0?(l=h[(l=l<<8|l>>>24)>>>24]<<24|h[l>>>16&255]<<16|h[l>>>8&255]<<8|h[255&l],l^=c[n/i|0]<<24):i>6&&n%i==4&&(l=h[l>>>24]<<24|h[l>>>16&255]<<16|h[l>>>8&255]<<8|h[255&l]),u[n]=o=(u[n-i]^l)>>>0);for(s=0;s<d;s++)n=d-s,l=3&s?u[n]:u[n-4],f[s]=s<4||n<=4?l:p[h[l>>>24]]^g[h[l>>>16&255]]^m[h[l>>>8&255]]^y[h[255&l]],f[s]=f[s]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,r,a){for(var i,n,s,o,l,d,u,f,h,c,v,p,g,m,y,b,E,T=this.keySize+6,S=this.invKeySchedule,A=this.invSBox,_=this.invSubMix,R=_[0],L=_[1],D=_[2],w=_[3],I=this.uint8ArrayToUint32Array_(r),k=I[0],O=I[1],x=I[2],P=I[3],C=new Int32Array(e),F=new Int32Array(C.length),M=this.networkToHostOrderSwap;t<C.length;){for(h=M(C[t]),c=M(C[t+1]),v=M(C[t+2]),p=M(C[t+3]),l=h^S[0],d=p^S[1],u=v^S[2],f=c^S[3],g=4,m=1;m<T;m++)i=R[l>>>24]^L[d>>16&255]^D[u>>8&255]^w[255&f]^S[g],n=R[d>>>24]^L[u>>16&255]^D[f>>8&255]^w[255&l]^S[g+1],s=R[u>>>24]^L[f>>16&255]^D[l>>8&255]^w[255&d]^S[g+2],o=R[f>>>24]^L[l>>16&255]^D[d>>8&255]^w[255&u]^S[g+3],l=i,d=n,u=s,f=o,g+=4;i=A[l>>>24]<<24^A[d>>16&255]<<16^A[u>>8&255]<<8^A[255&f]^S[g],n=A[d>>>24]<<24^A[u>>16&255]<<16^A[f>>8&255]<<8^A[255&l]^S[g+1],s=A[u>>>24]<<24^A[f>>16&255]<<16^A[l>>8&255]<<8^A[255&d]^S[g+2],o=A[f>>>24]<<24^A[l>>16&255]<<16^A[d>>8&255]<<8^A[255&u]^S[g+3],g+=3,F[t]=M(i^k),F[t+1]=M(o^O),F[t+2]=M(s^x),F[t+3]=M(n^P),k=h,O=c,x=v,P=p,t+=4}return a?(y=F.buffer,b=y.byteLength,(E=b&&new DataView(y).getUint8(b-1))?y.slice(0,b-E):y):F.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}(),l=r(0),d=r(5),u=Object(d.a)(),f=function(){function e(e,t,r){var a=(void 0===r?{}:r).removePKCS7Padding,i=void 0===a||a;if(this.logEnabled=!0,this.observer=e,this.config=t,this.removePKCS7Padding=i,i)try{var n=u.crypto;n&&(this.subtle=n.subtle||n.webkitSubtle)}catch(e){}this.disableWebCrypto=!this.subtle}var t=e.prototype;return t.isSync=function(){return this.disableWebCrypto&&this.config.enableSoftwareAES},t.decrypt=function(e,t,r,a){var i=this;if(this.disableWebCrypto&&this.config.enableSoftwareAES){this.logEnabled&&(l.b.log("JS AES decrypt"),this.logEnabled=!1);var d=this.decryptor;d||(this.decryptor=d=new o),d.expandKey(t),a(d.decrypt(e,0,r,this.removePKCS7Padding))}else{this.logEnabled&&(l.b.log("WebCrypto AES decrypt"),this.logEnabled=!1);var u=this.subtle;this.key!==t&&(this.key=t,this.fastAesKey=new s(u,t)),this.fastAesKey.expandKey().then(function(s){new n(u,r).decrypt(e,s).catch(function(n){i.onWebCryptoError(n,e,t,r,a)}).then(function(e){a(e)})}).catch(function(n){i.onWebCryptoError(n,e,t,r,a)})}},t.onWebCryptoError=function(e,t,r,n,s){this.config.enableSoftwareAES?(l.b.log("WebCrypto Error, disable WebCrypto API"),this.disableWebCrypto=!0,this.logEnabled=!0,this.decrypt(t,r,n,s)):(l.b.error("decrypting error : "+e.message),this.observer.trigger(a.a.ERROR,{type:i.b.MEDIA_ERROR,details:i.a.FRAG_DECRYPT_ERROR,fatal:!0,reason:e.message}))},t.destroy=function(){var e=this.decryptor;e&&(e.destroy(),this.decryptor=void 0)},e}(),h=r(3);function c(e,t){return 255===e[t]&&240==(246&e[t+1])}function v(e,t){return 1&e[t+1]?7:9}function p(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function g(e,t){return!!(t+1<e.length&&c(e,t))}function m(e,t){if(g(e,t)){var r=v(e,t);t+5<e.length&&(r=p(e,t));var a=t+r;if(a===e.length||a+1<e.length&&c(e,a))return!0}return!1}function y(e,t,r,n,s){if(!e.samplerate){var o=function(e,t,r,n){var s,o,d,u,f,h=navigator.userAgent.toLowerCase(),c=n,v=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];if(s=1+((192&t[r+2])>>>6),!((o=(60&t[r+2])>>>2)>v.length-1))return u=(1&t[r+2])<<2,u|=(192&t[r+3])>>>6,l.b.log("manifest codec:"+n+",ADTS data:type:"+s+",sampleingIndex:"+o+"["+v[o]+"Hz],channelConfig:"+u),/firefox/i.test(h)?o>=6?(s=5,f=new Array(4),d=o-3):(s=2,f=new Array(2),d=o):-1!==h.indexOf("android")?(s=2,f=new Array(2),d=o):(s=5,f=new Array(4),n&&(-1!==n.indexOf("mp4a.40.29")||-1!==n.indexOf("mp4a.40.5"))||!n&&o>=6?d=o-3:((n&&-1!==n.indexOf("mp4a.40.2")&&(o>=6&&1===u||/vivaldi/i.test(h))||!n&&1===u)&&(s=2,f=new Array(2)),d=o)),f[0]=s<<3,f[0]|=(14&o)>>1,f[1]|=(1&o)<<7,f[1]|=u<<3,5===s&&(f[1]|=(14&d)>>1,f[2]=(1&d)<<7,f[2]|=8,f[3]=0),{config:f,samplerate:v[o],channelCount:u,codec:"mp4a.40."+s,manifestCodec:c};e.trigger(a.a.ERROR,{type:i.b.MEDIA_ERROR,details:i.a.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+o})}(t,r,n,s);e.config=o.config,e.samplerate=o.samplerate,e.channelCount=o.channelCount,e.codec=o.codec,e.manifestCodec=o.manifestCodec,l.b.log("parsed codec:"+e.codec+",rate:"+o.samplerate+",nb channel:"+o.channelCount)}}function b(e){return 9216e4/e}function E(e,t,r,a,i){var n=function(e,t,r,a,i){var n,s,o=e.length;if(n=v(e,t),s=p(e,t),(s-=n)>0&&t+n+s<=o)return{headerLength:n,frameLength:s,stamp:r+a*i}}(t,r,a,i,b(e.samplerate));if(n){var s=n.stamp,o=n.headerLength,l=n.frameLength,d={unit:t.subarray(r+o,r+o+l),pts:s,dts:s};return e.samples.push(d),{sample:d,length:l+o}}}var T=r(4),S=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,a){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:t,duration:a,inputTimeScale:9e4}},t.resetTimeStamp=function(){},e.probe=function(e){if(!e)return!1;for(var t=(T.a.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(m(e,t))return l.b.log("ADTS sync word found !"),!0;return!1},t.append=function(e,t,r,a){for(var i=this._audioTrack,n=T.a.getID3Data(e,0)||[],s=T.a.getTimeStamp(n),o=Object(h.a)(s)?90*s:9e4*t,d=0,u=o,f=e.length,c=n.length,v=[{pts:u,dts:u,data:n}];c<f-1;)if(g(e,c)&&c+5<f){y(i,this.observer,e,c,i.manifestCodec);var p=E(i,e,c,o,d);if(!p){l.b.log("Unable to parse AAC frame");break}c+=p.length,u=p.sample.pts,d++}else T.a.isHeader(e,c)?(n=T.a.getID3Data(e,c),v.push({pts:u,dts:u,data:n}),c+=n.length):c++;this.remuxer.remux(i,{samples:[]},{samples:v,inputTimeScale:9e4},{samples:[]},t,r,a)},t.destroy=function(){},e}(),A=r(10),_={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,a,i){if(!(r+24>t.length)){var n=this.parseHeader(t,r);if(n&&r+n.frameLength<=t.length){var s=a+i*(9e4*n.samplesPerFrame/n.sampleRate),o={unit:t.subarray(r,r+n.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(o),{sample:o,length:n.frameLength}}}},parseHeader:function(e,t){var r=e[t+1]>>3&3,a=e[t+1]>>1&3,i=e[t+2]>>4&15,n=e[t+2]>>2&3,s=e[t+2]>>1&1;if(1!==r&&0!==i&&15!==i&&3!==n){var o=3===r?3-a:3===a?3:4,l=1e3*_.BitratesMap[14*o+i-1],d=3===r?0:2===r?1:2,u=_.SamplingRateMap[3*d+n],f=e[t+3]>>6==3?1:2,h=_.SamplesCoefficients[r][a],c=_.BytesInSlot[a],v=8*h*c;return{sampleRate:u,channelCount:f,frameLength:parseInt(h*l/u+s,10)*c,samplesPerFrame:v}}},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),a=4;r&&r.frameLength&&(a=r.frameLength);var i=t+a;if(i===e.length||i+1<e.length&&this.isHeaderPattern(e,i))return!0}return!1}},R=_,L=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,a=new Uint8Array(4),i=Math.min(4,t);if(0===i)throw new Error("no bytes available");a.set(e.subarray(r,r+i)),this.word=new DataView(a.buffer).getUint32(0),this.bitsAvailable=8*i,this.bytesAvailable-=i},t.skipBits=function(e){var t;this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(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 e>32&&l.b.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},t.skipLZ=function(){var e;for(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){var t,r=8,a=8;for(t=0;t<e;t++)0!==a&&(a=(r+this.readEG()+256)%256),r=0===a?r:a},t.readSPS=function(){var e,t,r,a,i,n,s,o=0,l=0,d=0,u=0,f=this.readUByte.bind(this),h=this.readBits.bind(this),c=this.readUEG.bind(this),v=this.readBoolean.bind(this),p=this.skipBits.bind(this),g=this.skipEG.bind(this),m=this.skipUEG.bind(this),y=this.skipScalingList.bind(this);if(f(),e=f(),h(5),p(3),f(),m(),100===e||110===e||122===e||244===e||44===e||83===e||86===e||118===e||128===e){var b=c();if(3===b&&p(1),m(),m(),p(1),v())for(n=3!==b?8:12,s=0;s<n;s++)v()&&y(s<6?16:64)}m();var E=c();if(0===E)c();else if(1===E)for(p(1),g(),g(),t=c(),s=0;s<t;s++)g();m(),p(1),r=c(),a=c(),0===(i=h(1))&&p(1),p(1),v()&&(o=c(),l=c(),d=c(),u=c());var T=[1,1];if(v()&&v())switch(f()){case 1:T=[1,1];break;case 2:T=[12,11];break;case 3:T=[10,11];break;case 4:T=[16,11];break;case 5:T=[40,33];break;case 6:T=[24,11];break;case 7:T=[20,11];break;case 8:T=[32,11];break;case 9:T=[80,33];break;case 10:T=[18,11];break;case 11:T=[15,11];break;case 12:T=[64,33];break;case 13:T=[160,99];break;case 14:T=[4,3];break;case 15:T=[3,2];break;case 16:T=[2,1];break;case 255:T=[f()<<8|f(),f()<<8|f()]}return{width:Math.ceil(16*(r+1)-2*o-2*l),height:(2-i)*(a+1)*16-(i?2:4)*(d+u),pixelRatio:T}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}(),D=function(){function e(e,t,r,a){this.decryptdata=r,this.discardEPB=a,this.decrypter=new f(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(e,t,r,a){var i=e[t].unit,n=i.subarray(16,i.length-i.length%16),s=n.buffer.slice(n.byteOffset,n.byteOffset+n.length),o=this;this.decryptBuffer(s,function(n){n=new Uint8Array(n),i.set(n,16),a||o.decryptAacSamples(e,t+1,r)})},t.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)){var a=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,a),!a)return}}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),a=0,i=32;i<=e.length-16;i+=160,a+=16)r.set(e.subarray(i,i+16),a);return r},t.getAvcDecryptedUnit=function(e,t){t=new Uint8Array(t);for(var r=0,a=32;a<=e.length-16;a+=160,r+=16)e.set(t.subarray(r,r+16),a);return e},t.decryptAvcSample=function(e,t,r,a,i,n){var s=this.discardEPB(i.data),o=this.getAvcEncryptedData(s),l=this;this.decryptBuffer(o.buffer,function(o){i.data=l.getAvcDecryptedUnit(s,o),n||l.decryptAvcSamples(e,t,r+1,a)})},t.decryptAvcSamples=function(e,t,r,a){for(;;t++,r=0){if(t>=e.length)return void a();for(var i=e[t].units;!(r>=i.length);r++){var n=i[r];if(!(n.length<=48||1!==n.type&&5!==n.type)){var s=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,a,n,s),!s)return}}}},e}(),w={video:1,audio:2,id3:3,text:4},I=function(){function e(e,t,r,a){this.observer=e,this.config=r,this.typeSupported=a,this.remuxer=t,this.sampleAes=null}var t=e.prototype;return t.setDecryptData=function(e){null!=e&&null!=e.key&&"SAMPLE-AES"===e.method?this.sampleAes=new D(this.observer,this.config,e,this.discardEPB):this.sampleAes=null},e.probe=function(t){var r=e._syncOffset(t);return!(r<0)&&(r&&l.b.warn("MPEG2-TS detected but first sync word found @ offset "+r+", junk ahead ?"),!0)},e._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},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:w[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}},t.resetInitSegment=function(t,r,a,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=e.createTrack("video",i),this._audioTrack=e.createTrack("audio",i),this._id3Track=e.createTrack("id3",i),this._txtTrack=e.createTrack("text",i),this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=r,this.videoCodec=a,this._duration=i},t.resetTimeStamp=function(){},t.append=function(t,r,n,s){var o,d,u,f,h,c=t.length,v=!1;this.contiguous=n;var p=this.pmtParsed,g=this._avcTrack,m=this._audioTrack,y=this._id3Track,b=g.pid,E=m.pid,T=y.pid,S=this._pmtId,A=g.pesData,_=m.pesData,R=y.pesData,L=this._parsePAT,D=this._parsePMT,w=this._parsePES,I=this._parseAVCPES.bind(this),k=this._parseAACPES.bind(this),O=this._parseMPEGPES.bind(this),x=this._parseID3PES.bind(this),P=e._syncOffset(t);for(c-=(c+P)%188,o=P;o<c;o+=188)if(71===t[o]){if(d=!!(64&t[o+1]),u=((31&t[o+1])<<8)+t[o+2],(48&t[o+3])>>4>1){if((f=o+5+t[o+4])===o+188)continue}else f=o+4;switch(u){case b:d&&(A&&(h=w(A))&&void 0!==h.pts&&I(h,!1),A={data:[],size:0}),A&&(A.data.push(t.subarray(f,o+188)),A.size+=o+188-f);break;case E:d&&(_&&(h=w(_))&&void 0!==h.pts&&(m.isAAC?k(h):O(h)),_={data:[],size:0}),_&&(_.data.push(t.subarray(f,o+188)),_.size+=o+188-f);break;case T:d&&(R&&(h=w(R))&&void 0!==h.pts&&x(h),R={data:[],size:0}),R&&(R.data.push(t.subarray(f,o+188)),R.size+=o+188-f);break;case 0:d&&(f+=t[f]+1),S=this._pmtId=L(t,f);break;case S:d&&(f+=t[f]+1);var C=D(t,f,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);(b=C.avc)>0&&(g.pid=b),(E=C.audio)>0&&(m.pid=E,m.isAAC=C.isAAC),(T=C.id3)>0&&(y.pid=T),v&&!p&&(l.b.log("reparse from beginning"),v=!1,o=P-188),p=this.pmtParsed=!0;break;case 17:case 8191:break;default:v=!0}}else this.observer.trigger(a.a.ERROR,{type:i.b.MEDIA_ERROR,details:i.a.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});A&&(h=w(A))&&void 0!==h.pts?(I(h,!0),g.pesData=null):g.pesData=A,_&&(h=w(_))&&void 0!==h.pts?(m.isAAC?k(h):O(h),m.pesData=null):(_&&_.size&&l.b.log("last AAC PES packet truncated,might overlap between fragments"),m.pesData=_),R&&(h=w(R))&&void 0!==h.pts?(x(h),y.pesData=null):y.pesData=R,null==this.sampleAes?this.remuxer.remux(m,g,y,this._txtTrack,r,n,s):this.decryptAndRemux(m,g,y,this._txtTrack,r,n,s)},t.decryptAndRemux=function(e,t,r,a,i,n,s){if(e.samples&&e.isAAC){var o=this;this.sampleAes.decryptAacSamples(e.samples,0,function(){o.decryptAndRemuxAvc(e,t,r,a,i,n,s)})}else this.decryptAndRemuxAvc(e,t,r,a,i,n,s)},t.decryptAndRemuxAvc=function(e,t,r,a,i,n,s){if(t.samples){var o=this;this.sampleAes.decryptAvcSamples(t.samples,0,0,function(){o.remuxer.remux(e,t,r,a,i,n,s)})}else this.remuxer.remux(e,t,r,a,i,n,s)},t.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},t._parsePAT=function(e,t){return(31&e[t+10])<<8|e[t+11]},t._parsePMT=function(e,t,r,a){var i,n,s={audio:-1,avc:-1,id3:-1,isAAC:!0};for(i=t+3+((15&e[t+1])<<8|e[t+2])-4,t+=12+((15&e[t+10])<<8|e[t+11]);t<i;){switch(n=(31&e[t+1])<<8|e[t+2],e[t]){case 207:if(!a){l.b.log("unknown stream type:"+e[t]);break}case 15:-1===s.audio&&(s.audio=n);break;case 21:-1===s.id3&&(s.id3=n);break;case 219:if(!a){l.b.log("unknown stream type:"+e[t]);break}case 27:-1===s.avc&&(s.avc=n);break;case 3:case 4:r?-1===s.audio&&(s.audio=n,s.isAAC=!1):l.b.log("MPEG audio found, not supported in this browser for now");break;case 36:l.b.warn("HEVC stream type found, not supported for now");break;default:l.b.log("unknown stream type:"+e[t])}t+=5+((15&e[t+3])<<8|e[t+4])}return s},t._parsePES=function(e){var t,r,a,i,n,s,o,d,u=0,f=e.data;if(!e||0===e.size)return null;for(;f[0].length<19&&f.length>1;){var h=new Uint8Array(f[0].length+f[1].length);h.set(f[0]),h.set(f[1],f[0].length),f[0]=h,f.splice(1,1)}if(1===((t=f[0])[0]<<16)+(t[1]<<8)+t[2]){if((a=(t[4]<<8)+t[5])&&a>e.size-6)return null;if(192&(r=t[7])&&((s=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2)>4294967295&&(s-=8589934592),64&r?((o=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>4294967295&&(o-=8589934592),s-o>54e5&&(l.b.warn(Math.round((s-o)/9e4)+"s delta between PTS and DTS, align them"),s=o)):o=s),d=(i=t[8])+9,e.size<=d)return null;e.size-=d,n=new Uint8Array(e.size);for(var c=0,v=f.length;c<v;c++){var p=(t=f[c]).byteLength;if(d){if(d>p){d-=p;continue}t=t.subarray(d),p-=d,d=0}n.set(t,u),u+=p}return a&&(a-=i+3),{data:n,pts:s,dts:o,len:a}}return null},t.pushAccesUnit=function(e,t){if(e.units.length&&e.frame){var r=t.samples,a=r.length;!this.config.forceKeyFrameOnDiscontinuity||!0===e.key||t.sps&&(a||this.contiguous)?(e.id=a,r.push(e)):t.dropped++}e.debug.length&&l.b.log(e.pts+"/"+e.dts+":"+e.debug)},t._parseAVCPES=function(e,t){var r,a,i,n=this,s=this._avcTrack,o=this._parseAVCNALu(e.data),l=this.avcSample,d=!1,u=this.pushAccesUnit.bind(this),f=function(e,t,r,a){return{key:e,pts:t,dts:r,units:[],debug:a}};e.data=null,l&&o.length&&!s.audFound&&(u(l,s),l=this.avcSample=f(!1,e.pts,e.dts,"")),o.forEach(function(t){switch(t.type){case 1:a=!0,l||(l=n.avcSample=f(!0,e.pts,e.dts,"")),l.frame=!0;var o=t.data;if(d&&o.length>4){var h=new L(o).readSliceType();2!==h&&4!==h&&7!==h&&9!==h||(l.key=!0)}break;case 5:a=!0,l||(l=n.avcSample=f(!0,e.pts,e.dts,"")),l.key=!0,l.frame=!0;break;case 6:a=!0,(r=new L(n.discardEPB(t.data))).readUByte();for(var c=0,v=0,p=!1,g=0;!p&&r.bytesAvailable>1;){c=0;do{c+=g=r.readUByte()}while(255===g);v=0;do{v+=g=r.readUByte()}while(255===g);if(4===c&&0!==r.bytesAvailable){if(p=!0,181===r.readUByte())if(49===r.readUShort())if(1195456820===r.readUInt())if(3===r.readUByte()){var m=r.readUByte(),y=31&m,b=[m,r.readUByte()];for(i=0;i<y;i++)b.push(r.readUByte()),b.push(r.readUByte()),b.push(r.readUByte());n._insertSampleInOrder(n._txtTrack.samples,{type:3,pts:e.pts,bytes:b})}}else if(5===c&&0!==r.bytesAvailable){if(p=!0,v>16){var E=[];for(i=0;i<16;i++)E.push(r.readUByte().toString(16)),3!==i&&5!==i&&7!==i&&9!==i||E.push("-");var S=v-16,A=new Uint8Array(S);for(i=0;i<S;i++)A[i]=r.readUByte();n._insertSampleInOrder(n._txtTrack.samples,{pts:e.pts,payloadType:c,uuid:E.join(""),userDataBytes:A,userData:Object(T.b)(A.buffer)})}}else if(v<r.bytesAvailable)for(i=0;i<v;i++)r.readUByte()}break;case 7:if(a=!0,d=!0,!s.sps){var _=(r=new L(t.data)).readSPS();s.width=_.width,s.height=_.height,s.pixelRatio=_.pixelRatio,s.sps=[t.data],s.duration=n._duration;var R=t.data.subarray(1,4),D="avc1.";for(i=0;i<3;i++){var w=R[i].toString(16);w.length<2&&(w="0"+w),D+=w}s.codec=D}break;case 8:a=!0,s.pps||(s.pps=[t.data]);break;case 9:a=!1,s.audFound=!0,l&&u(l,s),l=n.avcSample=f(!1,e.pts,e.dts,"");break;case 12:a=!1;break;default:a=!1,l&&(l.debug+="unknown NAL "+t.type+" ")}l&&a&&l.units.push(t)}),t&&l&&(u(l,s),this.avcSample=null)},t._insertSampleInOrder=function(e,t){var r=e.length;if(r>0){if(t.pts>=e[r-1].pts)e.push(t);else for(var a=r-1;a>=0;a--)if(t.pts<e[a].pts){e.splice(a,0,t);break}}else e.push(t)},t._getLastNalUnit=function(){var e,t=this.avcSample;if(!t||0===t.units.length){var r=this._avcTrack.samples;t=r[r.length-1]}if(t){var a=t.units;e=a[a.length-1]}return e},t._parseAVCNALu=function(e){var t,r,a,i,n=0,s=e.byteLength,o=this._avcTrack,l=o.naluState||0,d=l,u=[],f=-1;for(-1===l&&(f=0,i=31&e[0],l=0,n=1);n<s;)if(t=e[n++],l)if(1!==l)if(t)if(1===t){if(f>=0)a={data:e.subarray(f,n-l-1),type:i},u.push(a);else{var h=this._getLastNalUnit();if(h&&(d&&n<=4-d&&h.state&&(h.data=h.data.subarray(0,h.data.byteLength-d)),(r=n-l-1)>0)){var c=new Uint8Array(h.data.byteLength+r);c.set(h.data,0),c.set(e.subarray(0,r),h.data.byteLength),h.data=c}}n<s?(f=n,i=31&e[n],l=0):l=-1}else l=0;else l=3;else l=t?0:2;else l=t?0:1;if(f>=0&&l>=0&&(a={data:e.subarray(f,s),type:i,state:l},u.push(a)),0===u.length){var v=this._getLastNalUnit();if(v){var p=new Uint8Array(v.data.byteLength+e.byteLength);p.set(v.data,0),p.set(e,v.data.byteLength),v.data=p}}return o.naluState=l,u},t.discardEPB=function(e){for(var t,r,a=e.byteLength,i=[],n=1;n<a-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(i.push(n+2),n+=2):n++;if(0===i.length)return e;t=a-i.length,r=new Uint8Array(t);var s=0;for(n=0;n<t;s++,n++)s===i[0]&&(s++,i.shift()),r[n]=e[s];return r},t._parseAACPES=function(e){var t,r,n,s,o,d,u,f=this._audioTrack,h=e.data,c=e.pts,v=this.aacOverFlow,p=this.aacLastPTS;if(v){var m=new Uint8Array(v.byteLength+h.byteLength);m.set(v,0),m.set(h,v.byteLength),h=m}for(n=0,o=h.length;n<o-1&&!g(h,n);n++);if(n&&(n<o-1?(d="AAC PES did not start with ADTS header,offset:"+n,u=!1):(d="no ADTS header found in AAC PES",u=!0),l.b.warn("parsing error:"+d),this.observer.trigger(a.a.ERROR,{type:i.b.MEDIA_ERROR,details:i.a.FRAG_PARSING_ERROR,fatal:u,reason:d}),u))return;if(y(f,this.observer,h,n,this.audioCodec),r=0,t=b(f.samplerate),v&&p){var T=p+t;Math.abs(T-c)>1&&(l.b.log("AAC: align PTS for overlapping frames by "+Math.round((T-c)/90)),c=T)}for(;n<o;)if(g(h,n)&&n+5<o){var S=E(f,h,n,c,r);if(!S)break;n+=S.length,s=S.sample.pts,r++}else n++;v=n<o?h.subarray(n,o):null,this.aacOverFlow=v,this.aacLastPTS=s},t._parseMPEGPES=function(e){for(var t=e.data,r=t.length,a=0,i=0,n=e.pts;i<r;)if(R.isHeader(t,i)){var s=R.appendFrame(this._audioTrack,t,i,n,a);if(!s)break;i+=s.length,a++}else i++},t._parseID3PES=function(e){this._id3Track.samples.push(e)},e}(),k=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,a){this._audioTrack={container:"audio/mpeg",type:"audio",id:-1,sequenceNumber:0,isAAC:!1,samples:[],len:0,manifestCodec:t,duration:a,inputTimeScale:9e4}},t.resetTimeStamp=function(){},e.probe=function(e){var t,r,a=T.a.getID3Data(e,0);if(a&&void 0!==T.a.getTimeStamp(a))for(t=a.length,r=Math.min(e.length-1,t+100);t<r;t++)if(R.probe(e,t))return l.b.log("MPEG Audio sync word found !"),!0;return!1},t.append=function(e,t,r,a){for(var i=T.a.getID3Data(e,0),n=T.a.getTimeStamp(i),s=n?90*n:9e4*t,o=i.length,l=e.length,d=0,u=0,f=this._audioTrack,h=[{pts:s,dts:s,data:i}];o<l;)if(R.isHeader(e,o)){var c=R.appendFrame(f,e,o,s,d);if(!c)break;o+=c.length,u=c.sample.pts,d++}else T.a.isHeader(e,o)?(i=T.a.getID3Data(e,o),h.push({pts:u,dts:u,data:i}),o+=i.length):o++;this.remuxer.remux(f,{samples:[]},{samples:h,inputTimeScale:9e4},{samples:[]},t,r,a)},t.destroy=function(){},e}(),O=function(){function e(){}return e.getSilentFrame=function(e,t){switch(e){case"mp4a.40.2":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]);break;default: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}(),x=Math.pow(2,32)-1,P=function(){function e(){}return e.init=function(){var t;for(t in e.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:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=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]),a=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]);e.HDLR_TYPES={video:r,audio:a};var i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=n,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,l,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,i))},e.box=function(e){for(var t,r=Array.prototype.slice.call(arguments,1),a=8,i=r.length,n=i;i--;)a+=r[i].byteLength;for((t=new Uint8Array(a))[0]=a>>24&255,t[1]=a>>16&255,t[2]=a>>8&255,t[3]=255&a,t.set(e,4),i=0,a=8;i<n;i++)t.set(r[i],a),a+=r[i].byteLength;return t},e.hdlr=function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])},e.mdat=function(t){return e.box(e.types.mdat,t)},e.mdhd=function(t,r){r*=t;var a=Math.floor(r/(x+1)),i=Math.floor(r%(x+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,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,a>>24,a>>16&255,a>>8&255,255&a,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))},e.moof=function(t,r,a){return e.box(e.types.moof,e.mfhd(t),e.traf(a,r))},e.moov=function(t){for(var r=t.length,a=[];r--;)a[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(a).concat(e.mvex(t)))},e.mvex=function(t){for(var r=t.length,a=[];r--;)a[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(a))},e.mvhd=function(t,r){r*=t;var a=Math.floor(r/(x+1)),i=Math.floor(r%(x+1)),n=new Uint8Array([1,0,0,0,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,a>>24,a>>16&255,a>>8&255,255&a,i>>24,i>>16&255,i>>8&255,255&i,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 e.box(e.types.mvhd,n)},e.sdtp=function(t){var r,a,i=t.samples||[],n=new Uint8Array(4+i.length);for(a=0;a<i.length;a++)r=i[a].flags,n[a+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return e.box(e.types.sdtp,n)},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))},e.avc1=function(t){var r,a,i,n=[],s=[];for(r=0;r<t.sps.length;r++)i=(a=t.sps[r]).byteLength,n.push(i>>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(a));for(r=0;r<t.pps.length;r++)i=(a=t.pps[r]).byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(a));var o=e.box(e.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|t.sps.length].concat(n).concat([t.pps.length]).concat(s))),l=t.width,d=t.height,u=t.pixelRatio[0],f=t.pixelRatio[1];return e.box(e.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,l>>8&255,255&l,d>>8&255,255&d,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,f>>24,f>>16&255,f>>8&255,255&f])))},e.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]))},e.mp4a=function(t){var r=t.samplerate;return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){var r=t.samplerate;return e.box(e.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},e.stsd=function(t){return"audio"===t.type?t.isAAC||"mp3"!==t.codec?e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.mp3(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var r=t.id,a=t.duration*t.timescale,i=t.width,n=t.height,s=Math.floor(a/(x+1)),o=Math.floor(a%(x+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o,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,n>>8&255,255&n,0,0]))},e.traf=function(t,r){var a=e.sdtp(t),i=t.id,n=Math.floor(r/(x+1)),s=Math.floor(r%(x+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,a.length+16+20+8+16+8+8),a)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,r){var a,i,n,s,o,l,d=t.samples||[],u=d.length,f=12+16*u,h=new Uint8Array(f);for(r+=8+f,h.set([0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,255&u,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),a=0;a<u;a++)n=(i=d[a]).duration,s=i.size,o=i.flags,l=i.cts,h.set([n>>>24&255,n>>>16&255,n>>>8&255,255&n,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*a);return e.box(e.types.trun,h)},e.initSegment=function(t){e.types||e.init();var r,a=e.moov(t);return(r=new Uint8Array(e.FTYP.byteLength+a.byteLength)).set(e.FTYP),r.set(a,e.FTYP.byteLength),r},e}(),C=9e4;function F(e,t,r,a){void 0===r&&(r=1),void 0===a&&(a=!1);var i=e*t*r;return a?Math.round(i):i}function M(e,t){return void 0===t&&(t=!1),F(e,1e3,1/C,t)}function U(e,t){return void 0===t&&(t=1),F(e,C,1/t)}var N,B=U(10),G=U(.2),j=function(){function e(e,t,r,a){this.observer=e,this.config=t,this.typeSupported=r;var i=navigator.userAgent;this.isSafari=a&&a.indexOf("Apple")>-1&&i&&!i.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,r,i,n,s,o){if(this.ISGenerated||this.generateIS(e,t,n),this.ISGenerated){var d=e.samples.length,u=t.samples.length,f=n,h=n;if(d&&u){var c=(e.samples[0].pts-t.samples[0].pts)/t.inputTimeScale;f+=Math.max(0,c),h+=Math.max(0,-c)}if(d){e.timescale||(l.b.warn("regenerate InitSegment as audio detected"),this.generateIS(e,t,n));var v,p=this.remuxAudio(e,f,s,o);if(u)p&&(v=p.endPTS-p.startPTS),t.timescale||(l.b.warn("regenerate InitSegment as video detected"),this.generateIS(e,t,n)),this.remuxVideo(t,h,s,v,o)}else if(u){var g=this.remuxVideo(t,h,s,0,o);g&&e.codec&&this.remuxEmptyAudio(e,f,s,g)}}r.samples.length&&this.remuxID3(r,n),i.samples.length&&this.remuxText(i,n),this.observer.trigger(a.a.FRAG_PARSED)},t.generateIS=function(e,t,r){var n,s,o=this.observer,d=e.samples,u=t.samples,f=this.typeSupported,h="audio/mp4",c={},v={tracks:c},p=void 0===this._initPTS;if(p&&(n=s=1/0),e.config&&d.length&&(e.timescale=e.samplerate,l.b.log("audio sampling rate : "+e.samplerate),e.isAAC||(f.mpeg?(h="audio/mpeg",e.codec=""):f.mp3&&(e.codec="mp3")),c.audio={container:h,codec:e.codec,initSegment:!e.isAAC&&f.mpeg?new Uint8Array:P.initSegment([e]),metadata:{channelCount:e.channelCount}},p&&(n=s=d[0].pts-e.inputTimeScale*r)),t.sps&&t.pps&&u.length){var g=t.inputTimeScale;t.timescale=g,c.video={container:"video/mp4",codec:t.codec,initSegment:P.initSegment([t]),metadata:{width:t.width,height:t.height}},p&&(n=Math.min(n,u[0].pts-g*r),s=Math.min(s,u[0].dts-g*r),this.observer.trigger(a.a.INIT_PTS_FOUND,{initPTS:n}))}Object.keys(c).length?(o.trigger(a.a.FRAG_PARSING_INIT_SEGMENT,v),this.ISGenerated=!0,p&&(this._initPTS=n,this._initDTS=s)):o.trigger(a.a.ERROR,{type:i.b.MEDIA_ERROR,details:i.a.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})},t.remuxVideo=function(e,t,r,n,s){var o,d,u,f,h,c,v,p=8,g=e.timescale,m=e.samples,y=[],b=m.length,E=this._PTSNormalize,T=this._initPTS,S=this.nextAvcDts,A=this.isSafari;if(0!==b){A&&(r|=m.length&&S&&(s&&Math.abs(t-S/g)<.1||Math.abs(m[0].pts-S-T)<g/5)),r||(S=t*g),m.forEach(function(e){e.pts=E(e.pts-T,S),e.dts=E(e.dts-T,S)}),m.sort(function(e,t){var r=e.dts-t.dts,a=e.pts-t.pts;return r||a||e.id-t.id});var _=m.reduce(function(e,t){return Math.max(Math.min(e,t.pts-t.dts),-1*G)},0);if(_<0){l.b.warn("PTS < DTS detected in video samples, shifting DTS by "+M(_,!0)+" ms to overcome this issue");for(var R=0;R<m.length;R++)m[R].dts+=_}var L=m[0];h=Math.max(L.dts,0),f=Math.max(L.pts,0);var D=h-S;r&&D&&(D>1?l.b.log("AVC: "+M(D,!0)+" ms hole between fragments detected,filling it"):D<-1&&l.b.log("AVC: "+M(-D,!0)+" ms overlapping between fragments detected"),h=S,m[0].dts=h,f=Math.max(f-D,S),m[0].pts=f,l.b.log("Video: PTS/DTS adjusted: "+M(f,!0)+"/"+M(h,!0)+", delta: "+M(D,!0)+" ms")),L=m[m.length-1],v=Math.max(L.dts,0),c=Math.max(L.pts,0,v),A&&(o=Math.round((v-h)/(m.length-1)));for(var w=0,I=0,k=0;k<b;k++){for(var O=m[k],x=O.units,C=x.length,F=0,U=0;U<C;U++)F+=x[U].data.length;I+=F,w+=C,O.length=F,O.dts=A?h+k*o:Math.max(O.dts,h),O.pts=Math.max(O.pts,O.dts)}var N=I+4*w+8;try{d=new Uint8Array(N)}catch(e){return void this.observer.trigger(a.a.ERROR,{type:i.b.MUX_ERROR,details:i.a.REMUX_ALLOC_ERROR,fatal:!1,bytes:N,reason:"fail allocating video mdat "+N})}var B=new DataView(d.buffer);B.setUint32(0,N),d.set(P.types.mdat,4);for(var j=0;j<b;j++){for(var K=m[j],H=K.units,V=0,W=void 0,Y=0,z=H.length;Y<z;Y++){var X=H[Y],q=X.data,Q=X.data.byteLength;B.setUint32(p,Q),p+=4,d.set(q,p),p+=Q,V+=4+Q}if(A)W=Math.max(0,o*Math.round((K.pts-K.dts)/o));else{if(j<b-1)o=m[j+1].dts-K.dts;else{var Z=this.config,J=K.dts-m[j>0?j-1:j].dts;if(Z.stretchShortVideoTrack){var $=Z.maxBufferHole,ee=Math.floor($*g),te=(n?f+n*g:this.nextAudioPts)-K.pts;te>ee?((o=te-J)<0&&(o=J),l.b.log("It is approximately "+M(te,!1)+" ms to the next segment; using duration "+M(o,!1)+" ms for the last video frame.")):o=J}else o=J}W=Math.round(K.pts-K.dts)}y.push({size:V,duration:o,cts:W,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:K.key?2:1,isNonSync:K.key?0:1}})}this.nextAvcDts=v+o;var re=e.dropped;if(e.nbNalu=0,e.dropped=0,y.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var ae=y[0].flags;ae.dependsOn=2,ae.isNonSync=0}e.samples=y,u=P.moof(e.sequenceNumber++,h,e),e.samples=[];var ie={data1:u,data2:d,startPTS:f/g,endPTS:(c+o)/g,startDTS:h/g,endDTS:this.nextAvcDts/g,type:"video",hasAudio:!1,hasVideo:!0,nb:y.length,dropped:re};return this.observer.trigger(a.a.FRAG_PARSING_DATA,ie),ie}},t.remuxAudio=function(e,t,r,n){var s,o,d,u,f,h,c=e.inputTimeScale,v=e.timescale,p=c/v,g=(e.isAAC?1024:1152)*p,m=this._PTSNormalize,y=this._initPTS,b=!e.isAAC&&this.typeSupported.mpeg,E=b?0:8,T=e.samples,S=[],A=this.nextAudioPts;if(r|=T.length&&A&&(n&&Math.abs(t-A/c)<.1||Math.abs(T[0].pts-A-y)<20*g),T.forEach(function(e){e.pts=e.dts=m(e.pts-y,t*c)}),0!==(T=T.filter(function(e){return e.pts>=0})).length){if(r||(A=n?t*c:T[0].pts),e.isAAC)for(var _=this.config.maxAudioFramesDrift,R=0,L=A;R<T.length;){var D,w=T[R];if((D=w.pts-L)<=-_*g)l.b.warn("Dropping 1 audio frame @ "+M(L,!0)+" ms due to "+M(D,!0)+" ms overlap."),T.splice(R,1);else if(D>=_*g&&D<B&&L){var I=Math.round(D/g);l.b.warn("Injecting "+I+" audio frames @ "+M(L,!0)+" ms due to "+M(L,!0)+" ms gap.");for(var k=0;k<I;k++){var x=Math.max(L,0);(o=O.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(l.b.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),o=w.unit.subarray()),T.splice(R,0,{unit:o,pts:x,dts:x}),L+=g,R++}w.pts=w.dts=L,L+=g,R++}else Math.abs(D),w.pts=w.dts=L,L+=g,R++}for(var C=T.length,F=0;C--;)F+=T[C].unit.byteLength;for(var U=0,N=T.length;U<N;U++){var G=T[U],j=G.unit,K=G.pts;if(void 0!==h)s.duration=Math.round((K-h)/p);else{var H=K-A,V=0;if(r&&e.isAAC&&H){if(H>0&&H<B)V=Math.round((K-A)/g),l.b.log(M(H,!0)+" ms hole between AAC samples detected,filling it"),V>0&&((o=O.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(o=j.subarray()),F+=V*o.length);else if(H<-12){l.b.log("drop overlapping AAC sample, expected/parsed/delta: "+M(A,!0)+" ms / "+M(K,!0)+" ms / "+M(-H,!0)+" ms"),F-=j.byteLength;continue}K=A}if(f=K,!(F>0))return;F+=E;try{d=new Uint8Array(F)}catch(e){return void this.observer.trigger(a.a.ERROR,{type:i.b.MUX_ERROR,details:i.a.REMUX_ALLOC_ERROR,fatal:!1,bytes:F,reason:"fail allocating audio mdat "+F})}b||(new DataView(d.buffer).setUint32(0,F),d.set(P.types.mdat,4));for(var W=0;W<V;W++)(o=O.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(l.b.log("Unable to get silent frame for given audio codec; duplicating this frame instead."),o=j.subarray()),d.set(o,E),E+=o.byteLength,s={size:o.byteLength,cts:0,duration:1024,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},S.push(s)}d.set(j,E);var Y=j.byteLength;E+=Y,s={size:Y,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},S.push(s),h=K}var z=0;if((C=S.length)>=2&&(z=S[C-2].duration,s.duration=z),C){this.nextAudioPts=A=h+p*z,e.samples=S,u=b?new Uint8Array:P.moof(e.sequenceNumber++,f/p,e),e.samples=[];var X=f/c,q=A/c,Q={data1:u,data2:d,startPTS:X,endPTS:q,startDTS:X,endDTS:q,type:"audio",hasAudio:!0,hasVideo:!1,nb:C};return this.observer.trigger(a.a.FRAG_PARSING_DATA,Q),Q}return null}},t.remuxEmptyAudio=function(e,t,r,a){var i=e.inputTimeScale,n=i/(e.samplerate?e.samplerate:i),s=this.nextAudioPts,o=(void 0!==s?s:a.startDTS*i)+this._initDTS,d=a.endDTS*i+this._initDTS,u=1024*n,f=Math.ceil((d-o)/u),h=O.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(l.b.warn("remux empty Audio"),h){for(var c=[],v=0;v<f;v++){var p=o+v*u;c.push({unit:h,pts:p,dts:p})}e.samples=c,this.remuxAudio(e,t,r)}else l.b.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,n=this._initPTS,s=this._initDTS;if(r){for(var o=0;o<r;o++)(t=e.samples[o]).pts=(t.pts-n)/i,t.dts=(t.dts-s)/i;this.observer.trigger(a.a.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,n=this._initPTS;if(r){for(var s=0;s<r;s++)(t=e.samples[s]).pts=(t.pts-n)/i;this.observer.trigger(a.a.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;Math.abs(e-t)>4294967296;)e+=r;return e},e}(),K=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,n,s,o,l){var d=this.observer,u="";e&&(u+="audio"),t&&(u+="video"),d.trigger(a.a.FRAG_PARSING_DATA,{data1:l,startPTS:n,startDTS:n,type:u,hasAudio:!!e,hasVideo:!!t,nb:1,dropped:0}),d.trigger(a.a.FRAG_PARSED)},e}(),H=Object(d.a)();try{N=H.performance.now.bind(H.performance)}catch(e){l.b.debug("Unable to use Performance API on this environment"),N=H.Date.now}var V=function(){function e(e,t,r,a){this.observer=e,this.typeSupported=t,this.config=r,this.vendor=a}var t=e.prototype;return t.destroy=function(){var e=this.demuxer;e&&e.destroy()},t.push=function(e,t,r,i,n,s,o,l,d,u,h,c){var v=this;if(e.byteLength>0&&null!=t&&null!=t.key&&"AES-128"===t.method){var p=this.decrypter;null==p&&(p=this.decrypter=new f(this.observer,this.config));var g=N();p.decrypt(e,t.key.buffer,t.iv.buffer,function(e){var f=N();v.observer.trigger(a.a.FRAG_DECRYPTED,{stats:{tstart:g,tdecrypt:f}}),v.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),i,n,s,o,l,d,u,h,c)})}else this.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),i,n,s,o,l,d,u,h,c)},t.pushDecrypted=function(e,t,r,n,s,o,l,d,u,f,h,c){var v=this.demuxer;if(!v||(l||d)&&!this.probe(e)){for(var p=this.observer,g=this.typeSupported,m=this.config,y=[{demux:I,remux:j},{demux:A.a,remux:K},{demux:S,remux:j},{demux:k,remux:j}],b=0,E=y.length;b<E;b++){var T=y[b],_=T.demux.probe;if(_(e)){var R=this.remuxer=new T.remux(p,m,g,this.vendor);v=new T.demux(p,R,m,g),this.probe=_;break}}if(!v)return void p.trigger(a.a.ERROR,{type:i.b.MEDIA_ERROR,details:i.a.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});this.demuxer=v}var L=this.remuxer;(l||d)&&(v.resetInitSegment(r,n,s,f),L.resetInitSegment()),l&&(v.resetTimeStamp(c),L.resetTimeStamp(c)),"function"==typeof v.setDecryptData&&v.setDecryptData(t),v.append(e,o,u,h)},e}();t.a=V},function(e,t,r){"use strict";var a=r(0),i=r(1),n=Math.pow(2,32)-1,s=function(){function e(e,t){this.observer=e,this.remuxer=t}var t=e.prototype;return t.resetTimeStamp=function(e){this.initPTS=e},t.resetInitSegment=function(t,r,a,n){if(t&&t.byteLength){var s=this.initData=e.parseInitSegment(t);null==r&&(r="mp4a.40.5"),null==a&&(a="avc1.42e01e");var o={};s.audio&&s.video?o.audiovideo={container:"video/mp4",codec:r+","+a,initSegment:n?t:null}:(s.audio&&(o.audio={container:"audio/mp4",codec:r,initSegment:n?t:null}),s.video&&(o.video={container:"video/mp4",codec:a,initSegment:n?t:null})),this.observer.trigger(i.a.FRAG_PARSING_INIT_SEGMENT,{tracks:o})}else r&&(this.audioCodec=r),a&&(this.videoCodec=a)},e.probe=function(t){return e.findBox({data:t,start:0,end:Math.min(t.length,16384)},["moof"]).length>0},e.bin2str=function(e){return String.fromCharCode.apply(null,e)},e.readUint16=function(e,t){e.data&&(t+=e.start,e=e.data);var r=e[t]<<8|e[t+1];return r<0?65536+r:r},e.readUint32=function(e,t){e.data&&(t+=e.start,e=e.data);var r=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return r<0?4294967296+r:r},e.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},e.findBox=function(t,r){var a,i,n,s,o,l,d=[];if(t.data?(o=t.start,n=t.end,t=t.data):(o=0,n=t.byteLength),!r.length)return null;for(a=o;a<n;)l=(i=e.readUint32(t,a))>1?a+i:n,e.bin2str(t.subarray(a+4,a+8))===r[0]&&(1===r.length?d.push({data:t,start:a+8,end:l}):(s=e.findBox({data:t,start:a+8,end:l},r.slice(1))).length&&(d=d.concat(s))),a=l;return d},e.parseSegmentIndex=function(t){var r,a=e.findBox(t,["moov"])[0],i=a?a.end:null,n=0,s=e.findBox(t,["sidx"]);if(!s||!s[0])return null;r=[];var o=(s=s[0]).data[0];n=0===o?8:16;var l=e.readUint32(s,n);n+=4;n+=0===o?8:16,n+=2;var d=s.end+0,u=e.readUint16(s,n);n+=2;for(var f=0;f<u;f++){var h=n,c=e.readUint32(s,h);h+=4;var v=2147483647&c;if(1===(2147483648&c)>>>31)return void console.warn("SIDX has hierarchical references (not supported)");var p=e.readUint32(s,h);h+=4,r.push({referenceSize:v,subsegmentDuration:p,info:{duration:p/l,start:d,end:d+v-1}}),d+=v,n=h+=4}return{earliestPresentationTime:0,timescale:l,version:o,referencesCount:u,references:r,moovEndOffset:i}},e.parseInitSegment=function(t){var r=[];return e.findBox(t,["moov","trak"]).forEach(function(t){var i=e.findBox(t,["tkhd"])[0];if(i){var n=i.data[i.start],s=0===n?12:20,o=e.readUint32(i,s),l=e.findBox(t,["mdia","mdhd"])[0];if(l){s=0===(n=l.data[l.start])?12:20;var d=e.readUint32(l,s),u=e.findBox(t,["mdia","hdlr"])[0];if(u){var f={soun:"audio",vide:"video"}[e.bin2str(u.data.subarray(u.start+8,u.start+12))];if(f){var h=e.findBox(t,["mdia","minf","stbl","stsd"]);if(h.length){h=h[0];var c=e.bin2str(h.data.subarray(h.start+12,h.start+16));a.b.log("MP4Demuxer:"+f+":"+c+" found")}r[o]={timescale:d,type:f},r[f]={timescale:d,id:o}}}}}}),r},e.getStartDTS=function(t,r){var a,i,n;return a=e.findBox(r,["moof","traf"]),i=[].concat.apply([],a.map(function(r){return e.findBox(r,["tfhd"]).map(function(a){var i,n;return i=e.readUint32(a,4),n=t[i].timescale||9e4,e.findBox(r,["tfdt"]).map(function(t){var r,a;return r=t.data[t.start],a=e.readUint32(t,4),1===r&&(a*=Math.pow(2,32),a+=e.readUint32(t,8)),a})[0]/n})})),n=Math.min.apply(null,i),isFinite(n)?n:0},e.offsetStartDTS=function(t,r,a){e.findBox(r,["moof","traf"]).map(function(r){return e.findBox(r,["tfhd"]).map(function(i){var s=e.readUint32(i,4),o=t[s].timescale||9e4;e.findBox(r,["tfdt"]).map(function(t){var r=t.data[t.start],i=e.readUint32(t,4);if(0===r)e.writeUint32(t,4,i-a*o);else{i*=Math.pow(2,32),i+=e.readUint32(t,8),i-=a*o,i=Math.max(i,0);var s=Math.floor(i/(n+1)),l=Math.floor(i%(n+1));e.writeUint32(t,4,s),e.writeUint32(t,8,l)}})})})},t.append=function(t,r,a,n){var s=this.initData;s||(this.resetInitSegment(t,this.audioCodec,this.videoCodec,!1),s=this.initData);var o,l=this.initPTS;if(void 0===l){var d=e.getStartDTS(s,t);this.initPTS=l=d-r,this.observer.trigger(i.a.INIT_PTS_FOUND,{initPTS:l})}e.offsetStartDTS(s,t,l),o=e.getStartDTS(s,t),this.remuxer.remux(s.audio,s.video,null,null,o,a,n,t)},t.destroy=function(){},e}();t.a=s},function(e,t,r){function a(e){var t={};function r(a){if(t[a])return t[a].exports;var i=t[a]={i:a,l:!1,exports:{}};return e[a].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,t,a){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:a})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r.oe=function(e){throw console.error(e),e};var a=r(r.s=ENTRY_MODULE);return a.default||a}var i="[\\.|\\-|\\+|\\w|/|@]+",n="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+i+").*?\\)";function s(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function o(e,t,a){var o={};o[a]=[];var l=t.toString(),d=l.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!d)return o;for(var u,f=d[1],h=new RegExp("(\\\\n|\\W)"+s(f)+n,"g");u=h.exec(l);)"dll-reference"!==u[3]&&o[a].push(u[3]);for(h=new RegExp("\\("+s(f)+'\\("(dll-reference\\s('+i+'))"\\)\\)'+n,"g");u=h.exec(l);)e[u[2]]||(o[a].push(u[1]),e[u[2]]=r(u[1]).m),o[u[2]]=o[u[2]]||[],o[u[2]].push(u[4]);for(var c,v=Object.keys(o),p=0;p<v.length;p++)for(var g=0;g<o[v[p]].length;g++)c=o[v[p]][g],isNaN(1*c)||(o[v[p]][g]=1*o[v[p]][g]);return o}function l(e){return Object.keys(e).reduce(function(t,r){return t||e[r].length>0},!1)}e.exports=function(e,t){t=t||{};var i={main:r.m},n=t.all?{main:Object.keys(i.main)}:function(e,t){for(var r={main:[t]},a={main:[]},i={main:{}};l(r);)for(var n=Object.keys(r),s=0;s<n.length;s++){var d=n[s],u=r[d].pop();if(i[d]=i[d]||{},!i[d][u]&&e[d][u]){i[d][u]=!0,a[d]=a[d]||[],a[d].push(u);for(var f=o(e,e[d][u],d),h=Object.keys(f),c=0;c<h.length;c++)r[h[c]]=r[h[c]]||[],r[h[c]]=r[h[c]].concat(f[h[c]])}}return a}(i,e),s="";Object.keys(n).filter(function(e){return"main"!==e}).forEach(function(e){for(var t=0;n[e][t];)t++;n[e].push(t),i[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",s=s+"var "+e+" = ("+a.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+n[e].map(function(t){return JSON.stringify(t)+": "+i[e][t].toString()}).join(",")+"});\n"}),s=s+"new (("+a.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+n.main.map(function(e){return JSON.stringify(e)+": "+i.main[e].toString()}).join(",")+"}))(self);";var d=new window.Blob([s],{type:"text/javascript"});if(t.bare)return d;var u=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(d),f=new window.Worker(u);return f.objectURL=u,f}},function(e,t,r){"use strict";r.r(t);var a=r(9),i=r(1),n=r(0),s=r(8);t.default=function(e){var t=new s.EventEmitter;t.trigger=function(e){for(var r=arguments.length,a=new Array(r>1?r-1:0),i=1;i<r;i++)a[i-1]=arguments[i];t.emit.apply(t,[e,e].concat(a))},t.off=function(e){for(var r=arguments.length,a=new Array(r>1?r-1:0),i=1;i<r;i++)a[i-1]=arguments[i];t.removeListener.apply(t,[e].concat(a))};var r=function(t,r){e.postMessage({event:t,data:r})};e.addEventListener("message",function(i){var s=i.data;switch(s.cmd){case"init":var o=JSON.parse(s.config);e.demuxer=new a.a(t,s.typeSupported,o,s.vendor),Object(n.a)(o.debug),r("init",null);break;case"demux":e.demuxer.push(s.data,s.decryptdata,s.initSegment,s.audioCodec,s.videoCodec,s.timeOffset,s.discontinuity,s.trackSwitch,s.contiguous,s.duration,s.accurateTimeOffset,s.defaultInitPTS)}}),t.on(i.a.FRAG_DECRYPTED,r),t.on(i.a.FRAG_PARSING_INIT_SEGMENT,r),t.on(i.a.FRAG_PARSED,r),t.on(i.a.ERROR,r),t.on(i.a.FRAG_PARSING_METADATA,r),t.on(i.a.FRAG_PARSING_USERDATA,r),t.on(i.a.INIT_PTS_FOUND,r),t.on(i.a.FRAG_PARSING_DATA,function(t,r){var a=[],i={event:t,data:r};r.data1&&(i.data1=r.data1.buffer,a.push(r.data1.buffer),delete r.data1),r.data2&&(i.data2=r.data2.buffer,a.push(r.data2.buffer),delete r.data2),e.postMessage(i,a)})}},function(e,t,r){"use strict";r.r(t);var a,i,n=r(7),s=r(2),o=r(3),l=r(1),d=r(0),u={hlsEventGeneric:!0,hlsHandlerDestroying:!0,hlsHandlerDestroyed:!0},f=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(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];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(u[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(e,t){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,e,t).call()}catch(t){d.b.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.hls.trigger(l.a.ERROR,{type:s.b.OTHER_ERROR,details:s.a.INTERNAL_EXCEPTION,fatal:!1,event:e,err:t})}},e}();!function(e){e.MANIFEST="manifest",e.LEVEL="level",e.AUDIO_TRACK="audioTrack",e.SUBTITLE_TRACK="subtitleTrack"}(a||(a={})),function(e){e.MAIN="main",e.AUDIO="audio",e.SUBTITLE="subtitle"}(i||(i={}));var h=r(10);function c(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}var v,p=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,a;return t=e,(r=[{key:"uri",get:function(){return!this._uri&&this.reluri&&(this._uri=Object(n.buildAbsoluteURL)(this.baseuri,this.reluri,{alwaysNormalize:!0})),this._uri}}])&&c(t.prototype,r),a&&c(t,a),e}();function g(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}!function(e){e.AUDIO="audio",e.VIDEO="video"}(v||(v={}));var m=function(){function e(){var e;this._url=null,this._byteRange=null,this._decryptdata=null,this._elementaryStreams=((e={})[v.AUDIO]=!1,e[v.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,a,i=e.prototype;return i.setByteRange=function(e,t){var r=e.split("@",2),a=[];1===r.length?a[0]=t?t.byteRangeEndOffset:0:a[0]=parseInt(r[1]),a[1]=parseInt(r[0])+a[0],this._byteRange=a},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 p(e.baseuri,e.reluri)).method=e.method,r.iv=this.createInitializationVector(t)),r},t=e,(r=[{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=Object(n.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(e){this._url=e}},{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var e=this.sn;"number"!=typeof e&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&d.b.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),e=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,e)}return this._decryptdata}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(o.a)(this.programDateTime))return null;var e=Object(o.a)(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(t.prototype,r),a&&g(t,a),e}();function y(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}var b=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,a;return t=e,(r=[{key:"hasProgramDateTime",get:function(){return!(!this.fragments[0]||!Object(o.a)(this.fragments[0].programDateTime))}}])&&y(t.prototype,r),a&&y(t,a),e}(),E=/^(\d+)x(\d+)$/,T=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,S=function(){function e(t){for(var r in"string"==typeof t&&(t=e.parseAttrList(t)),t)t.hasOwnProperty(r)&&(this[r]=t[r])}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),a=0;a<t.length/2;a++)r[a]=parseInt(t.slice(2*a,2*a+2),16);return r}return null},t.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.enumeratedString=function(e){return this[e]},t.decimalResolution=function(e){var t=E.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,r={};for(T.lastIndex=0;null!==(t=T.exec(e));){var a=t[2];0===a.indexOf('"')&&a.lastIndexOf('"')===a.length-1&&(a=a.slice(1,-1)),r[t[1]]=a}return r},e}(),A={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 _(e,t){return MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}var R=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g,L=/#EXT-X-MEDIA:(.*)/g,D=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)([\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),w=/(?:(?:#(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?/,I=/\.(mp4|m4s|m4v|m4a)$/i,k=function(){function e(){}return e.findGroup=function(e,t){for(var r=0;r<e.length;r++){var a=e[r];if(a.id===t)return a}},e.convertAVC1ToAVCOTI=function(e){var t,r=e.split(".");return r.length>2?(t=r.shift()+".",t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).substr(-4)):t=e,t},e.resolve=function(e,t){return n.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.parseMasterPlaylist=function(t,r){var a,i=[];function n(e,t){["video","audio"].forEach(function(r){var a=e.filter(function(e){return function(e,t){var r=A[t];return!!r&&!0===r[e.slice(0,4)]}(e,r)});if(a.length){var i=a.filter(function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)});t[r+"Codec"]=i.length>0?i[0]:a[0],e=e.filter(function(e){return-1===a.indexOf(e)})}}),t.unknownCodecs=e}for(R.lastIndex=0;null!=(a=R.exec(t));){var s={},o=s.attrs=new S(a[1]);s.url=e.resolve(a[2],r);var l=o.decimalResolution("RESOLUTION");l&&(s.width=l.width,s.height=l.height),s.bitrate=o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),s.name=o.NAME,n([].concat((o.CODECS||"").split(/[ ,]+/)),s),s.videoCodec&&-1!==s.videoCodec.indexOf("avc1")&&(s.videoCodec=e.convertAVC1ToAVCOTI(s.videoCodec)),i.push(s)}return i},e.parseMasterPlaylistMedia=function(t,r,a,i){var n;void 0===i&&(i=[]);var s=[],o=0;for(L.lastIndex=0;null!==(n=L.exec(t));){var l=new S(n[1]);if(l.TYPE===a){var d={id:o++,groupId:l["GROUP-ID"],name:l.NAME||l.LANGUAGE,type:a,default:"YES"===l.DEFAULT,autoselect:"YES"===l.AUTOSELECT,forced:"YES"===l.FORCED,lang:l.LANGUAGE};if(l.URI&&(d.url=e.resolve(l.URI,r)),i.length){var u=e.findGroup(i,d.groupId);d.audioCodec=u?u.codec:i[0].codec}s.push(d)}}return s},e.parseLevelPlaylist=function(e,t,r,a,i){var n,s,l,u=0,f=0,h=new b(t),c=0,v=null,g=new m,y=null;for(D.lastIndex=0;null!==(n=D.exec(e));){var E=n[1];if(E){g.duration=parseFloat(E);var T=(" "+n[2]).slice(1);g.title=T||null,g.tagList.push(T?["INF",E,T]:["INF",E])}else if(n[3]){if(Object(o.a)(g.duration)){var A=u++;g.type=a,g.start=f,l&&(g.levelkey=l),g.sn=A,g.level=r,g.cc=c,g.urlId=i,g.baseurl=t,g.relurl=(" "+n[3]).slice(1),O(g,v),h.fragments.push(g),v=g,f+=g.duration,g=new m}}else if(n[4]){var _=(" "+n[4]).slice(1);v?g.setByteRange(_,v):g.setByteRange(_)}else if(n[5])g.rawProgramDateTime=(" "+n[5]).slice(1),g.tagList.push(["PROGRAM-DATE-TIME",g.rawProgramDateTime]),null===y&&(y=h.fragments.length);else{if(!(n=n[0].match(w))){d.b.warn("No matches on slow regex match for level playlist!");continue}for(s=1;s<n.length&&void 0===n[s];s++);var R=(" "+n[s+1]).slice(1),L=(" "+n[s+2]).slice(1);switch(n[s]){case"#":g.tagList.push(L?[R,L]:[R]);break;case"PLAYLIST-TYPE":h.type=R.toUpperCase();break;case"MEDIA-SEQUENCE":u=h.startSN=parseInt(R);break;case"TARGETDURATION":h.targetduration=parseFloat(R);break;case"VERSION":h.version=parseInt(R);break;case"EXTM3U":break;case"ENDLIST":h.live=!1;break;case"DIS":c++,g.tagList.push(["DIS"]);break;case"DISCONTINUITY-SEQ":c=parseInt(R);break;case"KEY":var k=new S(R),x=k.enumeratedString("METHOD"),P=k.URI,C=k.hexadecimalInteger("IV");x&&(l=new p(t,P),P&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(x)>=0&&(l.method=x,l.key=null,l.iv=C));break;case"START":var F=new S(R).decimalFloatingPoint("TIME-OFFSET");Object(o.a)(F)&&(h.startTimeOffset=F);break;case"MAP":var M=new S(R);g.relurl=M.URI,M.BYTERANGE&&g.setByteRange(M.BYTERANGE),g.baseurl=t,g.level=r,g.type=a,g.sn="initSegment",h.initSegment=g,(g=new m).rawProgramDateTime=h.initSegment.rawProgramDateTime;break;default:d.b.warn("line parsed but not handled: "+n)}}}return(g=v)&&!g.relurl&&(h.fragments.pop(),f-=g.duration),h.totalduration=f,h.averagetargetduration=f/h.fragments.length,h.endSN=u-1,h.startCC=h.fragments[0]?h.fragments[0].cc:0,h.endCC=c,!h.initSegment&&h.fragments.length&&h.fragments.every(function(e){return I.test(e.relurl)})&&(d.b.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(g=new m).relurl=h.fragments[0].relurl,g.baseurl=t,g.level=r,g.type=a,g.sn="initSegment",h.initSegment=g,h.needSidxRanges=!0),y&&function(e,t){for(var r=e[t],a=t-1;a>=0;a--){var i=e[a];i.programDateTime=r.programDateTime-1e3*i.duration,r=i}}(h.fragments,y),h},e}();function O(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),Object(o.a)(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}var x=window.performance,P=function(e){var t,r;function n(t){var r;return(r=e.call(this,t,l.a.MANIFEST_LOADING,l.a.LEVEL_LOADING,l.a.AUDIO_TRACK_LOADING,l.a.SUBTITLE_TRACK_LOADING)||this).loaders={},r}r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r,n.canHaveQualityLevels=function(e){return e!==a.AUDIO_TRACK&&e!==a.SUBTITLE_TRACK},n.mapContextToLevelType=function(e){switch(e.type){case a.AUDIO_TRACK:return i.AUDIO;case a.SUBTITLE_TRACK:return i.SUBTITLE;default:return i.MAIN}},n.getResponseUrl=function(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r};var u=n.prototype;return u.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,a=t.loader,i=new(r||a)(t);return e.loader=i,this.loaders[e.type]=i,i},u.getInternalLoader=function(e){return this.loaders[e.type]},u.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},u.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},u.destroy=function(){this.destroyInternalLoaders(),e.prototype.destroy.call(this)},u.onManifestLoading=function(e){this.load({url:e.url,type:a.MANIFEST,level:0,id:null,responseType:"text"})},u.onLevelLoading=function(e){this.load({url:e.url,type:a.LEVEL,level:e.level,id:e.id,responseType:"text"})},u.onAudioTrackLoading=function(e){this.load({url:e.url,type:a.AUDIO_TRACK,level:null,id:e.id,responseType:"text"})},u.onSubtitleTrackLoading=function(e){this.load({url:e.url,type:a.SUBTITLE_TRACK,level:null,id:e.id,responseType:"text"})},u.load=function(e){var t=this.hls.config;d.b.debug("Loading playlist of type "+e.type+", level: "+e.level+", id: "+e.id);var r,i,n,s,o=this.getInternalLoader(e);if(o){var l=o.context;if(l&&l.url===e.url)return d.b.trace("playlist request ongoing"),!1;d.b.warn("aborting previous loader for type: "+e.type),o.abort()}switch(e.type){case a.MANIFEST:r=t.manifestLoadingMaxRetry,i=t.manifestLoadingTimeOut,n=t.manifestLoadingRetryDelay,s=t.manifestLoadingMaxRetryTimeout;break;case a.LEVEL:r=0,s=0,n=0,i=t.levelLoadingTimeOut;break;default:r=t.levelLoadingMaxRetry,i=t.levelLoadingTimeOut,n=t.levelLoadingRetryDelay,s=t.levelLoadingMaxRetryTimeout}o=this.createInternalLoader(e);var u={timeout:i,maxRetry:r,retryDelay:n,maxRetryDelay:s},f={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};return d.b.debug("Calling internal loader delegate for URL: "+e.url),o.load(e,u,f),!0},u.loadsuccess=function(e,t,r,a){if(void 0===a&&(a=null),r.isSidxRequest)return this._handleSidxRequest(e,r),void this._handlePlaylistLoaded(e,t,r,a);if(this.resetInternalLoader(r.type),"string"!=typeof e.data)throw new Error('expected responseType of "text" for PlaylistLoader');var i=e.data;t.tload=x.now(),0===i.indexOf("#EXTM3U")?i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this._handleTrackOrLevelPlaylist(e,t,r,a):this._handleMasterPlaylist(e,t,r,a):this._handleManifestParsingError(e,r,"no EXTM3U delimiter",a)},u.loaderror=function(e,t,r){void 0===r&&(r=null),this._handleNetworkError(t,r,!1,e)},u.loadtimeout=function(e,t,r){void 0===r&&(r=null),this._handleNetworkError(t,r,!0)},u._handleMasterPlaylist=function(e,t,r,a){var i=this.hls,s=e.data,o=n.getResponseUrl(e,r),u=k.parseMasterPlaylist(s,o);if(u.length){var f=u.map(function(e){return{id:e.attrs.AUDIO,codec:e.audioCodec}}),h=k.parseMasterPlaylistMedia(s,o,"AUDIO",f),c=k.parseMasterPlaylistMedia(s,o,"SUBTITLES");if(h.length){var v=!1;h.forEach(function(e){e.url||(v=!0)}),!1===v&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(d.b.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),h.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1}))}i.trigger(l.a.MANIFEST_LOADED,{levels:u,audioTracks:h,subtitles:c,url:o,stats:t,networkDetails:a})}else this._handleManifestParsingError(e,r,"no level found in manifest",a)},u._handleTrackOrLevelPlaylist=function(e,t,r,i){var s=this.hls,d=r.id,u=r.level,f=r.type,h=n.getResponseUrl(e,r),c=Object(o.a)(d)?d:0,v=Object(o.a)(u)?u:c,p=n.mapContextToLevelType(r),g=k.parseLevelPlaylist(e.data,h,v,p,c);if(g.tload=t.tload,f===a.MANIFEST){var m={url:h,details:g};s.trigger(l.a.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:h,stats:t,networkDetails:i})}if(t.tparsed=x.now(),g.needSidxRanges){var y=g.initSegment.url;this.load({url:y,isSidxRequest:!0,type:f,level:u,levelDetails:g,id:d,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer"})}else r.levelDetails=g,this._handlePlaylistLoaded(e,t,r,i)},u._handleSidxRequest=function(e,t){if("string"==typeof e.data)throw new Error("sidx request must be made with responseType of array buffer");var r=h.a.parseSegmentIndex(new Uint8Array(e.data));if(r){var a=r.references,i=t.levelDetails;a.forEach(function(e,t){var r=e.info;if(i){var a=i.fragments[t];0===a.byteRange.length&&a.setByteRange(String(1+r.end-r.start)+"@"+String(r.start))}}),i&&i.initSegment.setByteRange(String(r.moovEndOffset)+"@0")}},u._handleManifestParsingError=function(e,t,r,a){this.hls.trigger(l.a.ERROR,{type:s.b.NETWORK_ERROR,details:s.a.MANIFEST_PARSING_ERROR,fatal:!0,url:e.url,reason:r,networkDetails:a})},u._handleNetworkError=function(e,t,r,i){var n,o;void 0===r&&(r=!1),void 0===i&&(i=null),d.b.info("A network error occured while loading a "+e.type+"-type playlist");var u=this.getInternalLoader(e);switch(e.type){case a.MANIFEST:n=r?s.a.MANIFEST_LOAD_TIMEOUT:s.a.MANIFEST_LOAD_ERROR,o=!0;break;case a.LEVEL:n=r?s.a.LEVEL_LOAD_TIMEOUT:s.a.LEVEL_LOAD_ERROR,o=!1;break;case a.AUDIO_TRACK:n=r?s.a.AUDIO_TRACK_LOAD_TIMEOUT:s.a.AUDIO_TRACK_LOAD_ERROR,o=!1;break;default:o=!1}u&&(u.abort(),this.resetInternalLoader(e.type));var f={type:s.b.NETWORK_ERROR,details:n,fatal:o,url:e.url,loader:u,context:e,networkDetails:t};i&&(f.response=i),this.hls.trigger(l.a.ERROR,f)},u._handlePlaylistLoaded=function(e,t,r,i){var s=r.type,o=r.level,d=r.id,u=r.levelDetails;if(u&&u.targetduration)if(n.canHaveQualityLevels(r.type))this.hls.trigger(l.a.LEVEL_LOADED,{details:u,level:o||0,id:d||0,stats:t,networkDetails:i});else switch(s){case a.AUDIO_TRACK:this.hls.trigger(l.a.AUDIO_TRACK_LOADED,{details:u,id:d,stats:t,networkDetails:i});break;case a.SUBTITLE_TRACK:this.hls.trigger(l.a.SUBTITLE_TRACK_LOADED,{details:u,id:d,stats:t,networkDetails:i})}else this._handleManifestParsingError(e,r,"invalid target duration",i)},n}(f);var C=function(e){var t,r;function a(t){var r;return(r=e.call(this,t,l.a.FRAG_LOADING)||this).loaders={},r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var i=a.prototype;return i.destroy=function(){var t=this.loaders;for(var r in t){var a=t[r];a&&a.destroy()}this.loaders={},e.prototype.destroy.call(this)},i.onFragLoading=function(e){var t=e.frag,r=t.type,a=this.loaders,i=this.hls.config,n=i.fLoader,s=i.loader;t.loaded=0;var l,u,f,h=a[r];h&&(d.b.warn("abort previous fragment loader for type: "+r),h.abort()),h=a[r]=t.loader=i.fLoader?new n(i):new s(i),l={url:t.url,frag:t,responseType:"arraybuffer",progressData:!1};var c=t.byteRangeStartOffset,v=t.byteRangeEndOffset;Object(o.a)(c)&&Object(o.a)(v)&&(l.rangeStart=c,l.rangeEnd=v),u={timeout:i.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:i.fragLoadingMaxRetryTimeout},f={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},h.load(l,u,f)},i.loadsuccess=function(e,t,r,a){void 0===a&&(a=null);var i=e.data,n=r.frag;n.loader=void 0,this.loaders[n.type]=void 0,this.hls.trigger(l.a.FRAG_LOADED,{payload:i,frag:n,stats:t,networkDetails:a})},i.loaderror=function(e,t,r){void 0===r&&(r=null);var a=t.frag,i=a.loader;i&&i.abort(),this.loaders[a.type]=void 0,this.hls.trigger(l.a.ERROR,{type:s.b.NETWORK_ERROR,details:s.a.FRAG_LOAD_ERROR,fatal:!1,frag:t.frag,response:e,networkDetails:r})},i.loadtimeout=function(e,t,r){void 0===r&&(r=null);var a=t.frag,i=a.loader;i&&i.abort(),this.loaders[a.type]=void 0,this.hls.trigger(l.a.ERROR,{type:s.b.NETWORK_ERROR,details:s.a.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t.frag,networkDetails:r})},i.loadprogress=function(e,t,r,a){void 0===a&&(a=null);var i=t.frag;i.loaded=e.loaded,this.hls.trigger(l.a.FRAG_LOAD_PROGRESS,{frag:i,stats:e,networkDetails:a})},a}(f);var F=function(e){var t,r;function a(t){var r;return(r=e.call(this,t,l.a.KEY_LOADING)||this).loaders={},r.decryptkey=null,r.decrypturl=null,r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var i=a.prototype;return i.destroy=function(){for(var t in this.loaders){var r=this.loaders[t];r&&r.destroy()}this.loaders={},e.prototype.destroy.call(this)},i.onKeyLoading=function(e){var t=e.frag,r=t.type,a=this.loaders[r];if(t.decryptdata){var i=t.decryptdata.uri;if(i!==this.decrypturl||null===this.decryptkey){var n=this.hls.config;if(a&&(d.b.warn("abort previous key loader for type:"+r),a.abort()),!i)return void d.b.warn("key uri is falsy");t.loader=this.loaders[r]=new n.loader(n),this.decrypturl=i,this.decryptkey=null;var s={url:i,frag:t,responseType:"arraybuffer"},o={timeout:n.fragLoadingTimeOut,maxRetry:0,retryDelay:n.fragLoadingRetryDelay,maxRetryDelay:n.fragLoadingMaxRetryTimeout},u={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};t.loader.load(s,o,u)}else this.decryptkey&&(t.decryptdata.key=this.decryptkey,this.hls.trigger(l.a.KEY_LOADED,{frag:t}))}else d.b.warn("Missing decryption data on fragment in onKeyLoading")},i.loadsuccess=function(e,t,r){var a=r.frag;a.decryptdata?(this.decryptkey=a.decryptdata.key=new Uint8Array(e.data),a.loader=void 0,delete this.loaders[a.type],this.hls.trigger(l.a.KEY_LOADED,{frag:a})):d.b.error("after key load, decryptdata unset")},i.loaderror=function(e,t){var r=t.frag,a=r.loader;a&&a.abort(),delete this.loaders[r.type],this.hls.trigger(l.a.ERROR,{type:s.b.NETWORK_ERROR,details:s.a.KEY_LOAD_ERROR,fatal:!1,frag:r,response:e})},i.loadtimeout=function(e,t){var r=t.frag,a=r.loader;a&&a.abort(),delete this.loaders[r.type],this.hls.trigger(l.a.ERROR,{type:s.b.NETWORK_ERROR,details:s.a.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})},a}(f);var M="NOT_LOADED",U="APPENDING",N="PARTIAL",B="OK",G=function(e){var t,r;function a(t){var r;return(r=e.call(this,t,l.a.BUFFER_APPENDED,l.a.FRAG_BUFFERED,l.a.FRAG_LOADED)||this).bufferPadding=.2,r.fragments=Object.create(null),r.timeRanges=Object.create(null),r.config=t.config,r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var i=a.prototype;return i.destroy=function(){this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.config=null,f.prototype.destroy.call(this),e.prototype.destroy.call(this)},i.getBufferedFrag=function(e,t){var r=this.fragments,a=Object.keys(r).filter(function(a){var i=r[a];if(i.body.type!==t)return!1;if(!i.buffered)return!1;var n=i.body;return n.startPTS<=e&&e<=n.endPTS});if(0===a.length)return null;var i=a.pop();return r[i].body},i.detectEvictedFragments=function(e,t){var r,a,i=this;Object.keys(this.fragments).forEach(function(n){var s=i.fragments[n];if(!0===s.buffered){var o=s.range[e];if(o){r=o.time;for(var l=0;l<r.length;l++)if(a=r[l],!1===i.isTimeBuffered(a.startPTS,a.endPTS,t)){i.removeFragment(s.body);break}}}})},i.detectPartialFragments=function(e){var t=this,r=this.getFragmentKey(e),a=this.fragments[r];a&&(a.buffered=!0,Object.keys(this.timeRanges).forEach(function(r){if(e.hasElementaryStream(r)){var i=t.timeRanges[r];a.range[r]=t.getBufferedTimes(e.startPTS,e.endPTS,i)}}))},i.getBufferedTimes=function(e,t,r){for(var a,i,n=[],s=!1,o=0;o<r.length;o++){if(a=r.start(o)-this.bufferPadding,i=r.end(o)+this.bufferPadding,e>=a&&t<=i){n.push({startPTS:Math.max(e,r.start(o)),endPTS:Math.min(t,r.end(o))});break}if(e<i&&t>a)n.push({startPTS:Math.max(e,r.start(o)),endPTS:Math.min(t,r.end(o))}),s=!0;else if(t<=a)break}return{time:n,partial:s}},i.getFragmentKey=function(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn},i.getPartialFragment=function(e){var t,r,a,i=this,n=null,s=0;return Object.keys(this.fragments).forEach(function(o){var l=i.fragments[o];i.isPartial(l)&&(r=l.body.startPTS-i.bufferPadding,a=l.body.endPTS+i.bufferPadding,e>=r&&e<=a&&(t=Math.min(e-r,a-e),s<=t&&(n=l.body,s=t)))}),n},i.getState=function(e){var t=this.getFragmentKey(e),r=this.fragments[t],a=M;return void 0!==r&&(a=r.buffered?!0===this.isPartial(r)?N:B:U),a},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 a,i,n=0;n<r.length;n++){if(a=r.start(n)-this.bufferPadding,i=r.end(n)+this.bufferPadding,e>=a&&t<=i)return!0;if(t<=a)return!1}return!1},i.onFragLoaded=function(e){var t=e.frag;Object(o.a)(t.sn)&&!t.bitrateTest&&(this.fragments[this.getFragmentKey(t)]={body:t,range:Object.create(null),buffered:!1})},i.onBufferAppended=function(e){var t=this;this.timeRanges=e.timeRanges,Object.keys(this.timeRanges).forEach(function(e){var r=t.timeRanges[e];t.detectEvictedFragments(e,r)})},i.onFragBuffered=function(e){this.detectPartialFragments(e.frag)},i.hasFragment=function(e){var t=this.getFragmentKey(e);return void 0!==this.fragments[t]},i.removeFragment=function(e){var t=this.getFragmentKey(e);delete this.fragments[t]},i.removeAllFragments=function(){this.fragments=Object.create(null)},a}(f),j={search:function(e,t){for(var r=0,a=e.length-1,i=null,n=null;r<=a;){var s=t(n=e[i=(r+a)/2|0]);if(s>0)r=i+1;else{if(!(s<0))return n;a=i-1}}return null}},K=function(){function e(){}return e.isBuffered=function(e,t){try{if(e)for(var r=e.buffered,a=0;a<r.length;a++)if(t>=r.start(a)&&t<=r.end(a))return!0}catch(e){}return!1},e.bufferInfo=function(e,t,r){try{if(e){var a,i=e.buffered,n=[];for(a=0;a<i.length;a++)n.push({start:i.start(a),end:i.end(a)});return this.bufferedInfo(n,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 a=[];if(r)for(var i=0;i<e.length;i++){var n=a.length;if(n){var s=a[n-1].end;e[i].start-s<r?e[i].end>s&&(a[n-1].end=e[i].end):a.push(e[i])}else a.push(e[i])}else a=e;for(var o,l=0,d=t,u=t,f=0;f<a.length;f++){var h=a[f].start,c=a[f].end;if(t+r>=h&&t<c)d=h,l=(u=c)-t;else if(t+r<h){o=h;break}}return{len:l,start:d,end:u,nextStart:o}},e}(),H=r(8),V=r(11),W=r(9);function Y(){return window.MediaSource||window.WebKitMediaSource}var z=r(5);var X=function(e){var t,r;function a(){return e.apply(this,arguments)||this}return r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r,a.prototype.trigger=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];this.emit.apply(this,[e,e].concat(r))},a}(H.EventEmitter),q=Object(z.a)(),Q=Y()||{isTypeSupported:function(){return!1}},Z=function(){function e(e,t){var r=this;this.hls=e,this.id=t;var a=this.observer=new X,i=e.config,n=function(t,a){(a=a||{}).frag=r.frag,a.id=r.id,e.trigger(t,a)};a.on(l.a.FRAG_DECRYPTED,n),a.on(l.a.FRAG_PARSING_INIT_SEGMENT,n),a.on(l.a.FRAG_PARSING_DATA,n),a.on(l.a.FRAG_PARSED,n),a.on(l.a.ERROR,n),a.on(l.a.FRAG_PARSING_METADATA,n),a.on(l.a.FRAG_PARSING_USERDATA,n),a.on(l.a.INIT_PTS_FOUND,n);var o={mp4:Q.isTypeSupported("video/mp4"),mpeg:Q.isTypeSupported("audio/mpeg"),mp3:Q.isTypeSupported('audio/mp4; codecs="mp3"')},u=navigator.vendor;if(i.enableWorker&&"undefined"!=typeof Worker){var f;d.b.log("demuxing in webworker");try{f=this.w=V(12),this.onwmsg=this.onWorkerMessage.bind(this),f.addEventListener("message",this.onwmsg),f.onerror=function(t){e.trigger(l.a.ERROR,{type:s.b.OTHER_ERROR,details:s.a.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",err:{message:t.message+" ("+t.filename+":"+t.lineno+")"}})},f.postMessage({cmd:"init",typeSupported:o,vendor:u,id:t,config:JSON.stringify(i)})}catch(e){d.b.warn("Error in worker:",e),d.b.error("Error while initializing DemuxerWorker, fallback on DemuxerInline"),f&&q.URL.revokeObjectURL(f.objectURL),this.demuxer=new W.a(a,o,i,u),this.w=void 0}}else this.demuxer=new W.a(a,o,i,u)}var t=e.prototype;return t.destroy=function(){var e=this.w;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.w=null;else{var t=this.demuxer;t&&(t.destroy(),this.demuxer=null)}var r=this.observer;r&&(r.removeAllListeners(),this.observer=null)},t.push=function(e,t,r,a,i,n,s,l){var u=this.w,f=Object(o.a)(i.startPTS)?i.startPTS:i.start,h=i.decryptdata,c=this.frag,v=!(c&&i.cc===c.cc),p=!(c&&i.level===c.level),g=c&&i.sn===c.sn+1,m=!p&&g;if(v&&d.b.log(this.id+":discontinuity detected"),p&&d.b.log(this.id+":switch detected"),this.frag=i,u)u.postMessage({cmd:"demux",data:e,decryptdata:h,initSegment:t,audioCodec:r,videoCodec:a,timeOffset:f,discontinuity:v,trackSwitch:p,contiguous:m,duration:n,accurateTimeOffset:s,defaultInitPTS:l},e instanceof ArrayBuffer?[e]:[]);else{var y=this.demuxer;y&&y.push(e,h,t,r,a,f,v,p,m,n,s,l)}},t.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":q.URL.revokeObjectURL(this.w.objectURL);break;case l.a.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 J(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 $(e,t,r){var a=e[t],i=e[r],n=i.startPTS;Object(o.a)(n)?r>t?(a.duration=n-a.start,a.duration<0&&d.b.warn("negative duration computed for frag "+a.sn+",level "+a.level+", there should be some duration drift between playlist and fragment!")):(i.duration=a.start-n,i.duration<0&&d.b.warn("negative duration computed for frag "+i.sn+",level "+i.level+", there should be some duration drift between playlist and fragment!")):i.start=r>t?a.start+a.duration:Math.max(a.start-i.duration,0)}function ee(e,t,r,a,i,n){var s=r;if(Object(o.a)(t.startPTS)){var l=Math.abs(t.startPTS-r);Object(o.a)(t.deltaPTS)?t.deltaPTS=Math.max(l,t.deltaPTS):t.deltaPTS=l,s=Math.max(r,t.startPTS),r=Math.min(r,t.startPTS),a=Math.max(a,t.endPTS),i=Math.min(i,t.startDTS),n=Math.max(n,t.endDTS)}var d=r-t.start;t.start=t.startPTS=r,t.maxStartPTS=s,t.endPTS=a,t.startDTS=i,t.endDTS=n,t.duration=a-r;var u,f,h,c=t.sn;if(!e||c<e.startSN||c>e.endSN)return 0;for(u=c-e.startSN,(f=e.fragments)[u]=t,h=u;h>0;h--)$(f,h,h-1);for(h=u;h<f.length-1;h++)$(f,h,h+1);return e.PTSKnown=!0,d}function te(e,t,r){if(e&&t)for(var a=Math.max(e.startSN,t.startSN)-t.startSN,i=Math.min(e.endSN,t.endSN)-t.startSN,n=t.startSN-e.startSN,s=a;s<=i;s++){var o=e.fragments[n+s],l=t.fragments[s];if(!o||!l)break;r(o,l,s)}}var re={toString:function(e){for(var t="",r=e.length,a=0;a<r;a++)t+="["+e.start(a).toFixed(3)+","+e.end(a).toFixed(3)+"]";return t}};function ae(e,t){t.fragments.forEach(function(t){if(t){var r=t.start+e;t.start=t.startPTS=r,t.endPTS=r+t.duration}}),t.PTSKnown=!0}function ie(e,t,r){!function(e,t,r){if(function(e,t,r){var a=!1;return t&&t.details&&r&&(r.endCC>r.startCC||e&&e.cc<r.startCC)&&(a=!0),a}(e,r,t)){var a=function(e,t){var r=e.fragments,a=t.fragments;if(a.length&&r.length){var i=function(e,t){for(var r=null,a=0;a<e.length;a+=1){var i=e[a];if(i&&i.cc===t){r=i;break}}return r}(r,a[0].cc);if(i&&(!i||i.startPTS))return i;d.b.log("No frag in previous level to align on")}else d.b.log("No fragments to align")}(r.details,t);a&&(d.b.log("Adjusting PTS using last level due to CC increase within current level"),ae(a.start,t))}}(e,r,t),!r.PTSKnown&&t&&function(e,t){if(t&&t.fragments.length){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;var r=t.fragments[0].programDateTime,a=e.fragments[0].programDateTime,i=(a-r)/1e3+t.fragments[0].start;Object(o.a)(i)&&(d.b.log("adjusting PTS using programDateTime delta, sliding:"+i.toFixed(3)),ae(i,e))}}(r,t.details)}function ne(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0);var a=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-a<=e?1:r.start-a>e&&r.start?-1:0}function se(e,t,r){var a=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-a>e}var oe=function(){function e(e,t,r,a){this.config=e,this.media=t,this.fragmentTracker=r,this.hls=a,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,a=this.stalled,i=r.currentTime,n=r.seeking,s=this.seeking&&!n,o=!this.seeking&&n;if(this.seeking=n,i===e){if((o||s)&&(this.stalled=null),!r.paused&&!r.ended&&0!==r.playbackRate&&r.buffered.length){var l=K.bufferInfo(r,i,0),u=l.len>0,f=l.nextStart||0;if(u||f){if(n){if(l.len>2||(!f||f-i>2))return;this.moved=!1}if(!this.moved&&this.stalled){var h=Math.max(f,l.start||0)-i;if(h>0&&h<=2)return void this._trySkipBufferHole(null)}var c=self.performance.now();if(null!==a){var v=c-a;!n&&v>=250&&this._reportStall(l.len);var p=K.bufferInfo(r,i,t.maxBufferHole);this._tryFixBufferStall(p,v)}else this.stalled=c}}}else if(this.moved=!0,null!==a){if(this.stallReported){var g=self.performance.now()-a;d.b.warn("playback not stuck anymore @"+i+", after "+Math.round(g)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},t._tryFixBufferStall=function(e,t){var r=this.config,a=this.fragmentTracker,i=this.media.currentTime,n=a.getPartialFragment(i);if(n&&this._trySkipBufferHole(n))return;e.len>r.maxBufferHole&&t>1e3*r.highBufferWatchdogPeriod&&(d.b.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.b.warn("Playback stalling at @"+r.currentTime+" due to low buffer"),t.trigger(l.a.ERROR,{type:s.b.MEDIA_ERROR,details:s.a.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))},t._trySkipBufferHole=function(e){for(var t=this.config,r=this.hls,a=this.media,i=a.currentTime,n=0,o=0;o<a.buffered.length;o++){var u=a.buffered.start(o);if(i+t.maxBufferHole>=n&&i<u){var f=Math.max(u+.05,a.currentTime+.1);return d.b.warn("skipping hole, adjusting currentTime from "+i+" to "+f),this.moved=!0,this.stalled=null,a.currentTime=f,e&&r.trigger(l.a.ERROR,{type:s.b.MEDIA_ERROR,details:s.a.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+i+" to "+f,frag:e}),f}n=a.buffered.end(o)}return 0},t._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,a=r.currentTime,i=(this.nudgeRetry||0)+1;if(this.nudgeRetry=i,i<e.nudgeMaxRetry){var n=a+i*e.nudgeOffset;d.b.warn("Nudging 'currentTime' from "+a+" to "+n),r.currentTime=n,t.trigger(l.a.ERROR,{type:s.b.MEDIA_ERROR,details:s.a.BUFFER_NUDGE_ON_STALL,fatal:!1})}else d.b.error("Playhead still not moving while enough data buffered @"+a+" after "+e.nudgeMaxRetry+" nudges"),t.trigger(l.a.ERROR,{type:s.b.MEDIA_ERROR,details:s.a.BUFFER_STALLED_ERROR,fatal:!0})},e}();var le={STOPPED:"STOPPED",STARTING:"STARTING",IDLE:"IDLE",PAUSED:"PAUSED",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BUFFER_FLUSHING:"BUFFER_FLUSHING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};function de(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}var ue=function(e){var t,r;function a(t,r){var a;return(a=e.call(this,t,l.a.MEDIA_ATTACHED,l.a.MEDIA_DETACHING,l.a.MANIFEST_LOADING,l.a.MANIFEST_PARSED,l.a.LEVEL_LOADED,l.a.KEY_LOADED,l.a.FRAG_LOADED,l.a.FRAG_LOAD_EMERGENCY_ABORTED,l.a.FRAG_PARSING_INIT_SEGMENT,l.a.FRAG_PARSING_DATA,l.a.FRAG_PARSED,l.a.ERROR,l.a.AUDIO_TRACK_SWITCHING,l.a.AUDIO_TRACK_SWITCHED,l.a.BUFFER_CREATED,l.a.BUFFER_APPENDED,l.a.BUFFER_FLUSHED)||this).fragmentTracker=r,a.config=t.config,a.audioCodecSwap=!1,a._state=le.STOPPED,a.stallReported=!1,a.gapController=null,a.altAudio=!1,a}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n,u,f,h=a.prototype;return h.startLoad=function(e){if(this.levels){var t=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var a=r.startLevel;-1===a&&(a=0,this.bitrateTest=!0),this.level=r.nextLoadLevel=a,this.loadedmetadata=!1}t>0&&-1===e&&(d.b.log("override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=le.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this.forceStartLoad=!0,this.state=le.STOPPED},h.stopLoad=function(){this.forceStartLoad=!1,e.prototype.stopLoad.call(this)},h.doTick=function(){switch(this.state){case le.BUFFER_FLUSHING:this.fragLoadError=0;break;case le.IDLE:this._doTickIdle();break;case le.WAITING_LEVEL:var e=this.levels[this.level];e&&e.details&&(this.state=le.IDLE);break;case le.FRAG_LOADING_WAITING_RETRY:var t=window.performance.now(),r=this.retryDate;(!r||t>=r||this.media&&this.media.seeking)&&(d.b.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=le.IDLE);break;case le.ERROR:case le.STOPPED:case le.FRAG_LOADING:case le.PARSING:case le.PARSED:case le.ENDED:}this._checkBuffer(),this._checkFragmentChanged()},h._doTickIdle=function(){var e=this.hls,t=e.config,r=this.media;if(void 0!==this.levelLastLoaded&&(r||!this.startFragRequested&&t.startFragPrefetch)){var a;a=this.loadedmetadata?r.currentTime:this.nextLoadPosition;var i=e.nextLoadLevel,n=this.levels[i];if(n){var s,o=n.bitrate;s=o?Math.max(8*t.maxBufferSize/o,t.maxBufferLength):t.maxBufferLength,s=Math.min(s,t.maxMaxBufferLength);var u=K.bufferInfo(this.mediaBuffer?this.mediaBuffer:r,a,t.maxBufferHole),f=u.len;if(!(f>=s)){d.b.trace("buffer length of "+f.toFixed(3)+" is below max of "+s.toFixed(3)+". checking for more payload ..."),this.level=e.nextLoadLevel=i;var h=n.details;if(!h||h.live&&this.levelLastLoaded!==i)this.state=le.WAITING_LEVEL;else{if(this._streamEnded(u,h)){var c={};return this.altAudio&&(c.type="video"),this.hls.trigger(l.a.BUFFER_EOS,c),void(this.state=le.ENDED)}this._fetchPayloadOrEos(a,u,h)}}}}},h._fetchPayloadOrEos=function(e,t,r){var a=this.fragPrevious,i=this.level,n=r.fragments,s=n.length;if(0!==s){var o,l=n[0].start,u=n[s-1].start+n[s-1].duration,f=t.end;if(r.initSegment&&!r.initSegment.data)o=r.initSegment;else if(r.live){var h=this.config.initialLiveManifestSize;if(s<h)return void d.b.warn("Can not start playback of a level, reason: not enough fragments "+s+" < "+h);if(null===(o=this._ensureFragmentAtLivePoint(r,f,l,u,a,n,s)))return}else f<l&&(o=n[0]);o||(o=this._findFragment(l,a,s,n,f,u,r)),o&&(o.encrypted?(d.b.log("Loading key for "+o.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+i),this._loadKey(o)):(d.b.log("Loading "+o.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+i+", currentTime:"+e.toFixed(3)+",bufferEnd:"+f.toFixed(3)),this._loadFragment(o)))}},h._ensureFragmentAtLivePoint=function(e,t,r,a,i,n,s){var l,u=this.hls.config,f=this.media,h=void 0!==u.liveMaxLatencyDuration?u.liveMaxLatencyDuration:u.liveMaxLatencyDurationCount*e.targetduration;if(t<Math.max(r-u.maxFragLookUpTolerance,a-h)){var c=this.liveSyncPosition=this.computeLivePosition(r,e);d.b.log("buffer end: "+t.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+c.toFixed(3)),t=c,f&&!f.paused&&f.readyState&&f.duration>c&&(f.currentTime=c),this.nextLoadPosition=c}if(e.PTSKnown&&t>a&&f&&f.readyState)return null;if(this.startFragRequested&&!e.PTSKnown){if(i)if(e.hasProgramDateTime)d.b.log("live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),l=function(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!Object(o.a)(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var a=0;a<e.length;++a){var i=e[a];if(se(t,r,i))return i}return null}(n,i.endProgramDateTime,u.maxFragLookUpTolerance);else{var v=i.sn+1;if(v>=e.startSN&&v<=e.endSN){var p=n[v-e.startSN];i.cc===p.cc&&(l=p,d.b.log("live playlist, switching playlist, load frag with next SN: "+l.sn))}l||(l=j.search(n,function(e){return i.cc-e.cc}))&&d.b.log("live playlist, switching playlist, load frag with same CC: "+l.sn)}l||(l=n[Math.min(s-1,Math.round(s/2))],d.b.log("live playlist, switching playlist, unknown, load middle frag : "+l.sn))}return l},h._findFragment=function(e,t,r,a,i,n,s){var o,l=this.hls.config;i<n?o=function(e,t,r,a){void 0===r&&(r=0),void 0===a&&(a=0);var i=e?t[e.sn-t[0].sn+1]:null;return i&&!ne(r,a,i)?i:j.search(t,ne.bind(null,r,a))}(t,a,i,i>n-l.maxFragLookUpTolerance?0:l.maxFragLookUpTolerance):o=a[r-1];if(o){var u=o.sn-s.startSN,f=t&&o.level===t.level,h=a[u-1],c=a[u+1];if(t&&o.sn===t.sn)if(f&&!o.backtracked)if(o.sn<s.endSN){var v=t.deltaPTS;v&&v>l.maxBufferHole&&t.dropped&&u?(o=h,d.b.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")):(o=c,d.b.log("Re-loading fragment with SN: "+o.sn))}else o=null;else o.backtracked&&(c&&c.backtracked?(d.b.warn("Already backtracked from fragment "+c.sn+", will not backtrack to fragment "+o.sn+". Loading fragment "+c.sn),o=c):(d.b.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),o.dropped=0,h?(o=h).backtracked=!0:u&&(o=null)))}return o},h._loadKey=function(e){this.state=le.KEY_LOADING,this.hls.trigger(l.a.KEY_LOADING,{frag:e})},h._loadFragment=function(e){var t=this.fragmentTracker.getState(e);this.fragCurrent=e,"initSegment"!==e.sn&&(this.startFragRequested=!0),Object(o.a)(e.sn)&&!e.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),e.backtracked||t===M||t===N?(e.autoLevel=this.hls.autoLevelEnabled,e.bitrateTest=this.bitrateTest,this.hls.trigger(l.a.FRAG_LOADING,{frag:e}),this.demuxer||(this.demuxer=new Z(this.hls,"main")),this.state=le.FRAG_LOADING):t===U&&this._reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e)},h.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,i.MAIN)},h.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.endPTS+.5):null},h._checkFragmentChanged=function(){var e,t,r=this.media;if(r&&r.readyState&&!1===r.seeking&&((t=r.currentTime)>this.lastCurrentTime&&(this.lastCurrentTime=t),K.isBuffered(r,t)?e=this.getBufferedFrag(t):K.isBuffered(r,t+.1)&&(e=this.getBufferedFrag(t+.1)),e)){var a=e;if(a!==this.fragPlaying){this.hls.trigger(l.a.FRAG_CHANGED,{frag:a});var i=a.level;this.fragPlaying&&this.fragPlaying.level===i||this.hls.trigger(l.a.LEVEL_SWITCHED,{level:i}),this.fragPlaying=a}}},h.immediateLevelSwitch=function(){if(d.b.log("immediateLevelSwitch"),!this.immediateSwitch){this.immediateSwitch=!0;var e,t=this.media;t?(e=t.paused,t.pause()):e=!0,this.previouslyPaused=e}var r=this.fragCurrent;r&&r.loader&&r.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},h.immediateLevelSwitchEnd=function(){var e=this.media;e&&e.buffered.length&&(this.immediateSwitch=!1,K.isBuffered(e,e.currentTime)&&(e.currentTime-=1e-4),this.previouslyPaused||e.play())},h.nextLevelSwitch=function(){var e=this.media;if(e&&e.readyState){var t,r,a;if((r=this.getBufferedFrag(e.currentTime))&&r.startPTS>1&&this.flushMainBuffer(0,r.startPTS-1),e.paused)t=0;else{var i=this.hls.nextLoadLevel,n=this.levels[i],s=this.fragLastKbps;t=s&&this.fragCurrent?this.fragCurrent.duration*n.bitrate/(1e3*s)+1:0}if((a=this.getBufferedFrag(e.currentTime+t))&&(a=this.followingBufferedFrag(a))){var o=this.fragCurrent;o&&o.loader&&o.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(a.maxStartPTS,Number.POSITIVE_INFINITY)}}},h.flushMainBuffer=function(e,t){this.state=le.BUFFER_FLUSHING;var r={startOffset:e,endOffset:t};this.altAudio&&(r.type="video"),this.hls.trigger(l.a.BUFFER_FLUSHING,r)},h.onMediaAttached=function(e){var t=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("seeked",this.onvseeked),t.addEventListener("ended",this.onvended);var r=this.config;this.levels&&r.autoStartLoad&&this.hls.startLoad(r.startPosition),this.gapController=new oe(r,t,this.fragmentTracker,this.hls)},h.onMediaDetaching=function(){var e=this.media;e&&e.ended&&(d.b.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var t=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()},h.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:void 0;Object(o.a)(t)&&d.b.log("media seeked to "+t.toFixed(3)),this.tick()},h.onManifestLoading=function(){d.b.log("trigger BUFFER_RESET"),this.hls.trigger(l.a.BUFFER_RESET),this.fragmentTracker.removeAllFragments(),this.stalled=!1,this.startPosition=this.lastCurrentTime=0},h.onManifestParsed=function(e){var t,r=!1,a=!1;e.levels.forEach(function(e){(t=e.audioCodec)&&(-1!==t.indexOf("mp4a.40.2")&&(r=!0),-1!==t.indexOf("mp4a.40.5")&&(a=!0))}),this.audioCodecSwitch=r&&a,this.audioCodecSwitch&&d.b.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;var i=this.config;(i.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(i.startPosition)},h.onLevelLoaded=function(e){var t=e.details,r=e.level,a=this.levels[this.levelLastLoaded],i=this.levels[r],n=t.totalduration,s=0;if(d.b.log("level "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+n),t.live){var u=i.details;u&&t.fragments.length>0?(!function(e,t){t.initSegment&&e.initSegment&&(t.initSegment=e.initSegment);var r,a=0;if(te(e,t,function(e,i){a=e.cc-i.cc,Object(o.a)(e.startPTS)&&(i.start=i.startPTS=e.startPTS,i.endPTS=e.endPTS,i.duration=e.duration,i.backtracked=e.backtracked,i.dropped=e.dropped,r=i),t.PTSKnown=!0}),t.PTSKnown){if(a){d.b.log("discontinuity sliding from playlist, take drift into account");for(var i=t.fragments,n=0;n<i.length;n++)i[n].cc+=a}r?ee(t,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):function(e,t){var r=t.startSN-e.startSN,a=e.fragments,i=t.fragments;if(!(r<0||r>a.length))for(var n=0;n<i.length;n++)i[n].start+=a[r].start}(e,t),t.PTSKnown=e.PTSKnown}}(u,t),s=t.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(s,u),t.PTSKnown&&Object(o.a)(s)?d.b.log("live playlist sliding:"+s.toFixed(3)):(d.b.log("live playlist - outdated PTS, unknown sliding"),ie(this.fragPrevious,a,t))):(d.b.log("live playlist - first load, unknown sliding"),t.PTSKnown=!1,ie(this.fragPrevious,a,t))}else t.PTSKnown=!1;if(i.details=t,this.levelLastLoaded=r,this.hls.trigger(l.a.LEVEL_UPDATED,{details:t,level:r}),!1===this.startFragRequested){if(-1===this.startPosition||-1===this.lastCurrentTime){var f=t.startTimeOffset;Object(o.a)(f)?(f<0&&(d.b.log("negative start time offset "+f+", count from end of last fragment"),f=s+n+f),d.b.log("start time offset found in playlist, adjust startPosition to "+f),this.startPosition=f):t.live?(this.startPosition=this.computeLivePosition(s,t),d.b.log("configure startPosition to "+this.startPosition)):this.startPosition=0,this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===le.WAITING_LEVEL&&(this.state=le.IDLE),this.tick()},h.onKeyLoaded=function(){this.state===le.KEY_LOADING&&(this.state=le.IDLE,this.tick())},h.onFragLoaded=function(e){var t=this.fragCurrent,r=this.hls,a=this.levels,i=this.media,n=e.frag;if(this.state===le.FRAG_LOADING&&t&&"main"===n.type&&n.level===t.level&&n.sn===t.sn){var s=e.stats,o=a[t.level],u=o.details;if(this.bitrateTest=!1,this.stats=s,d.b.log("Loaded "+t.sn+" of ["+u.startSN+" ,"+u.endSN+"],level "+t.level),n.bitrateTest&&r.nextLoadLevel)this.state=le.IDLE,this.startFragRequested=!1,s.tparsed=s.tbuffered=window.performance.now(),r.trigger(l.a.FRAG_BUFFERED,{stats:s,frag:t,id:"main"}),this.tick();else if("initSegment"===n.sn)this.state=le.IDLE,s.tparsed=s.tbuffered=window.performance.now(),u.initSegment.data=e.payload,r.trigger(l.a.FRAG_BUFFERED,{stats:s,frag:t,id:"main"}),this.tick();else{d.b.log("Parsing "+t.sn+" of ["+u.startSN+" ,"+u.endSN+"],level "+t.level+", cc "+t.cc),this.state=le.PARSING,this.pendingBuffering=!0,this.appended=!1,n.bitrateTest&&(n.bitrateTest=!1,this.fragmentTracker.onFragLoaded({frag:n}));var f=!(i&&i.seeking)&&(u.PTSKnown||!u.live),h=u.initSegment?u.initSegment.data:[],c=this._getAudioCodec(o);(this.demuxer=this.demuxer||new Z(this.hls,"main")).push(e.payload,h,c,o.videoCodec,t,u.totalduration,f)}}this.fragLoadError=0},h.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===le.PARSING){var a,i,n=e.tracks;if(n.audio&&this.altAudio&&delete n.audio,i=n.audio){var s=this.levels[this.level].audioCodec,o=navigator.userAgent.toLowerCase();s&&this.audioCodecSwap&&(d.b.log("swapping playlist audio codec"),s=-1!==s.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==i.metadata.channelCount&&-1===o.indexOf("firefox")&&(s="mp4a.40.5"),-1!==o.indexOf("android")&&"audio/mpeg"!==i.container&&(s="mp4a.40.2",d.b.log("Android: force audio codec to "+s)),i.levelCodec=s,i.id=e.id}for(a in(i=n.video)&&(i.levelCodec=this.levels[this.level].videoCodec,i.id=e.id),this.hls.trigger(l.a.BUFFER_CODECS,n),n){i=n[a],d.b.log("main track:"+a+",container:"+i.container+",codecs[level/parsed]=["+i.levelCodec+"/"+i.codec+"]");var u=i.initSegment;u&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(l.a.BUFFER_APPENDING,{type:a,data:u,parent:"main",content:"initSegment"}))}this.tick()}},h.onFragParsingData=function(e){var t=this,r=this.fragCurrent,a=e.frag;if(r&&"main"===e.id&&a.sn===r.sn&&a.level===r.level&&("audio"!==e.type||!this.altAudio)&&this.state===le.PARSING){var i=this.levels[this.level],n=r;if(Object(o.a)(e.endPTS)||(e.endPTS=e.startPTS+r.duration,e.endDTS=e.startDTS+r.duration),!0===e.hasAudio&&n.addElementaryStream(v.AUDIO),!0===e.hasVideo&&n.addElementaryStream(v.VIDEO),d.b.log("Parsed "+e.type+",PTS:["+e.startPTS.toFixed(3)+","+e.endPTS.toFixed(3)+"],DTS:["+e.startDTS.toFixed(3)+"/"+e.endDTS.toFixed(3)+"],nb:"+e.nb+",dropped:"+(e.dropped||0)),"video"===e.type)if(n.dropped=e.dropped,n.dropped)if(n.backtracked)d.b.warn("Already backtracked on this fragment, appending with the gap",n.sn);else{var s=i.details;if(!s||n.sn!==s.startSN)return d.b.warn("missing video frame(s), backtracking fragment",n.sn),this.fragmentTracker.removeFragment(n),n.backtracked=!0,this.nextLoadPosition=e.startPTS,this.state=le.IDLE,this.fragPrevious=n,void this.tick();d.b.warn("missing video frame(s) on first frag, appending with gap",n.sn)}else n.backtracked=!1;var u=ee(i.details,n,e.startPTS,e.endPTS,e.startDTS,e.endDTS),f=this.hls;f.trigger(l.a.LEVEL_PTS_UPDATED,{details:i.details,level:this.level,drift:u,type:e.type,start:e.startPTS,end:e.endPTS}),[e.data1,e.data2].forEach(function(r){r&&r.length&&t.state===le.PARSING&&(t.appended=!0,t.pendingBuffering=!0,f.trigger(l.a.BUFFER_APPENDING,{type:e.type,data:r,parent:"main",content:"data"}))}),this.tick()}},h.onFragParsed=function(e){var t=this.fragCurrent,r=e.frag;t&&"main"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===le.PARSING&&(this.stats.tparsed=window.performance.now(),this.state=le.PARSED,this._checkAppendedParsed())},h.onAudioTrackSwitching=function(e){var t=!!e.url,r=e.id;if(!t){if(this.mediaBuffer!==this.media){d.b.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;a.loader&&(d.b.log("switching to main audio track, cancel main fragment load"),a.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=le.IDLE}var i=this.hls;i.trigger(l.a.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),i.trigger(l.a.AUDIO_TRACK_SWITCHED,{id:r}),this.altAudio=!1}},h.onAudioTrackSwitched=function(e){var t=e.id,r=!!this.hls.audioTracks[t].url;if(r){var a=this.videoBuffer;a&&this.mediaBuffer!==a&&(d.b.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=a)}this.altAudio=r,this.tick()},h.onBufferCreated=function(e){var t,r,a=e.tracks,i=!1;for(var n in a){var s=a[n];"main"===s.id?(r=n,t=s,"video"===n&&(this.videoBuffer=a[n].buffer)):i=!0}i&&t?(d.b.log("alternate track found, use "+r+".buffered to schedule main fragment loading"),this.mediaBuffer=t.buffer):this.mediaBuffer=this.media},h.onBufferAppended=function(e){if("main"===e.parent){var t=this.state;t!==le.PARSING&&t!==le.PARSED||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}},h._checkAppendedParsed=function(){if(!(this.state!==le.PARSED||this.appended&&this.pendingBuffering)){var e=this.fragCurrent;if(e){var t=this.mediaBuffer?this.mediaBuffer:this.media;d.b.log("main buffered : "+re.toString(t.buffered)),this.fragPrevious=e;var r=this.stats;r.tbuffered=window.performance.now(),this.fragLastKbps=Math.round(8*r.total/(r.tbuffered-r.tfirst)),this.hls.trigger(l.a.FRAG_BUFFERED,{stats:r,frag:e,id:"main"}),this.state=le.IDLE}this.tick()}},h.onError=function(e){var t=e.frag||this.fragCurrent;if(!t||"main"===t.type){var r=!!this.media&&K.isBuffered(this.media,this.media.currentTime)&&K.isBuffered(this.media,this.media.currentTime+.5);switch(e.details){case s.a.FRAG_LOAD_ERROR:case s.a.FRAG_LOAD_TIMEOUT:case s.a.KEY_LOAD_ERROR:case s.a.KEY_LOAD_TIMEOUT:if(!e.fatal)if(this.fragLoadError+1<=this.config.fragLoadingMaxRetry){var a=Math.min(Math.pow(2,this.fragLoadError)*this.config.fragLoadingRetryDelay,this.config.fragLoadingMaxRetryTimeout);d.b.warn("mediaController: frag loading failed, retry in "+a+" ms"),this.retryDate=window.performance.now()+a,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.fragLoadError++,this.state=le.FRAG_LOADING_WAITING_RETRY}else d.b.error("mediaController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=le.ERROR;break;case s.a.LEVEL_LOAD_ERROR:case s.a.LEVEL_LOAD_TIMEOUT:this.state!==le.ERROR&&(e.fatal?(this.state=le.ERROR,d.b.warn("streamController: "+e.details+",switch to "+this.state+" state ...")):e.levelRetry||this.state!==le.WAITING_LEVEL||(this.state=le.IDLE));break;case s.a.BUFFER_FULL_ERROR:"main"!==e.parent||this.state!==le.PARSING&&this.state!==le.PARSED||(r?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=le.IDLE):(d.b.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)))}}},h._reduceMaxBufferLength=function(e){var t=this.config;return t.maxMaxBufferLength>=e&&(t.maxMaxBufferLength/=2,d.b.warn("main:reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},h._checkBuffer=function(){var e=this.media;if(e&&0!==e.readyState){var t=(this.mediaBuffer?this.mediaBuffer:e).buffered;!this.loadedmetadata&&t.length?(this.loadedmetadata=!0,this._seekToStartPos()):this.immediateSwitch?this.immediateLevelSwitchEnd():this.gapController.poll(this.lastCurrentTime,t)}},h.onFragLoadEmergencyAborted=function(){this.state=le.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},h.onBufferFlushed=function(){var e=this.mediaBuffer?this.mediaBuffer:this.media;e&&this.fragmentTracker.detectEvictedFragments(v.VIDEO,e.buffered),this.state=le.IDLE,this.fragPrevious=null},h.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},h._seekToStartPos=function(){var e=this.media,t=e.currentTime,r=e.seeking?t:this.startPosition;t!==r&&r>=0&&(d.b.log("target start position not buffered, seek to buffered.start(0) "+r+" from current time "+t+" "),e.currentTime=r)},h._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&(d.b.log("swapping playlist audio codec"),t&&(t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),t},n=a,(u=[{key:"state",set:function(e){if(this.state!==e){var t=this.state;this._state=e,d.b.log("main stream-controller: "+t+"->"+e),this.hls.trigger(l.a.STREAM_STATE_TRANSITION,{previousState:t,nextState:e})}},get:function(){return this._state}},{key:"currentLevel",get:function(){var e=this.media;if(e){var t=this.getBufferedFrag(e.currentTime);if(t)return t.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(n.prototype,u),f&&de(n,f),a}(function(e){var t,r;function a(){return e.apply(this,arguments)||this}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var i=a.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=le.STOPPED},i._streamEnded=function(e,t){var r=this.fragCurrent,a=this.fragmentTracker;if(!t.live&&r&&!r.backtracked&&r.sn===t.endSN&&!e.nextStart){var i=a.getState(r);return i===N||i===B}return!1},i.onMediaSeeking=function(){var e=this.config,t=this.media,r=this.mediaBuffer,a=this.state,i=t?t.currentTime:null,n=K.bufferInfo(r||t,i,this.config.maxBufferHole);if(Object(o.a)(i)&&d.b.log("media seeking to "+i.toFixed(3)),a===le.FRAG_LOADING){var s=this.fragCurrent;if(0===n.len&&s){var l=e.maxFragLookUpTolerance,u=s.start-l,f=s.start+s.duration+l;i<u||i>f?(s.loader&&(d.b.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),s.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=le.IDLE):d.b.log("seeking outside of buffer but within currently loaded fragment range")}}else a===le.ENDED&&(0===n.len&&(this.fragPrevious=null,this.fragCurrent=null),this.state=le.IDLE);t&&(this.lastCurrentTime=i),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=i),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=le.STOPPED,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)},a}(function(e){var t,r;function a(t){for(var r,a=arguments.length,i=new Array(a>1?a-1:0),n=1;n<a;n++)i[n-1]=arguments[n];return(r=e.call.apply(e,[this,t].concat(i))||this)._boundTick=void 0,r._tickTimer=null,r._tickInterval=null,r._tickCallCount=0,r._boundTick=r.tick.bind(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r)),r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var i=a.prototype;return i.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},i.hasInterval=function(){return!!this._tickInterval},i.hasNextTick=function(){return!!this._tickTimer},i.setInterval=function(e){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,e),!0)},i.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},i.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},i.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&(this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)),this._tickCallCount=0)},i.doTick=function(){},a}(f)));function fe(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}window.performance;var he,ce=function(e){var t,r;function a(t){var r;return(r=e.call(this,t,l.a.MANIFEST_LOADED,l.a.LEVEL_LOADED,l.a.AUDIO_TRACK_SWITCHED,l.a.FRAG_LOADED,l.a.ERROR)||this).canload=!1,r.currentLevelIndex=null,r.manualLevelIndex=-1,r.timer=null,he=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var i,n,o,u=a.prototype;return u.onHandlerDestroying=function(){this.clearTimer(),this.manualLevelIndex=-1},u.clearTimer=function(){null!==this.timer&&(clearTimeout(this.timer),this.timer=null)},u.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()},u.stopLoad=function(){this.canload=!1},u.onManifestLoaded=function(e){var t,r=[],a=[],i={},n=null,o=!1,u=!1;if(e.levels.forEach(function(e){var t=e.attrs;e.loadError=0,e.fragmentError=!1,o=o||!!e.videoCodec,u=u||!!e.audioCodec,he&&e.audioCodec&&-1!==e.audioCodec.indexOf("mp4a.40.34")&&(e.audioCodec=void 0),(n=i[e.bitrate])?n.url.push(e.url):(e.url=[e.url],e.urlId=0,i[e.bitrate]=e,r.push(e)),t&&(t.AUDIO&&(u=!0,J(n||e,"audio",t.AUDIO)),t.SUBTITLES&&J(n||e,"text",t.SUBTITLES))}),o&&u&&(r=r.filter(function(e){return!!e.videoCodec})),r=r.filter(function(e){var t=e.audioCodec,r=e.videoCodec;return(!t||_(t,"audio"))&&(!r||_(r,"video"))}),e.audioTracks&&(a=e.audioTracks.filter(function(e){return!e.audioCodec||_(e.audioCodec,"audio")})).forEach(function(e,t){e.id=t}),r.length>0){t=r[0].bitrate,r.sort(function(e,t){return e.bitrate-t.bitrate}),this._levels=r;for(var f=0;f<r.length;f++)if(r[f].bitrate===t){this._firstLevel=f,d.b.log("manifest loaded,"+r.length+" level(s) found, first bitrate:"+t);break}this.hls.trigger(l.a.MANIFEST_PARSED,{levels:r,audioTracks:a,firstLevel:this._firstLevel,stats:e.stats,audio:u,video:o,altAudio:a.some(function(e){return!!e.url})})}else this.hls.trigger(l.a.ERROR,{type:s.b.MEDIA_ERROR,details:s.a.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:this.hls.url,reason:"no level with compatible codecs found in manifest"})},u.setLevelInternal=function(e){var t=this._levels,r=this.hls;if(e>=0&&e<t.length){if(this.clearTimer(),this.currentLevelIndex!==e){d.b.log("switching to level "+e),this.currentLevelIndex=e;var a=t[e];a.level=e,r.trigger(l.a.LEVEL_SWITCHING,a)}var i=t[e],n=i.details;if(!n||n.live){var o=i.urlId;r.trigger(l.a.LEVEL_LOADING,{url:i.url[o],level:e,id:o})}}else r.trigger(l.a.ERROR,{type:s.b.OTHER_ERROR,details:s.a.LEVEL_SWITCH_ERROR,level:e,fatal:!1,reason:"invalid level idx"})},u.onError=function(e){if(e.fatal)e.type===s.b.NETWORK_ERROR&&this.clearTimer();else{var t,r=!1,a=!1;switch(e.details){case s.a.FRAG_LOAD_ERROR:case s.a.FRAG_LOAD_TIMEOUT:case s.a.KEY_LOAD_ERROR:case s.a.KEY_LOAD_TIMEOUT:t=e.frag.level,a=!0;break;case s.a.LEVEL_LOAD_ERROR:case s.a.LEVEL_LOAD_TIMEOUT:t=e.context.level,r=!0;break;case s.a.REMUX_ALLOC_ERROR:t=e.level,r=!0}void 0!==t&&this.recoverLevel(e,t,r,a)}},u.recoverLevel=function(e,t,r,a){var i,n,s,o=this,l=this.hls.config,u=e.details,f=this._levels[t];if(f.loadError++,f.fragmentError=a,r){if(!(this.levelRetryCount+1<=l.levelLoadingMaxRetry))return d.b.error("level controller, cannot recover from "+u+" error"),this.currentLevelIndex=null,this.clearTimer(),void(e.fatal=!0);n=Math.min(Math.pow(2,this.levelRetryCount)*l.levelLoadingRetryDelay,l.levelLoadingMaxRetryTimeout),this.timer=setTimeout(function(){return o.loadLevel()},n),e.levelRetry=!0,this.levelRetryCount++,d.b.warn("level controller, "+u+", retry in "+n+" ms, current retry count is "+this.levelRetryCount)}(r||a)&&((i=f.url.length)>1&&f.loadError<i?(f.urlId=(f.urlId+1)%i,f.details=void 0,d.b.warn("level controller, "+u+" for level "+t+": switching to redundant URL-id "+f.urlId)):-1===this.manualLevelIndex?(s=0===t?this._levels.length-1:t-1,d.b.warn("level controller, "+u+": switch to "+s),this.hls.nextAutoLevel=this.currentLevelIndex=s):a&&(d.b.warn("level controller, "+u+": reload a fragment"),this.currentLevelIndex=null))},u.onFragLoaded=function(e){var t=e.frag;if(void 0!==t&&"main"===t.type){var r=this._levels[t.level];void 0!==r&&(r.fragmentError=!1,r.loadError=0,this.levelRetryCount=0)}},u.onLevelLoaded=function(e){var t=this,r=e.level,a=e.details;if(r===this.currentLevelIndex){var i=this._levels[r];if(i.fragmentError||(i.loadError=0,this.levelRetryCount=0),a.live){var n=function(e,t,r){var a=1e3*(t.averagetargetduration?t.averagetargetduration:t.targetduration),i=a/2;return e&&t.endSN===e.endSN&&(a=i),r&&(a=Math.max(i,a-(window.performance.now()-r))),Math.round(a)}(i.details,a,e.stats.trequest);d.b.log("live playlist, reload in "+Math.round(n)+" ms"),this.timer=setTimeout(function(){return t.loadLevel()},n)}else this.clearTimer()}},u.onAudioTrackSwitched=function(e){var t=this.hls.audioTracks[e.id].groupId,r=this.hls.levels[this.currentLevelIndex];if(r&&r.audioGroupIds){for(var a=-1,i=0;i<r.audioGroupIds.length;i++)if(r.audioGroupIds[i]===t){a=i;break}a!==r.urlId&&(r.urlId=a,this.startLoad())}},u.loadLevel=function(){if(d.b.debug("call to loadLevel"),null!==this.currentLevelIndex&&this.canload){var e=this._levels[this.currentLevelIndex];if("object"==typeof e&&e.url.length>0){var t=this.currentLevelIndex,r=e.urlId,a=e.url[r];d.b.log("Attempt loading level index "+t+" with URL-id "+r),this.hls.trigger(l.a.LEVEL_LOADING,{url:a,level:t,id:r})}}},i=a,(n=[{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(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return 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)}}])&&fe(i.prototype,n),o&&fe(i,o),a}(f),ve=r(4);function pe(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)}var ge=function(e){var t,r;function a(t){var r;return(r=e.call(this,t,l.a.MEDIA_ATTACHED,l.a.MEDIA_DETACHING,l.a.FRAG_PARSING_METADATA,l.a.LIVE_BACK_BUFFER_REACHED)||this).id3Track=void 0,r.media=void 0,r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var i=a.prototype;return i.destroy=function(){f.prototype.destroy.call(this)},i.onMediaAttached=function(e){this.media=e.media,this.media},i.onMediaDetaching=function(){!function(e){if(e&&e.cues)for(;e.cues.length>0;)e.removeCue(e.cues[0])}(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 pe(r,this.media),r}return this.media.addTextTrack("metadata","id3")},i.onFragParsingMetadata=function(e){var t=e.frag,r=e.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var a=window.WebKitDataCue||window.VTTCue||window.TextTrackCue,i=0;i<r.length;i++){var n=ve.a.getID3Frames(r[i].data);if(n){var s=r[i].pts,o=i<r.length-1?r[i+1].pts:t.endPTS;s===o?o+=1e-4:s>o&&(d.b.warn("detected an id3 sample with endTime < startTime, adjusting endTime to (startTime + 0.25)"),o=s+.25);for(var l=0;l<n.length;l++){var u=n[l];if(!ve.a.isTimeStampFrame(u)){var f=new a(s,o,"");f.value=u,this.id3Track.addCue(f)}}}}},i.onLiveBackBufferReached=function(e){var t=e.bufferEnd,r=this.id3Track;if(r&&r.cues&&r.cues.length){var a=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,a=e.length-1;r<=a;){var i=Math.floor((a+r)/2);if(t<e[i].endTime)a=i-1;else{if(!(t>e[i].endTime))return e[i];r=i+1}}return e[r].endTime-t<t-e[a].endTime?e[r]:e[a]}(r.cues,t);if(a)for(;r.cues[0]!==a;)r.removeCue(r.cues[0])}},a}(f);var me=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(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);return this.estimate_/e}return this.estimate_},e}(),ye=function(){function e(e,t,r,a){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_=a,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new me(t),this.fast_=new me(r)}var t=e.prototype;return t.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,a=8*t/r;this.fast_.sample(r,a),this.slow_.sample(r,a)},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 be(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}var Ee=window.performance,Te=function(e){var t,r;function a(t){var r;return(r=e.call(this,t,l.a.FRAG_LOADING,l.a.FRAG_LOADED,l.a.FRAG_BUFFERED,l.a.ERROR)||this).lastLoadedFragLevel=0,r._nextAutoLevel=-1,r.hls=t,r.timer=null,r._bwEstimator=null,r.onCheck=r._abandonRulesCheck.bind(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r)),r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var i,n,u,h=a.prototype;return h.destroy=function(){this.clearTimer(),f.prototype.destroy.call(this)},h.onFragLoading=function(e){var t=e.frag;if("main"===t.type&&(this.timer||(this.fragCurrent=t,this.timer=setInterval(this.onCheck,100)),!this._bwEstimator)){var r,a,i=this.hls,n=i.config,s=t.level;i.levels[s].details.live?(r=n.abrEwmaFastLive,a=n.abrEwmaSlowLive):(r=n.abrEwmaFastVoD,a=n.abrEwmaSlowVoD),this._bwEstimator=new ye(i,a,r,n.abrEwmaDefaultEstimate)}},h._abandonRulesCheck=function(){var e=this.hls,t=e.media,r=this.fragCurrent;if(r){var a=r.loader,i=e.minAutoLevel;if(!a||a.stats&&a.stats.aborted)return d.b.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),void(this._nextAutoLevel=-1);var n=a.stats;if(t&&n&&(!t.paused&&0!==t.playbackRate||!t.readyState)&&r.autoLevel&&r.level){var s=Ee.now()-n.trequest,o=Math.abs(t.playbackRate);if(s>500*r.duration/o){var u=e.levels,f=Math.max(1,n.bw?n.bw/8:1e3*n.loaded/s),h=u[r.level],c=h.realBitrate?Math.max(h.realBitrate,h.bitrate):h.bitrate,v=n.total?n.total:Math.max(n.loaded,Math.round(r.duration*c/8)),p=t.currentTime,g=(v-n.loaded)/f,m=(K.bufferInfo(t,p,e.config.maxBufferHole).end-p)/o;if(m<2*r.duration/o&&g>m){var y;for(y=r.level-1;y>i;y--){var b=u[y].realBitrate?Math.max(u[y].realBitrate,u[y].bitrate):u[y].bitrate;if(r.duration*b/(6.4*f)<m)break}void 0<g&&(d.b.warn("loading too slow, abort fragment loading and switch to level "+y+":fragLoadedDelay["+y+"]<fragLoadedDelay["+(r.level-1)+"];bufferStarvationDelay:"+(void 0).toFixed(1)+"<"+g.toFixed(1)+":"+m.toFixed(1)),e.nextLoadLevel=y,this._bwEstimator.sample(s,n.loaded),a.abort(),this.clearTimer(),e.trigger(l.a.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,stats:n}))}}}}},h.onFragLoaded=function(e){var t=e.frag;if("main"===t.type&&Object(o.a)(t.sn)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var r=this.hls.levels[t.level],a=(r.loaded?r.loaded.bytes:0)+e.stats.loaded,i=(r.loaded?r.loaded.duration:0)+e.frag.duration;r.loaded={bytes:a,duration:i},r.realBitrate=Math.round(8*a/i)}if(e.frag.bitrateTest){var n=e.stats;n.tparsed=n.tbuffered=n.tload,this.onFragBuffered(e)}}},h.onFragBuffered=function(e){var t=e.stats,r=e.frag;if(!0!==t.aborted&&"main"===r.type&&Object(o.a)(r.sn)&&(!r.bitrateTest||t.tload===t.tbuffered)){var a=t.tparsed-t.trequest;d.b.log("latency/loading/parsing/append/kbps:"+Math.round(t.tfirst-t.trequest)+"/"+Math.round(t.tload-t.tfirst)+"/"+Math.round(t.tparsed-t.tload)+"/"+Math.round(t.tbuffered-t.tparsed)+"/"+Math.round(8*t.loaded/(t.tbuffered-t.trequest))),this._bwEstimator.sample(a,t.loaded),t.bwEstimate=this._bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},h.onError=function(e){switch(e.details){case s.a.FRAG_LOAD_ERROR:case s.a.FRAG_LOAD_TIMEOUT:this.clearTimer()}},h.clearTimer=function(){clearInterval(this.timer),this.timer=null},h._findBestLevel=function(e,t,r,a,i,n,s,o,l){for(var u=i;u>=a;u--){var f=l[u];if(f){var h=f.details,c=h?h.totalduration/h.fragments.length:t,v=!!h&&h.live,p=void 0;p=u<=e?s*r:o*r;var g=l[u].realBitrate?Math.max(l[u].realBitrate,l[u].bitrate):l[u].bitrate,m=g*c/p;if(d.b.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+u+"/"+Math.round(p)+"/"+g+"/"+c+"/"+n+"/"+m),p>g&&(!m||v&&!this.bitrateTestDelay||m<n))return u}}return-1},i=a,(n=[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this._bwEstimator;if(!(-1===e||t&&t.canEstimate()))return e;var r=this._nextABRAutoLevel;return-1!==e&&(r=Math.min(e,r)),r},set:function(e){this._nextAutoLevel=e}},{key:"_nextABRAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,r=e.levels,a=e.config,i=e.minAutoLevel,n=e.media,s=this.lastLoadedFragLevel,o=this.fragCurrent?this.fragCurrent.duration:0,l=n?n.currentTime:0,u=n&&0!==n.playbackRate?Math.abs(n.playbackRate):1,f=this._bwEstimator?this._bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,h=(K.bufferInfo(n,l,a.maxBufferHole).end-l)/u,c=this._findBestLevel(s,o,f,i,t,h,a.abrBandWidthFactor,a.abrBandWidthUpFactor,r);if(c>=0)return c;d.b.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var v=o?Math.min(o,a.maxStarvationDelay):a.maxStarvationDelay,p=a.abrBandWidthFactor,g=a.abrBandWidthUpFactor;if(0===h){var m=this.bitrateTestDelay;if(m)v=(o?Math.min(o,a.maxLoadingDelay):a.maxLoadingDelay)-m,d.b.trace("bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*v)+" ms"),p=g=1}return c=this._findBestLevel(s,o,f,i,t,h+v,p,g,r),Math.max(c,0)}}])&&be(i.prototype,n),u&&be(i,u),a}(f);var Se=Y(),Ae=function(e){var t,r;function a(t){var r;return(r=e.call(this,t,l.a.MEDIA_ATTACHING,l.a.MEDIA_DETACHING,l.a.MANIFEST_PARSED,l.a.BUFFER_RESET,l.a.BUFFER_APPENDING,l.a.BUFFER_CODECS,l.a.BUFFER_EOS,l.a.BUFFER_FLUSHING,l.a.LEVEL_PTS_UPDATED,l.a.LEVEL_UPDATED)||this)._msDuration=null,r._levelDuration=null,r._levelTargetDuration=10,r._live=null,r._objectUrl=null,r._needsFlush=!1,r._needsEos=!1,r.config=void 0,r.audioTimestampOffset=void 0,r.bufferCodecEventsExpected=0,r._bufferCodecEventsTotal=0,r.media=null,r.mediaSource=null,r.segments=[],r.parent=void 0,r.appending=!1,r.appended=0,r.appendError=0,r.flushBufferCounter=0,r.tracks={},r.pendingTracks={},r.sourceBuffer={},r.flushRange=[],r._onMediaSourceOpen=function(){d.b.log("media source opened"),r.hls.trigger(l.a.MEDIA_ATTACHED,{media:r.media});var e=r.mediaSource;e&&e.removeEventListener("sourceopen",r._onMediaSourceOpen),r.checkPendingTracks()},r._onMediaSourceClose=function(){d.b.log("media source closed")},r._onMediaSourceEnded=function(){d.b.log("media source ended")},r._onSBUpdateEnd=function(){if(r.audioTimestampOffset&&r.sourceBuffer.audio){var e=r.sourceBuffer.audio;d.b.warn("change mpeg audio timestamp offset from "+e.timestampOffset+" to "+r.audioTimestampOffset),e.timestampOffset=r.audioTimestampOffset,delete r.audioTimestampOffset}r._needsFlush&&r.doFlush(),r._needsEos&&r.checkEos(),r.appending=!1;var t=r.parent,a=r.segments.reduce(function(e,r){return r.parent===t?e+1:e},0),i={},n=r.sourceBuffer;for(var s in n){var o=n[s];if(!o)throw Error("handling source buffer update end error: source buffer for "+s+" uninitilized and unable to update buffered TimeRanges.");i[s]=o.buffered}r.hls.trigger(l.a.BUFFER_APPENDED,{parent:t,pending:a,timeRanges:i}),r._needsFlush||r.doAppending(),r.updateMediaElementDuration(),0===a&&r.flushLiveBackBuffer()},r._onSBUpdateError=function(e){d.b.error("sourceBuffer error:",e),r.hls.trigger(l.a.ERROR,{type:s.b.MEDIA_ERROR,details:s.a.BUFFER_APPENDING_ERROR,fatal:!1})},r.config=t.config,r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var i=a.prototype;return i.destroy=function(){f.prototype.destroy.call(this)},i.onLevelPtsUpdated=function(e){var t=e.type,r=this.tracks.audio;if("audio"===t&&r&&"audio/mpeg"===r.container){var a=this.sourceBuffer.audio;if(!a)throw Error("Level PTS Updated and source buffer for audio uninitalized");if(Math.abs(a.timestampOffset-e.start)>.1){var i=a.updating;try{a.abort()}catch(e){d.b.warn("can not abort audio buffer: "+e)}i?this.audioTimestampOffset=e.start:(d.b.warn("change mpeg audio timestamp offset from "+a.timestampOffset+" to "+e.start),a.timestampOffset=e.start)}}},i.onManifestParsed=function(e){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=e.altAudio?2:1,d.b.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},i.onMediaAttaching=function(e){var t=this.media=e.media;if(t&&Se){var r=this.mediaSource=new Se;r.addEventListener("sourceopen",this._onMediaSourceOpen),r.addEventListener("sourceended",this._onMediaSourceEnded),r.addEventListener("sourceclose",this._onMediaSourceClose),t.src=window.URL.createObjectURL(r),this._objectUrl=t.src}},i.onMediaDetaching=function(){d.b.log("media source detaching");var e=this.mediaSource;if(e){if("open"===e.readyState)try{e.endOfStream()}catch(e){d.b.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.b.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(l.a.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=this.sourceBuffer;for(var t in e){var r=e[t];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(e){var t=this;Object.keys(this.sourceBuffer).length||(Object.keys(e).forEach(function(r){t.pendingTracks[r]=e[r]}),this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},i.createSourceBuffers=function(e){var t=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(var a in e)if(!t[a]){var i=e[a];if(!i)throw Error("source buffer exists for track "+a+", however track does not");var n=i.levelCodec||i.codec,o=i.container+";codecs="+n;d.b.log("creating sourceBuffer("+o+")");try{var u=t[a]=r.addSourceBuffer(o);u.addEventListener("updateend",this._onSBUpdateEnd),u.addEventListener("error",this._onSBUpdateError),this.tracks[a]={buffer:u,codec:n,id:i.id,container:i.container,levelCodec:i.levelCodec}}catch(e){d.b.error("error while trying to add sourceBuffer:"+e.message),this.hls.trigger(l.a.ERROR,{type:s.b.MEDIA_ERROR,details:s.a.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:e,mimeType:o})}}this.hls.trigger(l.a.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)if(!e.type||e.type===t){var r=this.sourceBuffer[t];r&&!r.ended&&(r.ended=!0,d.b.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){var a=e[r];if(a){if(!a.ended)return;if(a.updating)return void(this._needsEos=!0)}}d.b.log("all media data are available, signal endOfStream() to MediaSource and stop loading fragment");try{t.endOfStream()}catch(e){d.b.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,a=Object.keys(r),i=t-Math.max(e,this._levelTargetDuration),n=a.length-1;n>=0;n--){var s=a[n],o=r[s];if(o){var u=o.buffered;u.length>0&&i>u.start(0)&&this.removeBufferRange(s,o,0,i)&&this.hls.trigger(l.a.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i})}}else d.b.error("flushLiveBackBuffer called without attaching media")}},i.onLevelUpdated=function(e){var t=e.details;t.fragments.length>0&&(this._levelDuration=t.totalduration+t.fragments[0].start,this._levelTargetDuration=t.averagetargetduration||t.targetduration||10,this._live=t.live,this.updateMediaElementDuration())},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){var a=this.sourceBuffer[r];if(a&&!0===a.updating)return}e=this.media.duration,null===this._msDuration&&(this._msDuration=this.mediaSource.duration),!0===this._live&&!0===t.liveDurationInfinity?(d.b.log("Media Source duration is set to Infinity"),this._msDuration=this.mediaSource.duration=1/0):(this._levelDuration>this._msDuration&&this._levelDuration>e||!Object(o.a)(e))&&(d.b.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 a in r){var i=r[a];i&&(t+=i.buffered.length)}}catch(e){d.b.error("error while accessing sourceBuffer.buffered")}this.appended=t,this.hls.trigger(l.a.BUFFER_FLUSHED)}},i.doAppending=function(){var e=this.config,t=this.hls,r=this.segments,a=this.sourceBuffer;if(Object.keys(a).length){if(!this.media||this.media.error)return this.segments=[],void d.b.error("trying to append although a media error occured, flush segment and abort");if(!this.appending){var i=r.shift();if(i)try{var n=a[i.type];if(!n)return void this._onSBUpdateEnd();if(n.updating)return void r.unshift(i);n.ended=!1,this.parent=i.parent,n.appendBuffer(i.data),this.appendError=0,this.appended++,this.appending=!0}catch(a){d.b.error("error while trying to append buffer:"+a.message),r.unshift(i);var o={type:s.b.MEDIA_ERROR,parent:i.parent,details:"",fatal:!1};22===a.code?(this.segments=[],o.details=s.a.BUFFER_FULL_ERROR):(this.appendError++,o.details=s.a.BUFFER_APPEND_ERROR,this.appendError>e.appendErrorMaxRetry&&(d.b.log("fail "+e.appendErrorMaxRetry+" times to append segment in sourceBuffer"),this.segments=[],o.fatal=!0)),t.trigger(l.a.ERROR,o)}}}},i.flushBuffer=function(e,t,r){var a=this.sourceBuffer;if(!Object.keys(a).length)return!0;var i="null";if(this.media&&(i=this.media.currentTime.toFixed(3)),d.b.log("flushBuffer,pos/start/end: "+i+"/"+e+"/"+t),this.flushBufferCounter>=this.appended)return d.b.warn("abort flushing too many retries"),!0;var n=a[r];if(n){if(n.ended=!1,n.updating)return d.b.warn("cannot flush, sb updating in progress"),!1;if(this.removeBufferRange(r,n,e,t))return this.flushBufferCounter++,!1}return d.b.log("buffer flushed"),!0},i.removeBufferRange=function(e,t,r,a){try{for(var i=0;i<t.buffered.length;i++){var n=t.buffered.start(i),s=t.buffered.end(i),o=Math.max(n,r),l=Math.min(s,a);if(Math.min(l,s)-o>.5){var u="null";return this.media&&(u=this.media.currentTime.toString()),d.b.log("sb remove "+e+" ["+o+","+l+"], of ["+n+","+s+"], pos:"+u),t.remove(o,l),!0}}}catch(e){d.b.warn("removeBufferRange failed",e)}return!1},a}(f);function _e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}var Re=function(e){var t,r;function a(t){var r;return(r=e.call(this,t,l.a.FPS_DROP_LEVEL_CAPPING,l.a.MEDIA_ATTACHING,l.a.MANIFEST_PARSED,l.a.BUFFER_CODECS,l.a.MEDIA_DETACHING)||this).autoLevelCapping=Number.POSITIVE_INFINITY,r.firstLevel=null,r.levels=[],r.media=null,r.restrictedLevels=[],r.timer=null,r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var i,n,s,o=a.prototype;return o.destroy=function(){this.hls.config.capLevelToPlayerSize&&(this.media=null,this.stopCapping())},o.onFpsDropLevelCapping=function(e){a.isLevelAllowed(e.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(e.droppedLevel)},o.onMediaAttaching=function(e){this.media=e.media instanceof window.HTMLVideoElement?e.media:null},o.onManifestParsed=function(e){var t=this.hls;this.restrictedLevels=[],this.levels=e.levels,this.firstLevel=e.firstLevel,t.config.capLevelToPlayerSize&&e.video&&this.startCapping()},o.onBufferCodecs=function(e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()},o.onLevelsUpdated=function(e){this.levels=e.levels},o.onMediaDetaching=function(){this.stopCapping()},o.detectPlayerSize=function(){if(this.media){var e=this.levels?this.levels.length:0;if(e){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e-1),t.autoLevelCapping>this.autoLevelCapping&&t.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},o.getMaxLevel=function(e){var t=this;if(!this.levels)return-1;var r=this.levels.filter(function(r,i){return a.isLevelAllowed(i,t.restrictedLevels)&&i<=e});return a.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)},o.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())},o.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 void 0===t&&(t=[]),-1===t.indexOf(e)},a.getMaxLevelByMediaSize=function(e,t,r){if(!e||e&&!e.length)return-1;for(var a,i,n=e.length-1,s=0;s<e.length;s+=1){var o=e[s];if((o.width>=t||o.height>=r)&&(a=o,!(i=e[s+1])||a.width!==i.width||a.height!==i.height)){n=s;break}}return n},i=a,s=[{key:"contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(e){}return e}}],(n=[{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}}])&&_e(i.prototype,n),s&&_e(i,s),a}(f);var Le,De=window.performance,we=function(e){var t,r;function a(t){return e.call(this,t,l.a.MEDIA_ATTACHING)||this}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var i=a.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 a=De.now();if(t){if(this.lastTime){var i=a-this.lastTime,n=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,o=1e3*n/i,u=this.hls;if(u.trigger(l.a.FPS_DROP,{currentDropped:n,currentDecoded:s,totalDroppedFrames:r}),o>0&&n>u.config.fpsDroppedMonitoringThreshold*s){var f=u.currentLevel;d.b.warn("drop FPS ratio greater than max allowed value for currentLevel: "+f),f>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=f)&&(f-=1,u.trigger(l.a.FPS_DROP_LEVEL_CAPPING,{level:f,droppedLevel:u.currentLevel}),u.autoLevelCapping=f,u.streamController.nextLevelSwitch())}}this.lastTime=a,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},i.checkFPSInterval=function(){var e=this.video;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},a}(f),Ie=window,ke=Ie.performance,Oe=Ie.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:ke.now(),retry:0},this.retryDelay=t.retryDelay,this.loadInternal()},t.loadInternal=function(){var e,t=this.context;e=this.loader=new Oe;var r=this.stats;r.tfirst=0,r.loaded=0;var a=this.xhrSetup;try{if(a)try{a(e,t.url)}catch(r){e.open("GET",t.url,!0),a(e,t.url)}e.readyState||e.open("GET",t.url,!0)}catch(r){return void this.callbacks.onError({code:e.status,text:r.message},t,e)}t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),e.send()},t.readystatechange=function(e){var t=e.currentTarget,r=t.readyState,a=this.stats,i=this.context,n=this.config;if(!a.aborted&&r>=2)if(window.clearTimeout(this.requestTimeout),0===a.tfirst&&(a.tfirst=Math.max(ke.now(),a.trequest)),4===r){var s=t.status;if(s>=200&&s<300){var o,l;a.tload=Math.max(a.tfirst,ke.now()),l="arraybuffer"===i.responseType?(o=t.response).byteLength:(o=t.responseText).length,a.loaded=a.total=l;var u={url:t.responseURL,data:o};this.callbacks.onSuccess(u,a,i,t)}else a.retry>=n.maxRetry||s>=400&&s<499?(d.b.error(s+" while loading "+i.url),this.callbacks.onError({code:s,text:t.statusText},i,t)):(d.b.warn(s+" while loading "+i.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,n.maxRetryDelay),a.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),n.timeout)},t.loadtimeout=function(){d.b.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;r.loaded=e.loaded,e.lengthComputable&&(r.total=e.total);var a=this.callbacks.onProgress;a&&a(r,this.context,null,t)},e}();r(6);function Pe(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}!function(e){e.WIDEVINE="com.widevine.alpha",e.PLAYREADY="com.microsoft.playready"}(Le||(Le={}));var Ce=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},a=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),a.forEach(function(t){Pe(e,t,r[t])})}return e}({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:Te,bufferController:Ae,capLevelController:Re,fpsController:we,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:"undefined"!=typeof window&&window.navigator&&window.navigator.requestMediaKeySystemAccess?window.navigator.requestMediaKeySystemAccess.bind(window.navigator):null},{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0});function Fe(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Me(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ue(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Ne(e,t,r){return t&&Ue(e.prototype,t),r&&Ue(e,r),e}r.d(t,"default",function(){return Be});var Be=function(e){var t,r;function a(t){var r;void 0===t&&(t={}),(r=e.call(this)||this).config=void 0,r._autoLevelCapping=void 0,r.abrController=void 0,r.capLevelController=void 0,r.levelController=void 0,r.streamController=void 0,r.networkControllers=void 0,r.audioTrackController=void 0,r.subtitleTrackController=void 0,r.emeController=void 0,r.coreComponents=void 0,r.media=null,r.url=null;var i=a.DefaultConfig;if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");r.config=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},a=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),a.forEach(function(t){Fe(e,t,r[t])})}return e}({},i,t);var n=Me(r).config;if(void 0!==n.liveMaxLatencyDurationCount&&n.liveMaxLatencyDurationCount<=n.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');if(void 0!==n.liveMaxLatencyDuration&&(void 0===n.liveSyncDuration||n.liveMaxLatencyDuration<=n.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be gt "liveSyncDuration"');Object(d.a)(n.debug),r._autoLevelCapping=-1;var s=r.abrController=new n.abrController(Me(r)),o=new n.bufferController(Me(r)),l=r.capLevelController=new n.capLevelController(Me(r)),u=new n.fpsController(Me(r)),f=new P(Me(r)),h=new C(Me(r)),c=new F(Me(r)),v=new ge(Me(r)),p=r.levelController=new ce(Me(r)),g=new G(Me(r)),m=[p,r.streamController=new ue(Me(r),g)],y=n.audioStreamController;y&&m.push(new y(Me(r),g)),r.networkControllers=m;var b=[f,h,c,s,o,l,u,v,g];if(y=n.audioTrackController){var E=new y(Me(r));r.audioTrackController=E,b.push(E)}if(y=n.subtitleTrackController){var T=new y(Me(r));r.subtitleTrackController=T,m.push(T)}if(y=n.emeController){var S=new y(Me(r));r.emeController=S,b.push(S)}return(y=n.subtitleStreamController)&&m.push(new y(Me(r),g)),(y=n.timelineController)&&b.push(new y(Me(r))),r.coreComponents=b,r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r,a.isSupported=function(){return function(){var e=Y();if(!e)return!1;var t=SourceBuffer||window.WebKitSourceBuffer,r=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),a=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove;return!!r&&!!a}()},Ne(a,null,[{key:"version",get:function(){return"0.13.0"}},{key:"Events",get:function(){return l.a}},{key:"ErrorTypes",get:function(){return s.b}},{key:"ErrorDetails",get:function(){return s.a}},{key:"DefaultConfig",get:function(){return a.defaultConfig?a.defaultConfig:Ce},set:function(e){a.defaultConfig=e}}]);var i=a.prototype;return i.destroy=function(){d.b.log("destroy"),this.trigger(l.a.DESTROYING),this.detachMedia(),this.coreComponents.concat(this.networkControllers).forEach(function(e){e.destroy()}),this.url=null,this.removeAllListeners(),this._autoLevelCapping=-1},i.attachMedia=function(e){d.b.log("attachMedia"),this.media=e,this.trigger(l.a.MEDIA_ATTACHING,{media:e})},i.detachMedia=function(){d.b.log("detachMedia"),this.trigger(l.a.MEDIA_DETACHING),this.media=null},i.loadSource=function(e){e=n.buildAbsoluteURL(window.location.href,e,{alwaysNormalize:!0}),d.b.log("loadSource:"+e),this.url=e,this.trigger(l.a.MANIFEST_LOADING,{url:e})},i.startLoad=function(e){void 0===e&&(e=-1),d.b.log("startLoad("+e+")"),this.networkControllers.forEach(function(t){t.startLoad(e)})},i.stopLoad=function(){d.b.log("stopLoad"),this.networkControllers.forEach(function(e){e.stopLoad()})},i.swapAudioCodec=function(){d.b.log("swapAudioCodec"),this.streamController.swapAudioCodec()},i.recoverMediaError=function(){d.b.log("recoverMediaError");var e=this.media;this.detachMedia(),e&&this.attachMedia(e)},Ne(a,[{key:"levels",get:function(){return this.levelController.levels}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){d.b.log("set currentLevel:"+e),this.loadLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){d.b.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){d.b.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.b.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){d.b.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){d.b.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,a=0;a<r;a++){if((e[a].realBitrate?Math.max(e[a].realBitrate,e[a].bitrate):e[a].bitrate)>t)return a}return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping;return-1===t&&e&&e.length?e.length-1:t}},{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)}}]),a}(X);Be.defaultConfig=void 0}]).default});
//# sourceMappingURL=hls.light.min.js.map