@mux/mux-video 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,33 +1,33 @@
1
- var xn=Object.create;var Mr=Object.defineProperty;var Sn=Object.getOwnPropertyDescriptor;var Dn=Object.getOwnPropertyNames;var An=Object.getPrototypeOf,Ln=Object.prototype.hasOwnProperty;var _n=(K,b,n)=>b in K?Mr(K,b,{enumerable:!0,configurable:!0,writable:!0,value:n}):K[b]=n;var li=(K,b)=>()=>(b||K((b={exports:{}}).exports,b),b.exports);var bn=(K,b,n,P)=>{if(b&&typeof b=="object"||typeof b=="function")for(let L of Dn(b))!Ln.call(K,L)&&L!==n&&Mr(K,L,{get:()=>b[L],enumerable:!(P=Sn(b,L))||P.enumerable});return K};var hr=(K,b,n)=>(n=K!=null?xn(An(K)):{},bn(b||!K||!K.__esModule?Mr(n,"default",{value:K,enumerable:!0}):n,K));var Yt=(K,b,n)=>(_n(K,typeof b!="symbol"?b+"":b,n),n),wr=(K,b,n)=>{if(!b.has(K))throw TypeError("Cannot "+n)};var se=(K,b,n)=>(wr(K,b,"read from private field"),n?n.call(K):b.get(K)),ye=(K,b,n)=>{if(b.has(K))throw TypeError("Cannot add the same private member more than once");b instanceof WeakSet?b.add(K):b.set(K,n)},be=(K,b,n,P)=>(wr(K,b,"write to private field"),P?P.call(K,n):b.set(K,n),n);var Ce=(K,b,n)=>(wr(K,b,"access private method"),n);var fi=li((vr,Ur)=>{(function(){var K,b;K=this,b=function(){return function(){var n={80:function(A,M,R){A.exports=R(728).default},728:function(A,M,R){"use strict";R.d(M,{default:function(){return Tn}});var O=R(48),_=R.n(O),y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(F){var C=16*Math.random()|0;return(F==="x"?C:3&C|8).toString(16)})},T=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},D=function(F){return F&&F.nodeName!==void 0?(F.muxId||(F.muxId=F.id||T()),F.muxId):F},E=function(F){var C;F&&F.nodeName!==void 0?F=D(C=F):C=document.querySelector(F);var w=C&&C.nodeName?C.nodeName.toLowerCase():"";return[C,F,w]},m=R(640),p=R.n(m),d=p().methodFactory;p().methodFactory=function(F,C,w){var N=d(F,C,w);return function(){for(var j=["[mux]"],V=0;V<arguments.length;V++)j.push(arguments[V]);N.apply(void 0,j)}},p().setLevel(p().getLevel());var e=p();function o(){return(_().doNotTrack||_().navigator&&_().navigator.doNotTrack)==="1"}var h={now:function(){var F=_().performance,C=F&&F.timing,w=F&&F.timeOrigin||C&&C.navigationStart;return typeof w=="number"&&typeof F.now=="function"?w+F.now():Date.now()}},g=R(678),i=R.n(g),r=function(F){return l(F)[0]},l=function(F){if(typeof F!="string"||F==="")return["localhost"];var C,w=(F.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return w&&(C=(w.match(/[^\.]+\.[^\.]+$/)||[])[0]),[w,C]},c={exists:function(){var F=_().performance;return(F&&F.timing)!==void 0},domContentLoadedEventEnd:function(){var F=_().performance,C=F&&F.timing;return C&&C.domContentLoadedEventEnd},navigationStart:function(){var F=_().performance,C=F&&F.timing;return C&&C.navigationStart}};function t(F,C,w){w=w===void 0?1:w,F[C]=F[C]||0,F[C]+=w}var a=["x-cdn","content-type","x-request-id"];function u(F){var C={};return(F=F||"").trim().split(/[\r\n]+/).forEach(function(w){if(w){var N=w.split(": "),j=N.shift();j&&(a.indexOf(j.toLowerCase())>=0||j.toLowerCase().indexOf("x-litix-")===0)&&(C[j]=N.join(": "))}}),C}var s=function(F){var C={};for(var w in F){var N=F[w];N["DATA-ID"].search("io.litix.data.")!==-1&&(C[N["DATA-ID"].replace("io.litix.data.","")]=N.VALUE)}return C};function f(F,C){var w=Object.keys(F);if(Object.getOwnPropertySymbols){var N=Object.getOwnPropertySymbols(F);C&&(N=N.filter(function(j){return Object.getOwnPropertyDescriptor(F,j).enumerable})),w.push.apply(w,N)}return w}function v(F){for(var C=1;C<arguments.length;C++){var w=arguments[C]!=null?arguments[C]:{};C%2?f(Object(w),!0).forEach(function(N){S(F,N,w[N])}):Object.getOwnPropertyDescriptors?Object.defineProperties(F,Object.getOwnPropertyDescriptors(w)):f(Object(w)).forEach(function(N){Object.defineProperty(F,N,Object.getOwnPropertyDescriptor(w,N))})}return F}function S(F,C,w){return C in F?Object.defineProperty(F,C,{value:w,enumerable:!0,configurable:!0,writable:!0}):F[C]=w,F}var x=function(F){if(!F)return{};var C=c.navigationStart(),w=F.loading,N=w?w.start:F.trequest,j=w?w.first:F.tfirst,V=w?w.end:F.tload;return{bytesLoaded:F.total,requestStart:Math.round(C+N),responseStart:Math.round(C+j),responseEnd:Math.round(C+V)}},I=function(F){if(F&&typeof F.getAllResponseHeaders=="function")return u(F.getAllResponseHeaders())},B=function(F,C){if(!F||typeof F.getRequests!="function")return{};var w=F.getRequests({state:"executed"});if(w.length===0)return{};var N,j=w[w.length-1],V=r(j.url),H=j.bytesLoaded,$=new Date(j.requestStartDate).getTime(),Z=new Date(j.firstByteDate).getTime(),Q=new Date(j.requestEndDate).getTime(),ne=isNaN(j.duration)?0:j.duration,pe=typeof C.getMetricsFor=="function"?C.getMetricsFor(j.mediaType).HttpList:C.getDashMetrics().getHttpRequests(j.mediaType);return pe.length>0&&(N=u(pe[pe.length-1]._responseHeaders||"")),{requestStart:$,requestResponseStart:Z,requestResponseEnd:Q,requestBytesLoaded:H,requestResponseHeaders:N,requestMediaDuration:ne,requestHostname:V}},k=function(F,C){var w=C.getQualityFor(F),N=C.getCurrentTrackFor(F).bitrateList;return N?{currentLevel:w,renditionWidth:N[w].width||null,renditionHeight:N[w].height||null,renditionBitrate:N[w].bandwidth}:{}};function U(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var W=0,G=function(){function F(){(function(j,V){if(!(j instanceof V))throw new TypeError("Cannot call a class as a function")})(this,F)}var C,w,N;return C=F,w=[{key:"on",value:function(j,V,H){return V._eventEmitterGuid=V._eventEmitterGuid||++W,this._listeners=this._listeners||{},this._listeners[j]=this._listeners[j]||[],H&&(V=V.bind(H)),this._listeners[j].push(V),V}},{key:"off",value:function(j,V){var H=this._listeners&&this._listeners[j];H&&H.forEach(function($,Z){$._eventEmitterGuid===V._eventEmitterGuid&&H.splice(Z,1)})}},{key:"one",value:function(j,V,H){var $=this;V._eventEmitterGuid=V._eventEmitterGuid||++W;var Z=function Q(){$.off(j,Q),V.apply(H||this,arguments)};Z._eventEmitterGuid=V._eventEmitterGuid,this.on(j,Z)}},{key:"emit",value:function(j,V){var H=this;if(this._listeners){V=V||{};var $=this._listeners["before*"]||[],Z=this._listeners[j]||[],Q=this._listeners["after"+j]||[],ne=function(pe,Ae){(pe=pe.slice()).forEach(function(Te){Te.call(H,{type:j},Ae)})};ne($,V),ne(Z,V),ne(Q,V)}}}],w&&U(C.prototype,w),N&&U(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}(),X=G;function Y(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var J=function(){function F(j){var V=this;(function(H,$){if(!(H instanceof $))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=j,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,j.on("playing",function(){V._playheadShouldBeProgressing=!0}),j.on("play",this._startPlaybackHeartbeatInterval.bind(this)),j.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),j.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),j.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),j.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),j.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),j.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),j.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),j.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),j.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("seeked",function(){j.data.player_is_paused?V._stopPlaybackHeartbeatInterval():V._startPlaybackHeartbeatInterval()}),j.on("timeupdate",function(){V._playbackHeartbeatInterval!==null&&j.emit("playbackheartbeat")}),j.on("devicesleep",function(H,$){V._playbackHeartbeatInterval!==null&&(_().clearInterval(V._playbackHeartbeatInterval),j.emit("playbackheartbeatend",{viewer_time:$.viewer_time}),V._playbackHeartbeatInterval=null)})}var C,w,N;return C=F,(w=[{key:"_startPlaybackHeartbeatInterval",value:function(){var j=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=_().setInterval(function(){j.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(_().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Y(C.prototype,w),N&&Y(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function ee(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function z(F,C,w){return C&&ee(F.prototype,C),w&&ee(F,w),Object.defineProperty(F,"prototype",{writable:!1}),F}var q=z(function F(C){var w=this;(function(N,j){if(!(N instanceof j))throw new TypeError("Cannot call a class as a function")})(this,F),C.on("viewinit",function(){w.viewErrored=!1}),C.on("error",function(){try{var N=C.errorTranslator({player_error_code:C.data.player_error_code,player_error_message:C.data.player_error_message});N?(C.data.player_error_code=N.player_error_code,C.data.player_error_message=N.player_error_message,w.viewErrored=!0):(delete C.data.player_error_code,delete C.data.player_error_message)}catch(j){C.mux.log.warn("Exception in error translator callback.",j),w.viewErrored=!0}})});function ie(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var ae=function(){function F(j){(function(V,H){if(!(V instanceof H))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=j,this._watchTimeTrackerLastCheckedTime=null,j.on("playbackheartbeat",this._updateWatchTime.bind(this)),j.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var C,w,N;return C=F,(w=[{key:"_updateWatchTime",value:function(j,V){var H=V.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=H),t(this.pm.data,"view_watch_time",H-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=H}},{key:"_clearWatchTimeState",value:function(j,V){this._updateWatchTime(j,V),this._watchTimeTrackerLastCheckedTime=null}}])&&ie(C.prototype,w),N&&ie(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function te(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var oe=function(){function F(j){(function(V,H){if(!(V instanceof H))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=j,this._playbackTimeTrackerLastPlayheadPosition=-1,j.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),j.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),j.on("seeking",this._clearPlaybackTimeState.bind(this))}var C,w,N;return C=F,(w=[{key:"_updatePlaybackTime",value:function(){var j=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&j>this._playbackTimeTrackerLastPlayheadPosition){var V=j-this._playbackTimeTrackerLastPlayheadPosition;V<=1e3&&t(this.pm.data,"view_content_playback_time",V)}this._playbackTimeTrackerLastPlayheadPosition=j}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&te(C.prototype,w),N&&te(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function ue(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var re=function(){function F(j){(function(H,$){if(!(H instanceof $))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=j;var V=this._updatePlayheadTime.bind(this);j.on("playbackheartbeat",V),j.on("playbackheartbeatend",V),j.on("timeupdate",V),j.on("destroy",function(){j.off("timeupdate",V)})}var C,w,N;return C=F,(w=[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=this.pm.data.view_max_playhead_position===void 0?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(j,V){var H=this,$=function(){H.pm.currentFragmentPDT&&H.pm.currentFragmentStart&&(H.pm.data.player_program_time=H.pm.currentFragmentPDT+H.pm.data.player_playhead_time-H.pm.currentFragmentStart)};if(V&&V.player_playhead_time)this.pm.data.player_playhead_time=V.player_playhead_time,$(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var Z=this.pm.getPlayheadTime();Z!==void 0&&(this.pm.data.player_playhead_time=Z,$(),this._updateMaxPlayheadPosition())}}}])&&ue(C.prototype,w),N&&ue(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function he(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function ge(F,C,w){return C&&he(F.prototype,C),w&&he(F,w),Object.defineProperty(F,"prototype",{writable:!1}),F}var Se=ge(function F(C){if(function(j,V){if(!(j instanceof V))throw new TypeError("Cannot call a class as a function")}(this,F),!C.disableRebufferTracking){var w,N=function(){if(w){var j=C.data.viewer_time-w;t(C.data,"view_rebuffer_duration",j),w=C.data.viewer_time}C.data.view_watch_time>=0&&C.data.view_rebuffer_count>0&&(C.data.view_rebuffer_frequency=C.data.view_rebuffer_count/C.data.view_watch_time,C.data.view_rebuffer_percentage=C.data.view_rebuffer_duration/C.data.view_watch_time)};C.on("playbackheartbeat",function(){return N()}),C.on("rebufferstart",function(){w||(t(C.data,"view_rebuffer_count",1),w=C.data.viewer_time,C.one("rebufferend",function(){N(),w=void 0}))})}});function Me(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var Oe=function(){function F(j){var V=this;(function(H,$){if(!(H instanceof $))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=j,j.disableRebufferTracking||j.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,j.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),j.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),j.on("seeking",function(){V._cleanupRebufferTracker(null,{viewer_time:h.now()})}))}var C,w,N;return C=F,w=[{key:"_checkIfRebuffering",value:function(j,V){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(j,V);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var H=V.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&H>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=V.viewer_time}else this._cleanupRebufferTracker(j,V,!0);else this._prepareRebufferTrackerState(V.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(j){this._lastCheckedTime=j,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=j}},{key:"_cleanupRebufferTracker",value:function(j,V){var H=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:V.viewer_time});else{if(this._lastCheckedTime===null)return;var $=this.pm.data.player_playhead_time-this._lastPlayheadTime,Z=V.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&$>0&&Z-$>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+Z-$}))}H?this._prepareRebufferTrackerState(V.viewer_time):this._clearRebufferTrackerState()}}],w&&Me(C.prototype,w),N&&Me(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}(),Ne=Oe;function Ie(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var Ke=function(){function F(j){var V=this;(function(H,$){if(!(H instanceof $))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=j,j.on("viewinit",function(){var H=j.data,$=H.view_id;if(!H.view_program_changed){var Z=function(Q,ne){var pe=ne.viewer_time;Q.type==="playing"&&j.data.view_time_to_first_frame===void 0?V.calculateTimeToFirstFrame(pe||h.now(),$):Q.type!=="adplaying"||j.data.view_time_to_first_frame!==void 0&&!V._inPrerollPosition()||V.calculateTimeToFirstFrame(pe||h.now(),$)};j.one("playing",Z),j.one("adplaying",Z),j.one("viewend",function(){j.off("playing",Z),j.off("adplaying",Z)})}})}var C,w,N;return C=F,(w=[{key:"_inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(j,V){V===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:j}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}])&&Ie(C.prototype,w),N&&Ie(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function me(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function ke(F,C,w){return C&&me(F.prototype,C),w&&me(F,w),Object.defineProperty(F,"prototype",{writable:!1}),F}var je=ke(function F(C){var w=this;(function(N,j){if(!(N instanceof j))throw new TypeError("Cannot call a class as a function")})(this,F),C.on("viewinit",function(){w._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(N){C.on(N,function(){if(w._lastPlayheadPosition>=0&&C.data.player_playhead_time>=0&&w._lastPlayerWidth>=0&&w._lastSourceWidth>0&&w._lastPlayerHeight>=0&&w._lastSourceHeight>0){var j=C.data.player_playhead_time-w._lastPlayheadPosition;if(j<0)return void(w._lastPlayheadPosition=-1);var V=Math.min(w._lastPlayerWidth/w._lastSourceWidth,w._lastPlayerHeight/w._lastSourceHeight),H=Math.max(0,V-1),$=Math.max(0,1-V);C.data.view_max_upscale_percentage=Math.max(C.data.view_max_upscale_percentage||0,H),C.data.view_max_downscale_percentage=Math.max(C.data.view_max_downscale_percentage||0,$),t(C.data,"view_total_content_playback_time",j),t(C.data,"view_total_upscaling",H*j),t(C.data,"view_total_downscaling",$*j)}w._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(N){C.on(N,function(){w._lastPlayheadPosition=C.data.player_playhead_time,w._lastPlayerWidth=C.data.player_width,w._lastPlayerHeight=C.data.player_height,w._lastSourceWidth=C.data.video_source_width,w._lastSourceHeight=C.data.video_source_height})})});function He(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function We(F,C,w){return C&&He(F.prototype,C),w&&He(F,w),Object.defineProperty(F,"prototype",{writable:!1}),F}var Ye=We(function F(C){var w=this;(function(N,j){if(!(N instanceof j))throw new TypeError("Cannot call a class as a function")})(this,F),this.isSeeking=!1,C.on("seeking",function(N,j){i()(C.data,j),w._lastSeekingTime=h.now(),w.isSeeking===!1&&(w.isSeeking=!0,C.send("seeking"))}),C.on("seeked",function(){w.isSeeking=!1;var N=w._lastSeekingTime||h.now(),j=h.now()-N;t(C.data,"view_seek_count",1),t(C.data,"view_seek_duration",j);var V=C.data.view_max_seek_time||0;C.data.view_max_seek_time=Math.max(V,j)}),C.on("viewend",function(){w.isSeeking=!1})});function Ge(F,C){return function(w){if(Array.isArray(w))return w}(F)||function(w,N){var j=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(j!=null){var V,H,$=[],Z=!0,Q=!1;try{for(j=j.call(w);!(Z=(V=j.next()).done)&&($.push(V.value),!N||$.length!==N);Z=!0);}catch(ne){Q=!0,H=ne}finally{try{Z||j.return==null||j.return()}finally{if(Q)throw H}}return $}}(F,C)||function(w,N){if(w){if(typeof w=="string")return nt(w,N);var j=Object.prototype.toString.call(w).slice(8,-1);return j==="Object"&&w.constructor&&(j=w.constructor.name),j==="Map"||j==="Set"?Array.from(w):j==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(j)?nt(w,N):void 0}}(F,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function nt(F,C){(C==null||C>F.length)&&(C=F.length);for(var w=0,N=new Array(C);w<C;w++)N[w]=F[w];return N}function we(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var Be=function(F,C){F.push(C),F.sort(function(w,N){return w.viewer_time-N.viewer_time})},$e=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Ue=function(){function F(j){var V=this;(function($,Z){if(!($ instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=j,j.on("viewinit",function(){V.isAdBreak=!1,V._currentAdRequestNumber=0,V._currentAdResponseNumber=0,V._adRequests=[],V._adResponses=[],V._adHasPlayed=!1,V._wouldBeNewAdPlay=!0,V._prerollPlayTime=void 0}),$e.forEach(function($){return j.on($,V._updateAdData.bind(V))});var H=function(){V.isAdBreak=!1};j.on("adbreakstart",function(){V.isAdBreak=!0}),j.on("play",H),j.on("playing",H),j.on("viewend",H),j.on("adrequest",function($,Z){Z=i()({ad_request_id:"generatedAdRequestId"+V._currentAdRequestNumber++},Z),Be(V._adRequests,Z),t(j.data,"view_ad_request_count"),V.inPrerollPosition()&&(j.data.view_preroll_requested=!0,V._adHasPlayed||t(j.data,"view_preroll_request_count"))}),j.on("adresponse",function($,Z){Z=i()({ad_request_id:"generatedAdRequestId"+V._currentAdResponseNumber++},Z),Be(V._adResponses,Z);var Q=V.findAdRequest(Z.ad_request_id);Q&&t(j.data,"view_ad_request_time",Math.max(0,Z.viewer_time-Q.viewer_time))}),j.on("adplay",function($,Z){V._adHasPlayed=!0,V._wouldBeNewAdPlay&&(V._wouldBeNewAdPlay=!1,t(j.data,"view_ad_played_count")),V.inPrerollPosition()&&!j.data.view_preroll_played&&(j.data.view_preroll_played=!0,V._adRequests.length>0&&(j.data.view_preroll_request_time=Math.max(0,Z.viewer_time-V._adRequests[0].viewer_time)),j.data.view_start&&(j.data.view_startup_preroll_request_time=Math.max(0,Z.viewer_time-j.data.view_start)),V._prerollPlayTime=Z.viewer_time)}),j.on("adplaying",function($,Z){V.inPrerollPosition()&&j.data.view_preroll_load_time===void 0&&V._prerollPlayTime!==void 0&&(j.data.view_preroll_load_time=Z.viewer_time-V._prerollPlayTime,j.data.view_startup_preroll_load_time=Z.viewer_time-V._prerollPlayTime)}),j.on("adended",function(){V._wouldBeNewAdPlay=!0}),j.on("aderror",function(){V._wouldBeNewAdPlay=!0})}var C,w,N;return C=F,(w=[{key:"inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(j){for(var V=0;V<this._adRequests.length;V++)if(this._adRequests[V].ad_request_id===j)return this._adRequests[V]}},{key:"_updateAdData",value:function(j,V){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&V.ad_tag_url){var H=Ge(l(V.ad_tag_url),2),$=H[0],Z=H[1];this.pm.data.view_preroll_ad_tag_domain=Z,this.pm.data.view_preroll_ad_tag_hostname=$}if(!this.pm.data.view_preroll_ad_asset_hostname&&V.ad_asset_url){var Q=Ge(l(V.ad_asset_url),2),ne=Q[0],pe=Q[1];this.pm.data.view_preroll_ad_asset_domain=pe,this.pm.data.view_preroll_ad_asset_hostname=ne}}}}])&&we(C.prototype,w),N&&we(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function Pe(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function ot(F,C,w){return C&&Pe(F.prototype,C),w&&Pe(F,w),Object.defineProperty(F,"prototype",{writable:!1}),F}var Xe=ot(function F(C){var w,N;(function($,Z){if(!($ instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,F);var j=function(){C.disableRebufferTracking||w&&(t(C.data,"view_waiting_rebuffer_duration",h.now()-w),w=!1,_().clearInterval(N))},V=!1,H=function(){V=!1,j()};C.on("waiting",function(){V&&(C.disableRebufferTracking||(t(C.data,"view_waiting_rebuffer_count",1),w=h.now(),N=_().setInterval(function(){if(w){var $=h.now();t(C.data,"view_waiting_rebuffer_duration",$-w),w=$}},250)))}),C.on("playing",function(){j(),V=!0}),C.on("pause",H),C.on("seeking",H)});function ft(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function St(F,C,w){return C&&ft(F.prototype,C),w&&ft(F,w),Object.defineProperty(F,"prototype",{writable:!1}),F}var qe=St(function F(C){var w=this;(function(V,H){if(!(V instanceof H))throw new TypeError("Cannot call a class as a function")})(this,F);var N=function(){w.lastWallClockTime=h.now(),C.on("before*",j)},j=function(V){var H=h.now(),$=w.lastWallClockTime;w.lastWallClockTime=H,H-$>3e4&&(C.emit("devicesleep",{viewer_time:$}),i()(C.data,{viewer_time:$}),C.send("devicesleep"),C.emit("devicewake",{viewer_time:H}),i()(C.data,{viewer_time:H}),C.send("devicewake"))};C.one("playbackheartbeat",N),C.on("playbackheartbeatend",function(){C.off("before*",j),C.one("playbackheartbeat",N)})}),Rt=R(375),Dt=R(655),lt=R.n(Dt),ct="muxData",ut=function(){var F;try{F=Rt.parse(lt().get(ct)||"")}catch{F={}}return F},At=function(F){try{lt().set(ct,Rt.stringify(F),{expires:7300})}catch{}},Tt=function(){var F=ut();return F.mux_viewer_id=F.mux_viewer_id||y(),F.msn=F.msn||Math.random(),At(F),{mux_viewer_id:F.mux_viewer_id,mux_sample_number:F.msn}};function Sr(F,C){var w=C.beaconCollectionDomain,N=C.beaconDomain;if(w)return"https://"+w;var j=N||"litix.io";return(F=F||"inferred").match(/^[a-z0-9]+$/)?"https://"+F+"."+j:"https://img.litix.io/a.gif"}var Kt=function(){var F;switch(It()){case"cellular":F="cellular";break;case"ethernet":F="wired";break;case"wifi":F="wifi";break;case void 0:break;default:F="other"}return F},It=function(){var F=_().navigator,C=F&&(F.connection||F.mozConnection||F.webkitConnection);return C&&C.type};Kt.getConnectionFromAPI=It;var et=Kt,or=lr({a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"}),jt=lr({ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function lr(F){var C={};for(var w in F)F.hasOwnProperty(w)&&(C[F[w]]=w);return C}function Wt(F){var C={},w={};return Object.keys(F).forEach(function(N){var j=!1;if(F.hasOwnProperty(N)&&F[N]!==void 0){var V=N.split("_"),H=V[0],$=or[H];$||(e.info("Data key word `"+V[0]+"` not expected in "+N),$=H+"_"),V.splice(1).forEach(function(Z){Z==="url"&&(j=!0),jt[Z]?$+=jt[Z]:Number(Z)&&Math.floor(Number(Z))===Number(Z)?$+=Z:(e.info("Data key word `"+Z+"` not expected in "+N),$+="_"+Z+"_")}),j?w[$]=F[N]:C[$]=F[N]}}),i()(C,w)}var Dr={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},Ar=["hb","requestcompleted","requestfailed","requestcanceled"],dt=function(F,C){this._beaconUrl=F||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=i()({},Dr,C)};dt.prototype.queueEvent=function(F,C){var w=i()({},C);return(this._eventQueue.length<=this._options.maxQueueLength||F==="eventrateexceeded")&&(this._eventQueue.push(w),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},dt.prototype.flushEvents=function(){this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()},dt.prototype.destroy=function(){var F=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,F?this._clearBeaconQueue():this.flushEvents(),_().clearTimeout(this._sendTimeout)},dt.prototype._clearBeaconQueue=function(){var F=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,C=this._eventQueue.slice(F);F>0&&i()(C[C.length-1],Wt({mux_view_message:"event queue truncated"}));var w=this._createPayload(C);Pt(this._beaconUrl,w,!0,function(){})},dt.prototype._sendBeaconQueue=function(){var F=this;if(!this._postInFlight){var C=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var w=this._createPayload(C),N=h.now();Pt(this._beaconUrl,w,!1,function(j,V){V?(F._eventQueue=C.concat(F._eventQueue),F._failureCount+=1,e.info("Error sending beacon: "+V)):F._failureCount=0,F._roundTripTime=h.now()-N,F._postInFlight=!1})}},dt.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var F=Math.pow(2,this._failureCount-1);return(1+(F*=Math.random()))*this._options.baseTimeBetweenBeacons},dt.prototype._startBeaconSending=function(){var F=this;_().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=_().setTimeout(function(){F._eventQueue.length&&F._sendBeaconQueue(),F._startBeaconSending()},this._getNextBeaconTime()))},dt.prototype._createPayload=function(F){var C,w,N,j=this,V={transmission_timestamp:Math.round(h.now())};this._roundTripTime&&(V.rtt_ms=Math.round(this._roundTripTime));var H=function(){C=JSON.stringify({metadata:V,events:w||F}),N=C.length/1024},$=function(){return N<=j._options.maxPayloadKBSize};return H(),$()||(e.info("Payload size is too big ("+N+" kb). Removing unnecessary events."),w=F.filter(function(Z){return Ar.indexOf(Z.e)===-1}),H()),$()||(e.info("Payload size still too big ("+N+" kb). Cropping fields.."),w.forEach(function(Z){for(var Q in Z){var ne=Z[Q];typeof ne=="string"&&ne.length>51200&&(Z[Q]=ne.substring(0,51200))}}),H()),C};var Pt=function(F,C,w,N){if(w&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(F,C))N();else if(_().fetch)_().fetch(F,{method:"POST",body:C,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(V){return N(null,V.ok?null:"Error")}).catch(function(V){return N(null,V)});else{if(_().XMLHttpRequest){var j=new(_()).XMLHttpRequest;return j.onreadystatechange=function(){if(j.readyState===4)return N(null,j.status!==200?"error":void 0)},j.open("POST",F),j.setRequestHeader("Content-Type","text/plain"),void j.send(C)}N()}},ur=dt;function Lt(F){return Lt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},Lt(F)}var Lr=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id"],ji=["viewstart","error","ended","viewend"],dr=function(F,C){var w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=F,this.envKey=C,this.eventQueue=new ur(Sr(C,w)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=w.sampleRate,this.disableCookies=w.disableCookies,this.respectDoNotTrack=w.respectDoNotTrack;var N=w.platform||{};this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:N.name,viewer_application_version:N.version,viewer_application_engine:N.layout,viewer_device_name:N.product,viewer_device_category:"",viewer_device_manufacturer:N.manufacturer,viewer_os_family:N.os&&N.os.family,viewer_os_architecture:N.os&&N.os.architecture,viewer_os_version:N.os&&N.os.version};var j=et();j&&(this.pageLevelData=i()(this.pageLevelData,{viewer_connection_type:j})),_()!==void 0&&_().location&&_().location.href&&(this.pageLevelData.page_url=_().location.href),this.viewerData=this.disableCookies?{}:Tt()};dr.prototype.send=function(F,C){if(F){if(this.respectDoNotTrack&&o())return e.info("Not sending `"+F+"` because Do Not Track is enabled");if(!C||Lt(C)!=="object")return e.error("A data object was expected in send() but was not provided");var w,N,j=this.disableCookies?{}:(w=ut(),N=h.now(),w.session_start&&(w.sst=w.session_start,delete w.session_start),w.session_id&&(w.sid=w.session_id,delete w.session_id),w.session_expires&&(w.sex=w.session_expires,delete w.session_expires),(!w.sex||w.sex<N)&&(w.sid=y(),w.sst=N),w.sex=N+15e5,At(w),{session_id:w.sid,session_start:w.sst,session_expires:w.sex}),V={};i()(V,this.pageLevelData),i()(V,C),i()(V,j),i()(V,this.viewerData),V.event=F,V.env_key=this.envKey,V.user_id&&(V.viewer_user_id=V.user_id,delete V.user_id);var H=V.mux_sample_number>=this.sampleRate,$=Wt(this._deduplicateBeaconData(F,V));if(this.lastEventTime=this.mux.utils.now(),H)return e.info("Not sending event due to sample rate restriction",F,V,$);if(this.envKey||e.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",F,V,$),!this.rateLimited){if(e.info("Sending event",F,V,$),this.rateLimited=!this.eventQueue.queueEvent(F,$),this.mux.WINDOW_UNLOADING&&F==="viewend")this.eventQueue.destroy(!0);else if((ji.indexOf(F)>=0||this.mux.WINDOW_HIDDEN&&F==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return V.event="eventrateexceeded",$=Wt(V),this.eventQueue.queueEvent(V.event,$),e.error("Beaconing disabled due to rate limit.")}}},dr.prototype.destroy=function(){this.eventQueue.destroy(!1)},dr.prototype._deduplicateBeaconData=function(F,C){var w=this,N={},j=C.view_id;if(!j||F==="viewstart"||F==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)N=i()({},C),j&&(this.previousBeaconData=N),j&&F==="viewend"&&(this.previousBeaconData=null);else{var V=F.indexOf("request")===0;Object.keys(C).forEach(function(H){var $=C[H];($!==w.previousBeaconData[H]||Lr.indexOf(H)>-1||function(Z,Q,ne,pe){return!(!Z||Q.indexOf("request_")!==0||Q!=="request_response_headers"&&Lt(ne)==="object"&&Lt(pe)==="object"&&Object.keys(ne||{}).length===Object.keys(pe||{}).length)}(V,H,$,w.previousBeaconData[H])||function(Z,Q){return Z==="renditionchange"&&Q.indexOf("video_source_")===0}(F,H))&&(N[H]=$,w.previousBeaconData[H]=$)})}return N};var Wi=dr;function ei(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function Gi(F,C,w){return C&&ei(F.prototype,C),w&&ei(F,w),Object.defineProperty(F,"prototype",{writable:!1}),F}var Hi=Gi(function F(C){(function(Q,ne){if(!(Q instanceof ne))throw new TypeError("Cannot call a class as a function")})(this,F);var w=0,N=0,j=0,V=0,H=0,$=0,Z=0;C.on("requestcompleted",function(Q,ne){var pe,Ae,Te=ne.request_start,le=ne.request_response_start,fe=ne.request_response_end,Le=ne.request_bytes_loaded;if(V++,le?(pe=le-Te,Ae=fe-le):Ae=fe-Te,Ae>0&&Le>0){var Je=Le/Ae*8e3;H++,N+=Le,j+=Ae,C.data.view_min_request_throughput=Math.min(C.data.view_min_request_throughput||1/0,Je),C.data.view_average_request_throughput=N/j*8e3,C.data.view_request_count=V,pe>0&&(w+=pe,C.data.view_max_request_latency=Math.max(C.data.view_max_request_latency||0,pe),C.data.view_average_request_latency=w/H)}}),C.on("requestfailed",function(Q,ne){V++,$++,C.data.view_request_count=V,C.data.view_request_failed_count=$}),C.on("requestcanceled",function(Q,ne){V++,Z++,C.data.view_request_count=V,C.data.view_request_canceled_count=Z})});function ti(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function Vi(F,C,w){return C&&ti(F.prototype,C),w&&ti(F,w),Object.defineProperty(F,"prototype",{writable:!1}),F}var Yi=Vi(function F(C){var w=this;(function(N,j){if(!(N instanceof j))throw new TypeError("Cannot call a class as a function")})(this,F),C.on("before*",function(N,j){var V=j.viewer_time,H=h.now(),$=w._lastEventTime;if(w._lastEventTime=H,$&&H-$>36e5){var Z=Object.keys(C.data).reduce(function(Q,ne){return ne.indexOf("video_")===0?i()(Q,function(pe,Ae,Te){return Ae in pe?Object.defineProperty(pe,Ae,{value:Te,enumerable:!0,configurable:!0,writable:!0}):pe[Ae]=Te,pe}({},ne,C.data[ne])):Q},{});C.mux.log.info("Received event after at least an hour inactivity, creating a new view"),C.emit("viewinit",i()({viewer_time:V},Z)),C.playbackHeartbeat._playheadShouldBeProgressing&&N.type!=="play"&&N.type!=="adbreakstart"&&(C.emit("play",{viewer_time:V}),N.type!=="playing"&&C.emit("playing",{viewer_time:V}))}})});function _r(F){return _r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},_r(F)}function Xi(F,C){return function(w){if(Array.isArray(w))return w}(F)||function(w,N){var j=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(j!=null){var V,H,$=[],Z=!0,Q=!1;try{for(j=j.call(w);!(Z=(V=j.next()).done)&&($.push(V.value),!N||$.length!==N);Z=!0);}catch(ne){Q=!0,H=ne}finally{try{Z||j.return==null||j.return()}finally{if(Q)throw H}}return $}}(F,C)||function(w,N){if(w){if(typeof w=="string")return ri(w,N);var j=Object.prototype.toString.call(w).slice(8,-1);return j==="Object"&&w.constructor&&(j=w.constructor.name),j==="Map"||j==="Set"?Array.from(w):j==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(j)?ri(w,N):void 0}}(F,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function ri(F,C){(C==null||C>F.length)&&(C=F.length);for(var w=0,N=new Array(C);w<C;w++)N[w]=F[w];return N}function ii(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function br(F,C){return br=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(w,N){return w.__proto__=N,w},br(F,C)}function zi(F){var C=function(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var w,N=fr(F);if(C){var j=fr(this).constructor;w=Reflect.construct(N,arguments,j)}else w=N.apply(this,arguments);return Qi(this,w)}}function Qi(F,C){if(C&&(_r(C)==="object"||typeof C=="function"))return C;if(C!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ve(F)}function Ve(F){if(F===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return F}function fr(F){return fr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(C){return C.__proto__||Object.getPrototypeOf(C)},fr(F)}var $i=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],Ji=function(F){(function(H,$){if(typeof $!="function"&&$!==null)throw new TypeError("Super expression must either be null or a function");H.prototype=Object.create($&&$.prototype,{constructor:{value:H,writable:!0,configurable:!0}}),Object.defineProperty(H,"prototype",{writable:!1}),$&&br(H,$)})(V,F);var C,w,N,j=zi(V);function V(H,$,Z){var Q;(function(le,fe){if(!(le instanceof fe))throw new TypeError("Cannot call a class as a function")})(this,V),(Q=j.call(this)).DOM_CONTENT_LOADED_EVENT_END=c.domContentLoadedEventEnd(),Q.NAVIGATION_START=c.navigationStart(),Q.mux=H,Q.id=$,(Z=i()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(le){return le}},Z)).data=Z.data||{},Z.data.property_key&&(Z.data.env_key=Z.data.property_key,delete Z.data.property_key),e.setLevel(Z.debug?"debug":"warn"),Q.getPlayheadTime=Z.getPlayheadTime,Q.getStateData=Z.getStateData||function(){return{}},Q.getAdData=Z.getAdData||function(){},Q.minimumRebufferDuration=Z.minimumRebufferDuration,Q.sustainedRebufferThreshold=Z.sustainedRebufferThreshold,Q.playbackHeartbeatTime=Z.playbackHeartbeatTime,Q.disableRebufferTracking=Z.disableRebufferTracking,Q.disableRebufferTracking&&Q.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),Q.disablePlayheadRebufferTracking=Z.disablePlayheadRebufferTracking,Q.errorTranslator=Z.errorTranslator,Q.playbackEventDispatcher=new Wi(H,Z.data.env_key,Z),Q.data={player_instance_id:y(),mux_sample_rate:Z.sampleRate,beacon_domain:Z.beaconCollectionDomain?Z.beaconCollectionDomain:Z.beaconDomain},Q.data.view_sequence_number=1,Q.data.player_sequence_number=1,Q.oldEmit=Q.emit,Q.emit=function(le,fe){fe=i()({viewer_time:this.mux.utils.now()},fe),this.oldEmit(le,fe)};var ne=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(Ve(Q));Q.on("viewinit",function(le,fe){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),i()(this.data,fe),this._initializeViewData(),this.one("play",ne),this.one("adbreakstart",ne)});var pe=function(le){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",le)}.bind(Ve(Q));if(Q.on("videochange",function(le,fe){pe(fe)}),Q.on("programchange",function(le,fe){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),pe(i()(fe,{view_program_changed:!0})),ne(),this.emit("play"),this.emit("playing")}),Q.on("fragmentchange",function(le,fe){this.currentFragmentPDT=fe.currentFragmentPDT,this.currentFragmentStart=fe.currentFragmentStart}),Q.on("destroy",Q.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var Ae=function(){var le=Q.data.view_start!==void 0;Q.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",le&&Q.mux.WINDOW_HIDDEN&&(Q.data.player_is_paused||Q.emit("hb"))};window.addEventListener("visibilitychange",Ae,!1);var Te=function(le){le.persisted||Q.destroy()};window.addEventListener("pagehide",Te,!1),Q.on("destroy",function(){window.removeEventListener("visibilitychange",Ae),window.removeEventListener("pagehide",Te)})}return Q.on("playerready",function(le,fe){i()(this.data,fe)}),$i.forEach(function(le){Q.on(le,function(fe,Le){le.indexOf("ad")!==0&&this._updateStateData(),i()(this.data,Le),this._sanitizeData()}),Q.on("after"+le,function(){(le!=="error"||this.errorTracker.viewErrored)&&this.send(le)})}),Q.on("viewend",function(le,fe){i()(Q.data,fe)}),Q.one("playerready",function(le){var fe=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=fe-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time}),Q.longResumeTracker=new Yi(Ve(Q)),Q.errorTracker=new q(Ve(Q)),new qe(Ve(Q)),Q.seekingTracker=new Ye(Ve(Q)),Q.playheadTime=new re(Ve(Q)),Q.playbackHeartbeat=new J(Ve(Q)),new je(Ve(Q)),Q.watchTimeTracker=new ae(Ve(Q)),new oe(Ve(Q)),Q.adTracker=new Ue(Ve(Q)),new Ne(Ve(Q)),new Se(Ve(Q)),new Ke(Ve(Q)),new Xe(Ve(Q)),new Hi(Ve(Q)),Z.hlsjs&&Q.addHLSJS(Z),Z.dashjs&&Q.addDashJS(Z),Q.emit("viewinit",Z.data),Q}return C=V,w=[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(H){var $=i()({},this.data);if($.video_source_is_live===void 0&&($.player_source_duration===1/0||$.video_source_duration===1/0?$.video_source_is_live=!0:($.player_source_duration>0||$.video_source_duration>0)&&($.video_source_is_live=!1)),$.video_source_is_live||["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"].forEach(function(pe){$[pe]=void 0}),$.video_source_url=$.video_source_url||$.player_source_url,$.video_source_url){var Z=Xi(l($.video_source_url),2),Q=Z[0],ne=Z[1];$.video_source_domain=ne,$.video_source_hostname=Q}delete $.ad_request_id,this.playbackEventDispatcher.send(H,$),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){i()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var H=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function($){var Z=parseInt(H.data[$],10);H.data[$]=isNaN(Z)?void 0:Z}),["player_source_url","video_source_url"].forEach(function($){if(H.data[$]){var Z=H.data[$].toLowerCase();Z.indexOf("data:")!==0&&Z.indexOf("blob:")!==0||(H.data[$]="MSE style URL")}})}},{key:"_resetVideoData",value:function(H,$){var Z=this;Object.keys(this.data).forEach(function(Q){Q.indexOf("video_")===0&&delete Z.data[Q]})}},{key:"_resetViewData",value:function(){var H=this;Object.keys(this.data).forEach(function($){$.indexOf("view_")===0&&delete H.data[$]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(H,$){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var H=this,$=this.data.view_id=y(),Z=function(){$===H.data.view_id&&t(H.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",Z):Z()}},{key:"_restartHeartBeat",value:function(){var H=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){H.data.player_is_paused||H.emit("hb")},1e4))}},{key:"addHLSJS",value:function(H){H.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=H.hlsjs,function($,Z,Q){var ne=arguments.length>4?arguments[4]:void 0,pe=$.log,Ae=$.utils.secondsToMs,Te=function(De){var de,Ee=parseInt(ne.version);return Ee===1&&De.programDateTime!==null&&(de=De.programDateTime),Ee===0&&De.pdt!==null&&(de=De.pdt),de};if(c.exists()){var le=function(De,de){return $.emit(Z,De,de)},fe=function(De,de){var Ee=de.levels,ce=de.audioTracks,xe=de.url,Fe=de.stats,Re=de.networkDetails,st=de.sessionData,it={},ht={};Ee.forEach(function(mt,Vt){it[Vt]={width:mt.width,height:mt.height,bitrate:mt.bitrate,attrs:mt.attrs}}),ce.forEach(function(mt,Vt){ht[Vt]={name:mt.name,language:mt.lang,bitrate:mt.bitrate}});var vt=x(Fe),gt=vt.bytesLoaded,Qe=vt.requestStart,Pr=vt.responseStart,Cr=vt.responseEnd;le("requestcompleted",v(v({},s(st)),{},{request_event_type:De,request_bytes_loaded:gt,request_start:Qe,request_response_start:Pr,request_response_end:Cr,request_type:"manifest",request_hostname:r(xe),request_response_headers:I(Re),request_rendition_lists:{media:it,audio:ht,video:{}}}))};Q.on(ne.Events.MANIFEST_LOADED,fe);var Le=function(De,de){var Ee=de.details,ce=de.level,xe=de.networkDetails,Fe=de.stats,Re=x(Fe),st=Re.bytesLoaded,it=Re.requestStart,ht=Re.responseStart,vt=Re.responseEnd,gt=Ee.fragments[Ee.fragments.length-1],Qe=Te(gt)+Ae(gt.duration);le("requestcompleted",{request_event_type:De,request_bytes_loaded:st,request_start:it,request_response_start:ht,request_response_end:vt,request_current_level:ce,request_type:"manifest",request_hostname:r(Ee.url),request_response_headers:I(xe),video_holdback:Ee.holdBack&&Ae(Ee.holdBack),video_part_holdback:Ee.partHoldBack&&Ae(Ee.partHoldBack),video_part_target_duration:Ee.partTarget&&Ae(Ee.partTarget),video_target_duration:Ee.targetduration&&Ae(Ee.targetduration),video_source_is_live:Ee.live,player_manifest_newest_program_time:isNaN(Qe)?void 0:Qe})};Q.on(ne.Events.LEVEL_LOADED,Le);var Je=function(De,de){var Ee=de.details,ce=de.networkDetails,xe=de.stats,Fe=x(xe),Re=Fe.bytesLoaded,st=Fe.requestStart,it=Fe.responseStart,ht=Fe.responseEnd;le("requestcompleted",{request_event_type:De,request_bytes_loaded:Re,request_start:st,request_response_start:it,request_response_end:ht,request_type:"manifest",request_hostname:r(Ee.url),request_response_headers:I(ce)})};Q.on(ne.Events.AUDIO_TRACK_LOADED,Je);var tt=function(De,de){var Ee=de.stats,ce=de.networkDetails,xe=de.frag;Ee=Ee||xe.stats;var Fe=x(Ee),Re={request_event_type:De,request_bytes_loaded:Fe.bytesLoaded,request_start:Fe.requestStart,request_response_start:Fe.responseStart,request_response_end:Fe.responseEnd,request_hostname:ce?r(ce.responseURL):void 0,request_response_headers:I(ce),request_media_duration:xe.duration};xe.type==="main"?(Re.request_type="media",Re.request_current_level=xe.level,Re.request_video_width=(Q.levels[xe.level]||{}).width,Re.request_video_height=(Q.levels[xe.level]||{}).height):Re.request_type=xe.type,le("requestcompleted",Re)};Q.on(ne.Events.FRAG_LOADED,tt);var _t=function(De,de){var Ee=de.frag,ce=Ee.start,xe={currentFragmentPDT:Te(Ee),currentFragmentStart:Ae(ce)};le("fragmentchange",xe)};Q.on(ne.Events.FRAG_CHANGED,_t);var _e=function(De,de){var Ee=de.type,ce=de.details,xe=de.response,Fe=de.fatal,Re=de.context,st=de.frag;if(ce===ne.ErrorDetails.MANIFEST_LOAD_ERROR||ce===ne.ErrorDetails.MANIFEST_LOAD_TIMEOUT||ce===ne.ErrorDetails.FRAG_LOAD_ERROR||ce===ne.ErrorDetails.FRAG_LOAD_TIMEOUT||ce===ne.ErrorDetails.LEVEL_LOAD_ERROR||ce===ne.ErrorDetails.LEVEL_LOAD_TIMEOUT){var it=st&&st.url||Re&&Re.url||"";le("requestfailed",{request_error:ce,request_url:it,request_hostname:r(it),request_type:ce===ne.ErrorDetails.FRAG_LOAD_ERROR||ce===ne.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:xe&&xe.code,request_error_text:xe&&xe.text})}Fe&&le("error",{player_error_code:Ee,player_error_message:ce})};Q.on(ne.Events.ERROR,_e);var rt=function(De,de){var Ee=de.frag,ce=Ee&&Ee._url||"";le("requestcanceled",{request_event_type:De,request_url:ce,request_type:"media",request_hostname:r(ce)})};Q.on(ne.Events.FRAG_LOAD_EMERGENCY_ABORTED,rt);var ze=function(De,de){var Ee=de.level,ce=Q.levels[Ee];if(ce&&ce.attrs&&ce.attrs.BANDWIDTH){var xe,Fe=ce.attrs.BANDWIDTH,Re=parseFloat(ce.attrs["FRAME-RATE"]);isNaN(Re)||(xe=Re),Fe?le("renditionchange",{video_source_fps:xe,video_source_bitrate:Fe,video_source_width:ce.width,video_source_height:ce.height}):pe.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};Q.on(ne.Events.LEVEL_SWITCHED,ze),Q._stopMuxMonitor=function(){Q.off(ne.Events.MANIFEST_LOADED,fe),Q.off(ne.Events.LEVEL_LOADED,Le),Q.off(ne.Events.AUDIO_TRACK_LOADED,Je),Q.off(ne.Events.FRAG_LOADED,tt),Q.off(ne.Events.FRAG_CHANGED,_t),Q.off(ne.Events.ERROR,_e),Q.off(ne.Events.FRAG_LOAD_EMERGENCY_ABORTED,rt),Q.off(ne.Events.LEVEL_SWITCHED,ze),Q.off(ne.Events.DESTROYING,Q._stopMuxMonitor),delete Q._stopMuxMonitor},Q.on(ne.Events.DESTROYING,Q._stopMuxMonitor)}else pe.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,H.hlsjs,{},H.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var H;this.hlsjs&&((H=this.hlsjs)&&typeof H._stopMuxMonitor=="function"&&H._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(H){H.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=H.dashjs,function($,Z,Q){var ne=$.log;if(Q&&Q.on){var pe=function(_e,rt){return $.emit(Z,_e,rt)},Ae=function(_e){var rt=_e.type,ze=(_e.data||{}).url;pe("requestcompleted",{request_event_type:rt,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:r(ze)})};Q.on("manifestLoaded",Ae);var Te={},le=function(_e){var rt=_e.type,ze=_e.fragmentModel,De=(_e.chunk||{}).mediaInfo||{},de=De.type,Ee=De.bitrateList,ce={};(Ee=Ee||[]).forEach(function(gt,Qe){ce[Qe]={},ce[Qe].width=gt.width,ce[Qe].height=gt.height,ce[Qe].bitrate=gt.bandwidth,ce[Qe].attrs={}}),de==="video"?Te.video=ce:de==="audio"?Te.audio=ce:Te.media=ce;var xe=B(ze,Q),Fe=xe.requestStart,Re=xe.requestResponseStart,st=xe.requestResponseEnd,it=xe.requestResponseHeaders,ht=xe.requestMediaDuration,vt=xe.requestHostname;pe("requestcompleted",{request_event_type:rt,request_start:Fe,request_response_start:Re,request_response_end:st,request_bytes_loaded:-1,request_type:de+"_init",request_response_headers:it,request_hostname:vt,request_media_duration:ht,request_rendition_lists:Te})};Q.on("initFragmentLoaded",le);var fe=function(_e){var rt=_e.type,ze=_e.fragmentModel,De=_e.chunk||{},de=De.mediaInfo,Ee=De.start,ce=(de||{}).type,xe=B(ze,Q),Fe=xe.requestStart,Re=xe.requestResponseStart,st=xe.requestResponseEnd,it=xe.requestBytesLoaded,ht=xe.requestResponseHeaders,vt=xe.requestMediaDuration,gt=xe.requestHostname,Qe=k(ce,Q),Pr=Qe.currentLevel,Cr=Qe.renditionWidth,mt=Qe.renditionHeight,Vt=Qe.renditionBitrate;pe("requestcompleted",{request_event_type:rt,request_start:Fe,request_response_start:Re,request_response_end:st,request_bytes_loaded:it,request_type:ce,request_response_headers:ht,request_hostname:gt,request_media_start_time:Ee,request_media_duration:vt,request_current_level:Pr,request_labeled_bitrate:Vt,request_video_width:Cr,request_video_height:mt})};Q.on("mediaFragmentLoaded",fe);var Le={video:void 0,audio:void 0,totalBitrate:void 0},Je=function(){if(Le.video&&typeof Le.video.bitrate=="number"){if(Le.video.width&&Le.video.height){var _e=Le.video.bitrate;return Le.audio&&typeof Le.audio.bitrate=="number"&&(_e+=Le.audio.bitrate),_e!==Le.totalBitrate?(Le.totalBitrate=_e,{video_source_bitrate:_e,video_source_height:Le.video.height,video_source_width:Le.video.width}):void 0}ne.warn("have bitrate info for video but missing width/height")}},tt=function(_e,rt,ze){if(typeof _e.newQuality=="number"){var De=_e.mediaType;if(De==="audio"||De==="video"){var de=Q.getBitrateInfoListFor(De).find(function(ce){return ce.qualityIndex===_e.newQuality});if(de&&typeof de.bitrate=="number"){Le[De]=de;var Ee=Je();Ee&&pe("renditionchange",Ee)}else ne.warn("missing bitrate info for ".concat(De))}}else ne.warn("missing evt.newQuality in qualityChangeRendered event",_e)};Q.on("qualityChangeRendered",tt);var _t=function(_e){var rt=_e.error,ze=_e.event,De=(ze=ze||{}).request||{},de=_().event&&_().event.currentTarget||{};pe("requestfailed",{request_error:rt+"_"+ze.id+"_"+De.type,request_url:ze.url,request_hostname:r(ze.url),request_type:De.mediaType,request_error_code:de.status,request_error_type:de.statusText})};Q.on("error",_t),Q._stopMuxMonitor=function(){Q.off("manifestLoaded",Ae),Q.off("initFragmentLoaded",le),Q.off("mediaFragmentLoaded",fe),Q.off("qualityChangeRendered",tt),Q.off("error",_t),delete Q._stopMuxMonitor}}else ne.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,H.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var H;this.dashjs&&((H=this.dashjs)&&typeof H._stopMuxMonitor=="function"&&H._stopMuxMonitor(),this.dashjs=void 0)}}],w&&ii(C.prototype,w),N&&ii(C,N),Object.defineProperty(C,"prototype",{writable:!1}),V}(X),Zi=Ji,qi=R(153),Gt=R.n(qi);function Or(F){return Or=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},Or(F)}function ni(F,C){return function(w){if(Array.isArray(w))return w}(F)||function(w,N){var j=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(j!=null){var V,H,$=[],Z=!0,Q=!1;try{for(j=j.call(w);!(Z=(V=j.next()).done)&&($.push(V.value),!N||$.length!==N);Z=!0);}catch(ne){Q=!0,H=ne}finally{try{Z||j.return==null||j.return()}finally{if(Q)throw H}}return $}}(F,C)||function(w,N){if(w){if(typeof w=="string")return ai(w,N);var j=Object.prototype.toString.call(w).slice(8,-1);return j==="Object"&&w.constructor&&(j=w.constructor.name),j==="Map"||j==="Set"?Array.from(w):j==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(j)?ai(w,N):void 0}}(F,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
4
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function ai(F,C){(C==null||C>F.length)&&(C=F.length);for(var w=0,N=new Array(C);w<C;w++)N[w]=F[w];return N}var Ct,en=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],tn={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};_()&&_().WeakMap&&(Ct=new WeakMap);var rn="#EXT-X-TARGETDURATION",nn="#EXT-X-PART-INF",an="#EXT-X-SERVER-CONTROL",sn="#EXTINF",on="#EXT-X-PROGRAM-DATE-TIME",ln="#EXT-X-VERSION",un="#EXT-X-SESSION-DATA",cr=function(F){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(F),this.manifest};cr.prototype.process=function(F){var C;for(this.buffer+=F,C=this.buffer.indexOf(`
1
+ var xn=Object.create;var Mr=Object.defineProperty;var Sn=Object.getOwnPropertyDescriptor;var Dn=Object.getOwnPropertyNames;var An=Object.getPrototypeOf,Ln=Object.prototype.hasOwnProperty;var _n=(K,b,n)=>b in K?Mr(K,b,{enumerable:!0,configurable:!0,writable:!0,value:n}):K[b]=n;var ui=(K,b)=>()=>(b||K((b={exports:{}}).exports,b),b.exports);var bn=(K,b,n,I)=>{if(b&&typeof b=="object"||typeof b=="function")for(let L of Dn(b))!Ln.call(K,L)&&L!==n&&Mr(K,L,{get:()=>b[L],enumerable:!(I=Sn(b,L))||I.enumerable});return K};var hr=(K,b,n)=>(n=K!=null?xn(An(K)):{},bn(b||!K||!K.__esModule?Mr(n,"default",{value:K,enumerable:!0}):n,K));var Yt=(K,b,n)=>(_n(K,typeof b!="symbol"?b+"":b,n),n),wr=(K,b,n)=>{if(!b.has(K))throw TypeError("Cannot "+n)};var se=(K,b,n)=>(wr(K,b,"read from private field"),n?n.call(K):b.get(K)),Ee=(K,b,n)=>{if(b.has(K))throw TypeError("Cannot add the same private member more than once");b instanceof WeakSet?b.add(K):b.set(K,n)},be=(K,b,n,I)=>(wr(K,b,"write to private field"),I?I.call(K,n):b.set(K,n),n);var Ce=(K,b,n)=>(wr(K,b,"access private method"),n);var ci=ui((vr,Ur)=>{(function(){var K,b;K=this,b=function(){return function(){var n={80:function(D,M,R){D.exports=R(728).default},728:function(D,M,R){"use strict";R.d(M,{default:function(){return Tn}});var O=R(48),_=R.n(O),y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(F){var C=16*Math.random()|0;return(F==="x"?C:3&C|8).toString(16)})},T=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},A=function(F){return F&&F.nodeName!==void 0?(F.muxId||(F.muxId=F.id||T()),F.muxId):F},E=function(F){var C;F&&F.nodeName!==void 0?F=A(C=F):C=document.querySelector(F);var w=C&&C.nodeName?C.nodeName.toLowerCase():"";return[C,F,w]},m=R(640),p=R.n(m),f=p().methodFactory;p().methodFactory=function(F,C,w){var N=f(F,C,w);return function(){for(var j=["[mux]"],V=0;V<arguments.length;V++)j.push(arguments[V]);N.apply(void 0,j)}},p().setLevel(p().getLevel());var e=p();function o(){return(_().doNotTrack||_().navigator&&_().navigator.doNotTrack)==="1"}var h={now:function(){var F=_().performance,C=F&&F.timing,w=F&&F.timeOrigin||C&&C.navigationStart;return typeof w=="number"&&typeof F.now=="function"?w+F.now():Date.now()}},g=R(678),i=R.n(g),r=function(F){return l(F)[0]},l=function(F){if(typeof F!="string"||F==="")return["localhost"];var C,w=(F.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return w&&(C=(w.match(/[^\.]+\.[^\.]+$/)||[])[0]),[w,C]},c={exists:function(){var F=_().performance;return(F&&F.timing)!==void 0},domContentLoadedEventEnd:function(){var F=_().performance,C=F&&F.timing;return C&&C.domContentLoadedEventEnd},navigationStart:function(){var F=_().performance,C=F&&F.timing;return C&&C.navigationStart}};function t(F,C,w){w=w===void 0?1:w,F[C]=F[C]||0,F[C]+=w}var a=["x-cdn","content-type","x-request-id"];function u(F){var C={};return(F=F||"").trim().split(/[\r\n]+/).forEach(function(w){if(w){var N=w.split(": "),j=N.shift();j&&(a.indexOf(j.toLowerCase())>=0||j.toLowerCase().indexOf("x-litix-")===0)&&(C[j]=N.join(": "))}}),C}var s=function(F){var C={};for(var w in F){var N=F[w];N["DATA-ID"].search("io.litix.data.")!==-1&&(C[N["DATA-ID"].replace("io.litix.data.","")]=N.VALUE)}return C};function d(F,C){var w=Object.keys(F);if(Object.getOwnPropertySymbols){var N=Object.getOwnPropertySymbols(F);C&&(N=N.filter(function(j){return Object.getOwnPropertyDescriptor(F,j).enumerable})),w.push.apply(w,N)}return w}function v(F){for(var C=1;C<arguments.length;C++){var w=arguments[C]!=null?arguments[C]:{};C%2?d(Object(w),!0).forEach(function(N){S(F,N,w[N])}):Object.getOwnPropertyDescriptors?Object.defineProperties(F,Object.getOwnPropertyDescriptors(w)):d(Object(w)).forEach(function(N){Object.defineProperty(F,N,Object.getOwnPropertyDescriptor(w,N))})}return F}function S(F,C,w){return C in F?Object.defineProperty(F,C,{value:w,enumerable:!0,configurable:!0,writable:!0}):F[C]=w,F}var x=function(F){if(!F)return{};var C=c.navigationStart(),w=F.loading,N=w?w.start:F.trequest,j=w?w.first:F.tfirst,V=w?w.end:F.tload;return{bytesLoaded:F.total,requestStart:Math.round(C+N),responseStart:Math.round(C+j),responseEnd:Math.round(C+V)}},P=function(F){if(F&&typeof F.getAllResponseHeaders=="function")return u(F.getAllResponseHeaders())},B=function(F,C){if(!F||typeof F.getRequests!="function")return{};var w=F.getRequests({state:"executed"});if(w.length===0)return{};var N,j=w[w.length-1],V=r(j.url),H=j.bytesLoaded,$=new Date(j.requestStartDate).getTime(),Z=new Date(j.firstByteDate).getTime(),Q=new Date(j.requestEndDate).getTime(),ne=isNaN(j.duration)?0:j.duration,me=typeof C.getMetricsFor=="function"?C.getMetricsFor(j.mediaType).HttpList:C.getDashMetrics().getHttpRequests(j.mediaType);return me.length>0&&(N=u(me[me.length-1]._responseHeaders||"")),{requestStart:$,requestResponseStart:Z,requestResponseEnd:Q,requestBytesLoaded:H,requestResponseHeaders:N,requestMediaDuration:ne,requestHostname:V}},k=function(F,C){var w=C.getQualityFor(F),N=C.getCurrentTrackFor(F).bitrateList;return N?{currentLevel:w,renditionWidth:N[w].width||null,renditionHeight:N[w].height||null,renditionBitrate:N[w].bandwidth}:{}};function U(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var W=0,G=function(){function F(){(function(j,V){if(!(j instanceof V))throw new TypeError("Cannot call a class as a function")})(this,F)}var C,w,N;return C=F,w=[{key:"on",value:function(j,V,H){return V._eventEmitterGuid=V._eventEmitterGuid||++W,this._listeners=this._listeners||{},this._listeners[j]=this._listeners[j]||[],H&&(V=V.bind(H)),this._listeners[j].push(V),V}},{key:"off",value:function(j,V){var H=this._listeners&&this._listeners[j];H&&H.forEach(function($,Z){$._eventEmitterGuid===V._eventEmitterGuid&&H.splice(Z,1)})}},{key:"one",value:function(j,V,H){var $=this;V._eventEmitterGuid=V._eventEmitterGuid||++W;var Z=function Q(){$.off(j,Q),V.apply(H||this,arguments)};Z._eventEmitterGuid=V._eventEmitterGuid,this.on(j,Z)}},{key:"emit",value:function(j,V){var H=this;if(this._listeners){V=V||{};var $=this._listeners["before*"]||[],Z=this._listeners[j]||[],Q=this._listeners["after"+j]||[],ne=function(me,Ae){(me=me.slice()).forEach(function(Te){Te.call(H,{type:j},Ae)})};ne($,V),ne(Z,V),ne(Q,V)}}}],w&&U(C.prototype,w),N&&U(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}(),z=G;function Y(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var J=function(){function F(j){var V=this;(function(H,$){if(!(H instanceof $))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=j,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,j.on("playing",function(){V._playheadShouldBeProgressing=!0}),j.on("play",this._startPlaybackHeartbeatInterval.bind(this)),j.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),j.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),j.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),j.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),j.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),j.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),j.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),j.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),j.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("seeked",function(){j.data.player_is_paused?V._stopPlaybackHeartbeatInterval():V._startPlaybackHeartbeatInterval()}),j.on("timeupdate",function(){V._playbackHeartbeatInterval!==null&&j.emit("playbackheartbeat")}),j.on("devicesleep",function(H,$){V._playbackHeartbeatInterval!==null&&(_().clearInterval(V._playbackHeartbeatInterval),j.emit("playbackheartbeatend",{viewer_time:$.viewer_time}),V._playbackHeartbeatInterval=null)})}var C,w,N;return C=F,(w=[{key:"_startPlaybackHeartbeatInterval",value:function(){var j=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=_().setInterval(function(){j.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(_().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Y(C.prototype,w),N&&Y(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function ee(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function X(F,C,w){return C&&ee(F.prototype,C),w&&ee(F,w),Object.defineProperty(F,"prototype",{writable:!1}),F}var q=X(function F(C){var w=this;(function(N,j){if(!(N instanceof j))throw new TypeError("Cannot call a class as a function")})(this,F),C.on("viewinit",function(){w.viewErrored=!1}),C.on("error",function(){try{var N=C.errorTranslator({player_error_code:C.data.player_error_code,player_error_message:C.data.player_error_message});N?(C.data.player_error_code=N.player_error_code,C.data.player_error_message=N.player_error_message,w.viewErrored=!0):(delete C.data.player_error_code,delete C.data.player_error_message)}catch(j){C.mux.log.warn("Exception in error translator callback.",j),w.viewErrored=!0}})});function ie(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var ae=function(){function F(j){(function(V,H){if(!(V instanceof H))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=j,this._watchTimeTrackerLastCheckedTime=null,j.on("playbackheartbeat",this._updateWatchTime.bind(this)),j.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var C,w,N;return C=F,(w=[{key:"_updateWatchTime",value:function(j,V){var H=V.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=H),t(this.pm.data,"view_watch_time",H-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=H}},{key:"_clearWatchTimeState",value:function(j,V){this._updateWatchTime(j,V),this._watchTimeTrackerLastCheckedTime=null}}])&&ie(C.prototype,w),N&&ie(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function te(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var oe=function(){function F(j){(function(V,H){if(!(V instanceof H))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=j,this._playbackTimeTrackerLastPlayheadPosition=-1,j.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),j.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),j.on("seeking",this._clearPlaybackTimeState.bind(this))}var C,w,N;return C=F,(w=[{key:"_updatePlaybackTime",value:function(){var j=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&j>this._playbackTimeTrackerLastPlayheadPosition){var V=j-this._playbackTimeTrackerLastPlayheadPosition;V<=1e3&&t(this.pm.data,"view_content_playback_time",V)}this._playbackTimeTrackerLastPlayheadPosition=j}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&te(C.prototype,w),N&&te(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function ue(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var re=function(){function F(j){(function(H,$){if(!(H instanceof $))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=j;var V=this._updatePlayheadTime.bind(this);j.on("playbackheartbeat",V),j.on("playbackheartbeatend",V),j.on("timeupdate",V),j.on("destroy",function(){j.off("timeupdate",V)})}var C,w,N;return C=F,(w=[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=this.pm.data.view_max_playhead_position===void 0?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(j,V){var H=this,$=function(){H.pm.currentFragmentPDT&&H.pm.currentFragmentStart&&(H.pm.data.player_program_time=H.pm.currentFragmentPDT+H.pm.data.player_playhead_time-H.pm.currentFragmentStart)};if(V&&V.player_playhead_time)this.pm.data.player_playhead_time=V.player_playhead_time,$(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var Z=this.pm.getPlayheadTime();Z!==void 0&&(this.pm.data.player_playhead_time=Z,$(),this._updateMaxPlayheadPosition())}}}])&&ue(C.prototype,w),N&&ue(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function he(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function ve(F,C,w){return C&&he(F.prototype,C),w&&he(F,w),Object.defineProperty(F,"prototype",{writable:!1}),F}var Se=ve(function F(C){if(function(j,V){if(!(j instanceof V))throw new TypeError("Cannot call a class as a function")}(this,F),!C.disableRebufferTracking){var w,N=function(){if(w){var j=C.data.viewer_time-w;t(C.data,"view_rebuffer_duration",j),w=C.data.viewer_time}C.data.view_watch_time>=0&&C.data.view_rebuffer_count>0&&(C.data.view_rebuffer_frequency=C.data.view_rebuffer_count/C.data.view_watch_time,C.data.view_rebuffer_percentage=C.data.view_rebuffer_duration/C.data.view_watch_time)};C.on("playbackheartbeat",function(){return N()}),C.on("rebufferstart",function(){w||(t(C.data,"view_rebuffer_count",1),w=C.data.viewer_time,C.one("rebufferend",function(){N(),w=void 0}))})}});function Me(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var Oe=function(){function F(j){var V=this;(function(H,$){if(!(H instanceof $))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=j,j.disableRebufferTracking||j.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,j.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),j.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),j.on("seeking",function(){V._cleanupRebufferTracker(null,{viewer_time:h.now()})}))}var C,w,N;return C=F,w=[{key:"_checkIfRebuffering",value:function(j,V){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(j,V);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var H=V.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&H>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=V.viewer_time}else this._cleanupRebufferTracker(j,V,!0);else this._prepareRebufferTrackerState(V.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(j){this._lastCheckedTime=j,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=j}},{key:"_cleanupRebufferTracker",value:function(j,V){var H=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:V.viewer_time});else{if(this._lastCheckedTime===null)return;var $=this.pm.data.player_playhead_time-this._lastPlayheadTime,Z=V.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&$>0&&Z-$>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+Z-$}))}H?this._prepareRebufferTrackerState(V.viewer_time):this._clearRebufferTrackerState()}}],w&&Me(C.prototype,w),N&&Me(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}(),Ne=Oe;function Pe(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var Ke=function(){function F(j){var V=this;(function(H,$){if(!(H instanceof $))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=j,j.on("viewinit",function(){var H=j.data,$=H.view_id;if(!H.view_program_changed){var Z=function(Q,ne){var me=ne.viewer_time;Q.type==="playing"&&j.data.view_time_to_first_frame===void 0?V.calculateTimeToFirstFrame(me||h.now(),$):Q.type!=="adplaying"||j.data.view_time_to_first_frame!==void 0&&!V._inPrerollPosition()||V.calculateTimeToFirstFrame(me||h.now(),$)};j.one("playing",Z),j.one("adplaying",Z),j.one("viewend",function(){j.off("playing",Z),j.off("adplaying",Z)})}})}var C,w,N;return C=F,(w=[{key:"_inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(j,V){V===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:j}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}])&&Pe(C.prototype,w),N&&Pe(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function ge(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function ke(F,C,w){return C&&ge(F.prototype,C),w&&ge(F,w),Object.defineProperty(F,"prototype",{writable:!1}),F}var je=ke(function F(C){var w=this;(function(N,j){if(!(N instanceof j))throw new TypeError("Cannot call a class as a function")})(this,F),C.on("viewinit",function(){w._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(N){C.on(N,function(){if(w._lastPlayheadPosition>=0&&C.data.player_playhead_time>=0&&w._lastPlayerWidth>=0&&w._lastSourceWidth>0&&w._lastPlayerHeight>=0&&w._lastSourceHeight>0){var j=C.data.player_playhead_time-w._lastPlayheadPosition;if(j<0)return void(w._lastPlayheadPosition=-1);var V=Math.min(w._lastPlayerWidth/w._lastSourceWidth,w._lastPlayerHeight/w._lastSourceHeight),H=Math.max(0,V-1),$=Math.max(0,1-V);C.data.view_max_upscale_percentage=Math.max(C.data.view_max_upscale_percentage||0,H),C.data.view_max_downscale_percentage=Math.max(C.data.view_max_downscale_percentage||0,$),t(C.data,"view_total_content_playback_time",j),t(C.data,"view_total_upscaling",H*j),t(C.data,"view_total_downscaling",$*j)}w._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(N){C.on(N,function(){w._lastPlayheadPosition=C.data.player_playhead_time,w._lastPlayerWidth=C.data.player_width,w._lastPlayerHeight=C.data.player_height,w._lastSourceWidth=C.data.video_source_width,w._lastSourceHeight=C.data.video_source_height})})});function He(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function We(F,C,w){return C&&He(F.prototype,C),w&&He(F,w),Object.defineProperty(F,"prototype",{writable:!1}),F}var Ye=We(function F(C){var w=this;(function(N,j){if(!(N instanceof j))throw new TypeError("Cannot call a class as a function")})(this,F),this.isSeeking=!1,C.on("seeking",function(N,j){i()(C.data,j),w._lastSeekingTime=h.now(),w.isSeeking===!1&&(w.isSeeking=!0,C.send("seeking"))}),C.on("seeked",function(){w.isSeeking=!1;var N=w._lastSeekingTime||h.now(),j=h.now()-N;t(C.data,"view_seek_count",1),t(C.data,"view_seek_duration",j);var V=C.data.view_max_seek_time||0;C.data.view_max_seek_time=Math.max(V,j)}),C.on("viewend",function(){w.isSeeking=!1})});function Ge(F,C){return function(w){if(Array.isArray(w))return w}(F)||function(w,N){var j=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(j!=null){var V,H,$=[],Z=!0,Q=!1;try{for(j=j.call(w);!(Z=(V=j.next()).done)&&($.push(V.value),!N||$.length!==N);Z=!0);}catch(ne){Q=!0,H=ne}finally{try{Z||j.return==null||j.return()}finally{if(Q)throw H}}return $}}(F,C)||function(w,N){if(w){if(typeof w=="string")return nt(w,N);var j=Object.prototype.toString.call(w).slice(8,-1);return j==="Object"&&w.constructor&&(j=w.constructor.name),j==="Map"||j==="Set"?Array.from(w):j==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(j)?nt(w,N):void 0}}(F,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function nt(F,C){(C==null||C>F.length)&&(C=F.length);for(var w=0,N=new Array(C);w<C;w++)N[w]=F[w];return N}function we(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var Be=function(F,C){F.push(C),F.sort(function(w,N){return w.viewer_time-N.viewer_time})},$e=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Ue=function(){function F(j){var V=this;(function($,Z){if(!($ instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=j,j.on("viewinit",function(){V.isAdBreak=!1,V._currentAdRequestNumber=0,V._currentAdResponseNumber=0,V._adRequests=[],V._adResponses=[],V._adHasPlayed=!1,V._wouldBeNewAdPlay=!0,V._prerollPlayTime=void 0}),$e.forEach(function($){return j.on($,V._updateAdData.bind(V))});var H=function(){V.isAdBreak=!1};j.on("adbreakstart",function(){V.isAdBreak=!0}),j.on("play",H),j.on("playing",H),j.on("viewend",H),j.on("adrequest",function($,Z){Z=i()({ad_request_id:"generatedAdRequestId"+V._currentAdRequestNumber++},Z),Be(V._adRequests,Z),t(j.data,"view_ad_request_count"),V.inPrerollPosition()&&(j.data.view_preroll_requested=!0,V._adHasPlayed||t(j.data,"view_preroll_request_count"))}),j.on("adresponse",function($,Z){Z=i()({ad_request_id:"generatedAdRequestId"+V._currentAdResponseNumber++},Z),Be(V._adResponses,Z);var Q=V.findAdRequest(Z.ad_request_id);Q&&t(j.data,"view_ad_request_time",Math.max(0,Z.viewer_time-Q.viewer_time))}),j.on("adplay",function($,Z){V._adHasPlayed=!0,V._wouldBeNewAdPlay&&(V._wouldBeNewAdPlay=!1,t(j.data,"view_ad_played_count")),V.inPrerollPosition()&&!j.data.view_preroll_played&&(j.data.view_preroll_played=!0,V._adRequests.length>0&&(j.data.view_preroll_request_time=Math.max(0,Z.viewer_time-V._adRequests[0].viewer_time)),j.data.view_start&&(j.data.view_startup_preroll_request_time=Math.max(0,Z.viewer_time-j.data.view_start)),V._prerollPlayTime=Z.viewer_time)}),j.on("adplaying",function($,Z){V.inPrerollPosition()&&j.data.view_preroll_load_time===void 0&&V._prerollPlayTime!==void 0&&(j.data.view_preroll_load_time=Z.viewer_time-V._prerollPlayTime,j.data.view_startup_preroll_load_time=Z.viewer_time-V._prerollPlayTime)}),j.on("adended",function(){V._wouldBeNewAdPlay=!0}),j.on("aderror",function(){V._wouldBeNewAdPlay=!0})}var C,w,N;return C=F,(w=[{key:"inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(j){for(var V=0;V<this._adRequests.length;V++)if(this._adRequests[V].ad_request_id===j)return this._adRequests[V]}},{key:"_updateAdData",value:function(j,V){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&V.ad_tag_url){var H=Ge(l(V.ad_tag_url),2),$=H[0],Z=H[1];this.pm.data.view_preroll_ad_tag_domain=Z,this.pm.data.view_preroll_ad_tag_hostname=$}if(!this.pm.data.view_preroll_ad_asset_hostname&&V.ad_asset_url){var Q=Ge(l(V.ad_asset_url),2),ne=Q[0],me=Q[1];this.pm.data.view_preroll_ad_asset_domain=me,this.pm.data.view_preroll_ad_asset_hostname=ne}}}}])&&we(C.prototype,w),N&&we(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function Ie(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function ot(F,C,w){return C&&Ie(F.prototype,C),w&&Ie(F,w),Object.defineProperty(F,"prototype",{writable:!1}),F}var ze=ot(function F(C){var w,N;(function($,Z){if(!($ instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,F);var j=function(){C.disableRebufferTracking||w&&(t(C.data,"view_waiting_rebuffer_duration",h.now()-w),w=!1,_().clearInterval(N))},V=!1,H=function(){V=!1,j()};C.on("waiting",function(){V&&(C.disableRebufferTracking||(t(C.data,"view_waiting_rebuffer_count",1),w=h.now(),N=_().setInterval(function(){if(w){var $=h.now();t(C.data,"view_waiting_rebuffer_duration",$-w),w=$}},250)))}),C.on("playing",function(){j(),V=!0}),C.on("pause",H),C.on("seeking",H)});function dt(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function St(F,C,w){return C&&dt(F.prototype,C),w&&dt(F,w),Object.defineProperty(F,"prototype",{writable:!1}),F}var qe=St(function F(C){var w=this;(function(V,H){if(!(V instanceof H))throw new TypeError("Cannot call a class as a function")})(this,F);var N=function(){w.lastWallClockTime=h.now(),C.on("before*",j)},j=function(V){var H=h.now(),$=w.lastWallClockTime;w.lastWallClockTime=H,H-$>3e4&&(C.emit("devicesleep",{viewer_time:$}),i()(C.data,{viewer_time:$}),C.send("devicesleep"),C.emit("devicewake",{viewer_time:H}),i()(C.data,{viewer_time:H}),C.send("devicewake"))};C.one("playbackheartbeat",N),C.on("playbackheartbeatend",function(){C.off("before*",j),C.one("playbackheartbeat",N)})}),Rt=R(375),Dt=R(655),lt=R.n(Dt),ct="muxData",ut=function(){var F;try{F=Rt.parse(lt().get(ct)||"")}catch{F={}}return F},At=function(F){try{lt().set(ct,Rt.stringify(F),{expires:7300})}catch{}},Tt=function(){var F=ut();return F.mux_viewer_id=F.mux_viewer_id||y(),F.msn=F.msn||Math.random(),At(F),{mux_viewer_id:F.mux_viewer_id,mux_sample_number:F.msn}};function Sr(F,C){var w=C.beaconCollectionDomain,N=C.beaconDomain;if(w)return"https://"+w;var j=N||"litix.io";return(F=F||"inferred").match(/^[a-z0-9]+$/)?"https://"+F+"."+j:"https://img.litix.io/a.gif"}var Kt=function(){var F;switch(Pt()){case"cellular":F="cellular";break;case"ethernet":F="wired";break;case"wifi":F="wifi";break;case void 0:break;default:F="other"}return F},Pt=function(){var F=_().navigator,C=F&&(F.connection||F.mozConnection||F.webkitConnection);return C&&C.type};Kt.getConnectionFromAPI=Pt;var et=Kt,or=lr({a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"}),jt=lr({ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function lr(F){var C={};for(var w in F)F.hasOwnProperty(w)&&(C[F[w]]=w);return C}function Wt(F){var C={},w={};return Object.keys(F).forEach(function(N){var j=!1;if(F.hasOwnProperty(N)&&F[N]!==void 0){var V=N.split("_"),H=V[0],$=or[H];$||(e.info("Data key word `"+V[0]+"` not expected in "+N),$=H+"_"),V.splice(1).forEach(function(Z){Z==="url"&&(j=!0),jt[Z]?$+=jt[Z]:Number(Z)&&Math.floor(Number(Z))===Number(Z)?$+=Z:(e.info("Data key word `"+Z+"` not expected in "+N),$+="_"+Z+"_")}),j?w[$]=F[N]:C[$]=F[N]}}),i()(C,w)}var Dr={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},Ar=["hb","requestcompleted","requestfailed","requestcanceled"],ft=function(F,C){this._beaconUrl=F||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=i()({},Dr,C)};ft.prototype.queueEvent=function(F,C){var w=i()({},C);return(this._eventQueue.length<=this._options.maxQueueLength||F==="eventrateexceeded")&&(this._eventQueue.push(w),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},ft.prototype.flushEvents=function(){this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()},ft.prototype.destroy=function(){var F=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,F?this._clearBeaconQueue():this.flushEvents(),_().clearTimeout(this._sendTimeout)},ft.prototype._clearBeaconQueue=function(){var F=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,C=this._eventQueue.slice(F);F>0&&i()(C[C.length-1],Wt({mux_view_message:"event queue truncated"}));var w=this._createPayload(C);It(this._beaconUrl,w,!0,function(){})},ft.prototype._sendBeaconQueue=function(){var F=this;if(!this._postInFlight){var C=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var w=this._createPayload(C),N=h.now();It(this._beaconUrl,w,!1,function(j,V){V?(F._eventQueue=C.concat(F._eventQueue),F._failureCount+=1,e.info("Error sending beacon: "+V)):F._failureCount=0,F._roundTripTime=h.now()-N,F._postInFlight=!1})}},ft.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var F=Math.pow(2,this._failureCount-1);return(1+(F*=Math.random()))*this._options.baseTimeBetweenBeacons},ft.prototype._startBeaconSending=function(){var F=this;_().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=_().setTimeout(function(){F._eventQueue.length&&F._sendBeaconQueue(),F._startBeaconSending()},this._getNextBeaconTime()))},ft.prototype._createPayload=function(F){var C,w,N,j=this,V={transmission_timestamp:Math.round(h.now())};this._roundTripTime&&(V.rtt_ms=Math.round(this._roundTripTime));var H=function(){C=JSON.stringify({metadata:V,events:w||F}),N=C.length/1024},$=function(){return N<=j._options.maxPayloadKBSize};return H(),$()||(e.info("Payload size is too big ("+N+" kb). Removing unnecessary events."),w=F.filter(function(Z){return Ar.indexOf(Z.e)===-1}),H()),$()||(e.info("Payload size still too big ("+N+" kb). Cropping fields.."),w.forEach(function(Z){for(var Q in Z){var ne=Z[Q];typeof ne=="string"&&ne.length>51200&&(Z[Q]=ne.substring(0,51200))}}),H()),C};var It=function(F,C,w,N){if(w&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(F,C))N();else if(_().fetch)_().fetch(F,{method:"POST",body:C,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(V){return N(null,V.ok?null:"Error")}).catch(function(V){return N(null,V)});else{if(_().XMLHttpRequest){var j=new(_()).XMLHttpRequest;return j.onreadystatechange=function(){if(j.readyState===4)return N(null,j.status!==200?"error":void 0)},j.open("POST",F),j.setRequestHeader("Content-Type","text/plain"),void j.send(C)}N()}},ur=ft;function Lt(F){return Lt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},Lt(F)}var Lr=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id"],ji=["viewstart","error","ended","viewend"],fr=function(F,C){var w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=F,this.envKey=C,this.eventQueue=new ur(Sr(C,w)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=w.sampleRate,this.disableCookies=w.disableCookies,this.respectDoNotTrack=w.respectDoNotTrack;var N=w.platform||{};this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:N.name,viewer_application_version:N.version,viewer_application_engine:N.layout,viewer_device_name:N.product,viewer_device_category:"",viewer_device_manufacturer:N.manufacturer,viewer_os_family:N.os&&N.os.family,viewer_os_architecture:N.os&&N.os.architecture,viewer_os_version:N.os&&N.os.version};var j=et();j&&(this.pageLevelData=i()(this.pageLevelData,{viewer_connection_type:j})),_()!==void 0&&_().location&&_().location.href&&(this.pageLevelData.page_url=_().location.href),this.viewerData=this.disableCookies?{}:Tt()};fr.prototype.send=function(F,C){if(F){if(this.respectDoNotTrack&&o())return e.info("Not sending `"+F+"` because Do Not Track is enabled");if(!C||Lt(C)!=="object")return e.error("A data object was expected in send() but was not provided");var w,N,j=this.disableCookies?{}:(w=ut(),N=h.now(),w.session_start&&(w.sst=w.session_start,delete w.session_start),w.session_id&&(w.sid=w.session_id,delete w.session_id),w.session_expires&&(w.sex=w.session_expires,delete w.session_expires),(!w.sex||w.sex<N)&&(w.sid=y(),w.sst=N),w.sex=N+15e5,At(w),{session_id:w.sid,session_start:w.sst,session_expires:w.sex}),V={};i()(V,this.pageLevelData),i()(V,C),i()(V,j),i()(V,this.viewerData),V.event=F,V.env_key=this.envKey,V.user_id&&(V.viewer_user_id=V.user_id,delete V.user_id);var H=V.mux_sample_number>=this.sampleRate,$=Wt(this._deduplicateBeaconData(F,V));if(this.lastEventTime=this.mux.utils.now(),H)return e.info("Not sending event due to sample rate restriction",F,V,$);if(this.envKey||e.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",F,V,$),!this.rateLimited){if(e.info("Sending event",F,V,$),this.rateLimited=!this.eventQueue.queueEvent(F,$),this.mux.WINDOW_UNLOADING&&F==="viewend")this.eventQueue.destroy(!0);else if((ji.indexOf(F)>=0||this.mux.WINDOW_HIDDEN&&F==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return V.event="eventrateexceeded",$=Wt(V),this.eventQueue.queueEvent(V.event,$),e.error("Beaconing disabled due to rate limit.")}}},fr.prototype.destroy=function(){this.eventQueue.destroy(!1)},fr.prototype._deduplicateBeaconData=function(F,C){var w=this,N={},j=C.view_id;if(!j||F==="viewstart"||F==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)N=i()({},C),j&&(this.previousBeaconData=N),j&&F==="viewend"&&(this.previousBeaconData=null);else{var V=F.indexOf("request")===0;Object.keys(C).forEach(function(H){var $=C[H];($!==w.previousBeaconData[H]||Lr.indexOf(H)>-1||function(Z,Q,ne,me){return!(!Z||Q.indexOf("request_")!==0||Q!=="request_response_headers"&&Lt(ne)==="object"&&Lt(me)==="object"&&Object.keys(ne||{}).length===Object.keys(me||{}).length)}(V,H,$,w.previousBeaconData[H])||function(Z,Q){return Z==="renditionchange"&&Q.indexOf("video_source_")===0}(F,H))&&(N[H]=$,w.previousBeaconData[H]=$)})}return N};var Wi=fr;function ti(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function Gi(F,C,w){return C&&ti(F.prototype,C),w&&ti(F,w),Object.defineProperty(F,"prototype",{writable:!1}),F}var Hi=Gi(function F(C){(function(Q,ne){if(!(Q instanceof ne))throw new TypeError("Cannot call a class as a function")})(this,F);var w=0,N=0,j=0,V=0,H=0,$=0,Z=0;C.on("requestcompleted",function(Q,ne){var me,Ae,Te=ne.request_start,le=ne.request_response_start,de=ne.request_response_end,Le=ne.request_bytes_loaded;if(V++,le?(me=le-Te,Ae=de-le):Ae=de-Te,Ae>0&&Le>0){var Je=Le/Ae*8e3;H++,N+=Le,j+=Ae,C.data.view_min_request_throughput=Math.min(C.data.view_min_request_throughput||1/0,Je),C.data.view_average_request_throughput=N/j*8e3,C.data.view_request_count=V,me>0&&(w+=me,C.data.view_max_request_latency=Math.max(C.data.view_max_request_latency||0,me),C.data.view_average_request_latency=w/H)}}),C.on("requestfailed",function(Q,ne){V++,$++,C.data.view_request_count=V,C.data.view_request_failed_count=$}),C.on("requestcanceled",function(Q,ne){V++,Z++,C.data.view_request_count=V,C.data.view_request_canceled_count=Z})});function ri(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function Vi(F,C,w){return C&&ri(F.prototype,C),w&&ri(F,w),Object.defineProperty(F,"prototype",{writable:!1}),F}var Yi=Vi(function F(C){var w=this;(function(N,j){if(!(N instanceof j))throw new TypeError("Cannot call a class as a function")})(this,F),C.on("before*",function(N,j){var V=j.viewer_time,H=h.now(),$=w._lastEventTime;if(w._lastEventTime=H,$&&H-$>36e5){var Z=Object.keys(C.data).reduce(function(Q,ne){return ne.indexOf("video_")===0?i()(Q,function(me,Ae,Te){return Ae in me?Object.defineProperty(me,Ae,{value:Te,enumerable:!0,configurable:!0,writable:!0}):me[Ae]=Te,me}({},ne,C.data[ne])):Q},{});C.mux.log.info("Received event after at least an hour inactivity, creating a new view"),C.emit("viewinit",i()({viewer_time:V},Z)),C.playbackHeartbeat._playheadShouldBeProgressing&&N.type!=="play"&&N.type!=="adbreakstart"&&(C.emit("play",{viewer_time:V}),N.type!=="playing"&&C.emit("playing",{viewer_time:V}))}})});function _r(F){return _r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},_r(F)}function zi(F,C){return function(w){if(Array.isArray(w))return w}(F)||function(w,N){var j=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(j!=null){var V,H,$=[],Z=!0,Q=!1;try{for(j=j.call(w);!(Z=(V=j.next()).done)&&($.push(V.value),!N||$.length!==N);Z=!0);}catch(ne){Q=!0,H=ne}finally{try{Z||j.return==null||j.return()}finally{if(Q)throw H}}return $}}(F,C)||function(w,N){if(w){if(typeof w=="string")return ii(w,N);var j=Object.prototype.toString.call(w).slice(8,-1);return j==="Object"&&w.constructor&&(j=w.constructor.name),j==="Map"||j==="Set"?Array.from(w):j==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(j)?ii(w,N):void 0}}(F,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function ii(F,C){(C==null||C>F.length)&&(C=F.length);for(var w=0,N=new Array(C);w<C;w++)N[w]=F[w];return N}function ni(F,C){for(var w=0;w<C.length;w++){var N=C[w];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function br(F,C){return br=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(w,N){return w.__proto__=N,w},br(F,C)}function Xi(F){var C=function(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var w,N=dr(F);if(C){var j=dr(this).constructor;w=Reflect.construct(N,arguments,j)}else w=N.apply(this,arguments);return Qi(this,w)}}function Qi(F,C){if(C&&(_r(C)==="object"||typeof C=="function"))return C;if(C!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ve(F)}function Ve(F){if(F===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return F}function dr(F){return dr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(C){return C.__proto__||Object.getPrototypeOf(C)},dr(F)}var $i=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],Ji=function(F){(function(H,$){if(typeof $!="function"&&$!==null)throw new TypeError("Super expression must either be null or a function");H.prototype=Object.create($&&$.prototype,{constructor:{value:H,writable:!0,configurable:!0}}),Object.defineProperty(H,"prototype",{writable:!1}),$&&br(H,$)})(V,F);var C,w,N,j=Xi(V);function V(H,$,Z){var Q;(function(le,de){if(!(le instanceof de))throw new TypeError("Cannot call a class as a function")})(this,V),(Q=j.call(this)).DOM_CONTENT_LOADED_EVENT_END=c.domContentLoadedEventEnd(),Q.NAVIGATION_START=c.navigationStart(),Q.mux=H,Q.id=$,(Z=i()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(le){return le}},Z)).data=Z.data||{},Z.data.property_key&&(Z.data.env_key=Z.data.property_key,delete Z.data.property_key),e.setLevel(Z.debug?"debug":"warn"),Q.getPlayheadTime=Z.getPlayheadTime,Q.getStateData=Z.getStateData||function(){return{}},Q.getAdData=Z.getAdData||function(){},Q.minimumRebufferDuration=Z.minimumRebufferDuration,Q.sustainedRebufferThreshold=Z.sustainedRebufferThreshold,Q.playbackHeartbeatTime=Z.playbackHeartbeatTime,Q.disableRebufferTracking=Z.disableRebufferTracking,Q.disableRebufferTracking&&Q.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),Q.disablePlayheadRebufferTracking=Z.disablePlayheadRebufferTracking,Q.errorTranslator=Z.errorTranslator,Q.playbackEventDispatcher=new Wi(H,Z.data.env_key,Z),Q.data={player_instance_id:y(),mux_sample_rate:Z.sampleRate,beacon_domain:Z.beaconCollectionDomain?Z.beaconCollectionDomain:Z.beaconDomain},Q.data.view_sequence_number=1,Q.data.player_sequence_number=1,Q.oldEmit=Q.emit,Q.emit=function(le,de){de=i()({viewer_time:this.mux.utils.now()},de),this.oldEmit(le,de)};var ne=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(Ve(Q));Q.on("viewinit",function(le,de){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),i()(this.data,de),this._initializeViewData(),this.one("play",ne),this.one("adbreakstart",ne)});var me=function(le){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",le)}.bind(Ve(Q));if(Q.on("videochange",function(le,de){me(de)}),Q.on("programchange",function(le,de){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),me(i()(de,{view_program_changed:!0})),ne(),this.emit("play"),this.emit("playing")}),Q.on("fragmentchange",function(le,de){this.currentFragmentPDT=de.currentFragmentPDT,this.currentFragmentStart=de.currentFragmentStart}),Q.on("destroy",Q.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var Ae=function(){var le=Q.data.view_start!==void 0;Q.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",le&&Q.mux.WINDOW_HIDDEN&&(Q.data.player_is_paused||Q.emit("hb"))};window.addEventListener("visibilitychange",Ae,!1);var Te=function(le){le.persisted||Q.destroy()};window.addEventListener("pagehide",Te,!1),Q.on("destroy",function(){window.removeEventListener("visibilitychange",Ae),window.removeEventListener("pagehide",Te)})}return Q.on("playerready",function(le,de){i()(this.data,de)}),$i.forEach(function(le){Q.on(le,function(de,Le){le.indexOf("ad")!==0&&this._updateStateData(),i()(this.data,Le),this._sanitizeData()}),Q.on("after"+le,function(){(le!=="error"||this.errorTracker.viewErrored)&&this.send(le)})}),Q.on("viewend",function(le,de){i()(Q.data,de)}),Q.one("playerready",function(le){var de=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=de-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time}),Q.longResumeTracker=new Yi(Ve(Q)),Q.errorTracker=new q(Ve(Q)),new qe(Ve(Q)),Q.seekingTracker=new Ye(Ve(Q)),Q.playheadTime=new re(Ve(Q)),Q.playbackHeartbeat=new J(Ve(Q)),new je(Ve(Q)),Q.watchTimeTracker=new ae(Ve(Q)),new oe(Ve(Q)),Q.adTracker=new Ue(Ve(Q)),new Ne(Ve(Q)),new Se(Ve(Q)),new Ke(Ve(Q)),new ze(Ve(Q)),new Hi(Ve(Q)),Z.hlsjs&&Q.addHLSJS(Z),Z.dashjs&&Q.addDashJS(Z),Q.emit("viewinit",Z.data),Q}return C=V,w=[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(H){var $=i()({},this.data);if($.video_source_is_live===void 0&&($.player_source_duration===1/0||$.video_source_duration===1/0?$.video_source_is_live=!0:($.player_source_duration>0||$.video_source_duration>0)&&($.video_source_is_live=!1)),$.video_source_is_live||["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"].forEach(function(me){$[me]=void 0}),$.video_source_url=$.video_source_url||$.player_source_url,$.video_source_url){var Z=zi(l($.video_source_url),2),Q=Z[0],ne=Z[1];$.video_source_domain=ne,$.video_source_hostname=Q}delete $.ad_request_id,this.playbackEventDispatcher.send(H,$),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){i()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var H=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function($){var Z=parseInt(H.data[$],10);H.data[$]=isNaN(Z)?void 0:Z}),["player_source_url","video_source_url"].forEach(function($){if(H.data[$]){var Z=H.data[$].toLowerCase();Z.indexOf("data:")!==0&&Z.indexOf("blob:")!==0||(H.data[$]="MSE style URL")}})}},{key:"_resetVideoData",value:function(H,$){var Z=this;Object.keys(this.data).forEach(function(Q){Q.indexOf("video_")===0&&delete Z.data[Q]})}},{key:"_resetViewData",value:function(){var H=this;Object.keys(this.data).forEach(function($){$.indexOf("view_")===0&&delete H.data[$]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(H,$){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var H=this,$=this.data.view_id=y(),Z=function(){$===H.data.view_id&&t(H.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",Z):Z()}},{key:"_restartHeartBeat",value:function(){var H=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){H.data.player_is_paused||H.emit("hb")},1e4))}},{key:"addHLSJS",value:function(H){H.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=H.hlsjs,function($,Z,Q){var ne=arguments.length>4?arguments[4]:void 0,me=$.log,Ae=$.utils.secondsToMs,Te=function(De){var fe,pe=parseInt(ne.version);return pe===1&&De.programDateTime!==null&&(fe=De.programDateTime),pe===0&&De.pdt!==null&&(fe=De.pdt),fe};if(c.exists()){var le=function(De,fe){return $.emit(Z,De,fe)},de=function(De,fe){var pe=fe.levels,ce=fe.audioTracks,xe=fe.url,Fe=fe.stats,Re=fe.networkDetails,st=fe.sessionData,it={},ht={};pe.forEach(function(mt,Vt){it[Vt]={width:mt.width,height:mt.height,bitrate:mt.bitrate,attrs:mt.attrs}}),ce.forEach(function(mt,Vt){ht[Vt]={name:mt.name,language:mt.lang,bitrate:mt.bitrate}});var vt=x(Fe),gt=vt.bytesLoaded,Qe=vt.requestStart,Ir=vt.responseStart,Cr=vt.responseEnd;le("requestcompleted",v(v({},s(st)),{},{request_event_type:De,request_bytes_loaded:gt,request_start:Qe,request_response_start:Ir,request_response_end:Cr,request_type:"manifest",request_hostname:r(xe),request_response_headers:P(Re),request_rendition_lists:{media:it,audio:ht,video:{}}}))};Q.on(ne.Events.MANIFEST_LOADED,de);var Le=function(De,fe){var pe=fe.details,ce=fe.level,xe=fe.networkDetails,Fe=fe.stats,Re=x(Fe),st=Re.bytesLoaded,it=Re.requestStart,ht=Re.responseStart,vt=Re.responseEnd,gt=pe.fragments[pe.fragments.length-1],Qe=Te(gt)+Ae(gt.duration);le("requestcompleted",{request_event_type:De,request_bytes_loaded:st,request_start:it,request_response_start:ht,request_response_end:vt,request_current_level:ce,request_type:"manifest",request_hostname:r(pe.url),request_response_headers:P(xe),video_holdback:pe.holdBack&&Ae(pe.holdBack),video_part_holdback:pe.partHoldBack&&Ae(pe.partHoldBack),video_part_target_duration:pe.partTarget&&Ae(pe.partTarget),video_target_duration:pe.targetduration&&Ae(pe.targetduration),video_source_is_live:pe.live,player_manifest_newest_program_time:isNaN(Qe)?void 0:Qe})};Q.on(ne.Events.LEVEL_LOADED,Le);var Je=function(De,fe){var pe=fe.details,ce=fe.networkDetails,xe=fe.stats,Fe=x(xe),Re=Fe.bytesLoaded,st=Fe.requestStart,it=Fe.responseStart,ht=Fe.responseEnd;le("requestcompleted",{request_event_type:De,request_bytes_loaded:Re,request_start:st,request_response_start:it,request_response_end:ht,request_type:"manifest",request_hostname:r(pe.url),request_response_headers:P(ce)})};Q.on(ne.Events.AUDIO_TRACK_LOADED,Je);var tt=function(De,fe){var pe=fe.stats,ce=fe.networkDetails,xe=fe.frag;pe=pe||xe.stats;var Fe=x(pe),Re={request_event_type:De,request_bytes_loaded:Fe.bytesLoaded,request_start:Fe.requestStart,request_response_start:Fe.responseStart,request_response_end:Fe.responseEnd,request_hostname:ce?r(ce.responseURL):void 0,request_response_headers:P(ce),request_media_duration:xe.duration};xe.type==="main"?(Re.request_type="media",Re.request_current_level=xe.level,Re.request_video_width=(Q.levels[xe.level]||{}).width,Re.request_video_height=(Q.levels[xe.level]||{}).height):Re.request_type=xe.type,le("requestcompleted",Re)};Q.on(ne.Events.FRAG_LOADED,tt);var _t=function(De,fe){var pe=fe.frag,ce=pe.start,xe={currentFragmentPDT:Te(pe),currentFragmentStart:Ae(ce)};le("fragmentchange",xe)};Q.on(ne.Events.FRAG_CHANGED,_t);var _e=function(De,fe){var pe=fe.type,ce=fe.details,xe=fe.response,Fe=fe.fatal,Re=fe.context,st=fe.frag;if(ce===ne.ErrorDetails.MANIFEST_LOAD_ERROR||ce===ne.ErrorDetails.MANIFEST_LOAD_TIMEOUT||ce===ne.ErrorDetails.FRAG_LOAD_ERROR||ce===ne.ErrorDetails.FRAG_LOAD_TIMEOUT||ce===ne.ErrorDetails.LEVEL_LOAD_ERROR||ce===ne.ErrorDetails.LEVEL_LOAD_TIMEOUT){var it=st&&st.url||Re&&Re.url||"";le("requestfailed",{request_error:ce,request_url:it,request_hostname:r(it),request_type:ce===ne.ErrorDetails.FRAG_LOAD_ERROR||ce===ne.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:xe&&xe.code,request_error_text:xe&&xe.text})}Fe&&le("error",{player_error_code:pe,player_error_message:ce})};Q.on(ne.Events.ERROR,_e);var rt=function(De,fe){var pe=fe.frag,ce=pe&&pe._url||"";le("requestcanceled",{request_event_type:De,request_url:ce,request_type:"media",request_hostname:r(ce)})};Q.on(ne.Events.FRAG_LOAD_EMERGENCY_ABORTED,rt);var Xe=function(De,fe){var pe=fe.level,ce=Q.levels[pe];if(ce&&ce.attrs&&ce.attrs.BANDWIDTH){var xe,Fe=ce.attrs.BANDWIDTH,Re=parseFloat(ce.attrs["FRAME-RATE"]);isNaN(Re)||(xe=Re),Fe?le("renditionchange",{video_source_fps:xe,video_source_bitrate:Fe,video_source_width:ce.width,video_source_height:ce.height}):me.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};Q.on(ne.Events.LEVEL_SWITCHED,Xe),Q._stopMuxMonitor=function(){Q.off(ne.Events.MANIFEST_LOADED,de),Q.off(ne.Events.LEVEL_LOADED,Le),Q.off(ne.Events.AUDIO_TRACK_LOADED,Je),Q.off(ne.Events.FRAG_LOADED,tt),Q.off(ne.Events.FRAG_CHANGED,_t),Q.off(ne.Events.ERROR,_e),Q.off(ne.Events.FRAG_LOAD_EMERGENCY_ABORTED,rt),Q.off(ne.Events.LEVEL_SWITCHED,Xe),Q.off(ne.Events.DESTROYING,Q._stopMuxMonitor),delete Q._stopMuxMonitor},Q.on(ne.Events.DESTROYING,Q._stopMuxMonitor)}else me.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,H.hlsjs,{},H.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var H;this.hlsjs&&((H=this.hlsjs)&&typeof H._stopMuxMonitor=="function"&&H._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(H){H.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=H.dashjs,function($,Z,Q){var ne=$.log;if(Q&&Q.on){var me=function(_e,rt){return $.emit(Z,_e,rt)},Ae=function(_e){var rt=_e.type,Xe=(_e.data||{}).url;me("requestcompleted",{request_event_type:rt,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:r(Xe)})};Q.on("manifestLoaded",Ae);var Te={},le=function(_e){var rt=_e.type,Xe=_e.fragmentModel,De=(_e.chunk||{}).mediaInfo||{},fe=De.type,pe=De.bitrateList,ce={};(pe=pe||[]).forEach(function(gt,Qe){ce[Qe]={},ce[Qe].width=gt.width,ce[Qe].height=gt.height,ce[Qe].bitrate=gt.bandwidth,ce[Qe].attrs={}}),fe==="video"?Te.video=ce:fe==="audio"?Te.audio=ce:Te.media=ce;var xe=B(Xe,Q),Fe=xe.requestStart,Re=xe.requestResponseStart,st=xe.requestResponseEnd,it=xe.requestResponseHeaders,ht=xe.requestMediaDuration,vt=xe.requestHostname;me("requestcompleted",{request_event_type:rt,request_start:Fe,request_response_start:Re,request_response_end:st,request_bytes_loaded:-1,request_type:fe+"_init",request_response_headers:it,request_hostname:vt,request_media_duration:ht,request_rendition_lists:Te})};Q.on("initFragmentLoaded",le);var de=function(_e){var rt=_e.type,Xe=_e.fragmentModel,De=_e.chunk||{},fe=De.mediaInfo,pe=De.start,ce=(fe||{}).type,xe=B(Xe,Q),Fe=xe.requestStart,Re=xe.requestResponseStart,st=xe.requestResponseEnd,it=xe.requestBytesLoaded,ht=xe.requestResponseHeaders,vt=xe.requestMediaDuration,gt=xe.requestHostname,Qe=k(ce,Q),Ir=Qe.currentLevel,Cr=Qe.renditionWidth,mt=Qe.renditionHeight,Vt=Qe.renditionBitrate;me("requestcompleted",{request_event_type:rt,request_start:Fe,request_response_start:Re,request_response_end:st,request_bytes_loaded:it,request_type:ce,request_response_headers:ht,request_hostname:gt,request_media_start_time:pe,request_media_duration:vt,request_current_level:Ir,request_labeled_bitrate:Vt,request_video_width:Cr,request_video_height:mt})};Q.on("mediaFragmentLoaded",de);var Le={video:void 0,audio:void 0,totalBitrate:void 0},Je=function(){if(Le.video&&typeof Le.video.bitrate=="number"){if(Le.video.width&&Le.video.height){var _e=Le.video.bitrate;return Le.audio&&typeof Le.audio.bitrate=="number"&&(_e+=Le.audio.bitrate),_e!==Le.totalBitrate?(Le.totalBitrate=_e,{video_source_bitrate:_e,video_source_height:Le.video.height,video_source_width:Le.video.width}):void 0}ne.warn("have bitrate info for video but missing width/height")}},tt=function(_e,rt,Xe){if(typeof _e.newQuality=="number"){var De=_e.mediaType;if(De==="audio"||De==="video"){var fe=Q.getBitrateInfoListFor(De).find(function(ce){return ce.qualityIndex===_e.newQuality});if(fe&&typeof fe.bitrate=="number"){Le[De]=fe;var pe=Je();pe&&me("renditionchange",pe)}else ne.warn("missing bitrate info for ".concat(De))}}else ne.warn("missing evt.newQuality in qualityChangeRendered event",_e)};Q.on("qualityChangeRendered",tt);var _t=function(_e){var rt=_e.error,Xe=_e.event,De=(Xe=Xe||{}).request||{},fe=_().event&&_().event.currentTarget||{};me("requestfailed",{request_error:rt+"_"+Xe.id+"_"+De.type,request_url:Xe.url,request_hostname:r(Xe.url),request_type:De.mediaType,request_error_code:fe.status,request_error_type:fe.statusText})};Q.on("error",_t),Q._stopMuxMonitor=function(){Q.off("manifestLoaded",Ae),Q.off("initFragmentLoaded",le),Q.off("mediaFragmentLoaded",de),Q.off("qualityChangeRendered",tt),Q.off("error",_t),delete Q._stopMuxMonitor}}else ne.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,H.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var H;this.dashjs&&((H=this.dashjs)&&typeof H._stopMuxMonitor=="function"&&H._stopMuxMonitor(),this.dashjs=void 0)}}],w&&ni(C.prototype,w),N&&ni(C,N),Object.defineProperty(C,"prototype",{writable:!1}),V}(z),Zi=Ji,qi=R(153),Gt=R.n(qi);function Or(F){return Or=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},Or(F)}function ai(F,C){return function(w){if(Array.isArray(w))return w}(F)||function(w,N){var j=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(j!=null){var V,H,$=[],Z=!0,Q=!1;try{for(j=j.call(w);!(Z=(V=j.next()).done)&&($.push(V.value),!N||$.length!==N);Z=!0);}catch(ne){Q=!0,H=ne}finally{try{Z||j.return==null||j.return()}finally{if(Q)throw H}}return $}}(F,C)||function(w,N){if(w){if(typeof w=="string")return si(w,N);var j=Object.prototype.toString.call(w).slice(8,-1);return j==="Object"&&w.constructor&&(j=w.constructor.name),j==="Map"||j==="Set"?Array.from(w):j==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(j)?si(w,N):void 0}}(F,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
4
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function si(F,C){(C==null||C>F.length)&&(C=F.length);for(var w=0,N=new Array(C);w<C;w++)N[w]=F[w];return N}var Ct,en=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],tn={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};_()&&_().WeakMap&&(Ct=new WeakMap);var rn="#EXT-X-TARGETDURATION",nn="#EXT-X-PART-INF",an="#EXT-X-SERVER-CONTROL",sn="#EXTINF",on="#EXT-X-PROGRAM-DATE-TIME",ln="#EXT-X-VERSION",un="#EXT-X-SESSION-DATA",cr=function(F){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(F),this.manifest};cr.prototype.process=function(F){var C;for(this.buffer+=F,C=this.buffer.indexOf(`
5
5
  `);C>-1;C=this.buffer.indexOf(`
6
- `))this.processLine(this.buffer.substring(0,C)),this.buffer=this.buffer.substring(C+1)},cr.prototype.processLine=function(F){var C=F.indexOf(":"),w=hn(F,C),N=w[0],j=w.length===2?Ir(w[1]):void 0;if(N[0]!=="#")this.currentUri.uri=N,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(N){case rn:if(!isFinite(j)||j<0)return;this.manifest.targetDuration=j,this.setHoldBack();break;case nn:Rr(this.manifest,w),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case an:Rr(this.manifest,w),this.setHoldBack();break;case sn:j===0?this.currentUri.duration=.01:j>0&&(this.currentUri.duration=j);break;case on:var V=j,H=new Date(V);this.manifest.dateTimeString||(this.manifest.dateTimeString=V,this.manifest.dateTimeObject=H),this.currentUri.dateTimeString=V,this.currentUri.dateTimeObject=H;break;case ln:Rr(this.manifest,w);break;case un:var $=vn(w[1]),Z=s($);i()(this.manifest.sessionData,Z)}},cr.prototype.setHoldBack=function(){var F=this.manifest,C=F.serverControl,w=F.targetDuration,N=F.partTargetDuration;if(C){var j="holdBack",V="partHoldBack",H=w&&3*w,$=N&&2*N;w&&!C.hasOwnProperty(j)&&(C[j]=H),H&&C[j]<H&&(C[j]=H),N&&!C.hasOwnProperty(V)&&(C[V]=3*N),N&&C[V]<$&&(C[V]=$)}};var Rr=function(F,C){var w,N=si(C[0].replace("#EXT-X-",""));cn(C[1])?(w={},w=i()(fn(C[1]),w)):w=Ir(C[1]),F[N]=w},si=function(F){return F.toLowerCase().replace(/-(\w)/g,function(C){return C[1].toUpperCase()})},Ir=function(F){if(F.toLowerCase()==="yes"||F.toLowerCase()==="no")return F.toLowerCase()==="yes";var C=F.indexOf(":")!==-1?F:parseFloat(F);return isNaN(C)?F:C},dn=function(F){var C={},w=F.split("=");return w.length>1&&(C[si(w[0])]=Ir(w[1])),C},fn=function(F){for(var C=F.split(","),w={},N=0;C.length>N;N++){var j=C[N],V=dn(j);w=i()(V,w)}return w},cn=function(F){return F.indexOf("=")>-1},hn=function(F,C){return C===-1?[F]:[F.substring(0,C),F.substring(C+1)]},vn=function(F){var C={};if(F){var w=F.search(",");return[F.slice(0,w),F.slice(w+1)].forEach(function(N,j){for(var V=N.replace(/['"]+/g,"").split("="),H=0;H<V.length;H++)V[H]==="DATA-ID"&&(C["DATA-ID"]=V[1-H]),V[H]==="VALUE"&&(C.VALUE=V[1-H])}),{data:C}}},gn=cr,mn={safeCall:function(F,C,w,N){var j=N;if(F&&typeof F[C]=="function")try{j=F[C].apply(F,w)}catch(V){e.info("safeCall error",V)}return j},safeIncrement:t,getComputedStyle:function(F,C){var w;if(F&&C&&_()&&typeof _().getComputedStyle=="function")return Ct&&Ct.has(F)&&(w=Ct.get(F)),w||(w=_().getComputedStyle(F,null),Ct&&Ct.set(F,w)),w.getPropertyValue(C)},secondsToMs:function(F){return Math.floor(1e3*F)},assign:i(),headersStringToObject:u,extractHostnameAndDomain:l,extractHostname:r,manifestParser:gn,generateShortID:T,generateUUID:y,now:h.now},pn={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled"};function En(F,C){return function(w){if(Array.isArray(w))return w}(F)||function(w,N){var j=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(j!=null){var V,H,$=[],Z=!0,Q=!1;try{for(j=j.call(w);!(Z=(V=j.next()).done)&&($.push(V.value),!N||$.length!==N);Z=!0);}catch(ne){Q=!0,H=ne}finally{try{Z||j.return==null||j.return()}finally{if(Q)throw H}}return $}}(F,C)||function(w,N){if(w){if(typeof w=="string")return oi(w,N);var j=Object.prototype.toString.call(w).slice(8,-1);return j==="Object"&&w.constructor&&(j=w.constructor.name),j==="Map"||j==="Set"?Array.from(w):j==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(j)?oi(w,N):void 0}}(F,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
7
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function oi(F,C){(C==null||C>F.length)&&(C=F.length);for(var w=0,N=new Array(C);w<C;w++)N[w]=F[w];return N}var at={},Ht=function F(C){var w=arguments;typeof C=="string"?F.hasOwnProperty(C)?_().setTimeout(function(){w=Array.prototype.splice.call(w,1),F[C].apply(null,w)},0):e.warn("`"+C+"` is an unknown task"):typeof C=="function"?_().setTimeout(function(){C(F)},0):e.warn("`"+C+"` is invalid.")},yn={loaded:h.now(),NAME:"mux-embed",VERSION:"4.14.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(F,C){return function(w,N,j){var V=ni(E(N),3),H=V[0],$=V[1],Z=V[2],Q=w.log,ne=w.utils.getComputedStyle,pe=w.utils.secondsToMs;if(!H)return Q.error("No element was found with the `"+$+"` query selector.");if(Z!=="video"&&Z!=="audio")return Q.error("The element of `"+$+"` was not a media element.");H.mux&&(H.mux.destroy(),delete H.mux,Q.warn("Already monitoring this video element, replacing existing event listeners")),(j=i()({automaticErrorTracking:!0},j)).data=i()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:w.VERSION},j.data),j.getPlayheadTime=function(){return pe(H.currentTime)},j.getStateData=function(){var Te=this.hlsjs&&this.hlsjs.url,le=this.dashjs&&Or(this.dashjs.getSource==="function")&&this.dashjs.getSource(),fe={player_is_paused:H.paused,player_playhead_time:pe(H.currentTime),player_width:parseInt(ne(H,"width")),player_height:parseInt(ne(H,"height")),player_autoplay_on:H.autoplay,player_preload_on:H.preload,player_language_code:H.lang,player_is_fullscreen:Gt()&&!!(Gt().fullscreenElement||Gt().webkitFullscreenElement||Gt().mozFullScreenElement||Gt().msFullscreenElement),video_poster_url:H.poster,video_source_url:Te||le||H.currentSrc,video_source_duration:pe(H.duration),video_source_height:H.videoHeight,video_source_width:H.videoWidth},Le=j.getPlayheadTime();if(H.getStartDate&&Le>0){var Je=H.getStartDate();if(Je&&typeof Je.getTime=="function"&&Je.getTime()){var tt=Je.getTime();if(fe.player_program_time=tt+Le,H.seekable.length>0){var _t=tt+H.seekable.end(H.seekable.length-1);fe.player_live_edge_program_time=_t}}}return fe},H.mux=H.mux||{},H.mux.deleted=!1,H.mux.emit=function(Te,le){w.emit($,Te,le)};var Ae=function(){Q.error("The monitor for this video element has already been destroyed.")};H.mux.destroy=function(){Object.keys(H.mux.listeners).forEach(function(Te){H.removeEventListener(Te,H.mux.listeners[Te],!1)}),delete H.mux.listeners,H.mux.destroy=Ae,H.mux.swapElement=Ae,H.mux.emit=Ae,H.mux.addHLSJS=Ae,H.mux.addDashJS=Ae,H.mux.removeHLSJS=Ae,H.mux.removeDashJS=Ae,H.mux.deleted=!0,w.emit($,"destroy")},H.mux.swapElement=function(Te){var le=ni(E(Te),3),fe=le[0],Le=le[1],Je=le[2];return fe?Je!=="video"&&Je!=="audio"?w.log.error("The element of `"+Le+"` was not a media element."):(fe.muxId=H.muxId,delete H.muxId,fe.mux=fe.mux||{},fe.mux.listeners=i()({},H.mux.listeners),delete H.mux.listeners,Object.keys(fe.mux.listeners).forEach(function(tt){H.removeEventListener(tt,fe.mux.listeners[tt],!1),fe.addEventListener(tt,fe.mux.listeners[tt],!1)}),fe.mux.swapElement=H.mux.swapElement,fe.mux.destroy=H.mux.destroy,delete H.mux,void(H=fe)):w.log.error("No element was found with the `"+Le+"` query selector.")},H.mux.addHLSJS=function(Te){w.addHLSJS($,Te)},H.mux.addDashJS=function(Te){w.addDashJS($,Te)},H.mux.removeHLSJS=function(){w.removeHLSJS($)},H.mux.removeDashJS=function(){w.removeDashJS($)},w.init($,j),w.emit($,"playerready"),H.paused||(w.emit($,"play"),H.readyState>2&&w.emit($,"playing")),H.mux.listeners={},en.forEach(function(Te){(Te!=="error"||j.automaticErrorTracking)&&(H.mux.listeners[Te]=function(){var le={};if(Te==="error"){if(!H.error||H.error.code===1)return;le.player_error_code=H.error.code,le.player_error_message=tn[H.error.code]||H.error.message}w.emit($,Te,le)},H.addEventListener(Te,H.mux.listeners[Te],!1))})}(Ht,F,C)},destroyMonitor:function(F){var C=En(E(F),1)[0];C&&C.mux&&typeof C.mux.destroy=="function"?C.mux.destroy():e.error("A video element monitor for `"+F+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(F,C){var w=D(F);at[w]?at[w].addHLSJS(C):e.error("A monitor for `"+w+"` has not been initialized.")},addDashJS:function(F,C){var w=D(F);at[w]?at[w].addDashJS(C):e.error("A monitor for `"+w+"` has not been initialized.")},removeHLSJS:function(F){var C=D(F);at[C]?at[C].removeHLSJS():e.error("A monitor for `"+C+"` has not been initialized.")},removeDashJS:function(F){var C=D(F);at[C]?at[C].removeDashJS():e.error("A monitor for `"+C+"` has not been initialized.")},init:function(F,C){o()&&C&&C.respectDoNotTrack&&e.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var w=D(F);at[w]=new Zi(Ht,w,C)},emit:function(F,C,w){var N=D(F);at[N]?(at[N].emit(C,w),C==="destroy"&&delete at[N]):e.error("A monitor for `"+N+"` has not been initialized.")},checkDoNotTrack:o,log:e,utils:mn,events:pn,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Ht,yn),_()!==void 0&&typeof _().addEventListener=="function"&&_().addEventListener("pagehide",function(F){F.persisted||(Ht.WINDOW_UNLOADING=!0)},!1);var Tn=Ht},655:function(A,M,R){var O,_;function y(T){return y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(D){return typeof D}:function(D){return D&&typeof Symbol=="function"&&D.constructor===Symbol&&D!==Symbol.prototype?"symbol":typeof D},y(T);}(function(T){var D=!1;if((_=typeof(O=T)=="function"?O.call(M,R,M,A):O)===void 0||(A.exports=_),D=!0,y(M)==="object"&&(A.exports=T(),D=!0),!D){var E=window.Cookies,m=window.Cookies=T();m.noConflict=function(){return window.Cookies=E,m}}})(function(){var T=function(){for(var D=0,E={};D<arguments.length;D++){var m=arguments[D];for(var p in m)E[p]=m[p]}return E};return function D(E){function m(p,d,e){var o;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(e=T({path:"/"},m.defaults,e)).expires=="number"){var h=new Date;h.setMilliseconds(h.getMilliseconds()+864e5*e.expires),e.expires=h}try{o=JSON.stringify(d),/^[\{\[]/.test(o)&&(d=o)}catch{}return d=E.write?E.write(d,p):encodeURIComponent(String(d)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),p=(p=(p=encodeURIComponent(String(p))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[p,"=",d,e.expires?"; expires="+e.expires.toUTCString():"",e.path?"; path="+e.path:"",e.domain?"; domain="+e.domain:"",e.secure?"; secure":""].join("")}p||(o={});for(var g=document.cookie?document.cookie.split("; "):[],i=/(%[0-9A-Z]{2})+/g,r=0;r<g.length;r++){var l=g[r].split("="),c=l.slice(1).join("=");c.charAt(0)==='"'&&(c=c.slice(1,-1));try{var t=l[0].replace(i,decodeURIComponent);if(c=E.read?E.read(c,t):E(c,t)||c.replace(i,decodeURIComponent),this.json)try{c=JSON.parse(c)}catch{}if(p===t){o=c;break}p||(o[t]=c)}catch{}}return o}}return m.set=m,m.get=function(p){return m.call(m,p)},m.getJSON=function(){return m.apply({json:!0},[].slice.call(arguments))},m.defaults={},m.remove=function(p,d){m(p,"",T(d,{expires:-1}))},m.withConverter=D,m}(function(){})})},153:function(A,M,R){var O,_=R.g!==void 0?R.g:typeof window!="undefined"?window:{},y=R(558);typeof document!="undefined"?O=document:(O=_["__GLOBAL_DOCUMENT_CACHE@4"])||(O=_["__GLOBAL_DOCUMENT_CACHE@4"]=y),A.exports=O},48:function(A,M,R){var O;O=typeof window!="undefined"?window:R.g!==void 0?R.g:typeof self!="undefined"?self:{},A.exports=O},678:function(A){var M=9007199254740991,R="[object Arguments]",O="[object Function]",_="[object GeneratorFunction]",y=/^(?:0|[1-9]\d*)$/;function T(S,x,I){switch(I.length){case 0:return S.call(x);case 1:return S.call(x,I[0]);case 2:return S.call(x,I[0],I[1]);case 3:return S.call(x,I[0],I[1],I[2])}return S.apply(x,I)}var D,E,m=Object.prototype,p=m.hasOwnProperty,d=m.toString,e=m.propertyIsEnumerable,o=(D=Object.keys,E=Object,function(S){return D(E(S))}),h=Math.max,g=!e.call({valueOf:1},"valueOf");function i(S,x){var I=a(S)||function(W){return function(G){return function(X){return!!X&&typeof X=="object"}(G)&&u(G)}(W)&&p.call(W,"callee")&&(!e.call(W,"callee")||d.call(W)==R)}(S)?function(W,G){for(var X=-1,Y=Array(W);++X<W;)Y[X]=G(X);return Y}(S.length,String):[],B=I.length,k=!!B;for(var U in S)!x&&!p.call(S,U)||k&&(U=="length"||l(U,B))||I.push(U);return I}function r(S,x,I){var B=S[x];p.call(S,x)&&t(B,I)&&(I!==void 0||x in S)||(S[x]=I)}function l(S,x){return!!(x=x==null?M:x)&&(typeof S=="number"||y.test(S))&&S>-1&&S%1==0&&S<x}function c(S){var x=S&&S.constructor;return S===(typeof x=="function"&&x.prototype||m)}function t(S,x){return S===x||S!=S&&x!=x}var a=Array.isArray;function u(S){return S!=null&&function(x){return typeof x=="number"&&x>-1&&x%1==0&&x<=M}(S.length)&&!function(x){var I=s(x)?d.call(x):"";return I==O||I==_}(S)}function s(S){var x=typeof S;return!!S&&(x=="object"||x=="function")}var f,v=(f=function(S,x){if(g||c(x)||u(x))(function(B,k,U,W){U||(U={});for(var G=-1,X=k.length;++G<X;){var Y=k[G],J=W?W(U[Y],B[Y],Y,U,B):void 0;r(U,Y,J===void 0?B[Y]:J)}})(x,function(B){return u(B)?i(B):function(k){if(!c(k))return o(k);var U=[];for(var W in Object(k))p.call(k,W)&&W!="constructor"&&U.push(W);return U}(B)}(x),S);else for(var I in x)p.call(x,I)&&r(S,I,x[I])},function(S,x){return x=h(x===void 0?S.length-1:x,0),function(){for(var I=arguments,B=-1,k=h(I.length-x,0),U=Array(k);++B<k;)U[B]=I[x+B];B=-1;for(var W=Array(x+1);++B<x;)W[B]=I[B];return W[x]=U,T(S,this,W)}}(function(S,x){var I=-1,B=x.length,k=B>1?x[B-1]:void 0,U=B>2?x[2]:void 0;for(k=f.length>3&&typeof k=="function"?(B--,k):void 0,U&&function(G,X,Y){if(!s(Y))return!1;var J=typeof X;return!!(J=="number"?u(Y)&&l(X,Y.length):J=="string"&&X in Y)&&t(Y[X],G)}(x[0],x[1],U)&&(k=B<3?void 0:k,B=1),S=Object(S);++I<B;){var W=x[I];W&&f(S,W,I,k)}return S}));A.exports=v},640:function(A,M,R){var O,_;(function(y,T){"use strict";O=function(){var D=function(){},E="undefined",m=typeof window!==E&&typeof window.navigator!==E&&/Trident\/|MSIE /.test(window.navigator.userAgent),p=["trace","debug","info","warn","error"];function d(a,u){var s=a[u];if(typeof s.bind=="function")return s.bind(a);try{return Function.prototype.bind.call(s,a)}catch{return function(){return Function.prototype.apply.apply(s,[a,arguments])}}}function e(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function o(a){return a==="debug"&&(a="log"),typeof console!==E&&(a==="trace"&&m?e:console[a]!==void 0?d(console,a):console.log!==void 0?d(console,"log"):D)}function h(a,u){for(var s=0;s<p.length;s++){var f=p[s];this[f]=s<a?D:this.methodFactory(f,a,u)}this.log=this.debug}function g(a,u,s){return function(){typeof console!==E&&(h.call(this,u,s),this[a].apply(this,arguments))}}function i(a,u,s){return o(a)||g.apply(this,arguments)}function r(a,u,s){var f,v=this;u=u==null?"WARN":u;var S="loglevel";function x(U){var W=(p[U]||"silent").toUpperCase();if(typeof window!==E&&S){try{return void(window.localStorage[S]=W)}catch{}try{window.document.cookie=encodeURIComponent(S)+"="+W+";"}catch{}}}function I(){var U;if(typeof window!==E&&S){try{U=window.localStorage[S]}catch{}if(typeof U===E)try{var W=window.document.cookie,G=W.indexOf(encodeURIComponent(S)+"=");G!==-1&&(U=/^([^;]+)/.exec(W.slice(G))[1])}catch{}return v.levels[U]===void 0&&(U=void 0),U}}function B(){if(typeof window!==E&&S){try{return void window.localStorage.removeItem(S)}catch{}try{window.document.cookie=encodeURIComponent(S)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof a=="string"?S+=":"+a:typeof a=="symbol"&&(S=void 0),v.name=a,v.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},v.methodFactory=s||i,v.getLevel=function(){return f},v.setLevel=function(U,W){if(typeof U=="string"&&v.levels[U.toUpperCase()]!==void 0&&(U=v.levels[U.toUpperCase()]),!(typeof U=="number"&&U>=0&&U<=v.levels.SILENT))throw"log.setLevel() called with invalid level: "+U;if(f=U,W!==!1&&x(U),h.call(v,U,a),typeof console===E&&U<v.levels.SILENT)return"No console available for logging"},v.setDefaultLevel=function(U){u=U,I()||v.setLevel(U,!1)},v.resetLevel=function(){v.setLevel(u,!1),B()},v.enableAll=function(U){v.setLevel(v.levels.TRACE,U)},v.disableAll=function(U){v.setLevel(v.levels.SILENT,U)};var k=I();k==null&&(k=u),v.setLevel(k,!1)}var l=new r,c={};l.getLogger=function(a){if(typeof a!="symbol"&&typeof a!="string"||a==="")throw new TypeError("You must supply a name when creating a logger.");var u=c[a];return u||(u=c[a]=new r(a,l.getLevel(),l.methodFactory)),u};var t=typeof window!==E?window.log:void 0;return l.noConflict=function(){return typeof window!==E&&window.log===l&&(window.log=t),l},l.getLoggers=function(){return c},l.default=l,l},(_=typeof O=="function"?O.call(M,R,M,A):O)===void 0||(A.exports=_)})()},375:function(A,M){"use strict";var R=Object.prototype.hasOwnProperty;function O(y){try{return decodeURIComponent(y.replace(/\+/g," "))}catch{return null}}function _(y){try{return encodeURIComponent(y)}catch{return null}}M.stringify=function(y,T){T=T||"";var D,E,m=[];for(E in typeof T!="string"&&(T="?"),y)if(R.call(y,E)){if((D=y[E])||D!=null&&!isNaN(D)||(D=""),E=_(E),D=_(D),E===null||D===null)continue;m.push(E+"="+D)}return m.length?T+m.join("&"):""},M.parse=function(y){for(var T,D=/([^=?#&]+)=?([^&]*)/g,E={};T=D.exec(y);){var m=O(T[1]),p=O(T[2]);m===null||p===null||m in E||(E[m]=p)}return E}},558:function(){}},P={};function L(A){var M=P[A];if(M!==void 0)return M.exports;var R=P[A]={exports:{}};return n[A].call(R.exports,R,R.exports,L),R.exports}return L.n=function(A){var M=A&&A.__esModule?function(){return A.default}:function(){return A};return L.d(M,{a:M}),M},L.d=function(A,M){for(var R in M)L.o(M,R)&&!L.o(A,R)&&Object.defineProperty(A,R,{enumerable:!0,get:M[R]})},L.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),L.o=function(A,M){return Object.prototype.hasOwnProperty.call(A,M)},L(80)}()},typeof vr=="object"&&typeof Ur=="object"?Ur.exports=b():typeof vr=="object"?vr.mux=b():K.mux=b()})()});var gr=li((Qt,Nr)=>{typeof window!="undefined"&&function(b,n){typeof Qt=="object"&&typeof Nr=="object"?Nr.exports=n():typeof define=="function"&&define.amd?define([],n):typeof Qt=="object"?Qt.Hls=n():b.Hls=n()}(Qt,function(){return function(K){var b={};function n(P){if(b[P])return b[P].exports;var L=b[P]={i:P,l:!1,exports:{}};return K[P].call(L.exports,L,L.exports,n),L.l=!0,L.exports}return n.m=K,n.c=b,n.d=function(P,L,A){n.o(P,L)||Object.defineProperty(P,L,{enumerable:!0,get:A})},n.r=function(P){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(P,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(P,"__esModule",{value:!0})},n.t=function(P,L){if(L&1&&(P=n(P)),L&8||L&4&&typeof P=="object"&&P&&P.__esModule)return P;var A=Object.create(null);if(n.r(A),Object.defineProperty(A,"default",{enumerable:!0,value:P}),L&2&&typeof P!="string")for(var M in P)n.d(A,M,function(R){return P[R]}.bind(null,M));return A},n.n=function(P){var L=P&&P.__esModule?function(){return P.default}:function(){return P};return n.d(L,"a",L),L},n.o=function(P,L){return Object.prototype.hasOwnProperty.call(P,L)},n.p="/dist/",n(n.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(K,b,n){"use strict";var P=Object.prototype.hasOwnProperty,L="~";function A(){}Object.create&&(A.prototype=Object.create(null),new A().__proto__||(L=!1));function M(y,T,D){this.fn=y,this.context=T,this.once=D||!1}function R(y,T,D,E,m){if(typeof D!="function")throw new TypeError("The listener must be a function");var p=new M(D,E||y,m),d=L?L+T:T;return y._events[d]?y._events[d].fn?y._events[d]=[y._events[d],p]:y._events[d].push(p):(y._events[d]=p,y._eventsCount++),y}function O(y,T){--y._eventsCount===0?y._events=new A:delete y._events[T]}function _(){this._events=new A,this._eventsCount=0}_.prototype.eventNames=function(){var T=[],D,E;if(this._eventsCount===0)return T;for(E in D=this._events)P.call(D,E)&&T.push(L?E.slice(1):E);return Object.getOwnPropertySymbols?T.concat(Object.getOwnPropertySymbols(D)):T},_.prototype.listeners=function(T){var D=L?L+T:T,E=this._events[D];if(!E)return[];if(E.fn)return[E.fn];for(var m=0,p=E.length,d=new Array(p);m<p;m++)d[m]=E[m].fn;return d},_.prototype.listenerCount=function(T){var D=L?L+T:T,E=this._events[D];return E?E.fn?1:E.length:0},_.prototype.emit=function(T,D,E,m,p,d){var e=L?L+T:T;if(!this._events[e])return!1;var o=this._events[e],h=arguments.length,g,i;if(o.fn){switch(o.once&&this.removeListener(T,o.fn,void 0,!0),h){case 1:return o.fn.call(o.context),!0;case 2:return o.fn.call(o.context,D),!0;case 3:return o.fn.call(o.context,D,E),!0;case 4:return o.fn.call(o.context,D,E,m),!0;case 5:return o.fn.call(o.context,D,E,m,p),!0;case 6:return o.fn.call(o.context,D,E,m,p,d),!0}for(i=1,g=new Array(h-1);i<h;i++)g[i-1]=arguments[i];o.fn.apply(o.context,g)}else{var r=o.length,l;for(i=0;i<r;i++)switch(o[i].once&&this.removeListener(T,o[i].fn,void 0,!0),h){case 1:o[i].fn.call(o[i].context);break;case 2:o[i].fn.call(o[i].context,D);break;case 3:o[i].fn.call(o[i].context,D,E);break;case 4:o[i].fn.call(o[i].context,D,E,m);break;default:if(!g)for(l=1,g=new Array(h-1);l<h;l++)g[l-1]=arguments[l];o[i].fn.apply(o[i].context,g)}}return!0},_.prototype.on=function(T,D,E){return R(this,T,D,E,!1)},_.prototype.once=function(T,D,E){return R(this,T,D,E,!0)},_.prototype.removeListener=function(T,D,E,m){var p=L?L+T:T;if(!this._events[p])return this;if(!D)return O(this,p),this;var d=this._events[p];if(d.fn)d.fn===D&&(!m||d.once)&&(!E||d.context===E)&&O(this,p);else{for(var e=0,o=[],h=d.length;e<h;e++)(d[e].fn!==D||m&&!d[e].once||E&&d[e].context!==E)&&o.push(d[e]);o.length?this._events[p]=o.length===1?o[0]:o:O(this,p)}return this},_.prototype.removeAllListeners=function(T){var D;return T?(D=L?L+T:T,this._events[D]&&O(this,D)):(this._events=new A,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=L,_.EventEmitter=_,K.exports=_},"./node_modules/url-toolkit/src/url-toolkit.js":function(K,b,n){(function(P){var L=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,A=/^(?=([^\/?#]*))\1([^]*)$/,M=/(?:\/|^)\.(?=\/)/g,R=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,O={buildAbsoluteURL:function(_,y,T){if(T=T||{},_=_.trim(),y=y.trim(),!y){if(!T.alwaysNormalize)return _;var D=O.parseURL(_);if(!D)throw new Error("Error trying to parse base URL.");return D.path=O.normalizePath(D.path),O.buildURLFromParts(D)}var E=O.parseURL(y);if(!E)throw new Error("Error trying to parse relative URL.");if(E.scheme)return T.alwaysNormalize?(E.path=O.normalizePath(E.path),O.buildURLFromParts(E)):y;var m=O.parseURL(_);if(!m)throw new Error("Error trying to parse base URL.");if(!m.netLoc&&m.path&&m.path[0]!=="/"){var p=A.exec(m.path);m.netLoc=p[1],m.path=p[2]}m.netLoc&&!m.path&&(m.path="/");var d={scheme:m.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc&&(d.netLoc=m.netLoc,E.path[0]!=="/"))if(!E.path)d.path=m.path,E.params||(d.params=m.params,E.query||(d.query=m.query));else{var e=m.path,o=e.substring(0,e.lastIndexOf("/")+1)+E.path;d.path=O.normalizePath(o)}return d.path===null&&(d.path=T.alwaysNormalize?O.normalizePath(E.path):E.path),O.buildURLFromParts(d)},parseURL:function(_){var y=L.exec(_);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(M,"");_.length!==(_=_.replace(R,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}};K.exports=O})(this)},"./node_modules/webworkify-webpack/index.js":function(K,b,n){function P(T){var D={};function E(p){if(D[p])return D[p].exports;var d=D[p]={i:p,l:!1,exports:{}};return T[p].call(d.exports,d,d.exports,E),d.l=!0,d.exports}E.m=T,E.c=D,E.i=function(p){return p},E.d=function(p,d,e){E.o(p,d)||Object.defineProperty(p,d,{configurable:!1,enumerable:!0,get:e})},E.r=function(p){Object.defineProperty(p,"__esModule",{value:!0})},E.n=function(p){var d=p&&p.__esModule?function(){return p.default}:function(){return p};return E.d(d,"a",d),d},E.o=function(p,d){return Object.prototype.hasOwnProperty.call(p,d)},E.p="/",E.oe=function(p){throw console.error(p),p};var m=E(E.s=ENTRY_MODULE);return m.default||m}var L="[\\.|\\-|\\+|\\w|/|@]+",A="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+L+").*?\\)";function M(T){return(T+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function R(T){return!isNaN(1*T)}function O(T,D,E){var m={};m[E]=[];var p=D.toString(),d=p.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!d)return m;for(var e=d[1],o=new RegExp("(\\\\n|\\W)"+M(e)+A,"g"),h;h=o.exec(p);)h[3]!=="dll-reference"&&m[E].push(h[3]);for(o=new RegExp("\\("+M(e)+'\\("(dll-reference\\s('+L+'))"\\)\\)'+A,"g");h=o.exec(p);)T[h[2]]||(m[E].push(h[1]),T[h[2]]=n(h[1]).m),m[h[2]]=m[h[2]]||[],m[h[2]].push(h[4]);for(var g=Object.keys(m),i=0;i<g.length;i++)for(var r=0;r<m[g[i]].length;r++)R(m[g[i]][r])&&(m[g[i]][r]=1*m[g[i]][r]);return m}function _(T){var D=Object.keys(T);return D.reduce(function(E,m){return E||T[m].length>0},!1)}function y(T,D){for(var E={main:[D]},m={main:[]},p={main:{}};_(E);)for(var d=Object.keys(E),e=0;e<d.length;e++){var o=d[e],h=E[o],g=h.pop();if(p[o]=p[o]||{},!(p[o][g]||!T[o][g])){p[o][g]=!0,m[o]=m[o]||[],m[o].push(g);for(var i=O(T,T[o][g],o),r=Object.keys(i),l=0;l<r.length;l++)E[r[l]]=E[r[l]]||[],E[r[l]]=E[r[l]].concat(i[r[l]])}}return m}K.exports=function(T,D){D=D||{};var E={main:n.m},m=D.all?{main:Object.keys(E.main)}:y(E,T),p="";Object.keys(m).filter(function(g){return g!=="main"}).forEach(function(g){for(var i=0;m[g][i];)i++;m[g].push(i),E[g][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",p=p+"var "+g+" = ("+P.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+m[g].map(function(r){return""+JSON.stringify(r)+": "+E[g][r].toString()}).join(",")+`});
8
- `}),p=p+"new (("+P.toString().replace("ENTRY_MODULE",JSON.stringify(T))+")({"+m.main.map(function(g){return""+JSON.stringify(g)+": "+E.main[g].toString()}).join(",")+"}))(self);";var d=new window.Blob([p],{type:"text/javascript"});if(D.bare)return d;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,o=e.createObjectURL(d),h=new window.Worker(o);return h.objectURL=o,h}},"./src/config.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"hlsDefaultConfig",function(){return l}),n.d(b,"mergeConfig",function(){return t}),n.d(b,"enableStreamingMode",function(){return a});var P=n("./src/controller/abr-controller.ts"),L=n("./src/controller/audio-stream-controller.ts"),A=n("./src/controller/audio-track-controller.ts"),M=n("./src/controller/subtitle-stream-controller.ts"),R=n("./src/controller/subtitle-track-controller.ts"),O=n("./src/controller/buffer-controller.ts"),_=n("./src/controller/timeline-controller.ts"),y=n("./src/controller/cap-level-controller.ts"),T=n("./src/controller/fps-controller.ts"),D=n("./src/controller/eme-controller.ts"),E=n("./src/controller/cmcd-controller.ts"),m=n("./src/utils/xhr-loader.ts"),p=n("./src/utils/fetch-loader.ts"),d=n("./src/utils/cues.ts"),e=n("./src/utils/mediakeys-helper.ts"),o=n("./src/utils/logger.ts");function h(){return h=Object.assign?Object.assign.bind():function(u){for(var s=1;s<arguments.length;s++){var f=arguments[s];for(var v in f)Object.prototype.hasOwnProperty.call(f,v)&&(u[v]=f[v])}return u},h.apply(this,arguments)}function g(u,s){var f=Object.keys(u);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(u);s&&(v=v.filter(function(S){return Object.getOwnPropertyDescriptor(u,S).enumerable})),f.push.apply(f,v)}return f}function i(u){for(var s=1;s<arguments.length;s++){var f=arguments[s]!=null?arguments[s]:{};s%2?g(Object(f),!0).forEach(function(v){r(u,v,f[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(f)):g(Object(f)).forEach(function(v){Object.defineProperty(u,v,Object.getOwnPropertyDescriptor(f,v))})}return u}function r(u,s,f){return s in u?Object.defineProperty(u,s,{value:f,enumerable:!0,configurable:!0,writable:!0}):u[s]=f,u}var l=i(i({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,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:m.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:P.default,bufferController:O.default,capLevelController:y.default,fpsController:T.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:e.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},c()),{},{subtitleStreamController:M.SubtitleStreamController,subtitleTrackController:R.default,timelineController:_.TimelineController,audioStreamController:L.default,audioTrackController:A.default,emeController:D.default,cmcdController:E.default});function c(){return{cueHandler:d.default,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function t(u,s){if((s.liveSyncDurationCount||s.liveMaxLatencyDurationCount)&&(s.liveSyncDuration||s.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(s.liveMaxLatencyDurationCount!==void 0&&(s.liveSyncDurationCount===void 0||s.liveMaxLatencyDurationCount<=s.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(s.liveMaxLatencyDuration!==void 0&&(s.liveSyncDuration===void 0||s.liveMaxLatencyDuration<=s.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return h({},u,s)}function a(u){var s=u.loader;if(s!==p.default&&s!==m.default)o.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),u.progressive=!1;else{var f=Object(p.fetchSupported)();f&&(u.loader=p.default,u.progressive=!0,u.enableSoftwareAES=!0,o.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/polyfills/number.ts"),L=n("./src/utils/ewma-bandwidth-estimator.ts"),A=n("./src/events.ts"),M=n("./src/utils/buffer-helper.ts"),R=n("./src/errors.ts"),O=n("./src/types/loader.ts"),_=n("./src/utils/logger.ts");function y(E,m){for(var p=0;p<m.length;p++){var d=m[p];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(E,d.key,d)}}function T(E,m,p){return m&&y(E.prototype,m),p&&y(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}var D=function(){function E(p){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=p;var d=p.config;this.bwEstimator=new L.default(d.abrEwmaSlowVoD,d.abrEwmaFastVoD,d.abrEwmaDefaultEstimate),this.registerListeners()}var m=E.prototype;return m.registerListeners=function(){var d=this.hls;d.on(A.Events.FRAG_LOADING,this.onFragLoading,this),d.on(A.Events.FRAG_LOADED,this.onFragLoaded,this),d.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),d.on(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(A.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){var d=this.hls;d.off(A.Events.FRAG_LOADING,this.onFragLoading,this),d.off(A.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),d.off(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(A.Events.ERROR,this.onError,this)},m.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},m.onFragLoading=function(d,e){var o=e.frag;if(o.type===O.PlaylistLevelType.MAIN&&!this.timer){var h;this.fragCurrent=o,this.partCurrent=(h=e.part)!=null?h:null,this.timer=self.setInterval(this.onCheck,100)}},m.onLevelLoaded=function(d,e){var o=this.hls.config;e.details.live?this.bwEstimator.update(o.abrEwmaSlowLive,o.abrEwmaFastLive):this.bwEstimator.update(o.abrEwmaSlowVoD,o.abrEwmaFastVoD)},m._abandonRulesCheck=function(){var d=this.fragCurrent,e=this.partCurrent,o=this.hls,h=o.autoLevelEnabled,g=o.config,i=o.media;if(!(!d||!i)){var r=e?e.stats:d.stats,l=e?e.duration:d.duration;if(r.aborted){_.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!h||i.paused||!i.playbackRate||!i.readyState)){var c=performance.now()-r.loading.start,t=Math.abs(i.playbackRate);if(!(c<=500*l/t)){var a=o.levels,u=o.minAutoLevel,s=a[d.level],f=r.total||Math.max(r.loaded,Math.round(l*s.maxBitrate/8)),v=Math.max(1,r.bwEstimate?r.bwEstimate/8:r.loaded*1e3/c),S=(f-r.loaded)/v,x=i.currentTime,I=(M.BufferHelper.bufferInfo(i,x,g.maxBufferHole).end-x)/t;if(!(I>=2*l/t||S<=I)){var B=Number.POSITIVE_INFINITY,k;for(k=d.level-1;k>u;k--){var U=a[k].maxBitrate;if(B=l*U/(8*.8*v),B<I)break}if(!(B>=S)){var W=this.bwEstimator.getEstimate();_.logger.warn("Fragment "+d.sn+(e?" part "+e.index:"")+" of level "+d.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+k+`
9
- Current BW estimate: `+(Object(P.isFiniteNumber)(W)?(W/1024).toFixed(3):"Unknown")+` Kb/s
6
+ `))this.processLine(this.buffer.substring(0,C)),this.buffer=this.buffer.substring(C+1)},cr.prototype.processLine=function(F){var C=F.indexOf(":"),w=hn(F,C),N=w[0],j=w.length===2?Pr(w[1]):void 0;if(N[0]!=="#")this.currentUri.uri=N,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(N){case rn:if(!isFinite(j)||j<0)return;this.manifest.targetDuration=j,this.setHoldBack();break;case nn:Rr(this.manifest,w),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case an:Rr(this.manifest,w),this.setHoldBack();break;case sn:j===0?this.currentUri.duration=.01:j>0&&(this.currentUri.duration=j);break;case on:var V=j,H=new Date(V);this.manifest.dateTimeString||(this.manifest.dateTimeString=V,this.manifest.dateTimeObject=H),this.currentUri.dateTimeString=V,this.currentUri.dateTimeObject=H;break;case ln:Rr(this.manifest,w);break;case un:var $=vn(w[1]),Z=s($);i()(this.manifest.sessionData,Z)}},cr.prototype.setHoldBack=function(){var F=this.manifest,C=F.serverControl,w=F.targetDuration,N=F.partTargetDuration;if(C){var j="holdBack",V="partHoldBack",H=w&&3*w,$=N&&2*N;w&&!C.hasOwnProperty(j)&&(C[j]=H),H&&C[j]<H&&(C[j]=H),N&&!C.hasOwnProperty(V)&&(C[V]=3*N),N&&C[V]<$&&(C[V]=$)}};var Rr=function(F,C){var w,N=oi(C[0].replace("#EXT-X-",""));cn(C[1])?(w={},w=i()(dn(C[1]),w)):w=Pr(C[1]),F[N]=w},oi=function(F){return F.toLowerCase().replace(/-(\w)/g,function(C){return C[1].toUpperCase()})},Pr=function(F){if(F.toLowerCase()==="yes"||F.toLowerCase()==="no")return F.toLowerCase()==="yes";var C=F.indexOf(":")!==-1?F:parseFloat(F);return isNaN(C)?F:C},fn=function(F){var C={},w=F.split("=");return w.length>1&&(C[oi(w[0])]=Pr(w[1])),C},dn=function(F){for(var C=F.split(","),w={},N=0;C.length>N;N++){var j=C[N],V=fn(j);w=i()(V,w)}return w},cn=function(F){return F.indexOf("=")>-1},hn=function(F,C){return C===-1?[F]:[F.substring(0,C),F.substring(C+1)]},vn=function(F){var C={};if(F){var w=F.search(",");return[F.slice(0,w),F.slice(w+1)].forEach(function(N,j){for(var V=N.replace(/['"]+/g,"").split("="),H=0;H<V.length;H++)V[H]==="DATA-ID"&&(C["DATA-ID"]=V[1-H]),V[H]==="VALUE"&&(C.VALUE=V[1-H])}),{data:C}}},gn=cr,mn={safeCall:function(F,C,w,N){var j=N;if(F&&typeof F[C]=="function")try{j=F[C].apply(F,w)}catch(V){e.info("safeCall error",V)}return j},safeIncrement:t,getComputedStyle:function(F,C){var w;if(F&&C&&_()&&typeof _().getComputedStyle=="function")return Ct&&Ct.has(F)&&(w=Ct.get(F)),w||(w=_().getComputedStyle(F,null),Ct&&Ct.set(F,w)),w.getPropertyValue(C)},secondsToMs:function(F){return Math.floor(1e3*F)},assign:i(),headersStringToObject:u,extractHostnameAndDomain:l,extractHostname:r,manifestParser:gn,generateShortID:T,generateUUID:y,now:h.now},pn={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled"};function En(F,C){return function(w){if(Array.isArray(w))return w}(F)||function(w,N){var j=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(j!=null){var V,H,$=[],Z=!0,Q=!1;try{for(j=j.call(w);!(Z=(V=j.next()).done)&&($.push(V.value),!N||$.length!==N);Z=!0);}catch(ne){Q=!0,H=ne}finally{try{Z||j.return==null||j.return()}finally{if(Q)throw H}}return $}}(F,C)||function(w,N){if(w){if(typeof w=="string")return li(w,N);var j=Object.prototype.toString.call(w).slice(8,-1);return j==="Object"&&w.constructor&&(j=w.constructor.name),j==="Map"||j==="Set"?Array.from(w):j==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(j)?li(w,N):void 0}}(F,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
7
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function li(F,C){(C==null||C>F.length)&&(C=F.length);for(var w=0,N=new Array(C);w<C;w++)N[w]=F[w];return N}var at={},Ht=function F(C){var w=arguments;typeof C=="string"?F.hasOwnProperty(C)?_().setTimeout(function(){w=Array.prototype.splice.call(w,1),F[C].apply(null,w)},0):e.warn("`"+C+"` is an unknown task"):typeof C=="function"?_().setTimeout(function(){C(F)},0):e.warn("`"+C+"` is invalid.")},yn={loaded:h.now(),NAME:"mux-embed",VERSION:"4.14.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(F,C){return function(w,N,j){var V=ai(E(N),3),H=V[0],$=V[1],Z=V[2],Q=w.log,ne=w.utils.getComputedStyle,me=w.utils.secondsToMs;if(!H)return Q.error("No element was found with the `"+$+"` query selector.");if(Z!=="video"&&Z!=="audio")return Q.error("The element of `"+$+"` was not a media element.");H.mux&&(H.mux.destroy(),delete H.mux,Q.warn("Already monitoring this video element, replacing existing event listeners")),(j=i()({automaticErrorTracking:!0},j)).data=i()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:w.VERSION},j.data),j.getPlayheadTime=function(){return me(H.currentTime)},j.getStateData=function(){var Te=this.hlsjs&&this.hlsjs.url,le=this.dashjs&&Or(this.dashjs.getSource==="function")&&this.dashjs.getSource(),de={player_is_paused:H.paused,player_playhead_time:me(H.currentTime),player_width:parseInt(ne(H,"width")),player_height:parseInt(ne(H,"height")),player_autoplay_on:H.autoplay,player_preload_on:H.preload,player_language_code:H.lang,player_is_fullscreen:Gt()&&!!(Gt().fullscreenElement||Gt().webkitFullscreenElement||Gt().mozFullScreenElement||Gt().msFullscreenElement),video_poster_url:H.poster,video_source_url:Te||le||H.currentSrc,video_source_duration:me(H.duration),video_source_height:H.videoHeight,video_source_width:H.videoWidth},Le=j.getPlayheadTime();if(H.getStartDate&&Le>0){var Je=H.getStartDate();if(Je&&typeof Je.getTime=="function"&&Je.getTime()){var tt=Je.getTime();if(de.player_program_time=tt+Le,H.seekable.length>0){var _t=tt+H.seekable.end(H.seekable.length-1);de.player_live_edge_program_time=_t}}}return de},H.mux=H.mux||{},H.mux.deleted=!1,H.mux.emit=function(Te,le){w.emit($,Te,le)};var Ae=function(){Q.error("The monitor for this video element has already been destroyed.")};H.mux.destroy=function(){Object.keys(H.mux.listeners).forEach(function(Te){H.removeEventListener(Te,H.mux.listeners[Te],!1)}),delete H.mux.listeners,H.mux.destroy=Ae,H.mux.swapElement=Ae,H.mux.emit=Ae,H.mux.addHLSJS=Ae,H.mux.addDashJS=Ae,H.mux.removeHLSJS=Ae,H.mux.removeDashJS=Ae,H.mux.deleted=!0,w.emit($,"destroy")},H.mux.swapElement=function(Te){var le=ai(E(Te),3),de=le[0],Le=le[1],Je=le[2];return de?Je!=="video"&&Je!=="audio"?w.log.error("The element of `"+Le+"` was not a media element."):(de.muxId=H.muxId,delete H.muxId,de.mux=de.mux||{},de.mux.listeners=i()({},H.mux.listeners),delete H.mux.listeners,Object.keys(de.mux.listeners).forEach(function(tt){H.removeEventListener(tt,de.mux.listeners[tt],!1),de.addEventListener(tt,de.mux.listeners[tt],!1)}),de.mux.swapElement=H.mux.swapElement,de.mux.destroy=H.mux.destroy,delete H.mux,void(H=de)):w.log.error("No element was found with the `"+Le+"` query selector.")},H.mux.addHLSJS=function(Te){w.addHLSJS($,Te)},H.mux.addDashJS=function(Te){w.addDashJS($,Te)},H.mux.removeHLSJS=function(){w.removeHLSJS($)},H.mux.removeDashJS=function(){w.removeDashJS($)},w.init($,j),w.emit($,"playerready"),H.paused||(w.emit($,"play"),H.readyState>2&&w.emit($,"playing")),H.mux.listeners={},en.forEach(function(Te){(Te!=="error"||j.automaticErrorTracking)&&(H.mux.listeners[Te]=function(){var le={};if(Te==="error"){if(!H.error||H.error.code===1)return;le.player_error_code=H.error.code,le.player_error_message=tn[H.error.code]||H.error.message}w.emit($,Te,le)},H.addEventListener(Te,H.mux.listeners[Te],!1))})}(Ht,F,C)},destroyMonitor:function(F){var C=En(E(F),1)[0];C&&C.mux&&typeof C.mux.destroy=="function"?C.mux.destroy():e.error("A video element monitor for `"+F+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(F,C){var w=A(F);at[w]?at[w].addHLSJS(C):e.error("A monitor for `"+w+"` has not been initialized.")},addDashJS:function(F,C){var w=A(F);at[w]?at[w].addDashJS(C):e.error("A monitor for `"+w+"` has not been initialized.")},removeHLSJS:function(F){var C=A(F);at[C]?at[C].removeHLSJS():e.error("A monitor for `"+C+"` has not been initialized.")},removeDashJS:function(F){var C=A(F);at[C]?at[C].removeDashJS():e.error("A monitor for `"+C+"` has not been initialized.")},init:function(F,C){o()&&C&&C.respectDoNotTrack&&e.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var w=A(F);at[w]=new Zi(Ht,w,C)},emit:function(F,C,w){var N=A(F);at[N]?(at[N].emit(C,w),C==="destroy"&&delete at[N]):e.error("A monitor for `"+N+"` has not been initialized.")},checkDoNotTrack:o,log:e,utils:mn,events:pn,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Ht,yn),_()!==void 0&&typeof _().addEventListener=="function"&&_().addEventListener("pagehide",function(F){F.persisted||(Ht.WINDOW_UNLOADING=!0)},!1);var Tn=Ht},655:function(D,M,R){var O,_;function y(T){return y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},y(T);}(function(T){var A=!1;if((_=typeof(O=T)=="function"?O.call(M,R,M,D):O)===void 0||(D.exports=_),A=!0,y(M)==="object"&&(D.exports=T(),A=!0),!A){var E=window.Cookies,m=window.Cookies=T();m.noConflict=function(){return window.Cookies=E,m}}})(function(){var T=function(){for(var A=0,E={};A<arguments.length;A++){var m=arguments[A];for(var p in m)E[p]=m[p]}return E};return function A(E){function m(p,f,e){var o;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(e=T({path:"/"},m.defaults,e)).expires=="number"){var h=new Date;h.setMilliseconds(h.getMilliseconds()+864e5*e.expires),e.expires=h}try{o=JSON.stringify(f),/^[\{\[]/.test(o)&&(f=o)}catch{}return f=E.write?E.write(f,p):encodeURIComponent(String(f)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),p=(p=(p=encodeURIComponent(String(p))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[p,"=",f,e.expires?"; expires="+e.expires.toUTCString():"",e.path?"; path="+e.path:"",e.domain?"; domain="+e.domain:"",e.secure?"; secure":""].join("")}p||(o={});for(var g=document.cookie?document.cookie.split("; "):[],i=/(%[0-9A-Z]{2})+/g,r=0;r<g.length;r++){var l=g[r].split("="),c=l.slice(1).join("=");c.charAt(0)==='"'&&(c=c.slice(1,-1));try{var t=l[0].replace(i,decodeURIComponent);if(c=E.read?E.read(c,t):E(c,t)||c.replace(i,decodeURIComponent),this.json)try{c=JSON.parse(c)}catch{}if(p===t){o=c;break}p||(o[t]=c)}catch{}}return o}}return m.set=m,m.get=function(p){return m.call(m,p)},m.getJSON=function(){return m.apply({json:!0},[].slice.call(arguments))},m.defaults={},m.remove=function(p,f){m(p,"",T(f,{expires:-1}))},m.withConverter=A,m}(function(){})})},153:function(D,M,R){var O,_=R.g!==void 0?R.g:typeof window!="undefined"?window:{},y=R(558);typeof document!="undefined"?O=document:(O=_["__GLOBAL_DOCUMENT_CACHE@4"])||(O=_["__GLOBAL_DOCUMENT_CACHE@4"]=y),D.exports=O},48:function(D,M,R){var O;O=typeof window!="undefined"?window:R.g!==void 0?R.g:typeof self!="undefined"?self:{},D.exports=O},678:function(D){var M=9007199254740991,R="[object Arguments]",O="[object Function]",_="[object GeneratorFunction]",y=/^(?:0|[1-9]\d*)$/;function T(S,x,P){switch(P.length){case 0:return S.call(x);case 1:return S.call(x,P[0]);case 2:return S.call(x,P[0],P[1]);case 3:return S.call(x,P[0],P[1],P[2])}return S.apply(x,P)}var A,E,m=Object.prototype,p=m.hasOwnProperty,f=m.toString,e=m.propertyIsEnumerable,o=(A=Object.keys,E=Object,function(S){return A(E(S))}),h=Math.max,g=!e.call({valueOf:1},"valueOf");function i(S,x){var P=a(S)||function(W){return function(G){return function(z){return!!z&&typeof z=="object"}(G)&&u(G)}(W)&&p.call(W,"callee")&&(!e.call(W,"callee")||f.call(W)==R)}(S)?function(W,G){for(var z=-1,Y=Array(W);++z<W;)Y[z]=G(z);return Y}(S.length,String):[],B=P.length,k=!!B;for(var U in S)!x&&!p.call(S,U)||k&&(U=="length"||l(U,B))||P.push(U);return P}function r(S,x,P){var B=S[x];p.call(S,x)&&t(B,P)&&(P!==void 0||x in S)||(S[x]=P)}function l(S,x){return!!(x=x==null?M:x)&&(typeof S=="number"||y.test(S))&&S>-1&&S%1==0&&S<x}function c(S){var x=S&&S.constructor;return S===(typeof x=="function"&&x.prototype||m)}function t(S,x){return S===x||S!=S&&x!=x}var a=Array.isArray;function u(S){return S!=null&&function(x){return typeof x=="number"&&x>-1&&x%1==0&&x<=M}(S.length)&&!function(x){var P=s(x)?f.call(x):"";return P==O||P==_}(S)}function s(S){var x=typeof S;return!!S&&(x=="object"||x=="function")}var d,v=(d=function(S,x){if(g||c(x)||u(x))(function(B,k,U,W){U||(U={});for(var G=-1,z=k.length;++G<z;){var Y=k[G],J=W?W(U[Y],B[Y],Y,U,B):void 0;r(U,Y,J===void 0?B[Y]:J)}})(x,function(B){return u(B)?i(B):function(k){if(!c(k))return o(k);var U=[];for(var W in Object(k))p.call(k,W)&&W!="constructor"&&U.push(W);return U}(B)}(x),S);else for(var P in x)p.call(x,P)&&r(S,P,x[P])},function(S,x){return x=h(x===void 0?S.length-1:x,0),function(){for(var P=arguments,B=-1,k=h(P.length-x,0),U=Array(k);++B<k;)U[B]=P[x+B];B=-1;for(var W=Array(x+1);++B<x;)W[B]=P[B];return W[x]=U,T(S,this,W)}}(function(S,x){var P=-1,B=x.length,k=B>1?x[B-1]:void 0,U=B>2?x[2]:void 0;for(k=d.length>3&&typeof k=="function"?(B--,k):void 0,U&&function(G,z,Y){if(!s(Y))return!1;var J=typeof z;return!!(J=="number"?u(Y)&&l(z,Y.length):J=="string"&&z in Y)&&t(Y[z],G)}(x[0],x[1],U)&&(k=B<3?void 0:k,B=1),S=Object(S);++P<B;){var W=x[P];W&&d(S,W,P,k)}return S}));D.exports=v},640:function(D,M,R){var O,_;(function(y,T){"use strict";O=function(){var A=function(){},E="undefined",m=typeof window!==E&&typeof window.navigator!==E&&/Trident\/|MSIE /.test(window.navigator.userAgent),p=["trace","debug","info","warn","error"];function f(a,u){var s=a[u];if(typeof s.bind=="function")return s.bind(a);try{return Function.prototype.bind.call(s,a)}catch{return function(){return Function.prototype.apply.apply(s,[a,arguments])}}}function e(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function o(a){return a==="debug"&&(a="log"),typeof console!==E&&(a==="trace"&&m?e:console[a]!==void 0?f(console,a):console.log!==void 0?f(console,"log"):A)}function h(a,u){for(var s=0;s<p.length;s++){var d=p[s];this[d]=s<a?A:this.methodFactory(d,a,u)}this.log=this.debug}function g(a,u,s){return function(){typeof console!==E&&(h.call(this,u,s),this[a].apply(this,arguments))}}function i(a,u,s){return o(a)||g.apply(this,arguments)}function r(a,u,s){var d,v=this;u=u==null?"WARN":u;var S="loglevel";function x(U){var W=(p[U]||"silent").toUpperCase();if(typeof window!==E&&S){try{return void(window.localStorage[S]=W)}catch{}try{window.document.cookie=encodeURIComponent(S)+"="+W+";"}catch{}}}function P(){var U;if(typeof window!==E&&S){try{U=window.localStorage[S]}catch{}if(typeof U===E)try{var W=window.document.cookie,G=W.indexOf(encodeURIComponent(S)+"=");G!==-1&&(U=/^([^;]+)/.exec(W.slice(G))[1])}catch{}return v.levels[U]===void 0&&(U=void 0),U}}function B(){if(typeof window!==E&&S){try{return void window.localStorage.removeItem(S)}catch{}try{window.document.cookie=encodeURIComponent(S)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof a=="string"?S+=":"+a:typeof a=="symbol"&&(S=void 0),v.name=a,v.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},v.methodFactory=s||i,v.getLevel=function(){return d},v.setLevel=function(U,W){if(typeof U=="string"&&v.levels[U.toUpperCase()]!==void 0&&(U=v.levels[U.toUpperCase()]),!(typeof U=="number"&&U>=0&&U<=v.levels.SILENT))throw"log.setLevel() called with invalid level: "+U;if(d=U,W!==!1&&x(U),h.call(v,U,a),typeof console===E&&U<v.levels.SILENT)return"No console available for logging"},v.setDefaultLevel=function(U){u=U,P()||v.setLevel(U,!1)},v.resetLevel=function(){v.setLevel(u,!1),B()},v.enableAll=function(U){v.setLevel(v.levels.TRACE,U)},v.disableAll=function(U){v.setLevel(v.levels.SILENT,U)};var k=P();k==null&&(k=u),v.setLevel(k,!1)}var l=new r,c={};l.getLogger=function(a){if(typeof a!="symbol"&&typeof a!="string"||a==="")throw new TypeError("You must supply a name when creating a logger.");var u=c[a];return u||(u=c[a]=new r(a,l.getLevel(),l.methodFactory)),u};var t=typeof window!==E?window.log:void 0;return l.noConflict=function(){return typeof window!==E&&window.log===l&&(window.log=t),l},l.getLoggers=function(){return c},l.default=l,l},(_=typeof O=="function"?O.call(M,R,M,D):O)===void 0||(D.exports=_)})()},375:function(D,M){"use strict";var R=Object.prototype.hasOwnProperty;function O(y){try{return decodeURIComponent(y.replace(/\+/g," "))}catch{return null}}function _(y){try{return encodeURIComponent(y)}catch{return null}}M.stringify=function(y,T){T=T||"";var A,E,m=[];for(E in typeof T!="string"&&(T="?"),y)if(R.call(y,E)){if((A=y[E])||A!=null&&!isNaN(A)||(A=""),E=_(E),A=_(A),E===null||A===null)continue;m.push(E+"="+A)}return m.length?T+m.join("&"):""},M.parse=function(y){for(var T,A=/([^=?#&]+)=?([^&]*)/g,E={};T=A.exec(y);){var m=O(T[1]),p=O(T[2]);m===null||p===null||m in E||(E[m]=p)}return E}},558:function(){}},I={};function L(D){var M=I[D];if(M!==void 0)return M.exports;var R=I[D]={exports:{}};return n[D].call(R.exports,R,R.exports,L),R.exports}return L.n=function(D){var M=D&&D.__esModule?function(){return D.default}:function(){return D};return L.d(M,{a:M}),M},L.d=function(D,M){for(var R in M)L.o(M,R)&&!L.o(D,R)&&Object.defineProperty(D,R,{enumerable:!0,get:M[R]})},L.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),L.o=function(D,M){return Object.prototype.hasOwnProperty.call(D,M)},L(80)}()},typeof vr=="object"&&typeof Ur=="object"?Ur.exports=b():typeof vr=="object"?vr.mux=b():K.mux=b()})()});var gr=ui((Qt,Nr)=>{typeof window!="undefined"&&function(b,n){typeof Qt=="object"&&typeof Nr=="object"?Nr.exports=n():typeof define=="function"&&define.amd?define([],n):typeof Qt=="object"?Qt.Hls=n():b.Hls=n()}(Qt,function(){return function(K){var b={};function n(I){if(b[I])return b[I].exports;var L=b[I]={i:I,l:!1,exports:{}};return K[I].call(L.exports,L,L.exports,n),L.l=!0,L.exports}return n.m=K,n.c=b,n.d=function(I,L,D){n.o(I,L)||Object.defineProperty(I,L,{enumerable:!0,get:D})},n.r=function(I){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(I,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(I,"__esModule",{value:!0})},n.t=function(I,L){if(L&1&&(I=n(I)),L&8||L&4&&typeof I=="object"&&I&&I.__esModule)return I;var D=Object.create(null);if(n.r(D),Object.defineProperty(D,"default",{enumerable:!0,value:I}),L&2&&typeof I!="string")for(var M in I)n.d(D,M,function(R){return I[R]}.bind(null,M));return D},n.n=function(I){var L=I&&I.__esModule?function(){return I.default}:function(){return I};return n.d(L,"a",L),L},n.o=function(I,L){return Object.prototype.hasOwnProperty.call(I,L)},n.p="/dist/",n(n.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(K,b,n){"use strict";var I=Object.prototype.hasOwnProperty,L="~";function D(){}Object.create&&(D.prototype=Object.create(null),new D().__proto__||(L=!1));function M(y,T,A){this.fn=y,this.context=T,this.once=A||!1}function R(y,T,A,E,m){if(typeof A!="function")throw new TypeError("The listener must be a function");var p=new M(A,E||y,m),f=L?L+T:T;return y._events[f]?y._events[f].fn?y._events[f]=[y._events[f],p]:y._events[f].push(p):(y._events[f]=p,y._eventsCount++),y}function O(y,T){--y._eventsCount===0?y._events=new D:delete y._events[T]}function _(){this._events=new D,this._eventsCount=0}_.prototype.eventNames=function(){var T=[],A,E;if(this._eventsCount===0)return T;for(E in A=this._events)I.call(A,E)&&T.push(L?E.slice(1):E);return Object.getOwnPropertySymbols?T.concat(Object.getOwnPropertySymbols(A)):T},_.prototype.listeners=function(T){var A=L?L+T:T,E=this._events[A];if(!E)return[];if(E.fn)return[E.fn];for(var m=0,p=E.length,f=new Array(p);m<p;m++)f[m]=E[m].fn;return f},_.prototype.listenerCount=function(T){var A=L?L+T:T,E=this._events[A];return E?E.fn?1:E.length:0},_.prototype.emit=function(T,A,E,m,p,f){var e=L?L+T:T;if(!this._events[e])return!1;var o=this._events[e],h=arguments.length,g,i;if(o.fn){switch(o.once&&this.removeListener(T,o.fn,void 0,!0),h){case 1:return o.fn.call(o.context),!0;case 2:return o.fn.call(o.context,A),!0;case 3:return o.fn.call(o.context,A,E),!0;case 4:return o.fn.call(o.context,A,E,m),!0;case 5:return o.fn.call(o.context,A,E,m,p),!0;case 6:return o.fn.call(o.context,A,E,m,p,f),!0}for(i=1,g=new Array(h-1);i<h;i++)g[i-1]=arguments[i];o.fn.apply(o.context,g)}else{var r=o.length,l;for(i=0;i<r;i++)switch(o[i].once&&this.removeListener(T,o[i].fn,void 0,!0),h){case 1:o[i].fn.call(o[i].context);break;case 2:o[i].fn.call(o[i].context,A);break;case 3:o[i].fn.call(o[i].context,A,E);break;case 4:o[i].fn.call(o[i].context,A,E,m);break;default:if(!g)for(l=1,g=new Array(h-1);l<h;l++)g[l-1]=arguments[l];o[i].fn.apply(o[i].context,g)}}return!0},_.prototype.on=function(T,A,E){return R(this,T,A,E,!1)},_.prototype.once=function(T,A,E){return R(this,T,A,E,!0)},_.prototype.removeListener=function(T,A,E,m){var p=L?L+T:T;if(!this._events[p])return this;if(!A)return O(this,p),this;var f=this._events[p];if(f.fn)f.fn===A&&(!m||f.once)&&(!E||f.context===E)&&O(this,p);else{for(var e=0,o=[],h=f.length;e<h;e++)(f[e].fn!==A||m&&!f[e].once||E&&f[e].context!==E)&&o.push(f[e]);o.length?this._events[p]=o.length===1?o[0]:o:O(this,p)}return this},_.prototype.removeAllListeners=function(T){var A;return T?(A=L?L+T:T,this._events[A]&&O(this,A)):(this._events=new D,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=L,_.EventEmitter=_,K.exports=_},"./node_modules/url-toolkit/src/url-toolkit.js":function(K,b,n){(function(I){var L=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,D=/^(?=([^\/?#]*))\1([^]*)$/,M=/(?:\/|^)\.(?=\/)/g,R=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,O={buildAbsoluteURL:function(_,y,T){if(T=T||{},_=_.trim(),y=y.trim(),!y){if(!T.alwaysNormalize)return _;var A=O.parseURL(_);if(!A)throw new Error("Error trying to parse base URL.");return A.path=O.normalizePath(A.path),O.buildURLFromParts(A)}var E=O.parseURL(y);if(!E)throw new Error("Error trying to parse relative URL.");if(E.scheme)return T.alwaysNormalize?(E.path=O.normalizePath(E.path),O.buildURLFromParts(E)):y;var m=O.parseURL(_);if(!m)throw new Error("Error trying to parse base URL.");if(!m.netLoc&&m.path&&m.path[0]!=="/"){var p=D.exec(m.path);m.netLoc=p[1],m.path=p[2]}m.netLoc&&!m.path&&(m.path="/");var f={scheme:m.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc&&(f.netLoc=m.netLoc,E.path[0]!=="/"))if(!E.path)f.path=m.path,E.params||(f.params=m.params,E.query||(f.query=m.query));else{var e=m.path,o=e.substring(0,e.lastIndexOf("/")+1)+E.path;f.path=O.normalizePath(o)}return f.path===null&&(f.path=T.alwaysNormalize?O.normalizePath(E.path):E.path),O.buildURLFromParts(f)},parseURL:function(_){var y=L.exec(_);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(M,"");_.length!==(_=_.replace(R,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}};K.exports=O})(this)},"./node_modules/webworkify-webpack/index.js":function(K,b,n){function I(T){var A={};function E(p){if(A[p])return A[p].exports;var f=A[p]={i:p,l:!1,exports:{}};return T[p].call(f.exports,f,f.exports,E),f.l=!0,f.exports}E.m=T,E.c=A,E.i=function(p){return p},E.d=function(p,f,e){E.o(p,f)||Object.defineProperty(p,f,{configurable:!1,enumerable:!0,get:e})},E.r=function(p){Object.defineProperty(p,"__esModule",{value:!0})},E.n=function(p){var f=p&&p.__esModule?function(){return p.default}:function(){return p};return E.d(f,"a",f),f},E.o=function(p,f){return Object.prototype.hasOwnProperty.call(p,f)},E.p="/",E.oe=function(p){throw console.error(p),p};var m=E(E.s=ENTRY_MODULE);return m.default||m}var L="[\\.|\\-|\\+|\\w|/|@]+",D="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+L+").*?\\)";function M(T){return(T+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function R(T){return!isNaN(1*T)}function O(T,A,E){var m={};m[E]=[];var p=A.toString(),f=p.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!f)return m;for(var e=f[1],o=new RegExp("(\\\\n|\\W)"+M(e)+D,"g"),h;h=o.exec(p);)h[3]!=="dll-reference"&&m[E].push(h[3]);for(o=new RegExp("\\("+M(e)+'\\("(dll-reference\\s('+L+'))"\\)\\)'+D,"g");h=o.exec(p);)T[h[2]]||(m[E].push(h[1]),T[h[2]]=n(h[1]).m),m[h[2]]=m[h[2]]||[],m[h[2]].push(h[4]);for(var g=Object.keys(m),i=0;i<g.length;i++)for(var r=0;r<m[g[i]].length;r++)R(m[g[i]][r])&&(m[g[i]][r]=1*m[g[i]][r]);return m}function _(T){var A=Object.keys(T);return A.reduce(function(E,m){return E||T[m].length>0},!1)}function y(T,A){for(var E={main:[A]},m={main:[]},p={main:{}};_(E);)for(var f=Object.keys(E),e=0;e<f.length;e++){var o=f[e],h=E[o],g=h.pop();if(p[o]=p[o]||{},!(p[o][g]||!T[o][g])){p[o][g]=!0,m[o]=m[o]||[],m[o].push(g);for(var i=O(T,T[o][g],o),r=Object.keys(i),l=0;l<r.length;l++)E[r[l]]=E[r[l]]||[],E[r[l]]=E[r[l]].concat(i[r[l]])}}return m}K.exports=function(T,A){A=A||{};var E={main:n.m},m=A.all?{main:Object.keys(E.main)}:y(E,T),p="";Object.keys(m).filter(function(g){return g!=="main"}).forEach(function(g){for(var i=0;m[g][i];)i++;m[g].push(i),E[g][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",p=p+"var "+g+" = ("+I.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+m[g].map(function(r){return""+JSON.stringify(r)+": "+E[g][r].toString()}).join(",")+`});
8
+ `}),p=p+"new (("+I.toString().replace("ENTRY_MODULE",JSON.stringify(T))+")({"+m.main.map(function(g){return""+JSON.stringify(g)+": "+E.main[g].toString()}).join(",")+"}))(self);";var f=new window.Blob([p],{type:"text/javascript"});if(A.bare)return f;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,o=e.createObjectURL(f),h=new window.Worker(o);return h.objectURL=o,h}},"./src/config.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"hlsDefaultConfig",function(){return l}),n.d(b,"mergeConfig",function(){return t}),n.d(b,"enableStreamingMode",function(){return a});var I=n("./src/controller/abr-controller.ts"),L=n("./src/controller/audio-stream-controller.ts"),D=n("./src/controller/audio-track-controller.ts"),M=n("./src/controller/subtitle-stream-controller.ts"),R=n("./src/controller/subtitle-track-controller.ts"),O=n("./src/controller/buffer-controller.ts"),_=n("./src/controller/timeline-controller.ts"),y=n("./src/controller/cap-level-controller.ts"),T=n("./src/controller/fps-controller.ts"),A=n("./src/controller/eme-controller.ts"),E=n("./src/controller/cmcd-controller.ts"),m=n("./src/utils/xhr-loader.ts"),p=n("./src/utils/fetch-loader.ts"),f=n("./src/utils/cues.ts"),e=n("./src/utils/mediakeys-helper.ts"),o=n("./src/utils/logger.ts");function h(){return h=Object.assign?Object.assign.bind():function(u){for(var s=1;s<arguments.length;s++){var d=arguments[s];for(var v in d)Object.prototype.hasOwnProperty.call(d,v)&&(u[v]=d[v])}return u},h.apply(this,arguments)}function g(u,s){var d=Object.keys(u);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(u);s&&(v=v.filter(function(S){return Object.getOwnPropertyDescriptor(u,S).enumerable})),d.push.apply(d,v)}return d}function i(u){for(var s=1;s<arguments.length;s++){var d=arguments[s]!=null?arguments[s]:{};s%2?g(Object(d),!0).forEach(function(v){r(u,v,d[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(d)):g(Object(d)).forEach(function(v){Object.defineProperty(u,v,Object.getOwnPropertyDescriptor(d,v))})}return u}function r(u,s,d){return s in u?Object.defineProperty(u,s,{value:d,enumerable:!0,configurable:!0,writable:!0}):u[s]=d,u}var l=i(i({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,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:m.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:I.default,bufferController:O.default,capLevelController:y.default,fpsController:T.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:e.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},c()),{},{subtitleStreamController:M.SubtitleStreamController,subtitleTrackController:R.default,timelineController:_.TimelineController,audioStreamController:L.default,audioTrackController:D.default,emeController:A.default,cmcdController:E.default});function c(){return{cueHandler:f.default,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function t(u,s){if((s.liveSyncDurationCount||s.liveMaxLatencyDurationCount)&&(s.liveSyncDuration||s.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(s.liveMaxLatencyDurationCount!==void 0&&(s.liveSyncDurationCount===void 0||s.liveMaxLatencyDurationCount<=s.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(s.liveMaxLatencyDuration!==void 0&&(s.liveSyncDuration===void 0||s.liveMaxLatencyDuration<=s.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return h({},u,s)}function a(u){var s=u.loader;if(s!==p.default&&s!==m.default)o.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),u.progressive=!1;else{var d=Object(p.fetchSupported)();d&&(u.loader=p.default,u.progressive=!0,u.enableSoftwareAES=!0,o.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/polyfills/number.ts"),L=n("./src/utils/ewma-bandwidth-estimator.ts"),D=n("./src/events.ts"),M=n("./src/utils/buffer-helper.ts"),R=n("./src/errors.ts"),O=n("./src/types/loader.ts"),_=n("./src/utils/logger.ts");function y(E,m){for(var p=0;p<m.length;p++){var f=m[p];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(E,f.key,f)}}function T(E,m,p){return m&&y(E.prototype,m),p&&y(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}var A=function(){function E(p){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=p;var f=p.config;this.bwEstimator=new L.default(f.abrEwmaSlowVoD,f.abrEwmaFastVoD,f.abrEwmaDefaultEstimate),this.registerListeners()}var m=E.prototype;return m.registerListeners=function(){var f=this.hls;f.on(D.Events.FRAG_LOADING,this.onFragLoading,this),f.on(D.Events.FRAG_LOADED,this.onFragLoaded,this),f.on(D.Events.FRAG_BUFFERED,this.onFragBuffered,this),f.on(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.on(D.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){var f=this.hls;f.off(D.Events.FRAG_LOADING,this.onFragLoading,this),f.off(D.Events.FRAG_LOADED,this.onFragLoaded,this),f.off(D.Events.FRAG_BUFFERED,this.onFragBuffered,this),f.off(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.off(D.Events.ERROR,this.onError,this)},m.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},m.onFragLoading=function(f,e){var o=e.frag;if(o.type===O.PlaylistLevelType.MAIN&&!this.timer){var h;this.fragCurrent=o,this.partCurrent=(h=e.part)!=null?h:null,this.timer=self.setInterval(this.onCheck,100)}},m.onLevelLoaded=function(f,e){var o=this.hls.config;e.details.live?this.bwEstimator.update(o.abrEwmaSlowLive,o.abrEwmaFastLive):this.bwEstimator.update(o.abrEwmaSlowVoD,o.abrEwmaFastVoD)},m._abandonRulesCheck=function(){var f=this.fragCurrent,e=this.partCurrent,o=this.hls,h=o.autoLevelEnabled,g=o.config,i=o.media;if(!(!f||!i)){var r=e?e.stats:f.stats,l=e?e.duration:f.duration;if(r.aborted){_.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!h||i.paused||!i.playbackRate||!i.readyState)){var c=performance.now()-r.loading.start,t=Math.abs(i.playbackRate);if(!(c<=500*l/t)){var a=o.levels,u=o.minAutoLevel,s=a[f.level],d=r.total||Math.max(r.loaded,Math.round(l*s.maxBitrate/8)),v=Math.max(1,r.bwEstimate?r.bwEstimate/8:r.loaded*1e3/c),S=(d-r.loaded)/v,x=i.currentTime,P=(M.BufferHelper.bufferInfo(i,x,g.maxBufferHole).end-x)/t;if(!(P>=2*l/t||S<=P)){var B=Number.POSITIVE_INFINITY,k;for(k=f.level-1;k>u;k--){var U=a[k].maxBitrate;if(B=l*U/(8*.8*v),B<P)break}if(!(B>=S)){var W=this.bwEstimator.getEstimate();_.logger.warn("Fragment "+f.sn+(e?" part "+e.index:"")+" of level "+f.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+k+`
9
+ Current BW estimate: `+(Object(I.isFiniteNumber)(W)?(W/1024).toFixed(3):"Unknown")+` Kb/s
10
10
  Estimated load time for current fragment: `+S.toFixed(3)+` s
11
11
  Estimated load time for the next fragment: `+B.toFixed(3)+` s
12
- Time to underbuffer: `+I.toFixed(3)+" s"),o.nextLoadLevel=k,this.bwEstimator.sample(c,r.loaded),this.clearTimer(),d.loader&&(this.fragCurrent=this.partCurrent=null,d.loader.abort()),o.trigger(A.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:d,part:e,stats:r})}}}}}},m.onFragLoaded=function(d,e){var o=e.frag,h=e.part;if(o.type===O.PlaylistLevelType.MAIN&&Object(P.isFiniteNumber)(o.sn)){var g=h?h.stats:o.stats,i=h?h.duration:o.duration;if(this.clearTimer(),this.lastLoadedFragLevel=o.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var r=this.hls.levels[o.level],l=(r.loaded?r.loaded.bytes:0)+g.loaded,c=(r.loaded?r.loaded.duration:0)+i;r.loaded={bytes:l,duration:c},r.realBitrate=Math.round(8*l/c)}if(o.bitrateTest){var t={stats:g,frag:o,part:h,id:o.type};this.onFragBuffered(A.Events.FRAG_BUFFERED,t)}}},m.onFragBuffered=function(d,e){var o=e.frag,h=e.part,g=h?h.stats:o.stats;if(!g.aborted&&!(o.type!==O.PlaylistLevelType.MAIN||o.sn==="initSegment")){var i=g.parsing.end-g.loading.start;this.bwEstimator.sample(i,g.loaded),g.bwEstimate=this.bwEstimator.getEstimate(),o.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},m.onError=function(d,e){switch(e.details){case R.ErrorDetails.FRAG_LOAD_ERROR:case R.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},m.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},m.getNextABRAutoLevel=function(){var d=this.fragCurrent,e=this.partCurrent,o=this.hls,h=o.maxAutoLevel,g=o.config,i=o.minAutoLevel,r=o.media,l=e?e.duration:d?d.duration:0,c=r?r.currentTime:0,t=r&&r.playbackRate!==0?Math.abs(r.playbackRate):1,a=this.bwEstimator?this.bwEstimator.getEstimate():g.abrEwmaDefaultEstimate,u=(M.BufferHelper.bufferInfo(r,c,g.maxBufferHole).end-c)/t,s=this.findBestLevel(a,i,h,u,g.abrBandWidthFactor,g.abrBandWidthUpFactor);if(s>=0)return s;_.logger.trace((u?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var f=l?Math.min(l,g.maxStarvationDelay):g.maxStarvationDelay,v=g.abrBandWidthFactor,S=g.abrBandWidthUpFactor;if(!u){var x=this.bitrateTestDelay;if(x){var I=l?Math.min(l,g.maxLoadingDelay):g.maxLoadingDelay;f=I-x,_.logger.trace("bitrate test took "+Math.round(1e3*x)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*f)+" ms"),v=S=1}}return s=this.findBestLevel(a,i,h,u+f,v,S),Math.max(s,0)},m.findBestLevel=function(d,e,o,h,g,i){for(var r,l=this.fragCurrent,c=this.partCurrent,t=this.lastLoadedFragLevel,a=this.hls.levels,u=a[t],s=!!(u!=null&&(r=u.details)!==null&&r!==void 0&&r.live),f=u==null?void 0:u.codecSet,v=c?c.duration:l?l.duration:0,S=o;S>=e;S--){var x=a[S];if(!(!x||f&&x.codecSet!==f)){var I=x.details,B=(c?I==null?void 0:I.partTarget:I==null?void 0:I.averagetargetduration)||v,k=void 0;S<=t?k=g*d:k=i*d;var U=a[S].maxBitrate,W=U*B/k;if(_.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+S+"/"+Math.round(k)+"/"+U+"/"+B+"/"+h+"/"+W),k>U&&(!W||s&&!this.bitrateTestDelay||W<h))return S}}return-1},T(E,[{key:"nextAutoLevel",get:function(){var d=this._nextAutoLevel,e=this.bwEstimator;if(d!==-1&&!e.canEstimate())return d;var o=this.getNextABRAutoLevel();return d!==-1&&this.hls.levels[o].loadError?d:(d!==-1&&(o=Math.min(d,o)),o)},set:function(d){this._nextAutoLevel=d}}]),E}();b.default=D},"./src/controller/audio-stream-controller.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/polyfills/number.ts"),L=n("./src/controller/base-stream-controller.ts"),A=n("./src/events.ts"),M=n("./src/utils/buffer-helper.ts"),R=n("./src/controller/fragment-tracker.ts"),O=n("./src/types/level.ts"),_=n("./src/types/loader.ts"),y=n("./src/loader/fragment.ts"),T=n("./src/demux/chunk-cache.ts"),D=n("./src/demux/transmuxer-interface.ts"),E=n("./src/types/transmuxer.ts"),m=n("./src/controller/fragment-finders.ts"),p=n("./src/utils/discontinuities.ts"),d=n("./src/errors.ts");function e(){return e=Object.assign?Object.assign.bind():function(r){for(var l=1;l<arguments.length;l++){var c=arguments[l];for(var t in c)Object.prototype.hasOwnProperty.call(c,t)&&(r[t]=c[t])}return r},e.apply(this,arguments)}function o(r,l){r.prototype=Object.create(l.prototype),r.prototype.constructor=r,h(r,l)}function h(r,l){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,a){return t.__proto__=a,t},h(r,l)}var g=100,i=function(r){o(l,r);function l(t,a){var u;return u=r.call(this,t,a,"[audio-stream-controller]")||this,u.videoBuffer=null,u.videoTrackCC=-1,u.waitingVideoCC=-1,u.audioSwitch=!1,u.trackId=-1,u.waitingData=null,u.mainDetails=null,u.bufferFlushed=!1,u.cachedTrackLoadedData=null,u._registerListeners(),u}var c=l.prototype;return c.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},c._registerListeners=function(){var a=this.hls;a.on(A.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.on(A.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(A.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.on(A.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),a.on(A.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),a.on(A.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.on(A.Events.ERROR,this.onError,this),a.on(A.Events.BUFFER_RESET,this.onBufferReset,this),a.on(A.Events.BUFFER_CREATED,this.onBufferCreated,this),a.on(A.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),a.on(A.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),a.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var a=this.hls;a.off(A.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.off(A.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(A.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.off(A.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),a.off(A.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),a.off(A.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.off(A.Events.ERROR,this.onError,this),a.off(A.Events.BUFFER_RESET,this.onBufferReset,this),a.off(A.Events.BUFFER_CREATED,this.onBufferCreated,this),a.off(A.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),a.off(A.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),a.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onInitPtsFound=function(a,u){var s=u.frag,f=u.id,v=u.initPTS;if(f==="main"){var S=s.cc;this.initPTS[s.cc]=v,this.log("InitPTS for cc: "+S+" found from main: "+v),this.videoTrackCC=S,this.state===L.State.WAITING_INIT_PTS&&this.tick()}},c.startLoad=function(a){if(!this.levels){this.startPosition=a,this.state=L.State.STOPPED;return}var u=this.lastCurrentTime;this.stopLoad(),this.setInterval(g),this.fragLoadError=0,u>0&&a===-1?(this.log("Override startPosition with lastCurrentTime @"+u.toFixed(3)),a=u,this.state=L.State.IDLE):(this.loadedmetadata=!1,this.state=L.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=a,this.tick()},c.doTick=function(){switch(this.state){case L.State.IDLE:this.doTickIdle();break;case L.State.WAITING_TRACK:{var a,u=this.levels,s=this.trackId,f=u==null||(a=u[s])===null||a===void 0?void 0:a.details;if(f){if(this.waitForCdnTuneIn(f))break;this.state=L.State.WAITING_INIT_PTS}break}case L.State.FRAG_LOADING_WAITING_RETRY:{var v,S=performance.now(),x=this.retryDate;(!x||S>=x||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=L.State.IDLE);break}case L.State.WAITING_INIT_PTS:{var I=this.waitingData;if(I){var B=I.frag,k=I.part,U=I.cache,W=I.complete;if(this.initPTS[B.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=L.State.FRAG_LOADING;var G=U.flush(),X={frag:B,part:k,payload:G,networkDetails:null};this._handleFragmentLoadProgress(X),W&&r.prototype._handleFragmentLoadComplete.call(this,X)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+B.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var Y=this.getLoadPosition(),J=M.BufferHelper.bufferInfo(this.mediaBuffer,Y,this.config.maxBufferHole),ee=Object(m.fragmentWithinToleranceTest)(J.end,this.config.maxFragLookUpTolerance,B);ee<0&&(this.log("Waiting fragment cc ("+B.cc+") @ "+B.start+" cancelled because another fragment at "+J.end+" is needed"),this.clearWaitingFragment())}}else this.state=L.State.IDLE}}this.onTickEnd()},c.clearWaitingFragment=function(){var a=this.waitingData;a&&(this.fragmentTracker.removeFragment(a.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=L.State.IDLE)},c.resetLoadingState=function(){this.clearWaitingFragment(),r.prototype.resetLoadingState.call(this)},c.onTickEnd=function(){var a=this.media;if(!(!a||!a.readyState)){var u=this.mediaBuffer?this.mediaBuffer:a,s=u.buffered;!this.loadedmetadata&&s.length&&(this.loadedmetadata=!0),this.lastCurrentTime=a.currentTime}},c.doTickIdle=function(){var a,u,s=this.hls,f=this.levels,v=this.media,S=this.trackId,x=s.config;if(!(!f||!f[S])&&!(!v&&(this.startFragRequested||!x.startFragPrefetch))){var I=f[S],B=I.details;if(!B||B.live&&this.levelLastLoaded!==S||this.waitForCdnTuneIn(B)){this.state=L.State.WAITING_TRACK;return}var k=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&k&&(this.bufferFlushed=!1,this.afterBufferFlushed(k,y.ElementaryStreamTypes.AUDIO,_.PlaylistLevelType.AUDIO));var U=this.getFwdBufferInfo(k,_.PlaylistLevelType.AUDIO);if(U!==null){var W=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_.PlaylistLevelType.MAIN),G=U.len,X=this.getMaxBufferLength(W==null?void 0:W.len),Y=this.audioSwitch;if(!(G>=X&&!Y)){if(!Y&&this._streamEnded(U,B)){s.trigger(A.Events.BUFFER_EOS,{type:"audio"}),this.state=L.State.ENDED;return}var J=B.fragments,ee=J[0].start,z=U.end;if(Y&&v){var q=this.getLoadPosition();z=q,B.PTSKnown&&q<ee&&(U.end>ee||U.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),v.currentTime=ee+.05)}if(!(W&&z>W.end+B.targetduration)&&!((!W||!W.len)&&U.len)){var ie=this.getNextFragment(z,B);if(!ie){this.bufferFlushed=!0;return}((a=ie.decryptdata)===null||a===void 0?void 0:a.keyFormat)==="identity"&&!((u=ie.decryptdata)!==null&&u!==void 0&&u.key)?this.loadKey(ie,B):this.loadFragment(ie,B,z)}}}}},c.getMaxBufferLength=function(a){var u=r.prototype.getMaxBufferLength.call(this);return a?Math.max(u,a):u},c.onMediaDetaching=function(){this.videoBuffer=null,r.prototype.onMediaDetaching.call(this)},c.onAudioTracksUpdated=function(a,u){var s=u.audioTracks;this.resetTransmuxer(),this.levels=s.map(function(f){return new O.Level(f)})},c.onAudioTrackSwitching=function(a,u){var s=!!u.url;this.trackId=u.id;var f=this.fragCurrent;f!=null&&f.loader&&f.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),s?this.setInterval(g):this.resetTransmuxer(),s?(this.audioSwitch=!0,this.state=L.State.IDLE):this.state=L.State.STOPPED,this.tick()},c.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},c.onLevelLoaded=function(a,u){this.mainDetails=u.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(A.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},c.onAudioTrackLoaded=function(a,u){var s;if(this.mainDetails==null){this.cachedTrackLoadedData=u;return}var f=this.levels,v=u.details,S=u.id;if(!f){this.warn("Audio tracks were reset while loading level "+S);return}this.log("Track "+S+" loaded ["+v.startSN+","+v.endSN+"],duration:"+v.totalduration);var x=f[S],I=0;if(v.live||(s=x.details)!==null&&s!==void 0&&s.live){var B=this.mainDetails;if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed||!B)return;!x.details&&v.hasProgramDateTime&&B.hasProgramDateTime?(Object(p.alignMediaPlaylistByPDT)(v,B),I=v.fragments[0].start):I=this.alignPlaylists(v,x.details)}x.details=v,this.levelLastLoaded=S,!this.startFragRequested&&(this.mainDetails||!v.live)&&this.setStartPosition(x.details,I),this.state===L.State.WAITING_TRACK&&!this.waitForCdnTuneIn(v)&&(this.state=L.State.IDLE),this.tick()},c._handleFragmentLoadProgress=function(a){var u,s=a.frag,f=a.part,v=a.payload,S=this.config,x=this.trackId,I=this.levels;if(!I){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+s.sn+" of level "+s.level+" will not be buffered");return}var B=I[x];console.assert(B,"Audio track is defined on fragment load progress");var k=B.details;console.assert(k,"Audio track details are defined on fragment load progress");var U=S.defaultAudioCodec||B.audioCodec||"mp4a.40.2",W=this.transmuxer;W||(W=this.transmuxer=new D.default(this.hls,_.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var G=this.initPTS[s.cc],X=(u=s.initSegment)===null||u===void 0?void 0:u.data;if(G!==void 0){var Y=!1,J=f?f.index:-1,ee=J!==-1,z=new E.ChunkMetadata(s.level,s.sn,s.stats.chunkCount,v.byteLength,J,ee);W.push(v,X,U,"",s,f,k.totalduration,Y,z,G)}else{this.log("Unknown video PTS for cc "+s.cc+", waiting for video PTS before demuxing audio frag "+s.sn+" of ["+k.startSN+" ,"+k.endSN+"],track "+x);var q=this.waitingData=this.waitingData||{frag:s,part:f,cache:new T.default,complete:!1},ie=q.cache;ie.push(new Uint8Array(v)),this.waitingVideoCC=this.videoTrackCC,this.state=L.State.WAITING_INIT_PTS}},c._handleFragmentLoadComplete=function(a){if(this.waitingData){this.waitingData.complete=!0;return}r.prototype._handleFragmentLoadComplete.call(this,a)},c.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},c.onBufferCreated=function(a,u){var s=u.tracks.audio;s&&(this.mediaBuffer=s.buffer||null),u.tracks.video&&(this.videoBuffer=u.tracks.video.buffer||null)},c.onFragBuffered=function(a,u){var s=u.frag,f=u.part;if(s.type===_.PlaylistLevelType.AUDIO){if(this.fragContextChanged(s)){this.warn("Fragment "+s.sn+(f?" p: "+f.index:"")+" of level "+s.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}s.sn!=="initSegment"&&(this.fragPrevious=s,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(s,f)}},c.onError=function(a,u){switch(u.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.AUDIO,u);break;case d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case d.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==L.State.ERROR&&this.state!==L.State.STOPPED&&(this.state=u.fatal?L.State.ERROR:L.State.IDLE,this.warn(u.details+" while loading frag, switching to "+this.state+" state"));break;case d.ErrorDetails.BUFFER_FULL_ERROR:if(u.parent==="audio"&&(this.state===L.State.PARSING||this.state===L.State.PARSED)){var s=!0,f=this.getFwdBufferInfo(this.mediaBuffer,_.PlaylistLevelType.AUDIO);f&&f.len>.5&&(s=!this.reduceMaxBufferLength(f.len)),s&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},c.onBufferFlushed=function(a,u){var s=u.type;s===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},c._handleTransmuxComplete=function(a){var u,s="audio",f=this.hls,v=a.remuxResult,S=a.chunkMeta,x=this.getCurrentContext(S);if(!x){this.warn("The loading context changed while buffering fragment "+S.sn+" of level "+S.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(S.level);return}var I=x.frag,B=x.part,k=x.level.details,U=v.audio,W=v.text,G=v.id3,X=v.initSegment;if(!(this.fragContextChanged(I)||!k)){if(this.state=L.State.PARSING,this.audioSwitch&&U&&this.completeAudioSwitch(),X!=null&&X.tracks&&(this._bufferInitSegment(X.tracks,I,S),f.trigger(A.Events.FRAG_PARSING_INIT_SEGMENT,{frag:I,id:s,tracks:X.tracks})),U){var Y=U.startPTS,J=U.endPTS,ee=U.startDTS,z=U.endDTS;B&&(B.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:Y,endPTS:J,startDTS:ee,endDTS:z}),I.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,Y,J,ee,z),this.bufferFragmentData(U,I,B,S)}if(G!=null&&(u=G.samples)!==null&&u!==void 0&&u.length){var q=e({id:s,frag:I,details:k},G);f.trigger(A.Events.FRAG_PARSING_METADATA,q)}if(W){var ie=e({id:s,frag:I,details:k},W);f.trigger(A.Events.FRAG_PARSING_USERDATA,ie)}}},c._bufferInitSegment=function(a,u,s){if(this.state===L.State.PARSING){a.video&&delete a.video;var f=a.audio;if(!!f){f.levelCodec=f.codec,f.id="audio",this.log("Init audio buffer, container:"+f.container+", codecs[parsed]=["+f.codec+"]"),this.hls.trigger(A.Events.BUFFER_CODECS,a);var v=f.initSegment;if(v!=null&&v.byteLength){var S={type:"audio",frag:u,part:null,chunkMeta:s,parent:u.type,data:v};this.hls.trigger(A.Events.BUFFER_APPENDING,S)}this.tick()}}},c.loadFragment=function(a,u,s){var f=this.fragmentTracker.getState(a);this.fragCurrent=a,(this.audioSwitch||f===R.FragmentState.NOT_LOADED||f===R.FragmentState.PARTIAL)&&(a.sn==="initSegment"?this._loadInitSegment(a):u.live&&!Object(P.isFiniteNumber)(this.initPTS[a.cc])?(this.log("Waiting for video PTS in continuity counter "+a.cc+" of live stream before loading audio fragment "+a.sn+" of level "+this.trackId),this.state=L.State.WAITING_INIT_PTS):(this.startFragRequested=!0,r.prototype.loadFragment.call(this,a,u,s)))},c.completeAudioSwitch=function(){var a=this.hls,u=this.media,s=this.trackId;u&&(this.log("Switching audio track : flushing all audio"),r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,a.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:s})},l}(L.default);b.default=i},"./src/controller/audio-track-controller.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/events.ts"),L=n("./src/errors.ts"),A=n("./src/controller/base-playlist-controller.ts"),M=n("./src/types/loader.ts");function R(D,E){for(var m=0;m<E.length;m++){var p=E[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(D,p.key,p)}}function O(D,E,m){return E&&R(D.prototype,E),m&&R(D,m),Object.defineProperty(D,"prototype",{writable:!1}),D}function _(D,E){D.prototype=Object.create(E.prototype),D.prototype.constructor=D,y(D,E)}function y(D,E){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,d){return p.__proto__=d,p},y(D,E)}var T=function(D){_(E,D);function E(p){var d;return d=D.call(this,p,"[audio-track-controller]")||this,d.tracks=[],d.groupId=null,d.tracksInGroup=[],d.trackId=-1,d.trackName="",d.selectDefaultTrack=!0,d.registerListeners(),d}var m=E.prototype;return m.registerListeners=function(){var d=this.hls;d.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.on(P.Events.LEVEL_LOADING,this.onLevelLoading,this),d.on(P.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),d.on(P.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.on(P.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){var d=this.hls;d.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.off(P.Events.LEVEL_LOADING,this.onLevelLoading,this),d.off(P.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),d.off(P.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.off(P.Events.ERROR,this.onError,this)},m.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,D.prototype.destroy.call(this)},m.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},m.onManifestParsed=function(d,e){this.tracks=e.audioTracks||[]},m.onAudioTrackLoaded=function(d,e){var o=e.id,h=e.details,g=this.tracksInGroup[o];if(!g){this.warn("Invalid audio track id "+o);return}var i=g.details;g.details=e.details,this.log("audioTrack "+o+" loaded ["+h.startSN+"-"+h.endSN+"]"),o===this.trackId&&(this.retryCount=0,this.playlistLoaded(o,e,i))},m.onLevelLoading=function(d,e){this.switchLevel(e.level)},m.onLevelSwitching=function(d,e){this.switchLevel(e.level)},m.switchLevel=function(d){var e=this.hls.levels[d];if(!!(e!=null&&e.audioGroupIds)){var o=e.audioGroupIds[e.urlId];if(this.groupId!==o){this.groupId=o;var h=this.tracks.filter(function(i){return!o||i.groupId===o});this.selectDefaultTrack&&!h.some(function(i){return i.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=h;var g={audioTracks:h};this.log("Updating audio tracks, "+h.length+' track(s) found in "'+o+'" group-id'),this.hls.trigger(P.Events.AUDIO_TRACKS_UPDATED,g),this.selectInitialTrack()}}},m.onError=function(d,e){D.prototype.onError.call(this,d,e),!(e.fatal||!e.context)&&e.context.type===M.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},m.setAudioTrack=function(d){var e=this.tracksInGroup;if(d<0||d>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var o=e[this.trackId];this.log("Now switching to audio-track index "+d);var h=e[d],g=h.id,i=h.groupId,r=i===void 0?"":i,l=h.name,c=h.type,t=h.url;if(this.trackId=d,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(P.Events.AUDIO_TRACK_SWITCHING,{id:g,groupId:r,name:l,type:c,url:t}),!(h.details&&!h.details.live)){var a=this.switchParams(h.url,o==null?void 0:o.details);this.loadPlaylist(a)}},m.selectInitialTrack=function(){var d=this.tracksInGroup;console.assert(d.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,o=this.findTrackId(e)||this.findTrackId();o!==-1?this.setAudioTrack(o):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},m.findTrackId=function(d){for(var e=this.tracksInGroup,o=0;o<e.length;o++){var h=e[o];if((!this.selectDefaultTrack||h.default)&&(!d||d===h.name))return h.id}return-1},m.loadPlaylist=function(d){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var o=e.id,h=e.groupId,g=e.url;if(d)try{g=d.addDirectives(g)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("loading audio-track playlist for id: "+o),this.clearTimer(),this.hls.trigger(P.Events.AUDIO_TRACK_LOADING,{url:g,id:o,groupId:h,deliveryDirectives:d||null})}},O(E,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(d){this.selectDefaultTrack=!1,this.setAudioTrack(d)}}]),E}(A.default);b.default=T},"./src/controller/base-playlist-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return O});var P=n("./src/polyfills/number.ts"),L=n("./src/types/level.ts"),A=n("./src/controller/level-helper.ts"),M=n("./src/utils/logger.ts"),R=n("./src/errors.ts"),O=function(){function _(T,D){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=M.logger.log.bind(M.logger,D+":"),this.warn=M.logger.warn.bind(M.logger,D+":"),this.hls=T}var y=_.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(D,E){E.fatal&&E.type===R.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},y.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},y.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},y.stopLoad=function(){this.canLoad=!1,this.clearTimer()},y.switchParams=function(D,E){var m=E==null?void 0:E.renditionReports;if(m)for(var p=0;p<m.length;p++){var d=m[p],e=""+d.URI;if(e===D.slice(-e.length)){var o=parseInt(d["LAST-MSN"]),h=parseInt(d["LAST-PART"]);if(E&&this.hls.config.lowLatencyMode){var g=Math.min(E.age-E.partTarget,E.targetduration);h!==void 0&&g>E.partTarget&&(h+=1)}if(Object(P.isFiniteNumber)(o))return new L.HlsUrlParameters(o,Object(P.isFiniteNumber)(h)?h:void 0,L.HlsSkip.No)}}},y.loadPlaylist=function(D){},y.shouldLoadTrack=function(D){return this.canLoad&&D&&!!D.url&&(!D.details||D.details.live)},y.playlistLoaded=function(D,E,m){var p=this,d=E.details,e=E.stats,o=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(d.advancedDateTime=Date.now()-o,d.live||m!=null&&m.live){if(d.reloaded(m),m&&this.log("live playlist "+D+" "+(d.advanced?"REFRESHED "+d.lastPartSn+"-"+d.lastPartIndex:"MISSED")),m&&d.fragments.length>0&&Object(A.mergeDetails)(m,d),!this.canLoad||!d.live)return;var h,g=void 0,i=void 0;if(d.canBlockReload&&d.endSN&&d.advanced){var r=this.hls.config.lowLatencyMode,l=d.lastPartSn,c=d.endSN,t=d.lastPartIndex,a=t!==-1,u=l===c,s=r?0:t;a?(g=u?c+1:l,i=u?s:t+1):g=c+1;var f=d.age,v=f+d.ageHeader,S=Math.min(v-d.partTarget,d.targetduration*1.5);if(S>0){if(m&&S>m.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+m.tuneInGoal+" to: "+S+" with playlist age: "+d.age),S=0;else{var x=Math.floor(S/d.targetduration);if(g+=x,i!==void 0){var I=Math.round(S%d.targetduration/d.partTarget);i+=I}this.log("CDN Tune-in age: "+d.ageHeader+"s last advanced "+f.toFixed(2)+"s goal: "+S+" skip sn "+x+" to part "+i)}d.tuneInGoal=S}if(h=this.getDeliveryDirectives(d,E.deliveryDirectives,g,i),r||!u){this.loadPlaylist(h);return}}else h=this.getDeliveryDirectives(d,E.deliveryDirectives,g,i);var B=Object(A.computeReloadInterval)(d,e);g!==void 0&&d.canBlockReload&&(B-=d.partTarget||1),this.log("reload live playlist "+D+" in "+Math.round(B)+" ms"),this.timer=self.setTimeout(function(){return p.loadPlaylist(h)},B)}else this.clearTimer()},y.getDeliveryDirectives=function(D,E,m,p){var d=Object(L.getSkipValue)(D,m);return E!=null&&E.skip&&D.deltaUpdateFailed&&(m=E.msn,p=E.part,d=L.HlsSkip.No),new L.HlsUrlParameters(m,p,d)},y.retryLoadingOrFail=function(D){var E=this,m=this.hls.config,p=this.retryCount<m.levelLoadingMaxRetry;if(p){var d;if(this.retryCount++,D.details.indexOf("LoadTimeOut")>-1&&(d=D.context)!==null&&d!==void 0&&d.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+D.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*m.levelLoadingRetryDelay,m.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return E.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+D.details+'"')}}else this.warn('cannot recover from error "'+D.details+'"'),this.clearTimer(),D.fatal=!0;return p},_}()},"./src/controller/base-stream-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"State",function(){return c}),n.d(b,"default",function(){return t});var P=n("./src/polyfills/number.ts"),L=n("./src/task-loop.ts"),A=n("./src/controller/fragment-tracker.ts"),M=n("./src/utils/buffer-helper.ts"),R=n("./src/utils/logger.ts"),O=n("./src/events.ts"),_=n("./src/errors.ts"),y=n("./src/types/transmuxer.ts"),T=n("./src/utils/mp4-tools.ts"),D=n("./src/utils/discontinuities.ts"),E=n("./src/controller/fragment-finders.ts"),m=n("./src/controller/level-helper.ts"),p=n("./src/loader/fragment-loader.ts"),d=n("./src/crypt/decrypter.ts"),e=n("./src/utils/time-ranges.ts"),o=n("./src/types/loader.ts");function h(a,u){for(var s=0;s<u.length;s++){var f=u[s];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(a,f.key,f)}}function g(a,u,s){return u&&h(a.prototype,u),s&&h(a,s),Object.defineProperty(a,"prototype",{writable:!1}),a}function i(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function r(a,u){a.prototype=Object.create(u.prototype),a.prototype.constructor=a,l(a,u)}function l(a,u){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,v){return f.__proto__=v,f},l(a,u)}var c={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},t=function(a){r(u,a);function u(f,v,S){var x;return x=a.call(this)||this,x.hls=void 0,x.fragPrevious=null,x.fragCurrent=null,x.fragmentTracker=void 0,x.transmuxer=null,x._state=c.STOPPED,x.media=null,x.mediaBuffer=null,x.config=void 0,x.bitrateTest=!1,x.lastCurrentTime=0,x.nextLoadPosition=0,x.startPosition=0,x.loadedmetadata=!1,x.fragLoadError=0,x.retryDate=0,x.levels=null,x.fragmentLoader=void 0,x.levelLastLoaded=null,x.startFragRequested=!1,x.decrypter=void 0,x.initPTS=[],x.onvseeking=null,x.onvended=null,x.logPrefix="",x.log=void 0,x.warn=void 0,x.logPrefix=S,x.log=R.logger.log.bind(R.logger,S+":"),x.warn=R.logger.warn.bind(R.logger,S+":"),x.hls=f,x.fragmentLoader=new p.default(f.config),x.fragmentTracker=v,x.config=f.config,x.decrypter=new d.default(f,f.config),f.on(O.Events.KEY_LOADED,x.onKeyLoaded,i(x)),f.on(O.Events.LEVEL_SWITCHING,x.onLevelSwitching,i(x)),x}var s=u.prototype;return s.doTick=function(){this.onTickEnd()},s.onTickEnd=function(){},s.startLoad=function(v){},s.stopLoad=function(){this.fragmentLoader.abort();var v=this.fragCurrent;v&&this.fragmentTracker.removeFragment(v),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=c.STOPPED},s._streamEnded=function(v,S){var x=this.fragCurrent,I=this.fragmentTracker;if(!S.live&&x&&this.media&&x.sn>=S.endSN&&!v.nextStart){var B=S.partList;if(B!=null&&B.length){var k=B[B.length-1],U=M.BufferHelper.isBuffered(this.media,k.start+k.duration/2);return U}var W=I.getState(x);return W===A.FragmentState.PARTIAL||W===A.FragmentState.OK}return!1},s.onMediaAttached=function(v,S){var x=this.media=this.mediaBuffer=S.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),x.addEventListener("seeking",this.onvseeking),x.addEventListener("ended",this.onvended);var I=this.config;this.levels&&I.autoStartLoad&&this.state===c.STOPPED&&this.startLoad(I.startPosition)},s.onMediaDetaching=function(){var v=this.media;v!=null&&v.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),v&&this.onvseeking&&this.onvended&&(v.removeEventListener("seeking",this.onvseeking),v.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},s.onMediaSeeking=function(){var v=this.config,S=this.fragCurrent,x=this.media,I=this.mediaBuffer,B=this.state,k=x?x.currentTime:0,U=M.BufferHelper.bufferInfo(I||x,k,v.maxBufferHole);if(this.log("media seeking to "+(Object(P.isFiniteNumber)(k)?k.toFixed(3):k)+", state: "+B),B===c.ENDED)this.resetLoadingState();else if(S&&!U.len){var W=v.maxFragLookUpTolerance,G=S.start-W,X=S.start+S.duration+W,Y=k>X;(k<G||Y)&&(Y&&S.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),S.loader.abort()),this.resetLoadingState())}x&&(this.lastCurrentTime=k),!this.loadedmetadata&&!U.len&&(this.nextLoadPosition=this.startPosition=k),this.tickImmediate()},s.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},s.onKeyLoaded=function(v,S){if(!(this.state!==c.KEY_LOADING||S.frag!==this.fragCurrent||!this.levels)){this.state=c.IDLE;var x=this.levels[S.frag.level].details;x&&this.loadFragment(S.frag,x,S.frag.start)}},s.onLevelSwitching=function(v,S){this.fragLoadError=0},s.onHandlerDestroying=function(){this.stopLoad(),a.prototype.onHandlerDestroying.call(this)},s.onHandlerDestroyed=function(){this.state=c.STOPPED,this.hls.off(O.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(O.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,a.prototype.onHandlerDestroyed.call(this)},s.loadKey=function(v,S){this.log("Loading key for "+v.sn+" of ["+S.startSN+"-"+S.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level),this.state=c.KEY_LOADING,this.fragCurrent=v,this.hls.trigger(O.Events.KEY_LOADING,{frag:v})},s.loadFragment=function(v,S,x){this._loadFragForPlayback(v,S,x)},s._loadFragForPlayback=function(v,S,x){var I=this,B=function(U){if(I.fragContextChanged(v)){I.warn("Fragment "+v.sn+(U.part?" p: "+U.part.index:"")+" of level "+v.level+" was dropped during download."),I.fragmentTracker.removeFragment(v);return}v.stats.chunkCount++,I._handleFragmentLoadProgress(U)};this._doFragLoad(v,S,x,B).then(function(k){if(!!k){I.fragLoadError=0;var U=I.state;if(I.fragContextChanged(v)){(U===c.FRAG_LOADING||!I.fragCurrent&&U===c.PARSING)&&(I.fragmentTracker.removeFragment(v),I.state=c.IDLE);return}"payload"in k&&(I.log("Loaded fragment "+v.sn+" of level "+v.level),I.hls.trigger(O.Events.FRAG_LOADED,k)),I._handleFragmentLoadComplete(k)}}).catch(function(k){I.state===c.STOPPED||I.state===c.ERROR||(I.warn(k),I.resetFragmentLoading(v))})},s.flushMainBuffer=function(v,S,x){if(x===void 0&&(x=null),!!(v-S)){var I={startOffset:v,endOffset:S,type:x};this.fragLoadError=0,this.hls.trigger(O.Events.BUFFER_FLUSHING,I)}},s._loadInitSegment=function(v){var S=this;this._doFragLoad(v).then(function(x){if(!x||S.fragContextChanged(v)||!S.levels)throw new Error("init load aborted");return x}).then(function(x){var I=S.hls,B=x.payload,k=v.decryptdata;if(B&&B.byteLength>0&&k&&k.key&&k.iv&&k.method==="AES-128"){var U=self.performance.now();return S.decrypter.webCryptoDecrypt(new Uint8Array(B),k.key.buffer,k.iv.buffer).then(function(W){var G=self.performance.now();return I.trigger(O.Events.FRAG_DECRYPTED,{frag:v,payload:W,stats:{tstart:U,tdecrypt:G}}),x.payload=W,x})}return x}).then(function(x){var I=S.fragCurrent,B=S.hls,k=S.levels;if(!k)throw new Error("init load aborted, missing levels");var U=k[v.level].details;console.assert(U,"Level details are defined when init segment is loaded");var W=v.stats;S.state=c.IDLE,S.fragLoadError=0,v.data=new Uint8Array(x.payload),W.parsing.start=W.buffering.start=self.performance.now(),W.parsing.end=W.buffering.end=self.performance.now(),x.frag===I&&B.trigger(O.Events.FRAG_BUFFERED,{stats:W,frag:I,part:null,id:v.type}),S.tick()}).catch(function(x){S.state===c.STOPPED||S.state===c.ERROR||(S.warn(x),S.resetFragmentLoading(v))})},s.fragContextChanged=function(v){var S=this.fragCurrent;return!v||!S||v.level!==S.level||v.sn!==S.sn||v.urlId!==S.urlId},s.fragBufferedComplete=function(v,S){var x=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+v.type+" sn: "+v.sn+(S?" part: "+S.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level+" "+(x?e.default.toString(M.BufferHelper.getBuffered(x)):"(detached)")),this.state=c.IDLE,x&&(!this.loadedmetadata&&x.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},s.seekToStartPos=function(){},s._handleFragmentLoadComplete=function(v){var S=this.transmuxer;if(!!S){var x=v.frag,I=v.part,B=v.partsLoaded,k=!B||B.length===0||B.some(function(W){return!W}),U=new y.ChunkMetadata(x.level,x.sn,x.stats.chunkCount+1,0,I?I.index:-1,!k);S.flush(U)}},s._handleFragmentLoadProgress=function(v){},s._doFragLoad=function(v,S,x,I){var B=this;if(x===void 0&&(x=null),!this.levels)throw new Error("frag load aborted, missing levels");if(x=Math.max(v.start,x||0),this.config.lowLatencyMode&&S){var k=S.partList;if(k&&I){x>v.end&&S.fragmentHint&&(v=S.fragmentHint);var U=this.getNextPart(k,v,x);if(U>-1){var W=k[U];return this.log("Loading part sn: "+v.sn+" p: "+W.index+" cc: "+v.cc+" of playlist ["+S.startSN+"-"+S.endSN+"] parts [0-"+U+"-"+(k.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(x.toFixed(3))),this.nextLoadPosition=W.start+W.duration,this.state=c.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:v,part:k[U],targetBufferTime:x}),this.doFragPartsLoad(v,k,U,I).catch(function(G){return B.handleFragLoadError(G)})}else if(!v.url||this.loadedEndOfParts(k,x))return Promise.resolve(null)}}return this.log("Loading fragment "+v.sn+" cc: "+v.cc+" "+(S?"of ["+S.startSN+"-"+S.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(x.toFixed(3))),Object(P.isFiniteNumber)(v.sn)&&!this.bitrateTest&&(this.nextLoadPosition=v.start+v.duration),this.state=c.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:v,targetBufferTime:x}),this.fragmentLoader.load(v,I).catch(function(G){return B.handleFragLoadError(G)})},s.doFragPartsLoad=function(v,S,x,I){var B=this;return new Promise(function(k,U){var W=[],G=function X(Y){var J=S[Y];B.fragmentLoader.loadPart(v,J,I).then(function(ee){W[J.index]=ee;var z=ee.part;B.hls.trigger(O.Events.FRAG_LOADED,ee);var q=S[Y+1];if(q&&q.fragment===v)X(Y+1);else return k({frag:v,part:z,partsLoaded:W})}).catch(U)};G(x)})},s.handleFragLoadError=function(v){var S=v.data;return S&&S.details===_.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(S.frag,S.part):this.hls.trigger(O.Events.ERROR,S),null},s._handleTransmuxerFlush=function(v){var S=this.getCurrentContext(v);if(!S||this.state!==c.PARSING){this.fragCurrent||(this.state=c.IDLE);return}var x=S.frag,I=S.part,B=S.level,k=self.performance.now();x.stats.parsing.end=k,I&&(I.stats.parsing.end=k),this.updateLevelTiming(x,I,B,v.partial)},s.getCurrentContext=function(v){var S=this.levels,x=v.level,I=v.sn,B=v.part;if(!S||!S[x])return this.warn("Levels object was unset while buffering fragment "+I+" of level "+x+". The current chunk will not be buffered."),null;var k=S[x],U=B>-1?Object(m.getPartWith)(k,I,B):null,W=U?U.fragment:Object(m.getFragmentWithSN)(k,I,this.fragCurrent);return W?{frag:W,part:U,level:k}:null},s.bufferFragmentData=function(v,S,x,I){if(!(!v||this.state!==c.PARSING)){var B=v.data1,k=v.data2,U=B;if(B&&k&&(U=Object(T.appendUint8Array)(B,k)),!(!U||!U.length)){var W={type:v.type,frag:S,part:x,chunkMeta:I,parent:S.type,data:U};this.hls.trigger(O.Events.BUFFER_APPENDING,W),v.dropped&&v.independent&&!x&&this.flushBufferGap(S)}}},s.flushBufferGap=function(v){var S=this.media;if(!!S){if(!M.BufferHelper.isBuffered(S,S.currentTime)){this.flushMainBuffer(0,v.start);return}var x=S.currentTime,I=M.BufferHelper.bufferInfo(S,x,0),B=v.duration,k=Math.min(this.config.maxFragLookUpTolerance*2,B*.25),U=Math.max(Math.min(v.start-k,I.end-k),x+k);v.start-U>k&&this.flushMainBuffer(U,v.start)}},s.getFwdBufferInfo=function(v,S){var x=this.config,I=this.getLoadPosition();if(!Object(P.isFiniteNumber)(I))return null;var B=M.BufferHelper.bufferInfo(v,I,x.maxBufferHole);if(B.len===0&&B.nextStart!==void 0){var k=this.fragmentTracker.getBufferedFrag(I,S);if(k&&B.nextStart<k.end)return M.BufferHelper.bufferInfo(v,I,Math.max(B.nextStart,x.maxBufferHole))}return B},s.getMaxBufferLength=function(v){var S=this.config,x;return v?x=Math.max(8*S.maxBufferSize/v,S.maxBufferLength):x=S.maxBufferLength,Math.min(x,S.maxMaxBufferLength)},s.reduceMaxBufferLength=function(v){var S=this.config,x=v||S.maxBufferLength;return S.maxMaxBufferLength>=x?(S.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+S.maxMaxBufferLength+"s"),!0):!1},s.getNextFragment=function(v,S){var x=S.fragments,I=x.length;if(!I)return null;var B=this.config,k=x[0].start,U;if(S.live){var W=B.initialLiveManifestSize;if(I<W)return this.warn("Not enough fragments to start playback (have: "+I+", need: "+W+")"),null;!S.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(U=this.getInitialLiveFragment(S,x),this.startPosition=U?this.hls.liveSyncPosition||U.start:v)}else v<=k&&(U=x[0]);if(!U){var G=B.lowLatencyMode?S.partEnd:S.fragmentEnd;U=this.getFragmentAtPosition(v,G,S)}return this.mapToInitFragWhenRequired(U)},s.mapToInitFragWhenRequired=function(v){return v!=null&&v.initSegment&&!(v!=null&&v.initSegment.data)&&!this.bitrateTest?v.initSegment:v},s.getNextPart=function(v,S,x){for(var I=-1,B=!1,k=!0,U=0,W=v.length;U<W;U++){var G=v[U];if(k=k&&!G.independent,I>-1&&x<G.start)break;var X=G.loaded;!X&&(B||G.independent||k)&&G.fragment===S&&(I=U),B=X}return I},s.loadedEndOfParts=function(v,S){var x=v[v.length-1];return x&&S>x.start&&x.loaded},s.getInitialLiveFragment=function(v,S){var x=this.fragPrevious,I=null;if(x){if(v.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+x.programDateTime),I=Object(E.findFragmentByPDT)(S,x.endProgramDateTime,this.config.maxFragLookUpTolerance)),!I){var B=x.sn+1;if(B>=v.startSN&&B<=v.endSN){var k=S[B-v.startSN];x.cc===k.cc&&(I=k,this.log("Live playlist, switching playlist, load frag with next SN: "+I.sn))}I||(I=Object(E.findFragWithCC)(S,x.cc),I&&this.log("Live playlist, switching playlist, load frag with same CC: "+I.sn))}}else{var U=this.hls.liveSyncPosition;U!==null&&(I=this.getFragmentAtPosition(U,this.bitrateTest?v.fragmentEnd:v.edge,v))}return I},s.getFragmentAtPosition=function(v,S,x){var I=this.config,B=this.fragPrevious,k=x.fragments,U=x.endSN,W=x.fragmentHint,G=I.maxFragLookUpTolerance,X=!!(I.lowLatencyMode&&x.partList&&W);X&&W&&!this.bitrateTest&&(k=k.concat(W),U=W.sn);var Y;if(v<S){var J=v>S-G?0:G;Y=Object(E.findFragmentByPTS)(B,k,v,J)}else Y=k[k.length-1];if(Y){var ee=Y.sn-x.startSN;if(B&&Y.sn===B.sn&&!X){var z=B&&Y.level===B.level;if(z){var q=k[ee+1];Y.sn<U&&this.fragmentTracker.getState(q)!==A.FragmentState.OK?(this.log("SN "+Y.sn+" just loaded, load next one: "+q.sn),Y=q):Y=null}}}return Y},s.synchronizeToLiveEdge=function(v){var S=this.config,x=this.media;if(!!x){var I=this.hls.liveSyncPosition,B=x.currentTime,k=v.fragments[0].start,U=v.edge,W=B>=k-S.maxFragLookUpTolerance&&B<=U;if(I!==null&&x.duration>I&&(B<I||!W)){var G=S.liveMaxLatencyDuration!==void 0?S.liveMaxLatencyDuration:S.liveMaxLatencyDurationCount*v.targetduration;(!W&&x.readyState<4||B<U-G)&&(this.loadedmetadata||(this.nextLoadPosition=I),x.readyState&&(this.warn("Playback: "+B.toFixed(3)+" is located too far from the end of live sliding playlist: "+U+", reset currentTime to : "+I.toFixed(3)),x.currentTime=I))}}},s.alignPlaylists=function(v,S){var x=this.levels,I=this.levelLastLoaded,B=this.fragPrevious,k=I!==null?x[I]:null,U=v.fragments.length;if(!U)return this.warn("No fragments in live playlist"),0;var W=v.fragments[0].start,G=!S,X=v.alignedSliding&&Object(P.isFiniteNumber)(W);if(G||!X&&!W){Object(D.alignStream)(B,k,v);var Y=v.fragments[0].start;return this.log("Live playlist sliding: "+Y.toFixed(2)+" start-sn: "+(S?S.startSN:"na")+"->"+v.startSN+" prev-sn: "+(B?B.sn:"na")+" fragments: "+U),Y}return W},s.waitForCdnTuneIn=function(v){var S=3;return v.live&&v.canBlockReload&&v.partTarget&&v.tuneInGoal>Math.max(v.partHoldBack,v.partTarget*S)},s.setStartPosition=function(v,S){var x=this.startPosition;if(x<S&&(x=-1),x===-1||this.lastCurrentTime===-1){var I=v.startTimeOffset;Object(P.isFiniteNumber)(I)?(x=S+I,I<0&&(x+=v.totalduration),x=Math.min(Math.max(S,x),S+v.totalduration),this.log("Start time offset "+I+" found in playlist, adjust startPosition to "+x),this.startPosition=x):v.live?x=this.hls.liveSyncPosition||S:this.startPosition=x=0,this.lastCurrentTime=x}this.nextLoadPosition=x},s.getLoadPosition=function(){var v=this.media,S=0;return this.loadedmetadata&&v?S=v.currentTime:this.nextLoadPosition&&(S=this.nextLoadPosition),S},s.handleFragLoadAborted=function(v,S){this.transmuxer&&v.sn!=="initSegment"&&v.stats.aborted&&(this.warn("Fragment "+v.sn+(S?" part"+S.index:"")+" of level "+v.level+" was aborted"),this.resetFragmentLoading(v))},s.resetFragmentLoading=function(v){(!this.fragCurrent||!this.fragContextChanged(v)&&this.state!==c.FRAG_LOADING_WAITING_RETRY)&&(this.state=c.IDLE)},s.onFragmentOrKeyLoadError=function(v,S){if(!S.fatal){var x=S.frag;if(!(!x||x.type!==v)){var I=this.fragCurrent;console.assert(I&&x.sn===I.sn&&x.level===I.level&&x.urlId===I.urlId,"Frag load error must match current frag to retry");var B=this.config;if(this.fragLoadError+1<=B.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var k=Math.min(Math.pow(2,this.fragLoadError)*B.fragLoadingRetryDelay,B.fragLoadingMaxRetryTimeout);this.warn("Fragment "+x.sn+" of "+v+" "+x.level+" failed to load, retrying in "+k+"ms"),this.retryDate=self.performance.now()+k,this.fragLoadError++,this.state=c.FRAG_LOADING_WAITING_RETRY}else S.levelRetry?(v===o.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=c.IDLE):(R.logger.error(S.details+" reaches max retry, redispatch as fatal ..."),S.fatal=!0,this.hls.stopLoad(),this.state=c.ERROR)}}},s.afterBufferFlushed=function(v,S,x){if(!!v){var I=M.BufferHelper.getBuffered(v);this.fragmentTracker.detectEvictedFragments(S,I,x),this.state===c.ENDED&&this.resetLoadingState()}},s.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=c.IDLE},s.resetStartWhenNotLoaded=function(v){if(!this.loadedmetadata){this.startFragRequested=!1;var S=this.levels?this.levels[v].details:null;S!=null&&S.live?(this.startPosition=-1,this.setStartPosition(S,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},s.updateLevelTiming=function(v,S,x,I){var B=this,k=x.details;console.assert(!!k,"level.details must be defined");var U=Object.keys(v.elementaryStreams).reduce(function(W,G){var X=v.elementaryStreams[G];if(X){var Y=X.endPTS-X.startPTS;if(Y<=0)return B.warn("Could not parse fragment "+v.sn+" "+G+" duration reliably ("+Y+")"),W||!1;var J=I?0:Object(m.updateFragPTSDTS)(k,v,X.startPTS,X.endPTS,X.startDTS,X.endDTS);return B.hls.trigger(O.Events.LEVEL_PTS_UPDATED,{details:k,level:x,drift:J,type:G,frag:v,start:X.startPTS,end:X.endPTS}),!0}return W},!1);U||(this.warn("Found no media in fragment "+v.sn+" of level "+x.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=c.PARSED,this.hls.trigger(O.Events.FRAG_PARSED,{frag:v,part:S})},s.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},g(u,[{key:"state",get:function(){return this._state},set:function(v){var S=this._state;S!==v&&(this._state=v,this.log(S+"->"+v))}}]),u}(L.default)},"./src/controller/buffer-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return E});var P=n("./src/polyfills/number.ts"),L=n("./src/events.ts"),A=n("./src/utils/logger.ts"),M=n("./src/errors.ts"),R=n("./src/utils/buffer-helper.ts"),O=n("./src/utils/mediasource-helper.ts"),_=n("./src/loader/fragment.ts"),y=n("./src/controller/buffer-operation-queue.ts"),T=Object(O.getMediaSource)(),D=/([ha]vc.)(?:\.[^.,]+)+/,E=function(){function m(d){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var o=e.hls,h=e.media,g=e.mediaSource;A.logger.log("[buffer-controller]: Media source opened"),h&&(e.updateMediaElementDuration(),o.trigger(L.Events.MEDIA_ATTACHED,{media:h})),g&&g.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){A.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){A.logger.log("[buffer-controller]: Media source ended")},this.hls=d,this._initSourceBuffer(),this.registerListeners()}var p=m.prototype;return p.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},p.destroy=function(){this.unregisterListeners(),this.details=null},p.registerListeners=function(){var e=this.hls;e.on(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(L.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(L.Events.BUFFER_RESET,this.onBufferReset,this),e.on(L.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(L.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(L.Events.BUFFER_EOS,this.onBufferEos,this),e.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(L.Events.FRAG_PARSED,this.onFragParsed,this),e.on(L.Events.FRAG_CHANGED,this.onFragChanged,this)},p.unregisterListeners=function(){var e=this.hls;e.off(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(L.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(L.Events.BUFFER_RESET,this.onBufferReset,this),e.off(L.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(L.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(L.Events.BUFFER_EOS,this.onBufferEos,this),e.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(L.Events.FRAG_PARSED,this.onFragParsed,this),e.off(L.Events.FRAG_CHANGED,this.onFragChanged,this)},p._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new y.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},p.onManifestParsed=function(e,o){var h=2;(o.audio&&!o.video||!o.altAudio)&&(h=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=h,this.details=null,A.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},p.onMediaAttaching=function(e,o){var h=this.media=o.media;if(h&&T){var g=this.mediaSource=new T;g.addEventListener("sourceopen",this._onMediaSourceOpen),g.addEventListener("sourceended",this._onMediaSourceEnded),g.addEventListener("sourceclose",this._onMediaSourceClose),h.src=self.URL.createObjectURL(g),this._objectUrl=h.src}},p.onMediaDetaching=function(){var e=this.media,o=this.mediaSource,h=this._objectUrl;if(o){if(A.logger.log("[buffer-controller]: media source detaching"),o.readyState==="open")try{o.endOfStream()}catch(g){A.logger.warn("[buffer-controller]: onMediaDetaching: "+g.message+" while calling endOfStream")}this.onBufferReset(),o.removeEventListener("sourceopen",this._onMediaSourceOpen),o.removeEventListener("sourceended",this._onMediaSourceEnded),o.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(h&&self.URL.revokeObjectURL(h),e.src===h?(e.removeAttribute("src"),e.load()):A.logger.warn("[buffer-controller]: 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.hls.trigger(L.Events.MEDIA_DETACHED,void 0)},p.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(o){var h=e.sourceBuffer[o];try{h&&(e.removeBufferListeners(o),e.mediaSource&&e.mediaSource.removeSourceBuffer(h),e.sourceBuffer[o]=void 0)}catch(g){A.logger.warn("[buffer-controller]: Failed to reset the "+o+" buffer",g)}}),this._initSourceBuffer()},p.onBufferCodecs=function(e,o){var h=this,g=this.getSourceBufferTypes().length;Object.keys(o).forEach(function(i){if(g){var r=h.tracks[i];if(r&&typeof r.buffer.changeType=="function"){var l=o[i],c=l.id,t=l.codec,a=l.levelCodec,u=l.container,s=l.metadata,f=(r.levelCodec||r.codec).replace(D,"$1"),v=(a||t).replace(D,"$1");if(f!==v){var S=u+";codecs="+(a||t);h.appendChangeType(i,S),A.logger.log("[buffer-controller]: switching codec "+f+" to "+v),h.tracks[i]={buffer:r.buffer,codec:t,container:u,levelCodec:a,metadata:s,id:c}}}}else h.pendingTracks[i]=o[i]}),!g&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},p.appendChangeType=function(e,o){var h=this,g=this.operationQueue,i={execute:function(){var l=h.sourceBuffer[e];l&&(A.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+o),l.changeType(o)),g.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(l){A.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",l)}};g.append(i,e)},p.onBufferAppending=function(e,o){var h=this,g=this.hls,i=this.operationQueue,r=this.tracks,l=o.data,c=o.type,t=o.frag,a=o.part,u=o.chunkMeta,s=u.buffering[c],f=self.performance.now();s.start=f;var v=t.stats.buffering,S=a?a.stats.buffering:null;v.start===0&&(v.start=f),S&&S.start===0&&(S.start=f);var x=r.audio,I=c==="audio"&&u.id===1&&(x==null?void 0:x.container)==="audio/mpeg",B={execute:function(){if(s.executeStart=self.performance.now(),I){var U=h.sourceBuffer[c];if(U){var W=t.start-U.timestampOffset;Math.abs(W)>=.1&&(A.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+t.start+" (delta: "+W+") sn: "+t.sn+")"),U.timestampOffset=t.start)}}h.appendExecutor(l,c)},onStart:function(){},onComplete:function(){var U=self.performance.now();s.executeEnd=s.end=U,v.first===0&&(v.first=U),S&&S.first===0&&(S.first=U);var W=h.sourceBuffer,G={};for(var X in W)G[X]=R.BufferHelper.getBuffered(W[X]);h.appendError=0,h.hls.trigger(L.Events.BUFFER_APPENDED,{type:c,frag:t,part:a,chunkMeta:u,parent:t.type,timeRanges:G})},onError:function(U){A.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",U);var W={type:M.ErrorTypes.MEDIA_ERROR,parent:t.type,details:M.ErrorDetails.BUFFER_APPEND_ERROR,err:U,fatal:!1};U.code===DOMException.QUOTA_EXCEEDED_ERR?W.details=M.ErrorDetails.BUFFER_FULL_ERROR:(h.appendError++,W.details=M.ErrorDetails.BUFFER_APPEND_ERROR,h.appendError>g.config.appendErrorMaxRetry&&(A.logger.error("[buffer-controller]: Failed "+g.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),W.fatal=!0,g.stopLoad())),g.trigger(L.Events.ERROR,W)}};i.append(B,c)},p.onBufferFlushing=function(e,o){var h=this,g=this.operationQueue,i=function(l){return{execute:h.removeExecutor.bind(h,l,o.startOffset,o.endOffset),onStart:function(){},onComplete:function(){h.hls.trigger(L.Events.BUFFER_FLUSHED,{type:l})},onError:function(t){A.logger.warn("[buffer-controller]: Failed to remove from "+l+" SourceBuffer",t)}}};o.type?g.append(i(o.type),o.type):this.getSourceBufferTypes().forEach(function(r){g.append(i(r),r)})},p.onFragParsed=function(e,o){var h=this,g=o.frag,i=o.part,r=[],l=i?i.elementaryStreams:g.elementaryStreams;l[_.ElementaryStreamTypes.AUDIOVIDEO]?r.push("audiovideo"):(l[_.ElementaryStreamTypes.AUDIO]&&r.push("audio"),l[_.ElementaryStreamTypes.VIDEO]&&r.push("video"));var c=function(){var a=self.performance.now();g.stats.buffering.end=a,i&&(i.stats.buffering.end=a);var u=i?i.stats:g.stats;h.hls.trigger(L.Events.FRAG_BUFFERED,{frag:g,part:i,stats:u,id:g.type})};r.length===0&&A.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+g.type+" level: "+g.level+" sn: "+g.sn),this.blockBuffers(c,r)},p.onFragChanged=function(e,o){this.flushBackBuffer()},p.onBufferEos=function(e,o){var h=this,g=this.getSourceBufferTypes().reduce(function(i,r){var l=h.sourceBuffer[r];return(!o.type||o.type===r)&&l&&!l.ended&&(l.ended=!0,A.logger.log("[buffer-controller]: "+r+" sourceBuffer now EOS")),i&&!!(!l||l.ended)},!0);g&&this.blockBuffers(function(){var i=h.mediaSource;!i||i.readyState!=="open"||i.endOfStream()})},p.onLevelUpdated=function(e,o){var h=o.details;!h.fragments.length||(this.details=h,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},p.flushBackBuffer=function(){var e=this.hls,o=this.details,h=this.media,g=this.sourceBuffer;if(!(!h||o===null)){var i=this.getSourceBufferTypes();if(!!i.length){var r=o.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!(!Object(P.isFiniteNumber)(r)||r<0)){var l=h.currentTime,c=o.levelTargetDuration,t=Math.max(r,c),a=Math.floor(l/c)*c-t;i.forEach(function(u){var s=g[u];if(s){var f=R.BufferHelper.getBuffered(s);f.length>0&&a>f.start(0)&&(e.trigger(L.Events.BACK_BUFFER_REACHED,{bufferEnd:a}),o.live&&e.trigger(L.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:a}),e.trigger(L.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:a,type:u}))}})}}}},p.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,o=this.hls,h=this.media,g=this.mediaSource,i=e.fragments[0].start+e.totalduration,r=h.duration,l=Object(P.isFiniteNumber)(g.duration)?g.duration:0;e.live&&o.config.liveDurationInfinity?(A.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),g.duration=1/0,this.updateSeekableRange(e)):(i>l&&i>r||!Object(P.isFiniteNumber)(r))&&(A.logger.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),g.duration=i)}},p.updateSeekableRange=function(e){var o=this.mediaSource,h=e.fragments,g=h.length;if(g&&e.live&&o!==null&&o!==void 0&&o.setLiveSeekableRange){var i=Math.max(0,h[0].start),r=Math.max(i,i+e.totalduration);o.setLiveSeekableRange(i,r)}},p.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,o=this.operationQueue,h=this.pendingTracks,g=Object.keys(h).length;if(g&&!e||g===2){this.createSourceBuffers(h),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length===0){this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}i.forEach(function(r){o.executeNext(r)})}},p.createSourceBuffers=function(e){var o=this.sourceBuffer,h=this.mediaSource;if(!h)throw Error("createSourceBuffers called when mediaSource was null");var g=0;for(var i in e)if(!o[i]){var r=e[i];if(!r)throw Error("source buffer exists for track "+i+", however track does not");var l=r.levelCodec||r.codec,c=r.container+";codecs="+l;A.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var t=o[i]=h.addSourceBuffer(c),a=i;this.addBufferListener(a,"updatestart",this._onSBUpdateStart),this.addBufferListener(a,"updateend",this._onSBUpdateEnd),this.addBufferListener(a,"error",this._onSBUpdateError),this.tracks[i]={buffer:t,codec:l,container:r.container,levelCodec:r.levelCodec,metadata:r.metadata,id:r.id},g++}catch(u){A.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+u.message),this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:u,mimeType:c})}}g&&this.hls.trigger(L.Events.BUFFER_CREATED,{tracks:this.tracks})},p._onSBUpdateStart=function(e){var o=this.operationQueue,h=o.current(e);h.onStart()},p._onSBUpdateEnd=function(e){var o=this.operationQueue,h=o.current(e);h.onComplete(),o.shiftAndExecuteNext(e)},p._onSBUpdateError=function(e,o){A.logger.error("[buffer-controller]: "+e+" SourceBuffer error",o),this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var h=this.operationQueue.current(e);h&&h.onError(o)},p.removeExecutor=function(e,o,h){var g=this.media,i=this.mediaSource,r=this.operationQueue,l=this.sourceBuffer,c=l[e];if(!g||!i||!c){A.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),r.shiftAndExecuteNext(e);return}var t=Object(P.isFiniteNumber)(g.duration)?g.duration:1/0,a=Object(P.isFiniteNumber)(i.duration)?i.duration:1/0,u=Math.max(0,o),s=Math.min(h,t,a);s>u?(A.logger.log("[buffer-controller]: Removing ["+u+","+s+"] from the "+e+" SourceBuffer"),console.assert(!c.updating,e+" sourceBuffer must not be updating"),c.remove(u,s)):r.shiftAndExecuteNext(e)},p.appendExecutor=function(e,o){var h=this.operationQueue,g=this.sourceBuffer,i=g[o];if(!i){A.logger.warn("[buffer-controller]: Attempting to append to the "+o+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(o);return}i.ended=!1,console.assert(!i.updating,o+" sourceBuffer must not be updating"),i.appendBuffer(e)},p.blockBuffers=function(e,o){var h=this;if(o===void 0&&(o=this.getSourceBufferTypes()),!o.length){A.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var g=this.operationQueue,i=o.map(function(r){return g.appendBlocker(r)});Promise.all(i).then(function(){e(),o.forEach(function(r){var l=h.sourceBuffer[r];(!l||!l.updating)&&g.shiftAndExecuteNext(r)})})},p.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},p.addBufferListener=function(e,o,h){var g=this.sourceBuffer[e];if(!!g){var i=h.bind(this,e);this.listeners[e].push({event:o,listener:i}),g.addEventListener(o,i)}},p.removeBufferListeners=function(e){var o=this.sourceBuffer[e];!o||this.listeners[e].forEach(function(h){o.removeEventListener(h.event,h.listener)})},m}()},"./src/controller/buffer-operation-queue.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return L});var P=n("./src/utils/logger.ts"),L=function(){function A(R){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=R}var M=A.prototype;return M.append=function(O,_){var y=this.queues[_];y.push(O),y.length===1&&this.buffers[_]&&this.executeNext(_)},M.insertAbort=function(O,_){var y=this.queues[_];y.unshift(O),this.executeNext(_)},M.appendBlocker=function(O){var _,y=new Promise(function(D){_=D}),T={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(T,O),y},M.executeNext=function(O){var _=this.buffers,y=this.queues,T=_[O],D=y[O];if(D.length){var E=D[0];try{E.execute()}catch(m){P.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),E.onError(m),(!T||!T.updating)&&(D.shift(),this.executeNext(O))}}},M.shiftAndExecuteNext=function(O){this.queues[O].shift(),this.executeNext(O)},M.current=function(O){return this.queues[O][0]},A}()},"./src/controller/cap-level-controller.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/events.ts");function L(R,O){for(var _=0;_<O.length;_++){var y=O[_];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(R,y.key,y)}}function A(R,O,_){return O&&L(R.prototype,O),_&&L(R,_),Object.defineProperty(R,"prototype",{writable:!1}),R}var M=function(){function R(_){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=_,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var O=R.prototype;return O.setStreamController=function(y){this.streamController=y},O.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},O.registerListeners=function(){var y=this.hls;y.on(P.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(P.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(P.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.unregisterListener=function(){var y=this.hls;y.off(P.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(P.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(P.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.onFpsDropLevelCapping=function(y,T){R.isLevelAllowed(T.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(T.droppedLevel)},O.onMediaAttaching=function(y,T){this.media=T.media instanceof HTMLVideoElement?T.media:null},O.onManifestParsed=function(y,T){var D=this.hls;this.restrictedLevels=[],this.firstLevel=T.firstLevel,D.config.capLevelToPlayerSize&&T.video&&this.startCapping()},O.onBufferCodecs=function(y,T){var D=this.hls;D.config.capLevelToPlayerSize&&T.video&&this.startCapping()},O.onMediaDetaching=function(){this.stopCapping()},O.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var y=this.hls.levels;if(y.length){var T=this.hls;T.autoLevelCapping=this.getMaxLevel(y.length-1),T.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=T.autoLevelCapping}}},O.getMaxLevel=function(y){var T=this,D=this.hls.levels;if(!D.length)return-1;var E=D.filter(function(m,p){return R.isLevelAllowed(p,T.restrictedLevels)&&p<=y});return this.clientRect=null,R.getMaxLevelByMediaSize(E,this.mediaWidth,this.mediaHeight)},O.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},O.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},O.getDimensions=function(){if(this.clientRect)return this.clientRect;var y=this.media,T={width:0,height:0};if(y){var D=y.getBoundingClientRect();T.width=D.width,T.height=D.height,!T.width&&!T.height&&(T.width=D.right-D.left||y.width||0,T.height=D.bottom-D.top||y.height||0)}return this.clientRect=T,T},R.isLevelAllowed=function(y,T){return T===void 0&&(T=[]),T.indexOf(y)===-1},R.getMaxLevelByMediaSize=function(y,T,D){if(!y||!y.length)return-1;for(var E=function(o,h){return h?o.width!==h.width||o.height!==h.height:!0},m=y.length-1,p=0;p<y.length;p+=1){var d=y[p];if((d.width>=T||d.height>=D)&&E(d,y[p+1])){m=p;break}}return m},A(R,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var y=1;if(!this.hls.config.ignoreDevicePixelRatio)try{y=self.devicePixelRatio}catch{}return y}}]),R}();b.default=M},"./src/controller/cmcd-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return E});var P=n("./src/events.ts"),L=n("./src/types/cmcd.ts"),A=n("./src/utils/buffer-helper.ts"),M=n("./src/utils/logger.ts");function R(m,p){for(var d=0;d<p.length;d++){var e=p[d];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(m,e.key,e)}}function O(m,p,d){return p&&R(m.prototype,p),d&&R(m,d),Object.defineProperty(m,"prototype",{writable:!1}),m}function _(m,p){var d=typeof Symbol!="undefined"&&m[Symbol.iterator]||m["@@iterator"];if(d)return(d=d.call(m)).next.bind(d);if(Array.isArray(m)||(d=y(m))||p&&m&&typeof m.length=="number"){d&&(m=d);var e=0;return function(){return e>=m.length?{done:!0}:{done:!1,value:m[e++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
13
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function y(m,p){if(!!m){if(typeof m=="string")return T(m,p);var d=Object.prototype.toString.call(m).slice(8,-1);if(d==="Object"&&m.constructor&&(d=m.constructor.name),d==="Map"||d==="Set")return Array.from(m);if(d==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(d))return T(m,p)}}function T(m,p){(p==null||p>m.length)&&(p=m.length);for(var d=0,e=new Array(p);d<p;d++)e[d]=m[d];return e}function D(){return D=Object.assign?Object.assign.bind():function(m){for(var p=1;p<arguments.length;p++){var d=arguments[p];for(var e in d)Object.prototype.hasOwnProperty.call(d,e)&&(m[e]=d[e])}return m},D.apply(this,arguments)}var E=function(){function m(d){var e=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(g){try{e.apply(g,{ot:L.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(i){M.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(g){try{var i=g.frag,r=e.hls.levels[i.level],l=e.getObjectType(i),c={d:i.duration*1e3,ot:l};(l===L.CMCDObjectType.VIDEO||l===L.CMCDObjectType.AUDIO||l==L.CMCDObjectType.MUXED)&&(c.br=r.bitrate/1e3,c.tb=e.getTopBandwidth(l)/1e3,c.bl=e.getBufferLength(l)),e.apply(g,c)}catch(t){M.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=d;var o=this.config=d.config,h=o.cmcd;h!=null&&(o.pLoader=this.createPlaylistLoader(),o.fLoader=this.createFragmentLoader(),this.sid=h.sessionId||m.uuid(),this.cid=h.contentId,this.useHeaders=h.useHeaders===!0,this.registerListeners())}var p=m.prototype;return p.registerListeners=function(){var e=this.hls;e.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(P.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(P.Events.BUFFER_CREATED,this.onBufferCreated,this)},p.unregisterListeners=function(){var e=this.hls;e.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(P.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(P.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},p.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},p.onMediaAttached=function(e,o){this.media=o.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},p.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},p.onBufferCreated=function(e,o){var h,g;this.audioBuffer=(h=o.tracks.audio)===null||h===void 0?void 0:h.buffer,this.videoBuffer=(g=o.tracks.video)===null||g===void 0?void 0:g.buffer},p.createData=function(){var e;return{v:L.CMCDVersion,sf:L.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},p.apply=function(e,o){o===void 0&&(o={}),D(o,this.createData());var h=o.ot===L.CMCDObjectType.INIT||o.ot===L.CMCDObjectType.VIDEO||o.ot===L.CMCDObjectType.MUXED;if(this.starved&&h&&(o.bs=!0,o.su=!0,this.starved=!1),o.su==null&&(o.su=this.buffering),this.useHeaders){var g=m.toHeaders(o);if(!Object.keys(g).length)return;e.headers||(e.headers={}),D(e.headers,g)}else{var i=m.toQuery(o);if(!i)return;e.url=m.appendQueryToUri(e.url,i)}},p.getObjectType=function(e){var o=e.type;if(o==="subtitle")return L.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return L.CMCDObjectType.INIT;if(o==="audio")return L.CMCDObjectType.AUDIO;if(o==="main")return this.hls.audioTracks.length?L.CMCDObjectType.VIDEO:L.CMCDObjectType.MUXED},p.getTopBandwidth=function(e){var o=0,h,g=this.hls;if(e===L.CMCDObjectType.AUDIO)h=g.audioTracks;else{var i=g.maxAutoLevel,r=i>-1?i+1:g.levels.length;h=g.levels.slice(0,r)}for(var l=_(h),c;!(c=l()).done;){var t=c.value;t.bitrate>o&&(o=t.bitrate)}return o>0?o:NaN},p.getBufferLength=function(e){var o=this.hls.media,h=e===L.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!h||!o)return NaN;var g=A.BufferHelper.bufferInfo(h,o.currentTime,this.config.maxBufferHole);return g.len*1e3},p.createPlaylistLoader=function(){var e=this.config.pLoader,o=this.applyPlaylistData,h=e||this.config.loader;return function(){function g(r){this.loader=void 0,this.loader=new h(r)}var i=g.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(l,c,t){o(l),this.loader.load(l,c,t)},O(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},p.createFragmentLoader=function(){var e=this.config.fLoader,o=this.applyFragmentData,h=e||this.config.loader;return function(){function g(r){this.loader=void 0,this.loader=new h(r)}var i=g.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(l,c,t){o(l),this.loader.load(l,c,t)},O(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},m.uuid=function(){var e=URL.createObjectURL(new Blob),o=e.toString();return URL.revokeObjectURL(e),o.slice(o.lastIndexOf("/")+1)},m.serialize=function(e){for(var o=[],h=function(I){return!Number.isNaN(I)&&I!=null&&I!==""&&I!==!1},g=function(I){return Math.round(I)},i=function(I){return g(I/100)*100},r=function(I){return encodeURIComponent(I)},l={br:g,d:g,bl:i,dl:i,mtp:i,nor:r,rtp:i,tb:g},c=Object.keys(e||{}).sort(),t=_(c),a;!(a=t()).done;){var u=a.value,s=e[u];if(!!h(s)&&!(u==="v"&&s===1)&&!(u=="pr"&&s===1)){var f=l[u];f&&(s=f(s));var v=typeof s,S=void 0;u==="ot"||u==="sf"||u==="st"?S=u+"="+s:v==="boolean"?S=u:v==="number"?S=u+"="+s:S=u+"="+JSON.stringify(s),o.push(S)}}return o.join(",")},m.toHeaders=function(e){for(var o=Object.keys(e),h={},g=["Object","Request","Session","Status"],i=[{},{},{},{}],r={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},l=0,c=o;l<c.length;l++){var t=c[l],a=r[t]!=null?r[t]:1;i[a][t]=e[t]}for(var u=0;u<i.length;u++){var s=m.serialize(i[u]);s&&(h["CMCD-"+g[u]]=s)}return h},m.toQuery=function(e){return"CMCD="+encodeURIComponent(m.serialize(e))},m.appendQueryToUri=function(e,o){if(!o)return e;var h=e.includes("?")?"&":"?";return""+e+h+o},m}()},"./src/controller/eme-controller.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/events.ts"),L=n("./src/errors.ts"),A=n("./src/utils/logger.ts"),M=n("./src/utils/mediakeys-helper.ts");function R(E,m){for(var p=0;p<m.length;p++){var d=m[p];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(E,d.key,d)}}function O(E,m,p){return m&&R(E.prototype,m),p&&R(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}var _=3,y=function(m,p,d){var e={audioCapabilities:[],videoCapabilities:[]};return m.forEach(function(o){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+o+'"',robustness:d.audioRobustness||""})}),p.forEach(function(o){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+o+'"',robustness:d.videoRobustness||""})}),[e]},T=function(m,p,d,e){switch(m){case M.KeySystems.WIDEVINE:return y(p,d,e);default:throw new Error("Unknown key-system: "+m)}},D=function(){function E(p){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=p,this._config=p.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var m=E.prototype;return m.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},m._registerListeners=function(){this.hls.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(P.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this)},m._unregisterListeners=function(){this.hls.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(P.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this)},m.getLicenseServerUrl=function(d){switch(d){case M.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+d+'"')},m._attemptKeySystemAccess=function(d,e,o){var h=this,g=T(d,e,o,this._drmSystemOptions);A.logger.log("Requesting encrypted media key-system access");var i=this.requestMediaKeySystemAccess(d,g);this.mediaKeysPromise=i.then(function(r){return h._onMediaKeySystemAccessObtained(d,r)}),i.catch(function(r){A.logger.error('Failed to obtain key-system "'+d+'" access:',r)})},m._onMediaKeySystemAccessObtained=function(d,e){var o=this;A.logger.log('Access for key-system "'+d+'" obtained');var h={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:d};this._mediaKeysList.push(h);var g=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(i){return h.mediaKeys=i,A.logger.log('Media-keys created for key-system "'+d+'"'),o._onMediaKeysCreated(),i});return g.catch(function(i){A.logger.error("Failed to create media-keys:",i)}),g},m._onMediaKeysCreated=function(){var d=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),d._onNewMediaKeySession(e.mediaKeysSession))})},m._onNewMediaKeySession=function(d){var e=this;A.logger.log("New key-system session "+d.sessionId),d.addEventListener("message",function(o){e._onKeySessionMessage(d,o.message)},!1)},m._onKeySessionMessage=function(d,e){A.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(o){A.logger.log("Received license data (length: "+(o&&o.byteLength)+"), updating key-session"),d.update(o).catch(function(h){A.logger.warn("Updating key-session failed: "+h)})})},m.onMediaEncrypted=function(d){var e=this;if(A.logger.log('Media is encrypted using "'+d.initDataType+'" init data type'),!this.mediaKeysPromise){A.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var o=function(g){!e._media||(e._attemptSetMediaKeys(g),e._generateRequestWithPreferredKeySession(d.initDataType,d.initData))};this.mediaKeysPromise.then(o).catch(o)},m._attemptSetMediaKeys=function(d){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys){A.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}A.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},m._generateRequestWithPreferredKeySession=function(d,e){var o=this,h=this._mediaKeysList[0];if(!h){A.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(h.mediaKeysSessionInitialized){A.logger.warn("Key-Session already initialized but requested again");return}var g=h.mediaKeysSession;if(!g){A.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){A.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}A.logger.log('Generating key-session request for "'+d+'" init data type'),h.mediaKeysSessionInitialized=!0,g.generateRequest(d,e).then(function(){A.logger.debug("Key-session generation succeeded")}).catch(function(i){A.logger.error("Error generating key-session request:",i),o.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},m._createLicenseXhr=function(d,e,o){var h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,h,d,e,o);var g=this._licenseXhrSetup;if(g)try{g.call(this.hls,h,d),g=void 0}catch(i){A.logger.error(i)}try{h.readyState||h.open("POST",d,!0),g&&g.call(this.hls,h,d)}catch(i){throw new Error("issue setting up KeySystem license XHR "+i)}return h},m._onLicenseRequestReadyStageChange=function(d,e,o,h){switch(d.readyState){case 4:if(d.status===200){this._requestLicenseFailureCount=0,A.logger.log("License request succeeded");var g=d.response,i=this._licenseResponseCallback;if(i)try{g=i.call(this.hls,d,e)}catch(l){A.logger.error(l)}h(g)}else{if(A.logger.error("License Request XHR failed ("+e+"). Status: "+d.status+" ("+d.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>_){this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var r=_-this._requestLicenseFailureCount+1;A.logger.warn("Retrying license request, "+r+" attempts left"),this._requestLicense(o,h)}break}},m._generateLicenseRequestChallenge=function(d,e){switch(d.mediaKeySystemDomain){case M.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+d.mediaKeySystemDomain)},m._requestLicense=function(d,e){A.logger.log("Requesting content license for key-system");var o=this._mediaKeysList[0];if(!o){A.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var h=this.getLicenseServerUrl(o.mediaKeySystemDomain),g=this._createLicenseXhr(h,d,e);A.logger.log("Sending license request to URL: "+h);var i=this._generateLicenseRequestChallenge(o,d);g.send(i)}catch(r){A.logger.error("Failure requesting DRM license: "+r),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},m.onMediaAttached=function(d,e){if(!!this._emeEnabled){var o=e.media;this._media=o,o.addEventListener("encrypted",this._onMediaEncrypted)}},m.onMediaDetached=function(){var d=this._media,e=this._mediaKeysList;!d||(d.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(o){if(o.mediaKeysSession)return o.mediaKeysSession.close().catch(function(){})})).then(function(){return d.setMediaKeys(null)}).catch(function(){}))},m.onManifestParsed=function(d,e){if(!!this._emeEnabled){var o=e.levels.map(function(g){return g.audioCodec}).filter(function(g){return!!g}),h=e.levels.map(function(g){return g.videoCodec}).filter(function(g){return!!g});this._attemptKeySystemAccess(M.KeySystems.WIDEVINE,o,h)}},O(E,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),E}();b.default=D},"./src/controller/fps-controller.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/events.ts"),L=n("./src/utils/logger.ts"),A=function(){function M(O){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=O,this.registerListeners()}var R=M.prototype;return R.setStreamController=function(_){this.streamController=_},R.registerListeners=function(){this.hls.on(P.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},R.unregisterListeners=function(){this.hls.off(P.Events.MEDIA_ATTACHING,this.onMediaAttaching)},R.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},R.onMediaAttaching=function(_,y){var T=this.hls.config;if(T.capLevelOnFPSDrop){var D=y.media instanceof self.HTMLVideoElement?y.media:null;this.media=D,D&&typeof D.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),T.fpsDroppedMonitoringPeriod)}},R.checkFPS=function(_,y,T){var D=performance.now();if(y){if(this.lastTime){var E=D-this.lastTime,m=T-this.lastDroppedFrames,p=y-this.lastDecodedFrames,d=1e3*m/E,e=this.hls;if(e.trigger(P.Events.FPS_DROP,{currentDropped:m,currentDecoded:p,totalDroppedFrames:T}),d>0&&m>e.config.fpsDroppedMonitoringThreshold*p){var o=e.currentLevel;L.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+o),o>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=o)&&(o=o-1,e.trigger(P.Events.FPS_DROP_LEVEL_CAPPING,{level:o,droppedLevel:e.currentLevel}),e.autoLevelCapping=o,this.streamController.nextLevelSwitch())}}this.lastTime=D,this.lastDroppedFrames=T,this.lastDecodedFrames=y}},R.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var y=_.getVideoPlaybackQuality();this.checkFPS(_,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},M}();b.default=A},"./src/controller/fragment-finders.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"findFragmentByPDT",function(){return A}),n.d(b,"findFragmentByPTS",function(){return M}),n.d(b,"fragmentWithinToleranceTest",function(){return R}),n.d(b,"pdtWithinToleranceTest",function(){return O}),n.d(b,"findFragWithCC",function(){return _});var P=n("./src/polyfills/number.ts"),L=n("./src/utils/binary-search.ts");function A(y,T,D){if(T===null||!Array.isArray(y)||!y.length||!Object(P.isFiniteNumber)(T))return null;var E=y[0].programDateTime;if(T<(E||0))return null;var m=y[y.length-1].endProgramDateTime;if(T>=(m||0))return null;D=D||0;for(var p=0;p<y.length;++p){var d=y[p];if(O(T,D,d))return d}return null}function M(y,T,D,E){D===void 0&&(D=0),E===void 0&&(E=0);var m=null;if(y?m=T[y.sn-T[0].sn+1]||null:D===0&&T[0].start===0&&(m=T[0]),m&&R(D,E,m)===0)return m;var p=L.default.search(T,R.bind(null,D,E));return p||m}function R(y,T,D){y===void 0&&(y=0),T===void 0&&(T=0);var E=Math.min(T,D.duration+(D.deltaPTS?D.deltaPTS:0));return D.start+D.duration-E<=y?1:D.start-E>y&&D.start?-1:0}function O(y,T,D){var E=Math.min(T,D.duration+(D.deltaPTS?D.deltaPTS:0))*1e3,m=D.endProgramDateTime||0;return m-E>y}function _(y,T){return L.default.search(y,function(D){return D.cc<T?1:D.cc>T?-1:0})}},"./src/controller/fragment-tracker.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"FragmentState",function(){return A}),n.d(b,"FragmentTracker",function(){return M});var P=n("./src/events.ts"),L=n("./src/types/loader.ts"),A;(function(_){_.NOT_LOADED="NOT_LOADED",_.APPENDING="APPENDING",_.PARTIAL="PARTIAL",_.OK="OK"})(A||(A={}));var M=function(){function _(T){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=T,this._registerListeners()}var y=_.prototype;return y._registerListeners=function(){var D=this.hls;D.on(P.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.on(P.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.on(P.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var D=this.hls;D.off(P.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.off(P.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.off(P.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(D,E){if(E===L.PlaylistLevelType.MAIN){var m=this.activeFragment,p=this.activeParts;if(!m)return null;if(p)for(var d=p.length;d--;){var e=p[d],o=e?e.end:m.appendedPTS;if(e.start<=D&&o!==void 0&&D<=o)return d>9&&(this.activeParts=p.slice(d-9)),e}else if(m.start<=D&&m.appendedPTS!==void 0&&D<=m.appendedPTS)return m}return this.getBufferedFrag(D,E)},y.getBufferedFrag=function(D,E){for(var m=this.fragments,p=Object.keys(m),d=p.length;d--;){var e=m[p[d]];if((e==null?void 0:e.body.type)===E&&e.buffered){var o=e.body;if(o.start<=D&&D<=o.end)return o}}return null},y.detectEvictedFragments=function(D,E,m){var p=this;Object.keys(this.fragments).forEach(function(d){var e=p.fragments[d];if(!!e){if(!e.buffered){e.body.type===m&&p.removeFragment(e.body);return}var o=e.range[D];!o||o.time.some(function(h){var g=!p.isTimeBuffered(h.startPTS,h.endPTS,E);return g&&p.removeFragment(e.body),g})}})},y.detectPartialFragments=function(D){var E=this,m=this.timeRanges,p=D.frag,d=D.part;if(!(!m||p.sn==="initSegment")){var e=O(p),o=this.fragments[e];!o||(Object.keys(m).forEach(function(h){var g=p.elementaryStreams[h];if(!!g){var i=m[h],r=d!==null||g.partial===!0;o.range[h]=E.getBufferedTimes(p,d,r,i)}}),o.loaded=null,Object.keys(o.range).length?o.buffered=!0:this.removeFragment(o.body))}},y.fragBuffered=function(D){var E=O(D),m=this.fragments[E];m&&(m.loaded=null,m.buffered=!0)},y.getBufferedTimes=function(D,E,m,p){for(var d={time:[],partial:m},e=E?E.start:D.start,o=E?E.end:D.end,h=D.minEndPTS||o,g=D.maxStartPTS||e,i=0;i<p.length;i++){var r=p.start(i)-this.bufferPadding,l=p.end(i)+this.bufferPadding;if(g>=r&&h<=l){d.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(o,p.end(i))});break}else if(e<l&&o>r)d.partial=!0,d.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(o,p.end(i))});else if(o<=r)break}return d},y.getPartialFragment=function(D){var E=null,m,p,d,e=0,o=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(g){var i=h[g];!i||R(i)&&(p=i.body.start-o,d=i.body.end+o,D>=p&&D<=d&&(m=Math.min(D-p,d-D),e<=m&&(E=i.body,e=m)))}),E},y.getState=function(D){var E=O(D),m=this.fragments[E];return m?m.buffered?R(m)?A.PARTIAL:A.OK:A.APPENDING:A.NOT_LOADED},y.isTimeBuffered=function(D,E,m){for(var p,d,e=0;e<m.length;e++){if(p=m.start(e)-this.bufferPadding,d=m.end(e)+this.bufferPadding,D>=p&&E<=d)return!0;if(E<=p)return!1}return!1},y.onFragLoaded=function(D,E){var m=E.frag,p=E.part;if(!(m.sn==="initSegment"||m.bitrateTest||p)){var d=O(m);this.fragments[d]={body:m,loaded:E,buffered:!1,range:Object.create(null)}}},y.onBufferAppended=function(D,E){var m=this,p=E.frag,d=E.part,e=E.timeRanges;if(p.type===L.PlaylistLevelType.MAIN)if(this.activeFragment=p,d){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(d)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(h){var g=e[h];if(m.detectEvictedFragments(h,g),!d)for(var i=0;i<g.length;i++)p.appendedPTS=Math.max(g.end(i),p.appendedPTS||0)})},y.onFragBuffered=function(D,E){this.detectPartialFragments(E)},y.hasFragment=function(D){var E=O(D);return!!this.fragments[E]},y.removeFragmentsInRange=function(D,E,m){var p=this;Object.keys(this.fragments).forEach(function(d){var e=p.fragments[d];if(!!e&&e.buffered){var o=e.body;o.type===m&&o.start<E&&o.end>D&&p.removeFragment(o)}})},y.removeFragment=function(D){var E=O(D);D.stats.loaded=0,D.clearElementaryStreamInfo(),delete this.fragments[E]},y.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},_}();function R(_){var y,T;return _.buffered&&(((y=_.range.video)===null||y===void 0?void 0:y.partial)||((T=_.range.audio)===null||T===void 0?void 0:T.partial))}function O(_){return _.type+"_"+_.level+"_"+_.urlId+"_"+_.sn}},"./src/controller/gap-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"STALL_MINIMUM_DURATION_MS",function(){return R}),n.d(b,"MAX_START_GAP_JUMP",function(){return O}),n.d(b,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return _}),n.d(b,"SKIP_BUFFER_RANGE_START",function(){return y}),n.d(b,"default",function(){return T});var P=n("./src/utils/buffer-helper.ts"),L=n("./src/errors.ts"),A=n("./src/events.ts"),M=n("./src/utils/logger.ts"),R=250,O=2,_=.1,y=.05,T=function(){function D(m,p,d,e){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=m,this.media=p,this.fragmentTracker=d,this.hls=e}var E=D.prototype;return E.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},E.poll=function(p,d){var e=this.config,o=this.media,h=this.stalled;if(o!==null){var g=o.currentTime,i=o.seeking,r=this.seeking&&!i,l=!this.seeking&&i;if(this.seeking=i,g!==p){if(this.moved=!0,h!==null){if(this.stallReported){var c=self.performance.now()-h;M.logger.warn("playback not stuck anymore @"+g+", after "+Math.round(c)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((l||r)&&(this.stalled=null),!(o.paused&&!i||o.ended||o.playbackRate===0||!P.BufferHelper.getBuffered(o).length)){var t=P.BufferHelper.bufferInfo(o,g,0),a=t.len>0,u=t.nextStart||0;if(!(!a&&!u)){if(i){var s=t.len>O,f=!u||d&&d.start<=g||u-g>O&&!this.fragmentTracker.getPartialFragment(g);if(s||f)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var v,S=Math.max(u,t.start||0)-g,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,I=x==null||(v=x.details)===null||v===void 0?void 0:v.live,B=I?x.details.targetduration*2:O;if(S>0&&S<=B){this._trySkipBufferHole(null);return}}var k=self.performance.now();if(h===null){this.stalled=k;return}var U=k-h;if(!(!i&&U>=R&&(this._reportStall(t),!this.media))){var W=P.BufferHelper.bufferInfo(o,g,e.maxBufferHole);this._tryFixBufferStall(W,U)}}}}},E._tryFixBufferStall=function(p,d){var e=this.config,o=this.fragmentTracker,h=this.media;if(h!==null){var g=h.currentTime,i=o.getPartialFragment(g);if(i){var r=this._trySkipBufferHole(i);if(r||!this.media)return}p.len>e.maxBufferHole&&d>e.highBufferWatchdogPeriod*1e3&&(M.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},E._reportStall=function(p){var d=this.hls,e=this.media,o=this.stallReported;!o&&e&&(this.stallReported=!0,M.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer ("+JSON.stringify(p)+")"),d.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p.len}))},E._trySkipBufferHole=function(p){var d=this.config,e=this.hls,o=this.media;if(o===null)return 0;for(var h=o.currentTime,g=0,i=P.BufferHelper.getBuffered(o),r=0;r<i.length;r++){var l=i.start(r);if(h+d.maxBufferHole>=g&&h<l){var c=Math.max(l+y,o.currentTime+_);return M.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+c),this.moved=!0,this.stalled=null,o.currentTime=c,p&&e.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+c,frag:p}),c}g=i.end(r)}return 0},E._tryNudgeBuffer=function(){var p=this.config,d=this.hls,e=this.media,o=this.nudgeRetry;if(e!==null){var h=e.currentTime;if(this.nudgeRetry++,o<p.nudgeMaxRetry){var g=h+(o+1)*p.nudgeOffset;M.logger.warn("Nudging 'currentTime' from "+h+" to "+g),e.currentTime=g,d.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else M.logger.error("Playhead still not moving while enough data buffered @"+h+" after "+p.nudgeMaxRetry+" nudges"),d.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},D}()},"./src/controller/id3-track-controller.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/polyfills/number.ts"),L=n("./src/events.ts"),A=n("./src/utils/texttrack-utils.ts"),M=n("./src/demux/id3.ts"),R=n("./src/loader/date-range.ts"),O=n("./src/types/demuxer.ts"),_=.25;function y(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function T(m,p){return m.getTime()/1e3-p}function D(m){return Uint8Array.from(m.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var E=function(){function m(d){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=d,this._registerListeners()}var p=m.prototype;return p.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},p._registerListeners=function(){var e=this.hls;e.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(L.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p._unregisterListeners=function(){var e=this.hls;e.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(L.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p.onMediaAttached=function(e,o){this.media=o.media},p.onMediaDetaching=function(){!this.id3Track||(Object(A.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},p.onManifestLoading=function(){this.dateRangeCuesAppended={}},p.createTrack=function(e){var o=this.getID3Track(e.textTracks);return o.mode="hidden",o},p.getID3Track=function(e){if(!!this.media){for(var o=0;o<e.length;o++){var h=e[o];if(h.kind==="metadata"&&h.label==="id3")return Object(A.sendAddTrackEvent)(h,this.media),h}return this.media.addTextTrack("metadata","id3")}},p.onFragParsingMetadata=function(e,o){if(!!this.media){var h=this.hls.config,g=h.enableEmsgMetadataCues,i=h.enableID3MetadataCues;if(!(!g&&!i)){var r=o.frag,l=o.samples,c=o.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var t=c.edge||r.end,a=y(),u=!1,s={},f=0;f<l.length;f++){var v=l[f].type;if(!(v===O.MetadataSchema.emsg&&!g||!i)){var S=M.getID3Frames(l[f].data);if(S){var x=l[f].pts,I=t,B=I-x;B<=0&&(I=x+_);for(var k=0;k<S.length;k++){var U=S[k];if(!M.isTimeStampFrame(U)){var W=new a(x,I,"");W.value=U,v&&(W.type=v),this.id3Track.addCue(W),s[U.key]=null,u=!0}}}}}u&&this.updateId3CueEnds(s)}}},p.updateId3CueEnds=function(e){var o,h=(o=this.id3Track)===null||o===void 0?void 0:o.cues;if(h)for(var g=h.length;g--;){var i,r=h[g],l=(i=r.value)===null||i===void 0?void 0:i.key;if(l&&l in e){var c=e[l];c&&r.endTime!==c&&(r.endTime=c),e[l]=r.startTime}}},p.onBufferFlushing=function(e,o){var h=o.startOffset,g=o.endOffset,i=o.type,r=this.id3Track,l=this.hls;if(!!l){var c=l.config,t=c.enableEmsgMetadataCues,a=c.enableID3MetadataCues;if(r&&(t||a)){var u;i==="audio"?u=function(f){return f.type===O.MetadataSchema.audioId3&&a}:i==="video"?u=function(f){return f.type===O.MetadataSchema.emsg&&t}:u=function(f){return f.type===O.MetadataSchema.audioId3&&a||f.type===O.MetadataSchema.emsg&&t},Object(A.removeCuesInRange)(r,h,g,u)}}},p.onLevelUpdated=function(e,o){var h=this,g=o.details;if(!(!this.media||!g.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var i=this.dateRangeCuesAppended,r=this.id3Track,l=g.dateRanges,c=Object.keys(l);if(r)for(var t=Object.keys(i).filter(function(B){return!c.includes(B)}),a=function(k){var U=t[k];Object.keys(i[U].cues).forEach(function(W){r.removeCue(i[U].cues[W])}),delete i[U]},u=t.length;u--;)a(u);var s=g.fragments[g.fragments.length-1];if(!(c.length===0||!Object(P.isFiniteNumber)(s==null?void 0:s.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var f=s.programDateTime/1e3-s.start,v=g.edge||s.end,S=y(),x=function(k){var U=c[k],W=l[U],G=i[U],X=(G==null?void 0:G.cues)||{},Y=(G==null?void 0:G.durationKnown)||!1,J=T(W.startDate,f),ee=v,z=W.endDate;if(z)ee=T(z,f),Y=!0;else if(W.endOnNext&&!Y){var q=c.reduce(function(re,he){var ge=l[he];return ge.class===W.class&&ge.id!==he&&ge.startDate>W.startDate&&re.push(ge),re},[]).sort(function(re,he){return re.startDate.getTime()-he.startDate.getTime()})[0];q&&(ee=T(q.startDate,f),Y=!0)}for(var ie=Object.keys(W.attr),ae=0;ae<ie.length;ae++){var te=ie[ae];if(!(te===R.DateRangeAttribute.ID||te===R.DateRangeAttribute.CLASS||te===R.DateRangeAttribute.START_DATE||te===R.DateRangeAttribute.DURATION||te===R.DateRangeAttribute.END_DATE||te===R.DateRangeAttribute.END_ON_NEXT)){var oe=X[te];if(oe)Y&&!G.durationKnown&&(oe.endTime=ee);else{var ue=W.attr[te];oe=new S(J,ee,""),(te===R.DateRangeAttribute.SCTE35_OUT||te===R.DateRangeAttribute.SCTE35_IN)&&(ue=D(ue)),oe.value={key:te,data:ue},oe.type=O.MetadataSchema.dateRange,h.id3Track.addCue(oe),X[te]=oe}}}i[U]={cues:X,dateRange:W,durationKnown:Y}},I=0;I<c.length;I++)x(I)}}},m}();b.default=E},"./src/controller/latency-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return O});var P=n("./src/errors.ts"),L=n("./src/events.ts"),A=n("./src/utils/logger.ts");function M(_,y){for(var T=0;T<y.length;T++){var D=y[T];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function R(_,y,T){return y&&M(_.prototype,y),T&&M(_,T),Object.defineProperty(_,"prototype",{writable:!1}),_}var O=function(){function _(T){var D=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return D.timeupdate()},this.hls=T,this.config=T.config,this.registerListeners()}var y=_.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(L.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(L.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(L.Events.ERROR,this.onError)},y.onMediaAttached=function(D,E){this.media=E.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},y.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},y.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},y.onLevelUpdated=function(D,E){var m=E.details;this.levelDetails=m,m.advanced&&this.timeupdate(),!m.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(D,E){E.details===P.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,A.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},y.timeupdate=function(){var D=this.media,E=this.levelDetails;if(!(!D||!E)){this.currentTime=D.currentTime;var m=this.computeLatency();if(m!==null){this._latency=m;var p=this.config,d=p.lowLatencyMode,e=p.maxLiveSyncPlaybackRate;if(!(!d||e===1)){var o=this.targetLatency;if(o!==null){var h=m-o,g=Math.min(this.maxLatency,o+E.targetduration),i=h<g;if(E.live&&i&&h>.05&&this.forwardBufferLength>1){var r=Math.min(2,Math.max(1,e)),l=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;D.playbackRate=Math.min(r,Math.max(1,l))}else D.playbackRate!==1&&D.playbackRate!==0&&(D.playbackRate=1)}}}}},y.estimateLiveEdge=function(){var D=this.levelDetails;return D===null?null:D.edge+D.age},y.computeLatency=function(){var D=this.estimateLiveEdge();return D===null?null:D-this.currentTime},R(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var D=this.config,E=this.levelDetails;return D.liveMaxLatencyDuration!==void 0?D.liveMaxLatencyDuration:E?D.liveMaxLatencyDurationCount*E.targetduration:0}},{key:"targetLatency",get:function(){var D=this.levelDetails;if(D===null)return null;var E=D.holdBack,m=D.partHoldBack,p=D.targetduration,d=this.config,e=d.liveSyncDuration,o=d.liveSyncDurationCount,h=d.lowLatencyMode,g=this.hls.userConfig,i=h&&m||E;(g.liveSyncDuration||g.liveSyncDurationCount||i===0)&&(i=e!==void 0?e:o*p);var r=p,l=1;return i+Math.min(this.stallCount*l,r)}},{key:"liveSyncPosition",get:function(){var D=this.estimateLiveEdge(),E=this.targetLatency,m=this.levelDetails;if(D===null||E===null||m===null)return null;var p=m.edge,d=D-E-this.edgeStalled,e=p-m.totalduration,o=p-(this.config.lowLatencyMode&&m.partTarget||m.targetduration);return Math.min(Math.max(e,d),o)}},{key:"drift",get:function(){var D=this.levelDetails;return D===null?1:D.drift}},{key:"edgeStalled",get:function(){var D=this.levelDetails;if(D===null)return 0;var E=(this.config.lowLatencyMode&&D.partTarget||D.targetduration)*3;return Math.max(D.age-E,0)}},{key:"forwardBufferLength",get:function(){var D=this.media,E=this.levelDetails;if(!D||!E)return 0;var m=D.buffered.length;return(m?D.buffered.end(m-1):E.edge)-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return d});var P=n("./src/types/level.ts"),L=n("./src/events.ts"),A=n("./src/errors.ts"),M=n("./src/utils/codecs.ts"),R=n("./src/controller/level-helper.ts"),O=n("./src/controller/base-playlist-controller.ts"),_=n("./src/types/loader.ts");function y(){return y=Object.assign?Object.assign.bind():function(e){for(var o=1;o<arguments.length;o++){var h=arguments[o];for(var g in h)Object.prototype.hasOwnProperty.call(h,g)&&(e[g]=h[g])}return e},y.apply(this,arguments)}function T(e,o){for(var h=0;h<o.length;h++){var g=o[h];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(e,g.key,g)}}function D(e,o,h){return o&&T(e.prototype,o),h&&T(e,h),Object.defineProperty(e,"prototype",{writable:!1}),e}function E(e,o){e.prototype=Object.create(o.prototype),e.prototype.constructor=e,m(e,o)}function m(e,o){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,i){return g.__proto__=i,g},m(e,o)}var p=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),d=function(e){E(o,e);function o(g){var i;return i=e.call(this,g,"[level-controller]")||this,i._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.onParsedComplete=void 0,i._registerListeners(),i}var h=o.prototype;return h._registerListeners=function(){var i=this.hls;i.on(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(L.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(L.Events.ERROR,this.onError,this)},h._unregisterListeners=function(){var i=this.hls;i.off(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(L.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(L.Events.ERROR,this.onError,this)},h.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},h.startLoad=function(){var i=this._levels;i.forEach(function(r){r.loadError=0}),e.prototype.startLoad.call(this)},h.onManifestLoaded=function(i,r){var l=[],c=[],t=[],a,u={},s,f=!1,v=!1,S=!1;if(r.levels.forEach(function(k){var U=k.attrs;f=f||!!(k.width&&k.height),v=v||!!k.videoCodec,S=S||!!k.audioCodec,p&&k.audioCodec&&k.audioCodec.indexOf("mp4a.40.34")!==-1&&(k.audioCodec=void 0);var W=k.bitrate+"-"+k.attrs.RESOLUTION+"-"+k.attrs.CODECS;s=u[W],s?s.url.push(k.url):(s=new P.Level(k),u[W]=s,l.push(s)),U&&(U.AUDIO&&Object(R.addGroupId)(s,"audio",U.AUDIO),U.SUBTITLES&&Object(R.addGroupId)(s,"text",U.SUBTITLES))}),(f||v)&&S&&(l=l.filter(function(k){var U=k.videoCodec,W=k.width,G=k.height;return!!U||!!(W&&G)})),l=l.filter(function(k){var U=k.audioCodec,W=k.videoCodec;return(!U||Object(M.isCodecSupportedInMp4)(U,"audio"))&&(!W||Object(M.isCodecSupportedInMp4)(W,"video"))}),r.audioTracks&&(c=r.audioTracks.filter(function(k){return!k.audioCodec||Object(M.isCodecSupportedInMp4)(k.audioCodec,"audio")}),Object(R.assignTrackIdsByGroup)(c)),r.subtitles&&(t=r.subtitles,Object(R.assignTrackIdsByGroup)(t)),l.length>0){a=l[0].bitrate,l.sort(function(k,U){return k.bitrate-U.bitrate}),this._levels=l;for(var x=0;x<l.length;x++)if(l[x].bitrate===a){this._firstLevel=x,this.log("manifest loaded, "+l.length+" level(s) found, first bitrate: "+a);break}var I=S&&!v,B={levels:l,audioTracks:c,subtitleTracks:t,firstLevel:this._firstLevel,stats:r.stats,audio:S,video:v,altAudio:!I&&c.some(function(k){return!!k.url})};this.hls.trigger(L.Events.MANIFEST_PARSED,B),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(L.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,reason:"no level with compatible codecs found in manifest"})},h.onError=function(i,r){var l;if(e.prototype.onError.call(this,i,r),!r.fatal){var c=r.context,t=this._levels[this.currentLevelIndex];if(c&&(c.type===_.PlaylistContextType.AUDIO_TRACK&&t.audioGroupIds&&c.groupId===t.audioGroupIds[t.urlId]||c.type===_.PlaylistContextType.SUBTITLE_TRACK&&t.textGroupIds&&c.groupId===t.textGroupIds[t.urlId])){this.redundantFailover(this.currentLevelIndex);return}var a=!1,u=!0,s;switch(r.details){case A.ErrorDetails.FRAG_LOAD_ERROR:case A.ErrorDetails.FRAG_LOAD_TIMEOUT:case A.ErrorDetails.KEY_LOAD_ERROR:case A.ErrorDetails.KEY_LOAD_TIMEOUT:if(r.frag){var f=r.frag.type===_.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,v=this._levels[f];v?(v.fragmentError++,v.fragmentError>this.hls.config.fragLoadingMaxRetry&&(s=f)):s=f}break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:c&&(c.deliveryDirectives&&(u=!1),s=c.level),a=!0;break;case A.ErrorDetails.REMUX_ALLOC_ERROR:s=(l=r.level)!=null?l:this.currentLevelIndex,a=!0;break}s!==void 0&&this.recoverLevel(r,s,a,u)}},h.recoverLevel=function(i,r,l,c){var t=i.details,a=this._levels[r];if(a.loadError++,l){var u=this.retryLoadingOrFail(i);if(u)i.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(c){var s=a.url.length;if(s>1&&a.loadError<s)i.levelRetry=!0,this.redundantFailover(r);else if(this.manualLevelIndex===-1){for(var f=-1,v=this._levels,S=v.length;S--;){var x=(S+this.currentLevelIndex)%v.length;if(x!==this.currentLevelIndex&&v[x].loadError===0){f=x;break}}f>-1&&this.currentLevelIndex!==f&&(this.warn(t+": switch to "+f),i.levelRetry=!0,this.hls.nextAutoLevel=f)}}},h.redundantFailover=function(i){var r=this._levels[i],l=r.url.length;if(l>1){var c=(r.urlId+1)%l;this.warn("Switching to redundant URL-id "+c),this._levels.forEach(function(t){t.urlId=c}),this.level=i}},h.onFragLoaded=function(i,r){var l=r.frag;if(l!==void 0&&l.type===_.PlaylistLevelType.MAIN){var c=this._levels[l.level];c!==void 0&&(c.fragmentError=0,c.loadError=0)}},h.onLevelLoaded=function(i,r){var l,c=r.level,t=r.details,a=this._levels[c];if(!a){var u;this.warn("Invalid level index "+c),(u=r.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(t.deltaUpdateFailed=!0);return}c===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0,this.retryCount=0),this.playlistLoaded(c,r,a.details)):(l=r.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(t.deltaUpdateFailed=!0)},h.onAudioTrackSwitched=function(i,r){var l=this.hls.levels[this.currentLevelIndex];if(!!l&&l.audioGroupIds){for(var c=-1,t=this.hls.audioTracks[r.id].groupId,a=0;a<l.audioGroupIds.length;a++)if(l.audioGroupIds[a]===t){c=a;break}c!==l.urlId&&(l.urlId=c,this.startLoad())}},h.loadPlaylist=function(i){var r=this.currentLevelIndex,l=this._levels[r];if(this.canLoad&&l&&l.url.length>0){var c=l.urlId,t=l.url[c];if(i)try{t=i.addDirectives(t)}catch(a){this.warn("Could not construct new URL with HLS Delivery Directives: "+a)}this.log("Attempt loading level index "+r+(i?" at sn "+i.msn+" part "+i.part:"")+" with URL-id "+c+" "+t),this.clearTimer(),this.hls.trigger(L.Events.LEVEL_LOADING,{url:t,level:r,id:c,deliveryDirectives:i||null})}},h.removeLevel=function(i,r){var l=function(a,u){return u!==r},c=this._levels.filter(function(t,a){return a!==i?!0:t.url.length>1&&r!==void 0?(t.url=t.url.filter(l),t.audioGroupIds&&(t.audioGroupIds=t.audioGroupIds.filter(l)),t.textGroupIds&&(t.textGroupIds=t.textGroupIds.filter(l)),t.urlId=0,!0):!1}).map(function(t,a){var u=t.details;return u!=null&&u.fragments&&u.fragments.forEach(function(s){s.level=a}),t});this._levels=c,this.hls.trigger(L.Events.LEVELS_UPDATED,{levels:c})},D(o,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(i){var r,l=this._levels;if(l.length!==0&&!(this.currentLevelIndex===i&&(r=l[i])!==null&&r!==void 0&&r.details)){if(i<0||i>=l.length){var c=i<0;if(this.hls.trigger(L.Events.ERROR,{type:A.ErrorTypes.OTHER_ERROR,details:A.ErrorDetails.LEVEL_SWITCH_ERROR,level:i,fatal:c,reason:"invalid level idx"}),c)return;i=Math.min(i,l.length-1)}this.clearTimer();var t=this.currentLevelIndex,a=l[t],u=l[i];this.log("switching to level "+i+" from "+t),this.currentLevelIndex=i;var s=y({},u,{level:i,maxBitrate:u.maxBitrate,uri:u.uri,urlId:u.urlId});delete s._urlId,this.hls.trigger(L.Events.LEVEL_SWITCHING,s);var f=u.details;if(!f||f.live){var v=this.switchParams(u.uri,a==null?void 0:a.details);this.loadPlaylist(v)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(i){this.manualLevelIndex=i,this._startLevel===void 0&&(this._startLevel=i),i!==-1&&(this.level=i)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(i){this._firstLevel=i}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var i=this.hls.config.startLevel;return i!==void 0?i:this._firstLevel}else return this._startLevel},set:function(i){this._startLevel=i}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(i){this.level=i,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=i)}}]),o}(O.default)},"./src/controller/level-helper.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"addGroupId",function(){return R}),n.d(b,"assignTrackIdsByGroup",function(){return O}),n.d(b,"updatePTS",function(){return _}),n.d(b,"updateFragPTSDTS",function(){return T}),n.d(b,"mergeDetails",function(){return D}),n.d(b,"mapPartIntersection",function(){return m}),n.d(b,"mapFragmentIntersection",function(){return p}),n.d(b,"adjustSliding",function(){return d}),n.d(b,"addSliding",function(){return e}),n.d(b,"computeReloadInterval",function(){return o}),n.d(b,"getFragmentWithSN",function(){return h}),n.d(b,"getPartWith",function(){return g});var P=n("./src/polyfills/number.ts"),L=n("./src/utils/logger.ts"),A=n("./src/loader/date-range.ts");function M(){return M=Object.assign?Object.assign.bind():function(i){for(var r=1;r<arguments.length;r++){var l=arguments[r];for(var c in l)Object.prototype.hasOwnProperty.call(l,c)&&(i[c]=l[c])}return i},M.apply(this,arguments)}function R(i,r,l){switch(r){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(l);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(l);break}}function O(i){var r={};i.forEach(function(l){var c=l.groupId||"";l.id=r[c]=r[c]||0,r[c]++})}function _(i,r,l){var c=i[r],t=i[l];y(c,t)}function y(i,r){var l=r.startPTS;if(Object(P.isFiniteNumber)(l)){var c=0,t;r.sn>i.sn?(c=l-i.start,t=i):(c=i.start-l,t=r),t.duration!==c&&(t.duration=c)}else if(r.sn>i.sn){var a=i.cc===r.cc;a&&i.minEndPTS?r.start=i.start+(i.minEndPTS-i.start):r.start=i.start+i.duration}else r.start=Math.max(i.start-r.duration,0)}function T(i,r,l,c,t,a){var u=c-l;u<=0&&(L.logger.warn("Fragment should have a positive duration",r),c=l+r.duration,a=t+r.duration);var s=l,f=c,v=r.startPTS,S=r.endPTS;if(Object(P.isFiniteNumber)(v)){var x=Math.abs(v-l);Object(P.isFiniteNumber)(r.deltaPTS)?r.deltaPTS=Math.max(x,r.deltaPTS):r.deltaPTS=x,s=Math.max(l,v),l=Math.min(l,v),t=Math.min(t,r.startDTS),f=Math.min(c,S),c=Math.max(c,S),a=Math.max(a,r.endDTS)}r.duration=c-l;var I=l-r.start;r.appendedPTS=c,r.start=r.startPTS=l,r.maxStartPTS=s,r.startDTS=t,r.endPTS=c,r.minEndPTS=f,r.endDTS=a;var B=r.sn;if(!i||B<i.startSN||B>i.endSN)return 0;var k,U=B-i.startSN,W=i.fragments;for(W[U]=r,k=U;k>0;k--)y(W[k],W[k-1]);for(k=U;k<W.length-1;k++)y(W[k],W[k+1]);return i.fragmentHint&&y(W[W.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,I}function D(i,r){for(var l=null,c=i.fragments,t=c.length-1;t>=0;t--){var a=c[t].initSegment;if(a){l=a;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var u=0,s;if(p(i,r,function(k,U){k.relurl&&(u=k.cc-U.cc),Object(P.isFiniteNumber)(k.startPTS)&&Object(P.isFiniteNumber)(k.endPTS)&&(U.start=U.startPTS=k.startPTS,U.startDTS=k.startDTS,U.appendedPTS=k.appendedPTS,U.maxStartPTS=k.maxStartPTS,U.endPTS=k.endPTS,U.endDTS=k.endDTS,U.minEndPTS=k.minEndPTS,U.duration=k.endPTS-k.startPTS,U.duration&&(s=U),r.PTSKnown=r.alignedSliding=!0),U.elementaryStreams=k.elementaryStreams,U.loader=k.loader,U.stats=k.stats,U.urlId=k.urlId,k.initSegment&&(U.initSegment=k.initSegment,l=k.initSegment)}),l){var f=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments;f.forEach(function(k){var U;(!k.initSegment||k.initSegment.relurl===((U=l)===null||U===void 0?void 0:U.relurl))&&(k.initSegment=l)})}if(r.skippedSegments)if(r.deltaUpdateFailed=r.fragments.some(function(k){return!k}),r.deltaUpdateFailed){L.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var v=r.skippedSegments;v--;)r.fragments.shift();r.startSN=r.fragments[0].sn,r.startCC=r.fragments[0].cc}else r.canSkipDateRanges&&(r.dateRanges=E(i.dateRanges,r.dateRanges,r.recentlyRemovedDateranges));var S=r.fragments;if(u){L.logger.warn("discontinuity sliding from playlist, take drift into account");for(var x=0;x<S.length;x++)S[x].cc+=u}r.skippedSegments&&(r.startCC=r.fragments[0].cc),m(i.partList,r.partList,function(k,U){U.elementaryStreams=k.elementaryStreams,U.stats=k.stats}),s?T(r,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):d(i,r),S.length&&(r.totalduration=r.edge-S[0].start),r.driftStartTime=i.driftStartTime,r.driftStart=i.driftStart;var I=r.advancedDateTime;if(r.advanced&&I){var B=r.edge;r.driftStart||(r.driftStartTime=I,r.driftStart=B),r.driftEndTime=I,r.driftEnd=B}else r.driftEndTime=i.driftEndTime,r.driftEnd=i.driftEnd,r.advancedDateTime=i.advancedDateTime}function E(i,r,l){var c=M({},i);return l&&l.forEach(function(t){delete c[t]}),Object.keys(r).forEach(function(t){var a=new A.DateRange(r[t].attr,c[t]);a.isValid?c[t]=a:L.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(r[t].attr)+'"')}),c}function m(i,r,l){if(i&&r)for(var c=0,t=0,a=i.length;t<=a;t++){var u=i[t],s=r[t+c];u&&s&&u.index===s.index&&u.fragment.sn===s.fragment.sn?l(u,s):c--}}function p(i,r,l){for(var c=r.skippedSegments,t=Math.max(i.startSN,r.startSN)-r.startSN,a=(i.fragmentHint?1:0)+(c?r.endSN:Math.min(i.endSN,r.endSN))-r.startSN,u=r.startSN-i.startSN,s=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments,f=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,v=t;v<=a;v++){var S=f[u+v],x=s[v];c&&!x&&v<c&&(x=r.fragments[v]=S),S&&x&&l(S,x)}}function d(i,r){var l=r.startSN+r.skippedSegments-i.startSN,c=i.fragments;l<0||l>=c.length||e(r,c[l].start)}function e(i,r){if(r){for(var l=i.fragments,c=i.skippedSegments;c<l.length;c++)l[c].start+=r;i.fragmentHint&&(i.fragmentHint.start+=r)}}function o(i,r){var l=1e3*i.levelTargetDuration,c=l/2,t=i.age,a=t>0&&t<l*3,u=r.loading.end-r.loading.start,s,f=i.availabilityDelay;if(i.updated===!1)if(a){var v=333*i.misses;s=Math.max(Math.min(c,u*2),v),i.availabilityDelay=(i.availabilityDelay||0)+s}else s=c;else a?(f=Math.min(f||l/2,t),i.availabilityDelay=f,s=f+l-t):s=l-u;return Math.round(s)}function h(i,r,l){if(!i||!i.details)return null;var c=i.details,t=c.fragments[r-c.startSN];return t||(t=c.fragmentHint,t&&t.sn===r)?t:r<c.startSN&&l&&l.sn===r?l:null}function g(i,r,l){if(!i||!i.details)return null;var c=i.details.partList;if(c)for(var t=c.length;t--;){var a=c[t];if(a.index===l&&a.fragment.sn===r)return a}return null}},"./src/controller/stream-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return g});var P=n("./src/polyfills/number.ts"),L=n("./src/controller/base-stream-controller.ts"),A=n("./src/is-supported.ts"),M=n("./src/events.ts"),R=n("./src/utils/buffer-helper.ts"),O=n("./src/controller/fragment-tracker.ts"),_=n("./src/types/loader.ts"),y=n("./src/loader/fragment.ts"),T=n("./src/demux/transmuxer-interface.ts"),D=n("./src/types/transmuxer.ts"),E=n("./src/controller/gap-controller.ts"),m=n("./src/errors.ts");function p(i,r){for(var l=0;l<r.length;l++){var c=r[l];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(i,c.key,c)}}function d(i,r,l){return r&&p(i.prototype,r),l&&p(i,l),Object.defineProperty(i,"prototype",{writable:!1}),i}function e(i,r){i.prototype=Object.create(r.prototype),i.prototype.constructor=i,o(i,r)}function o(i,r){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,t){return c.__proto__=t,c},o(i,r)}var h=100,g=function(i){e(r,i);function r(c,t){var a;return a=i.call(this,c,t,"[stream-controller]")||this,a.audioCodecSwap=!1,a.gapController=null,a.level=-1,a._forceStartLoad=!1,a.altAudio=!1,a.audioOnly=!1,a.fragPlaying=null,a.onvplaying=null,a.onvseeked=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a._registerListeners(),a}var l=r.prototype;return l._registerListeners=function(){var t=this.hls;t.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(M.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(M.Events.ERROR,this.onError,this),t.on(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(M.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(M.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(M.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},l._unregisterListeners=function(){var t=this.hls;t.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(M.Events.ERROR,this.onError,this),t.off(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(M.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(M.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(M.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},l.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},l.startLoad=function(t){if(this.levels){var a=this.lastCurrentTime,u=this.hls;if(this.stopLoad(),this.setInterval(h),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var s=u.startLevel;s===-1&&(u.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=u.nextAutoLevel),this.level=u.nextLoadLevel=s,this.loadedmetadata=!1}a>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),t=a),this.state=L.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=L.State.STOPPED},l.stopLoad=function(){this._forceStartLoad=!1,i.prototype.stopLoad.call(this)},l.doTick=function(){switch(this.state){case L.State.IDLE:this.doTickIdle();break;case L.State.WAITING_LEVEL:{var t,a=this.levels,u=this.level,s=a==null||(t=a[u])===null||t===void 0?void 0:t.details;if(s&&(!s.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(s))break;this.state=L.State.IDLE;break}break}case L.State.FRAG_LOADING_WAITING_RETRY:{var f,v=self.performance.now(),S=this.retryDate;(!S||v>=S||(f=this.media)!==null&&f!==void 0&&f.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=L.State.IDLE)}break;default:break}this.onTickEnd()},l.onTickEnd=function(){i.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},l.doTickIdle=function(){var t,a,u=this.hls,s=this.levelLastLoaded,f=this.levels,v=this.media,S=u.config,x=u.nextLoadLevel;if(!(s===null||!v&&(this.startFragRequested||!S.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!f||!f[x])){var I=f[x];this.level=u.nextLoadLevel=x;var B=I.details;if(!B||this.state===L.State.WAITING_LEVEL||B.live&&this.levelLastLoaded!==x){this.state=L.State.WAITING_LEVEL;return}var k=this.getMainFwdBufferInfo();if(k!==null){var U=k.len,W=this.getMaxBufferLength(I.maxBitrate);if(!(U>=W)){if(this._streamEnded(k,B)){var G={};this.altAudio&&(G.type="video"),this.hls.trigger(M.Events.BUFFER_EOS,G),this.state=L.State.ENDED;return}this.backtrackFragment&&this.backtrackFragment.start>k.end&&(this.backtrackFragment=null);var X=this.backtrackFragment?this.backtrackFragment.start:k.end,Y=this.getNextFragment(X,B);if(this.couldBacktrack&&!this.fragPrevious&&Y&&Y.sn!=="initSegment"&&this.fragmentTracker.getState(Y)!==O.FragmentState.OK){var J,ee=((J=this.backtrackFragment)!=null?J:Y).sn,z=ee-B.startSN,q=B.fragments[z-1];q&&Y.cc===q.cc&&(Y=q,this.fragmentTracker.removeFragment(q))}else this.backtrackFragment&&k.len&&(this.backtrackFragment=null);if(Y&&this.fragmentTracker.getState(Y)===O.FragmentState.OK&&this.nextLoadPosition>X){var ie=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;v&&this.afterBufferFlushed(v,ie,_.PlaylistLevelType.MAIN),Y=this.getNextFragment(this.nextLoadPosition,B)}!Y||(Y.initSegment&&!Y.initSegment.data&&!this.bitrateTest&&(Y=Y.initSegment),((t=Y.decryptdata)===null||t===void 0?void 0:t.keyFormat)==="identity"&&!((a=Y.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(Y,B):this.loadFragment(Y,B,X))}}}},l.loadFragment=function(t,a,u){var s,f=this.fragmentTracker.getState(t);this.fragCurrent=t,f===O.FragmentState.NOT_LOADED?t.sn==="initSegment"?this._loadInitSegment(t):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t)):(this.startFragRequested=!0,i.prototype.loadFragment.call(this,t,a,u)):f===O.FragmentState.APPENDING?this.reduceMaxBufferLength(t.duration)&&this.fragmentTracker.removeFragment(t):((s=this.media)===null||s===void 0?void 0:s.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},l.getAppendedFrag=function(t){var a=this.fragmentTracker.getAppendedFrag(t,_.PlaylistLevelType.MAIN);return a&&"fragment"in a?a.fragment:a},l.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,_.PlaylistLevelType.MAIN)},l.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},l.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},l.nextLevelSwitch=function(){var t=this.levels,a=this.media;if(a!=null&&a.readyState){var u,s=this.getAppendedFrag(a.currentTime);if(s&&s.start>1&&this.flushMainBuffer(0,s.start-1),!a.paused&&t){var f=this.hls.nextLoadLevel,v=t[f],S=this.fragLastKbps;S&&this.fragCurrent?u=this.fragCurrent.duration*v.maxBitrate/(1e3*S)+1:u=0}else u=0;var x=this.getBufferedFrag(a.currentTime+u);if(x){var I=this.followingBufferedFrag(x);if(I){this.abortCurrentFrag();var B=I.maxStartPTS?I.maxStartPTS:I.start,k=I.duration,U=Math.max(x.end,B+Math.min(Math.max(k-this.config.maxFragLookUpTolerance,k*.5),k*.75));this.flushMainBuffer(U,Number.POSITIVE_INFINITY)}}}},l.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t!=null&&t.loader&&t.loader.abort(),this.state){case L.State.KEY_LOADING:case L.State.FRAG_LOADING:case L.State.FRAG_LOADING_WAITING_RETRY:case L.State.PARSING:case L.State.PARSED:this.state=L.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},l.flushMainBuffer=function(t,a){i.prototype.flushMainBuffer.call(this,t,a,this.altAudio?"video":null)},l.onMediaAttached=function(t,a){i.prototype.onMediaAttached.call(this,t,a);var u=a.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),u.addEventListener("playing",this.onvplaying),u.addEventListener("seeked",this.onvseeked),this.gapController=new E.default(this.config,u,this.fragmentTracker,this.hls)},l.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),i.prototype.onMediaDetaching.call(this)},l.onMediaPlaying=function(){this.tick()},l.onMediaSeeked=function(){var t=this.media,a=t?t.currentTime:null;Object(P.isFiniteNumber)(a)&&this.log("Media seeked to "+a.toFixed(3)),this.tick()},l.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(M.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},l.onManifestParsed=function(t,a){var u=!1,s=!1,f;a.levels.forEach(function(v){f=v.audioCodec,f&&(f.indexOf("mp4a.40.2")!==-1&&(u=!0),f.indexOf("mp4a.40.5")!==-1&&(s=!0))}),this.audioCodecSwitch=u&&s&&!Object(A.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=a.levels,this.startFragRequested=!1},l.onLevelLoading=function(t,a){var u=this.levels;if(!(!u||this.state!==L.State.IDLE)){var s=u[a.level];(!s.details||s.details.live&&this.levelLastLoaded!==a.level||this.waitForCdnTuneIn(s.details))&&(this.state=L.State.WAITING_LEVEL)}},l.onLevelLoaded=function(t,a){var u,s=this.levels,f=a.level,v=a.details,S=v.totalduration;if(!s){this.warn("Levels were reset while loading level "+f);return}this.log("Level "+f+" loaded ["+v.startSN+","+v.endSN+"], cc ["+v.startCC+", "+v.endCC+"] duration:"+S);var x=this.fragCurrent;x&&(this.state===L.State.FRAG_LOADING||this.state===L.State.FRAG_LOADING_WAITING_RETRY)&&x.level!==a.level&&x.loader&&(this.state=L.State.IDLE,this.backtrackFragment=null,x.loader.abort());var I=s[f],B=0;if(v.live||(u=I.details)!==null&&u!==void 0&&u.live){if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed)return;B=this.alignPlaylists(v,I.details)}if(I.details=v,this.levelLastLoaded=f,this.hls.trigger(M.Events.LEVEL_UPDATED,{details:v,level:f}),this.state===L.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(v))return;this.state=L.State.IDLE}this.startFragRequested?v.live&&this.synchronizeToLiveEdge(v):this.setStartPosition(v,B),this.tick()},l._handleFragmentLoadProgress=function(t){var a,u=t.frag,s=t.part,f=t.payload,v=this.levels;if(!v){this.warn("Levels were reset while fragment load was in progress. Fragment "+u.sn+" of level "+u.level+" will not be buffered");return}var S=v[u.level],x=S.details;if(!x){this.warn("Dropping fragment "+u.sn+" of level "+u.level+" after level details were reset");return}var I=S.videoCodec,B=x.PTSKnown||!x.live,k=(a=u.initSegment)===null||a===void 0?void 0:a.data,U=this._getAudioCodec(S),W=this.transmuxer=this.transmuxer||new T.default(this.hls,_.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),G=s?s.index:-1,X=G!==-1,Y=new D.ChunkMetadata(u.level,u.sn,u.stats.chunkCount,f.byteLength,G,X),J=this.initPTS[u.cc];W.push(f,k,U,I,u,s,x.totalduration,B,Y,J)},l.onAudioTrackSwitching=function(t,a){var u=this.altAudio,s=!!a.url,f=a.id;if(!s){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var v=this.fragCurrent;v!=null&&v.loader&&(this.log("Switching to main audio track, cancel main fragment load"),v.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var S=this.hls;u&&S.trigger(M.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),S.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:f})}},l.onAudioTrackSwitched=function(t,a){var u=a.id,s=!!this.hls.audioTracks[u].url;if(s){var f=this.videoBuffer;f&&this.mediaBuffer!==f&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=f)}this.altAudio=s,this.tick()},l.onBufferCreated=function(t,a){var u=a.tracks,s,f,v=!1;for(var S in u){var x=u[S];if(x.id==="main"){if(f=S,s=x,S==="video"){var I=u[S];I&&(this.videoBuffer=I.buffer)}}else v=!0}v&&s?(this.log("Alternate track found, use "+f+".buffered to schedule main fragment loading"),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media},l.onFragBuffered=function(t,a){var u=a.frag,s=a.part;if(!(u&&u.type!==_.PlaylistLevelType.MAIN)){if(this.fragContextChanged(u)){this.warn("Fragment "+u.sn+(s?" p: "+s.index:"")+" of level "+u.level+" finished buffering, but was aborted. state: "+this.state),this.state===L.State.PARSED&&(this.state=L.State.IDLE);return}var f=s?s.stats:u.stats;this.fragLastKbps=Math.round(8*f.total/(f.buffering.end-f.loading.first)),u.sn!=="initSegment"&&(this.fragPrevious=u),this.fragBufferedComplete(u,s)}},l.onError=function(t,a){switch(a.details){case m.ErrorDetails.FRAG_LOAD_ERROR:case m.ErrorDetails.FRAG_LOAD_TIMEOUT:case m.ErrorDetails.KEY_LOAD_ERROR:case m.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.MAIN,a);break;case m.ErrorDetails.LEVEL_LOAD_ERROR:case m.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==L.State.ERROR&&(a.fatal?(this.warn(""+a.details),this.state=L.State.ERROR):!a.levelRetry&&this.state===L.State.WAITING_LEVEL&&(this.state=L.State.IDLE));break;case m.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="main"&&(this.state===L.State.PARSING||this.state===L.State.PARSED)){var u=!0,s=this.getFwdBufferInfo(this.media,_.PlaylistLevelType.MAIN);s&&s.len>.5&&(u=!this.reduceMaxBufferLength(s.len)),u&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},l.checkBuffer=function(){var t=this.media,a=this.gapController;if(!(!t||!a||!t.readyState)){if(this.loadedmetadata||!R.BufferHelper.getBuffered(t).length){var u=this.state!==L.State.IDLE?this.fragCurrent:null;a.poll(this.lastCurrentTime,u)}this.lastCurrentTime=t.currentTime}},l.onFragLoadEmergencyAborted=function(){this.state=L.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},l.onBufferFlushed=function(t,a){var u=a.type;if(u!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var s=(u===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(s,u,_.PlaylistLevelType.MAIN)}},l.onLevelsUpdated=function(t,a){this.levels=a.levels},l.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},l.seekToStartPos=function(){var t=this.media;if(!!t){var a=t.currentTime,u=this.startPosition;if(u>=0&&a<u){if(t.seeking){this.log("could not seek to "+u+", already seeking at "+a);return}var s=R.BufferHelper.getBuffered(t),f=s.length?s.start(0):0,v=f-u;v>0&&(v<this.config.maxBufferHole||v<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+v+" to match buffer start"),u+=v,this.startPosition=u),this.log("seek to target start position "+u+" from current time "+a),t.currentTime=u}}},l._getAudioCodec=function(t){var a=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&a&&(this.log("Swapping audio codec"),a.indexOf("mp4a.40.5")!==-1?a="mp4a.40.2":a="mp4a.40.5"),a},l._loadBitrateTestFrag=function(t){var a=this;t.bitrateTest=!0,this._doFragLoad(t).then(function(u){var s=a.hls;if(!(!u||s.nextLoadLevel||a.fragContextChanged(t))){a.fragLoadError=0,a.state=L.State.IDLE,a.startFragRequested=!1,a.bitrateTest=!1;var f=t.stats;f.parsing.start=f.parsing.end=f.buffering.start=f.buffering.end=self.performance.now(),s.trigger(M.Events.FRAG_LOADED,u),t.bitrateTest=!1}})},l._handleTransmuxComplete=function(t){var a,u="main",s=this.hls,f=t.remuxResult,v=t.chunkMeta,S=this.getCurrentContext(v);if(!S){this.warn("The loading context changed while buffering fragment "+v.sn+" of level "+v.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(v.level);return}var x=S.frag,I=S.part,B=S.level,k=f.video,U=f.text,W=f.id3,G=f.initSegment,X=B.details,Y=this.altAudio?void 0:f.audio;if(!this.fragContextChanged(x)){if(this.state=L.State.PARSING,G){G.tracks&&(this._bufferInitSegment(B,G.tracks,x,v),s.trigger(M.Events.FRAG_PARSING_INIT_SEGMENT,{frag:x,id:u,tracks:G.tracks}));var J=G.initPTS,ee=G.timescale;Object(P.isFiniteNumber)(J)&&(this.initPTS[x.cc]=J,s.trigger(M.Events.INIT_PTS_FOUND,{frag:x,id:u,initPTS:J,timescale:ee}))}if(k&&f.independent!==!1){if(X){var z=k.startPTS,q=k.endPTS,ie=k.startDTS,ae=k.endDTS;if(I)I.elementaryStreams[k.type]={startPTS:z,endPTS:q,startDTS:ie,endDTS:ae};else if(k.firstKeyFrame&&k.independent&&(this.couldBacktrack=!0),k.dropped&&k.independent){var te=this.getMainFwdBufferInfo(),oe=(te?te.end:this.getLoadPosition())+this.config.maxBufferHole,ue=k.firstKeyFramePTS?k.firstKeyFramePTS:z;if(oe<ue-this.config.maxBufferHole){this.backtrack(x);return}x.setElementaryStreamInfo(k.type,x.start,q,x.start,ae,!0)}x.setElementaryStreamInfo(k.type,z,q,ie,ae),this.backtrackFragment&&(this.backtrackFragment=x),this.bufferFragmentData(k,x,I,v)}}else if(f.independent===!1){this.backtrack(x);return}if(Y){var re=Y.startPTS,he=Y.endPTS,ge=Y.startDTS,Se=Y.endDTS;I&&(I.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:re,endPTS:he,startDTS:ge,endDTS:Se}),x.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,re,he,ge,Se),this.bufferFragmentData(Y,x,I,v)}if(X&&W!==null&&W!==void 0&&(a=W.samples)!==null&&a!==void 0&&a.length){var Me={id:u,frag:x,details:X,samples:W.samples};s.trigger(M.Events.FRAG_PARSING_METADATA,Me)}if(X&&U){var Oe={id:u,frag:x,details:X,samples:U.samples};s.trigger(M.Events.FRAG_PARSING_USERDATA,Oe)}}},l._bufferInitSegment=function(t,a,u,s){var f=this;if(this.state===L.State.PARSING){this.audioOnly=!!a.audio&&!a.video,this.altAudio&&!this.audioOnly&&delete a.audio;var v=a.audio,S=a.video,x=a.audiovideo;if(v){var I=t.audioCodec,B=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(I&&(I.indexOf("mp4a.40.5")!==-1?I="mp4a.40.2":I="mp4a.40.5"),v.metadata.channelCount!==1&&B.indexOf("firefox")===-1&&(I="mp4a.40.5")),B.indexOf("android")!==-1&&v.container!=="audio/mpeg"&&(I="mp4a.40.2",this.log("Android: force audio codec to "+I)),t.audioCodec&&t.audioCodec!==I&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+I+'"'),v.levelCodec=I,v.id="main",this.log("Init audio buffer, container:"+v.container+", codecs[selected/level/parsed]=["+(I||"")+"/"+(t.audioCodec||"")+"/"+v.codec+"]")}S&&(S.levelCodec=t.videoCodec,S.id="main",this.log("Init video buffer, container:"+S.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+S.codec+"]")),x&&this.log("Init audiovideo buffer, container:"+x.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+x.codec+"]"),this.hls.trigger(M.Events.BUFFER_CODECS,a),Object.keys(a).forEach(function(k){var U=a[k],W=U.initSegment;W!=null&&W.byteLength&&f.hls.trigger(M.Events.BUFFER_APPENDING,{type:k,data:W,frag:u,part:null,chunkMeta:s,parent:u.type})}),this.tick()}},l.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,_.PlaylistLevelType.MAIN)},l.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=L.State.IDLE},l.checkFragmentChanged=function(){var t=this.media,a=null;if(t&&t.readyState>1&&t.seeking===!1){var u=t.currentTime;if(R.BufferHelper.isBuffered(t,u)?a=this.getAppendedFrag(u):R.BufferHelper.isBuffered(t,u+.1)&&(a=this.getAppendedFrag(u+.1)),a){this.backtrackFragment=null;var s=this.fragPlaying,f=a.level;(!s||a.sn!==s.sn||s.level!==f||a.urlId!==s.urlId)&&(this.hls.trigger(M.Events.FRAG_CHANGED,{frag:a}),(!s||s.level!==f)&&this.hls.trigger(M.Events.LEVEL_SWITCHED,{level:f}),this.fragPlaying=a)}}},d(r,[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var a=t.currentTime,u=this.currentFrag;if(u&&Object(P.isFiniteNumber)(a)&&Object(P.isFiniteNumber)(u.programDateTime)){var s=u.programDateTime+(a-u.start)*1e3;return new Date(s)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),r}(L.default)},"./src/controller/subtitle-stream-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"SubtitleStreamController",function(){return e});var P=n("./src/events.ts"),L=n("./src/utils/buffer-helper.ts"),A=n("./src/controller/fragment-finders.ts"),M=n("./src/utils/discontinuities.ts"),R=n("./src/controller/level-helper.ts"),O=n("./src/controller/fragment-tracker.ts"),_=n("./src/controller/base-stream-controller.ts"),y=n("./src/types/loader.ts"),T=n("./src/types/level.ts");function D(h,g){for(var i=0;i<g.length;i++){var r=g[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(h,r.key,r)}}function E(h,g,i){return g&&D(h.prototype,g),i&&D(h,i),Object.defineProperty(h,"prototype",{writable:!1}),h}function m(h,g){h.prototype=Object.create(g.prototype),h.prototype.constructor=h,p(h,g)}function p(h,g){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,l){return r.__proto__=l,r},p(h,g)}var d=500,e=function(h){m(g,h);function g(r,l){var c;return c=h.call(this,r,l,"[subtitle-stream-controller]")||this,c.levels=[],c.currentTrackId=-1,c.tracksBuffered=[],c.mainDetails=null,c._registerListeners(),c}var i=g.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var l=this.hls;l.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(P.Events.ERROR,this.onError,this),l.on(P.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(P.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.on(P.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.on(P.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.on(P.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var l=this.hls;l.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(P.Events.ERROR,this.onError,this),l.off(P.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.off(P.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.off(P.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.off(P.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.off(P.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.startLoad=function(){this.stopLoad(),this.state=_.State.IDLE,this.setInterval(d),this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onLevelLoaded=function(l,c){this.mainDetails=c.details},i.onSubtitleFragProcessed=function(l,c){var t=c.frag,a=c.success;if(this.fragPrevious=t,this.state=_.State.IDLE,!!a){var u=this.tracksBuffered[this.currentTrackId];if(!!u){for(var s,f=t.start,v=0;v<u.length;v++)if(f>=u[v].start&&f<=u[v].end){s=u[v];break}var S=t.start+t.duration;s?s.end=S:(s={start:f,end:S},u.push(s)),this.fragmentTracker.fragBuffered(t)}}},i.onBufferFlushing=function(l,c){var t=c.startOffset,a=c.endOffset;if(t===0&&a!==Number.POSITIVE_INFINITY){var u=this.currentTrackId,s=this.levels;if(!s.length||!s[u]||!s[u].details)return;var f=s[u].details,v=f.targetduration,S=a-v;if(S<=0)return;c.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(x){for(var I=0;I<x.length;){if(x[I].end<=S){x.shift();continue}else if(x[I].start<S)x[I].start=S;else break;I++}}),this.fragmentTracker.removeFragmentsInRange(t,S,y.PlaylistLevelType.SUBTITLE)}},i.onError=function(l,c){var t,a=c.frag;!a||a.type!==y.PlaylistLevelType.SUBTITLE||((t=this.fragCurrent)!==null&&t!==void 0&&t.loader&&this.fragCurrent.loader.abort(),this.state=_.State.IDLE)},i.onSubtitleTracksUpdated=function(l,c){var t=this,a=c.subtitleTracks;this.tracksBuffered=[],this.levels=a.map(function(u){return new T.Level(u)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(u){t.tracksBuffered[u.id]=[]}),this.mediaBuffer=null},i.onSubtitleTrackSwitch=function(l,c){if(this.currentTrackId=c.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var t=this.levels[this.currentTrackId];t!=null&&t.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,t&&this.setInterval(d)},i.onSubtitleTrackLoaded=function(l,c){var t,a=c.details,u=c.id,s=this.currentTrackId,f=this.levels;if(!!f.length){var v=f[s];if(!(u>=f.length||u!==s||!v)){if(this.mediaBuffer=this.mediaBufferTimeRanges,a.live||(t=v.details)!==null&&t!==void 0&&t.live){var S=this.mainDetails;if(a.deltaUpdateFailed||!S)return;var x=S.fragments[0];if(!v.details)a.hasProgramDateTime&&S.hasProgramDateTime?Object(M.alignMediaPlaylistByPDT)(a,S):x&&Object(R.addSliding)(a,x.start);else{var I=this.alignPlaylists(a,v.details);I===0&&x&&Object(R.addSliding)(a,x.start)}}if(v.details=a,this.levelLastLoaded=u,this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===_.State.IDLE){var B=Object(A.findFragmentByPTS)(null,a.fragments,this.media.currentTime,0);B||(this.warn("Subtitle playlist not aligned with playback"),v.details=void 0)}}}},i._handleFragmentLoadComplete=function(l){var c=l.frag,t=l.payload,a=c.decryptdata,u=this.hls;if(!this.fragContextChanged(c)&&t&&t.byteLength>0&&a&&a.key&&a.iv&&a.method==="AES-128"){var s=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(t),a.key.buffer,a.iv.buffer).then(function(f){var v=performance.now();u.trigger(P.Events.FRAG_DECRYPTED,{frag:c,payload:f,stats:{tstart:s,tdecrypt:v}})})}},i.doTick=function(){if(!this.media){this.state=_.State.IDLE;return}if(this.state===_.State.IDLE){var l=this.currentTrackId,c=this.levels;if(!c.length||!c[l]||!c[l].details)return;var t=c[l].details,a=t.targetduration,u=this.config,s=this.media,f=L.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],s.currentTime-a,u.maxBufferHole),v=f.end,S=f.len,x=this.getMaxBufferLength()+a;if(S>x)return;console.assert(t,"Subtitle track details are defined on idle subtitle stream controller tick");var I=t.fragments,B=I.length,k=t.edge,U,W=this.fragPrevious;if(v<k){var G=u.maxFragLookUpTolerance;U=Object(A.findFragmentByPTS)(W,I,Math.max(I[0].start,v),G),!U&&W&&W.start<I[0].start&&(U=I[0])}else U=I[B-1];if(U=this.mapToInitFragWhenRequired(U),!U||this.fragmentTracker.getState(U)!==O.FragmentState.NOT_LOADED)return;U.encrypted?this.loadKey(U,t):this.loadFragment(U,t,v)}},i.loadFragment=function(l,c,t){this.fragCurrent=l,l.sn==="initSegment"?this._loadInitSegment(l):h.prototype.loadFragment.call(this,l,c,t)},E(g,[{key:"mediaBufferTimeRanges",get:function(){return new o(this.tracksBuffered[this.currentTrackId]||[])}}]),g}(_.default),o=function(g){this.buffered=void 0;var i=function(l,c,t){if(c=c>>>0,c>t-1)throw new DOMException("Failed to execute '"+l+"' on 'TimeRanges': The index provided ("+c+") is greater than the maximum bound ("+t+")");return g[c][l]};this.buffered={get length(){return g.length},end:function(l){return i("end",l,g.length)},start:function(l){return i("start",l,g.length)}}}},"./src/controller/subtitle-track-controller.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/events.ts"),L=n("./src/utils/texttrack-utils.ts"),A=n("./src/controller/base-playlist-controller.ts"),M=n("./src/types/loader.ts");function R(E,m){for(var p=0;p<m.length;p++){var d=m[p];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(E,d.key,d)}}function O(E,m,p){return m&&R(E.prototype,m),p&&R(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}function _(E,m){E.prototype=Object.create(m.prototype),E.prototype.constructor=E,y(E,m)}function y(E,m){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(d,e){return d.__proto__=e,d},y(E,m)}var T=function(E){_(m,E);function m(d){var e;return e=E.call(this,d,"[subtitle-track-controller]")||this,e.media=null,e.tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.selectDefaultTrack=!0,e.queuedDefaultTrack=-1,e.trackChangeListener=function(){return e.onTextTracksChanged()},e.asyncPollTrackChange=function(){return e.pollTrackChange(0)},e.useTextTrackPolling=!1,e.subtitlePollingInterval=-1,e._subtitleDisplay=!0,e.registerListeners(),e}var p=m.prototype;return p.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,E.prototype.destroy.call(this)},p.registerListeners=function(){var e=this.hls;e.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(P.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(P.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(P.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(P.Events.ERROR,this.onError,this)},p.unregisterListeners=function(){var e=this.hls;e.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(P.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(P.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(P.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(P.Events.ERROR,this.onError,this)},p.onMediaAttached=function(e,o){this.media=o.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},p.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},p.onMediaDetaching=function(){if(!!this.media){self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var e=D(this.media.textTracks);e.forEach(function(o){Object(L.clearCurrentCues)(o)}),this.subtitleTrack=-1,this.media=null}},p.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},p.onManifestParsed=function(e,o){this.tracks=o.subtitleTracks},p.onSubtitleTrackLoaded=function(e,o){var h=o.id,g=o.details,i=this.trackId,r=this.tracksInGroup[i];if(!r){this.warn("Invalid subtitle track id "+h);return}var l=r.details;r.details=o.details,this.log("subtitle track "+h+" loaded ["+g.startSN+"-"+g.endSN+"]"),h===this.trackId&&(this.retryCount=0,this.playlistLoaded(h,o,l))},p.onLevelLoading=function(e,o){this.switchLevel(o.level)},p.onLevelSwitching=function(e,o){this.switchLevel(o.level)},p.switchLevel=function(e){var o=this.hls.levels[e];if(!!(o!=null&&o.textGroupIds)){var h=o.textGroupIds[o.urlId];if(this.groupId!==h){var g=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,i=this.tracks.filter(function(c){return!h||c.groupId===h});this.tracksInGroup=i;var r=this.findTrackId(g==null?void 0:g.name)||this.findTrackId();this.groupId=h;var l={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+h+'" group-id'),this.hls.trigger(P.Events.SUBTITLE_TRACKS_UPDATED,l),r!==-1&&this.setSubtitleTrack(r,g)}}},p.findTrackId=function(e){for(var o=this.tracksInGroup,h=0;h<o.length;h++){var g=o[h];if((!this.selectDefaultTrack||g.default)&&(!e||e===g.name))return g.id}return-1},p.onError=function(e,o){E.prototype.onError.call(this,e,o),!(o.fatal||!o.context)&&o.context.type===M.PlaylistContextType.SUBTITLE_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},p.loadPlaylist=function(e){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var h=o.id,g=o.groupId,i=o.url;if(e)try{i=e.addDirectives(i)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log("Loading subtitle playlist for id "+h),this.hls.trigger(P.Events.SUBTITLE_TRACK_LOADING,{url:i,id:h,groupId:g,deliveryDirectives:e||null})}},p.toggleTrackModes=function(e){var o=this,h=this.media,g=this.trackId;if(!!h){var i=D(h.textTracks),r=i.filter(function(t){return t.groupId===o.groupId});if(e===-1)[].slice.call(i).forEach(function(t){t.mode="disabled"});else{var l=r[g];l&&(l.mode="disabled")}var c=r[e];c&&(c.mode=this.subtitleDisplay?"showing":"hidden")}},p.setSubtitleTrack=function(e,o){var h,g=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(h=g[e])!==null&&h!==void 0&&h.details)||e<-1||e>=g.length)){this.clearTimer();var i=g[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,i){var r=i.id,l=i.groupId,c=l===void 0?"":l,t=i.name,a=i.type,u=i.url;this.hls.trigger(P.Events.SUBTITLE_TRACK_SWITCH,{id:r,groupId:c,name:t,type:a,url:u});var s=this.switchParams(i.url,o==null?void 0:o.details);this.loadPlaylist(s)}else this.hls.trigger(P.Events.SUBTITLE_TRACK_SWITCH,{id:e})}},p.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var e=-1,o=D(this.media.textTracks),h=0;h<o.length;h++)if(o[h].mode==="hidden")e=h;else if(o[h].mode==="showing"){e=h;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},O(m,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var o=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,o)}}]),m}(A.default);function D(E){for(var m=[],p=0;p<E.length;p++){var d=E[p];d.kind==="subtitles"&&d.label&&m.push(E[p])}return m}b.default=T},"./src/controller/timeline-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"TimelineController",function(){return E});var P=n("./src/polyfills/number.ts"),L=n("./src/events.ts"),A=n("./src/utils/cea-608-parser.ts"),M=n("./src/utils/output-filter.ts"),R=n("./src/utils/webvtt-parser.ts"),O=n("./src/utils/texttrack-utils.ts"),_=n("./src/utils/imsc1-ttml-parser.ts"),y=n("./src/utils/mp4-tools.ts"),T=n("./src/types/loader.ts"),D=n("./src/utils/logger.ts"),E=function(){function e(h){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=d(),this.captionsProperties=void 0,this.hls=h,this.config=h.config,this.Cues=h.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var g=new M.default(this,"textTrack1"),i=new M.default(this,"textTrack2"),r=new M.default(this,"textTrack3"),l=new M.default(this,"textTrack4");this.cea608Parser1=new A.default(1,g,i),this.cea608Parser2=new A.default(3,r,l)}h.on(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),h.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),h.on(L.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.on(L.Events.FRAG_LOADING,this.onFragLoading,this),h.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),h.on(L.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),h.on(L.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),h.on(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.on(L.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),h.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=e.prototype;return o.destroy=function(){var g=this.hls;g.off(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),g.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),g.off(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),g.off(L.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),g.off(L.Events.FRAG_LOADING,this.onFragLoading,this),g.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),g.off(L.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),g.off(L.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),g.off(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),g.off(L.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),g.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(g,i,r,l,c){for(var t=!1,a=c.length;a--;){var u=c[a],s=p(u[0],u[1],i,r);if(s>=0&&(u[0]=Math.min(u[0],i),u[1]=Math.max(u[1],r),t=!0,s/(r-i)>.5))return}if(t||c.push([i,r]),this.config.renderTextTracksNatively){var f=this.captionsTracks[g];this.Cues.newCue(f,i,r,l)}else{var v=this.Cues.newCue(null,i,r,l);this.hls.trigger(L.Events.CUES_PARSED,{type:"captions",cues:v,track:g})}},o.onInitPtsFound=function(g,i){var r=this,l=i.frag,c=i.id,t=i.initPTS,a=i.timescale,u=this.unparsedVttFrags;c==="main"&&(this.initPTS[l.cc]=t,this.timescale[l.cc]=a),u.length&&(this.unparsedVttFrags=[],u.forEach(function(s){r.onFragLoaded(L.Events.FRAG_LOADED,s)}))},o.getExistingTrack=function(g){var i=this.media;if(i)for(var r=0;r<i.textTracks.length;r++){var l=i.textTracks[r];if(l[g])return l}return null},o.createCaptionsTrack=function(g){this.config.renderTextTracksNatively?this.createNativeTrack(g):this.createNonNativeTrack(g)},o.createNativeTrack=function(g){if(!this.captionsTracks[g]){var i=this.captionsProperties,r=this.captionsTracks,l=this.media,c=i[g],t=c.label,a=c.languageCode,u=this.getExistingTrack(g);if(u)r[g]=u,Object(O.clearCurrentCues)(r[g]),Object(O.sendAddTrackEvent)(r[g],l);else{var s=this.createTextTrack("captions",t,a);s&&(s[g]=!0,r[g]=s)}}},o.createNonNativeTrack=function(g){if(!this.nonNativeCaptionsTracks[g]){var i=this.captionsProperties[g];if(!!i){var r=i.label,l={_id:g,label:r,kind:"captions",default:i.media?!!i.media.default:!1,closedCaptions:i.media};this.nonNativeCaptionsTracks[g]=l,this.hls.trigger(L.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[l]})}}},o.createTextTrack=function(g,i,r){var l=this.media;if(!!l)return l.addTextTrack(g,i,r)},o.onMediaAttaching=function(g,i){this.media=i.media,this._cleanTracks()},o.onMediaDetaching=function(){var g=this.captionsTracks;Object.keys(g).forEach(function(i){Object(O.clearCurrentCues)(g[i]),delete g[i]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=d(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var g=this.media;if(!!g){var i=g.textTracks;if(i)for(var r=0;r<i.length;r++)Object(O.clearCurrentCues)(i[r])}},o.onSubtitleTracksUpdated=function(g,i){var r=this;this.textTracks=[];var l=i.subtitleTracks||[],c=l.some(function(s){return s.textCodec===_.IMSC1_CODEC});if(this.config.enableWebVTT||c&&this.config.enableIMSC1){var t=this.tracks&&l&&this.tracks.length===l.length;if(this.tracks=l||[],this.config.renderTextTracksNatively){var a=this.media?this.media.textTracks:[];this.tracks.forEach(function(s,f){var v;if(f<a.length){for(var S=null,x=0;x<a.length;x++)if(m(a[x],s)){S=a[x];break}S&&(v=S)}if(v)Object(O.clearCurrentCues)(v);else{var I=r._captionsOrSubtitlesFromCharacteristics(s);v=r.createTextTrack(I,s.name,s.lang),v&&(v.mode="disabled")}v&&(v.groupId=s.groupId,r.textTracks.push(v))})}else if(!t&&this.tracks&&this.tracks.length){var u=this.tracks.map(function(s){return{label:s.name,kind:s.type.toLowerCase(),default:s.default,subtitleTrack:s}});this.hls.trigger(L.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:u})}}},o._captionsOrSubtitlesFromCharacteristics=function(g){var i;if((i=g.attrs)!==null&&i!==void 0&&i.CHARACTERISTICS){var r=/transcribes-spoken-dialog/gi.test(g.attrs.CHARACTERISTICS),l=/describes-music-and-sound/gi.test(g.attrs.CHARACTERISTICS);if(r&&l)return"captions"}return"subtitles"},o.onManifestLoaded=function(g,i){var r=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach(function(l){var c=/(?:CC|SERVICE)([1-4])/.exec(l.instreamId);if(!!c){var t="textTrack"+c[1],a=r.captionsProperties[t];!a||(a.label=l.name,l.lang&&(a.languageCode=l.lang),a.media=l)}})},o.onFragLoading=function(g,i){var r=this.cea608Parser1,l=this.cea608Parser2,c=this.lastSn,t=this.lastPartIndex;if(!(!this.enabled||!(r&&l))&&i.frag.type===T.PlaylistLevelType.MAIN){var a,u,s=i.frag.sn,f=(a=i==null||(u=i.part)===null||u===void 0?void 0:u.index)!=null?a:-1;s===c+1||s===c&&f===t+1||(r.reset(),l.reset()),this.lastSn=s,this.lastPartIndex=f}},o.onFragLoaded=function(g,i){var r=i.frag,l=i.payload,c=this.initPTS,t=this.unparsedVttFrags;if(r.type===T.PlaylistLevelType.SUBTITLE)if(l.byteLength){if(!Object(P.isFiniteNumber)(c[r.cc])){t.push(i),c.length&&this.hls.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")});return}var a=r.decryptdata,u="stats"in i;if(a==null||a.key==null||a.method!=="AES-128"||u){var s=this.tracks[r.level],f=this.vttCCs;f[r.cc]||(f[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),s&&s.textCodec===_.IMSC1_CODEC?this._parseIMSC1(r,l):this._parseVTTs(r,l,f)}}else this.hls.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(g,i){var r=this,l=this.hls;Object(_.parseIMSC1)(i,this.initPTS[g.cc],this.timescale[g.cc],function(c){r._appendCues(c,g.level),l.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:g})},function(c){D.logger.log("Failed to parse IMSC1: "+c),l.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:c})})},o._parseVTTs=function(g,i,r){var l,c=this,t=this.hls,a=(l=g.initSegment)!==null&&l!==void 0&&l.data?Object(y.appendUint8Array)(g.initSegment.data,new Uint8Array(i)):i;Object(R.parseWebVTT)(a,this.initPTS[g.cc],this.timescale[g.cc],r,g.cc,g.start,function(u){c._appendCues(u,g.level),t.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:g})},function(u){c._fallbackToIMSC1(g,i),D.logger.log("Failed to parse VTT cue: "+u),t.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:u})})},o._fallbackToIMSC1=function(g,i){var r=this,l=this.tracks[g.level];l.textCodec||Object(_.parseIMSC1)(i,this.initPTS[g.cc],this.timescale[g.cc],function(){l.textCodec=_.IMSC1_CODEC,r._parseIMSC1(g,i)},function(){l.textCodec="wvtt"})},o._appendCues=function(g,i){var r=this.hls;if(this.config.renderTextTracksNatively){var l=this.textTracks[i];if(!l||l.mode==="disabled")return;g.forEach(function(a){return Object(O.addCueToTrack)(l,a)})}else{var c=this.tracks[i];if(!c)return;var t=c.default?"default":"subtitles"+i;r.trigger(L.Events.CUES_PARSED,{type:"subtitles",cues:g,track:t})}},o.onFragDecrypted=function(g,i){var r=i.frag;if(r.type===T.PlaylistLevelType.SUBTITLE){if(!Object(P.isFiniteNumber)(this.initPTS[r.cc])){this.unparsedVttFrags.push(i);return}this.onFragLoaded(L.Events.FRAG_LOADED,i)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(g,i){var r=this.cea608Parser1,l=this.cea608Parser2;if(!(!this.enabled||!(r&&l)))for(var c=0;c<i.samples.length;c++){var t=i.samples[c].bytes;if(t){var a=this.extractCea608Data(t);r.addData(i.samples[c].pts,a[0]),l.addData(i.samples[c].pts,a[1])}}},o.onBufferFlushing=function(g,i){var r=i.startOffset,l=i.endOffset,c=i.endOffsetSubtitles,t=i.type,a=this.media;if(!(!a||a.currentTime<l)){if(!t||t==="video"){var u=this.captionsTracks;Object.keys(u).forEach(function(f){return Object(O.removeCuesInRange)(u[f],r,l)})}if(this.config.renderTextTracksNatively&&r===0&&c!==void 0){var s=this.textTracks;Object.keys(s).forEach(function(f){return Object(O.removeCuesInRange)(s[f],r,c)})}}},o.extractCea608Data=function(g){for(var i=[[],[]],r=g[0]&31,l=2,c=0;c<r;c++){var t=g[l++],a=127&g[l++],u=127&g[l++];if(!(a===0&&u===0)){var s=(4&t)!==0;if(s){var f=3&t;(f===0||f===1)&&(i[f].push(a),i[f].push(u))}}}return i},e}();function m(e,o){return e&&e.label===o.name&&!(e.textTrack1||e.textTrack2)}function p(e,o,h,g){return Math.min(o,g)-Math.max(e,h)}function d(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return P});var P=function(){function L(M,R){this.subtle=void 0,this.aesIV=void 0,this.subtle=M,this.aesIV=R}var A=L.prototype;return A.decrypt=function(R,O){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},O,R)},L}()},"./src/crypt/aes-decryptor.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"removePadding",function(){return L}),n.d(b,"default",function(){return A});var P=n("./src/utils/typed-array.ts");function L(M){var R=M.byteLength,O=R&&new DataView(M.buffer).getUint8(R-1);return O?Object(P.sliceUint8)(M,0,R-O):M}var A=function(){function M(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var R=M.prototype;return R.uint8ArrayToUint32Array_=function(_){for(var y=new DataView(_),T=new Uint32Array(4),D=0;D<4;D++)T[D]=y.getUint32(D*4);return T},R.initTable=function(){var _=this.sBox,y=this.invSBox,T=this.subMix,D=T[0],E=T[1],m=T[2],p=T[3],d=this.invSubMix,e=d[0],o=d[1],h=d[2],g=d[3],i=new Uint32Array(256),r=0,l=0,c=0;for(c=0;c<256;c++)c<128?i[c]=c<<1:i[c]=c<<1^283;for(c=0;c<256;c++){var t=l^l<<1^l<<2^l<<3^l<<4;t=t>>>8^t&255^99,_[r]=t,y[t]=r;var a=i[r],u=i[a],s=i[u],f=i[t]*257^t*16843008;D[r]=f<<24|f>>>8,E[r]=f<<16|f>>>16,m[r]=f<<8|f>>>24,p[r]=f,f=s*16843009^u*65537^a*257^r*16843008,e[t]=f<<24|f>>>8,o[t]=f<<16|f>>>16,h[t]=f<<8|f>>>24,g[t]=f,r?(r=a^i[i[i[s^a]]],l^=i[i[l]]):r=l=1}},R.expandKey=function(_){for(var y=this.uint8ArrayToUint32Array_(_),T=!0,D=0;D<y.length&&T;)T=y[D]===this.key[D],D++;if(!T){this.key=y;var E=this.keySize=y.length;if(E!==4&&E!==6&&E!==8)throw new Error("Invalid aes key size="+E);var m=this.ksRows=(E+6+1)*4,p,d,e=this.keySchedule=new Uint32Array(m),o=this.invKeySchedule=new Uint32Array(m),h=this.sBox,g=this.rcon,i=this.invSubMix,r=i[0],l=i[1],c=i[2],t=i[3],a,u;for(p=0;p<m;p++){if(p<E){a=e[p]=y[p];continue}u=a,p%E===0?(u=u<<8|u>>>24,u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[u&255],u^=g[p/E|0]<<24):E>6&&p%E===4&&(u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[u&255]),e[p]=a=(e[p-E]^u)>>>0}for(d=0;d<m;d++)p=m-d,d&3?u=e[p]:u=e[p-4],d<4||p<=4?o[d]=u:o[d]=r[h[u>>>24]]^l[h[u>>>16&255]]^c[h[u>>>8&255]]^t[h[u&255]],o[d]=o[d]>>>0}},R.networkToHostOrderSwap=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},R.decrypt=function(_,y,T){for(var D=this.keySize+6,E=this.invKeySchedule,m=this.invSBox,p=this.invSubMix,d=p[0],e=p[1],o=p[2],h=p[3],g=this.uint8ArrayToUint32Array_(T),i=g[0],r=g[1],l=g[2],c=g[3],t=new Int32Array(_),a=new Int32Array(t.length),u,s,f,v,S,x,I,B,k,U,W,G,X,Y,J=this.networkToHostOrderSwap;y<t.length;){for(k=J(t[y]),U=J(t[y+1]),W=J(t[y+2]),G=J(t[y+3]),S=k^E[0],x=G^E[1],I=W^E[2],B=U^E[3],X=4,Y=1;Y<D;Y++)u=d[S>>>24]^e[x>>16&255]^o[I>>8&255]^h[B&255]^E[X],s=d[x>>>24]^e[I>>16&255]^o[B>>8&255]^h[S&255]^E[X+1],f=d[I>>>24]^e[B>>16&255]^o[S>>8&255]^h[x&255]^E[X+2],v=d[B>>>24]^e[S>>16&255]^o[x>>8&255]^h[I&255]^E[X+3],S=u,x=s,I=f,B=v,X=X+4;u=m[S>>>24]<<24^m[x>>16&255]<<16^m[I>>8&255]<<8^m[B&255]^E[X],s=m[x>>>24]<<24^m[I>>16&255]<<16^m[B>>8&255]<<8^m[S&255]^E[X+1],f=m[I>>>24]<<24^m[B>>16&255]<<16^m[S>>8&255]<<8^m[x&255]^E[X+2],v=m[B>>>24]<<24^m[S>>16&255]<<16^m[x>>8&255]<<8^m[I&255]^E[X+3],a[y]=J(u^i),a[y+1]=J(v^r),a[y+2]=J(f^l),a[y+3]=J(s^c),i=k,r=U,l=W,c=G,y=y+4}return a.buffer},M}()},"./src/crypt/decrypter.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return y});var P=n("./src/crypt/aes-crypto.ts"),L=n("./src/crypt/fast-aes-key.ts"),A=n("./src/crypt/aes-decryptor.ts"),M=n("./src/utils/logger.ts"),R=n("./src/utils/mp4-tools.ts"),O=n("./src/utils/typed-array.ts"),_=16,y=function(){function T(E,m,p){var d=p===void 0?{}:p,e=d.removePKCS7Padding,o=e===void 0?!0:e;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=E,this.config=m,this.removePKCS7Padding=o,o)try{var h=self.crypto;h&&(this.subtle=h.subtle||h.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var D=T.prototype;return D.destroy=function(){this.observer=null},D.isSync=function(){return this.config.enableSoftwareAES},D.flush=function(){var m=this.currentResult;if(!m){this.reset();return}var p=new Uint8Array(m);return this.reset(),this.removePKCS7Padding?Object(A.removePadding)(p):p},D.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},D.decrypt=function(m,p,d,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(m),p,d);var o=this.flush();o&&e(o.buffer)}else this.webCryptoDecrypt(new Uint8Array(m),p,d).then(e)},D.softwareDecrypt=function(m,p,d){var e=this.currentIV,o=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(m=Object(R.appendUint8Array)(h,m),this.remainderData=null);var g=this.getValidChunk(m);if(!g.length)return null;e&&(d=e);var i=this.softwareDecrypter;i||(i=this.softwareDecrypter=new A.default),i.expandKey(p);var r=o;return this.currentResult=i.decrypt(g.buffer,0,d),this.currentIV=Object(O.sliceUint8)(g,-16).buffer,r||null},D.webCryptoDecrypt=function(m,p,d){var e=this,o=this.subtle;return(this.key!==p||!this.fastAesKey)&&(this.key=p,this.fastAesKey=new L.default(o,p)),this.fastAesKey.expandKey().then(function(h){if(!o)return Promise.reject(new Error("web crypto not initialized"));var g=new P.default(o,d);return g.decrypt(m.buffer,h)}).catch(function(h){return e.onWebCryptoError(h,m,p,d)})},D.onWebCryptoError=function(m,p,d,e){return M.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",m),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(p,d,e)},D.getValidChunk=function(m){var p=m,d=m.length-m.length%_;return d!==m.length&&(p=Object(O.sliceUint8)(m,0,d),this.remainderData=Object(O.sliceUint8)(m,d)),p},D.logOnce=function(m){!this.logEnabled||(M.logger.log("[decrypter.ts]: "+m),this.logEnabled=!1)},T}()},"./src/crypt/fast-aes-key.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return P});var P=function(){function L(M,R){this.subtle=void 0,this.key=void 0,this.subtle=M,this.key=R}var A=L.prototype;return A.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},L}()},"./src/demux/aacdemuxer.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/demux/base-audio-demuxer.ts"),L=n("./src/demux/adts.ts"),A=n("./src/utils/logger.ts"),M=n("./src/demux/id3.ts");function R(y,T){y.prototype=Object.create(T.prototype),y.prototype.constructor=y,O(y,T)}function O(y,T){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,m){return E.__proto__=m,E},O(y,T)}var _=function(y){R(T,y);function T(E,m){var p;return p=y.call(this)||this,p.observer=void 0,p.config=void 0,p.observer=E,p.config=m,p}var D=T.prototype;return D.resetInitSegment=function(m,p,d,e){y.prototype.resetInitSegment.call(this,m,p,d,e),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:p,duration:e,inputTimeScale:9e4,dropped:0}},T.probe=function(m){if(!m)return!1;for(var p=M.getID3Data(m,0)||[],d=p.length,e=m.length;d<e;d++)if(L.probe(m,d))return A.logger.log("ADTS sync word found !"),!0;return!1},D.canParse=function(m,p){return L.canParse(m,p)},D.appendFrame=function(m,p,d){L.initTrackConfig(m,this.observer,p,d,m.manifestCodec);var e=L.appendFrame(m,p,d,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},T}(P.default);b.default=_},"./src/demux/adts.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"getAudioConfig",function(){return M}),n.d(b,"isHeaderPattern",function(){return R}),n.d(b,"getHeaderLength",function(){return O}),n.d(b,"getFullFrameLength",function(){return _}),n.d(b,"canGetFrameLength",function(){return y}),n.d(b,"isHeader",function(){return T}),n.d(b,"canParse",function(){return D}),n.d(b,"probe",function(){return E}),n.d(b,"initTrackConfig",function(){return m}),n.d(b,"getFrameDuration",function(){return p}),n.d(b,"parseFrameHeader",function(){return d}),n.d(b,"appendFrame",function(){return e});var P=n("./src/utils/logger.ts"),L=n("./src/errors.ts"),A=n("./src/events.ts");function M(o,h,g,i){var r,l,c,t,a=navigator.userAgent.toLowerCase(),u=i,s=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=((h[g+2]&192)>>>6)+1;var f=(h[g+2]&60)>>>2;if(f>s.length-1){o.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+f});return}return c=(h[g+2]&1)<<2,c|=(h[g+3]&192)>>>6,P.logger.log("manifest codec:"+i+", ADTS type:"+r+", samplingIndex:"+f),/firefox/i.test(a)?f>=6?(r=5,t=new Array(4),l=f-3):(r=2,t=new Array(2),l=f):a.indexOf("android")!==-1?(r=2,t=new Array(2),l=f):(r=5,t=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&f>=6?l=f-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(f>=6&&c===1||/vivaldi/i.test(a))||!i&&c===1)&&(r=2,t=new Array(2)),l=f)),t[0]=r<<3,t[0]|=(f&14)>>1,t[1]|=(f&1)<<7,t[1]|=c<<3,r===5&&(t[1]|=(l&14)>>1,t[2]=(l&1)<<7,t[2]|=2<<2,t[3]=0),{config:t,samplerate:s[f],channelCount:c,codec:"mp4a.40."+r,manifestCodec:u}}function R(o,h){return o[h]===255&&(o[h+1]&246)===240}function O(o,h){return o[h+1]&1?7:9}function _(o,h){return(o[h+3]&3)<<11|o[h+4]<<3|(o[h+5]&224)>>>5}function y(o,h){return h+5<o.length}function T(o,h){return h+1<o.length&&R(o,h)}function D(o,h){return y(o,h)&&R(o,h)&&_(o,h)<=o.length-h}function E(o,h){if(T(o,h)){var g=O(o,h);if(h+g>=o.length)return!1;var i=_(o,h);if(i<=g)return!1;var r=h+i;return r===o.length||T(o,r)}return!1}function m(o,h,g,i,r){if(!o.samplerate){var l=M(h,g,i,r);if(!l)return;o.config=l.config,o.samplerate=l.samplerate,o.channelCount=l.channelCount,o.codec=l.codec,o.manifestCodec=l.manifestCodec,P.logger.log("parsed codec:"+o.codec+", rate:"+l.samplerate+", channels:"+l.channelCount)}}function p(o){return 1024*9e4/o}function d(o,h){var g=O(o,h);if(h+g<=o.length){var i=_(o,h)-g;if(i>0)return{headerLength:g,frameLength:i}}}function e(o,h,g,i,r){var l=p(o.samplerate),c=i+r*l,t=d(h,g),a;if(t){var u=t.frameLength,s=t.headerLength,f=s+u,v=Math.max(0,g+f-h.length);v?(a=new Uint8Array(f-s),a.set(h.subarray(g+s,h.length),0)):a=h.subarray(g+s,g+f);var S={unit:a,pts:c};return v||o.samples.push(S),{sample:S,length:f,missing:v}}var x=h.length-g;a=new Uint8Array(x),a.set(h.subarray(g,h.length),0);var I={unit:a,pts:c};return{sample:I,length:x,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"initPTSFn",function(){return y});var P=n("./src/polyfills/number.ts"),L=n("./src/demux/id3.ts"),A=n("./src/types/demuxer.ts"),M=n("./src/demux/dummy-demuxed-track.ts"),R=n("./src/utils/mp4-tools.ts"),O=n("./src/utils/typed-array.ts"),_=function(){function T(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var D=T.prototype;return D.resetInitSegment=function(m,p,d,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},D.resetTimeStamp=function(m){this.initPTS=m,this.resetContiguity()},D.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},D.canParse=function(m,p){return!1},D.appendFrame=function(m,p,d){},D.demux=function(m,p){this.cachedData&&(m=Object(R.appendUint8Array)(this.cachedData,m),this.cachedData=null);var d=L.getID3Data(m,0),e=d?d.length:0,o,h,g=this._audioTrack,i=this._id3Track,r=d?L.getTimeStamp(d):void 0,l=m.length;for((this.basePTS===null||this.frameIndex===0&&Object(P.isFiniteNumber)(r))&&(this.basePTS=y(r,p,this.initPTS)),d&&d.length>0&&i.samples.push({pts:this.basePTS,dts:this.basePTS,data:d,type:A.MetadataSchema.audioId3}),h=this.basePTS;e<l;){if(this.canParse(m,e)){var c=this.appendFrame(g,m,e);c?(this.frameIndex++,h=c.sample.pts,e+=c.length,o=e):e=l}else L.canParse(m,e)?(d=L.getID3Data(m,e),i.samples.push({pts:h,dts:h,data:d,type:A.MetadataSchema.audioId3}),e+=d.length,o=e):e++;if(e===l&&o!==l){var t=Object(O.sliceUint8)(m,o);this.cachedData?this.cachedData=Object(R.appendUint8Array)(this.cachedData,t):this.cachedData=t}}return{audioTrack:g,videoTrack:Object(M.dummyTrack)(),id3Track:i,textTrack:Object(M.dummyTrack)()}},D.demuxSampleAes=function(m,p,d){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},D.flush=function(m){var p=this.cachedData;return p&&(this.cachedData=null,this.demux(p,0)),{audioTrack:this._audioTrack,videoTrack:Object(M.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(M.dummyTrack)()}},D.destroy=function(){},T}(),y=function(D,E,m){return Object(P.isFiniteNumber)(D)?D*90:E*9e4+(m||0)};b.default=_},"./src/demux/chunk-cache.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return P});var P=function(){function A(){this.chunks=[],this.dataLength=0}var M=A.prototype;return M.push=function(O){this.chunks.push(O),this.dataLength+=O.length},M.flush=function(){var O=this.chunks,_=this.dataLength,y;if(O.length)O.length===1?y=O[0]:y=L(O,_);else return new Uint8Array(0);return this.reset(),y},M.reset=function(){this.chunks.length=0,this.dataLength=0},A}();function L(A,M){for(var R=new Uint8Array(M),O=0,_=0;_<A.length;_++){var y=A[_];R.set(y,O),O+=y.length}return R}},"./src/demux/dummy-demuxed-track.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"dummyTrack",function(){return P});function P(L,A){return L===void 0&&(L=""),A===void 0&&(A=9e4),{type:L,id:-1,pid:-1,inputTimeScale:A,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/utils/logger.ts"),L=function(){function A(R){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=R,this.bytesAvailable=R.byteLength,this.word=0,this.bitsAvailable=0}var M=A.prototype;return M.loadWord=function(){var O=this.data,_=this.bytesAvailable,y=O.byteLength-_,T=new Uint8Array(4),D=Math.min(4,_);if(D===0)throw new Error("no bytes available");T.set(O.subarray(y,y+D)),this.word=new DataView(T.buffer).getUint32(0),this.bitsAvailable=D*8,this.bytesAvailable-=D},M.skipBits=function(O){var _;this.bitsAvailable>O?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,_=O>>3,O-=_>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},M.readBits=function(O){var _=Math.min(this.bitsAvailable,O),y=this.word>>>32-_;return O>32&&P.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=_,this.bitsAvailable>0?this.word<<=_:this.bytesAvailable>0&&this.loadWord(),_=O-_,_>0&&this.bitsAvailable?y<<_|this.readBits(_):y},M.skipLZ=function(){var O;for(O=0;O<this.bitsAvailable;++O)if((this.word&2147483648>>>O)!==0)return this.word<<=O,this.bitsAvailable-=O,O;return this.loadWord(),O+this.skipLZ()},M.skipUEG=function(){this.skipBits(1+this.skipLZ())},M.skipEG=function(){this.skipBits(1+this.skipLZ())},M.readUEG=function(){var O=this.skipLZ();return this.readBits(O+1)-1},M.readEG=function(){var O=this.readUEG();return 1&O?1+O>>>1:-1*(O>>>1)},M.readBoolean=function(){return this.readBits(1)===1},M.readUByte=function(){return this.readBits(8)},M.readUShort=function(){return this.readBits(16)},M.readUInt=function(){return this.readBits(32)},M.skipScalingList=function(O){for(var _=8,y=8,T,D=0;D<O;D++)y!==0&&(T=this.readEG(),y=(_+T+256)%256),_=y===0?_:y},M.readSPS=function(){var O=0,_=0,y=0,T=0,D,E,m,p=this.readUByte.bind(this),d=this.readBits.bind(this),e=this.readUEG.bind(this),o=this.readBoolean.bind(this),h=this.skipBits.bind(this),g=this.skipEG.bind(this),i=this.skipUEG.bind(this),r=this.skipScalingList.bind(this);p();var l=p();if(d(5),h(3),p(),i(),l===100||l===110||l===122||l===244||l===44||l===83||l===86||l===118||l===128){var c=e();if(c===3&&h(1),i(),i(),h(1),o())for(E=c!==3?8:12,m=0;m<E;m++)o()&&(m<6?r(16):r(64))}i();var t=e();if(t===0)e();else if(t===1)for(h(1),g(),g(),D=e(),m=0;m<D;m++)g();i(),h(1);var a=e(),u=e(),s=d(1);s===0&&h(1),h(1),o()&&(O=e(),_=e(),y=e(),T=e());var f=[1,1];if(o()&&o()){var v=p();switch(v){case 1:f=[1,1];break;case 2:f=[12,11];break;case 3:f=[10,11];break;case 4:f=[16,11];break;case 5:f=[40,33];break;case 6:f=[24,11];break;case 7:f=[20,11];break;case 8:f=[32,11];break;case 9:f=[80,33];break;case 10:f=[18,11];break;case 11:f=[15,11];break;case 12:f=[64,33];break;case 13:f=[160,99];break;case 14:f=[4,3];break;case 15:f=[3,2];break;case 16:f=[2,1];break;case 255:{f=[p()<<8|p(),p()<<8|p()];break}}}return{width:Math.ceil((a+1)*16-O*2-_*2),height:(2-s)*(u+1)*16-(s?2:4)*(y+T),pixelRatio:f}},M.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},A}();b.default=L},"./src/demux/id3.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"isHeader",function(){return P}),n.d(b,"isFooter",function(){return L}),n.d(b,"getID3Data",function(){return A}),n.d(b,"canParse",function(){return R}),n.d(b,"getTimeStamp",function(){return O}),n.d(b,"isTimeStampFrame",function(){return _}),n.d(b,"getID3Frames",function(){return T}),n.d(b,"decodeFrame",function(){return D}),n.d(b,"utf8ArrayToStr",function(){return e}),n.d(b,"testables",function(){return o});var P=function(r,l){return l+10<=r.length&&r[l]===73&&r[l+1]===68&&r[l+2]===51&&r[l+3]<255&&r[l+4]<255&&r[l+6]<128&&r[l+7]<128&&r[l+8]<128&&r[l+9]<128},L=function(r,l){return l+10<=r.length&&r[l]===51&&r[l+1]===68&&r[l+2]===73&&r[l+3]<255&&r[l+4]<255&&r[l+6]<128&&r[l+7]<128&&r[l+8]<128&&r[l+9]<128},A=function(r,l){for(var c=l,t=0;P(r,l);){t+=10;var a=M(r,l+6);t+=a,L(r,l+10)&&(t+=10),l+=t}if(t>0)return r.subarray(c,c+t)},M=function(r,l){var c=0;return c=(r[l]&127)<<21,c|=(r[l+1]&127)<<14,c|=(r[l+2]&127)<<7,c|=r[l+3]&127,c},R=function(r,l){return P(r,l)&&M(r,l+6)+10<=r.length-l},O=function(r){for(var l=T(r),c=0;c<l.length;c++){var t=l[c];if(_(t))return d(t)}},_=function(r){return r&&r.key==="PRIV"&&r.info==="com.apple.streaming.transportStreamTimestamp"},y=function(r){var l=String.fromCharCode(r[0],r[1],r[2],r[3]),c=M(r,4),t=10;return{type:l,size:c,data:r.subarray(t,t+c)}},T=function(r){for(var l=0,c=[];P(r,l);){var t=M(r,l+6);l+=10;for(var a=l+t;l+8<a;){var u=y(r.subarray(l)),s=D(u);s&&c.push(s),l+=u.size+10}L(r,l)&&(l+=10)}return c},D=function(r){return r.type==="PRIV"?E(r):r.type[0]==="W"?p(r):m(r)},E=function(r){if(!(r.size<2)){var l=e(r.data,!0),c=new Uint8Array(r.data.subarray(l.length+1));return{key:r.type,info:l,data:c.buffer}}},m=function(r){if(!(r.size<2)){if(r.type==="TXXX"){var l=1,c=e(r.data.subarray(l),!0);l+=c.length+1;var t=e(r.data.subarray(l));return{key:r.type,info:c,data:t}}var a=e(r.data.subarray(1));return{key:r.type,data:a}}},p=function(r){if(r.type==="WXXX"){if(r.size<2)return;var l=1,c=e(r.data.subarray(l),!0);l+=c.length+1;var t=e(r.data.subarray(l));return{key:r.type,info:c,data:t}}var a=e(r.data);return{key:r.type,data:a}},d=function(r){if(r.data.byteLength===8){var l=new Uint8Array(r.data),c=l[3]&1,t=(l[4]<<23)+(l[5]<<15)+(l[6]<<7)+l[7];return t/=45,c&&(t+=4772185884e-2),Math.round(t)}},e=function(r,l){l===void 0&&(l=!1);var c=g();if(c){var t=c.decode(r);if(l){var a=t.indexOf("\0");return a!==-1?t.substring(0,a):t}return t.replace(/\0/g,"")}for(var u=r.length,s,f,v,S="",x=0;x<u;){if(s=r[x++],s===0&&l)return S;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:S+=String.fromCharCode(s);break;case 12:case 13:f=r[x++],S+=String.fromCharCode((s&31)<<6|f&63);break;case 14:f=r[x++],v=r[x++],S+=String.fromCharCode((s&15)<<12|(f&63)<<6|(v&63)<<0);break;default:}}return S},o={decodeTextFrame:m},h;function g(){return!h&&typeof self.TextDecoder!="undefined"&&(h=new self.TextDecoder("utf-8")),h}},"./src/demux/mp3demuxer.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/demux/base-audio-demuxer.ts"),L=n("./src/demux/id3.ts"),A=n("./src/utils/logger.ts"),M=n("./src/demux/mpegaudio.ts");function R(y,T){y.prototype=Object.create(T.prototype),y.prototype.constructor=y,O(y,T)}function O(y,T){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,m){return E.__proto__=m,E},O(y,T)}var _=function(y){R(T,y);function T(){return y.apply(this,arguments)||this}var D=T.prototype;return D.resetInitSegment=function(m,p,d,e){y.prototype.resetInitSegment.call(this,m,p,d,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:p,duration:e,inputTimeScale:9e4,dropped:0}},T.probe=function(m){if(!m)return!1;for(var p=L.getID3Data(m,0)||[],d=p.length,e=m.length;d<e;d++)if(M.probe(m,d))return A.logger.log("MPEG Audio sync word found !"),!0;return!1},D.canParse=function(m,p){return M.canParse(m,p)},D.appendFrame=function(m,p,d){if(this.basePTS!==null)return M.appendFrame(m,p,d,this.basePTS,this.frameIndex)},T}(P.default);b.default=_},"./src/demux/mp4demuxer.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/polyfills/number.ts"),L=n("./src/types/demuxer.ts"),A=n("./src/utils/mp4-tools.ts"),M=n("./src/demux/dummy-demuxed-track.ts"),R=/\/emsg[-/]ID3/i,O=function(){function _(T,D){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=D}var y=_.prototype;return y.resetTimeStamp=function(){},y.resetInitSegment=function(D,E,m,p){var d=Object(A.parseInitSegment)(D),e=this.videoTrack=Object(M.dummyTrack)("video",1),o=this.audioTrack=Object(M.dummyTrack)("audio",1),h=this.txtTrack=Object(M.dummyTrack)("text",1);if(this.id3Track=Object(M.dummyTrack)("id3",1),this.timeOffset=0,d.video){var g=d.video,i=g.id,r=g.timescale,l=g.codec;e.id=i,e.timescale=h.timescale=r,e.codec=l}if(d.audio){var c=d.audio,t=c.id,a=c.timescale,u=c.codec;o.id=t,o.timescale=a,o.codec=u}h.id=A.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=o.duration=p},y.resetContiguity=function(){},_.probe=function(D){return D=D.length>16384?D.subarray(0,16384):D,Object(A.findBox)(D,["moof"]).length>0},y.demux=function(D,E){this.timeOffset=E;var m=D,p=this.videoTrack,d=this.txtTrack;if(this.config.progressive){this.remainderData&&(m=Object(A.appendUint8Array)(this.remainderData,D));var e=Object(A.segmentValidRange)(m);this.remainderData=e.remainder,p.samples=e.valid||new Uint8Array}else p.samples=m;var o=this.extractID3Track(p,E);return d.samples=Object(A.parseSamples)(E,p),{videoTrack:p,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}},y.flush=function(){var D=this.timeOffset,E=this.videoTrack,m=this.txtTrack;E.samples=this.remainderData||new Uint8Array,this.remainderData=null;var p=this.extractID3Track(E,this.timeOffset);return m.samples=Object(A.parseSamples)(D,E),{videoTrack:E,audioTrack:Object(M.dummyTrack)(),id3Track:p,textTrack:Object(M.dummyTrack)()}},y.extractID3Track=function(D,E){var m=this.id3Track;if(D.samples.length){var p=Object(A.findBox)(D.samples,["emsg"]);p&&p.forEach(function(d){var e=Object(A.parseEmsg)(d);if(R.test(e.schemeIdUri)){var o=Object(P.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:E+e.presentationTimeDelta/e.timeScale,h=e.payload;m.samples.push({data:h,len:h.byteLength,dts:o,pts:o,type:L.MetadataSchema.emsg})}})}return m},y.demuxSampleAes=function(D,E,m){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},y.destroy=function(){},_}();b.default=O},"./src/demux/mpegaudio.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"appendFrame",function(){return O}),n.d(b,"parseHeader",function(){return _}),n.d(b,"isHeaderPattern",function(){return y}),n.d(b,"isHeader",function(){return T}),n.d(b,"canParse",function(){return D}),n.d(b,"probe",function(){return E});var P=null,L=[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],A=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],M=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],R=[0,1,1,4];function O(m,p,d,e,o){if(!(d+24>p.length)){var h=_(p,d);if(h&&d+h.frameLength<=p.length){var g=h.samplesPerFrame*9e4/h.sampleRate,i=e+o*g,r={unit:p.subarray(d,d+h.frameLength),pts:i,dts:i};return m.config=[],m.channelCount=h.channelCount,m.samplerate=h.sampleRate,m.samples.push(r),{sample:r,length:h.frameLength,missing:0}}}}function _(m,p){var d=m[p+1]>>3&3,e=m[p+1]>>1&3,o=m[p+2]>>4&15,h=m[p+2]>>2&3;if(d!==1&&o!==0&&o!==15&&h!==3){var g=m[p+2]>>1&1,i=m[p+3]>>6,r=d===3?3-e:e===3?3:4,l=L[r*14+o-1]*1e3,c=d===3?0:d===2?1:2,t=A[c*3+h],a=i===3?1:2,u=M[d][e],s=R[e],f=u*8*s,v=Math.floor(u*l/t+g)*s;if(P===null){var S=navigator.userAgent||"",x=S.match(/Chrome\/(\d+)/i);P=x?parseInt(x[1]):0}var I=!!P&&P<=87;return I&&e===2&&l>=224e3&&i===0&&(m[p+3]=m[p+3]|128),{sampleRate:t,channelCount:a,frameLength:v,samplesPerFrame:f}}}function y(m,p){return m[p]===255&&(m[p+1]&224)===224&&(m[p+1]&6)!==0}function T(m,p){return p+1<m.length&&y(m,p)}function D(m,p){var d=4;return y(m,p)&&d<=m.length-p}function E(m,p){if(p+1<m.length&&y(m,p)){var d=4,e=_(m,p),o=d;e!=null&&e.frameLength&&(o=e.frameLength);var h=p+o;return h===m.length||T(m,h)}return!1}},"./src/demux/sample-aes.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/crypt/decrypter.ts"),L=n("./src/demux/tsdemuxer.ts"),A=function(){function M(O,_,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new P.default(O,_,{removePKCS7Padding:!1})}var R=M.prototype;return R.decryptBuffer=function(_,y){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,y)},R.decryptAacSample=function(_,y,T,D){var E=_[y].unit;if(!(E.length<=16)){var m=E.subarray(16,E.length-E.length%16),p=m.buffer.slice(m.byteOffset,m.byteOffset+m.length),d=this;this.decryptBuffer(p,function(e){var o=new Uint8Array(e);E.set(o,16),D||d.decryptAacSamples(_,y+1,T)})}},R.decryptAacSamples=function(_,y,T){for(;;y++){if(y>=_.length){T();return}if(!(_[y].unit.length<32)){var D=this.decrypter.isSync();if(this.decryptAacSample(_,y,T,D),!D)return}}},R.getAvcEncryptedData=function(_){for(var y=Math.floor((_.length-48)/160)*16+16,T=new Int8Array(y),D=0,E=32;E<_.length-16;E+=160,D+=16)T.set(_.subarray(E,E+16),D);return T},R.getAvcDecryptedUnit=function(_,y){for(var T=new Uint8Array(y),D=0,E=32;E<_.length-16;E+=160,D+=16)_.set(T.subarray(D,D+16),E);return _},R.decryptAvcSample=function(_,y,T,D,E,m){var p=Object(L.discardEPB)(E.data),d=this.getAvcEncryptedData(p),e=this;this.decryptBuffer(d.buffer,function(o){E.data=e.getAvcDecryptedUnit(p,o),m||e.decryptAvcSamples(_,y,T+1,D)})},R.decryptAvcSamples=function(_,y,T,D){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,T=0){if(y>=_.length){D();return}for(var E=_[y].units;!(T>=E.length);T++){var m=E[T];if(!(m.data.length<=48||m.type!==1&&m.type!==5)){var p=this.decrypter.isSync();if(this.decryptAvcSample(_,y,T,D,m,p),!p)return}}}},M}();b.default=A},"./src/demux/transmuxer-interface.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return E});var P=n("./node_modules/webworkify-webpack/index.js"),L=n.n(P),A=n("./src/events.ts"),M=n("./src/demux/transmuxer.ts"),R=n("./src/utils/logger.ts"),O=n("./src/errors.ts"),_=n("./src/utils/mediasource-helper.ts"),y=n("./node_modules/eventemitter3/index.js"),T=n.n(y),D=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},E=function(){function m(d,e,o,h){var g=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=d,this.id=e,this.onTransmuxComplete=o,this.onFlush=h;var i=d.config,r=function(u,s){s=s||{},s.frag=g.frag,s.id=g.id,d.trigger(u,s)};this.observer=new y.EventEmitter,this.observer.on(A.Events.FRAG_DECRYPTED,r),this.observer.on(A.Events.ERROR,r);var l={mp4:D.isTypeSupported("video/mp4"),mpeg:D.isTypeSupported("audio/mpeg"),mp3:D.isTypeSupported('audio/mp4; codecs="mp3"')},c=navigator.vendor;if(i.enableWorker&&typeof Worker!="undefined"){R.logger.log("demuxing in webworker");var t;try{t=this.worker=P("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),t.addEventListener("message",this.onwmsg),t.onerror=function(a){d.trigger(A.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(a.message+" ("+a.filename+":"+a.lineno+")")})},t.postMessage({cmd:"init",typeSupported:l,vendor:c,id:e,config:JSON.stringify(i)})}catch(a){R.logger.warn("Error in worker:",a),R.logger.error("Error while initializing DemuxerWorker, fallback to inline"),t&&self.URL.revokeObjectURL(t.objectURL),this.transmuxer=new M.default(this.observer,l,i,c,e),this.worker=null}}else this.transmuxer=new M.default(this.observer,l,i,c,e)}var p=m.prototype;return p.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var o=this.transmuxer;o&&(o.destroy(),this.transmuxer=null)}var h=this.observer;h&&h.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},p.push=function(e,o,h,g,i,r,l,c,t,a){var u,s,f=this;t.transmuxing.start=self.performance.now();var v=this.transmuxer,S=this.worker,x=r?r.start:i.start,I=i.decryptdata,B=this.frag,k=!(B&&i.cc===B.cc),U=!(B&&t.level===B.level),W=B?t.sn-B.sn:-1,G=this.part?t.part-this.part.index:-1,X=W===0&&t.id>1&&t.id===(B==null?void 0:B.stats.chunkCount),Y=!U&&(W===1||W===0&&(G===1||X&&G<=0)),J=self.performance.now();(U||W||i.stats.parsing.start===0)&&(i.stats.parsing.start=J),r&&(G||!Y)&&(r.stats.parsing.start=J);var ee=!(B&&((u=i.initSegment)===null||u===void 0?void 0:u.url)===((s=B.initSegment)===null||s===void 0?void 0:s.url)),z=new M.TransmuxState(k,Y,c,U,x,ee);if(!Y||k||ee){R.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+t.sn+" p: "+t.part+" level: "+t.level+" id: "+t.id+`
12
+ Time to underbuffer: `+P.toFixed(3)+" s"),o.nextLoadLevel=k,this.bwEstimator.sample(c,r.loaded),this.clearTimer(),f.loader&&(this.fragCurrent=this.partCurrent=null,f.loader.abort()),o.trigger(D.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:f,part:e,stats:r})}}}}}},m.onFragLoaded=function(f,e){var o=e.frag,h=e.part;if(o.type===O.PlaylistLevelType.MAIN&&Object(I.isFiniteNumber)(o.sn)){var g=h?h.stats:o.stats,i=h?h.duration:o.duration;if(this.clearTimer(),this.lastLoadedFragLevel=o.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var r=this.hls.levels[o.level],l=(r.loaded?r.loaded.bytes:0)+g.loaded,c=(r.loaded?r.loaded.duration:0)+i;r.loaded={bytes:l,duration:c},r.realBitrate=Math.round(8*l/c)}if(o.bitrateTest){var t={stats:g,frag:o,part:h,id:o.type};this.onFragBuffered(D.Events.FRAG_BUFFERED,t)}}},m.onFragBuffered=function(f,e){var o=e.frag,h=e.part,g=h?h.stats:o.stats;if(!g.aborted&&!(o.type!==O.PlaylistLevelType.MAIN||o.sn==="initSegment")){var i=g.parsing.end-g.loading.start;this.bwEstimator.sample(i,g.loaded),g.bwEstimate=this.bwEstimator.getEstimate(),o.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},m.onError=function(f,e){switch(e.details){case R.ErrorDetails.FRAG_LOAD_ERROR:case R.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},m.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},m.getNextABRAutoLevel=function(){var f=this.fragCurrent,e=this.partCurrent,o=this.hls,h=o.maxAutoLevel,g=o.config,i=o.minAutoLevel,r=o.media,l=e?e.duration:f?f.duration:0,c=r?r.currentTime:0,t=r&&r.playbackRate!==0?Math.abs(r.playbackRate):1,a=this.bwEstimator?this.bwEstimator.getEstimate():g.abrEwmaDefaultEstimate,u=(M.BufferHelper.bufferInfo(r,c,g.maxBufferHole).end-c)/t,s=this.findBestLevel(a,i,h,u,g.abrBandWidthFactor,g.abrBandWidthUpFactor);if(s>=0)return s;_.logger.trace((u?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var d=l?Math.min(l,g.maxStarvationDelay):g.maxStarvationDelay,v=g.abrBandWidthFactor,S=g.abrBandWidthUpFactor;if(!u){var x=this.bitrateTestDelay;if(x){var P=l?Math.min(l,g.maxLoadingDelay):g.maxLoadingDelay;d=P-x,_.logger.trace("bitrate test took "+Math.round(1e3*x)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*d)+" ms"),v=S=1}}return s=this.findBestLevel(a,i,h,u+d,v,S),Math.max(s,0)},m.findBestLevel=function(f,e,o,h,g,i){for(var r,l=this.fragCurrent,c=this.partCurrent,t=this.lastLoadedFragLevel,a=this.hls.levels,u=a[t],s=!!(u!=null&&(r=u.details)!==null&&r!==void 0&&r.live),d=u==null?void 0:u.codecSet,v=c?c.duration:l?l.duration:0,S=o;S>=e;S--){var x=a[S];if(!(!x||d&&x.codecSet!==d)){var P=x.details,B=(c?P==null?void 0:P.partTarget:P==null?void 0:P.averagetargetduration)||v,k=void 0;S<=t?k=g*f:k=i*f;var U=a[S].maxBitrate,W=U*B/k;if(_.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+S+"/"+Math.round(k)+"/"+U+"/"+B+"/"+h+"/"+W),k>U&&(!W||s&&!this.bitrateTestDelay||W<h))return S}}return-1},T(E,[{key:"nextAutoLevel",get:function(){var f=this._nextAutoLevel,e=this.bwEstimator;if(f!==-1&&!e.canEstimate())return f;var o=this.getNextABRAutoLevel();return f!==-1&&this.hls.levels[o].loadError?f:(f!==-1&&(o=Math.min(f,o)),o)},set:function(f){this._nextAutoLevel=f}}]),E}();b.default=A},"./src/controller/audio-stream-controller.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/polyfills/number.ts"),L=n("./src/controller/base-stream-controller.ts"),D=n("./src/events.ts"),M=n("./src/utils/buffer-helper.ts"),R=n("./src/controller/fragment-tracker.ts"),O=n("./src/types/level.ts"),_=n("./src/types/loader.ts"),y=n("./src/loader/fragment.ts"),T=n("./src/demux/chunk-cache.ts"),A=n("./src/demux/transmuxer-interface.ts"),E=n("./src/types/transmuxer.ts"),m=n("./src/controller/fragment-finders.ts"),p=n("./src/utils/discontinuities.ts"),f=n("./src/errors.ts");function e(){return e=Object.assign?Object.assign.bind():function(r){for(var l=1;l<arguments.length;l++){var c=arguments[l];for(var t in c)Object.prototype.hasOwnProperty.call(c,t)&&(r[t]=c[t])}return r},e.apply(this,arguments)}function o(r,l){r.prototype=Object.create(l.prototype),r.prototype.constructor=r,h(r,l)}function h(r,l){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,a){return t.__proto__=a,t},h(r,l)}var g=100,i=function(r){o(l,r);function l(t,a){var u;return u=r.call(this,t,a,"[audio-stream-controller]")||this,u.videoBuffer=null,u.videoTrackCC=-1,u.waitingVideoCC=-1,u.audioSwitch=!1,u.trackId=-1,u.waitingData=null,u.mainDetails=null,u.bufferFlushed=!1,u.cachedTrackLoadedData=null,u._registerListeners(),u}var c=l.prototype;return c.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},c._registerListeners=function(){var a=this.hls;a.on(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.on(D.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),a.on(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),a.on(D.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.on(D.Events.ERROR,this.onError,this),a.on(D.Events.BUFFER_RESET,this.onBufferReset,this),a.on(D.Events.BUFFER_CREATED,this.onBufferCreated,this),a.on(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),a.on(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),a.on(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var a=this.hls;a.off(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.off(D.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),a.off(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),a.off(D.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.off(D.Events.ERROR,this.onError,this),a.off(D.Events.BUFFER_RESET,this.onBufferReset,this),a.off(D.Events.BUFFER_CREATED,this.onBufferCreated,this),a.off(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),a.off(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),a.off(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onInitPtsFound=function(a,u){var s=u.frag,d=u.id,v=u.initPTS;if(d==="main"){var S=s.cc;this.initPTS[s.cc]=v,this.log("InitPTS for cc: "+S+" found from main: "+v),this.videoTrackCC=S,this.state===L.State.WAITING_INIT_PTS&&this.tick()}},c.startLoad=function(a){if(!this.levels){this.startPosition=a,this.state=L.State.STOPPED;return}var u=this.lastCurrentTime;this.stopLoad(),this.setInterval(g),this.fragLoadError=0,u>0&&a===-1?(this.log("Override startPosition with lastCurrentTime @"+u.toFixed(3)),a=u,this.state=L.State.IDLE):(this.loadedmetadata=!1,this.state=L.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=a,this.tick()},c.doTick=function(){switch(this.state){case L.State.IDLE:this.doTickIdle();break;case L.State.WAITING_TRACK:{var a,u=this.levels,s=this.trackId,d=u==null||(a=u[s])===null||a===void 0?void 0:a.details;if(d){if(this.waitForCdnTuneIn(d))break;this.state=L.State.WAITING_INIT_PTS}break}case L.State.FRAG_LOADING_WAITING_RETRY:{var v,S=performance.now(),x=this.retryDate;(!x||S>=x||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=L.State.IDLE);break}case L.State.WAITING_INIT_PTS:{var P=this.waitingData;if(P){var B=P.frag,k=P.part,U=P.cache,W=P.complete;if(this.initPTS[B.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=L.State.FRAG_LOADING;var G=U.flush(),z={frag:B,part:k,payload:G,networkDetails:null};this._handleFragmentLoadProgress(z),W&&r.prototype._handleFragmentLoadComplete.call(this,z)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+B.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var Y=this.getLoadPosition(),J=M.BufferHelper.bufferInfo(this.mediaBuffer,Y,this.config.maxBufferHole),ee=Object(m.fragmentWithinToleranceTest)(J.end,this.config.maxFragLookUpTolerance,B);ee<0&&(this.log("Waiting fragment cc ("+B.cc+") @ "+B.start+" cancelled because another fragment at "+J.end+" is needed"),this.clearWaitingFragment())}}else this.state=L.State.IDLE}}this.onTickEnd()},c.clearWaitingFragment=function(){var a=this.waitingData;a&&(this.fragmentTracker.removeFragment(a.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=L.State.IDLE)},c.resetLoadingState=function(){this.clearWaitingFragment(),r.prototype.resetLoadingState.call(this)},c.onTickEnd=function(){var a=this.media;if(!(!a||!a.readyState)){var u=this.mediaBuffer?this.mediaBuffer:a,s=u.buffered;!this.loadedmetadata&&s.length&&(this.loadedmetadata=!0),this.lastCurrentTime=a.currentTime}},c.doTickIdle=function(){var a,u,s=this.hls,d=this.levels,v=this.media,S=this.trackId,x=s.config;if(!(!d||!d[S])&&!(!v&&(this.startFragRequested||!x.startFragPrefetch))){var P=d[S],B=P.details;if(!B||B.live&&this.levelLastLoaded!==S||this.waitForCdnTuneIn(B)){this.state=L.State.WAITING_TRACK;return}var k=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&k&&(this.bufferFlushed=!1,this.afterBufferFlushed(k,y.ElementaryStreamTypes.AUDIO,_.PlaylistLevelType.AUDIO));var U=this.getFwdBufferInfo(k,_.PlaylistLevelType.AUDIO);if(U!==null){var W=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_.PlaylistLevelType.MAIN),G=U.len,z=this.getMaxBufferLength(W==null?void 0:W.len),Y=this.audioSwitch;if(!(G>=z&&!Y)){if(!Y&&this._streamEnded(U,B)){s.trigger(D.Events.BUFFER_EOS,{type:"audio"}),this.state=L.State.ENDED;return}var J=B.fragments,ee=J[0].start,X=U.end;if(Y&&v){var q=this.getLoadPosition();X=q,B.PTSKnown&&q<ee&&(U.end>ee||U.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),v.currentTime=ee+.05)}if(!(W&&X>W.end+B.targetduration)&&!((!W||!W.len)&&U.len)){var ie=this.getNextFragment(X,B);if(!ie){this.bufferFlushed=!0;return}((a=ie.decryptdata)===null||a===void 0?void 0:a.keyFormat)==="identity"&&!((u=ie.decryptdata)!==null&&u!==void 0&&u.key)?this.loadKey(ie,B):this.loadFragment(ie,B,X)}}}}},c.getMaxBufferLength=function(a){var u=r.prototype.getMaxBufferLength.call(this);return a?Math.max(u,a):u},c.onMediaDetaching=function(){this.videoBuffer=null,r.prototype.onMediaDetaching.call(this)},c.onAudioTracksUpdated=function(a,u){var s=u.audioTracks;this.resetTransmuxer(),this.levels=s.map(function(d){return new O.Level(d)})},c.onAudioTrackSwitching=function(a,u){var s=!!u.url;this.trackId=u.id;var d=this.fragCurrent;d!=null&&d.loader&&d.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),s?this.setInterval(g):this.resetTransmuxer(),s?(this.audioSwitch=!0,this.state=L.State.IDLE):this.state=L.State.STOPPED,this.tick()},c.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},c.onLevelLoaded=function(a,u){this.mainDetails=u.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(D.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},c.onAudioTrackLoaded=function(a,u){var s;if(this.mainDetails==null){this.cachedTrackLoadedData=u;return}var d=this.levels,v=u.details,S=u.id;if(!d){this.warn("Audio tracks were reset while loading level "+S);return}this.log("Track "+S+" loaded ["+v.startSN+","+v.endSN+"],duration:"+v.totalduration);var x=d[S],P=0;if(v.live||(s=x.details)!==null&&s!==void 0&&s.live){var B=this.mainDetails;if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed||!B)return;!x.details&&v.hasProgramDateTime&&B.hasProgramDateTime?(Object(p.alignMediaPlaylistByPDT)(v,B),P=v.fragments[0].start):P=this.alignPlaylists(v,x.details)}x.details=v,this.levelLastLoaded=S,!this.startFragRequested&&(this.mainDetails||!v.live)&&this.setStartPosition(x.details,P),this.state===L.State.WAITING_TRACK&&!this.waitForCdnTuneIn(v)&&(this.state=L.State.IDLE),this.tick()},c._handleFragmentLoadProgress=function(a){var u,s=a.frag,d=a.part,v=a.payload,S=this.config,x=this.trackId,P=this.levels;if(!P){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+s.sn+" of level "+s.level+" will not be buffered");return}var B=P[x];console.assert(B,"Audio track is defined on fragment load progress");var k=B.details;console.assert(k,"Audio track details are defined on fragment load progress");var U=S.defaultAudioCodec||B.audioCodec||"mp4a.40.2",W=this.transmuxer;W||(W=this.transmuxer=new A.default(this.hls,_.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var G=this.initPTS[s.cc],z=(u=s.initSegment)===null||u===void 0?void 0:u.data;if(G!==void 0){var Y=!1,J=d?d.index:-1,ee=J!==-1,X=new E.ChunkMetadata(s.level,s.sn,s.stats.chunkCount,v.byteLength,J,ee);W.push(v,z,U,"",s,d,k.totalduration,Y,X,G)}else{this.log("Unknown video PTS for cc "+s.cc+", waiting for video PTS before demuxing audio frag "+s.sn+" of ["+k.startSN+" ,"+k.endSN+"],track "+x);var q=this.waitingData=this.waitingData||{frag:s,part:d,cache:new T.default,complete:!1},ie=q.cache;ie.push(new Uint8Array(v)),this.waitingVideoCC=this.videoTrackCC,this.state=L.State.WAITING_INIT_PTS}},c._handleFragmentLoadComplete=function(a){if(this.waitingData){this.waitingData.complete=!0;return}r.prototype._handleFragmentLoadComplete.call(this,a)},c.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},c.onBufferCreated=function(a,u){var s=u.tracks.audio;s&&(this.mediaBuffer=s.buffer||null),u.tracks.video&&(this.videoBuffer=u.tracks.video.buffer||null)},c.onFragBuffered=function(a,u){var s=u.frag,d=u.part;if(s.type===_.PlaylistLevelType.AUDIO){if(this.fragContextChanged(s)){this.warn("Fragment "+s.sn+(d?" p: "+d.index:"")+" of level "+s.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}s.sn!=="initSegment"&&(this.fragPrevious=s,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(s,d)}},c.onError=function(a,u){switch(u.details){case f.ErrorDetails.FRAG_LOAD_ERROR:case f.ErrorDetails.FRAG_LOAD_TIMEOUT:case f.ErrorDetails.KEY_LOAD_ERROR:case f.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.AUDIO,u);break;case f.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case f.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==L.State.ERROR&&this.state!==L.State.STOPPED&&(this.state=u.fatal?L.State.ERROR:L.State.IDLE,this.warn(u.details+" while loading frag, switching to "+this.state+" state"));break;case f.ErrorDetails.BUFFER_FULL_ERROR:if(u.parent==="audio"&&(this.state===L.State.PARSING||this.state===L.State.PARSED)){var s=!0,d=this.getFwdBufferInfo(this.mediaBuffer,_.PlaylistLevelType.AUDIO);d&&d.len>.5&&(s=!this.reduceMaxBufferLength(d.len)),s&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},c.onBufferFlushed=function(a,u){var s=u.type;s===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},c._handleTransmuxComplete=function(a){var u,s="audio",d=this.hls,v=a.remuxResult,S=a.chunkMeta,x=this.getCurrentContext(S);if(!x){this.warn("The loading context changed while buffering fragment "+S.sn+" of level "+S.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(S.level);return}var P=x.frag,B=x.part,k=x.level.details,U=v.audio,W=v.text,G=v.id3,z=v.initSegment;if(!(this.fragContextChanged(P)||!k)){if(this.state=L.State.PARSING,this.audioSwitch&&U&&this.completeAudioSwitch(),z!=null&&z.tracks&&(this._bufferInitSegment(z.tracks,P,S),d.trigger(D.Events.FRAG_PARSING_INIT_SEGMENT,{frag:P,id:s,tracks:z.tracks})),U){var Y=U.startPTS,J=U.endPTS,ee=U.startDTS,X=U.endDTS;B&&(B.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:Y,endPTS:J,startDTS:ee,endDTS:X}),P.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,Y,J,ee,X),this.bufferFragmentData(U,P,B,S)}if(G!=null&&(u=G.samples)!==null&&u!==void 0&&u.length){var q=e({id:s,frag:P,details:k},G);d.trigger(D.Events.FRAG_PARSING_METADATA,q)}if(W){var ie=e({id:s,frag:P,details:k},W);d.trigger(D.Events.FRAG_PARSING_USERDATA,ie)}}},c._bufferInitSegment=function(a,u,s){if(this.state===L.State.PARSING){a.video&&delete a.video;var d=a.audio;if(!!d){d.levelCodec=d.codec,d.id="audio",this.log("Init audio buffer, container:"+d.container+", codecs[parsed]=["+d.codec+"]"),this.hls.trigger(D.Events.BUFFER_CODECS,a);var v=d.initSegment;if(v!=null&&v.byteLength){var S={type:"audio",frag:u,part:null,chunkMeta:s,parent:u.type,data:v};this.hls.trigger(D.Events.BUFFER_APPENDING,S)}this.tick()}}},c.loadFragment=function(a,u,s){var d=this.fragmentTracker.getState(a);this.fragCurrent=a,(this.audioSwitch||d===R.FragmentState.NOT_LOADED||d===R.FragmentState.PARTIAL)&&(a.sn==="initSegment"?this._loadInitSegment(a):u.live&&!Object(I.isFiniteNumber)(this.initPTS[a.cc])?(this.log("Waiting for video PTS in continuity counter "+a.cc+" of live stream before loading audio fragment "+a.sn+" of level "+this.trackId),this.state=L.State.WAITING_INIT_PTS):(this.startFragRequested=!0,r.prototype.loadFragment.call(this,a,u,s)))},c.completeAudioSwitch=function(){var a=this.hls,u=this.media,s=this.trackId;u&&(this.log("Switching audio track : flushing all audio"),r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,a.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:s})},l}(L.default);b.default=i},"./src/controller/audio-track-controller.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/events.ts"),L=n("./src/errors.ts"),D=n("./src/controller/base-playlist-controller.ts"),M=n("./src/types/loader.ts");function R(A,E){for(var m=0;m<E.length;m++){var p=E[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(A,p.key,p)}}function O(A,E,m){return E&&R(A.prototype,E),m&&R(A,m),Object.defineProperty(A,"prototype",{writable:!1}),A}function _(A,E){A.prototype=Object.create(E.prototype),A.prototype.constructor=A,y(A,E)}function y(A,E){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,f){return p.__proto__=f,p},y(A,E)}var T=function(A){_(E,A);function E(p){var f;return f=A.call(this,p,"[audio-track-controller]")||this,f.tracks=[],f.groupId=null,f.tracksInGroup=[],f.trackId=-1,f.trackName="",f.selectDefaultTrack=!0,f.registerListeners(),f}var m=E.prototype;return m.registerListeners=function(){var f=this.hls;f.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.on(I.Events.LEVEL_LOADING,this.onLevelLoading,this),f.on(I.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),f.on(I.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),f.on(I.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){var f=this.hls;f.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.off(I.Events.LEVEL_LOADING,this.onLevelLoading,this),f.off(I.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),f.off(I.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),f.off(I.Events.ERROR,this.onError,this)},m.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,A.prototype.destroy.call(this)},m.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},m.onManifestParsed=function(f,e){this.tracks=e.audioTracks||[]},m.onAudioTrackLoaded=function(f,e){var o=e.id,h=e.details,g=this.tracksInGroup[o];if(!g){this.warn("Invalid audio track id "+o);return}var i=g.details;g.details=e.details,this.log("audioTrack "+o+" loaded ["+h.startSN+"-"+h.endSN+"]"),o===this.trackId&&(this.retryCount=0,this.playlistLoaded(o,e,i))},m.onLevelLoading=function(f,e){this.switchLevel(e.level)},m.onLevelSwitching=function(f,e){this.switchLevel(e.level)},m.switchLevel=function(f){var e=this.hls.levels[f];if(!!(e!=null&&e.audioGroupIds)){var o=e.audioGroupIds[e.urlId];if(this.groupId!==o){this.groupId=o;var h=this.tracks.filter(function(i){return!o||i.groupId===o});this.selectDefaultTrack&&!h.some(function(i){return i.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=h;var g={audioTracks:h};this.log("Updating audio tracks, "+h.length+' track(s) found in "'+o+'" group-id'),this.hls.trigger(I.Events.AUDIO_TRACKS_UPDATED,g),this.selectInitialTrack()}}},m.onError=function(f,e){A.prototype.onError.call(this,f,e),!(e.fatal||!e.context)&&e.context.type===M.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},m.setAudioTrack=function(f){var e=this.tracksInGroup;if(f<0||f>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var o=e[this.trackId];this.log("Now switching to audio-track index "+f);var h=e[f],g=h.id,i=h.groupId,r=i===void 0?"":i,l=h.name,c=h.type,t=h.url;if(this.trackId=f,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(I.Events.AUDIO_TRACK_SWITCHING,{id:g,groupId:r,name:l,type:c,url:t}),!(h.details&&!h.details.live)){var a=this.switchParams(h.url,o==null?void 0:o.details);this.loadPlaylist(a)}},m.selectInitialTrack=function(){var f=this.tracksInGroup;console.assert(f.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,o=this.findTrackId(e)||this.findTrackId();o!==-1?this.setAudioTrack(o):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},m.findTrackId=function(f){for(var e=this.tracksInGroup,o=0;o<e.length;o++){var h=e[o];if((!this.selectDefaultTrack||h.default)&&(!f||f===h.name))return h.id}return-1},m.loadPlaylist=function(f){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var o=e.id,h=e.groupId,g=e.url;if(f)try{g=f.addDirectives(g)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("loading audio-track playlist for id: "+o),this.clearTimer(),this.hls.trigger(I.Events.AUDIO_TRACK_LOADING,{url:g,id:o,groupId:h,deliveryDirectives:f||null})}},O(E,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(f){this.selectDefaultTrack=!1,this.setAudioTrack(f)}}]),E}(D.default);b.default=T},"./src/controller/base-playlist-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return O});var I=n("./src/polyfills/number.ts"),L=n("./src/types/level.ts"),D=n("./src/controller/level-helper.ts"),M=n("./src/utils/logger.ts"),R=n("./src/errors.ts"),O=function(){function _(T,A){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=M.logger.log.bind(M.logger,A+":"),this.warn=M.logger.warn.bind(M.logger,A+":"),this.hls=T}var y=_.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(A,E){E.fatal&&E.type===R.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},y.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},y.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},y.stopLoad=function(){this.canLoad=!1,this.clearTimer()},y.switchParams=function(A,E){var m=E==null?void 0:E.renditionReports;if(m)for(var p=0;p<m.length;p++){var f=m[p],e=""+f.URI;if(e===A.slice(-e.length)){var o=parseInt(f["LAST-MSN"]),h=parseInt(f["LAST-PART"]);if(E&&this.hls.config.lowLatencyMode){var g=Math.min(E.age-E.partTarget,E.targetduration);h!==void 0&&g>E.partTarget&&(h+=1)}if(Object(I.isFiniteNumber)(o))return new L.HlsUrlParameters(o,Object(I.isFiniteNumber)(h)?h:void 0,L.HlsSkip.No)}}},y.loadPlaylist=function(A){},y.shouldLoadTrack=function(A){return this.canLoad&&A&&!!A.url&&(!A.details||A.details.live)},y.playlistLoaded=function(A,E,m){var p=this,f=E.details,e=E.stats,o=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(f.advancedDateTime=Date.now()-o,f.live||m!=null&&m.live){if(f.reloaded(m),m&&this.log("live playlist "+A+" "+(f.advanced?"REFRESHED "+f.lastPartSn+"-"+f.lastPartIndex:"MISSED")),m&&f.fragments.length>0&&Object(D.mergeDetails)(m,f),!this.canLoad||!f.live)return;var h,g=void 0,i=void 0;if(f.canBlockReload&&f.endSN&&f.advanced){var r=this.hls.config.lowLatencyMode,l=f.lastPartSn,c=f.endSN,t=f.lastPartIndex,a=t!==-1,u=l===c,s=r?0:t;a?(g=u?c+1:l,i=u?s:t+1):g=c+1;var d=f.age,v=d+f.ageHeader,S=Math.min(v-f.partTarget,f.targetduration*1.5);if(S>0){if(m&&S>m.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+m.tuneInGoal+" to: "+S+" with playlist age: "+f.age),S=0;else{var x=Math.floor(S/f.targetduration);if(g+=x,i!==void 0){var P=Math.round(S%f.targetduration/f.partTarget);i+=P}this.log("CDN Tune-in age: "+f.ageHeader+"s last advanced "+d.toFixed(2)+"s goal: "+S+" skip sn "+x+" to part "+i)}f.tuneInGoal=S}if(h=this.getDeliveryDirectives(f,E.deliveryDirectives,g,i),r||!u){this.loadPlaylist(h);return}}else h=this.getDeliveryDirectives(f,E.deliveryDirectives,g,i);var B=Object(D.computeReloadInterval)(f,e);g!==void 0&&f.canBlockReload&&(B-=f.partTarget||1),this.log("reload live playlist "+A+" in "+Math.round(B)+" ms"),this.timer=self.setTimeout(function(){return p.loadPlaylist(h)},B)}else this.clearTimer()},y.getDeliveryDirectives=function(A,E,m,p){var f=Object(L.getSkipValue)(A,m);return E!=null&&E.skip&&A.deltaUpdateFailed&&(m=E.msn,p=E.part,f=L.HlsSkip.No),new L.HlsUrlParameters(m,p,f)},y.retryLoadingOrFail=function(A){var E=this,m=this.hls.config,p=this.retryCount<m.levelLoadingMaxRetry;if(p){var f;if(this.retryCount++,A.details.indexOf("LoadTimeOut")>-1&&(f=A.context)!==null&&f!==void 0&&f.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+A.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*m.levelLoadingRetryDelay,m.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return E.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+A.details+'"')}}else this.warn('cannot recover from error "'+A.details+'"'),this.clearTimer(),A.fatal=!0;return p},_}()},"./src/controller/base-stream-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"State",function(){return c}),n.d(b,"default",function(){return t});var I=n("./src/polyfills/number.ts"),L=n("./src/task-loop.ts"),D=n("./src/controller/fragment-tracker.ts"),M=n("./src/utils/buffer-helper.ts"),R=n("./src/utils/logger.ts"),O=n("./src/events.ts"),_=n("./src/errors.ts"),y=n("./src/types/transmuxer.ts"),T=n("./src/utils/mp4-tools.ts"),A=n("./src/utils/discontinuities.ts"),E=n("./src/controller/fragment-finders.ts"),m=n("./src/controller/level-helper.ts"),p=n("./src/loader/fragment-loader.ts"),f=n("./src/crypt/decrypter.ts"),e=n("./src/utils/time-ranges.ts"),o=n("./src/types/loader.ts");function h(a,u){for(var s=0;s<u.length;s++){var d=u[s];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}function g(a,u,s){return u&&h(a.prototype,u),s&&h(a,s),Object.defineProperty(a,"prototype",{writable:!1}),a}function i(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function r(a,u){a.prototype=Object.create(u.prototype),a.prototype.constructor=a,l(a,u)}function l(a,u){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(d,v){return d.__proto__=v,d},l(a,u)}var c={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},t=function(a){r(u,a);function u(d,v,S){var x;return x=a.call(this)||this,x.hls=void 0,x.fragPrevious=null,x.fragCurrent=null,x.fragmentTracker=void 0,x.transmuxer=null,x._state=c.STOPPED,x.media=null,x.mediaBuffer=null,x.config=void 0,x.bitrateTest=!1,x.lastCurrentTime=0,x.nextLoadPosition=0,x.startPosition=0,x.loadedmetadata=!1,x.fragLoadError=0,x.retryDate=0,x.levels=null,x.fragmentLoader=void 0,x.levelLastLoaded=null,x.startFragRequested=!1,x.decrypter=void 0,x.initPTS=[],x.onvseeking=null,x.onvended=null,x.logPrefix="",x.log=void 0,x.warn=void 0,x.logPrefix=S,x.log=R.logger.log.bind(R.logger,S+":"),x.warn=R.logger.warn.bind(R.logger,S+":"),x.hls=d,x.fragmentLoader=new p.default(d.config),x.fragmentTracker=v,x.config=d.config,x.decrypter=new f.default(d,d.config),d.on(O.Events.KEY_LOADED,x.onKeyLoaded,i(x)),d.on(O.Events.LEVEL_SWITCHING,x.onLevelSwitching,i(x)),x}var s=u.prototype;return s.doTick=function(){this.onTickEnd()},s.onTickEnd=function(){},s.startLoad=function(v){},s.stopLoad=function(){this.fragmentLoader.abort();var v=this.fragCurrent;v&&this.fragmentTracker.removeFragment(v),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=c.STOPPED},s._streamEnded=function(v,S){var x=this.fragCurrent,P=this.fragmentTracker;if(!S.live&&x&&this.media&&x.sn>=S.endSN&&!v.nextStart){var B=S.partList;if(B!=null&&B.length){var k=B[B.length-1],U=M.BufferHelper.isBuffered(this.media,k.start+k.duration/2);return U}var W=P.getState(x);return W===D.FragmentState.PARTIAL||W===D.FragmentState.OK}return!1},s.onMediaAttached=function(v,S){var x=this.media=this.mediaBuffer=S.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),x.addEventListener("seeking",this.onvseeking),x.addEventListener("ended",this.onvended);var P=this.config;this.levels&&P.autoStartLoad&&this.state===c.STOPPED&&this.startLoad(P.startPosition)},s.onMediaDetaching=function(){var v=this.media;v!=null&&v.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),v&&this.onvseeking&&this.onvended&&(v.removeEventListener("seeking",this.onvseeking),v.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},s.onMediaSeeking=function(){var v=this.config,S=this.fragCurrent,x=this.media,P=this.mediaBuffer,B=this.state,k=x?x.currentTime:0,U=M.BufferHelper.bufferInfo(P||x,k,v.maxBufferHole);if(this.log("media seeking to "+(Object(I.isFiniteNumber)(k)?k.toFixed(3):k)+", state: "+B),B===c.ENDED)this.resetLoadingState();else if(S&&!U.len){var W=v.maxFragLookUpTolerance,G=S.start-W,z=S.start+S.duration+W,Y=k>z;(k<G||Y)&&(Y&&S.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),S.loader.abort()),this.resetLoadingState())}x&&(this.lastCurrentTime=k),!this.loadedmetadata&&!U.len&&(this.nextLoadPosition=this.startPosition=k),this.tickImmediate()},s.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},s.onKeyLoaded=function(v,S){if(!(this.state!==c.KEY_LOADING||S.frag!==this.fragCurrent||!this.levels)){this.state=c.IDLE;var x=this.levels[S.frag.level].details;x&&this.loadFragment(S.frag,x,S.frag.start)}},s.onLevelSwitching=function(v,S){this.fragLoadError=0},s.onHandlerDestroying=function(){this.stopLoad(),a.prototype.onHandlerDestroying.call(this)},s.onHandlerDestroyed=function(){this.state=c.STOPPED,this.hls.off(O.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(O.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,a.prototype.onHandlerDestroyed.call(this)},s.loadKey=function(v,S){this.log("Loading key for "+v.sn+" of ["+S.startSN+"-"+S.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level),this.state=c.KEY_LOADING,this.fragCurrent=v,this.hls.trigger(O.Events.KEY_LOADING,{frag:v})},s.loadFragment=function(v,S,x){this._loadFragForPlayback(v,S,x)},s._loadFragForPlayback=function(v,S,x){var P=this,B=function(U){if(P.fragContextChanged(v)){P.warn("Fragment "+v.sn+(U.part?" p: "+U.part.index:"")+" of level "+v.level+" was dropped during download."),P.fragmentTracker.removeFragment(v);return}v.stats.chunkCount++,P._handleFragmentLoadProgress(U)};this._doFragLoad(v,S,x,B).then(function(k){if(!!k){P.fragLoadError=0;var U=P.state;if(P.fragContextChanged(v)){(U===c.FRAG_LOADING||!P.fragCurrent&&U===c.PARSING)&&(P.fragmentTracker.removeFragment(v),P.state=c.IDLE);return}"payload"in k&&(P.log("Loaded fragment "+v.sn+" of level "+v.level),P.hls.trigger(O.Events.FRAG_LOADED,k)),P._handleFragmentLoadComplete(k)}}).catch(function(k){P.state===c.STOPPED||P.state===c.ERROR||(P.warn(k),P.resetFragmentLoading(v))})},s.flushMainBuffer=function(v,S,x){if(x===void 0&&(x=null),!!(v-S)){var P={startOffset:v,endOffset:S,type:x};this.fragLoadError=0,this.hls.trigger(O.Events.BUFFER_FLUSHING,P)}},s._loadInitSegment=function(v){var S=this;this._doFragLoad(v).then(function(x){if(!x||S.fragContextChanged(v)||!S.levels)throw new Error("init load aborted");return x}).then(function(x){var P=S.hls,B=x.payload,k=v.decryptdata;if(B&&B.byteLength>0&&k&&k.key&&k.iv&&k.method==="AES-128"){var U=self.performance.now();return S.decrypter.webCryptoDecrypt(new Uint8Array(B),k.key.buffer,k.iv.buffer).then(function(W){var G=self.performance.now();return P.trigger(O.Events.FRAG_DECRYPTED,{frag:v,payload:W,stats:{tstart:U,tdecrypt:G}}),x.payload=W,x})}return x}).then(function(x){var P=S.fragCurrent,B=S.hls,k=S.levels;if(!k)throw new Error("init load aborted, missing levels");var U=k[v.level].details;console.assert(U,"Level details are defined when init segment is loaded");var W=v.stats;S.state=c.IDLE,S.fragLoadError=0,v.data=new Uint8Array(x.payload),W.parsing.start=W.buffering.start=self.performance.now(),W.parsing.end=W.buffering.end=self.performance.now(),x.frag===P&&B.trigger(O.Events.FRAG_BUFFERED,{stats:W,frag:P,part:null,id:v.type}),S.tick()}).catch(function(x){S.state===c.STOPPED||S.state===c.ERROR||(S.warn(x),S.resetFragmentLoading(v))})},s.fragContextChanged=function(v){var S=this.fragCurrent;return!v||!S||v.level!==S.level||v.sn!==S.sn||v.urlId!==S.urlId},s.fragBufferedComplete=function(v,S){var x=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+v.type+" sn: "+v.sn+(S?" part: "+S.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level+" "+(x?e.default.toString(M.BufferHelper.getBuffered(x)):"(detached)")),this.state=c.IDLE,x&&(!this.loadedmetadata&&x.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},s.seekToStartPos=function(){},s._handleFragmentLoadComplete=function(v){var S=this.transmuxer;if(!!S){var x=v.frag,P=v.part,B=v.partsLoaded,k=!B||B.length===0||B.some(function(W){return!W}),U=new y.ChunkMetadata(x.level,x.sn,x.stats.chunkCount+1,0,P?P.index:-1,!k);S.flush(U)}},s._handleFragmentLoadProgress=function(v){},s._doFragLoad=function(v,S,x,P){var B=this;if(x===void 0&&(x=null),!this.levels)throw new Error("frag load aborted, missing levels");if(x=Math.max(v.start,x||0),this.config.lowLatencyMode&&S){var k=S.partList;if(k&&P){x>v.end&&S.fragmentHint&&(v=S.fragmentHint);var U=this.getNextPart(k,v,x);if(U>-1){var W=k[U];return this.log("Loading part sn: "+v.sn+" p: "+W.index+" cc: "+v.cc+" of playlist ["+S.startSN+"-"+S.endSN+"] parts [0-"+U+"-"+(k.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(x.toFixed(3))),this.nextLoadPosition=W.start+W.duration,this.state=c.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:v,part:k[U],targetBufferTime:x}),this.doFragPartsLoad(v,k,U,P).catch(function(G){return B.handleFragLoadError(G)})}else if(!v.url||this.loadedEndOfParts(k,x))return Promise.resolve(null)}}return this.log("Loading fragment "+v.sn+" cc: "+v.cc+" "+(S?"of ["+S.startSN+"-"+S.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(x.toFixed(3))),Object(I.isFiniteNumber)(v.sn)&&!this.bitrateTest&&(this.nextLoadPosition=v.start+v.duration),this.state=c.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:v,targetBufferTime:x}),this.fragmentLoader.load(v,P).catch(function(G){return B.handleFragLoadError(G)})},s.doFragPartsLoad=function(v,S,x,P){var B=this;return new Promise(function(k,U){var W=[],G=function z(Y){var J=S[Y];B.fragmentLoader.loadPart(v,J,P).then(function(ee){W[J.index]=ee;var X=ee.part;B.hls.trigger(O.Events.FRAG_LOADED,ee);var q=S[Y+1];if(q&&q.fragment===v)z(Y+1);else return k({frag:v,part:X,partsLoaded:W})}).catch(U)};G(x)})},s.handleFragLoadError=function(v){var S=v.data;return S&&S.details===_.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(S.frag,S.part):this.hls.trigger(O.Events.ERROR,S),null},s._handleTransmuxerFlush=function(v){var S=this.getCurrentContext(v);if(!S||this.state!==c.PARSING){this.fragCurrent||(this.state=c.IDLE);return}var x=S.frag,P=S.part,B=S.level,k=self.performance.now();x.stats.parsing.end=k,P&&(P.stats.parsing.end=k),this.updateLevelTiming(x,P,B,v.partial)},s.getCurrentContext=function(v){var S=this.levels,x=v.level,P=v.sn,B=v.part;if(!S||!S[x])return this.warn("Levels object was unset while buffering fragment "+P+" of level "+x+". The current chunk will not be buffered."),null;var k=S[x],U=B>-1?Object(m.getPartWith)(k,P,B):null,W=U?U.fragment:Object(m.getFragmentWithSN)(k,P,this.fragCurrent);return W?{frag:W,part:U,level:k}:null},s.bufferFragmentData=function(v,S,x,P){if(!(!v||this.state!==c.PARSING)){var B=v.data1,k=v.data2,U=B;if(B&&k&&(U=Object(T.appendUint8Array)(B,k)),!(!U||!U.length)){var W={type:v.type,frag:S,part:x,chunkMeta:P,parent:S.type,data:U};this.hls.trigger(O.Events.BUFFER_APPENDING,W),v.dropped&&v.independent&&!x&&this.flushBufferGap(S)}}},s.flushBufferGap=function(v){var S=this.media;if(!!S){if(!M.BufferHelper.isBuffered(S,S.currentTime)){this.flushMainBuffer(0,v.start);return}var x=S.currentTime,P=M.BufferHelper.bufferInfo(S,x,0),B=v.duration,k=Math.min(this.config.maxFragLookUpTolerance*2,B*.25),U=Math.max(Math.min(v.start-k,P.end-k),x+k);v.start-U>k&&this.flushMainBuffer(U,v.start)}},s.getFwdBufferInfo=function(v,S){var x=this.config,P=this.getLoadPosition();if(!Object(I.isFiniteNumber)(P))return null;var B=M.BufferHelper.bufferInfo(v,P,x.maxBufferHole);if(B.len===0&&B.nextStart!==void 0){var k=this.fragmentTracker.getBufferedFrag(P,S);if(k&&B.nextStart<k.end)return M.BufferHelper.bufferInfo(v,P,Math.max(B.nextStart,x.maxBufferHole))}return B},s.getMaxBufferLength=function(v){var S=this.config,x;return v?x=Math.max(8*S.maxBufferSize/v,S.maxBufferLength):x=S.maxBufferLength,Math.min(x,S.maxMaxBufferLength)},s.reduceMaxBufferLength=function(v){var S=this.config,x=v||S.maxBufferLength;return S.maxMaxBufferLength>=x?(S.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+S.maxMaxBufferLength+"s"),!0):!1},s.getNextFragment=function(v,S){var x=S.fragments,P=x.length;if(!P)return null;var B=this.config,k=x[0].start,U;if(S.live){var W=B.initialLiveManifestSize;if(P<W)return this.warn("Not enough fragments to start playback (have: "+P+", need: "+W+")"),null;!S.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(U=this.getInitialLiveFragment(S,x),this.startPosition=U?this.hls.liveSyncPosition||U.start:v)}else v<=k&&(U=x[0]);if(!U){var G=B.lowLatencyMode?S.partEnd:S.fragmentEnd;U=this.getFragmentAtPosition(v,G,S)}return this.mapToInitFragWhenRequired(U)},s.mapToInitFragWhenRequired=function(v){return v!=null&&v.initSegment&&!(v!=null&&v.initSegment.data)&&!this.bitrateTest?v.initSegment:v},s.getNextPart=function(v,S,x){for(var P=-1,B=!1,k=!0,U=0,W=v.length;U<W;U++){var G=v[U];if(k=k&&!G.independent,P>-1&&x<G.start)break;var z=G.loaded;!z&&(B||G.independent||k)&&G.fragment===S&&(P=U),B=z}return P},s.loadedEndOfParts=function(v,S){var x=v[v.length-1];return x&&S>x.start&&x.loaded},s.getInitialLiveFragment=function(v,S){var x=this.fragPrevious,P=null;if(x){if(v.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+x.programDateTime),P=Object(E.findFragmentByPDT)(S,x.endProgramDateTime,this.config.maxFragLookUpTolerance)),!P){var B=x.sn+1;if(B>=v.startSN&&B<=v.endSN){var k=S[B-v.startSN];x.cc===k.cc&&(P=k,this.log("Live playlist, switching playlist, load frag with next SN: "+P.sn))}P||(P=Object(E.findFragWithCC)(S,x.cc),P&&this.log("Live playlist, switching playlist, load frag with same CC: "+P.sn))}}else{var U=this.hls.liveSyncPosition;U!==null&&(P=this.getFragmentAtPosition(U,this.bitrateTest?v.fragmentEnd:v.edge,v))}return P},s.getFragmentAtPosition=function(v,S,x){var P=this.config,B=this.fragPrevious,k=x.fragments,U=x.endSN,W=x.fragmentHint,G=P.maxFragLookUpTolerance,z=!!(P.lowLatencyMode&&x.partList&&W);z&&W&&!this.bitrateTest&&(k=k.concat(W),U=W.sn);var Y;if(v<S){var J=v>S-G?0:G;Y=Object(E.findFragmentByPTS)(B,k,v,J)}else Y=k[k.length-1];if(Y){var ee=Y.sn-x.startSN;if(B&&Y.sn===B.sn&&!z){var X=B&&Y.level===B.level;if(X){var q=k[ee+1];Y.sn<U&&this.fragmentTracker.getState(q)!==D.FragmentState.OK?(this.log("SN "+Y.sn+" just loaded, load next one: "+q.sn),Y=q):Y=null}}}return Y},s.synchronizeToLiveEdge=function(v){var S=this.config,x=this.media;if(!!x){var P=this.hls.liveSyncPosition,B=x.currentTime,k=v.fragments[0].start,U=v.edge,W=B>=k-S.maxFragLookUpTolerance&&B<=U;if(P!==null&&x.duration>P&&(B<P||!W)){var G=S.liveMaxLatencyDuration!==void 0?S.liveMaxLatencyDuration:S.liveMaxLatencyDurationCount*v.targetduration;(!W&&x.readyState<4||B<U-G)&&(this.loadedmetadata||(this.nextLoadPosition=P),x.readyState&&(this.warn("Playback: "+B.toFixed(3)+" is located too far from the end of live sliding playlist: "+U+", reset currentTime to : "+P.toFixed(3)),x.currentTime=P))}}},s.alignPlaylists=function(v,S){var x=this.levels,P=this.levelLastLoaded,B=this.fragPrevious,k=P!==null?x[P]:null,U=v.fragments.length;if(!U)return this.warn("No fragments in live playlist"),0;var W=v.fragments[0].start,G=!S,z=v.alignedSliding&&Object(I.isFiniteNumber)(W);if(G||!z&&!W){Object(A.alignStream)(B,k,v);var Y=v.fragments[0].start;return this.log("Live playlist sliding: "+Y.toFixed(2)+" start-sn: "+(S?S.startSN:"na")+"->"+v.startSN+" prev-sn: "+(B?B.sn:"na")+" fragments: "+U),Y}return W},s.waitForCdnTuneIn=function(v){var S=3;return v.live&&v.canBlockReload&&v.partTarget&&v.tuneInGoal>Math.max(v.partHoldBack,v.partTarget*S)},s.setStartPosition=function(v,S){var x=this.startPosition;if(x<S&&(x=-1),x===-1||this.lastCurrentTime===-1){var P=v.startTimeOffset;Object(I.isFiniteNumber)(P)?(x=S+P,P<0&&(x+=v.totalduration),x=Math.min(Math.max(S,x),S+v.totalduration),this.log("Start time offset "+P+" found in playlist, adjust startPosition to "+x),this.startPosition=x):v.live?x=this.hls.liveSyncPosition||S:this.startPosition=x=0,this.lastCurrentTime=x}this.nextLoadPosition=x},s.getLoadPosition=function(){var v=this.media,S=0;return this.loadedmetadata&&v?S=v.currentTime:this.nextLoadPosition&&(S=this.nextLoadPosition),S},s.handleFragLoadAborted=function(v,S){this.transmuxer&&v.sn!=="initSegment"&&v.stats.aborted&&(this.warn("Fragment "+v.sn+(S?" part"+S.index:"")+" of level "+v.level+" was aborted"),this.resetFragmentLoading(v))},s.resetFragmentLoading=function(v){(!this.fragCurrent||!this.fragContextChanged(v)&&this.state!==c.FRAG_LOADING_WAITING_RETRY)&&(this.state=c.IDLE)},s.onFragmentOrKeyLoadError=function(v,S){if(!S.fatal){var x=S.frag;if(!(!x||x.type!==v)){var P=this.fragCurrent;console.assert(P&&x.sn===P.sn&&x.level===P.level&&x.urlId===P.urlId,"Frag load error must match current frag to retry");var B=this.config;if(this.fragLoadError+1<=B.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var k=Math.min(Math.pow(2,this.fragLoadError)*B.fragLoadingRetryDelay,B.fragLoadingMaxRetryTimeout);this.warn("Fragment "+x.sn+" of "+v+" "+x.level+" failed to load, retrying in "+k+"ms"),this.retryDate=self.performance.now()+k,this.fragLoadError++,this.state=c.FRAG_LOADING_WAITING_RETRY}else S.levelRetry?(v===o.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=c.IDLE):(R.logger.error(S.details+" reaches max retry, redispatch as fatal ..."),S.fatal=!0,this.hls.stopLoad(),this.state=c.ERROR)}}},s.afterBufferFlushed=function(v,S,x){if(!!v){var P=M.BufferHelper.getBuffered(v);this.fragmentTracker.detectEvictedFragments(S,P,x),this.state===c.ENDED&&this.resetLoadingState()}},s.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=c.IDLE},s.resetStartWhenNotLoaded=function(v){if(!this.loadedmetadata){this.startFragRequested=!1;var S=this.levels?this.levels[v].details:null;S!=null&&S.live?(this.startPosition=-1,this.setStartPosition(S,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},s.updateLevelTiming=function(v,S,x,P){var B=this,k=x.details;console.assert(!!k,"level.details must be defined");var U=Object.keys(v.elementaryStreams).reduce(function(W,G){var z=v.elementaryStreams[G];if(z){var Y=z.endPTS-z.startPTS;if(Y<=0)return B.warn("Could not parse fragment "+v.sn+" "+G+" duration reliably ("+Y+")"),W||!1;var J=P?0:Object(m.updateFragPTSDTS)(k,v,z.startPTS,z.endPTS,z.startDTS,z.endDTS);return B.hls.trigger(O.Events.LEVEL_PTS_UPDATED,{details:k,level:x,drift:J,type:G,frag:v,start:z.startPTS,end:z.endPTS}),!0}return W},!1);U||(this.warn("Found no media in fragment "+v.sn+" of level "+x.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=c.PARSED,this.hls.trigger(O.Events.FRAG_PARSED,{frag:v,part:S})},s.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},g(u,[{key:"state",get:function(){return this._state},set:function(v){var S=this._state;S!==v&&(this._state=v,this.log(S+"->"+v))}}]),u}(L.default)},"./src/controller/buffer-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return E});var I=n("./src/polyfills/number.ts"),L=n("./src/events.ts"),D=n("./src/utils/logger.ts"),M=n("./src/errors.ts"),R=n("./src/utils/buffer-helper.ts"),O=n("./src/utils/mediasource-helper.ts"),_=n("./src/loader/fragment.ts"),y=n("./src/controller/buffer-operation-queue.ts"),T=Object(O.getMediaSource)(),A=/([ha]vc.)(?:\.[^.,]+)+/,E=function(){function m(f){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var o=e.hls,h=e.media,g=e.mediaSource;D.logger.log("[buffer-controller]: Media source opened"),h&&(e.updateMediaElementDuration(),o.trigger(L.Events.MEDIA_ATTACHED,{media:h})),g&&g.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){D.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){D.logger.log("[buffer-controller]: Media source ended")},this.hls=f,this._initSourceBuffer(),this.registerListeners()}var p=m.prototype;return p.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},p.destroy=function(){this.unregisterListeners(),this.details=null},p.registerListeners=function(){var e=this.hls;e.on(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(L.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(L.Events.BUFFER_RESET,this.onBufferReset,this),e.on(L.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(L.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(L.Events.BUFFER_EOS,this.onBufferEos,this),e.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(L.Events.FRAG_PARSED,this.onFragParsed,this),e.on(L.Events.FRAG_CHANGED,this.onFragChanged,this)},p.unregisterListeners=function(){var e=this.hls;e.off(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(L.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(L.Events.BUFFER_RESET,this.onBufferReset,this),e.off(L.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(L.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(L.Events.BUFFER_EOS,this.onBufferEos,this),e.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(L.Events.FRAG_PARSED,this.onFragParsed,this),e.off(L.Events.FRAG_CHANGED,this.onFragChanged,this)},p._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new y.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},p.onManifestParsed=function(e,o){var h=2;(o.audio&&!o.video||!o.altAudio)&&(h=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=h,this.details=null,D.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},p.onMediaAttaching=function(e,o){var h=this.media=o.media;if(h&&T){var g=this.mediaSource=new T;g.addEventListener("sourceopen",this._onMediaSourceOpen),g.addEventListener("sourceended",this._onMediaSourceEnded),g.addEventListener("sourceclose",this._onMediaSourceClose),h.src=self.URL.createObjectURL(g),this._objectUrl=h.src}},p.onMediaDetaching=function(){var e=this.media,o=this.mediaSource,h=this._objectUrl;if(o){if(D.logger.log("[buffer-controller]: media source detaching"),o.readyState==="open")try{o.endOfStream()}catch(g){D.logger.warn("[buffer-controller]: onMediaDetaching: "+g.message+" while calling endOfStream")}this.onBufferReset(),o.removeEventListener("sourceopen",this._onMediaSourceOpen),o.removeEventListener("sourceended",this._onMediaSourceEnded),o.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(h&&self.URL.revokeObjectURL(h),e.src===h?(e.removeAttribute("src"),e.load()):D.logger.warn("[buffer-controller]: 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.hls.trigger(L.Events.MEDIA_DETACHED,void 0)},p.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(o){var h=e.sourceBuffer[o];try{h&&(e.removeBufferListeners(o),e.mediaSource&&e.mediaSource.removeSourceBuffer(h),e.sourceBuffer[o]=void 0)}catch(g){D.logger.warn("[buffer-controller]: Failed to reset the "+o+" buffer",g)}}),this._initSourceBuffer()},p.onBufferCodecs=function(e,o){var h=this,g=this.getSourceBufferTypes().length;Object.keys(o).forEach(function(i){if(g){var r=h.tracks[i];if(r&&typeof r.buffer.changeType=="function"){var l=o[i],c=l.id,t=l.codec,a=l.levelCodec,u=l.container,s=l.metadata,d=(r.levelCodec||r.codec).replace(A,"$1"),v=(a||t).replace(A,"$1");if(d!==v){var S=u+";codecs="+(a||t);h.appendChangeType(i,S),D.logger.log("[buffer-controller]: switching codec "+d+" to "+v),h.tracks[i]={buffer:r.buffer,codec:t,container:u,levelCodec:a,metadata:s,id:c}}}}else h.pendingTracks[i]=o[i]}),!g&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},p.appendChangeType=function(e,o){var h=this,g=this.operationQueue,i={execute:function(){var l=h.sourceBuffer[e];l&&(D.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+o),l.changeType(o)),g.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(l){D.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",l)}};g.append(i,e)},p.onBufferAppending=function(e,o){var h=this,g=this.hls,i=this.operationQueue,r=this.tracks,l=o.data,c=o.type,t=o.frag,a=o.part,u=o.chunkMeta,s=u.buffering[c],d=self.performance.now();s.start=d;var v=t.stats.buffering,S=a?a.stats.buffering:null;v.start===0&&(v.start=d),S&&S.start===0&&(S.start=d);var x=r.audio,P=c==="audio"&&u.id===1&&(x==null?void 0:x.container)==="audio/mpeg",B={execute:function(){if(s.executeStart=self.performance.now(),P){var U=h.sourceBuffer[c];if(U){var W=t.start-U.timestampOffset;Math.abs(W)>=.1&&(D.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+t.start+" (delta: "+W+") sn: "+t.sn+")"),U.timestampOffset=t.start)}}h.appendExecutor(l,c)},onStart:function(){},onComplete:function(){var U=self.performance.now();s.executeEnd=s.end=U,v.first===0&&(v.first=U),S&&S.first===0&&(S.first=U);var W=h.sourceBuffer,G={};for(var z in W)G[z]=R.BufferHelper.getBuffered(W[z]);h.appendError=0,h.hls.trigger(L.Events.BUFFER_APPENDED,{type:c,frag:t,part:a,chunkMeta:u,parent:t.type,timeRanges:G})},onError:function(U){D.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",U);var W={type:M.ErrorTypes.MEDIA_ERROR,parent:t.type,details:M.ErrorDetails.BUFFER_APPEND_ERROR,err:U,fatal:!1};U.code===DOMException.QUOTA_EXCEEDED_ERR?W.details=M.ErrorDetails.BUFFER_FULL_ERROR:(h.appendError++,W.details=M.ErrorDetails.BUFFER_APPEND_ERROR,h.appendError>g.config.appendErrorMaxRetry&&(D.logger.error("[buffer-controller]: Failed "+g.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),W.fatal=!0,g.stopLoad())),g.trigger(L.Events.ERROR,W)}};i.append(B,c)},p.onBufferFlushing=function(e,o){var h=this,g=this.operationQueue,i=function(l){return{execute:h.removeExecutor.bind(h,l,o.startOffset,o.endOffset),onStart:function(){},onComplete:function(){h.hls.trigger(L.Events.BUFFER_FLUSHED,{type:l})},onError:function(t){D.logger.warn("[buffer-controller]: Failed to remove from "+l+" SourceBuffer",t)}}};o.type?g.append(i(o.type),o.type):this.getSourceBufferTypes().forEach(function(r){g.append(i(r),r)})},p.onFragParsed=function(e,o){var h=this,g=o.frag,i=o.part,r=[],l=i?i.elementaryStreams:g.elementaryStreams;l[_.ElementaryStreamTypes.AUDIOVIDEO]?r.push("audiovideo"):(l[_.ElementaryStreamTypes.AUDIO]&&r.push("audio"),l[_.ElementaryStreamTypes.VIDEO]&&r.push("video"));var c=function(){var a=self.performance.now();g.stats.buffering.end=a,i&&(i.stats.buffering.end=a);var u=i?i.stats:g.stats;h.hls.trigger(L.Events.FRAG_BUFFERED,{frag:g,part:i,stats:u,id:g.type})};r.length===0&&D.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+g.type+" level: "+g.level+" sn: "+g.sn),this.blockBuffers(c,r)},p.onFragChanged=function(e,o){this.flushBackBuffer()},p.onBufferEos=function(e,o){var h=this,g=this.getSourceBufferTypes().reduce(function(i,r){var l=h.sourceBuffer[r];return(!o.type||o.type===r)&&l&&!l.ended&&(l.ended=!0,D.logger.log("[buffer-controller]: "+r+" sourceBuffer now EOS")),i&&!!(!l||l.ended)},!0);g&&this.blockBuffers(function(){var i=h.mediaSource;!i||i.readyState!=="open"||i.endOfStream()})},p.onLevelUpdated=function(e,o){var h=o.details;!h.fragments.length||(this.details=h,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},p.flushBackBuffer=function(){var e=this.hls,o=this.details,h=this.media,g=this.sourceBuffer;if(!(!h||o===null)){var i=this.getSourceBufferTypes();if(!!i.length){var r=o.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!(!Object(I.isFiniteNumber)(r)||r<0)){var l=h.currentTime,c=o.levelTargetDuration,t=Math.max(r,c),a=Math.floor(l/c)*c-t;i.forEach(function(u){var s=g[u];if(s){var d=R.BufferHelper.getBuffered(s);d.length>0&&a>d.start(0)&&(e.trigger(L.Events.BACK_BUFFER_REACHED,{bufferEnd:a}),o.live&&e.trigger(L.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:a}),e.trigger(L.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:a,type:u}))}})}}}},p.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,o=this.hls,h=this.media,g=this.mediaSource,i=e.fragments[0].start+e.totalduration,r=h.duration,l=Object(I.isFiniteNumber)(g.duration)?g.duration:0;e.live&&o.config.liveDurationInfinity?(D.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),g.duration=1/0,this.updateSeekableRange(e)):(i>l&&i>r||!Object(I.isFiniteNumber)(r))&&(D.logger.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),g.duration=i)}},p.updateSeekableRange=function(e){var o=this.mediaSource,h=e.fragments,g=h.length;if(g&&e.live&&o!==null&&o!==void 0&&o.setLiveSeekableRange){var i=Math.max(0,h[0].start),r=Math.max(i,i+e.totalduration);o.setLiveSeekableRange(i,r)}},p.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,o=this.operationQueue,h=this.pendingTracks,g=Object.keys(h).length;if(g&&!e||g===2){this.createSourceBuffers(h),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length===0){this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}i.forEach(function(r){o.executeNext(r)})}},p.createSourceBuffers=function(e){var o=this.sourceBuffer,h=this.mediaSource;if(!h)throw Error("createSourceBuffers called when mediaSource was null");var g=0;for(var i in e)if(!o[i]){var r=e[i];if(!r)throw Error("source buffer exists for track "+i+", however track does not");var l=r.levelCodec||r.codec,c=r.container+";codecs="+l;D.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var t=o[i]=h.addSourceBuffer(c),a=i;this.addBufferListener(a,"updatestart",this._onSBUpdateStart),this.addBufferListener(a,"updateend",this._onSBUpdateEnd),this.addBufferListener(a,"error",this._onSBUpdateError),this.tracks[i]={buffer:t,codec:l,container:r.container,levelCodec:r.levelCodec,metadata:r.metadata,id:r.id},g++}catch(u){D.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+u.message),this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:u,mimeType:c})}}g&&this.hls.trigger(L.Events.BUFFER_CREATED,{tracks:this.tracks})},p._onSBUpdateStart=function(e){var o=this.operationQueue,h=o.current(e);h.onStart()},p._onSBUpdateEnd=function(e){var o=this.operationQueue,h=o.current(e);h.onComplete(),o.shiftAndExecuteNext(e)},p._onSBUpdateError=function(e,o){D.logger.error("[buffer-controller]: "+e+" SourceBuffer error",o),this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var h=this.operationQueue.current(e);h&&h.onError(o)},p.removeExecutor=function(e,o,h){var g=this.media,i=this.mediaSource,r=this.operationQueue,l=this.sourceBuffer,c=l[e];if(!g||!i||!c){D.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),r.shiftAndExecuteNext(e);return}var t=Object(I.isFiniteNumber)(g.duration)?g.duration:1/0,a=Object(I.isFiniteNumber)(i.duration)?i.duration:1/0,u=Math.max(0,o),s=Math.min(h,t,a);s>u?(D.logger.log("[buffer-controller]: Removing ["+u+","+s+"] from the "+e+" SourceBuffer"),console.assert(!c.updating,e+" sourceBuffer must not be updating"),c.remove(u,s)):r.shiftAndExecuteNext(e)},p.appendExecutor=function(e,o){var h=this.operationQueue,g=this.sourceBuffer,i=g[o];if(!i){D.logger.warn("[buffer-controller]: Attempting to append to the "+o+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(o);return}i.ended=!1,console.assert(!i.updating,o+" sourceBuffer must not be updating"),i.appendBuffer(e)},p.blockBuffers=function(e,o){var h=this;if(o===void 0&&(o=this.getSourceBufferTypes()),!o.length){D.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var g=this.operationQueue,i=o.map(function(r){return g.appendBlocker(r)});Promise.all(i).then(function(){e(),o.forEach(function(r){var l=h.sourceBuffer[r];(!l||!l.updating)&&g.shiftAndExecuteNext(r)})})},p.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},p.addBufferListener=function(e,o,h){var g=this.sourceBuffer[e];if(!!g){var i=h.bind(this,e);this.listeners[e].push({event:o,listener:i}),g.addEventListener(o,i)}},p.removeBufferListeners=function(e){var o=this.sourceBuffer[e];!o||this.listeners[e].forEach(function(h){o.removeEventListener(h.event,h.listener)})},m}()},"./src/controller/buffer-operation-queue.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return L});var I=n("./src/utils/logger.ts"),L=function(){function D(R){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=R}var M=D.prototype;return M.append=function(O,_){var y=this.queues[_];y.push(O),y.length===1&&this.buffers[_]&&this.executeNext(_)},M.insertAbort=function(O,_){var y=this.queues[_];y.unshift(O),this.executeNext(_)},M.appendBlocker=function(O){var _,y=new Promise(function(A){_=A}),T={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(T,O),y},M.executeNext=function(O){var _=this.buffers,y=this.queues,T=_[O],A=y[O];if(A.length){var E=A[0];try{E.execute()}catch(m){I.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),E.onError(m),(!T||!T.updating)&&(A.shift(),this.executeNext(O))}}},M.shiftAndExecuteNext=function(O){this.queues[O].shift(),this.executeNext(O)},M.current=function(O){return this.queues[O][0]},D}()},"./src/controller/cap-level-controller.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/events.ts");function L(R,O){for(var _=0;_<O.length;_++){var y=O[_];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(R,y.key,y)}}function D(R,O,_){return O&&L(R.prototype,O),_&&L(R,_),Object.defineProperty(R,"prototype",{writable:!1}),R}var M=function(){function R(_){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=_,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var O=R.prototype;return O.setStreamController=function(y){this.streamController=y},O.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},O.registerListeners=function(){var y=this.hls;y.on(I.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(I.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.unregisterListener=function(){var y=this.hls;y.off(I.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(I.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.onFpsDropLevelCapping=function(y,T){R.isLevelAllowed(T.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(T.droppedLevel)},O.onMediaAttaching=function(y,T){this.media=T.media instanceof HTMLVideoElement?T.media:null},O.onManifestParsed=function(y,T){var A=this.hls;this.restrictedLevels=[],this.firstLevel=T.firstLevel,A.config.capLevelToPlayerSize&&T.video&&this.startCapping()},O.onBufferCodecs=function(y,T){var A=this.hls;A.config.capLevelToPlayerSize&&T.video&&this.startCapping()},O.onMediaDetaching=function(){this.stopCapping()},O.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var y=this.hls.levels;if(y.length){var T=this.hls;T.autoLevelCapping=this.getMaxLevel(y.length-1),T.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=T.autoLevelCapping}}},O.getMaxLevel=function(y){var T=this,A=this.hls.levels;if(!A.length)return-1;var E=A.filter(function(m,p){return R.isLevelAllowed(p,T.restrictedLevels)&&p<=y});return this.clientRect=null,R.getMaxLevelByMediaSize(E,this.mediaWidth,this.mediaHeight)},O.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},O.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},O.getDimensions=function(){if(this.clientRect)return this.clientRect;var y=this.media,T={width:0,height:0};if(y){var A=y.getBoundingClientRect();T.width=A.width,T.height=A.height,!T.width&&!T.height&&(T.width=A.right-A.left||y.width||0,T.height=A.bottom-A.top||y.height||0)}return this.clientRect=T,T},R.isLevelAllowed=function(y,T){return T===void 0&&(T=[]),T.indexOf(y)===-1},R.getMaxLevelByMediaSize=function(y,T,A){if(!y||!y.length)return-1;for(var E=function(o,h){return h?o.width!==h.width||o.height!==h.height:!0},m=y.length-1,p=0;p<y.length;p+=1){var f=y[p];if((f.width>=T||f.height>=A)&&E(f,y[p+1])){m=p;break}}return m},D(R,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var y=1;if(!this.hls.config.ignoreDevicePixelRatio)try{y=self.devicePixelRatio}catch{}return y}}]),R}();b.default=M},"./src/controller/cmcd-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return E});var I=n("./src/events.ts"),L=n("./src/types/cmcd.ts"),D=n("./src/utils/buffer-helper.ts"),M=n("./src/utils/logger.ts");function R(m,p){for(var f=0;f<p.length;f++){var e=p[f];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(m,e.key,e)}}function O(m,p,f){return p&&R(m.prototype,p),f&&R(m,f),Object.defineProperty(m,"prototype",{writable:!1}),m}function _(m,p){var f=typeof Symbol!="undefined"&&m[Symbol.iterator]||m["@@iterator"];if(f)return(f=f.call(m)).next.bind(f);if(Array.isArray(m)||(f=y(m))||p&&m&&typeof m.length=="number"){f&&(m=f);var e=0;return function(){return e>=m.length?{done:!0}:{done:!1,value:m[e++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
13
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function y(m,p){if(!!m){if(typeof m=="string")return T(m,p);var f=Object.prototype.toString.call(m).slice(8,-1);if(f==="Object"&&m.constructor&&(f=m.constructor.name),f==="Map"||f==="Set")return Array.from(m);if(f==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(f))return T(m,p)}}function T(m,p){(p==null||p>m.length)&&(p=m.length);for(var f=0,e=new Array(p);f<p;f++)e[f]=m[f];return e}function A(){return A=Object.assign?Object.assign.bind():function(m){for(var p=1;p<arguments.length;p++){var f=arguments[p];for(var e in f)Object.prototype.hasOwnProperty.call(f,e)&&(m[e]=f[e])}return m},A.apply(this,arguments)}var E=function(){function m(f){var e=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(g){try{e.apply(g,{ot:L.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(i){M.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(g){try{var i=g.frag,r=e.hls.levels[i.level],l=e.getObjectType(i),c={d:i.duration*1e3,ot:l};(l===L.CMCDObjectType.VIDEO||l===L.CMCDObjectType.AUDIO||l==L.CMCDObjectType.MUXED)&&(c.br=r.bitrate/1e3,c.tb=e.getTopBandwidth(l)/1e3,c.bl=e.getBufferLength(l)),e.apply(g,c)}catch(t){M.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=f;var o=this.config=f.config,h=o.cmcd;h!=null&&(o.pLoader=this.createPlaylistLoader(),o.fLoader=this.createFragmentLoader(),this.sid=h.sessionId||m.uuid(),this.cid=h.contentId,this.useHeaders=h.useHeaders===!0,this.registerListeners())}var p=m.prototype;return p.registerListeners=function(){var e=this.hls;e.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(I.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(I.Events.BUFFER_CREATED,this.onBufferCreated,this)},p.unregisterListeners=function(){var e=this.hls;e.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(I.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(I.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},p.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},p.onMediaAttached=function(e,o){this.media=o.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},p.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},p.onBufferCreated=function(e,o){var h,g;this.audioBuffer=(h=o.tracks.audio)===null||h===void 0?void 0:h.buffer,this.videoBuffer=(g=o.tracks.video)===null||g===void 0?void 0:g.buffer},p.createData=function(){var e;return{v:L.CMCDVersion,sf:L.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},p.apply=function(e,o){o===void 0&&(o={}),A(o,this.createData());var h=o.ot===L.CMCDObjectType.INIT||o.ot===L.CMCDObjectType.VIDEO||o.ot===L.CMCDObjectType.MUXED;if(this.starved&&h&&(o.bs=!0,o.su=!0,this.starved=!1),o.su==null&&(o.su=this.buffering),this.useHeaders){var g=m.toHeaders(o);if(!Object.keys(g).length)return;e.headers||(e.headers={}),A(e.headers,g)}else{var i=m.toQuery(o);if(!i)return;e.url=m.appendQueryToUri(e.url,i)}},p.getObjectType=function(e){var o=e.type;if(o==="subtitle")return L.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return L.CMCDObjectType.INIT;if(o==="audio")return L.CMCDObjectType.AUDIO;if(o==="main")return this.hls.audioTracks.length?L.CMCDObjectType.VIDEO:L.CMCDObjectType.MUXED},p.getTopBandwidth=function(e){var o=0,h,g=this.hls;if(e===L.CMCDObjectType.AUDIO)h=g.audioTracks;else{var i=g.maxAutoLevel,r=i>-1?i+1:g.levels.length;h=g.levels.slice(0,r)}for(var l=_(h),c;!(c=l()).done;){var t=c.value;t.bitrate>o&&(o=t.bitrate)}return o>0?o:NaN},p.getBufferLength=function(e){var o=this.hls.media,h=e===L.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!h||!o)return NaN;var g=D.BufferHelper.bufferInfo(h,o.currentTime,this.config.maxBufferHole);return g.len*1e3},p.createPlaylistLoader=function(){var e=this.config.pLoader,o=this.applyPlaylistData,h=e||this.config.loader;return function(){function g(r){this.loader=void 0,this.loader=new h(r)}var i=g.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(l,c,t){o(l),this.loader.load(l,c,t)},O(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},p.createFragmentLoader=function(){var e=this.config.fLoader,o=this.applyFragmentData,h=e||this.config.loader;return function(){function g(r){this.loader=void 0,this.loader=new h(r)}var i=g.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(l,c,t){o(l),this.loader.load(l,c,t)},O(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},m.uuid=function(){var e=URL.createObjectURL(new Blob),o=e.toString();return URL.revokeObjectURL(e),o.slice(o.lastIndexOf("/")+1)},m.serialize=function(e){for(var o=[],h=function(P){return!Number.isNaN(P)&&P!=null&&P!==""&&P!==!1},g=function(P){return Math.round(P)},i=function(P){return g(P/100)*100},r=function(P){return encodeURIComponent(P)},l={br:g,d:g,bl:i,dl:i,mtp:i,nor:r,rtp:i,tb:g},c=Object.keys(e||{}).sort(),t=_(c),a;!(a=t()).done;){var u=a.value,s=e[u];if(!!h(s)&&!(u==="v"&&s===1)&&!(u=="pr"&&s===1)){var d=l[u];d&&(s=d(s));var v=typeof s,S=void 0;u==="ot"||u==="sf"||u==="st"?S=u+"="+s:v==="boolean"?S=u:v==="number"?S=u+"="+s:S=u+"="+JSON.stringify(s),o.push(S)}}return o.join(",")},m.toHeaders=function(e){for(var o=Object.keys(e),h={},g=["Object","Request","Session","Status"],i=[{},{},{},{}],r={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},l=0,c=o;l<c.length;l++){var t=c[l],a=r[t]!=null?r[t]:1;i[a][t]=e[t]}for(var u=0;u<i.length;u++){var s=m.serialize(i[u]);s&&(h["CMCD-"+g[u]]=s)}return h},m.toQuery=function(e){return"CMCD="+encodeURIComponent(m.serialize(e))},m.appendQueryToUri=function(e,o){if(!o)return e;var h=e.includes("?")?"&":"?";return""+e+h+o},m}()},"./src/controller/eme-controller.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/events.ts"),L=n("./src/errors.ts"),D=n("./src/utils/logger.ts"),M=n("./src/utils/mediakeys-helper.ts");function R(E,m){for(var p=0;p<m.length;p++){var f=m[p];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(E,f.key,f)}}function O(E,m,p){return m&&R(E.prototype,m),p&&R(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}var _=3,y=function(m,p,f){var e={audioCapabilities:[],videoCapabilities:[]};return m.forEach(function(o){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+o+'"',robustness:f.audioRobustness||""})}),p.forEach(function(o){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+o+'"',robustness:f.videoRobustness||""})}),[e]},T=function(m,p,f,e){switch(m){case M.KeySystems.WIDEVINE:return y(p,f,e);default:throw new Error("Unknown key-system: "+m)}},A=function(){function E(p){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=p,this._config=p.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var m=E.prototype;return m.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},m._registerListeners=function(){this.hls.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(I.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this)},m._unregisterListeners=function(){this.hls.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(I.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this)},m.getLicenseServerUrl=function(f){switch(f){case M.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+f+'"')},m._attemptKeySystemAccess=function(f,e,o){var h=this,g=T(f,e,o,this._drmSystemOptions);D.logger.log("Requesting encrypted media key-system access");var i=this.requestMediaKeySystemAccess(f,g);this.mediaKeysPromise=i.then(function(r){return h._onMediaKeySystemAccessObtained(f,r)}),i.catch(function(r){D.logger.error('Failed to obtain key-system "'+f+'" access:',r)})},m._onMediaKeySystemAccessObtained=function(f,e){var o=this;D.logger.log('Access for key-system "'+f+'" obtained');var h={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:f};this._mediaKeysList.push(h);var g=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(i){return h.mediaKeys=i,D.logger.log('Media-keys created for key-system "'+f+'"'),o._onMediaKeysCreated(),i});return g.catch(function(i){D.logger.error("Failed to create media-keys:",i)}),g},m._onMediaKeysCreated=function(){var f=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),f._onNewMediaKeySession(e.mediaKeysSession))})},m._onNewMediaKeySession=function(f){var e=this;D.logger.log("New key-system session "+f.sessionId),f.addEventListener("message",function(o){e._onKeySessionMessage(f,o.message)},!1)},m._onKeySessionMessage=function(f,e){D.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(o){D.logger.log("Received license data (length: "+(o&&o.byteLength)+"), updating key-session"),f.update(o).catch(function(h){D.logger.warn("Updating key-session failed: "+h)})})},m.onMediaEncrypted=function(f){var e=this;if(D.logger.log('Media is encrypted using "'+f.initDataType+'" init data type'),!this.mediaKeysPromise){D.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var o=function(g){!e._media||(e._attemptSetMediaKeys(g),e._generateRequestWithPreferredKeySession(f.initDataType,f.initData))};this.mediaKeysPromise.then(o).catch(o)},m._attemptSetMediaKeys=function(f){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys){D.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}D.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},m._generateRequestWithPreferredKeySession=function(f,e){var o=this,h=this._mediaKeysList[0];if(!h){D.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(h.mediaKeysSessionInitialized){D.logger.warn("Key-Session already initialized but requested again");return}var g=h.mediaKeysSession;if(!g){D.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){D.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}D.logger.log('Generating key-session request for "'+f+'" init data type'),h.mediaKeysSessionInitialized=!0,g.generateRequest(f,e).then(function(){D.logger.debug("Key-session generation succeeded")}).catch(function(i){D.logger.error("Error generating key-session request:",i),o.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},m._createLicenseXhr=function(f,e,o){var h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,h,f,e,o);var g=this._licenseXhrSetup;if(g)try{g.call(this.hls,h,f),g=void 0}catch(i){D.logger.error(i)}try{h.readyState||h.open("POST",f,!0),g&&g.call(this.hls,h,f)}catch(i){throw new Error("issue setting up KeySystem license XHR "+i)}return h},m._onLicenseRequestReadyStageChange=function(f,e,o,h){switch(f.readyState){case 4:if(f.status===200){this._requestLicenseFailureCount=0,D.logger.log("License request succeeded");var g=f.response,i=this._licenseResponseCallback;if(i)try{g=i.call(this.hls,f,e)}catch(l){D.logger.error(l)}h(g)}else{if(D.logger.error("License Request XHR failed ("+e+"). Status: "+f.status+" ("+f.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>_){this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var r=_-this._requestLicenseFailureCount+1;D.logger.warn("Retrying license request, "+r+" attempts left"),this._requestLicense(o,h)}break}},m._generateLicenseRequestChallenge=function(f,e){switch(f.mediaKeySystemDomain){case M.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+f.mediaKeySystemDomain)},m._requestLicense=function(f,e){D.logger.log("Requesting content license for key-system");var o=this._mediaKeysList[0];if(!o){D.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var h=this.getLicenseServerUrl(o.mediaKeySystemDomain),g=this._createLicenseXhr(h,f,e);D.logger.log("Sending license request to URL: "+h);var i=this._generateLicenseRequestChallenge(o,f);g.send(i)}catch(r){D.logger.error("Failure requesting DRM license: "+r),this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},m.onMediaAttached=function(f,e){if(!!this._emeEnabled){var o=e.media;this._media=o,o.addEventListener("encrypted",this._onMediaEncrypted)}},m.onMediaDetached=function(){var f=this._media,e=this._mediaKeysList;!f||(f.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(o){if(o.mediaKeysSession)return o.mediaKeysSession.close().catch(function(){})})).then(function(){return f.setMediaKeys(null)}).catch(function(){}))},m.onManifestParsed=function(f,e){if(!!this._emeEnabled){var o=e.levels.map(function(g){return g.audioCodec}).filter(function(g){return!!g}),h=e.levels.map(function(g){return g.videoCodec}).filter(function(g){return!!g});this._attemptKeySystemAccess(M.KeySystems.WIDEVINE,o,h)}},O(E,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),E}();b.default=A},"./src/controller/fps-controller.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/events.ts"),L=n("./src/utils/logger.ts"),D=function(){function M(O){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=O,this.registerListeners()}var R=M.prototype;return R.setStreamController=function(_){this.streamController=_},R.registerListeners=function(){this.hls.on(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},R.unregisterListeners=function(){this.hls.off(I.Events.MEDIA_ATTACHING,this.onMediaAttaching)},R.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},R.onMediaAttaching=function(_,y){var T=this.hls.config;if(T.capLevelOnFPSDrop){var A=y.media instanceof self.HTMLVideoElement?y.media:null;this.media=A,A&&typeof A.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),T.fpsDroppedMonitoringPeriod)}},R.checkFPS=function(_,y,T){var A=performance.now();if(y){if(this.lastTime){var E=A-this.lastTime,m=T-this.lastDroppedFrames,p=y-this.lastDecodedFrames,f=1e3*m/E,e=this.hls;if(e.trigger(I.Events.FPS_DROP,{currentDropped:m,currentDecoded:p,totalDroppedFrames:T}),f>0&&m>e.config.fpsDroppedMonitoringThreshold*p){var o=e.currentLevel;L.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+o),o>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=o)&&(o=o-1,e.trigger(I.Events.FPS_DROP_LEVEL_CAPPING,{level:o,droppedLevel:e.currentLevel}),e.autoLevelCapping=o,this.streamController.nextLevelSwitch())}}this.lastTime=A,this.lastDroppedFrames=T,this.lastDecodedFrames=y}},R.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var y=_.getVideoPlaybackQuality();this.checkFPS(_,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},M}();b.default=D},"./src/controller/fragment-finders.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"findFragmentByPDT",function(){return D}),n.d(b,"findFragmentByPTS",function(){return M}),n.d(b,"fragmentWithinToleranceTest",function(){return R}),n.d(b,"pdtWithinToleranceTest",function(){return O}),n.d(b,"findFragWithCC",function(){return _});var I=n("./src/polyfills/number.ts"),L=n("./src/utils/binary-search.ts");function D(y,T,A){if(T===null||!Array.isArray(y)||!y.length||!Object(I.isFiniteNumber)(T))return null;var E=y[0].programDateTime;if(T<(E||0))return null;var m=y[y.length-1].endProgramDateTime;if(T>=(m||0))return null;A=A||0;for(var p=0;p<y.length;++p){var f=y[p];if(O(T,A,f))return f}return null}function M(y,T,A,E){A===void 0&&(A=0),E===void 0&&(E=0);var m=null;if(y?m=T[y.sn-T[0].sn+1]||null:A===0&&T[0].start===0&&(m=T[0]),m&&R(A,E,m)===0)return m;var p=L.default.search(T,R.bind(null,A,E));return p||m}function R(y,T,A){y===void 0&&(y=0),T===void 0&&(T=0);var E=Math.min(T,A.duration+(A.deltaPTS?A.deltaPTS:0));return A.start+A.duration-E<=y?1:A.start-E>y&&A.start?-1:0}function O(y,T,A){var E=Math.min(T,A.duration+(A.deltaPTS?A.deltaPTS:0))*1e3,m=A.endProgramDateTime||0;return m-E>y}function _(y,T){return L.default.search(y,function(A){return A.cc<T?1:A.cc>T?-1:0})}},"./src/controller/fragment-tracker.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"FragmentState",function(){return D}),n.d(b,"FragmentTracker",function(){return M});var I=n("./src/events.ts"),L=n("./src/types/loader.ts"),D;(function(_){_.NOT_LOADED="NOT_LOADED",_.APPENDING="APPENDING",_.PARTIAL="PARTIAL",_.OK="OK"})(D||(D={}));var M=function(){function _(T){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=T,this._registerListeners()}var y=_.prototype;return y._registerListeners=function(){var A=this.hls;A.on(I.Events.BUFFER_APPENDED,this.onBufferAppended,this),A.on(I.Events.FRAG_BUFFERED,this.onFragBuffered,this),A.on(I.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var A=this.hls;A.off(I.Events.BUFFER_APPENDED,this.onBufferAppended,this),A.off(I.Events.FRAG_BUFFERED,this.onFragBuffered,this),A.off(I.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(A,E){if(E===L.PlaylistLevelType.MAIN){var m=this.activeFragment,p=this.activeParts;if(!m)return null;if(p)for(var f=p.length;f--;){var e=p[f],o=e?e.end:m.appendedPTS;if(e.start<=A&&o!==void 0&&A<=o)return f>9&&(this.activeParts=p.slice(f-9)),e}else if(m.start<=A&&m.appendedPTS!==void 0&&A<=m.appendedPTS)return m}return this.getBufferedFrag(A,E)},y.getBufferedFrag=function(A,E){for(var m=this.fragments,p=Object.keys(m),f=p.length;f--;){var e=m[p[f]];if((e==null?void 0:e.body.type)===E&&e.buffered){var o=e.body;if(o.start<=A&&A<=o.end)return o}}return null},y.detectEvictedFragments=function(A,E,m){var p=this;Object.keys(this.fragments).forEach(function(f){var e=p.fragments[f];if(!!e){if(!e.buffered){e.body.type===m&&p.removeFragment(e.body);return}var o=e.range[A];!o||o.time.some(function(h){var g=!p.isTimeBuffered(h.startPTS,h.endPTS,E);return g&&p.removeFragment(e.body),g})}})},y.detectPartialFragments=function(A){var E=this,m=this.timeRanges,p=A.frag,f=A.part;if(!(!m||p.sn==="initSegment")){var e=O(p),o=this.fragments[e];!o||(Object.keys(m).forEach(function(h){var g=p.elementaryStreams[h];if(!!g){var i=m[h],r=f!==null||g.partial===!0;o.range[h]=E.getBufferedTimes(p,f,r,i)}}),o.loaded=null,Object.keys(o.range).length?o.buffered=!0:this.removeFragment(o.body))}},y.fragBuffered=function(A){var E=O(A),m=this.fragments[E];m&&(m.loaded=null,m.buffered=!0)},y.getBufferedTimes=function(A,E,m,p){for(var f={time:[],partial:m},e=E?E.start:A.start,o=E?E.end:A.end,h=A.minEndPTS||o,g=A.maxStartPTS||e,i=0;i<p.length;i++){var r=p.start(i)-this.bufferPadding,l=p.end(i)+this.bufferPadding;if(g>=r&&h<=l){f.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(o,p.end(i))});break}else if(e<l&&o>r)f.partial=!0,f.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(o,p.end(i))});else if(o<=r)break}return f},y.getPartialFragment=function(A){var E=null,m,p,f,e=0,o=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(g){var i=h[g];!i||R(i)&&(p=i.body.start-o,f=i.body.end+o,A>=p&&A<=f&&(m=Math.min(A-p,f-A),e<=m&&(E=i.body,e=m)))}),E},y.getState=function(A){var E=O(A),m=this.fragments[E];return m?m.buffered?R(m)?D.PARTIAL:D.OK:D.APPENDING:D.NOT_LOADED},y.isTimeBuffered=function(A,E,m){for(var p,f,e=0;e<m.length;e++){if(p=m.start(e)-this.bufferPadding,f=m.end(e)+this.bufferPadding,A>=p&&E<=f)return!0;if(E<=p)return!1}return!1},y.onFragLoaded=function(A,E){var m=E.frag,p=E.part;if(!(m.sn==="initSegment"||m.bitrateTest||p)){var f=O(m);this.fragments[f]={body:m,loaded:E,buffered:!1,range:Object.create(null)}}},y.onBufferAppended=function(A,E){var m=this,p=E.frag,f=E.part,e=E.timeRanges;if(p.type===L.PlaylistLevelType.MAIN)if(this.activeFragment=p,f){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(f)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(h){var g=e[h];if(m.detectEvictedFragments(h,g),!f)for(var i=0;i<g.length;i++)p.appendedPTS=Math.max(g.end(i),p.appendedPTS||0)})},y.onFragBuffered=function(A,E){this.detectPartialFragments(E)},y.hasFragment=function(A){var E=O(A);return!!this.fragments[E]},y.removeFragmentsInRange=function(A,E,m){var p=this;Object.keys(this.fragments).forEach(function(f){var e=p.fragments[f];if(!!e&&e.buffered){var o=e.body;o.type===m&&o.start<E&&o.end>A&&p.removeFragment(o)}})},y.removeFragment=function(A){var E=O(A);A.stats.loaded=0,A.clearElementaryStreamInfo(),delete this.fragments[E]},y.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},_}();function R(_){var y,T;return _.buffered&&(((y=_.range.video)===null||y===void 0?void 0:y.partial)||((T=_.range.audio)===null||T===void 0?void 0:T.partial))}function O(_){return _.type+"_"+_.level+"_"+_.urlId+"_"+_.sn}},"./src/controller/gap-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"STALL_MINIMUM_DURATION_MS",function(){return R}),n.d(b,"MAX_START_GAP_JUMP",function(){return O}),n.d(b,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return _}),n.d(b,"SKIP_BUFFER_RANGE_START",function(){return y}),n.d(b,"default",function(){return T});var I=n("./src/utils/buffer-helper.ts"),L=n("./src/errors.ts"),D=n("./src/events.ts"),M=n("./src/utils/logger.ts"),R=250,O=2,_=.1,y=.05,T=function(){function A(m,p,f,e){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=m,this.media=p,this.fragmentTracker=f,this.hls=e}var E=A.prototype;return E.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},E.poll=function(p,f){var e=this.config,o=this.media,h=this.stalled;if(o!==null){var g=o.currentTime,i=o.seeking,r=this.seeking&&!i,l=!this.seeking&&i;if(this.seeking=i,g!==p){if(this.moved=!0,h!==null){if(this.stallReported){var c=self.performance.now()-h;M.logger.warn("playback not stuck anymore @"+g+", after "+Math.round(c)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((l||r)&&(this.stalled=null),!(o.paused&&!i||o.ended||o.playbackRate===0||!I.BufferHelper.getBuffered(o).length)){var t=I.BufferHelper.bufferInfo(o,g,0),a=t.len>0,u=t.nextStart||0;if(!(!a&&!u)){if(i){var s=t.len>O,d=!u||f&&f.start<=g||u-g>O&&!this.fragmentTracker.getPartialFragment(g);if(s||d)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var v,S=Math.max(u,t.start||0)-g,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=x==null||(v=x.details)===null||v===void 0?void 0:v.live,B=P?x.details.targetduration*2:O;if(S>0&&S<=B){this._trySkipBufferHole(null);return}}var k=self.performance.now();if(h===null){this.stalled=k;return}var U=k-h;if(!(!i&&U>=R&&(this._reportStall(t),!this.media))){var W=I.BufferHelper.bufferInfo(o,g,e.maxBufferHole);this._tryFixBufferStall(W,U)}}}}},E._tryFixBufferStall=function(p,f){var e=this.config,o=this.fragmentTracker,h=this.media;if(h!==null){var g=h.currentTime,i=o.getPartialFragment(g);if(i){var r=this._trySkipBufferHole(i);if(r||!this.media)return}p.len>e.maxBufferHole&&f>e.highBufferWatchdogPeriod*1e3&&(M.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},E._reportStall=function(p){var f=this.hls,e=this.media,o=this.stallReported;!o&&e&&(this.stallReported=!0,M.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer ("+JSON.stringify(p)+")"),f.trigger(D.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p.len}))},E._trySkipBufferHole=function(p){var f=this.config,e=this.hls,o=this.media;if(o===null)return 0;for(var h=o.currentTime,g=0,i=I.BufferHelper.getBuffered(o),r=0;r<i.length;r++){var l=i.start(r);if(h+f.maxBufferHole>=g&&h<l){var c=Math.max(l+y,o.currentTime+_);return M.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+c),this.moved=!0,this.stalled=null,o.currentTime=c,p&&e.trigger(D.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+c,frag:p}),c}g=i.end(r)}return 0},E._tryNudgeBuffer=function(){var p=this.config,f=this.hls,e=this.media,o=this.nudgeRetry;if(e!==null){var h=e.currentTime;if(this.nudgeRetry++,o<p.nudgeMaxRetry){var g=h+(o+1)*p.nudgeOffset;M.logger.warn("Nudging 'currentTime' from "+h+" to "+g),e.currentTime=g,f.trigger(D.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else M.logger.error("Playhead still not moving while enough data buffered @"+h+" after "+p.nudgeMaxRetry+" nudges"),f.trigger(D.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},A}()},"./src/controller/id3-track-controller.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/polyfills/number.ts"),L=n("./src/events.ts"),D=n("./src/utils/texttrack-utils.ts"),M=n("./src/demux/id3.ts"),R=n("./src/loader/date-range.ts"),O=n("./src/types/demuxer.ts"),_=.25;function y(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function T(m,p){return m.getTime()/1e3-p}function A(m){return Uint8Array.from(m.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var E=function(){function m(f){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=f,this._registerListeners()}var p=m.prototype;return p.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},p._registerListeners=function(){var e=this.hls;e.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(L.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p._unregisterListeners=function(){var e=this.hls;e.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(L.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p.onMediaAttached=function(e,o){this.media=o.media},p.onMediaDetaching=function(){!this.id3Track||(Object(D.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},p.onManifestLoading=function(){this.dateRangeCuesAppended={}},p.createTrack=function(e){var o=this.getID3Track(e.textTracks);return o.mode="hidden",o},p.getID3Track=function(e){if(!!this.media){for(var o=0;o<e.length;o++){var h=e[o];if(h.kind==="metadata"&&h.label==="id3")return Object(D.sendAddTrackEvent)(h,this.media),h}return this.media.addTextTrack("metadata","id3")}},p.onFragParsingMetadata=function(e,o){if(!!this.media){var h=this.hls.config,g=h.enableEmsgMetadataCues,i=h.enableID3MetadataCues;if(!(!g&&!i)){var r=o.frag,l=o.samples,c=o.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var t=c.edge||r.end,a=y(),u=!1,s={},d=0;d<l.length;d++){var v=l[d].type;if(!(v===O.MetadataSchema.emsg&&!g||!i)){var S=M.getID3Frames(l[d].data);if(S){var x=l[d].pts,P=t,B=P-x;B<=0&&(P=x+_);for(var k=0;k<S.length;k++){var U=S[k];if(!M.isTimeStampFrame(U)){var W=new a(x,P,"");W.value=U,v&&(W.type=v),this.id3Track.addCue(W),s[U.key]=null,u=!0}}}}}u&&this.updateId3CueEnds(s)}}},p.updateId3CueEnds=function(e){var o,h=(o=this.id3Track)===null||o===void 0?void 0:o.cues;if(h)for(var g=h.length;g--;){var i,r=h[g],l=(i=r.value)===null||i===void 0?void 0:i.key;if(l&&l in e){var c=e[l];c&&r.endTime!==c&&(r.endTime=c),e[l]=r.startTime}}},p.onBufferFlushing=function(e,o){var h=o.startOffset,g=o.endOffset,i=o.type,r=this.id3Track,l=this.hls;if(!!l){var c=l.config,t=c.enableEmsgMetadataCues,a=c.enableID3MetadataCues;if(r&&(t||a)){var u;i==="audio"?u=function(d){return d.type===O.MetadataSchema.audioId3&&a}:i==="video"?u=function(d){return d.type===O.MetadataSchema.emsg&&t}:u=function(d){return d.type===O.MetadataSchema.audioId3&&a||d.type===O.MetadataSchema.emsg&&t},Object(D.removeCuesInRange)(r,h,g,u)}}},p.onLevelUpdated=function(e,o){var h=this,g=o.details;if(!(!this.media||!g.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var i=this.dateRangeCuesAppended,r=this.id3Track,l=g.dateRanges,c=Object.keys(l);if(r)for(var t=Object.keys(i).filter(function(B){return!c.includes(B)}),a=function(k){var U=t[k];Object.keys(i[U].cues).forEach(function(W){r.removeCue(i[U].cues[W])}),delete i[U]},u=t.length;u--;)a(u);var s=g.fragments[g.fragments.length-1];if(!(c.length===0||!Object(I.isFiniteNumber)(s==null?void 0:s.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var d=s.programDateTime/1e3-s.start,v=g.edge||s.end,S=y(),x=function(k){var U=c[k],W=l[U],G=i[U],z=(G==null?void 0:G.cues)||{},Y=(G==null?void 0:G.durationKnown)||!1,J=T(W.startDate,d),ee=v,X=W.endDate;if(X)ee=T(X,d),Y=!0;else if(W.endOnNext&&!Y){var q=c.reduce(function(re,he){var ve=l[he];return ve.class===W.class&&ve.id!==he&&ve.startDate>W.startDate&&re.push(ve),re},[]).sort(function(re,he){return re.startDate.getTime()-he.startDate.getTime()})[0];q&&(ee=T(q.startDate,d),Y=!0)}for(var ie=Object.keys(W.attr),ae=0;ae<ie.length;ae++){var te=ie[ae];if(!(te===R.DateRangeAttribute.ID||te===R.DateRangeAttribute.CLASS||te===R.DateRangeAttribute.START_DATE||te===R.DateRangeAttribute.DURATION||te===R.DateRangeAttribute.END_DATE||te===R.DateRangeAttribute.END_ON_NEXT)){var oe=z[te];if(oe)Y&&!G.durationKnown&&(oe.endTime=ee);else{var ue=W.attr[te];oe=new S(J,ee,""),(te===R.DateRangeAttribute.SCTE35_OUT||te===R.DateRangeAttribute.SCTE35_IN)&&(ue=A(ue)),oe.value={key:te,data:ue},oe.type=O.MetadataSchema.dateRange,h.id3Track.addCue(oe),z[te]=oe}}}i[U]={cues:z,dateRange:W,durationKnown:Y}},P=0;P<c.length;P++)x(P)}}},m}();b.default=E},"./src/controller/latency-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return O});var I=n("./src/errors.ts"),L=n("./src/events.ts"),D=n("./src/utils/logger.ts");function M(_,y){for(var T=0;T<y.length;T++){var A=y[T];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(_,A.key,A)}}function R(_,y,T){return y&&M(_.prototype,y),T&&M(_,T),Object.defineProperty(_,"prototype",{writable:!1}),_}var O=function(){function _(T){var A=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return A.timeupdate()},this.hls=T,this.config=T.config,this.registerListeners()}var y=_.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(L.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(L.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(L.Events.ERROR,this.onError)},y.onMediaAttached=function(A,E){this.media=E.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},y.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},y.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},y.onLevelUpdated=function(A,E){var m=E.details;this.levelDetails=m,m.advanced&&this.timeupdate(),!m.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(A,E){E.details===I.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,D.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},y.timeupdate=function(){var A=this.media,E=this.levelDetails;if(!(!A||!E)){this.currentTime=A.currentTime;var m=this.computeLatency();if(m!==null){this._latency=m;var p=this.config,f=p.lowLatencyMode,e=p.maxLiveSyncPlaybackRate;if(!(!f||e===1)){var o=this.targetLatency;if(o!==null){var h=m-o,g=Math.min(this.maxLatency,o+E.targetduration),i=h<g;if(E.live&&i&&h>.05&&this.forwardBufferLength>1){var r=Math.min(2,Math.max(1,e)),l=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;A.playbackRate=Math.min(r,Math.max(1,l))}else A.playbackRate!==1&&A.playbackRate!==0&&(A.playbackRate=1)}}}}},y.estimateLiveEdge=function(){var A=this.levelDetails;return A===null?null:A.edge+A.age},y.computeLatency=function(){var A=this.estimateLiveEdge();return A===null?null:A-this.currentTime},R(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var A=this.config,E=this.levelDetails;return A.liveMaxLatencyDuration!==void 0?A.liveMaxLatencyDuration:E?A.liveMaxLatencyDurationCount*E.targetduration:0}},{key:"targetLatency",get:function(){var A=this.levelDetails;if(A===null)return null;var E=A.holdBack,m=A.partHoldBack,p=A.targetduration,f=this.config,e=f.liveSyncDuration,o=f.liveSyncDurationCount,h=f.lowLatencyMode,g=this.hls.userConfig,i=h&&m||E;(g.liveSyncDuration||g.liveSyncDurationCount||i===0)&&(i=e!==void 0?e:o*p);var r=p,l=1;return i+Math.min(this.stallCount*l,r)}},{key:"liveSyncPosition",get:function(){var A=this.estimateLiveEdge(),E=this.targetLatency,m=this.levelDetails;if(A===null||E===null||m===null)return null;var p=m.edge,f=A-E-this.edgeStalled,e=p-m.totalduration,o=p-(this.config.lowLatencyMode&&m.partTarget||m.targetduration);return Math.min(Math.max(e,f),o)}},{key:"drift",get:function(){var A=this.levelDetails;return A===null?1:A.drift}},{key:"edgeStalled",get:function(){var A=this.levelDetails;if(A===null)return 0;var E=(this.config.lowLatencyMode&&A.partTarget||A.targetduration)*3;return Math.max(A.age-E,0)}},{key:"forwardBufferLength",get:function(){var A=this.media,E=this.levelDetails;if(!A||!E)return 0;var m=A.buffered.length;return(m?A.buffered.end(m-1):E.edge)-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return f});var I=n("./src/types/level.ts"),L=n("./src/events.ts"),D=n("./src/errors.ts"),M=n("./src/utils/codecs.ts"),R=n("./src/controller/level-helper.ts"),O=n("./src/controller/base-playlist-controller.ts"),_=n("./src/types/loader.ts");function y(){return y=Object.assign?Object.assign.bind():function(e){for(var o=1;o<arguments.length;o++){var h=arguments[o];for(var g in h)Object.prototype.hasOwnProperty.call(h,g)&&(e[g]=h[g])}return e},y.apply(this,arguments)}function T(e,o){for(var h=0;h<o.length;h++){var g=o[h];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(e,g.key,g)}}function A(e,o,h){return o&&T(e.prototype,o),h&&T(e,h),Object.defineProperty(e,"prototype",{writable:!1}),e}function E(e,o){e.prototype=Object.create(o.prototype),e.prototype.constructor=e,m(e,o)}function m(e,o){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,i){return g.__proto__=i,g},m(e,o)}var p=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),f=function(e){E(o,e);function o(g){var i;return i=e.call(this,g,"[level-controller]")||this,i._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.onParsedComplete=void 0,i._registerListeners(),i}var h=o.prototype;return h._registerListeners=function(){var i=this.hls;i.on(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(L.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(L.Events.ERROR,this.onError,this)},h._unregisterListeners=function(){var i=this.hls;i.off(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(L.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(L.Events.ERROR,this.onError,this)},h.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},h.startLoad=function(){var i=this._levels;i.forEach(function(r){r.loadError=0}),e.prototype.startLoad.call(this)},h.onManifestLoaded=function(i,r){var l=[],c=[],t=[],a,u={},s,d=!1,v=!1,S=!1;if(r.levels.forEach(function(k){var U=k.attrs;d=d||!!(k.width&&k.height),v=v||!!k.videoCodec,S=S||!!k.audioCodec,p&&k.audioCodec&&k.audioCodec.indexOf("mp4a.40.34")!==-1&&(k.audioCodec=void 0);var W=k.bitrate+"-"+k.attrs.RESOLUTION+"-"+k.attrs.CODECS;s=u[W],s?s.url.push(k.url):(s=new I.Level(k),u[W]=s,l.push(s)),U&&(U.AUDIO&&Object(R.addGroupId)(s,"audio",U.AUDIO),U.SUBTITLES&&Object(R.addGroupId)(s,"text",U.SUBTITLES))}),(d||v)&&S&&(l=l.filter(function(k){var U=k.videoCodec,W=k.width,G=k.height;return!!U||!!(W&&G)})),l=l.filter(function(k){var U=k.audioCodec,W=k.videoCodec;return(!U||Object(M.isCodecSupportedInMp4)(U,"audio"))&&(!W||Object(M.isCodecSupportedInMp4)(W,"video"))}),r.audioTracks&&(c=r.audioTracks.filter(function(k){return!k.audioCodec||Object(M.isCodecSupportedInMp4)(k.audioCodec,"audio")}),Object(R.assignTrackIdsByGroup)(c)),r.subtitles&&(t=r.subtitles,Object(R.assignTrackIdsByGroup)(t)),l.length>0){a=l[0].bitrate,l.sort(function(k,U){return k.bitrate-U.bitrate}),this._levels=l;for(var x=0;x<l.length;x++)if(l[x].bitrate===a){this._firstLevel=x,this.log("manifest loaded, "+l.length+" level(s) found, first bitrate: "+a);break}var P=S&&!v,B={levels:l,audioTracks:c,subtitleTracks:t,firstLevel:this._firstLevel,stats:r.stats,audio:S,video:v,altAudio:!P&&c.some(function(k){return!!k.url})};this.hls.trigger(L.Events.MANIFEST_PARSED,B),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(L.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,reason:"no level with compatible codecs found in manifest"})},h.onError=function(i,r){var l;if(e.prototype.onError.call(this,i,r),!r.fatal){var c=r.context,t=this._levels[this.currentLevelIndex];if(c&&(c.type===_.PlaylistContextType.AUDIO_TRACK&&t.audioGroupIds&&c.groupId===t.audioGroupIds[t.urlId]||c.type===_.PlaylistContextType.SUBTITLE_TRACK&&t.textGroupIds&&c.groupId===t.textGroupIds[t.urlId])){this.redundantFailover(this.currentLevelIndex);return}var a=!1,u=!0,s;switch(r.details){case D.ErrorDetails.FRAG_LOAD_ERROR:case D.ErrorDetails.FRAG_LOAD_TIMEOUT:case D.ErrorDetails.KEY_LOAD_ERROR:case D.ErrorDetails.KEY_LOAD_TIMEOUT:if(r.frag){var d=r.frag.type===_.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,v=this._levels[d];v?(v.fragmentError++,v.fragmentError>this.hls.config.fragLoadingMaxRetry&&(s=d)):s=d}break;case D.ErrorDetails.LEVEL_LOAD_ERROR:case D.ErrorDetails.LEVEL_LOAD_TIMEOUT:c&&(c.deliveryDirectives&&(u=!1),s=c.level),a=!0;break;case D.ErrorDetails.REMUX_ALLOC_ERROR:s=(l=r.level)!=null?l:this.currentLevelIndex,a=!0;break}s!==void 0&&this.recoverLevel(r,s,a,u)}},h.recoverLevel=function(i,r,l,c){var t=i.details,a=this._levels[r];if(a.loadError++,l){var u=this.retryLoadingOrFail(i);if(u)i.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(c){var s=a.url.length;if(s>1&&a.loadError<s)i.levelRetry=!0,this.redundantFailover(r);else if(this.manualLevelIndex===-1){for(var d=-1,v=this._levels,S=v.length;S--;){var x=(S+this.currentLevelIndex)%v.length;if(x!==this.currentLevelIndex&&v[x].loadError===0){d=x;break}}d>-1&&this.currentLevelIndex!==d&&(this.warn(t+": switch to "+d),i.levelRetry=!0,this.hls.nextAutoLevel=d)}}},h.redundantFailover=function(i){var r=this._levels[i],l=r.url.length;if(l>1){var c=(r.urlId+1)%l;this.warn("Switching to redundant URL-id "+c),this._levels.forEach(function(t){t.urlId=c}),this.level=i}},h.onFragLoaded=function(i,r){var l=r.frag;if(l!==void 0&&l.type===_.PlaylistLevelType.MAIN){var c=this._levels[l.level];c!==void 0&&(c.fragmentError=0,c.loadError=0)}},h.onLevelLoaded=function(i,r){var l,c=r.level,t=r.details,a=this._levels[c];if(!a){var u;this.warn("Invalid level index "+c),(u=r.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(t.deltaUpdateFailed=!0);return}c===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0,this.retryCount=0),this.playlistLoaded(c,r,a.details)):(l=r.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(t.deltaUpdateFailed=!0)},h.onAudioTrackSwitched=function(i,r){var l=this.hls.levels[this.currentLevelIndex];if(!!l&&l.audioGroupIds){for(var c=-1,t=this.hls.audioTracks[r.id].groupId,a=0;a<l.audioGroupIds.length;a++)if(l.audioGroupIds[a]===t){c=a;break}c!==l.urlId&&(l.urlId=c,this.startLoad())}},h.loadPlaylist=function(i){var r=this.currentLevelIndex,l=this._levels[r];if(this.canLoad&&l&&l.url.length>0){var c=l.urlId,t=l.url[c];if(i)try{t=i.addDirectives(t)}catch(a){this.warn("Could not construct new URL with HLS Delivery Directives: "+a)}this.log("Attempt loading level index "+r+(i?" at sn "+i.msn+" part "+i.part:"")+" with URL-id "+c+" "+t),this.clearTimer(),this.hls.trigger(L.Events.LEVEL_LOADING,{url:t,level:r,id:c,deliveryDirectives:i||null})}},h.removeLevel=function(i,r){var l=function(a,u){return u!==r},c=this._levels.filter(function(t,a){return a!==i?!0:t.url.length>1&&r!==void 0?(t.url=t.url.filter(l),t.audioGroupIds&&(t.audioGroupIds=t.audioGroupIds.filter(l)),t.textGroupIds&&(t.textGroupIds=t.textGroupIds.filter(l)),t.urlId=0,!0):!1}).map(function(t,a){var u=t.details;return u!=null&&u.fragments&&u.fragments.forEach(function(s){s.level=a}),t});this._levels=c,this.hls.trigger(L.Events.LEVELS_UPDATED,{levels:c})},A(o,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(i){var r,l=this._levels;if(l.length!==0&&!(this.currentLevelIndex===i&&(r=l[i])!==null&&r!==void 0&&r.details)){if(i<0||i>=l.length){var c=i<0;if(this.hls.trigger(L.Events.ERROR,{type:D.ErrorTypes.OTHER_ERROR,details:D.ErrorDetails.LEVEL_SWITCH_ERROR,level:i,fatal:c,reason:"invalid level idx"}),c)return;i=Math.min(i,l.length-1)}this.clearTimer();var t=this.currentLevelIndex,a=l[t],u=l[i];this.log("switching to level "+i+" from "+t),this.currentLevelIndex=i;var s=y({},u,{level:i,maxBitrate:u.maxBitrate,uri:u.uri,urlId:u.urlId});delete s._urlId,this.hls.trigger(L.Events.LEVEL_SWITCHING,s);var d=u.details;if(!d||d.live){var v=this.switchParams(u.uri,a==null?void 0:a.details);this.loadPlaylist(v)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(i){this.manualLevelIndex=i,this._startLevel===void 0&&(this._startLevel=i),i!==-1&&(this.level=i)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(i){this._firstLevel=i}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var i=this.hls.config.startLevel;return i!==void 0?i:this._firstLevel}else return this._startLevel},set:function(i){this._startLevel=i}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(i){this.level=i,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=i)}}]),o}(O.default)},"./src/controller/level-helper.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"addGroupId",function(){return R}),n.d(b,"assignTrackIdsByGroup",function(){return O}),n.d(b,"updatePTS",function(){return _}),n.d(b,"updateFragPTSDTS",function(){return T}),n.d(b,"mergeDetails",function(){return A}),n.d(b,"mapPartIntersection",function(){return m}),n.d(b,"mapFragmentIntersection",function(){return p}),n.d(b,"adjustSliding",function(){return f}),n.d(b,"addSliding",function(){return e}),n.d(b,"computeReloadInterval",function(){return o}),n.d(b,"getFragmentWithSN",function(){return h}),n.d(b,"getPartWith",function(){return g});var I=n("./src/polyfills/number.ts"),L=n("./src/utils/logger.ts"),D=n("./src/loader/date-range.ts");function M(){return M=Object.assign?Object.assign.bind():function(i){for(var r=1;r<arguments.length;r++){var l=arguments[r];for(var c in l)Object.prototype.hasOwnProperty.call(l,c)&&(i[c]=l[c])}return i},M.apply(this,arguments)}function R(i,r,l){switch(r){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(l);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(l);break}}function O(i){var r={};i.forEach(function(l){var c=l.groupId||"";l.id=r[c]=r[c]||0,r[c]++})}function _(i,r,l){var c=i[r],t=i[l];y(c,t)}function y(i,r){var l=r.startPTS;if(Object(I.isFiniteNumber)(l)){var c=0,t;r.sn>i.sn?(c=l-i.start,t=i):(c=i.start-l,t=r),t.duration!==c&&(t.duration=c)}else if(r.sn>i.sn){var a=i.cc===r.cc;a&&i.minEndPTS?r.start=i.start+(i.minEndPTS-i.start):r.start=i.start+i.duration}else r.start=Math.max(i.start-r.duration,0)}function T(i,r,l,c,t,a){var u=c-l;u<=0&&(L.logger.warn("Fragment should have a positive duration",r),c=l+r.duration,a=t+r.duration);var s=l,d=c,v=r.startPTS,S=r.endPTS;if(Object(I.isFiniteNumber)(v)){var x=Math.abs(v-l);Object(I.isFiniteNumber)(r.deltaPTS)?r.deltaPTS=Math.max(x,r.deltaPTS):r.deltaPTS=x,s=Math.max(l,v),l=Math.min(l,v),t=Math.min(t,r.startDTS),d=Math.min(c,S),c=Math.max(c,S),a=Math.max(a,r.endDTS)}r.duration=c-l;var P=l-r.start;r.appendedPTS=c,r.start=r.startPTS=l,r.maxStartPTS=s,r.startDTS=t,r.endPTS=c,r.minEndPTS=d,r.endDTS=a;var B=r.sn;if(!i||B<i.startSN||B>i.endSN)return 0;var k,U=B-i.startSN,W=i.fragments;for(W[U]=r,k=U;k>0;k--)y(W[k],W[k-1]);for(k=U;k<W.length-1;k++)y(W[k],W[k+1]);return i.fragmentHint&&y(W[W.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,P}function A(i,r){for(var l=null,c=i.fragments,t=c.length-1;t>=0;t--){var a=c[t].initSegment;if(a){l=a;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var u=0,s;if(p(i,r,function(k,U){k.relurl&&(u=k.cc-U.cc),Object(I.isFiniteNumber)(k.startPTS)&&Object(I.isFiniteNumber)(k.endPTS)&&(U.start=U.startPTS=k.startPTS,U.startDTS=k.startDTS,U.appendedPTS=k.appendedPTS,U.maxStartPTS=k.maxStartPTS,U.endPTS=k.endPTS,U.endDTS=k.endDTS,U.minEndPTS=k.minEndPTS,U.duration=k.endPTS-k.startPTS,U.duration&&(s=U),r.PTSKnown=r.alignedSliding=!0),U.elementaryStreams=k.elementaryStreams,U.loader=k.loader,U.stats=k.stats,U.urlId=k.urlId,k.initSegment&&(U.initSegment=k.initSegment,l=k.initSegment)}),l){var d=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments;d.forEach(function(k){var U;(!k.initSegment||k.initSegment.relurl===((U=l)===null||U===void 0?void 0:U.relurl))&&(k.initSegment=l)})}if(r.skippedSegments)if(r.deltaUpdateFailed=r.fragments.some(function(k){return!k}),r.deltaUpdateFailed){L.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var v=r.skippedSegments;v--;)r.fragments.shift();r.startSN=r.fragments[0].sn,r.startCC=r.fragments[0].cc}else r.canSkipDateRanges&&(r.dateRanges=E(i.dateRanges,r.dateRanges,r.recentlyRemovedDateranges));var S=r.fragments;if(u){L.logger.warn("discontinuity sliding from playlist, take drift into account");for(var x=0;x<S.length;x++)S[x].cc+=u}r.skippedSegments&&(r.startCC=r.fragments[0].cc),m(i.partList,r.partList,function(k,U){U.elementaryStreams=k.elementaryStreams,U.stats=k.stats}),s?T(r,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):f(i,r),S.length&&(r.totalduration=r.edge-S[0].start),r.driftStartTime=i.driftStartTime,r.driftStart=i.driftStart;var P=r.advancedDateTime;if(r.advanced&&P){var B=r.edge;r.driftStart||(r.driftStartTime=P,r.driftStart=B),r.driftEndTime=P,r.driftEnd=B}else r.driftEndTime=i.driftEndTime,r.driftEnd=i.driftEnd,r.advancedDateTime=i.advancedDateTime}function E(i,r,l){var c=M({},i);return l&&l.forEach(function(t){delete c[t]}),Object.keys(r).forEach(function(t){var a=new D.DateRange(r[t].attr,c[t]);a.isValid?c[t]=a:L.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(r[t].attr)+'"')}),c}function m(i,r,l){if(i&&r)for(var c=0,t=0,a=i.length;t<=a;t++){var u=i[t],s=r[t+c];u&&s&&u.index===s.index&&u.fragment.sn===s.fragment.sn?l(u,s):c--}}function p(i,r,l){for(var c=r.skippedSegments,t=Math.max(i.startSN,r.startSN)-r.startSN,a=(i.fragmentHint?1:0)+(c?r.endSN:Math.min(i.endSN,r.endSN))-r.startSN,u=r.startSN-i.startSN,s=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments,d=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,v=t;v<=a;v++){var S=d[u+v],x=s[v];c&&!x&&v<c&&(x=r.fragments[v]=S),S&&x&&l(S,x)}}function f(i,r){var l=r.startSN+r.skippedSegments-i.startSN,c=i.fragments;l<0||l>=c.length||e(r,c[l].start)}function e(i,r){if(r){for(var l=i.fragments,c=i.skippedSegments;c<l.length;c++)l[c].start+=r;i.fragmentHint&&(i.fragmentHint.start+=r)}}function o(i,r){var l=1e3*i.levelTargetDuration,c=l/2,t=i.age,a=t>0&&t<l*3,u=r.loading.end-r.loading.start,s,d=i.availabilityDelay;if(i.updated===!1)if(a){var v=333*i.misses;s=Math.max(Math.min(c,u*2),v),i.availabilityDelay=(i.availabilityDelay||0)+s}else s=c;else a?(d=Math.min(d||l/2,t),i.availabilityDelay=d,s=d+l-t):s=l-u;return Math.round(s)}function h(i,r,l){if(!i||!i.details)return null;var c=i.details,t=c.fragments[r-c.startSN];return t||(t=c.fragmentHint,t&&t.sn===r)?t:r<c.startSN&&l&&l.sn===r?l:null}function g(i,r,l){if(!i||!i.details)return null;var c=i.details.partList;if(c)for(var t=c.length;t--;){var a=c[t];if(a.index===l&&a.fragment.sn===r)return a}return null}},"./src/controller/stream-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return g});var I=n("./src/polyfills/number.ts"),L=n("./src/controller/base-stream-controller.ts"),D=n("./src/is-supported.ts"),M=n("./src/events.ts"),R=n("./src/utils/buffer-helper.ts"),O=n("./src/controller/fragment-tracker.ts"),_=n("./src/types/loader.ts"),y=n("./src/loader/fragment.ts"),T=n("./src/demux/transmuxer-interface.ts"),A=n("./src/types/transmuxer.ts"),E=n("./src/controller/gap-controller.ts"),m=n("./src/errors.ts");function p(i,r){for(var l=0;l<r.length;l++){var c=r[l];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(i,c.key,c)}}function f(i,r,l){return r&&p(i.prototype,r),l&&p(i,l),Object.defineProperty(i,"prototype",{writable:!1}),i}function e(i,r){i.prototype=Object.create(r.prototype),i.prototype.constructor=i,o(i,r)}function o(i,r){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,t){return c.__proto__=t,c},o(i,r)}var h=100,g=function(i){e(r,i);function r(c,t){var a;return a=i.call(this,c,t,"[stream-controller]")||this,a.audioCodecSwap=!1,a.gapController=null,a.level=-1,a._forceStartLoad=!1,a.altAudio=!1,a.audioOnly=!1,a.fragPlaying=null,a.onvplaying=null,a.onvseeked=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a._registerListeners(),a}var l=r.prototype;return l._registerListeners=function(){var t=this.hls;t.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(M.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(M.Events.ERROR,this.onError,this),t.on(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(M.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(M.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(M.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},l._unregisterListeners=function(){var t=this.hls;t.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(M.Events.ERROR,this.onError,this),t.off(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(M.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(M.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(M.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},l.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},l.startLoad=function(t){if(this.levels){var a=this.lastCurrentTime,u=this.hls;if(this.stopLoad(),this.setInterval(h),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var s=u.startLevel;s===-1&&(u.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=u.nextAutoLevel),this.level=u.nextLoadLevel=s,this.loadedmetadata=!1}a>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),t=a),this.state=L.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=L.State.STOPPED},l.stopLoad=function(){this._forceStartLoad=!1,i.prototype.stopLoad.call(this)},l.doTick=function(){switch(this.state){case L.State.IDLE:this.doTickIdle();break;case L.State.WAITING_LEVEL:{var t,a=this.levels,u=this.level,s=a==null||(t=a[u])===null||t===void 0?void 0:t.details;if(s&&(!s.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(s))break;this.state=L.State.IDLE;break}break}case L.State.FRAG_LOADING_WAITING_RETRY:{var d,v=self.performance.now(),S=this.retryDate;(!S||v>=S||(d=this.media)!==null&&d!==void 0&&d.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=L.State.IDLE)}break;default:break}this.onTickEnd()},l.onTickEnd=function(){i.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},l.doTickIdle=function(){var t,a,u=this.hls,s=this.levelLastLoaded,d=this.levels,v=this.media,S=u.config,x=u.nextLoadLevel;if(!(s===null||!v&&(this.startFragRequested||!S.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!d||!d[x])){var P=d[x];this.level=u.nextLoadLevel=x;var B=P.details;if(!B||this.state===L.State.WAITING_LEVEL||B.live&&this.levelLastLoaded!==x){this.state=L.State.WAITING_LEVEL;return}var k=this.getMainFwdBufferInfo();if(k!==null){var U=k.len,W=this.getMaxBufferLength(P.maxBitrate);if(!(U>=W)){if(this._streamEnded(k,B)){var G={};this.altAudio&&(G.type="video"),this.hls.trigger(M.Events.BUFFER_EOS,G),this.state=L.State.ENDED;return}this.backtrackFragment&&this.backtrackFragment.start>k.end&&(this.backtrackFragment=null);var z=this.backtrackFragment?this.backtrackFragment.start:k.end,Y=this.getNextFragment(z,B);if(this.couldBacktrack&&!this.fragPrevious&&Y&&Y.sn!=="initSegment"&&this.fragmentTracker.getState(Y)!==O.FragmentState.OK){var J,ee=((J=this.backtrackFragment)!=null?J:Y).sn,X=ee-B.startSN,q=B.fragments[X-1];q&&Y.cc===q.cc&&(Y=q,this.fragmentTracker.removeFragment(q))}else this.backtrackFragment&&k.len&&(this.backtrackFragment=null);if(Y&&this.fragmentTracker.getState(Y)===O.FragmentState.OK&&this.nextLoadPosition>z){var ie=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;v&&this.afterBufferFlushed(v,ie,_.PlaylistLevelType.MAIN),Y=this.getNextFragment(this.nextLoadPosition,B)}!Y||(Y.initSegment&&!Y.initSegment.data&&!this.bitrateTest&&(Y=Y.initSegment),((t=Y.decryptdata)===null||t===void 0?void 0:t.keyFormat)==="identity"&&!((a=Y.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(Y,B):this.loadFragment(Y,B,z))}}}},l.loadFragment=function(t,a,u){var s,d=this.fragmentTracker.getState(t);this.fragCurrent=t,d===O.FragmentState.NOT_LOADED?t.sn==="initSegment"?this._loadInitSegment(t):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t)):(this.startFragRequested=!0,i.prototype.loadFragment.call(this,t,a,u)):d===O.FragmentState.APPENDING?this.reduceMaxBufferLength(t.duration)&&this.fragmentTracker.removeFragment(t):((s=this.media)===null||s===void 0?void 0:s.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},l.getAppendedFrag=function(t){var a=this.fragmentTracker.getAppendedFrag(t,_.PlaylistLevelType.MAIN);return a&&"fragment"in a?a.fragment:a},l.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,_.PlaylistLevelType.MAIN)},l.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},l.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},l.nextLevelSwitch=function(){var t=this.levels,a=this.media;if(a!=null&&a.readyState){var u,s=this.getAppendedFrag(a.currentTime);if(s&&s.start>1&&this.flushMainBuffer(0,s.start-1),!a.paused&&t){var d=this.hls.nextLoadLevel,v=t[d],S=this.fragLastKbps;S&&this.fragCurrent?u=this.fragCurrent.duration*v.maxBitrate/(1e3*S)+1:u=0}else u=0;var x=this.getBufferedFrag(a.currentTime+u);if(x){var P=this.followingBufferedFrag(x);if(P){this.abortCurrentFrag();var B=P.maxStartPTS?P.maxStartPTS:P.start,k=P.duration,U=Math.max(x.end,B+Math.min(Math.max(k-this.config.maxFragLookUpTolerance,k*.5),k*.75));this.flushMainBuffer(U,Number.POSITIVE_INFINITY)}}}},l.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t!=null&&t.loader&&t.loader.abort(),this.state){case L.State.KEY_LOADING:case L.State.FRAG_LOADING:case L.State.FRAG_LOADING_WAITING_RETRY:case L.State.PARSING:case L.State.PARSED:this.state=L.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},l.flushMainBuffer=function(t,a){i.prototype.flushMainBuffer.call(this,t,a,this.altAudio?"video":null)},l.onMediaAttached=function(t,a){i.prototype.onMediaAttached.call(this,t,a);var u=a.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),u.addEventListener("playing",this.onvplaying),u.addEventListener("seeked",this.onvseeked),this.gapController=new E.default(this.config,u,this.fragmentTracker,this.hls)},l.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),i.prototype.onMediaDetaching.call(this)},l.onMediaPlaying=function(){this.tick()},l.onMediaSeeked=function(){var t=this.media,a=t?t.currentTime:null;Object(I.isFiniteNumber)(a)&&this.log("Media seeked to "+a.toFixed(3)),this.tick()},l.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(M.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},l.onManifestParsed=function(t,a){var u=!1,s=!1,d;a.levels.forEach(function(v){d=v.audioCodec,d&&(d.indexOf("mp4a.40.2")!==-1&&(u=!0),d.indexOf("mp4a.40.5")!==-1&&(s=!0))}),this.audioCodecSwitch=u&&s&&!Object(D.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=a.levels,this.startFragRequested=!1},l.onLevelLoading=function(t,a){var u=this.levels;if(!(!u||this.state!==L.State.IDLE)){var s=u[a.level];(!s.details||s.details.live&&this.levelLastLoaded!==a.level||this.waitForCdnTuneIn(s.details))&&(this.state=L.State.WAITING_LEVEL)}},l.onLevelLoaded=function(t,a){var u,s=this.levels,d=a.level,v=a.details,S=v.totalduration;if(!s){this.warn("Levels were reset while loading level "+d);return}this.log("Level "+d+" loaded ["+v.startSN+","+v.endSN+"], cc ["+v.startCC+", "+v.endCC+"] duration:"+S);var x=this.fragCurrent;x&&(this.state===L.State.FRAG_LOADING||this.state===L.State.FRAG_LOADING_WAITING_RETRY)&&x.level!==a.level&&x.loader&&(this.state=L.State.IDLE,this.backtrackFragment=null,x.loader.abort());var P=s[d],B=0;if(v.live||(u=P.details)!==null&&u!==void 0&&u.live){if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed)return;B=this.alignPlaylists(v,P.details)}if(P.details=v,this.levelLastLoaded=d,this.hls.trigger(M.Events.LEVEL_UPDATED,{details:v,level:d}),this.state===L.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(v))return;this.state=L.State.IDLE}this.startFragRequested?v.live&&this.synchronizeToLiveEdge(v):this.setStartPosition(v,B),this.tick()},l._handleFragmentLoadProgress=function(t){var a,u=t.frag,s=t.part,d=t.payload,v=this.levels;if(!v){this.warn("Levels were reset while fragment load was in progress. Fragment "+u.sn+" of level "+u.level+" will not be buffered");return}var S=v[u.level],x=S.details;if(!x){this.warn("Dropping fragment "+u.sn+" of level "+u.level+" after level details were reset");return}var P=S.videoCodec,B=x.PTSKnown||!x.live,k=(a=u.initSegment)===null||a===void 0?void 0:a.data,U=this._getAudioCodec(S),W=this.transmuxer=this.transmuxer||new T.default(this.hls,_.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),G=s?s.index:-1,z=G!==-1,Y=new A.ChunkMetadata(u.level,u.sn,u.stats.chunkCount,d.byteLength,G,z),J=this.initPTS[u.cc];W.push(d,k,U,P,u,s,x.totalduration,B,Y,J)},l.onAudioTrackSwitching=function(t,a){var u=this.altAudio,s=!!a.url,d=a.id;if(!s){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var v=this.fragCurrent;v!=null&&v.loader&&(this.log("Switching to main audio track, cancel main fragment load"),v.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var S=this.hls;u&&S.trigger(M.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),S.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:d})}},l.onAudioTrackSwitched=function(t,a){var u=a.id,s=!!this.hls.audioTracks[u].url;if(s){var d=this.videoBuffer;d&&this.mediaBuffer!==d&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=d)}this.altAudio=s,this.tick()},l.onBufferCreated=function(t,a){var u=a.tracks,s,d,v=!1;for(var S in u){var x=u[S];if(x.id==="main"){if(d=S,s=x,S==="video"){var P=u[S];P&&(this.videoBuffer=P.buffer)}}else v=!0}v&&s?(this.log("Alternate track found, use "+d+".buffered to schedule main fragment loading"),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media},l.onFragBuffered=function(t,a){var u=a.frag,s=a.part;if(!(u&&u.type!==_.PlaylistLevelType.MAIN)){if(this.fragContextChanged(u)){this.warn("Fragment "+u.sn+(s?" p: "+s.index:"")+" of level "+u.level+" finished buffering, but was aborted. state: "+this.state),this.state===L.State.PARSED&&(this.state=L.State.IDLE);return}var d=s?s.stats:u.stats;this.fragLastKbps=Math.round(8*d.total/(d.buffering.end-d.loading.first)),u.sn!=="initSegment"&&(this.fragPrevious=u),this.fragBufferedComplete(u,s)}},l.onError=function(t,a){switch(a.details){case m.ErrorDetails.FRAG_LOAD_ERROR:case m.ErrorDetails.FRAG_LOAD_TIMEOUT:case m.ErrorDetails.KEY_LOAD_ERROR:case m.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.MAIN,a);break;case m.ErrorDetails.LEVEL_LOAD_ERROR:case m.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==L.State.ERROR&&(a.fatal?(this.warn(""+a.details),this.state=L.State.ERROR):!a.levelRetry&&this.state===L.State.WAITING_LEVEL&&(this.state=L.State.IDLE));break;case m.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="main"&&(this.state===L.State.PARSING||this.state===L.State.PARSED)){var u=!0,s=this.getFwdBufferInfo(this.media,_.PlaylistLevelType.MAIN);s&&s.len>.5&&(u=!this.reduceMaxBufferLength(s.len)),u&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},l.checkBuffer=function(){var t=this.media,a=this.gapController;if(!(!t||!a||!t.readyState)){if(this.loadedmetadata||!R.BufferHelper.getBuffered(t).length){var u=this.state!==L.State.IDLE?this.fragCurrent:null;a.poll(this.lastCurrentTime,u)}this.lastCurrentTime=t.currentTime}},l.onFragLoadEmergencyAborted=function(){this.state=L.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},l.onBufferFlushed=function(t,a){var u=a.type;if(u!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var s=(u===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(s,u,_.PlaylistLevelType.MAIN)}},l.onLevelsUpdated=function(t,a){this.levels=a.levels},l.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},l.seekToStartPos=function(){var t=this.media;if(!!t){var a=t.currentTime,u=this.startPosition;if(u>=0&&a<u){if(t.seeking){this.log("could not seek to "+u+", already seeking at "+a);return}var s=R.BufferHelper.getBuffered(t),d=s.length?s.start(0):0,v=d-u;v>0&&(v<this.config.maxBufferHole||v<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+v+" to match buffer start"),u+=v,this.startPosition=u),this.log("seek to target start position "+u+" from current time "+a),t.currentTime=u}}},l._getAudioCodec=function(t){var a=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&a&&(this.log("Swapping audio codec"),a.indexOf("mp4a.40.5")!==-1?a="mp4a.40.2":a="mp4a.40.5"),a},l._loadBitrateTestFrag=function(t){var a=this;t.bitrateTest=!0,this._doFragLoad(t).then(function(u){var s=a.hls;if(!(!u||s.nextLoadLevel||a.fragContextChanged(t))){a.fragLoadError=0,a.state=L.State.IDLE,a.startFragRequested=!1,a.bitrateTest=!1;var d=t.stats;d.parsing.start=d.parsing.end=d.buffering.start=d.buffering.end=self.performance.now(),s.trigger(M.Events.FRAG_LOADED,u),t.bitrateTest=!1}})},l._handleTransmuxComplete=function(t){var a,u="main",s=this.hls,d=t.remuxResult,v=t.chunkMeta,S=this.getCurrentContext(v);if(!S){this.warn("The loading context changed while buffering fragment "+v.sn+" of level "+v.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(v.level);return}var x=S.frag,P=S.part,B=S.level,k=d.video,U=d.text,W=d.id3,G=d.initSegment,z=B.details,Y=this.altAudio?void 0:d.audio;if(!this.fragContextChanged(x)){if(this.state=L.State.PARSING,G){G.tracks&&(this._bufferInitSegment(B,G.tracks,x,v),s.trigger(M.Events.FRAG_PARSING_INIT_SEGMENT,{frag:x,id:u,tracks:G.tracks}));var J=G.initPTS,ee=G.timescale;Object(I.isFiniteNumber)(J)&&(this.initPTS[x.cc]=J,s.trigger(M.Events.INIT_PTS_FOUND,{frag:x,id:u,initPTS:J,timescale:ee}))}if(k&&d.independent!==!1){if(z){var X=k.startPTS,q=k.endPTS,ie=k.startDTS,ae=k.endDTS;if(P)P.elementaryStreams[k.type]={startPTS:X,endPTS:q,startDTS:ie,endDTS:ae};else if(k.firstKeyFrame&&k.independent&&(this.couldBacktrack=!0),k.dropped&&k.independent){var te=this.getMainFwdBufferInfo(),oe=(te?te.end:this.getLoadPosition())+this.config.maxBufferHole,ue=k.firstKeyFramePTS?k.firstKeyFramePTS:X;if(oe<ue-this.config.maxBufferHole){this.backtrack(x);return}x.setElementaryStreamInfo(k.type,x.start,q,x.start,ae,!0)}x.setElementaryStreamInfo(k.type,X,q,ie,ae),this.backtrackFragment&&(this.backtrackFragment=x),this.bufferFragmentData(k,x,P,v)}}else if(d.independent===!1){this.backtrack(x);return}if(Y){var re=Y.startPTS,he=Y.endPTS,ve=Y.startDTS,Se=Y.endDTS;P&&(P.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:re,endPTS:he,startDTS:ve,endDTS:Se}),x.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,re,he,ve,Se),this.bufferFragmentData(Y,x,P,v)}if(z&&W!==null&&W!==void 0&&(a=W.samples)!==null&&a!==void 0&&a.length){var Me={id:u,frag:x,details:z,samples:W.samples};s.trigger(M.Events.FRAG_PARSING_METADATA,Me)}if(z&&U){var Oe={id:u,frag:x,details:z,samples:U.samples};s.trigger(M.Events.FRAG_PARSING_USERDATA,Oe)}}},l._bufferInitSegment=function(t,a,u,s){var d=this;if(this.state===L.State.PARSING){this.audioOnly=!!a.audio&&!a.video,this.altAudio&&!this.audioOnly&&delete a.audio;var v=a.audio,S=a.video,x=a.audiovideo;if(v){var P=t.audioCodec,B=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(P&&(P.indexOf("mp4a.40.5")!==-1?P="mp4a.40.2":P="mp4a.40.5"),v.metadata.channelCount!==1&&B.indexOf("firefox")===-1&&(P="mp4a.40.5")),B.indexOf("android")!==-1&&v.container!=="audio/mpeg"&&(P="mp4a.40.2",this.log("Android: force audio codec to "+P)),t.audioCodec&&t.audioCodec!==P&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+P+'"'),v.levelCodec=P,v.id="main",this.log("Init audio buffer, container:"+v.container+", codecs[selected/level/parsed]=["+(P||"")+"/"+(t.audioCodec||"")+"/"+v.codec+"]")}S&&(S.levelCodec=t.videoCodec,S.id="main",this.log("Init video buffer, container:"+S.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+S.codec+"]")),x&&this.log("Init audiovideo buffer, container:"+x.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+x.codec+"]"),this.hls.trigger(M.Events.BUFFER_CODECS,a),Object.keys(a).forEach(function(k){var U=a[k],W=U.initSegment;W!=null&&W.byteLength&&d.hls.trigger(M.Events.BUFFER_APPENDING,{type:k,data:W,frag:u,part:null,chunkMeta:s,parent:u.type})}),this.tick()}},l.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,_.PlaylistLevelType.MAIN)},l.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=L.State.IDLE},l.checkFragmentChanged=function(){var t=this.media,a=null;if(t&&t.readyState>1&&t.seeking===!1){var u=t.currentTime;if(R.BufferHelper.isBuffered(t,u)?a=this.getAppendedFrag(u):R.BufferHelper.isBuffered(t,u+.1)&&(a=this.getAppendedFrag(u+.1)),a){this.backtrackFragment=null;var s=this.fragPlaying,d=a.level;(!s||a.sn!==s.sn||s.level!==d||a.urlId!==s.urlId)&&(this.hls.trigger(M.Events.FRAG_CHANGED,{frag:a}),(!s||s.level!==d)&&this.hls.trigger(M.Events.LEVEL_SWITCHED,{level:d}),this.fragPlaying=a)}}},f(r,[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var a=t.currentTime,u=this.currentFrag;if(u&&Object(I.isFiniteNumber)(a)&&Object(I.isFiniteNumber)(u.programDateTime)){var s=u.programDateTime+(a-u.start)*1e3;return new Date(s)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),r}(L.default)},"./src/controller/subtitle-stream-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"SubtitleStreamController",function(){return e});var I=n("./src/events.ts"),L=n("./src/utils/buffer-helper.ts"),D=n("./src/controller/fragment-finders.ts"),M=n("./src/utils/discontinuities.ts"),R=n("./src/controller/level-helper.ts"),O=n("./src/controller/fragment-tracker.ts"),_=n("./src/controller/base-stream-controller.ts"),y=n("./src/types/loader.ts"),T=n("./src/types/level.ts");function A(h,g){for(var i=0;i<g.length;i++){var r=g[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(h,r.key,r)}}function E(h,g,i){return g&&A(h.prototype,g),i&&A(h,i),Object.defineProperty(h,"prototype",{writable:!1}),h}function m(h,g){h.prototype=Object.create(g.prototype),h.prototype.constructor=h,p(h,g)}function p(h,g){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,l){return r.__proto__=l,r},p(h,g)}var f=500,e=function(h){m(g,h);function g(r,l){var c;return c=h.call(this,r,l,"[subtitle-stream-controller]")||this,c.levels=[],c.currentTrackId=-1,c.tracksBuffered=[],c.mainDetails=null,c._registerListeners(),c}var i=g.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var l=this.hls;l.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(I.Events.ERROR,this.onError,this),l.on(I.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(I.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.on(I.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.on(I.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.on(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var l=this.hls;l.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(I.Events.ERROR,this.onError,this),l.off(I.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.off(I.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.off(I.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.off(I.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.off(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.startLoad=function(){this.stopLoad(),this.state=_.State.IDLE,this.setInterval(f),this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onLevelLoaded=function(l,c){this.mainDetails=c.details},i.onSubtitleFragProcessed=function(l,c){var t=c.frag,a=c.success;if(this.fragPrevious=t,this.state=_.State.IDLE,!!a){var u=this.tracksBuffered[this.currentTrackId];if(!!u){for(var s,d=t.start,v=0;v<u.length;v++)if(d>=u[v].start&&d<=u[v].end){s=u[v];break}var S=t.start+t.duration;s?s.end=S:(s={start:d,end:S},u.push(s)),this.fragmentTracker.fragBuffered(t)}}},i.onBufferFlushing=function(l,c){var t=c.startOffset,a=c.endOffset;if(t===0&&a!==Number.POSITIVE_INFINITY){var u=this.currentTrackId,s=this.levels;if(!s.length||!s[u]||!s[u].details)return;var d=s[u].details,v=d.targetduration,S=a-v;if(S<=0)return;c.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(x){for(var P=0;P<x.length;){if(x[P].end<=S){x.shift();continue}else if(x[P].start<S)x[P].start=S;else break;P++}}),this.fragmentTracker.removeFragmentsInRange(t,S,y.PlaylistLevelType.SUBTITLE)}},i.onError=function(l,c){var t,a=c.frag;!a||a.type!==y.PlaylistLevelType.SUBTITLE||((t=this.fragCurrent)!==null&&t!==void 0&&t.loader&&this.fragCurrent.loader.abort(),this.state=_.State.IDLE)},i.onSubtitleTracksUpdated=function(l,c){var t=this,a=c.subtitleTracks;this.tracksBuffered=[],this.levels=a.map(function(u){return new T.Level(u)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(u){t.tracksBuffered[u.id]=[]}),this.mediaBuffer=null},i.onSubtitleTrackSwitch=function(l,c){if(this.currentTrackId=c.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var t=this.levels[this.currentTrackId];t!=null&&t.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,t&&this.setInterval(f)},i.onSubtitleTrackLoaded=function(l,c){var t,a=c.details,u=c.id,s=this.currentTrackId,d=this.levels;if(!!d.length){var v=d[s];if(!(u>=d.length||u!==s||!v)){if(this.mediaBuffer=this.mediaBufferTimeRanges,a.live||(t=v.details)!==null&&t!==void 0&&t.live){var S=this.mainDetails;if(a.deltaUpdateFailed||!S)return;var x=S.fragments[0];if(!v.details)a.hasProgramDateTime&&S.hasProgramDateTime?Object(M.alignMediaPlaylistByPDT)(a,S):x&&Object(R.addSliding)(a,x.start);else{var P=this.alignPlaylists(a,v.details);P===0&&x&&Object(R.addSliding)(a,x.start)}}if(v.details=a,this.levelLastLoaded=u,this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===_.State.IDLE){var B=Object(D.findFragmentByPTS)(null,a.fragments,this.media.currentTime,0);B||(this.warn("Subtitle playlist not aligned with playback"),v.details=void 0)}}}},i._handleFragmentLoadComplete=function(l){var c=l.frag,t=l.payload,a=c.decryptdata,u=this.hls;if(!this.fragContextChanged(c)&&t&&t.byteLength>0&&a&&a.key&&a.iv&&a.method==="AES-128"){var s=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(t),a.key.buffer,a.iv.buffer).then(function(d){var v=performance.now();u.trigger(I.Events.FRAG_DECRYPTED,{frag:c,payload:d,stats:{tstart:s,tdecrypt:v}})})}},i.doTick=function(){if(!this.media){this.state=_.State.IDLE;return}if(this.state===_.State.IDLE){var l=this.currentTrackId,c=this.levels;if(!c.length||!c[l]||!c[l].details)return;var t=c[l].details,a=t.targetduration,u=this.config,s=this.media,d=L.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],s.currentTime-a,u.maxBufferHole),v=d.end,S=d.len,x=this.getMaxBufferLength()+a;if(S>x)return;console.assert(t,"Subtitle track details are defined on idle subtitle stream controller tick");var P=t.fragments,B=P.length,k=t.edge,U,W=this.fragPrevious;if(v<k){var G=u.maxFragLookUpTolerance;U=Object(D.findFragmentByPTS)(W,P,Math.max(P[0].start,v),G),!U&&W&&W.start<P[0].start&&(U=P[0])}else U=P[B-1];if(U=this.mapToInitFragWhenRequired(U),!U||this.fragmentTracker.getState(U)!==O.FragmentState.NOT_LOADED)return;U.encrypted?this.loadKey(U,t):this.loadFragment(U,t,v)}},i.loadFragment=function(l,c,t){this.fragCurrent=l,l.sn==="initSegment"?this._loadInitSegment(l):h.prototype.loadFragment.call(this,l,c,t)},E(g,[{key:"mediaBufferTimeRanges",get:function(){return new o(this.tracksBuffered[this.currentTrackId]||[])}}]),g}(_.default),o=function(g){this.buffered=void 0;var i=function(l,c,t){if(c=c>>>0,c>t-1)throw new DOMException("Failed to execute '"+l+"' on 'TimeRanges': The index provided ("+c+") is greater than the maximum bound ("+t+")");return g[c][l]};this.buffered={get length(){return g.length},end:function(l){return i("end",l,g.length)},start:function(l){return i("start",l,g.length)}}}},"./src/controller/subtitle-track-controller.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/events.ts"),L=n("./src/utils/texttrack-utils.ts"),D=n("./src/controller/base-playlist-controller.ts"),M=n("./src/types/loader.ts");function R(E,m){for(var p=0;p<m.length;p++){var f=m[p];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(E,f.key,f)}}function O(E,m,p){return m&&R(E.prototype,m),p&&R(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}function _(E,m){E.prototype=Object.create(m.prototype),E.prototype.constructor=E,y(E,m)}function y(E,m){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,e){return f.__proto__=e,f},y(E,m)}var T=function(E){_(m,E);function m(f){var e;return e=E.call(this,f,"[subtitle-track-controller]")||this,e.media=null,e.tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.selectDefaultTrack=!0,e.queuedDefaultTrack=-1,e.trackChangeListener=function(){return e.onTextTracksChanged()},e.asyncPollTrackChange=function(){return e.pollTrackChange(0)},e.useTextTrackPolling=!1,e.subtitlePollingInterval=-1,e._subtitleDisplay=!0,e.registerListeners(),e}var p=m.prototype;return p.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,E.prototype.destroy.call(this)},p.registerListeners=function(){var e=this.hls;e.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(I.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(I.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(I.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(I.Events.ERROR,this.onError,this)},p.unregisterListeners=function(){var e=this.hls;e.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(I.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(I.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(I.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(I.Events.ERROR,this.onError,this)},p.onMediaAttached=function(e,o){this.media=o.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},p.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},p.onMediaDetaching=function(){if(!!this.media){self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var e=A(this.media.textTracks);e.forEach(function(o){Object(L.clearCurrentCues)(o)}),this.subtitleTrack=-1,this.media=null}},p.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},p.onManifestParsed=function(e,o){this.tracks=o.subtitleTracks},p.onSubtitleTrackLoaded=function(e,o){var h=o.id,g=o.details,i=this.trackId,r=this.tracksInGroup[i];if(!r){this.warn("Invalid subtitle track id "+h);return}var l=r.details;r.details=o.details,this.log("subtitle track "+h+" loaded ["+g.startSN+"-"+g.endSN+"]"),h===this.trackId&&(this.retryCount=0,this.playlistLoaded(h,o,l))},p.onLevelLoading=function(e,o){this.switchLevel(o.level)},p.onLevelSwitching=function(e,o){this.switchLevel(o.level)},p.switchLevel=function(e){var o=this.hls.levels[e];if(!!(o!=null&&o.textGroupIds)){var h=o.textGroupIds[o.urlId];if(this.groupId!==h){var g=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,i=this.tracks.filter(function(c){return!h||c.groupId===h});this.tracksInGroup=i;var r=this.findTrackId(g==null?void 0:g.name)||this.findTrackId();this.groupId=h;var l={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+h+'" group-id'),this.hls.trigger(I.Events.SUBTITLE_TRACKS_UPDATED,l),r!==-1&&this.setSubtitleTrack(r,g)}}},p.findTrackId=function(e){for(var o=this.tracksInGroup,h=0;h<o.length;h++){var g=o[h];if((!this.selectDefaultTrack||g.default)&&(!e||e===g.name))return g.id}return-1},p.onError=function(e,o){E.prototype.onError.call(this,e,o),!(o.fatal||!o.context)&&o.context.type===M.PlaylistContextType.SUBTITLE_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},p.loadPlaylist=function(e){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var h=o.id,g=o.groupId,i=o.url;if(e)try{i=e.addDirectives(i)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log("Loading subtitle playlist for id "+h),this.hls.trigger(I.Events.SUBTITLE_TRACK_LOADING,{url:i,id:h,groupId:g,deliveryDirectives:e||null})}},p.toggleTrackModes=function(e){var o=this,h=this.media,g=this.trackId;if(!!h){var i=A(h.textTracks),r=i.filter(function(t){return t.groupId===o.groupId});if(e===-1)[].slice.call(i).forEach(function(t){t.mode="disabled"});else{var l=r[g];l&&(l.mode="disabled")}var c=r[e];c&&(c.mode=this.subtitleDisplay?"showing":"hidden")}},p.setSubtitleTrack=function(e,o){var h,g=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(h=g[e])!==null&&h!==void 0&&h.details)||e<-1||e>=g.length)){this.clearTimer();var i=g[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,i){var r=i.id,l=i.groupId,c=l===void 0?"":l,t=i.name,a=i.type,u=i.url;this.hls.trigger(I.Events.SUBTITLE_TRACK_SWITCH,{id:r,groupId:c,name:t,type:a,url:u});var s=this.switchParams(i.url,o==null?void 0:o.details);this.loadPlaylist(s)}else this.hls.trigger(I.Events.SUBTITLE_TRACK_SWITCH,{id:e})}},p.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var e=-1,o=A(this.media.textTracks),h=0;h<o.length;h++)if(o[h].mode==="hidden")e=h;else if(o[h].mode==="showing"){e=h;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},O(m,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var o=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,o)}}]),m}(D.default);function A(E){for(var m=[],p=0;p<E.length;p++){var f=E[p];f.kind==="subtitles"&&f.label&&m.push(E[p])}return m}b.default=T},"./src/controller/timeline-controller.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"TimelineController",function(){return E});var I=n("./src/polyfills/number.ts"),L=n("./src/events.ts"),D=n("./src/utils/cea-608-parser.ts"),M=n("./src/utils/output-filter.ts"),R=n("./src/utils/webvtt-parser.ts"),O=n("./src/utils/texttrack-utils.ts"),_=n("./src/utils/imsc1-ttml-parser.ts"),y=n("./src/utils/mp4-tools.ts"),T=n("./src/types/loader.ts"),A=n("./src/utils/logger.ts"),E=function(){function e(h){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=f(),this.captionsProperties=void 0,this.hls=h,this.config=h.config,this.Cues=h.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var g=new M.default(this,"textTrack1"),i=new M.default(this,"textTrack2"),r=new M.default(this,"textTrack3"),l=new M.default(this,"textTrack4");this.cea608Parser1=new D.default(1,g,i),this.cea608Parser2=new D.default(3,r,l)}h.on(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),h.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),h.on(L.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.on(L.Events.FRAG_LOADING,this.onFragLoading,this),h.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),h.on(L.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),h.on(L.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),h.on(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.on(L.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),h.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=e.prototype;return o.destroy=function(){var g=this.hls;g.off(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),g.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),g.off(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),g.off(L.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),g.off(L.Events.FRAG_LOADING,this.onFragLoading,this),g.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),g.off(L.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),g.off(L.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),g.off(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),g.off(L.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),g.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(g,i,r,l,c){for(var t=!1,a=c.length;a--;){var u=c[a],s=p(u[0],u[1],i,r);if(s>=0&&(u[0]=Math.min(u[0],i),u[1]=Math.max(u[1],r),t=!0,s/(r-i)>.5))return}if(t||c.push([i,r]),this.config.renderTextTracksNatively){var d=this.captionsTracks[g];this.Cues.newCue(d,i,r,l)}else{var v=this.Cues.newCue(null,i,r,l);this.hls.trigger(L.Events.CUES_PARSED,{type:"captions",cues:v,track:g})}},o.onInitPtsFound=function(g,i){var r=this,l=i.frag,c=i.id,t=i.initPTS,a=i.timescale,u=this.unparsedVttFrags;c==="main"&&(this.initPTS[l.cc]=t,this.timescale[l.cc]=a),u.length&&(this.unparsedVttFrags=[],u.forEach(function(s){r.onFragLoaded(L.Events.FRAG_LOADED,s)}))},o.getExistingTrack=function(g){var i=this.media;if(i)for(var r=0;r<i.textTracks.length;r++){var l=i.textTracks[r];if(l[g])return l}return null},o.createCaptionsTrack=function(g){this.config.renderTextTracksNatively?this.createNativeTrack(g):this.createNonNativeTrack(g)},o.createNativeTrack=function(g){if(!this.captionsTracks[g]){var i=this.captionsProperties,r=this.captionsTracks,l=this.media,c=i[g],t=c.label,a=c.languageCode,u=this.getExistingTrack(g);if(u)r[g]=u,Object(O.clearCurrentCues)(r[g]),Object(O.sendAddTrackEvent)(r[g],l);else{var s=this.createTextTrack("captions",t,a);s&&(s[g]=!0,r[g]=s)}}},o.createNonNativeTrack=function(g){if(!this.nonNativeCaptionsTracks[g]){var i=this.captionsProperties[g];if(!!i){var r=i.label,l={_id:g,label:r,kind:"captions",default:i.media?!!i.media.default:!1,closedCaptions:i.media};this.nonNativeCaptionsTracks[g]=l,this.hls.trigger(L.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[l]})}}},o.createTextTrack=function(g,i,r){var l=this.media;if(!!l)return l.addTextTrack(g,i,r)},o.onMediaAttaching=function(g,i){this.media=i.media,this._cleanTracks()},o.onMediaDetaching=function(){var g=this.captionsTracks;Object.keys(g).forEach(function(i){Object(O.clearCurrentCues)(g[i]),delete g[i]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=f(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var g=this.media;if(!!g){var i=g.textTracks;if(i)for(var r=0;r<i.length;r++)Object(O.clearCurrentCues)(i[r])}},o.onSubtitleTracksUpdated=function(g,i){var r=this;this.textTracks=[];var l=i.subtitleTracks||[],c=l.some(function(s){return s.textCodec===_.IMSC1_CODEC});if(this.config.enableWebVTT||c&&this.config.enableIMSC1){var t=this.tracks&&l&&this.tracks.length===l.length;if(this.tracks=l||[],this.config.renderTextTracksNatively){var a=this.media?this.media.textTracks:[];this.tracks.forEach(function(s,d){var v;if(d<a.length){for(var S=null,x=0;x<a.length;x++)if(m(a[x],s)){S=a[x];break}S&&(v=S)}if(v)Object(O.clearCurrentCues)(v);else{var P=r._captionsOrSubtitlesFromCharacteristics(s);v=r.createTextTrack(P,s.name,s.lang),v&&(v.mode="disabled")}v&&(v.groupId=s.groupId,r.textTracks.push(v))})}else if(!t&&this.tracks&&this.tracks.length){var u=this.tracks.map(function(s){return{label:s.name,kind:s.type.toLowerCase(),default:s.default,subtitleTrack:s}});this.hls.trigger(L.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:u})}}},o._captionsOrSubtitlesFromCharacteristics=function(g){var i;if((i=g.attrs)!==null&&i!==void 0&&i.CHARACTERISTICS){var r=/transcribes-spoken-dialog/gi.test(g.attrs.CHARACTERISTICS),l=/describes-music-and-sound/gi.test(g.attrs.CHARACTERISTICS);if(r&&l)return"captions"}return"subtitles"},o.onManifestLoaded=function(g,i){var r=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach(function(l){var c=/(?:CC|SERVICE)([1-4])/.exec(l.instreamId);if(!!c){var t="textTrack"+c[1],a=r.captionsProperties[t];!a||(a.label=l.name,l.lang&&(a.languageCode=l.lang),a.media=l)}})},o.onFragLoading=function(g,i){var r=this.cea608Parser1,l=this.cea608Parser2,c=this.lastSn,t=this.lastPartIndex;if(!(!this.enabled||!(r&&l))&&i.frag.type===T.PlaylistLevelType.MAIN){var a,u,s=i.frag.sn,d=(a=i==null||(u=i.part)===null||u===void 0?void 0:u.index)!=null?a:-1;s===c+1||s===c&&d===t+1||(r.reset(),l.reset()),this.lastSn=s,this.lastPartIndex=d}},o.onFragLoaded=function(g,i){var r=i.frag,l=i.payload,c=this.initPTS,t=this.unparsedVttFrags;if(r.type===T.PlaylistLevelType.SUBTITLE)if(l.byteLength){if(!Object(I.isFiniteNumber)(c[r.cc])){t.push(i),c.length&&this.hls.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")});return}var a=r.decryptdata,u="stats"in i;if(a==null||a.key==null||a.method!=="AES-128"||u){var s=this.tracks[r.level],d=this.vttCCs;d[r.cc]||(d[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),s&&s.textCodec===_.IMSC1_CODEC?this._parseIMSC1(r,l):this._parseVTTs(r,l,d)}}else this.hls.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(g,i){var r=this,l=this.hls;Object(_.parseIMSC1)(i,this.initPTS[g.cc],this.timescale[g.cc],function(c){r._appendCues(c,g.level),l.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:g})},function(c){A.logger.log("Failed to parse IMSC1: "+c),l.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:c})})},o._parseVTTs=function(g,i,r){var l,c=this,t=this.hls,a=(l=g.initSegment)!==null&&l!==void 0&&l.data?Object(y.appendUint8Array)(g.initSegment.data,new Uint8Array(i)):i;Object(R.parseWebVTT)(a,this.initPTS[g.cc],this.timescale[g.cc],r,g.cc,g.start,function(u){c._appendCues(u,g.level),t.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:g})},function(u){c._fallbackToIMSC1(g,i),A.logger.log("Failed to parse VTT cue: "+u),t.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:u})})},o._fallbackToIMSC1=function(g,i){var r=this,l=this.tracks[g.level];l.textCodec||Object(_.parseIMSC1)(i,this.initPTS[g.cc],this.timescale[g.cc],function(){l.textCodec=_.IMSC1_CODEC,r._parseIMSC1(g,i)},function(){l.textCodec="wvtt"})},o._appendCues=function(g,i){var r=this.hls;if(this.config.renderTextTracksNatively){var l=this.textTracks[i];if(!l||l.mode==="disabled")return;g.forEach(function(a){return Object(O.addCueToTrack)(l,a)})}else{var c=this.tracks[i];if(!c)return;var t=c.default?"default":"subtitles"+i;r.trigger(L.Events.CUES_PARSED,{type:"subtitles",cues:g,track:t})}},o.onFragDecrypted=function(g,i){var r=i.frag;if(r.type===T.PlaylistLevelType.SUBTITLE){if(!Object(I.isFiniteNumber)(this.initPTS[r.cc])){this.unparsedVttFrags.push(i);return}this.onFragLoaded(L.Events.FRAG_LOADED,i)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(g,i){var r=this.cea608Parser1,l=this.cea608Parser2;if(!(!this.enabled||!(r&&l)))for(var c=0;c<i.samples.length;c++){var t=i.samples[c].bytes;if(t){var a=this.extractCea608Data(t);r.addData(i.samples[c].pts,a[0]),l.addData(i.samples[c].pts,a[1])}}},o.onBufferFlushing=function(g,i){var r=i.startOffset,l=i.endOffset,c=i.endOffsetSubtitles,t=i.type,a=this.media;if(!(!a||a.currentTime<l)){if(!t||t==="video"){var u=this.captionsTracks;Object.keys(u).forEach(function(d){return Object(O.removeCuesInRange)(u[d],r,l)})}if(this.config.renderTextTracksNatively&&r===0&&c!==void 0){var s=this.textTracks;Object.keys(s).forEach(function(d){return Object(O.removeCuesInRange)(s[d],r,c)})}}},o.extractCea608Data=function(g){for(var i=[[],[]],r=g[0]&31,l=2,c=0;c<r;c++){var t=g[l++],a=127&g[l++],u=127&g[l++];if(!(a===0&&u===0)){var s=(4&t)!==0;if(s){var d=3&t;(d===0||d===1)&&(i[d].push(a),i[d].push(u))}}}return i},e}();function m(e,o){return e&&e.label===o.name&&!(e.textTrack1||e.textTrack2)}function p(e,o,h,g){return Math.min(o,g)-Math.max(e,h)}function f(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return I});var I=function(){function L(M,R){this.subtle=void 0,this.aesIV=void 0,this.subtle=M,this.aesIV=R}var D=L.prototype;return D.decrypt=function(R,O){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},O,R)},L}()},"./src/crypt/aes-decryptor.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"removePadding",function(){return L}),n.d(b,"default",function(){return D});var I=n("./src/utils/typed-array.ts");function L(M){var R=M.byteLength,O=R&&new DataView(M.buffer).getUint8(R-1);return O?Object(I.sliceUint8)(M,0,R-O):M}var D=function(){function M(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var R=M.prototype;return R.uint8ArrayToUint32Array_=function(_){for(var y=new DataView(_),T=new Uint32Array(4),A=0;A<4;A++)T[A]=y.getUint32(A*4);return T},R.initTable=function(){var _=this.sBox,y=this.invSBox,T=this.subMix,A=T[0],E=T[1],m=T[2],p=T[3],f=this.invSubMix,e=f[0],o=f[1],h=f[2],g=f[3],i=new Uint32Array(256),r=0,l=0,c=0;for(c=0;c<256;c++)c<128?i[c]=c<<1:i[c]=c<<1^283;for(c=0;c<256;c++){var t=l^l<<1^l<<2^l<<3^l<<4;t=t>>>8^t&255^99,_[r]=t,y[t]=r;var a=i[r],u=i[a],s=i[u],d=i[t]*257^t*16843008;A[r]=d<<24|d>>>8,E[r]=d<<16|d>>>16,m[r]=d<<8|d>>>24,p[r]=d,d=s*16843009^u*65537^a*257^r*16843008,e[t]=d<<24|d>>>8,o[t]=d<<16|d>>>16,h[t]=d<<8|d>>>24,g[t]=d,r?(r=a^i[i[i[s^a]]],l^=i[i[l]]):r=l=1}},R.expandKey=function(_){for(var y=this.uint8ArrayToUint32Array_(_),T=!0,A=0;A<y.length&&T;)T=y[A]===this.key[A],A++;if(!T){this.key=y;var E=this.keySize=y.length;if(E!==4&&E!==6&&E!==8)throw new Error("Invalid aes key size="+E);var m=this.ksRows=(E+6+1)*4,p,f,e=this.keySchedule=new Uint32Array(m),o=this.invKeySchedule=new Uint32Array(m),h=this.sBox,g=this.rcon,i=this.invSubMix,r=i[0],l=i[1],c=i[2],t=i[3],a,u;for(p=0;p<m;p++){if(p<E){a=e[p]=y[p];continue}u=a,p%E===0?(u=u<<8|u>>>24,u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[u&255],u^=g[p/E|0]<<24):E>6&&p%E===4&&(u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[u&255]),e[p]=a=(e[p-E]^u)>>>0}for(f=0;f<m;f++)p=m-f,f&3?u=e[p]:u=e[p-4],f<4||p<=4?o[f]=u:o[f]=r[h[u>>>24]]^l[h[u>>>16&255]]^c[h[u>>>8&255]]^t[h[u&255]],o[f]=o[f]>>>0}},R.networkToHostOrderSwap=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},R.decrypt=function(_,y,T){for(var A=this.keySize+6,E=this.invKeySchedule,m=this.invSBox,p=this.invSubMix,f=p[0],e=p[1],o=p[2],h=p[3],g=this.uint8ArrayToUint32Array_(T),i=g[0],r=g[1],l=g[2],c=g[3],t=new Int32Array(_),a=new Int32Array(t.length),u,s,d,v,S,x,P,B,k,U,W,G,z,Y,J=this.networkToHostOrderSwap;y<t.length;){for(k=J(t[y]),U=J(t[y+1]),W=J(t[y+2]),G=J(t[y+3]),S=k^E[0],x=G^E[1],P=W^E[2],B=U^E[3],z=4,Y=1;Y<A;Y++)u=f[S>>>24]^e[x>>16&255]^o[P>>8&255]^h[B&255]^E[z],s=f[x>>>24]^e[P>>16&255]^o[B>>8&255]^h[S&255]^E[z+1],d=f[P>>>24]^e[B>>16&255]^o[S>>8&255]^h[x&255]^E[z+2],v=f[B>>>24]^e[S>>16&255]^o[x>>8&255]^h[P&255]^E[z+3],S=u,x=s,P=d,B=v,z=z+4;u=m[S>>>24]<<24^m[x>>16&255]<<16^m[P>>8&255]<<8^m[B&255]^E[z],s=m[x>>>24]<<24^m[P>>16&255]<<16^m[B>>8&255]<<8^m[S&255]^E[z+1],d=m[P>>>24]<<24^m[B>>16&255]<<16^m[S>>8&255]<<8^m[x&255]^E[z+2],v=m[B>>>24]<<24^m[S>>16&255]<<16^m[x>>8&255]<<8^m[P&255]^E[z+3],a[y]=J(u^i),a[y+1]=J(v^r),a[y+2]=J(d^l),a[y+3]=J(s^c),i=k,r=U,l=W,c=G,y=y+4}return a.buffer},M}()},"./src/crypt/decrypter.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return y});var I=n("./src/crypt/aes-crypto.ts"),L=n("./src/crypt/fast-aes-key.ts"),D=n("./src/crypt/aes-decryptor.ts"),M=n("./src/utils/logger.ts"),R=n("./src/utils/mp4-tools.ts"),O=n("./src/utils/typed-array.ts"),_=16,y=function(){function T(E,m,p){var f=p===void 0?{}:p,e=f.removePKCS7Padding,o=e===void 0?!0:e;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=E,this.config=m,this.removePKCS7Padding=o,o)try{var h=self.crypto;h&&(this.subtle=h.subtle||h.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var A=T.prototype;return A.destroy=function(){this.observer=null},A.isSync=function(){return this.config.enableSoftwareAES},A.flush=function(){var m=this.currentResult;if(!m){this.reset();return}var p=new Uint8Array(m);return this.reset(),this.removePKCS7Padding?Object(D.removePadding)(p):p},A.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},A.decrypt=function(m,p,f,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(m),p,f);var o=this.flush();o&&e(o.buffer)}else this.webCryptoDecrypt(new Uint8Array(m),p,f).then(e)},A.softwareDecrypt=function(m,p,f){var e=this.currentIV,o=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(m=Object(R.appendUint8Array)(h,m),this.remainderData=null);var g=this.getValidChunk(m);if(!g.length)return null;e&&(f=e);var i=this.softwareDecrypter;i||(i=this.softwareDecrypter=new D.default),i.expandKey(p);var r=o;return this.currentResult=i.decrypt(g.buffer,0,f),this.currentIV=Object(O.sliceUint8)(g,-16).buffer,r||null},A.webCryptoDecrypt=function(m,p,f){var e=this,o=this.subtle;return(this.key!==p||!this.fastAesKey)&&(this.key=p,this.fastAesKey=new L.default(o,p)),this.fastAesKey.expandKey().then(function(h){if(!o)return Promise.reject(new Error("web crypto not initialized"));var g=new I.default(o,f);return g.decrypt(m.buffer,h)}).catch(function(h){return e.onWebCryptoError(h,m,p,f)})},A.onWebCryptoError=function(m,p,f,e){return M.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",m),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(p,f,e)},A.getValidChunk=function(m){var p=m,f=m.length-m.length%_;return f!==m.length&&(p=Object(O.sliceUint8)(m,0,f),this.remainderData=Object(O.sliceUint8)(m,f)),p},A.logOnce=function(m){!this.logEnabled||(M.logger.log("[decrypter.ts]: "+m),this.logEnabled=!1)},T}()},"./src/crypt/fast-aes-key.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return I});var I=function(){function L(M,R){this.subtle=void 0,this.key=void 0,this.subtle=M,this.key=R}var D=L.prototype;return D.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},L}()},"./src/demux/aacdemuxer.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/demux/base-audio-demuxer.ts"),L=n("./src/demux/adts.ts"),D=n("./src/utils/logger.ts"),M=n("./src/demux/id3.ts");function R(y,T){y.prototype=Object.create(T.prototype),y.prototype.constructor=y,O(y,T)}function O(y,T){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,m){return E.__proto__=m,E},O(y,T)}var _=function(y){R(T,y);function T(E,m){var p;return p=y.call(this)||this,p.observer=void 0,p.config=void 0,p.observer=E,p.config=m,p}var A=T.prototype;return A.resetInitSegment=function(m,p,f,e){y.prototype.resetInitSegment.call(this,m,p,f,e),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:p,duration:e,inputTimeScale:9e4,dropped:0}},T.probe=function(m){if(!m)return!1;for(var p=M.getID3Data(m,0)||[],f=p.length,e=m.length;f<e;f++)if(L.probe(m,f))return D.logger.log("ADTS sync word found !"),!0;return!1},A.canParse=function(m,p){return L.canParse(m,p)},A.appendFrame=function(m,p,f){L.initTrackConfig(m,this.observer,p,f,m.manifestCodec);var e=L.appendFrame(m,p,f,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},T}(I.default);b.default=_},"./src/demux/adts.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"getAudioConfig",function(){return M}),n.d(b,"isHeaderPattern",function(){return R}),n.d(b,"getHeaderLength",function(){return O}),n.d(b,"getFullFrameLength",function(){return _}),n.d(b,"canGetFrameLength",function(){return y}),n.d(b,"isHeader",function(){return T}),n.d(b,"canParse",function(){return A}),n.d(b,"probe",function(){return E}),n.d(b,"initTrackConfig",function(){return m}),n.d(b,"getFrameDuration",function(){return p}),n.d(b,"parseFrameHeader",function(){return f}),n.d(b,"appendFrame",function(){return e});var I=n("./src/utils/logger.ts"),L=n("./src/errors.ts"),D=n("./src/events.ts");function M(o,h,g,i){var r,l,c,t,a=navigator.userAgent.toLowerCase(),u=i,s=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=((h[g+2]&192)>>>6)+1;var d=(h[g+2]&60)>>>2;if(d>s.length-1){o.trigger(D.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d});return}return c=(h[g+2]&1)<<2,c|=(h[g+3]&192)>>>6,I.logger.log("manifest codec:"+i+", ADTS type:"+r+", samplingIndex:"+d),/firefox/i.test(a)?d>=6?(r=5,t=new Array(4),l=d-3):(r=2,t=new Array(2),l=d):a.indexOf("android")!==-1?(r=2,t=new Array(2),l=d):(r=5,t=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&d>=6?l=d-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(d>=6&&c===1||/vivaldi/i.test(a))||!i&&c===1)&&(r=2,t=new Array(2)),l=d)),t[0]=r<<3,t[0]|=(d&14)>>1,t[1]|=(d&1)<<7,t[1]|=c<<3,r===5&&(t[1]|=(l&14)>>1,t[2]=(l&1)<<7,t[2]|=2<<2,t[3]=0),{config:t,samplerate:s[d],channelCount:c,codec:"mp4a.40."+r,manifestCodec:u}}function R(o,h){return o[h]===255&&(o[h+1]&246)===240}function O(o,h){return o[h+1]&1?7:9}function _(o,h){return(o[h+3]&3)<<11|o[h+4]<<3|(o[h+5]&224)>>>5}function y(o,h){return h+5<o.length}function T(o,h){return h+1<o.length&&R(o,h)}function A(o,h){return y(o,h)&&R(o,h)&&_(o,h)<=o.length-h}function E(o,h){if(T(o,h)){var g=O(o,h);if(h+g>=o.length)return!1;var i=_(o,h);if(i<=g)return!1;var r=h+i;return r===o.length||T(o,r)}return!1}function m(o,h,g,i,r){if(!o.samplerate){var l=M(h,g,i,r);if(!l)return;o.config=l.config,o.samplerate=l.samplerate,o.channelCount=l.channelCount,o.codec=l.codec,o.manifestCodec=l.manifestCodec,I.logger.log("parsed codec:"+o.codec+", rate:"+l.samplerate+", channels:"+l.channelCount)}}function p(o){return 1024*9e4/o}function f(o,h){var g=O(o,h);if(h+g<=o.length){var i=_(o,h)-g;if(i>0)return{headerLength:g,frameLength:i}}}function e(o,h,g,i,r){var l=p(o.samplerate),c=i+r*l,t=f(h,g),a;if(t){var u=t.frameLength,s=t.headerLength,d=s+u,v=Math.max(0,g+d-h.length);v?(a=new Uint8Array(d-s),a.set(h.subarray(g+s,h.length),0)):a=h.subarray(g+s,g+d);var S={unit:a,pts:c};return v||o.samples.push(S),{sample:S,length:d,missing:v}}var x=h.length-g;a=new Uint8Array(x),a.set(h.subarray(g,h.length),0);var P={unit:a,pts:c};return{sample:P,length:x,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"initPTSFn",function(){return y});var I=n("./src/polyfills/number.ts"),L=n("./src/demux/id3.ts"),D=n("./src/types/demuxer.ts"),M=n("./src/demux/dummy-demuxed-track.ts"),R=n("./src/utils/mp4-tools.ts"),O=n("./src/utils/typed-array.ts"),_=function(){function T(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var A=T.prototype;return A.resetInitSegment=function(m,p,f,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},A.resetTimeStamp=function(m){this.initPTS=m,this.resetContiguity()},A.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},A.canParse=function(m,p){return!1},A.appendFrame=function(m,p,f){},A.demux=function(m,p){this.cachedData&&(m=Object(R.appendUint8Array)(this.cachedData,m),this.cachedData=null);var f=L.getID3Data(m,0),e=f?f.length:0,o,h,g=this._audioTrack,i=this._id3Track,r=f?L.getTimeStamp(f):void 0,l=m.length;for((this.basePTS===null||this.frameIndex===0&&Object(I.isFiniteNumber)(r))&&(this.basePTS=y(r,p,this.initPTS)),f&&f.length>0&&i.samples.push({pts:this.basePTS,dts:this.basePTS,data:f,type:D.MetadataSchema.audioId3}),h=this.basePTS;e<l;){if(this.canParse(m,e)){var c=this.appendFrame(g,m,e);c?(this.frameIndex++,h=c.sample.pts,e+=c.length,o=e):e=l}else L.canParse(m,e)?(f=L.getID3Data(m,e),i.samples.push({pts:h,dts:h,data:f,type:D.MetadataSchema.audioId3}),e+=f.length,o=e):e++;if(e===l&&o!==l){var t=Object(O.sliceUint8)(m,o);this.cachedData?this.cachedData=Object(R.appendUint8Array)(this.cachedData,t):this.cachedData=t}}return{audioTrack:g,videoTrack:Object(M.dummyTrack)(),id3Track:i,textTrack:Object(M.dummyTrack)()}},A.demuxSampleAes=function(m,p,f){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},A.flush=function(m){var p=this.cachedData;return p&&(this.cachedData=null,this.demux(p,0)),{audioTrack:this._audioTrack,videoTrack:Object(M.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(M.dummyTrack)()}},A.destroy=function(){},T}(),y=function(A,E,m){return Object(I.isFiniteNumber)(A)?A*90:E*9e4+(m||0)};b.default=_},"./src/demux/chunk-cache.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return I});var I=function(){function D(){this.chunks=[],this.dataLength=0}var M=D.prototype;return M.push=function(O){this.chunks.push(O),this.dataLength+=O.length},M.flush=function(){var O=this.chunks,_=this.dataLength,y;if(O.length)O.length===1?y=O[0]:y=L(O,_);else return new Uint8Array(0);return this.reset(),y},M.reset=function(){this.chunks.length=0,this.dataLength=0},D}();function L(D,M){for(var R=new Uint8Array(M),O=0,_=0;_<D.length;_++){var y=D[_];R.set(y,O),O+=y.length}return R}},"./src/demux/dummy-demuxed-track.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"dummyTrack",function(){return I});function I(L,D){return L===void 0&&(L=""),D===void 0&&(D=9e4),{type:L,id:-1,pid:-1,inputTimeScale:D,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/utils/logger.ts"),L=function(){function D(R){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=R,this.bytesAvailable=R.byteLength,this.word=0,this.bitsAvailable=0}var M=D.prototype;return M.loadWord=function(){var O=this.data,_=this.bytesAvailable,y=O.byteLength-_,T=new Uint8Array(4),A=Math.min(4,_);if(A===0)throw new Error("no bytes available");T.set(O.subarray(y,y+A)),this.word=new DataView(T.buffer).getUint32(0),this.bitsAvailable=A*8,this.bytesAvailable-=A},M.skipBits=function(O){var _;this.bitsAvailable>O?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,_=O>>3,O-=_>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},M.readBits=function(O){var _=Math.min(this.bitsAvailable,O),y=this.word>>>32-_;return O>32&&I.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=_,this.bitsAvailable>0?this.word<<=_:this.bytesAvailable>0&&this.loadWord(),_=O-_,_>0&&this.bitsAvailable?y<<_|this.readBits(_):y},M.skipLZ=function(){var O;for(O=0;O<this.bitsAvailable;++O)if((this.word&2147483648>>>O)!==0)return this.word<<=O,this.bitsAvailable-=O,O;return this.loadWord(),O+this.skipLZ()},M.skipUEG=function(){this.skipBits(1+this.skipLZ())},M.skipEG=function(){this.skipBits(1+this.skipLZ())},M.readUEG=function(){var O=this.skipLZ();return this.readBits(O+1)-1},M.readEG=function(){var O=this.readUEG();return 1&O?1+O>>>1:-1*(O>>>1)},M.readBoolean=function(){return this.readBits(1)===1},M.readUByte=function(){return this.readBits(8)},M.readUShort=function(){return this.readBits(16)},M.readUInt=function(){return this.readBits(32)},M.skipScalingList=function(O){for(var _=8,y=8,T,A=0;A<O;A++)y!==0&&(T=this.readEG(),y=(_+T+256)%256),_=y===0?_:y},M.readSPS=function(){var O=0,_=0,y=0,T=0,A,E,m,p=this.readUByte.bind(this),f=this.readBits.bind(this),e=this.readUEG.bind(this),o=this.readBoolean.bind(this),h=this.skipBits.bind(this),g=this.skipEG.bind(this),i=this.skipUEG.bind(this),r=this.skipScalingList.bind(this);p();var l=p();if(f(5),h(3),p(),i(),l===100||l===110||l===122||l===244||l===44||l===83||l===86||l===118||l===128){var c=e();if(c===3&&h(1),i(),i(),h(1),o())for(E=c!==3?8:12,m=0;m<E;m++)o()&&(m<6?r(16):r(64))}i();var t=e();if(t===0)e();else if(t===1)for(h(1),g(),g(),A=e(),m=0;m<A;m++)g();i(),h(1);var a=e(),u=e(),s=f(1);s===0&&h(1),h(1),o()&&(O=e(),_=e(),y=e(),T=e());var d=[1,1];if(o()&&o()){var v=p();switch(v){case 1:d=[1,1];break;case 2:d=[12,11];break;case 3:d=[10,11];break;case 4:d=[16,11];break;case 5:d=[40,33];break;case 6:d=[24,11];break;case 7:d=[20,11];break;case 8:d=[32,11];break;case 9:d=[80,33];break;case 10:d=[18,11];break;case 11:d=[15,11];break;case 12:d=[64,33];break;case 13:d=[160,99];break;case 14:d=[4,3];break;case 15:d=[3,2];break;case 16:d=[2,1];break;case 255:{d=[p()<<8|p(),p()<<8|p()];break}}}return{width:Math.ceil((a+1)*16-O*2-_*2),height:(2-s)*(u+1)*16-(s?2:4)*(y+T),pixelRatio:d}},M.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},D}();b.default=L},"./src/demux/id3.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"isHeader",function(){return I}),n.d(b,"isFooter",function(){return L}),n.d(b,"getID3Data",function(){return D}),n.d(b,"canParse",function(){return R}),n.d(b,"getTimeStamp",function(){return O}),n.d(b,"isTimeStampFrame",function(){return _}),n.d(b,"getID3Frames",function(){return T}),n.d(b,"decodeFrame",function(){return A}),n.d(b,"utf8ArrayToStr",function(){return e}),n.d(b,"testables",function(){return o});var I=function(r,l){return l+10<=r.length&&r[l]===73&&r[l+1]===68&&r[l+2]===51&&r[l+3]<255&&r[l+4]<255&&r[l+6]<128&&r[l+7]<128&&r[l+8]<128&&r[l+9]<128},L=function(r,l){return l+10<=r.length&&r[l]===51&&r[l+1]===68&&r[l+2]===73&&r[l+3]<255&&r[l+4]<255&&r[l+6]<128&&r[l+7]<128&&r[l+8]<128&&r[l+9]<128},D=function(r,l){for(var c=l,t=0;I(r,l);){t+=10;var a=M(r,l+6);t+=a,L(r,l+10)&&(t+=10),l+=t}if(t>0)return r.subarray(c,c+t)},M=function(r,l){var c=0;return c=(r[l]&127)<<21,c|=(r[l+1]&127)<<14,c|=(r[l+2]&127)<<7,c|=r[l+3]&127,c},R=function(r,l){return I(r,l)&&M(r,l+6)+10<=r.length-l},O=function(r){for(var l=T(r),c=0;c<l.length;c++){var t=l[c];if(_(t))return f(t)}},_=function(r){return r&&r.key==="PRIV"&&r.info==="com.apple.streaming.transportStreamTimestamp"},y=function(r){var l=String.fromCharCode(r[0],r[1],r[2],r[3]),c=M(r,4),t=10;return{type:l,size:c,data:r.subarray(t,t+c)}},T=function(r){for(var l=0,c=[];I(r,l);){var t=M(r,l+6);l+=10;for(var a=l+t;l+8<a;){var u=y(r.subarray(l)),s=A(u);s&&c.push(s),l+=u.size+10}L(r,l)&&(l+=10)}return c},A=function(r){return r.type==="PRIV"?E(r):r.type[0]==="W"?p(r):m(r)},E=function(r){if(!(r.size<2)){var l=e(r.data,!0),c=new Uint8Array(r.data.subarray(l.length+1));return{key:r.type,info:l,data:c.buffer}}},m=function(r){if(!(r.size<2)){if(r.type==="TXXX"){var l=1,c=e(r.data.subarray(l),!0);l+=c.length+1;var t=e(r.data.subarray(l));return{key:r.type,info:c,data:t}}var a=e(r.data.subarray(1));return{key:r.type,data:a}}},p=function(r){if(r.type==="WXXX"){if(r.size<2)return;var l=1,c=e(r.data.subarray(l),!0);l+=c.length+1;var t=e(r.data.subarray(l));return{key:r.type,info:c,data:t}}var a=e(r.data);return{key:r.type,data:a}},f=function(r){if(r.data.byteLength===8){var l=new Uint8Array(r.data),c=l[3]&1,t=(l[4]<<23)+(l[5]<<15)+(l[6]<<7)+l[7];return t/=45,c&&(t+=4772185884e-2),Math.round(t)}},e=function(r,l){l===void 0&&(l=!1);var c=g();if(c){var t=c.decode(r);if(l){var a=t.indexOf("\0");return a!==-1?t.substring(0,a):t}return t.replace(/\0/g,"")}for(var u=r.length,s,d,v,S="",x=0;x<u;){if(s=r[x++],s===0&&l)return S;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:S+=String.fromCharCode(s);break;case 12:case 13:d=r[x++],S+=String.fromCharCode((s&31)<<6|d&63);break;case 14:d=r[x++],v=r[x++],S+=String.fromCharCode((s&15)<<12|(d&63)<<6|(v&63)<<0);break;default:}}return S},o={decodeTextFrame:m},h;function g(){return!h&&typeof self.TextDecoder!="undefined"&&(h=new self.TextDecoder("utf-8")),h}},"./src/demux/mp3demuxer.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/demux/base-audio-demuxer.ts"),L=n("./src/demux/id3.ts"),D=n("./src/utils/logger.ts"),M=n("./src/demux/mpegaudio.ts");function R(y,T){y.prototype=Object.create(T.prototype),y.prototype.constructor=y,O(y,T)}function O(y,T){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,m){return E.__proto__=m,E},O(y,T)}var _=function(y){R(T,y);function T(){return y.apply(this,arguments)||this}var A=T.prototype;return A.resetInitSegment=function(m,p,f,e){y.prototype.resetInitSegment.call(this,m,p,f,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:p,duration:e,inputTimeScale:9e4,dropped:0}},T.probe=function(m){if(!m)return!1;for(var p=L.getID3Data(m,0)||[],f=p.length,e=m.length;f<e;f++)if(M.probe(m,f))return D.logger.log("MPEG Audio sync word found !"),!0;return!1},A.canParse=function(m,p){return M.canParse(m,p)},A.appendFrame=function(m,p,f){if(this.basePTS!==null)return M.appendFrame(m,p,f,this.basePTS,this.frameIndex)},T}(I.default);b.default=_},"./src/demux/mp4demuxer.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/polyfills/number.ts"),L=n("./src/types/demuxer.ts"),D=n("./src/utils/mp4-tools.ts"),M=n("./src/demux/dummy-demuxed-track.ts"),R=/\/emsg[-/]ID3/i,O=function(){function _(T,A){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=A}var y=_.prototype;return y.resetTimeStamp=function(){},y.resetInitSegment=function(A,E,m,p){var f=Object(D.parseInitSegment)(A),e=this.videoTrack=Object(M.dummyTrack)("video",1),o=this.audioTrack=Object(M.dummyTrack)("audio",1),h=this.txtTrack=Object(M.dummyTrack)("text",1);if(this.id3Track=Object(M.dummyTrack)("id3",1),this.timeOffset=0,f.video){var g=f.video,i=g.id,r=g.timescale,l=g.codec;e.id=i,e.timescale=h.timescale=r,e.codec=l}if(f.audio){var c=f.audio,t=c.id,a=c.timescale,u=c.codec;o.id=t,o.timescale=a,o.codec=u}h.id=D.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=o.duration=p},y.resetContiguity=function(){},_.probe=function(A){return A=A.length>16384?A.subarray(0,16384):A,Object(D.findBox)(A,["moof"]).length>0},y.demux=function(A,E){this.timeOffset=E;var m=A,p=this.videoTrack,f=this.txtTrack;if(this.config.progressive){this.remainderData&&(m=Object(D.appendUint8Array)(this.remainderData,A));var e=Object(D.segmentValidRange)(m);this.remainderData=e.remainder,p.samples=e.valid||new Uint8Array}else p.samples=m;var o=this.extractID3Track(p,E);return f.samples=Object(D.parseSamples)(E,p),{videoTrack:p,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}},y.flush=function(){var A=this.timeOffset,E=this.videoTrack,m=this.txtTrack;E.samples=this.remainderData||new Uint8Array,this.remainderData=null;var p=this.extractID3Track(E,this.timeOffset);return m.samples=Object(D.parseSamples)(A,E),{videoTrack:E,audioTrack:Object(M.dummyTrack)(),id3Track:p,textTrack:Object(M.dummyTrack)()}},y.extractID3Track=function(A,E){var m=this.id3Track;if(A.samples.length){var p=Object(D.findBox)(A.samples,["emsg"]);p&&p.forEach(function(f){var e=Object(D.parseEmsg)(f);if(R.test(e.schemeIdUri)){var o=Object(I.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:E+e.presentationTimeDelta/e.timeScale,h=e.payload;m.samples.push({data:h,len:h.byteLength,dts:o,pts:o,type:L.MetadataSchema.emsg})}})}return m},y.demuxSampleAes=function(A,E,m){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},y.destroy=function(){},_}();b.default=O},"./src/demux/mpegaudio.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"appendFrame",function(){return O}),n.d(b,"parseHeader",function(){return _}),n.d(b,"isHeaderPattern",function(){return y}),n.d(b,"isHeader",function(){return T}),n.d(b,"canParse",function(){return A}),n.d(b,"probe",function(){return E});var I=null,L=[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],D=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],M=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],R=[0,1,1,4];function O(m,p,f,e,o){if(!(f+24>p.length)){var h=_(p,f);if(h&&f+h.frameLength<=p.length){var g=h.samplesPerFrame*9e4/h.sampleRate,i=e+o*g,r={unit:p.subarray(f,f+h.frameLength),pts:i,dts:i};return m.config=[],m.channelCount=h.channelCount,m.samplerate=h.sampleRate,m.samples.push(r),{sample:r,length:h.frameLength,missing:0}}}}function _(m,p){var f=m[p+1]>>3&3,e=m[p+1]>>1&3,o=m[p+2]>>4&15,h=m[p+2]>>2&3;if(f!==1&&o!==0&&o!==15&&h!==3){var g=m[p+2]>>1&1,i=m[p+3]>>6,r=f===3?3-e:e===3?3:4,l=L[r*14+o-1]*1e3,c=f===3?0:f===2?1:2,t=D[c*3+h],a=i===3?1:2,u=M[f][e],s=R[e],d=u*8*s,v=Math.floor(u*l/t+g)*s;if(I===null){var S=navigator.userAgent||"",x=S.match(/Chrome\/(\d+)/i);I=x?parseInt(x[1]):0}var P=!!I&&I<=87;return P&&e===2&&l>=224e3&&i===0&&(m[p+3]=m[p+3]|128),{sampleRate:t,channelCount:a,frameLength:v,samplesPerFrame:d}}}function y(m,p){return m[p]===255&&(m[p+1]&224)===224&&(m[p+1]&6)!==0}function T(m,p){return p+1<m.length&&y(m,p)}function A(m,p){var f=4;return y(m,p)&&f<=m.length-p}function E(m,p){if(p+1<m.length&&y(m,p)){var f=4,e=_(m,p),o=f;e!=null&&e.frameLength&&(o=e.frameLength);var h=p+o;return h===m.length||T(m,h)}return!1}},"./src/demux/sample-aes.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/crypt/decrypter.ts"),L=n("./src/demux/tsdemuxer.ts"),D=function(){function M(O,_,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new I.default(O,_,{removePKCS7Padding:!1})}var R=M.prototype;return R.decryptBuffer=function(_,y){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,y)},R.decryptAacSample=function(_,y,T,A){var E=_[y].unit;if(!(E.length<=16)){var m=E.subarray(16,E.length-E.length%16),p=m.buffer.slice(m.byteOffset,m.byteOffset+m.length),f=this;this.decryptBuffer(p,function(e){var o=new Uint8Array(e);E.set(o,16),A||f.decryptAacSamples(_,y+1,T)})}},R.decryptAacSamples=function(_,y,T){for(;;y++){if(y>=_.length){T();return}if(!(_[y].unit.length<32)){var A=this.decrypter.isSync();if(this.decryptAacSample(_,y,T,A),!A)return}}},R.getAvcEncryptedData=function(_){for(var y=Math.floor((_.length-48)/160)*16+16,T=new Int8Array(y),A=0,E=32;E<_.length-16;E+=160,A+=16)T.set(_.subarray(E,E+16),A);return T},R.getAvcDecryptedUnit=function(_,y){for(var T=new Uint8Array(y),A=0,E=32;E<_.length-16;E+=160,A+=16)_.set(T.subarray(A,A+16),E);return _},R.decryptAvcSample=function(_,y,T,A,E,m){var p=Object(L.discardEPB)(E.data),f=this.getAvcEncryptedData(p),e=this;this.decryptBuffer(f.buffer,function(o){E.data=e.getAvcDecryptedUnit(p,o),m||e.decryptAvcSamples(_,y,T+1,A)})},R.decryptAvcSamples=function(_,y,T,A){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,T=0){if(y>=_.length){A();return}for(var E=_[y].units;!(T>=E.length);T++){var m=E[T];if(!(m.data.length<=48||m.type!==1&&m.type!==5)){var p=this.decrypter.isSync();if(this.decryptAvcSample(_,y,T,A,m,p),!p)return}}}},M}();b.default=D},"./src/demux/transmuxer-interface.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return E});var I=n("./node_modules/webworkify-webpack/index.js"),L=n.n(I),D=n("./src/events.ts"),M=n("./src/demux/transmuxer.ts"),R=n("./src/utils/logger.ts"),O=n("./src/errors.ts"),_=n("./src/utils/mediasource-helper.ts"),y=n("./node_modules/eventemitter3/index.js"),T=n.n(y),A=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},E=function(){function m(f,e,o,h){var g=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=f,this.id=e,this.onTransmuxComplete=o,this.onFlush=h;var i=f.config,r=function(u,s){s=s||{},s.frag=g.frag,s.id=g.id,f.trigger(u,s)};this.observer=new y.EventEmitter,this.observer.on(D.Events.FRAG_DECRYPTED,r),this.observer.on(D.Events.ERROR,r);var l={mp4:A.isTypeSupported("video/mp4"),mpeg:A.isTypeSupported("audio/mpeg"),mp3:A.isTypeSupported('audio/mp4; codecs="mp3"')},c=navigator.vendor;if(i.enableWorker&&typeof Worker!="undefined"){R.logger.log("demuxing in webworker");var t;try{t=this.worker=I("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),t.addEventListener("message",this.onwmsg),t.onerror=function(a){f.trigger(D.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(a.message+" ("+a.filename+":"+a.lineno+")")})},t.postMessage({cmd:"init",typeSupported:l,vendor:c,id:e,config:JSON.stringify(i)})}catch(a){R.logger.warn("Error in worker:",a),R.logger.error("Error while initializing DemuxerWorker, fallback to inline"),t&&self.URL.revokeObjectURL(t.objectURL),this.transmuxer=new M.default(this.observer,l,i,c,e),this.worker=null}}else this.transmuxer=new M.default(this.observer,l,i,c,e)}var p=m.prototype;return p.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var o=this.transmuxer;o&&(o.destroy(),this.transmuxer=null)}var h=this.observer;h&&h.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},p.push=function(e,o,h,g,i,r,l,c,t,a){var u,s,d=this;t.transmuxing.start=self.performance.now();var v=this.transmuxer,S=this.worker,x=r?r.start:i.start,P=i.decryptdata,B=this.frag,k=!(B&&i.cc===B.cc),U=!(B&&t.level===B.level),W=B?t.sn-B.sn:-1,G=this.part?t.part-this.part.index:-1,z=W===0&&t.id>1&&t.id===(B==null?void 0:B.stats.chunkCount),Y=!U&&(W===1||W===0&&(G===1||z&&G<=0)),J=self.performance.now();(U||W||i.stats.parsing.start===0)&&(i.stats.parsing.start=J),r&&(G||!Y)&&(r.stats.parsing.start=J);var ee=!(B&&((u=i.initSegment)===null||u===void 0?void 0:u.url)===((s=B.initSegment)===null||s===void 0?void 0:s.url)),X=new M.TransmuxState(k,Y,c,U,x,ee);if(!Y||k||ee){R.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+t.sn+" p: "+t.part+" level: "+t.level+" id: "+t.id+`
14
14
  discontinuity: `+k+`
15
15
  trackSwitch: `+U+`
16
16
  contiguous: `+Y+`
17
17
  accurateTimeOffset: `+c+`
18
18
  timeOffset: `+x+`
19
- initSegmentChange: `+ee);var q=new M.TransmuxConfig(h,g,o,l,a);this.configureTransmuxer(q)}if(this.frag=i,this.part=r,S)S.postMessage({cmd:"demux",data:e,decryptdata:I,chunkMeta:t,state:z},e instanceof ArrayBuffer?[e]:[]);else if(v){var ie=v.push(e,I,t,z);Object(M.isPromise)(ie)?ie.then(function(ae){f.handleTransmuxComplete(ae)}):this.handleTransmuxComplete(ie)}},p.flush=function(e){var o=this;e.transmuxing.start=self.performance.now();var h=this.transmuxer,g=this.worker;if(g)g.postMessage({cmd:"flush",chunkMeta:e});else if(h){var i=h.flush(e);Object(M.isPromise)(i)?i.then(function(r){o.handleFlushResult(r,e)}):this.handleFlushResult(i,e)}},p.handleFlushResult=function(e,o){var h=this;e.forEach(function(g){h.handleTransmuxComplete(g)}),this.onFlush(o)},p.onWorkerMessage=function(e){var o=e.data,h=this.hls;switch(o.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(o.data);break}case"flush":{this.onFlush(o.data);break}case"workerLog":R.logger[o.data.logType]&&R.logger[o.data.logType](o.data.message);break;default:{o.data=o.data||{},o.data.frag=this.frag,o.data.id=this.id,h.trigger(o.event,o.data);break}}},p.configureTransmuxer=function(e){var o=this.worker,h=this.transmuxer;o?o.postMessage({cmd:"configure",config:e}):h&&h.configure(e)},p.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},m}()},"./src/demux/transmuxer-worker.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return O});var P=n("./src/demux/transmuxer.ts"),L=n("./src/events.ts"),A=n("./src/utils/logger.ts"),M=n("./node_modules/eventemitter3/index.js"),R=n.n(M);function O(E){var m=new M.EventEmitter,p=function(o,h){E.postMessage({event:o,data:h})};m.on(L.Events.FRAG_DECRYPTED,p),m.on(L.Events.ERROR,p);var d=function(){var o=function(i){var r=function(c){p("workerLog",{logType:i,message:c})};A.logger[i]=r};for(var h in A.logger)o(h)};E.addEventListener("message",function(e){var o=e.data;switch(o.cmd){case"init":{var h=JSON.parse(o.config);E.transmuxer=new P.default(m,o.typeSupported,h,o.vendor,o.id),Object(A.enableLogs)(h.debug),d(),p("init",null);break}case"configure":{E.transmuxer.configure(o.config);break}case"demux":{var g=E.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(P.isPromise)(g)?g.then(function(l){_(E,l)}):_(E,g);break}case"flush":{var i=o.chunkMeta,r=E.transmuxer.flush(i);Object(P.isPromise)(r)?r.then(function(l){T(E,l,i)}):T(E,r,i);break}default:break}})}function _(E,m){if(D(m.remuxResult))return!1;var p=[],d=m.remuxResult,e=d.audio,o=d.video;return e&&y(p,e),o&&y(p,o),E.postMessage({event:"transmuxComplete",data:m},p),!0}function y(E,m){m.data1&&E.push(m.data1.buffer),m.data2&&E.push(m.data2.buffer)}function T(E,m,p){var d=m.reduce(function(e,o){return _(E,o)||e},!1);d||E.postMessage({event:"transmuxComplete",data:m[0]}),E.postMessage({event:"flush",data:p})}function D(E){return!E.audio&&!E.video&&!E.text&&!E.id3&&!E.initSegment}},"./src/demux/transmuxer.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return p}),n.d(b,"isPromise",function(){return o}),n.d(b,"TransmuxConfig",function(){return h}),n.d(b,"TransmuxState",function(){return g});var P=n("./src/events.ts"),L=n("./src/errors.ts"),A=n("./src/crypt/decrypter.ts"),M=n("./src/demux/aacdemuxer.ts"),R=n("./src/demux/mp4demuxer.ts"),O=n("./src/demux/tsdemuxer.ts"),_=n("./src/demux/mp3demuxer.ts"),y=n("./src/remux/mp4-remuxer.ts"),T=n("./src/remux/passthrough-remuxer.ts"),D=n("./src/utils/logger.ts"),E;try{E=self.performance.now.bind(self.performance)}catch{D.logger.debug("Unable to use Performance API on this environment"),E=self.Date.now}var m=[{demux:O.default,remux:y.default},{demux:R.default,remux:T.default},{demux:M.default,remux:y.default},{demux:_.default,remux:y.default}],p=function(){function i(l,c,t,a,u){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=l,this.typeSupported=c,this.config=t,this.vendor=a,this.id=u}var r=i.prototype;return r.configure=function(c){this.transmuxConfig=c,this.decrypter&&this.decrypter.reset()},r.push=function(c,t,a,u){var s=this,f=a.transmuxing;f.executeStart=E();var v=new Uint8Array(c),S=this.config,x=this.currentTransmuxState,I=this.transmuxConfig;u&&(this.currentTransmuxState=u);var B=u||x,k=B.contiguous,U=B.discontinuity,W=B.trackSwitch,G=B.accurateTimeOffset,X=B.timeOffset,Y=B.initSegmentChange,J=I.audioCodec,ee=I.videoCodec,z=I.defaultInitPts,q=I.duration,ie=I.initSegmentData;(U||W||Y)&&this.resetInitSegment(ie,J,ee,q),(U||Y)&&this.resetInitialTimestamp(z),k||this.resetContiguity();var ae=d(v,t);if(ae&&ae.method==="AES-128"){var te=this.getDecrypter();if(S.enableSoftwareAES){var oe=te.softwareDecrypt(v,ae.key.buffer,ae.iv.buffer);if(!oe)return f.executeEnd=E(),e(a);v=new Uint8Array(oe)}else return this.decryptionPromise=te.webCryptoDecrypt(v,ae.key.buffer,ae.iv.buffer).then(function(he){var ge=s.push(he,null,a);return s.decryptionPromise=null,ge}),this.decryptionPromise}this.needsProbing(v,U,W)&&this.configureTransmuxer(v,I);var ue=this.transmux(v,ae,X,G,a),re=this.currentTransmuxState;return re.contiguous=!0,re.discontinuity=!1,re.trackSwitch=!1,f.executeEnd=E(),ue},r.flush=function(c){var t=this,a=c.transmuxing;a.executeStart=E();var u=this.decrypter,s=this.currentTransmuxState,f=this.decryptionPromise;if(f)return f.then(function(){return t.flush(c)});var v=[],S=s.timeOffset;if(u){var x=u.flush();x&&v.push(this.push(x,null,c))}var I=this.demuxer,B=this.remuxer;if(!I||!B)return this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),a.executeEnd=E(),[e(c)];var k=I.flush(S);return o(k)?k.then(function(U){return t.flushRemux(v,U,c),v}):(this.flushRemux(v,k,c),v)},r.flushRemux=function(c,t,a){var u=t.audioTrack,s=t.videoTrack,f=t.id3Track,v=t.textTrack,S=this.currentTransmuxState,x=S.accurateTimeOffset,I=S.timeOffset;D.logger.log("[transmuxer.ts]: Flushed fragment "+a.sn+(a.part>-1?" p: "+a.part:"")+" of level "+a.level);var B=this.remuxer.remux(u,s,f,v,I,x,!0,this.id);c.push({remuxResult:B,chunkMeta:a}),a.transmuxing.executeEnd=E()},r.resetInitialTimestamp=function(c){var t=this.demuxer,a=this.remuxer;!t||!a||(t.resetTimeStamp(c),a.resetTimeStamp(c))},r.resetContiguity=function(){var c=this.demuxer,t=this.remuxer;!c||!t||(c.resetContiguity(),t.resetNextTimestamp())},r.resetInitSegment=function(c,t,a,u){var s=this.demuxer,f=this.remuxer;!s||!f||(s.resetInitSegment(c,t,a,u),f.resetInitSegment(c,t,a))},r.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},r.transmux=function(c,t,a,u,s){var f;return t&&t.method==="SAMPLE-AES"?f=this.transmuxSampleAes(c,t,a,u,s):f=this.transmuxUnencrypted(c,a,u,s),f},r.transmuxUnencrypted=function(c,t,a,u){var s=this.demuxer.demux(c,t,!1,!this.config.progressive),f=s.audioTrack,v=s.videoTrack,S=s.id3Track,x=s.textTrack,I=this.remuxer.remux(f,v,S,x,t,a,!1,this.id);return{remuxResult:I,chunkMeta:u}},r.transmuxSampleAes=function(c,t,a,u,s){var f=this;return this.demuxer.demuxSampleAes(c,t,a).then(function(v){var S=f.remuxer.remux(v.audioTrack,v.videoTrack,v.id3Track,v.textTrack,a,u,!1,f.id);return{remuxResult:S,chunkMeta:s}})},r.configureTransmuxer=function(c,t){for(var a=this.config,u=this.observer,s=this.typeSupported,f=this.vendor,v=t.audioCodec,S=t.defaultInitPts,x=t.duration,I=t.initSegmentData,B=t.videoCodec,k,U=0,W=m.length;U<W;U++)if(m[U].demux.probe(c)){k=m[U];break}k||(D.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),k={demux:R.default,remux:T.default});var G=this.demuxer,X=this.remuxer,Y=k.remux,J=k.demux;(!X||!(X instanceof Y))&&(this.remuxer=new Y(u,a,s,f)),(!G||!(G instanceof J))&&(this.demuxer=new J(u,a,s),this.probe=J.probe),this.resetInitSegment(I,v,B,x),this.resetInitialTimestamp(S)},r.needsProbing=function(c,t,a){return!this.demuxer||!this.remuxer||t||a},r.getDecrypter=function(){var c=this.decrypter;return c||(c=this.decrypter=new A.default(this.observer,this.config)),c},i}();function d(i,r){var l=null;return i.byteLength>0&&r!=null&&r.key!=null&&r.iv!==null&&r.method!=null&&(l=r),l}var e=function(r){return{remuxResult:{},chunkMeta:r}};function o(i){return"then"in i&&i.then instanceof Function}var h=function(r,l,c,t,a){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=r,this.videoCodec=l,this.initSegmentData=c,this.duration=t,this.defaultInitPts=a},g=function(r,l,c,t,a,u){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=r,this.contiguous=l,this.accurateTimeOffset=c,this.trackSwitch=t,this.timeOffset=a,this.initSegmentChange=u}},"./src/demux/tsdemuxer.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"discardEPB",function(){return h});var P=n("./src/demux/adts.ts"),L=n("./src/demux/mpegaudio.ts"),A=n("./src/demux/exp-golomb.ts"),M=n("./src/demux/sample-aes.ts"),R=n("./src/events.ts"),O=n("./src/utils/mp4-tools.ts"),_=n("./src/utils/logger.ts"),y=n("./src/errors.ts"),T=n("./src/types/demuxer.ts");function D(){return D=Object.assign?Object.assign.bind():function(g){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var l in r)Object.prototype.hasOwnProperty.call(r,l)&&(g[l]=r[l])}return g},D.apply(this,arguments)}var E=function(){function g(r,l,c){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=r,this.config=l,this.typeSupported=c}g.probe=function(l){return l[0]===71&&l[188]===71},g.createTrack=function(l,c){return{container:l==="video"||l==="audio"?"video/mp2t":void 0,type:l,id:O.RemuxerTrackIdConfig[l],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:l==="audio"?c:void 0}};var i=g.prototype;return i.resetInitSegment=function(l,c,t,a){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=g.createTrack("video"),this._audioTrack=g.createTrack("audio",a),this._id3Track=g.createTrack("id3"),this._txtTrack=g.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=c,this.videoCodec=t,this._duration=a},i.resetTimeStamp=function(){},i.resetContiguity=function(){var l=this._audioTrack,c=this._avcTrack,t=this._id3Track;l&&(l.pesData=null),c&&(c.pesData=null),t&&(t.pesData=null),this.aacOverFlow=null},i.demux=function(l,c,t,a){t===void 0&&(t=!1),a===void 0&&(a=!1),t||(this.sampleAes=null);var u,s=this._avcTrack,f=this._audioTrack,v=this._id3Track,S=this._txtTrack,x=s.pid,I=s.pesData,B=f.pid,k=v.pid,U=f.pesData,W=v.pesData,G=null,X=this.pmtParsed,Y=this._pmtId,J=l.length;if(this.remainderData&&(l=Object(O.appendUint8Array)(this.remainderData,l),J=l.length,this.remainderData=null),J<188&&!a)return this.remainderData=l,{audioTrack:f,videoTrack:s,id3Track:v,textTrack:S};J-=J%188,J<l.byteLength&&!a&&(this.remainderData=new Uint8Array(l.buffer,J,l.buffer.byteLength-J));for(var ee=0,z=0;z<J;z+=188)if(l[z]===71){var q=!!(l[z+1]&64),ie=((l[z+1]&31)<<8)+l[z+2],ae=(l[z+3]&48)>>4,te=void 0;if(ae>1){if(te=z+5+l[z+4],te===z+188)continue}else te=z+4;switch(ie){case x:q&&(I&&(u=e(I))&&this.parseAVCPES(s,S,u,!1),I={data:[],size:0}),I&&(I.data.push(l.subarray(te,z+188)),I.size+=z+188-te);break;case B:if(q){if(U&&(u=e(U)))switch(f.segmentCodec){case"aac":this.parseAACPES(f,u);break;case"mp3":this.parseMPEGPES(f,u);break}U={data:[],size:0}}U&&(U.data.push(l.subarray(te,z+188)),U.size+=z+188-te);break;case k:q&&(W&&(u=e(W))&&this.parseID3PES(v,u),W={data:[],size:0}),W&&(W.data.push(l.subarray(te,z+188)),W.size+=z+188-te);break;case 0:q&&(te+=l[te]+1),Y=this._pmtId=p(l,te);break;case Y:{q&&(te+=l[te]+1);var oe=d(l,te,this.typeSupported,t);x=oe.avc,x>0&&(s.pid=x),B=oe.audio,B>0&&(f.pid=B,f.segmentCodec=oe.segmentCodec),k=oe.id3,k>0&&(v.pid=k),G!==null&&!X&&(_.logger.log("unknown PID '"+G+"' in TS found"),G=null),X=this.pmtParsed=!0;break}case 17:case 8191:break;default:G=ie;break}}else ee++;ee>0&&this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+ee+" TS packet/s that do not start with 0x47"}),s.pesData=I,f.pesData=U,v.pesData=W;var ue={audioTrack:f,videoTrack:s,id3Track:v,textTrack:S};return a&&this.extractRemainingSamples(ue),ue},i.flush=function(){var l=this.remainderData;this.remainderData=null;var c;return l?c=this.demux(l,-1,!1,!0):c={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(c),this.sampleAes?this.decrypt(c,this.sampleAes):c},i.extractRemainingSamples=function(l){var c=l.audioTrack,t=l.videoTrack,a=l.id3Track,u=l.textTrack,s=t.pesData,f=c.pesData,v=a.pesData,S;if(s&&(S=e(s))?(this.parseAVCPES(t,u,S,!0),t.pesData=null):t.pesData=s,f&&(S=e(f))){switch(c.segmentCodec){case"aac":this.parseAACPES(c,S);break;case"mp3":this.parseMPEGPES(c,S);break}c.pesData=null}else f!=null&&f.size&&_.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=f;v&&(S=e(v))?(this.parseID3PES(a,S),a.pesData=null):a.pesData=v},i.demuxSampleAes=function(l,c,t){var a=this.demux(l,t,!0,!this.config.progressive),u=this.sampleAes=new M.default(this.observer,this.config,c);return this.decrypt(a,u)},i.decrypt=function(l,c){return new Promise(function(t){var a=l.audioTrack,u=l.videoTrack;a.samples&&a.segmentCodec==="aac"?c.decryptAacSamples(a.samples,0,function(){u.samples?c.decryptAvcSamples(u.samples,0,0,function(){t(l)}):t(l)}):u.samples&&c.decryptAvcSamples(u.samples,0,0,function(){t(l)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(l,c,t,a){var u=this,s=this.parseAVCNALu(l,t.data),f=!1,v=this.avcSample,S,x=!1;t.data=null,v&&s.length&&!l.audFound&&(o(v,l),v=this.avcSample=m(!1,t.pts,t.dts,"")),s.forEach(function(I){switch(I.type){case 1:{S=!0,v||(v=u.avcSample=m(!0,t.pts,t.dts,"")),f&&(v.debug+="NDR "),v.frame=!0;var B=I.data;if(x&&B.length>4){var k=new A.default(B).readSliceType();(k===2||k===4||k===7||k===9)&&(v.key=!0)}break}case 5:S=!0,v||(v=u.avcSample=m(!0,t.pts,t.dts,"")),f&&(v.debug+="IDR "),v.key=!0,v.frame=!0;break;case 6:{S=!0,f&&v&&(v.debug+="SEI "),Object(O.parseSEIMessageFromNALu)(h(I.data),t.pts,c.samples);break}case 7:if(S=!0,x=!0,f&&v&&(v.debug+="SPS "),!l.sps){var U=new A.default(I.data),W=U.readSPS();l.width=W.width,l.height=W.height,l.pixelRatio=W.pixelRatio,l.sps=[I.data],l.duration=u._duration;for(var G=I.data.subarray(1,4),X="avc1.",Y=0;Y<3;Y++){var J=G[Y].toString(16);J.length<2&&(J="0"+J),X+=J}l.codec=X}break;case 8:S=!0,f&&v&&(v.debug+="PPS "),l.pps||(l.pps=[I.data]);break;case 9:S=!1,l.audFound=!0,v&&o(v,l),v=u.avcSample=m(!1,t.pts,t.dts,f?"AUD ":"");break;case 12:S=!0;break;default:S=!1,v&&(v.debug+="unknown NAL "+I.type+" ");break}if(v&&S){var ee=v.units;ee.push(I)}}),a&&v&&(o(v,l),this.avcSample=null)},i.getLastNalUnit=function(l){var c,t=this.avcSample,a;if((!t||t.units.length===0)&&(t=l[l.length-1]),(c=t)!==null&&c!==void 0&&c.units){var u=t.units;a=u[u.length-1]}return a},i.parseAVCNALu=function(l,c){var t=c.byteLength,a=l.naluState||0,u=a,s=[],f=0,v,S,x,I=-1,B=0;for(a===-1&&(I=0,B=c[0]&31,a=0,f=1);f<t;){if(v=c[f++],!a){a=v?0:1;continue}if(a===1){a=v?0:2;continue}if(!v)a=3;else if(v===1){if(I>=0){var k={data:c.subarray(I,f-a-1),type:B};s.push(k)}else{var U=this.getLastNalUnit(l.samples);if(U&&(u&&f<=4-u&&U.state&&(U.data=U.data.subarray(0,U.data.byteLength-u)),S=f-a-1,S>0)){var W=new Uint8Array(U.data.byteLength+S);W.set(U.data,0),W.set(c.subarray(0,S),U.data.byteLength),U.data=W,U.state=0}}f<t?(x=c[f]&31,I=f,B=x,a=0):a=-1}else a=0}if(I>=0&&a>=0){var G={data:c.subarray(I,t),type:B,state:a};s.push(G)}if(s.length===0){var X=this.getLastNalUnit(l.samples);if(X){var Y=new Uint8Array(X.data.byteLength+c.byteLength);Y.set(X.data,0),Y.set(c,X.data.byteLength),X.data=Y}}return l.naluState=a,s},i.parseAACPES=function(l,c){var t=0,a=this.aacOverFlow,u=c.data;if(a){this.aacOverFlow=null;var s=a.missing,f=a.sample.unit.byteLength;if(s===-1){var v=new Uint8Array(f+u.byteLength);v.set(a.sample.unit,0),v.set(u,f),u=v}else{var S=f-s;a.sample.unit.set(u.subarray(0,s),S),l.samples.push(a.sample),t=a.missing}}var x,I;for(x=t,I=u.length;x<I-1&&!P.isHeader(u,x);x++);if(x!==t){var B,k;if(x<I-1?(B="AAC PES did not start with ADTS header,offset:"+x,k=!1):(B="no ADTS header found in AAC PES",k=!0),_.logger.warn("parsing error:"+B),this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:k,reason:B}),k)return}P.initTrackConfig(l,this.observer,u,x,this.audioCodec);var U;if(c.pts!==void 0)U=c.pts;else if(a){var W=P.getFrameDuration(l.samplerate);U=a.sample.pts+W}else{_.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var G=0,X;x<I;)if(X=P.appendFrame(l,u,x,U,G),x+=X.length,X.missing){this.aacOverFlow=X;break}else for(G++;x<I-1&&!P.isHeader(u,x);x++);},i.parseMPEGPES=function(l,c){var t=c.data,a=t.length,u=0,s=0,f=c.pts;if(f===void 0){_.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;s<a;)if(L.isHeader(t,s)){var v=L.appendFrame(l,t,s,f,u);if(v)s+=v.length,u++;else break}else s++},i.parseID3PES=function(l,c){if(c.pts===void 0){_.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var t=D({},c,{type:this._avcTrack?T.MetadataSchema.emsg:T.MetadataSchema.audioId3});l.samples.push(t)},g}();function m(g,i,r,l){return{key:g,frame:!1,pts:i,dts:r,units:[],debug:l,length:0}}function p(g,i){return(g[i+10]&31)<<8|g[i+11]}function d(g,i,r,l){var c={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},t=(g[i+1]&15)<<8|g[i+2],a=i+3+t-4,u=(g[i+10]&15)<<8|g[i+11];for(i+=12+u;i<a;){var s=(g[i+1]&31)<<8|g[i+2];switch(g[i]){case 207:if(!l){_.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:c.audio===-1&&(c.audio=s);break;case 21:c.id3===-1&&(c.id3=s);break;case 219:if(!l){_.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:c.avc===-1&&(c.avc=s);break;case 3:case 4:r.mpeg!==!0&&r.mp3!==!0?_.logger.log("MPEG audio found, not supported in this browser"):c.audio===-1&&(c.audio=s,c.segmentCodec="mp3");break;case 36:_.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((g[i+3]&15)<<8|g[i+4])+5}return c}function e(g){var i=0,r,l,c,t,a,u=g.data;if(!g||g.size===0)return null;for(;u[0].length<19&&u.length>1;){var s=new Uint8Array(u[0].length+u[1].length);s.set(u[0]),s.set(u[1],u[0].length),u[0]=s,u.splice(1,1)}r=u[0];var f=(r[0]<<16)+(r[1]<<8)+r[2];if(f===1){if(l=(r[4]<<8)+r[5],l&&l>g.size-6)return null;var v=r[7];v&192&&(t=(r[9]&14)*536870912+(r[10]&255)*4194304+(r[11]&254)*16384+(r[12]&255)*128+(r[13]&254)/2,v&64?(a=(r[14]&14)*536870912+(r[15]&255)*4194304+(r[16]&254)*16384+(r[17]&255)*128+(r[18]&254)/2,t-a>60*9e4&&(_.logger.warn(Math.round((t-a)/9e4)+"s delta between PTS and DTS, align them"),t=a)):a=t),c=r[8];var S=c+9;if(g.size<=S)return null;g.size-=S;for(var x=new Uint8Array(g.size),I=0,B=u.length;I<B;I++){r=u[I];var k=r.byteLength;if(S)if(S>k){S-=k;continue}else r=r.subarray(S),k-=S,S=0;x.set(r,i),i+=k}return l&&(l-=c+3),{data:x,pts:t,dts:a,len:l}}return null}function o(g,i){if(g.units.length&&g.frame){if(g.pts===void 0){var r=i.samples,l=r.length;if(l){var c=r[l-1];g.pts=c.pts,g.dts=c.dts}else{i.dropped++;return}}i.samples.push(g)}g.debug.length&&_.logger.log(g.pts+"/"+g.dts+":"+g.debug)}function h(g){for(var i=g.byteLength,r=[],l=1;l<i-2;)g[l]===0&&g[l+1]===0&&g[l+2]===3?(r.push(l+2),l+=2):l++;if(r.length===0)return g;var c=i-r.length,t=new Uint8Array(c),a=0;for(l=0;l<c;a++,l++)a===r[0]&&(a++,r.shift()),t[l]=g[a];return t}b.default=E},"./src/errors.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"ErrorTypes",function(){return P}),n.d(b,"ErrorDetails",function(){return L});var P;(function(A){A.NETWORK_ERROR="networkError",A.MEDIA_ERROR="mediaError",A.KEY_SYSTEM_ERROR="keySystemError",A.MUX_ERROR="muxError",A.OTHER_ERROR="otherError"})(P||(P={}));var L;(function(A){A.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",A.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",A.KEY_SYSTEM_NO_SESSION="keySystemNoSession",A.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",A.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",A.MANIFEST_LOAD_ERROR="manifestLoadError",A.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",A.MANIFEST_PARSING_ERROR="manifestParsingError",A.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",A.LEVEL_EMPTY_ERROR="levelEmptyError",A.LEVEL_LOAD_ERROR="levelLoadError",A.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",A.LEVEL_SWITCH_ERROR="levelSwitchError",A.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",A.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",A.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",A.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",A.FRAG_LOAD_ERROR="fragLoadError",A.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",A.FRAG_DECRYPT_ERROR="fragDecryptError",A.FRAG_PARSING_ERROR="fragParsingError",A.REMUX_ALLOC_ERROR="remuxAllocError",A.KEY_LOAD_ERROR="keyLoadError",A.KEY_LOAD_TIMEOUT="keyLoadTimeOut",A.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",A.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",A.BUFFER_APPEND_ERROR="bufferAppendError",A.BUFFER_APPENDING_ERROR="bufferAppendingError",A.BUFFER_STALLED_ERROR="bufferStalledError",A.BUFFER_FULL_ERROR="bufferFullError",A.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",A.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",A.INTERNAL_EXCEPTION="internalException",A.INTERNAL_ABORTED="aborted",A.UNKNOWN="unknown"})(L||(L={}))},"./src/events.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"Events",function(){return P});var P;(function(L){L.MEDIA_ATTACHING="hlsMediaAttaching",L.MEDIA_ATTACHED="hlsMediaAttached",L.MEDIA_DETACHING="hlsMediaDetaching",L.MEDIA_DETACHED="hlsMediaDetached",L.BUFFER_RESET="hlsBufferReset",L.BUFFER_CODECS="hlsBufferCodecs",L.BUFFER_CREATED="hlsBufferCreated",L.BUFFER_APPENDING="hlsBufferAppending",L.BUFFER_APPENDED="hlsBufferAppended",L.BUFFER_EOS="hlsBufferEos",L.BUFFER_FLUSHING="hlsBufferFlushing",L.BUFFER_FLUSHED="hlsBufferFlushed",L.MANIFEST_LOADING="hlsManifestLoading",L.MANIFEST_LOADED="hlsManifestLoaded",L.MANIFEST_PARSED="hlsManifestParsed",L.LEVEL_SWITCHING="hlsLevelSwitching",L.LEVEL_SWITCHED="hlsLevelSwitched",L.LEVEL_LOADING="hlsLevelLoading",L.LEVEL_LOADED="hlsLevelLoaded",L.LEVEL_UPDATED="hlsLevelUpdated",L.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",L.LEVELS_UPDATED="hlsLevelsUpdated",L.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",L.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",L.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",L.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",L.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",L.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",L.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",L.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",L.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",L.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",L.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",L.CUES_PARSED="hlsCuesParsed",L.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",L.INIT_PTS_FOUND="hlsInitPtsFound",L.FRAG_LOADING="hlsFragLoading",L.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",L.FRAG_LOADED="hlsFragLoaded",L.FRAG_DECRYPTED="hlsFragDecrypted",L.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",L.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",L.FRAG_PARSING_METADATA="hlsFragParsingMetadata",L.FRAG_PARSED="hlsFragParsed",L.FRAG_BUFFERED="hlsFragBuffered",L.FRAG_CHANGED="hlsFragChanged",L.FPS_DROP="hlsFpsDrop",L.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",L.ERROR="hlsError",L.DESTROYING="hlsDestroying",L.KEY_LOADING="hlsKeyLoading",L.KEY_LOADED="hlsKeyLoaded",L.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",L.BACK_BUFFER_REACHED="hlsBackBufferReached"})(P||(P={}))},"./src/hls.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return i});var P=n("./node_modules/url-toolkit/src/url-toolkit.js"),L=n.n(P),A=n("./src/loader/playlist-loader.ts"),M=n("./src/loader/key-loader.ts"),R=n("./src/controller/id3-track-controller.ts"),O=n("./src/controller/latency-controller.ts"),_=n("./src/controller/level-controller.ts"),y=n("./src/controller/fragment-tracker.ts"),T=n("./src/controller/stream-controller.ts"),D=n("./src/is-supported.ts"),E=n("./src/utils/logger.ts"),m=n("./src/config.ts"),p=n("./node_modules/eventemitter3/index.js"),d=n.n(p),e=n("./src/events.ts"),o=n("./src/errors.ts");function h(r,l){for(var c=0;c<l.length;c++){var t=l[c];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,t.key,t)}}function g(r,l,c){return l&&h(r.prototype,l),c&&h(r,c),Object.defineProperty(r,"prototype",{writable:!1}),r}var i=function(){r.isSupported=function(){return Object(D.isSupported)()};function r(c){c===void 0&&(c={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new p.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var t=this.config=Object(m.mergeConfig)(r.DefaultConfig,c);this.userConfig=c,Object(E.enableLogs)(t.debug),this._autoLevelCapping=-1,t.progressive&&Object(m.enableStreamingMode)(t);var a=t.abrController,u=t.bufferController,s=t.capLevelController,f=t.fpsController,v=this.abrController=new a(this),S=this.bufferController=new u(this),x=this.capLevelController=new s(this),I=new f(this),B=new A.default(this),k=new M.default(this),U=new R.default(this),W=this.levelController=new _.default(this),G=new y.FragmentTracker(this),X=this.streamController=new T.default(this,G);x.setStreamController(X),I.setStreamController(X);var Y=[B,k,W,X];this.networkControllers=Y;var J=[v,S,x,I,U,G];this.audioTrackController=this.createController(t.audioTrackController,null,Y),this.createController(t.audioStreamController,G,Y),this.subtitleTrackController=this.createController(t.subtitleTrackController,null,Y),this.createController(t.subtitleStreamController,G,Y),this.createController(t.timelineController,null,J),this.emeController=this.createController(t.emeController,null,J),this.cmcdController=this.createController(t.cmcdController,null,J),this.latencyController=this.createController(O.default,null,J),this.coreComponents=J}var l=r.prototype;return l.createController=function(t,a,u){if(t){var s=a?new t(this,a):new t(this);return u&&u.push(s),s}return null},l.on=function(t,a,u){u===void 0&&(u=this),this._emitter.on(t,a,u)},l.once=function(t,a,u){u===void 0&&(u=this),this._emitter.once(t,a,u)},l.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},l.off=function(t,a,u,s){u===void 0&&(u=this),this._emitter.off(t,a,u,s)},l.listeners=function(t){return this._emitter.listeners(t)},l.emit=function(t,a,u){return this._emitter.emit(t,a,u)},l.trigger=function(t,a){if(this.config.debug)return this.emit(t,t,a);try{return this.emit(t,t,a)}catch(u){E.logger.error("An internal error happened while handling event "+t+'. Error message: "'+u.message+'". Here is a stacktrace:',u),this.trigger(e.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:u})}return!1},l.listenerCount=function(t){return this._emitter.listenerCount(t)},l.destroy=function(){E.logger.log("destroy"),this.trigger(e.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(t){return t.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(t){return t.destroy()}),this.coreComponents.length=0},l.attachMedia=function(t){E.logger.log("attachMedia"),this._media=t,this.trigger(e.Events.MEDIA_ATTACHING,{media:t})},l.detachMedia=function(){E.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},l.loadSource=function(t){this.stopLoad();var a=this.media,u=this.url,s=this.url=P.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});E.logger.log("loadSource:"+s),a&&u&&u!==s&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(a)),this.trigger(e.Events.MANIFEST_LOADING,{url:t})},l.startLoad=function(t){t===void 0&&(t=-1),E.logger.log("startLoad("+t+")"),this.networkControllers.forEach(function(a){a.startLoad(t)})},l.stopLoad=function(){E.logger.log("stopLoad"),this.networkControllers.forEach(function(t){t.stopLoad()})},l.swapAudioCodec=function(){E.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},l.recoverMediaError=function(){E.logger.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},l.removeLevel=function(t,a){a===void 0&&(a=0),this.levelController.removeLevel(t,a)},g(r,[{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){E.logger.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){E.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){E.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){E.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){E.logger.log("set startLevel:"+t),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var a=!!t;a!==this.config.capLevelToPlayerSize&&(a?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=a)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(E.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,a=this.config.minAutoBitrate;if(!t)return 0;for(var u=t.length,s=0;s<u;s++)if(t[s].maxBitrate>=a)return s;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,a=this.autoLevelCapping,u;return a===-1&&t&&t.length?u=t.length-1:u=a,u}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var a=this.audioTrackController;a&&(a.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var a=this.subtitleTrackController;a&&(a.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return t?t.subtitleDisplay:!1},set:function(t){var a=this.subtitleTrackController;a&&(a.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.2.3"}},{key:"Events",get:function(){return e.Events}},{key:"ErrorTypes",get:function(){return o.ErrorTypes}},{key:"ErrorDetails",get:function(){return o.ErrorDetails}},{key:"DefaultConfig",get:function(){return r.defaultConfig?r.defaultConfig:m.hlsDefaultConfig},set:function(t){r.defaultConfig=t}}]),r}();i.defaultConfig=void 0},"./src/is-supported.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"isSupported",function(){return A}),n.d(b,"changeTypeSupported",function(){return M});var P=n("./src/utils/mediasource-helper.ts");function L(){return self.SourceBuffer||self.WebKitSourceBuffer}function A(){var R=Object(P.getMediaSource)();if(!R)return!1;var O=L(),_=R&&typeof R.isTypeSupported=="function"&&R.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!_&&!!y}function M(){var R,O=L();return typeof(O==null||(R=O.prototype)===null||R===void 0?void 0:R.changeType)=="function"}},"./src/loader/date-range.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"DateRangeAttribute",function(){return _}),n.d(b,"DateRange",function(){return y});var P=n("./src/polyfills/number.ts"),L=n("./src/utils/attr-list.ts"),A=n("./src/utils/logger.ts");function M(){return M=Object.assign?Object.assign.bind():function(T){for(var D=1;D<arguments.length;D++){var E=arguments[D];for(var m in E)Object.prototype.hasOwnProperty.call(E,m)&&(T[m]=E[m])}return T},M.apply(this,arguments)}function R(T,D){for(var E=0;E<D.length;E++){var m=D[E];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(T,m.key,m)}}function O(T,D,E){return D&&R(T.prototype,D),E&&R(T,E),Object.defineProperty(T,"prototype",{writable:!1}),T}var _;(function(T){T.ID="ID",T.CLASS="CLASS",T.START_DATE="START-DATE",T.DURATION="DURATION",T.END_DATE="END-DATE",T.END_ON_NEXT="END-ON-NEXT",T.PLANNED_DURATION="PLANNED-DURATION",T.SCTE35_OUT="SCTE35-OUT",T.SCTE35_IN="SCTE35-IN"})(_||(_={}));var y=function(){function T(D,E){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,E){var m=E.attr;for(var p in m)if(Object.prototype.hasOwnProperty.call(D,p)&&D[p]!==m[p]){A.logger.warn('DATERANGE tag attribute: "'+p+'" does not match for tags with ID: "'+D.ID+'"'),this._badValueForSameId=p;break}D=M(new L.AttrList({}),m,D)}if(this.attr=D,this._startDate=new Date(D[_.START_DATE]),_.END_DATE in this.attr){var d=new Date(this.attr[_.END_DATE]);Object(P.isFiniteNumber)(d.getTime())&&(this._endDate=d)}}return O(T,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var E=this.duration;return E!==null?new Date(this._startDate.getTime()+E*1e3):null}},{key:"duration",get:function(){if(_.DURATION in this.attr){var E=this.attr.decimalFloatingPoint(_.DURATION);if(Object(P.isFiniteNumber)(E))return E}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return _.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(_.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(_.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&Object(P.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),T}()},"./src/loader/fragment-loader.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return E}),n.d(b,"LoadError",function(){return p});var P=n("./src/polyfills/number.ts"),L=n("./src/errors.ts");function A(d,e){d.prototype=Object.create(e.prototype),d.prototype.constructor=d,y(d,e)}function M(d){var e=typeof Map=="function"?new Map:void 0;return M=function(h){if(h===null||!_(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(h))return e.get(h);e.set(h,g)}function g(){return R(h,arguments,T(this).constructor)}return g.prototype=Object.create(h.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),y(g,h)},M(d)}function R(d,e,o){return O()?R=Reflect.construct.bind():R=function(g,i,r){var l=[null];l.push.apply(l,i);var c=Function.bind.apply(g,l),t=new c;return r&&y(t,r.prototype),t},R.apply(null,arguments)}function O(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function _(d){return Function.toString.call(d).indexOf("[native code]")!==-1}function y(d,e){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(h,g){return h.__proto__=g,h},y(d,e)}function T(d){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},T(d)}var D=Math.pow(2,17),E=function(){function d(o){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=o}var e=d.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(h,g){var i=this,r=h.url;if(!r)return Promise.reject(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,networkDetails:null},"Fragment does not have a "+(r?"part list":"url")));this.abort();var l=this.config,c=l.fLoader,t=l.loader;return new Promise(function(a,u){i.loader&&i.loader.destroy();var s=i.loader=h.loader=c?new c(l):new t(l),f=m(h),v={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:h.sn==="initSegment"?1/0:D};h.stats=s.stats,s.load(f,v,{onSuccess:function(x,I,B,k){i.resetLoader(h,s),a({frag:h,part:null,payload:x.data,networkDetails:k})},onError:function(x,I,B){i.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,response:x,networkDetails:B}))},onAbort:function(x,I,B){i.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,networkDetails:B}))},onTimeout:function(x,I,B){i.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,networkDetails:B}))},onProgress:function(x,I,B,k){g&&g({frag:h,part:null,payload:B,networkDetails:k})}})})},e.loadPart=function(h,g,i){var r=this;this.abort();var l=this.config,c=l.fLoader,t=l.loader;return new Promise(function(a,u){r.loader&&r.loader.destroy();var s=r.loader=h.loader=c?new c(l):new t(l),f=m(h,g),v={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:D};g.stats=s.stats,s.load(f,v,{onSuccess:function(x,I,B,k){r.resetLoader(h,s),r.updateStatsFromPart(h,g);var U={frag:h,part:g,payload:x.data,networkDetails:k};i(U),a(U)},onError:function(x,I,B){r.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,part:g,response:x,networkDetails:B}))},onAbort:function(x,I,B){h.stats.aborted=g.stats.aborted,r.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,part:g,networkDetails:B}))},onTimeout:function(x,I,B){r.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,part:g,networkDetails:B}))}})})},e.updateStatsFromPart=function(h,g){var i=h.stats,r=g.stats,l=r.total;if(i.loaded+=r.loaded,l){var c=Math.round(h.duration/g.duration),t=Math.min(Math.round(i.loaded/l),c),a=c-t,u=a*Math.round(i.loaded/t);i.total=i.loaded+u}else i.total=Math.max(i.loaded,i.total);var s=i.loading,f=r.loading;s.start?s.first+=f.first-f.start:(s.start=f.start,s.first=f.first),s.end=f.end},e.resetLoader=function(h,g){h.loader=null,this.loader===g&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),g.destroy()},d}();function m(d,e){e===void 0&&(e=null);var o=e||d,h={frag:d,part:e,responseType:"arraybuffer",url:o.url,headers:{},rangeStart:0,rangeEnd:0},g=o.byteRangeStartOffset,i=o.byteRangeEndOffset;return Object(P.isFiniteNumber)(g)&&Object(P.isFiniteNumber)(i)&&(h.rangeStart=g,h.rangeEnd=i),h}var p=function(d){A(e,d);function e(o){for(var h,g=arguments.length,i=new Array(g>1?g-1:0),r=1;r<g;r++)i[r-1]=arguments[r];return h=d.call.apply(d,[this].concat(i))||this,h.data=void 0,h.data=o,h}return e}(M(Error))},"./src/loader/fragment.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"ElementaryStreamTypes",function(){return E}),n.d(b,"BaseSegment",function(){return m}),n.d(b,"Fragment",function(){return p}),n.d(b,"Part",function(){return d});var P=n("./src/polyfills/number.ts"),L=n("./node_modules/url-toolkit/src/url-toolkit.js"),A=n.n(L),M=n("./src/utils/logger.ts"),R=n("./src/loader/level-key.ts"),O=n("./src/loader/load-stats.ts");function _(e,o){e.prototype=Object.create(o.prototype),e.prototype.constructor=e,y(e,o)}function y(e,o){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,i){return g.__proto__=i,g},y(e,o)}function T(e,o){for(var h=0;h<o.length;h++){var g=o[h];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(e,g.key,g)}}function D(e,o,h){return o&&T(e.prototype,o),h&&T(e,h),Object.defineProperty(e,"prototype",{writable:!1}),e}var E;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(E||(E={}));var m=function(){function e(h){var g;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(g={},g[E.AUDIO]=null,g[E.VIDEO]=null,g[E.AUDIOVIDEO]=null,g),this.baseurl=h}var o=e.prototype;return o.setByteRange=function(g,i){var r=g.split("@",2),l=[];r.length===1?l[0]=i?i.byteRangeEndOffset:0:l[0]=parseInt(r[1]),l[1]=parseInt(r[0])+l[0],this._byteRange=l},D(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:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(L.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(g){this._url=g}}]),e}(),p=function(e){_(o,e);function o(g,i){var r;return r=e.call(this,i)||this,r._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkey=void 0,r.type=void 0,r.loader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.appendedPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new O.LoadStats,r.urlId=0,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.type=g,r}var h=o.prototype;return h.createInitializationVector=function(i){for(var r=new Uint8Array(16),l=12;l<16;l++)r[l]=i>>8*(15-l)&255;return r},h.setDecryptDataFromLevelKey=function(i,r){var l=i;return(i==null?void 0:i.method)==="AES-128"&&i.uri&&!i.iv&&(l=R.LevelKey.fromURI(i.uri),l.method=i.method,l.iv=this.createInitializationVector(r),l.keyFormat="identity"),l},h.setElementaryStreamInfo=function(i,r,l,c,t,a){a===void 0&&(a=!1);var u=this.elementaryStreams,s=u[i];if(!s){u[i]={startPTS:r,endPTS:l,startDTS:c,endDTS:t,partial:a};return}s.startPTS=Math.min(s.startPTS,r),s.endPTS=Math.max(s.endPTS,l),s.startDTS=Math.min(s.startDTS,c),s.endDTS=Math.max(s.endDTS,t)},h.clearElementaryStreamInfo=function(){var i=this.elementaryStreams;i[E.AUDIO]=null,i[E.VIDEO]=null,i[E.AUDIOVIDEO]=null},D(o,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var i=this.sn;typeof i!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&M.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),i=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,i)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(P.isFiniteNumber)(this.programDateTime))return null;var i=Object(P.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+i*1e3}},{key:"encrypted",get:function(){var i;return!!((i=this.decryptdata)!==null&&i!==void 0&&i.keyFormat&&this.decryptdata.uri)}}]),o}(m),d=function(e){_(o,e);function o(h,g,i,r,l){var c;c=e.call(this,i)||this,c.fragOffset=0,c.duration=0,c.gap=!1,c.independent=!1,c.relurl=void 0,c.fragment=void 0,c.index=void 0,c.stats=new O.LoadStats,c.duration=h.decimalFloatingPoint("DURATION"),c.gap=h.bool("GAP"),c.independent=h.bool("INDEPENDENT"),c.relurl=h.enumeratedString("URI"),c.fragment=g,c.index=r;var t=h.enumeratedString("BYTERANGE");return t&&c.setByteRange(t,l),l&&(c.fragOffset=l.fragOffset+l.duration),c}return D(o,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var g=this.elementaryStreams;return!!(g.audio||g.video||g.audiovideo)}}]),o}(m)},"./src/loader/key-loader.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return M});var P=n("./src/events.ts"),L=n("./src/errors.ts"),A=n("./src/utils/logger.ts"),M=function(){function R(_){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=_,this.registerListeners()}var O=R.prototype;return O.startLoad=function(y){},O.stopLoad=function(){this.destroyInternalLoaders()},O.registerListeners=function(){this.hls.on(P.Events.KEY_LOADING,this.onKeyLoading,this)},O.unregisterListeners=function(){this.hls.off(P.Events.KEY_LOADING,this.onKeyLoading)},O.destroyInternalLoaders=function(){for(var y in this.loaders){var T=this.loaders[y];T&&T.destroy()}this.loaders={}},O.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},O.onKeyLoading=function(y,T){var D=T.frag,E=D.type,m=this.loaders[E];if(!D.decryptdata){A.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var p=D.decryptdata.uri;if(p!==this.decrypturl||this.decryptkey===null){var d=this.hls.config;if(m&&(A.logger.warn("abort previous key loader for type:"+E),m.abort()),!p){A.logger.warn("key uri is falsy");return}var e=d.loader,o=D.loader=this.loaders[E]=new e(d);this.decrypturl=p,this.decryptkey=null;var h={url:p,frag:D,responseType:"arraybuffer"},g={timeout:d.fragLoadingTimeOut,maxRetry:0,retryDelay:d.fragLoadingRetryDelay,maxRetryDelay:d.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};o.load(h,g,i)}else this.decryptkey&&(D.decryptdata.key=this.decryptkey,this.hls.trigger(P.Events.KEY_LOADED,{frag:D}))},O.loadsuccess=function(y,T,D){var E=D.frag;if(!E.decryptdata){A.logger.error("after key load, decryptdata unset");return}this.decryptkey=E.decryptdata.key=new Uint8Array(y.data),E.loader=null,delete this.loaders[E.type],this.hls.trigger(P.Events.KEY_LOADED,{frag:E})},O.loaderror=function(y,T){var D=T.frag,E=D.loader;E&&E.abort(),delete this.loaders[D.type],this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:D,response:y})},O.loadtimeout=function(y,T){var D=T.frag,E=D.loader;E&&E.abort(),delete this.loaders[D.type],this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:D})},R}()},"./src/loader/level-details.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"LevelDetails",function(){return R});var P=n("./src/polyfills/number.ts");function L(O,_){for(var y=0;y<_.length;y++){var T=_[y];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function A(O,_,y){return _&&L(O.prototype,_),y&&L(O,y),Object.defineProperty(O,"prototype",{writable:!1}),O}var M=10,R=function(){function O(y){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.dateRanges={},this.url=y}var _=O.prototype;return _.reloaded=function(T){if(!T){this.advanced=!0,this.updated=!0;return}var D=this.lastPartSn-T.lastPartSn,E=this.lastPartIndex-T.lastPartIndex;this.updated=this.endSN!==T.endSN||!!E||!!D,this.advanced=this.endSN>T.endSN||D>0||D===0&&E>0,this.updated||this.advanced?this.misses=Math.floor(T.misses*.6):this.misses=T.misses+1,this.availabilityDelay=T.availabilityDelay},A(O,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(P.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||M}},{key:"drift",get:function(){var T=this.driftEndTime-this.driftStartTime;if(T>0){var D=this.driftEnd-this.driftStart;return D*1e3/T}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var T;return(T=this.fragments)!==null&&T!==void 0&&T.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),O}()},"./src/loader/level-key.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"LevelKey",function(){return R});var P=n("./node_modules/url-toolkit/src/url-toolkit.js"),L=n.n(P);function A(O,_){for(var y=0;y<_.length;y++){var T=_[y];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function M(O,_,y){return _&&A(O.prototype,_),y&&A(O,y),Object.defineProperty(O,"prototype",{writable:!1}),O}var R=function(){O.fromURL=function(y,T){return new O(y,T)},O.fromURI=function(y){return new O(y)};function O(_,y){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,y?this._uri=Object(P.buildAbsoluteURL)(_,y,{alwaysNormalize:!0}):this._uri=_}return M(O,[{key:"uri",get:function(){return this._uri}}]),O}()},"./src/loader/load-stats.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"LoadStats",function(){return P});var P=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return h});var P=n("./src/polyfills/number.ts"),L=n("./node_modules/url-toolkit/src/url-toolkit.js"),A=n.n(L),M=n("./src/loader/date-range.ts"),R=n("./src/loader/fragment.ts"),O=n("./src/loader/level-details.ts"),_=n("./src/loader/level-key.ts"),y=n("./src/utils/attr-list.ts"),T=n("./src/utils/logger.ts"),D=n("./src/utils/codecs.ts"),E=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,m=/#EXT-X-MEDIA:(.*)/g,p=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),d=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),e=/\.(mp4|m4s|m4v|m4a)$/i;function o(t){var a,u;return e.test((a=(u=L.parseURL(t))===null||u===void 0?void 0:u.path)!=null?a:"")}var h=function(){function t(){}return t.findGroup=function(u,s){for(var f=0;f<u.length;f++){var v=u[f];if(v.id===s)return v}},t.convertAVC1ToAVCOTI=function(u){var s=u.split(".");if(s.length>2){var f=s.shift()+".";return f+=parseInt(s.shift()).toString(16),f+=("000"+parseInt(s.shift()).toString(16)).slice(-4),f}return u},t.resolve=function(u,s){return L.buildAbsoluteURL(s,u,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(u,s){var f=[],v={},S=!1;E.lastIndex=0;for(var x;(x=E.exec(u))!=null;)if(x[1]){var I=new y.AttrList(x[1]),B={attrs:I,bitrate:I.decimalInteger("AVERAGE-BANDWIDTH")||I.decimalInteger("BANDWIDTH"),name:I.NAME,url:t.resolve(x[2],s)},k=I.decimalResolution("RESOLUTION");k&&(B.width=k.width,B.height=k.height),g((I.CODECS||"").split(/[ ,]+/).filter(function(W){return W}),B),B.videoCodec&&B.videoCodec.indexOf("avc1")!==-1&&(B.videoCodec=t.convertAVC1ToAVCOTI(B.videoCodec)),f.push(B)}else if(x[3]){var U=new y.AttrList(x[3]);U["DATA-ID"]&&(S=!0,v[U["DATA-ID"]]=U)}return{levels:f,sessionData:S?v:null}},t.parseMasterPlaylistMedia=function(u,s,f,v){v===void 0&&(v=[]);var S,x=[],I=0;for(m.lastIndex=0;(S=m.exec(u))!==null;){var B=new y.AttrList(S[1]);if(B.TYPE===f){var k={attrs:B,bitrate:0,id:I++,groupId:B["GROUP-ID"],instreamId:B["INSTREAM-ID"],name:B.NAME||B.LANGUAGE||"",type:f,default:B.bool("DEFAULT"),autoselect:B.bool("AUTOSELECT"),forced:B.bool("FORCED"),lang:B.LANGUAGE,url:B.URI?t.resolve(B.URI,s):""};if(v.length){var U=t.findGroup(v,k.groupId)||v[0];i(k,U,"audioCodec"),i(k,U,"textCodec")}x.push(k)}}return x},t.parseLevelPlaylist=function(u,s,f,v,S){var x=new O.LevelDetails(s),I=x.fragments,B=null,k=0,U=0,W=0,G=0,X=null,Y=new R.Fragment(v,s),J,ee,z,q=-1,ie=!1;for(p.lastIndex=0,x.m3u8=u;(J=p.exec(u))!==null;){ie&&(ie=!1,Y=new R.Fragment(v,s),Y.start=W,Y.sn=k,Y.cc=G,Y.level=f,B&&(Y.initSegment=B,Y.rawProgramDateTime=B.rawProgramDateTime,B.rawProgramDateTime=null));var ae=J[1];if(ae){Y.duration=parseFloat(ae);var te=(" "+J[2]).slice(1);Y.title=te||null,Y.tagList.push(te?["INF",ae,te]:["INF",ae])}else if(J[3])Object(P.isFiniteNumber)(Y.duration)&&(Y.start=W,z&&(Y.levelkey=z),Y.sn=k,Y.level=f,Y.cc=G,Y.urlId=S,I.push(Y),Y.relurl=(" "+J[3]).slice(1),l(Y,X),X=Y,W+=Y.duration,k++,U=0,ie=!0);else if(J[4]){var oe=(" "+J[4]).slice(1);X?Y.setByteRange(oe,X):Y.setByteRange(oe)}else if(J[5])Y.rawProgramDateTime=(" "+J[5]).slice(1),Y.tagList.push(["PROGRAM-DATE-TIME",Y.rawProgramDateTime]),q===-1&&(q=I.length);else{if(J=J[0].match(d),!J){T.logger.warn("No matches on slow regex match for level playlist!");continue}for(ee=1;ee<J.length&&typeof J[ee]=="undefined";ee++);var ue=(" "+J[ee]).slice(1),re=(" "+J[ee+1]).slice(1),he=J[ee+2]?(" "+J[ee+2]).slice(1):"";switch(ue){case"PLAYLIST-TYPE":x.type=re.toUpperCase();break;case"MEDIA-SEQUENCE":k=x.startSN=parseInt(re);break;case"SKIP":{var ge=new y.AttrList(re),Se=ge.decimalInteger("SKIPPED-SEGMENTS");if(Object(P.isFiniteNumber)(Se)){x.skippedSegments=Se;for(var Me=Se;Me--;)I.unshift(null);k+=Se}var Oe=ge.enumeratedString("RECENTLY-REMOVED-DATERANGES");Oe&&(x.recentlyRemovedDateranges=Oe.split(" "));break}case"TARGETDURATION":x.targetduration=parseFloat(re);break;case"VERSION":x.version=parseInt(re);break;case"EXTM3U":break;case"ENDLIST":x.live=!1;break;case"#":(re||he)&&Y.tagList.push(he?[re,he]:[re]);break;case"DISCONTINUITY":G++,Y.tagList.push(["DIS"]);break;case"GAP":Y.tagList.push([ue]);break;case"BITRATE":Y.tagList.push([ue,re]);break;case"DATERANGE":{var Ne=new y.AttrList(re),Ie=new M.DateRange(Ne,x.dateRanges[Ne.ID]);Ie.isValid||x.skippedSegments?x.dateRanges[Ie.id]=Ie:T.logger.warn('Ignoring invalid DATERANGE tag: "'+re+'"'),Y.tagList.push(["EXT-X-DATERANGE",re]);break}case"DISCONTINUITY-SEQUENCE":G=parseInt(re);break;case"KEY":{var Ke,me=new y.AttrList(re),ke=me.enumeratedString("METHOD"),je=me.URI,He=me.hexadecimalInteger("IV"),We=me.enumeratedString("KEYFORMATVERSIONS"),Ye=me.enumeratedString("KEYID"),Ge=(Ke=me.enumeratedString("KEYFORMAT"))!=null?Ke:"identity",nt=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(nt.indexOf(Ge)>-1){T.logger.warn("Keyformat "+Ge+" is not supported from the manifest");continue}else if(Ge!=="identity")continue;ke&&(z=_.LevelKey.fromURL(s,je),je&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(ke)>=0&&(z.method=ke,z.keyFormat=Ge,Ye&&(z.keyID=Ye),We&&(z.keyFormatVersions=We),z.iv=He));break}case"START":{var we=new y.AttrList(re),Be=we.decimalFloatingPoint("TIME-OFFSET");Object(P.isFiniteNumber)(Be)&&(x.startTimeOffset=Be);break}case"MAP":{var $e=new y.AttrList(re);if(Y.duration){var Ue=new R.Fragment(v,s);c(Ue,$e,f,z),B=Ue,Y.initSegment=B,B.rawProgramDateTime&&!Y.rawProgramDateTime&&(Y.rawProgramDateTime=B.rawProgramDateTime)}else c(Y,$e,f,z),B=Y,ie=!0;break}case"SERVER-CONTROL":{var Pe=new y.AttrList(re);x.canBlockReload=Pe.bool("CAN-BLOCK-RELOAD"),x.canSkipUntil=Pe.optionalFloat("CAN-SKIP-UNTIL",0),x.canSkipDateRanges=x.canSkipUntil>0&&Pe.bool("CAN-SKIP-DATERANGES"),x.partHoldBack=Pe.optionalFloat("PART-HOLD-BACK",0),x.holdBack=Pe.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var ot=new y.AttrList(re);x.partTarget=ot.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Xe=x.partList;Xe||(Xe=x.partList=[]);var ft=U>0?Xe[Xe.length-1]:void 0,St=U++,qe=new R.Part(new y.AttrList(re),Y,s,St,ft);Xe.push(qe),Y.duration+=qe.duration;break}case"PRELOAD-HINT":{var Rt=new y.AttrList(re);x.preloadHint=Rt;break}case"RENDITION-REPORT":{var Dt=new y.AttrList(re);x.renditionReports=x.renditionReports||[],x.renditionReports.push(Dt);break}default:T.logger.warn("line parsed but not handled: "+J);break}}}X&&!X.relurl?(I.pop(),W-=X.duration,x.partList&&(x.fragmentHint=X)):x.partList&&(l(Y,X),Y.cc=G,x.fragmentHint=Y);var lt=I.length,ct=I[0],ut=I[lt-1];if(W+=x.skippedSegments*x.targetduration,W>0&&lt&&ut){x.averagetargetduration=W/lt;var At=ut.sn;x.endSN=At!=="initSegment"?At:0,ct&&(x.startCC=ct.cc,ct.initSegment||x.fragments.every(function(Tt){return Tt.relurl&&o(Tt.relurl)})&&(T.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),Y=new R.Fragment(v,s),Y.relurl=ut.relurl,Y.level=f,Y.sn="initSegment",ct.initSegment=Y,x.needSidxRanges=!0))}else x.endSN=0,x.startCC=0;return x.fragmentHint&&(W+=x.fragmentHint.duration),x.totalduration=W,x.endCC=G,q>0&&r(I,q),x},t}();function g(t,a){["video","audio","text"].forEach(function(u){var s=t.filter(function(v){return Object(D.isCodecType)(v,u)});if(s.length){var f=s.filter(function(v){return v.lastIndexOf("avc1",0)===0||v.lastIndexOf("mp4a",0)===0});a[u+"Codec"]=f.length>0?f[0]:s[0],t=t.filter(function(v){return s.indexOf(v)===-1})}}),a.unknownCodecs=t}function i(t,a,u){var s=a[u];s&&(t[u]=s)}function r(t,a){for(var u=t[a],s=a;s--;){var f=t[s];if(!f)return;f.programDateTime=u.programDateTime-f.duration*1e3,u=f}}function l(t,a){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):a!=null&&a.programDateTime&&(t.programDateTime=a.endProgramDateTime),Object(P.isFiniteNumber)(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function c(t,a,u,s){t.relurl=a.URI,a.BYTERANGE&&t.setByteRange(a.BYTERANGE),t.level=u,t.sn="initSegment",s&&(t.levelkey=s),t.initSegment=null}},"./src/loader/playlist-loader.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/polyfills/number.ts"),L=n("./src/events.ts"),A=n("./src/errors.ts"),M=n("./src/utils/logger.ts"),R=n("./src/utils/mp4-tools.ts"),O=n("./src/loader/m3u8-parser.ts"),_=n("./src/types/loader.ts"),y=n("./src/utils/attr-list.ts");function T(m){var p=m.type;switch(p){case _.PlaylistContextType.AUDIO_TRACK:return _.PlaylistLevelType.AUDIO;case _.PlaylistContextType.SUBTITLE_TRACK:return _.PlaylistLevelType.SUBTITLE;default:return _.PlaylistLevelType.MAIN}}function D(m,p){var d=m.url;return(d===void 0||d.indexOf("data:")===0)&&(d=p.url),d}var E=function(){function m(d){this.hls=void 0,this.loaders=Object.create(null),this.hls=d,this.registerListeners()}var p=m.prototype;return p.startLoad=function(e){},p.stopLoad=function(){this.destroyInternalLoaders()},p.registerListeners=function(){var e=this.hls;e.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(L.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.unregisterListeners=function(){var e=this.hls;e.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(L.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.createInternalLoader=function(e){var o=this.hls.config,h=o.pLoader,g=o.loader,i=h||g,r=new i(o);return e.loader=r,this.loaders[e.type]=r,r},p.getInternalLoader=function(e){return this.loaders[e.type]},p.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},p.destroyInternalLoaders=function(){for(var e in this.loaders){var o=this.loaders[e];o&&o.destroy(),this.resetInternalLoader(e)}},p.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},p.onManifestLoading=function(e,o){var h=o.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:_.PlaylistContextType.MANIFEST,url:h,deliveryDirectives:null})},p.onLevelLoading=function(e,o){var h=o.id,g=o.level,i=o.url,r=o.deliveryDirectives;this.load({id:h,groupId:null,level:g,responseType:"text",type:_.PlaylistContextType.LEVEL,url:i,deliveryDirectives:r})},p.onAudioTrackLoading=function(e,o){var h=o.id,g=o.groupId,i=o.url,r=o.deliveryDirectives;this.load({id:h,groupId:g,level:null,responseType:"text",type:_.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:r})},p.onSubtitleTrackLoading=function(e,o){var h=o.id,g=o.groupId,i=o.url,r=o.deliveryDirectives;this.load({id:h,groupId:g,level:null,responseType:"text",type:_.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:r})},p.load=function(e){var o,h=this.hls.config,g=this.getInternalLoader(e);if(g){var i=g.context;if(i&&i.url===e.url){M.logger.trace("[playlist-loader]: playlist request ongoing");return}M.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),g.abort()}var r,l,c,t;switch(e.type){case _.PlaylistContextType.MANIFEST:r=h.manifestLoadingMaxRetry,l=h.manifestLoadingTimeOut,c=h.manifestLoadingRetryDelay,t=h.manifestLoadingMaxRetryTimeout;break;case _.PlaylistContextType.LEVEL:case _.PlaylistContextType.AUDIO_TRACK:case _.PlaylistContextType.SUBTITLE_TRACK:r=0,l=h.levelLoadingTimeOut;break;default:r=h.levelLoadingMaxRetry,l=h.levelLoadingTimeOut,c=h.levelLoadingRetryDelay,t=h.levelLoadingMaxRetryTimeout;break}if(g=this.createInternalLoader(e),(o=e.deliveryDirectives)!==null&&o!==void 0&&o.part){var a;if(e.type===_.PlaylistContextType.LEVEL&&e.level!==null?a=this.hls.levels[e.level].details:e.type===_.PlaylistContextType.AUDIO_TRACK&&e.id!==null?a=this.hls.audioTracks[e.id].details:e.type===_.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(a=this.hls.subtitleTracks[e.id].details),a){var u=a.partTarget,s=a.targetduration;u&&s&&(l=Math.min(Math.max(u*3,s*.8)*1e3,l))}}var f={timeout:l,maxRetry:r,retryDelay:c,maxRetryDelay:t,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};g.load(e,f,v)},p.loadsuccess=function(e,o,h,g){if(g===void 0&&(g=null),h.isSidxRequest){this.handleSidxRequest(e,h),this.handlePlaylistLoaded(e,o,h,g);return}this.resetInternalLoader(h.type);var i=e.data;if(i.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,h,"no EXTM3U delimiter",g);return}o.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,o,h,g):this.handleMasterPlaylist(e,o,h,g)},p.loaderror=function(e,o,h){h===void 0&&(h=null),this.handleNetworkError(o,h,!1,e)},p.loadtimeout=function(e,o,h){h===void 0&&(h=null),this.handleNetworkError(o,h,!0)},p.handleMasterPlaylist=function(e,o,h,g){var i=this.hls,r=e.data,l=D(e,h),c=O.default.parseMasterPlaylist(r,l),t=c.levels,a=c.sessionData;if(!t.length){this.handleManifestParsingError(e,h,"no level found in manifest",g);return}var u=t.map(function(I){return{id:I.attrs.AUDIO,audioCodec:I.audioCodec}}),s=t.map(function(I){return{id:I.attrs.SUBTITLES,textCodec:I.textCodec}}),f=O.default.parseMasterPlaylistMedia(r,l,"AUDIO",u),v=O.default.parseMasterPlaylistMedia(r,l,"SUBTITLES",s),S=O.default.parseMasterPlaylistMedia(r,l,"CLOSED-CAPTIONS");if(f.length){var x=f.some(function(I){return!I.url});!x&&t[0].audioCodec&&!t[0].attrs.AUDIO&&(M.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),f.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}i.trigger(L.Events.MANIFEST_LOADED,{levels:t,audioTracks:f,subtitles:v,captions:S,url:l,stats:o,networkDetails:g,sessionData:a})},p.handleTrackOrLevelPlaylist=function(e,o,h,g){var i=this.hls,r=h.id,l=h.level,c=h.type,t=D(e,h),a=Object(P.isFiniteNumber)(r)?r:0,u=Object(P.isFiniteNumber)(l)?l:a,s=T(h),f=O.default.parseLevelPlaylist(e.data,t,u,s,a);if(!f.fragments.length){i.trigger(L.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:t,reason:"no fragments found in level",level:typeof h.level=="number"?h.level:void 0});return}if(c===_.PlaylistContextType.MANIFEST){var v={attrs:new y.AttrList({}),bitrate:0,details:f,name:"",url:t};i.trigger(L.Events.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:t,stats:o,networkDetails:g,sessionData:null})}if(o.parsing.end=performance.now(),f.needSidxRanges){var S,x=(S=f.fragments[0].initSegment)===null||S===void 0?void 0:S.url;this.load({url:x,isSidxRequest:!0,type:c,level:l,levelDetails:f,id:r,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}h.levelDetails=f,this.handlePlaylistLoaded(e,o,h,g)},p.handleSidxRequest=function(e,o){var h=new Uint8Array(e.data),g=Object(R.findBox)(h,["sidx"])[0];if(!!g){var i=Object(R.parseSegmentIndex)(g);if(!!i){var r=i.references,l=o.levelDetails;r.forEach(function(c,t){var a=c.info,u=l.fragments[t];if(u.byteRange.length===0&&u.setByteRange(String(1+a.end-a.start)+"@"+String(a.start)),u.initSegment){var s=Object(R.findBox)(h,["moov"])[0],f=s?s.length:null;u.initSegment.setByteRange(String(f)+"@0")}})}}},p.handleManifestParsingError=function(e,o,h,g){this.hls.trigger(L.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:o.type===_.PlaylistContextType.MANIFEST,url:e.url,reason:h,response:e,context:o,networkDetails:g})},p.handleNetworkError=function(e,o,h,g){h===void 0&&(h=!1),M.logger.warn("[playlist-loader]: A network "+(h?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var i=A.ErrorDetails.UNKNOWN,r=!1,l=this.getInternalLoader(e);switch(e.type){case _.PlaylistContextType.MANIFEST:i=h?A.ErrorDetails.MANIFEST_LOAD_TIMEOUT:A.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0;break;case _.PlaylistContextType.LEVEL:i=h?A.ErrorDetails.LEVEL_LOAD_TIMEOUT:A.ErrorDetails.LEVEL_LOAD_ERROR,r=!1;break;case _.PlaylistContextType.AUDIO_TRACK:i=h?A.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:A.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,r=!1;break;case _.PlaylistContextType.SUBTITLE_TRACK:i=h?A.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:A.ErrorDetails.SUBTITLE_LOAD_ERROR,r=!1;break}l&&this.resetInternalLoader(e.type);var c={type:A.ErrorTypes.NETWORK_ERROR,details:i,fatal:r,url:e.url,loader:l,context:e,networkDetails:o};g&&(c.response=g),this.hls.trigger(L.Events.ERROR,c)},p.handlePlaylistLoaded=function(e,o,h,g){var i=h.type,r=h.level,l=h.id,c=h.groupId,t=h.loader,a=h.levelDetails,u=h.deliveryDirectives;if(!(a!=null&&a.targetduration)){this.handleManifestParsingError(e,h,"invalid target duration",g);return}if(!!t)switch(a.live&&(t.getCacheAge&&(a.ageHeader=t.getCacheAge()||0),(!t.getCacheAge||isNaN(a.ageHeader))&&(a.ageHeader=0)),i){case _.PlaylistContextType.MANIFEST:case _.PlaylistContextType.LEVEL:this.hls.trigger(L.Events.LEVEL_LOADED,{details:a,level:r||0,id:l||0,stats:o,networkDetails:g,deliveryDirectives:u});break;case _.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(L.Events.AUDIO_TRACK_LOADED,{details:a,id:l||0,groupId:c||"",stats:o,networkDetails:g,deliveryDirectives:u});break;case _.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(L.Events.SUBTITLE_TRACK_LOADED,{details:a,id:l||0,groupId:c||"",stats:o,networkDetails:g,deliveryDirectives:u});break}},m}();b.default=E},"./src/polyfills/number.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"isFiniteNumber",function(){return P}),n.d(b,"MAX_SAFE_INTEGER",function(){return L});var P=Number.isFinite||function(A){return typeof A=="number"&&isFinite(A)},L=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(K,b,n){"use strict";n.r(b);var P=function(){function L(){}return L.getSilentFrame=function(M,R){switch(M){case"mp4a.40.2":if(R===1)return new Uint8Array([0,200,0,128,35,128]);if(R===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(R===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(R===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(R===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(R===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(R===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(R===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(R===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}},L}();b.default=P},"./src/remux/mp4-generator.ts":function(K,b,n){"use strict";n.r(b);var P=Math.pow(2,32)-1,L=function(){function A(){}return A.init=function(){A.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var R;for(R in A.types)A.types.hasOwnProperty(R)&&(A.types[R]=[R.charCodeAt(0),R.charCodeAt(1),R.charCodeAt(2),R.charCodeAt(3)]);var O=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]),_=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]);A.HDLR_TYPES={video:O,audio:_};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),T=new Uint8Array([0,0,0,0,0,0,0,0]);A.STTS=A.STSC=A.STCO=T,A.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),A.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),A.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),A.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var D=new Uint8Array([105,115,111,109]),E=new Uint8Array([97,118,99,49]),m=new Uint8Array([0,0,0,1]);A.FTYP=A.box(A.types.ftyp,D,m,D,E),A.DINF=A.box(A.types.dinf,A.box(A.types.dref,y))},A.box=function(R){for(var O=8,_=arguments.length,y=new Array(_>1?_-1:0),T=1;T<_;T++)y[T-1]=arguments[T];for(var D=y.length,E=D;D--;)O+=y[D].byteLength;var m=new Uint8Array(O);for(m[0]=O>>24&255,m[1]=O>>16&255,m[2]=O>>8&255,m[3]=O&255,m.set(R,4),D=0,O=8;D<E;D++)m.set(y[D],O),O+=y[D].byteLength;return m},A.hdlr=function(R){return A.box(A.types.hdlr,A.HDLR_TYPES[R])},A.mdat=function(R){return A.box(A.types.mdat,R)},A.mdhd=function(R,O){O*=R;var _=Math.floor(O/(P+1)),y=Math.floor(O%(P+1));return A.box(A.types.mdhd,new Uint8Array([1,0,0,0,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,R&255,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},A.mdia=function(R){return A.box(A.types.mdia,A.mdhd(R.timescale,R.duration),A.hdlr(R.type),A.minf(R))},A.mfhd=function(R){return A.box(A.types.mfhd,new Uint8Array([0,0,0,0,R>>24,R>>16&255,R>>8&255,R&255]))},A.minf=function(R){return R.type==="audio"?A.box(A.types.minf,A.box(A.types.smhd,A.SMHD),A.DINF,A.stbl(R)):A.box(A.types.minf,A.box(A.types.vmhd,A.VMHD),A.DINF,A.stbl(R))},A.moof=function(R,O,_){return A.box(A.types.moof,A.mfhd(R),A.traf(_,O))},A.moov=function(R){for(var O=R.length,_=[];O--;)_[O]=A.trak(R[O]);return A.box.apply(null,[A.types.moov,A.mvhd(R[0].timescale,R[0].duration)].concat(_).concat(A.mvex(R)))},A.mvex=function(R){for(var O=R.length,_=[];O--;)_[O]=A.trex(R[O]);return A.box.apply(null,[A.types.mvex].concat(_))},A.mvhd=function(R,O){O*=R;var _=Math.floor(O/(P+1)),y=Math.floor(O%(P+1)),T=new Uint8Array([1,0,0,0,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,R&255,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return A.box(A.types.mvhd,T)},A.sdtp=function(R){var O=R.samples||[],_=new Uint8Array(4+O.length),y,T;for(y=0;y<O.length;y++)T=O[y].flags,_[y+4]=T.dependsOn<<4|T.isDependedOn<<2|T.hasRedundancy;return A.box(A.types.sdtp,_)},A.stbl=function(R){return A.box(A.types.stbl,A.stsd(R),A.box(A.types.stts,A.STTS),A.box(A.types.stsc,A.STSC),A.box(A.types.stsz,A.STSZ),A.box(A.types.stco,A.STCO))},A.avc1=function(R){var O=[],_=[],y,T,D;for(y=0;y<R.sps.length;y++)T=R.sps[y],D=T.byteLength,O.push(D>>>8&255),O.push(D&255),O=O.concat(Array.prototype.slice.call(T));for(y=0;y<R.pps.length;y++)T=R.pps[y],D=T.byteLength,_.push(D>>>8&255),_.push(D&255),_=_.concat(Array.prototype.slice.call(T));var E=A.box(A.types.avcC,new Uint8Array([1,O[3],O[4],O[5],255,224|R.sps.length].concat(O).concat([R.pps.length]).concat(_))),m=R.width,p=R.height,d=R.pixelRatio[0],e=R.pixelRatio[1];return A.box(A.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,m>>8&255,m&255,p>>8&255,p&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),E,A.box(A.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),A.box(A.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,d&255,e>>24,e>>16&255,e>>8&255,e&255])))},A.esds=function(R){var O=R.config.length;return new Uint8Array([0,0,0,0,3,23+O,0,1,0,4,15+O,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([O]).concat(R.config).concat([6,1,2]))},A.mp4a=function(R){var O=R.samplerate;return A.box(A.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,R.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]),A.box(A.types.esds,A.esds(R)))},A.mp3=function(R){var O=R.samplerate;return A.box(A.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,R.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]))},A.stsd=function(R){return R.type==="audio"?R.segmentCodec==="mp3"&&R.codec==="mp3"?A.box(A.types.stsd,A.STSD,A.mp3(R)):A.box(A.types.stsd,A.STSD,A.mp4a(R)):A.box(A.types.stsd,A.STSD,A.avc1(R))},A.tkhd=function(R){var O=R.id,_=R.duration*R.timescale,y=R.width,T=R.height,D=Math.floor(_/(P+1)),E=Math.floor(_%(P+1));return A.box(A.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,O>>24&255,O>>16&255,O>>8&255,O&255,0,0,0,0,D>>24,D>>16&255,D>>8&255,D&255,E>>24,E>>16&255,E>>8&255,E&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,y>>8&255,y&255,0,0,T>>8&255,T&255,0,0]))},A.traf=function(R,O){var _=A.sdtp(R),y=R.id,T=Math.floor(O/(P+1)),D=Math.floor(O%(P+1));return A.box(A.types.traf,A.box(A.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),A.box(A.types.tfdt,new Uint8Array([1,0,0,0,T>>24,T>>16&255,T>>8&255,T&255,D>>24,D>>16&255,D>>8&255,D&255])),A.trun(R,_.length+16+20+8+16+8+8),_)},A.trak=function(R){return R.duration=R.duration||4294967295,A.box(A.types.trak,A.tkhd(R),A.mdia(R))},A.trex=function(R){var O=R.id;return A.box(A.types.trex,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},A.trun=function(R,O){var _=R.samples||[],y=_.length,T=12+16*y,D=new Uint8Array(T),E,m,p,d,e,o;for(O+=8+T,D.set([R.type==="video"?1:0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,O>>>24&255,O>>>16&255,O>>>8&255,O&255],0),E=0;E<y;E++)m=_[E],p=m.duration,d=m.size,e=m.flags,o=m.cts,D.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,o>>>24&255,o>>>16&255,o>>>8&255,o&255],12+16*E);return A.box(A.types.trun,D)},A.initSegment=function(R){A.types||A.init();var O=A.moov(R),_=new Uint8Array(A.FTYP.byteLength+O.byteLength);return _.set(A.FTYP),_.set(O,A.FTYP.byteLength),_},A}();L.types=void 0,L.HDLR_TYPES=void 0,L.STTS=void 0,L.STSC=void 0,L.STCO=void 0,L.STSZ=void 0,L.VMHD=void 0,L.SMHD=void 0,L.STSD=void 0,L.FTYP=void 0,L.DINF=void 0,b.default=L},"./src/remux/mp4-remuxer.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return e}),n.d(b,"normalizePts",function(){return o}),n.d(b,"flushTextTrackMetadataCueSamples",function(){return g}),n.d(b,"flushTextTrackUserdataCueSamples",function(){return i});var P=n("./src/polyfills/number.ts"),L=n("./src/remux/aac-helper.ts"),A=n("./src/remux/mp4-generator.ts"),M=n("./src/events.ts"),R=n("./src/errors.ts"),O=n("./src/utils/logger.ts"),_=n("./src/types/loader.ts"),y=n("./src/utils/timescale-conversion.ts");function T(){return T=Object.assign?Object.assign.bind():function(c){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var u in a)Object.prototype.hasOwnProperty.call(a,u)&&(c[u]=a[u])}return c},T.apply(this,arguments)}var D=10*1e3,E=1024,m=1152,p=null,d=null,e=function(){function c(a,u,s,f){if(f===void 0&&(f=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=a,this.config=u,this.typeSupported=s,this.ISGenerated=!1,p===null){var v=navigator.userAgent||"",S=v.match(/Chrome\/(\d+)/i);p=S?parseInt(S[1]):0}if(d===null){var x=navigator.userAgent.match(/Safari\/(\d+)/i);d=x?parseInt(x[1]):0}}var t=c.prototype;return t.destroy=function(){},t.resetTimeStamp=function(u){O.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=u},t.resetNextTimestamp=function(){O.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){O.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},t.getVideoStartPts=function(u){var s=!1,f=u.reduce(function(v,S){var x=S.pts-v;return x<-4294967296?(s=!0,o(v,S.pts)):x>0?v:S.pts},u[0].pts);return s&&O.logger.debug("PTS rollover detected"),f},t.remux=function(u,s,f,v,S,x,I,B){var k,U,W,G,X,Y,J=S,ee=S,z=u.pid>-1,q=s.pid>-1,ie=s.samples.length,ae=u.samples.length>0,te=I&&ie>0||ie>1,oe=(!z||ae)&&(!q||te)||this.ISGenerated||I;if(oe){this.ISGenerated||(W=this.generateIS(u,s,S));var ue=this.isVideoContiguous,re=-1,he;if(te&&(re=h(s.samples),!ue&&this.config.forceKeyFrameOnDiscontinuity))if(Y=!0,re>0){O.logger.warn("[mp4-remuxer]: Dropped "+re+" out of "+ie+" video samples due to a missing keyframe");var ge=this.getVideoStartPts(s.samples);s.samples=s.samples.slice(re),s.dropped+=re,ee+=(s.samples[0].pts-ge)/s.inputTimeScale,he=ee}else re===-1&&(O.logger.warn("[mp4-remuxer]: No keyframe found out of "+ie+" video samples"),Y=!1);if(this.ISGenerated){if(ae&&te){var Se=this.getVideoStartPts(s.samples),Me=o(u.samples[0].pts,Se)-Se,Oe=Me/s.inputTimeScale;J+=Math.max(0,Oe),ee+=Math.max(0,-Oe)}if(ae){if(u.samplerate||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),W=this.generateIS(u,s,S)),U=this.remuxAudio(u,J,this.isAudioContiguous,x,q||te||B===_.PlaylistLevelType.AUDIO?ee:void 0),te){var Ne=U?U.endPTS-U.startPTS:0;s.inputTimeScale||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),W=this.generateIS(u,s,S)),k=this.remuxVideo(s,ee,ue,Ne)}}else te&&(k=this.remuxVideo(s,ee,ue,0));k&&(k.firstKeyFrame=re,k.independent=re!==-1,k.firstKeyFramePTS=he)}}return this.ISGenerated&&(f.samples.length&&(X=g(f,S,this._initPTS,this._initDTS)),v.samples.length&&(G=i(v,S,this._initPTS))),{audio:U,video:k,initSegment:W,independent:Y,text:G,id3:X}},t.generateIS=function(u,s,f){var v=u.samples,S=s.samples,x=this.typeSupported,I={},B=!Object(P.isFiniteNumber)(this._initPTS),k="audio/mp4",U,W,G;if(B&&(U=W=1/0),u.config&&v.length){switch(u.timescale=u.samplerate,u.segmentCodec){case"mp3":x.mpeg?(k="audio/mpeg",u.codec=""):x.mp3&&(u.codec="mp3");break}I.audio={id:"audio",container:k,codec:u.codec,initSegment:u.segmentCodec==="mp3"&&x.mpeg?new Uint8Array(0):A.default.initSegment([u]),metadata:{channelCount:u.channelCount}},B&&(G=u.inputTimeScale,U=W=v[0].pts-Math.round(G*f))}if(s.sps&&s.pps&&S.length&&(s.timescale=s.inputTimeScale,I.video={id:"main",container:"video/mp4",codec:s.codec,initSegment:A.default.initSegment([s]),metadata:{width:s.width,height:s.height}},B)){G=s.inputTimeScale;var X=this.getVideoStartPts(S),Y=Math.round(G*f);W=Math.min(W,o(S[0].dts,X)-Y),U=Math.min(U,X-Y)}if(Object.keys(I).length)return this.ISGenerated=!0,B&&(this._initPTS=U,this._initDTS=W),{tracks:I,initPTS:U,timescale:G}},t.remuxVideo=function(u,s,f,v){var S=u.inputTimeScale,x=u.samples,I=[],B=x.length,k=this._initPTS,U=this.nextAvcDts,W=8,G=this.videoSampleDuration,X,Y,J=Number.POSITIVE_INFINITY,ee=Number.NEGATIVE_INFINITY,z=!1;if(!f||U===null){var q=s*S,ie=x[0].pts-o(x[0].dts,x[0].pts);U=q-ie}for(var ae=0;ae<B;ae++){var te=x[ae];te.pts=o(te.pts-k,U),te.dts=o(te.dts-k,U),te.dts<x[ae>0?ae-1:ae].dts&&(z=!0)}z&&x.sort(function(Pt,ur){var Lt=Pt.dts-ur.dts,Lr=Pt.pts-ur.pts;return Lt||Lr}),X=x[0].dts,Y=x[x.length-1].dts;var oe=Y-X,ue=oe?Math.round(oe/(B-1)):G||u.inputTimeScale/30;if(f){var re=X-U,he=re>ue,ge=re<-1;if(he||ge){he?O.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(re,!0)+" ms ("+re+"dts) hole between fragments detected, filling it"):O.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-re,!0)+" ms ("+re+"dts) overlapping between fragments detected"),X=U;var Se=x[0].pts-re;x[0].dts=X,x[0].pts=Se,O.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(Se,!0)+"/"+Object(y.toMsFromMpegTsClock)(X,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(re,!0)+" ms")}}X=Math.max(0,X);for(var Me=0,Oe=0,Ne=0;Ne<B;Ne++){for(var Ie=x[Ne],Ke=Ie.units,me=Ke.length,ke=0,je=0;je<me;je++)ke+=Ke[je].data.length;Oe+=ke,Me+=me,Ie.length=ke,Ie.dts=Math.max(Ie.dts,X),J=Math.min(Ie.pts,J),ee=Math.max(Ie.pts,ee)}Y=x[B-1].dts;var He=Oe+4*Me+8,We;try{We=new Uint8Array(He)}catch{this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:R.ErrorTypes.MUX_ERROR,details:R.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:He,reason:"fail allocating video mdat "+He});return}var Ye=new DataView(We.buffer);Ye.setUint32(0,He),We.set(A.default.types.mdat,4);for(var Ge=!1,nt=Number.POSITIVE_INFINITY,we=Number.POSITIVE_INFINITY,Be=Number.NEGATIVE_INFINITY,$e=Number.NEGATIVE_INFINITY,Ue=0;Ue<B;Ue++){for(var Pe=x[Ue],ot=Pe.units,Xe=0,ft=0,St=ot.length;ft<St;ft++){var qe=ot[ft],Rt=qe.data,Dt=qe.data.byteLength;Ye.setUint32(W,Dt),W+=4,We.set(Rt,W),W+=Dt,Xe+=4+Dt}var lt=void 0;if(Ue<B-1)G=x[Ue+1].dts-Pe.dts,lt=x[Ue+1].pts-Pe.pts;else{var ct=this.config,ut=Ue>0?Pe.dts-x[Ue-1].dts:ue;if(lt=Ue>0?Pe.pts-x[Ue-1].pts:ue,ct.stretchShortVideoTrack&&this.nextAudioPts!==null){var At=Math.floor(ct.maxBufferHole*S),Tt=(v?J+v*S:this.nextAudioPts)-Pe.pts;Tt>At?(G=Tt-ut,G<0?G=ut:Ge=!0,O.logger.log("[mp4-remuxer]: It is approximately "+Tt/90+" ms to the next segment; using duration "+G/90+" ms for the last video frame.")):G=ut}else G=ut}var Sr=Math.round(Pe.pts-Pe.dts);nt=Math.min(nt,G),Be=Math.max(Be,G),we=Math.min(we,lt),$e=Math.max($e,lt),I.push(new r(Pe.key,G,Xe,Sr))}if(I.length){if(p){if(p<70){var Kt=I[0].flags;Kt.dependsOn=2,Kt.isNonSync=0}}else if(d&&$e-we<Be-nt&&ue/Be<.025&&I[0].cts===0){O.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var It=X,et=0,or=I.length;et<or;et++){var jt=It+I[et].duration,lr=It+I[et].cts;if(et<or-1){var Wt=jt+I[et+1].cts;I[et].duration=Wt-lr}else I[et].duration=et?I[et-1].duration:ue;I[et].cts=0,It=jt}}}console.assert(G!==null,"mp4SampleDuration must be computed"),G=Ge||!G?ue:G,this.nextAvcDts=U=Y+G,this.videoSampleDuration=G,this.isVideoContiguous=!0;var Dr=A.default.moof(u.sequenceNumber++,X,T({},u,{samples:I})),Ar="video",dt={data1:Dr,data2:We,startPTS:J/S,endPTS:(ee+G)/S,startDTS:X/S,endDTS:U/S,type:Ar,hasAudio:!1,hasVideo:!0,nb:I.length,dropped:u.dropped};return u.samples=[],u.dropped=0,console.assert(We.length,"MDAT length must not be zero"),dt},t.remuxAudio=function(u,s,f,v,S){var x=u.inputTimeScale,I=u.samplerate?u.samplerate:x,B=x/I,k=u.segmentCodec==="aac"?E:m,U=k*B,W=this._initPTS,G=u.segmentCodec==="mp3"&&this.typeSupported.mpeg,X=[],Y=S!==void 0,J=u.samples,ee=G?0:8,z=this.nextAudioPts||-1,q=s*x;if(this.isAudioContiguous=f=f||J.length&&z>0&&(v&&Math.abs(q-z)<9e3||Math.abs(o(J[0].pts-W,q)-z)<20*U),J.forEach(function(qe){qe.pts=o(qe.pts-W,q)}),!f||z<0){if(J=J.filter(function(qe){return qe.pts>=0}),!J.length)return;S===0?z=0:v&&!Y?z=Math.max(0,q):z=J[0].pts}if(u.segmentCodec==="aac")for(var ie=this.config.maxAudioFramesDrift,ae=0,te=z;ae<J.length;ae++){var oe=J[ae],ue=oe.pts,re=ue-te,he=Math.abs(1e3*re/x);if(re<=-ie*U&&Y)ae===0&&(O.logger.warn("Audio frame @ "+(ue/x).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*re/x)+" ms."),this.nextAudioPts=z=te=ue);else if(re>=ie*U&&he<D&&Y){var ge=Math.round(re/U);te=ue-ge*U,te<0&&(ge--,te+=U),ae===0&&(this.nextAudioPts=z=te),O.logger.warn("[mp4-remuxer]: Injecting "+ge+" audio frame @ "+(te/x).toFixed(3)+"s due to "+Math.round(1e3*re/x)+" ms gap.");for(var Se=0;Se<ge;Se++){var Me=Math.max(te,0),Oe=L.default.getSilentFrame(u.manifestCodec||u.codec,u.channelCount);Oe||(O.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Oe=oe.unit.subarray()),J.splice(ae,0,{unit:Oe,pts:Me}),te+=U,ae++}}oe.pts=te,te+=U}for(var Ne=null,Ie=null,Ke,me=0,ke=J.length;ke--;)me+=J[ke].unit.byteLength;for(var je=0,He=J.length;je<He;je++){var We=J[je],Ye=We.unit,Ge=We.pts;if(Ie!==null){var nt=X[je-1];nt.duration=Math.round((Ge-Ie)/B)}else if(f&&u.segmentCodec==="aac"&&(Ge=z),Ne=Ge,me>0){me+=ee;try{Ke=new Uint8Array(me)}catch{this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:R.ErrorTypes.MUX_ERROR,details:R.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:me,reason:"fail allocating audio mdat "+me});return}if(!G){var we=new DataView(Ke.buffer);we.setUint32(0,me),Ke.set(A.default.types.mdat,4)}}else return;Ke.set(Ye,ee);var Be=Ye.byteLength;ee+=Be,X.push(new r(!0,k,Be,0)),Ie=Ge}var $e=X.length;if(!!$e){var Ue=X[X.length-1];this.nextAudioPts=z=Ie+B*Ue.duration;var Pe=G?new Uint8Array(0):A.default.moof(u.sequenceNumber++,Ne/B,T({},u,{samples:X}));u.samples=[];var ot=Ne/x,Xe=z/x,ft="audio",St={data1:Pe,data2:Ke,startPTS:ot,endPTS:Xe,startDTS:ot,endDTS:Xe,type:ft,hasAudio:!0,hasVideo:!1,nb:$e};return this.isAudioContiguous=!0,console.assert(Ke.length,"MDAT length must not be zero"),St}},t.remuxEmptyAudio=function(u,s,f,v){var S=u.inputTimeScale,x=u.samplerate?u.samplerate:S,I=S/x,B=this.nextAudioPts,k=(B!==null?B:v.startDTS*S)+this._initDTS,U=v.endDTS*S+this._initDTS,W=I*E,G=Math.ceil((U-k)/W),X=L.default.getSilentFrame(u.manifestCodec||u.codec,u.channelCount);if(O.logger.warn("[mp4-remuxer]: remux empty Audio"),!X){O.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var Y=[],J=0;J<G;J++){var ee=k+J*W;Y.push({unit:X,pts:ee,dts:ee})}return u.samples=Y,this.remuxAudio(u,s,f,!1)},c}();function o(c,t){var a;if(t===null)return c;for(t<c?a=-8589934592:a=8589934592;Math.abs(c-t)>4294967296;)c+=a;return c}function h(c){for(var t=0;t<c.length;t++)if(c[t].key)return t;return-1}function g(c,t,a,u){var s=c.samples.length;if(!!s){for(var f=c.inputTimeScale,v=0;v<s;v++){var S=c.samples[v];S.pts=o(S.pts-a,t*f)/f,S.dts=o(S.dts-u,t*f)/f}var x=c.samples;return c.samples=[],{samples:x}}}function i(c,t,a){var u=c.samples.length;if(!!u){for(var s=c.inputTimeScale,f=0;f<u;f++){var v=c.samples[f];v.pts=o(v.pts-a,t*s)/s}c.samples.sort(function(x,I){return x.pts-I.pts});var S=c.samples;return c.samples=[],{samples:S}}}var r=function(t,a,u,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=a,this.size=u,this.cts=s,this.flags=new l(t)},l=function(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}},"./src/remux/passthrough-remuxer.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/polyfills/number.ts"),L=n("./src/remux/mp4-remuxer.ts"),A=n("./src/utils/mp4-tools.ts"),M=n("./src/loader/fragment.ts"),R=n("./src/utils/logger.ts"),O=function(){function y(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var T=y.prototype;return T.destroy=function(){},T.resetTimeStamp=function(E){this.initPTS=E,this.lastEndTime=null},T.resetNextTimestamp=function(){this.lastEndTime=null},T.resetInitSegment=function(E,m,p){this.audioCodec=m,this.videoCodec=p,this.generateInitSegment(E),this.emitInitSegment=!0},T.generateInitSegment=function(E){var m=this.audioCodec,p=this.videoCodec;if(!E||!E.byteLength){this.initTracks=void 0,this.initData=void 0;return}var d=this.initData=Object(A.parseInitSegment)(E);m||(m=_(d.audio,M.ElementaryStreamTypes.AUDIO)),p||(p=_(d.video,M.ElementaryStreamTypes.VIDEO));var e={};d.audio&&d.video?e.audiovideo={container:"video/mp4",codec:m+","+p,initSegment:E,id:"main"}:d.audio?e.audio={container:"audio/mp4",codec:m,initSegment:E,id:"audio"}:d.video?e.video={container:"video/mp4",codec:p,initSegment:E,id:"main"}:R.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},T.remux=function(E,m,p,d,e){var o,h=this.initPTS,g=this.lastEndTime,i={audio:void 0,video:void 0,text:d,id3:p,initSegment:void 0};Object(P.isFiniteNumber)(g)||(g=this.lastEndTime=e||0);var r=m.samples;if(!r||!r.length)return i;var l={initPTS:void 0,timescale:1},c=this.initData;if((!c||!c.length)&&(this.generateInitSegment(r),c=this.initData),!c||!c.length)return R.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(l.tracks=this.initTracks,this.emitInitSegment=!1);var t=Object(A.getStartDTS)(c,r);Object(P.isFiniteNumber)(h)||(this.initPTS=l.initPTS=h=t-e);var a=Object(A.getDuration)(r,c),u=E?t-h:g,s=u+a;Object(A.offsetStartDTS)(c,r,h),a>0?this.lastEndTime=s:(R.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var f=!!c.audio,v=!!c.video,S="";f&&(S+="audio"),v&&(S+="video");var x={data1:r,startPTS:u,startDTS:u,endPTS:s,endDTS:s,type:S,hasAudio:f,hasVideo:v,nb:1,dropped:0};i.audio=x.type==="audio"?x:void 0,i.video=x.type!=="audio"?x:void 0,i.initSegment=l;var I=(o=this.initPTS)!=null?o:0;return i.id3=Object(L.flushTextTrackMetadataCueSamples)(p,e,I,I),d.samples.length&&(i.text=Object(L.flushTextTrackUserdataCueSamples)(d,e,I)),i},y}();function _(y,T){var D=y==null?void 0:y.codec;return D&&D.length>4?D:D==="hvc1"||D==="hev1"?"hvc1.1.c.L120.90":D==="av01"?"av01.0.04M.08":D==="avc1"||T===M.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}b.default=O},"./src/task-loop.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return P});var P=function(){function L(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var A=L.prototype;return A.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},A.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},A.onHandlerDestroyed=function(){},A.hasInterval=function(){return!!this._tickInterval},A.hasNextTick=function(){return!!this._tickTimer},A.setInterval=function(R){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,R),!0)},A.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},A.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},A.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},A.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},A.doTick=function(){},L}()},"./src/types/cmcd.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"CMCDVersion",function(){return P}),n.d(b,"CMCDObjectType",function(){return L}),n.d(b,"CMCDStreamingFormat",function(){return A}),n.d(b,"CMCDStreamType",function(){return M});var P=1,L;(function(R){R.MANIFEST="m",R.AUDIO="a",R.VIDEO="v",R.MUXED="av",R.INIT="i",R.CAPTION="c",R.TIMED_TEXT="tt",R.KEY="k",R.OTHER="o"})(L||(L={}));var A;(function(R){R.DASH="d",R.HLS="h",R.SMOOTH="s",R.OTHER="o"})(A||(A={}));var M;(function(R){R.VOD="v",R.LIVE="l"})(M||(M={}))},"./src/types/demuxer.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"MetadataSchema",function(){return P});var P;(function(L){L.audioId3="org.id3",L.dateRange="com.apple.quicktime.HLS",L.emsg="https://aomedia.org/emsg/ID3"})(P||(P={}))},"./src/types/level.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"HlsSkip",function(){return A}),n.d(b,"getSkipValue",function(){return M}),n.d(b,"HlsUrlParameters",function(){return R}),n.d(b,"Level",function(){return O});function P(_,y){for(var T=0;T<y.length;T++){var D=y[T];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function L(_,y,T){return y&&P(_.prototype,y),T&&P(_,T),Object.defineProperty(_,"prototype",{writable:!1}),_}var A;(function(_){_.No="",_.Yes="YES",_.v2="v2"})(A||(A={}));function M(_,y){var T=_.canSkipUntil,D=_.canSkipDateRanges,E=_.endSN,m=y!==void 0?y-E:0;return T&&m<T?D?A.v2:A.Yes:A.No}var R=function(){function _(T,D,E){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=T,this.part=D,this.skip=E}var y=_.prototype;return y.addDirectives=function(D){var E=new self.URL(D);return this.msn!==void 0&&E.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&E.searchParams.set("_HLS_part",this.part.toString()),this.skip&&E.searchParams.set("_HLS_skip",this.skip),E.toString()},_}(),O=function(){function _(y){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[y.url],this.attrs=y.attrs,this.bitrate=y.bitrate,y.details&&(this.details=y.details),this.id=y.id||0,this.name=y.name,this.width=y.width||0,this.height=y.height||0,this.audioCodec=y.audioCodec,this.videoCodec=y.videoCodec,this.unknownCodecs=y.unknownCodecs,this.codecSet=[y.videoCodec,y.audioCodec].filter(function(T){return T}).join(",").replace(/\.[^.,]+/g,"")}return L(_,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(T){var D=T%this.url.length;this._urlId!==D&&(this.details=void 0,this._urlId=D)}}]),_}()},"./src/types/loader.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"PlaylistContextType",function(){return P}),n.d(b,"PlaylistLevelType",function(){return L});var P;(function(A){A.MANIFEST="manifest",A.LEVEL="level",A.AUDIO_TRACK="audioTrack",A.SUBTITLE_TRACK="subtitleTrack"})(P||(P={}));var L;(function(A){A.MAIN="main",A.AUDIO="audio",A.SUBTITLE="subtitle"})(L||(L={}))},"./src/types/transmuxer.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"ChunkMetadata",function(){return P});var P=function(M,R,O,_,y,T){_===void 0&&(_=0),y===void 0&&(y=-1),T===void 0&&(T=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=L(),this.buffering={audio:L(),video:L(),audiovideo:L()},this.level=M,this.sn=R,this.id=O,this.size=_,this.part=y,this.partial=T};function L(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"AttrList",function(){return A});var P=/^(\d+)x(\d+)$/,L=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,A=function(){function M(O){typeof O=="string"&&(O=M.parseAttrList(O));for(var _ in O)O.hasOwnProperty(_)&&(this[_]=O[_])}var R=M.prototype;return R.decimalInteger=function(_){var y=parseInt(this[_],10);return y>Number.MAX_SAFE_INTEGER?1/0:y},R.hexadecimalInteger=function(_){if(this[_]){var y=(this[_]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var T=new Uint8Array(y.length/2),D=0;D<y.length/2;D++)T[D]=parseInt(y.slice(D*2,D*2+2),16);return T}else return null},R.hexadecimalIntegerAsNumber=function(_){var y=parseInt(this[_],16);return y>Number.MAX_SAFE_INTEGER?1/0:y},R.decimalFloatingPoint=function(_){return parseFloat(this[_])},R.optionalFloat=function(_,y){var T=this[_];return T?parseFloat(T):y},R.enumeratedString=function(_){return this[_]},R.bool=function(_){return this[_]==="YES"},R.decimalResolution=function(_){var y=P.exec(this[_]);if(y!==null)return{width:parseInt(y[1],10),height:parseInt(y[2],10)}},M.parseAttrList=function(_){var y,T={},D='"';for(L.lastIndex=0;(y=L.exec(_))!==null;){var E=y[2];E.indexOf(D)===0&&E.lastIndexOf(D)===E.length-1&&(E=E.slice(1,-1)),T[y[1]]=E}return T},M}()},"./src/utils/binary-search.ts":function(K,b,n){"use strict";n.r(b);var P={search:function(A,M){for(var R=0,O=A.length-1,_=null,y=null;R<=O;){_=(R+O)/2|0,y=A[_];var T=M(y);if(T>0)R=_+1;else if(T<0)O=_-1;else return y}return null}};b.default=P},"./src/utils/buffer-helper.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"BufferHelper",function(){return A});var P=n("./src/utils/logger.ts"),L={length:0,start:function(){return 0},end:function(){return 0}},A=function(){function M(){}return M.isBuffered=function(O,_){try{if(O){for(var y=M.getBuffered(O),T=0;T<y.length;T++)if(_>=y.start(T)&&_<=y.end(T))return!0}}catch{}return!1},M.bufferInfo=function(O,_,y){try{if(O){var T=M.getBuffered(O),D=[],E;for(E=0;E<T.length;E++)D.push({start:T.start(E),end:T.end(E)});return this.bufferedInfo(D,_,y)}}catch{}return{len:0,start:_,end:_,nextStart:void 0}},M.bufferedInfo=function(O,_,y){_=Math.max(0,_),O.sort(function(r,l){var c=r.start-l.start;return c||l.end-r.end});var T=[];if(y)for(var D=0;D<O.length;D++){var E=T.length;if(E){var m=T[E-1].end;O[D].start-m<y?O[D].end>m&&(T[E-1].end=O[D].end):T.push(O[D])}else T.push(O[D])}else T=O;for(var p=0,d,e=_,o=_,h=0;h<T.length;h++){var g=T[h].start,i=T[h].end;if(_+y>=g&&_<i)e=g,o=i,p=o-_;else if(_+y<g){d=g;break}}return{len:p,start:e||0,end:o||0,nextStart:d}},M.getBuffered=function(O){try{return O.buffered}catch(_){return P.logger.log("failed to get media.buffered",_),L}},M}()},"./src/utils/cea-608-parser.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"Row",function(){return o}),n.d(b,"CaptionScreen",function(){return h});var P=n("./src/utils/logger.ts"),L={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},A=function(a){var u=a;return L.hasOwnProperty(a)&&(u=L[a]),String.fromCharCode(u)},M=15,R=100,O={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_={17:2,18:4,21:6,22:8,23:10,19:13,20:15},y={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},T={25:2,26:4,29:6,30:8,31:10,27:13,28:15},D=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],E;(function(t){t[t.ERROR=0]="ERROR",t[t.TEXT=1]="TEXT",t[t.WARNING=2]="WARNING",t[t.INFO=2]="INFO",t[t.DEBUG=3]="DEBUG",t[t.DATA=3]="DATA"})(E||(E={}));var m=function(){function t(){this.time=null,this.verboseLevel=E.ERROR}var a=t.prototype;return a.log=function(s,f){this.verboseLevel>=s&&P.logger.log(this.time+" ["+s+"] "+f)},t}(),p=function(a){for(var u=[],s=0;s<a.length;s++)u.push(a[s].toString(16));return u},d=function(){function t(u,s,f,v,S){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=u||"white",this.underline=s||!1,this.italics=f||!1,this.background=v||"black",this.flash=S||!1}var a=t.prototype;return a.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},a.setStyles=function(s){for(var f=["foreground","underline","italics","background","flash"],v=0;v<f.length;v++){var S=f[v];s.hasOwnProperty(S)&&(this[S]=s[S])}},a.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},a.equals=function(s){return this.foreground===s.foreground&&this.underline===s.underline&&this.italics===s.italics&&this.background===s.background&&this.flash===s.flash},a.copy=function(s){this.foreground=s.foreground,this.underline=s.underline,this.italics=s.italics,this.background=s.background,this.flash=s.flash},a.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},t}(),e=function(){function t(u,s,f,v,S,x){this.uchar=void 0,this.penState=void 0,this.uchar=u||" ",this.penState=new d(s,f,v,S,x)}var a=t.prototype;return a.reset=function(){this.uchar=" ",this.penState.reset()},a.setChar=function(s,f){this.uchar=s,this.penState.copy(f)},a.setPenState=function(s){this.penState.copy(s)},a.equals=function(s){return this.uchar===s.uchar&&this.penState.equals(s.penState)},a.copy=function(s){this.uchar=s.uchar,this.penState.copy(s.penState)},a.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},t}(),o=function(){function t(u){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var s=0;s<R;s++)this.chars.push(new e);this.logger=u,this.pos=0,this.currPenState=new d}var a=t.prototype;return a.equals=function(s){for(var f=!0,v=0;v<R;v++)if(!this.chars[v].equals(s.chars[v])){f=!1;break}return f},a.copy=function(s){for(var f=0;f<R;f++)this.chars[f].copy(s.chars[f])},a.isEmpty=function(){for(var s=!0,f=0;f<R;f++)if(!this.chars[f].isEmpty()){s=!1;break}return s},a.setCursor=function(s){this.pos!==s&&(this.pos=s),this.pos<0?(this.logger.log(E.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>R&&(this.logger.log(E.DEBUG,"Too large cursor position "+this.pos),this.pos=R)},a.moveCursor=function(s){var f=this.pos+s;if(s>1)for(var v=this.pos+1;v<f+1;v++)this.chars[v].setPenState(this.currPenState);this.setCursor(f)},a.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},a.insertChar=function(s){s>=144&&this.backSpace();var f=A(s);if(this.pos>=R){this.logger.log(E.ERROR,"Cannot insert "+s.toString(16)+" ("+f+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(f,this.currPenState),this.moveCursor(1)},a.clearFromPos=function(s){var f;for(f=s;f<R;f++)this.chars[f].reset()},a.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},a.clearToEndOfRow=function(){this.clearFromPos(this.pos)},a.getTextString=function(){for(var s=[],f=!0,v=0;v<R;v++){var S=this.chars[v].uchar;S!==" "&&(f=!1),s.push(S)}return f?"":s.join("")},a.setPenStyles=function(s){this.currPenState.setStyles(s);var f=this.chars[this.pos];f.setPenState(this.currPenState)},t}(),h=function(){function t(u){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var s=0;s<M;s++)this.rows.push(new o(u));this.logger=u,this.currRow=M-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var a=t.prototype;return a.reset=function(){for(var s=0;s<M;s++)this.rows[s].clear();this.currRow=M-1},a.equals=function(s){for(var f=!0,v=0;v<M;v++)if(!this.rows[v].equals(s.rows[v])){f=!1;break}return f},a.copy=function(s){for(var f=0;f<M;f++)this.rows[f].copy(s.rows[f])},a.isEmpty=function(){for(var s=!0,f=0;f<M;f++)if(!this.rows[f].isEmpty()){s=!1;break}return s},a.backSpace=function(){var s=this.rows[this.currRow];s.backSpace()},a.clearToEndOfRow=function(){var s=this.rows[this.currRow];s.clearToEndOfRow()},a.insertChar=function(s){var f=this.rows[this.currRow];f.insertChar(s)},a.setPen=function(s){var f=this.rows[this.currRow];f.setPenStyles(s)},a.moveCursor=function(s){var f=this.rows[this.currRow];f.moveCursor(s)},a.setCursor=function(s){this.logger.log(E.INFO,"setCursor: "+s);var f=this.rows[this.currRow];f.setCursor(s)},a.setPAC=function(s){this.logger.log(E.INFO,"pacData = "+JSON.stringify(s));var f=s.row-1;if(this.nrRollUpRows&&f<this.nrRollUpRows-1&&(f=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==f){for(var v=0;v<M;v++)this.rows[v].clear();var S=this.currRow+1-this.nrRollUpRows,x=this.lastOutputScreen;if(x){var I=x.rows[S].cueStartTime,B=this.logger.time;if(I&&B!==null&&I<B)for(var k=0;k<this.nrRollUpRows;k++)this.rows[f-this.nrRollUpRows+k+1].copy(x.rows[S+k])}}this.currRow=f;var U=this.rows[this.currRow];if(s.indent!==null){var W=s.indent,G=Math.max(W-1,0);U.setCursor(s.indent),s.color=U.chars[G].penState.foreground}var X={foreground:s.color,underline:s.underline,italics:s.italics,background:"black",flash:!1};this.setPen(X)},a.setBkgData=function(s){this.logger.log(E.INFO,"bkgData = "+JSON.stringify(s)),this.backSpace(),this.setPen(s),this.insertChar(32)},a.setRollUpRows=function(s){this.nrRollUpRows=s},a.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(E.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(E.TEXT,this.getDisplayText());var s=this.currRow+1-this.nrRollUpRows,f=this.rows.splice(s,1)[0];f.clear(),this.rows.splice(this.currRow,0,f),this.logger.log(E.INFO,"Rolling up")},a.getDisplayText=function(s){s=s||!1;for(var f=[],v="",S=-1,x=0;x<M;x++){var I=this.rows[x].getTextString();I&&(S=x+1,s?f.push("Row "+S+": '"+I+"'"):f.push(I.trim()))}return f.length>0&&(s?v="["+f.join(" | ")+"]":v=f.join(`
20
- `)),v},a.getTextAndFormat=function(){return this.rows},t}(),g=function(){function t(u,s,f){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=u,this.outputFilter=s,this.mode=null,this.verbose=0,this.displayedMemory=new h(f),this.nonDisplayedMemory=new h(f),this.lastOutputScreen=new h(f),this.currRollUpRow=this.displayedMemory.rows[M-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=f}var a=t.prototype;return a.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[M-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},a.getHandler=function(){return this.outputFilter},a.setHandler=function(s){this.outputFilter=s},a.setPAC=function(s){this.writeScreen.setPAC(s)},a.setBkgData=function(s){this.writeScreen.setBkgData(s)},a.setMode=function(s){s!==this.mode&&(this.mode=s,this.logger.log(E.INFO,"MODE="+s),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=s)},a.insertChars=function(s){for(var f=0;f<s.length;f++)this.writeScreen.insertChar(s[f]);var v=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(E.INFO,v+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(E.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},a.ccRCL=function(){this.logger.log(E.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},a.ccBS=function(){this.logger.log(E.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},a.ccAOF=function(){},a.ccAON=function(){},a.ccDER=function(){this.logger.log(E.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},a.ccRU=function(s){this.logger.log(E.INFO,"RU("+s+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(s)},a.ccFON=function(){this.logger.log(E.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},a.ccRDC=function(){this.logger.log(E.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},a.ccTR=function(){this.logger.log(E.INFO,"TR"),this.setMode("MODE_TEXT")},a.ccRTD=function(){this.logger.log(E.INFO,"RTD"),this.setMode("MODE_TEXT")},a.ccEDM=function(){this.logger.log(E.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},a.ccCR=function(){this.logger.log(E.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},a.ccENM=function(){this.logger.log(E.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},a.ccEOC=function(){if(this.logger.log(E.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var s=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=s,this.writeScreen=this.nonDisplayedMemory,this.logger.log(E.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},a.ccTO=function(s){this.logger.log(E.INFO,"TO("+s+") - Tab Offset"),this.writeScreen.moveCursor(s)},a.ccMIDROW=function(s){var f={flash:!1};if(f.underline=s%2===1,f.italics=s>=46,f.italics)f.foreground="white";else{var v=Math.floor(s/2)-16,S=["white","green","blue","cyan","red","yellow","magenta"];f.foreground=S[v]}this.logger.log(E.INFO,"MIDROW: "+JSON.stringify(f)),this.writeScreen.setPen(f)},a.outputDataUpdate=function(s){s===void 0&&(s=!1);var f=this.logger.time;f!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=f:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,f,this.lastOutputScreen),s&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:f),this.lastOutputScreen.copy(this.displayedMemory))},a.cueSplitAtTime=function(s){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,s,this.displayedMemory),this.cueStartTime=s))},t}(),i=function(){function t(u,s,f){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var v=new m;this.channels=[null,new g(u,s,v),new g(u+1,f,v)],this.cmdHistory=c(),this.logger=v}var a=t.prototype;return a.getHandler=function(s){return this.channels[s].getHandler()},a.setHandler=function(s,f){this.channels[s].setHandler(f)},a.addData=function(s,f){var v,S,x,I=!1;this.logger.time=s;for(var B=0;B<f.length;B+=2)if(S=f[B]&127,x=f[B+1]&127,!(S===0&&x===0)){if(this.logger.log(E.DATA,"["+p([f[B],f[B+1]])+"] -> ("+p([S,x])+")"),v=this.parseCmd(S,x),v||(v=this.parseMidrow(S,x)),v||(v=this.parsePAC(S,x)),v||(v=this.parseBackgroundAttributes(S,x)),!v&&(I=this.parseChars(S,x),I)){var k=this.currentChannel;if(k&&k>0){var U=this.channels[k];U.insertChars(I)}else this.logger.log(E.WARNING,"No channel found yet. TEXT-MODE?")}!v&&!I&&this.logger.log(E.WARNING,"Couldn't parse cleaned data "+p([S,x])+" orig: "+p([f[B],f[B+1]]))}},a.parseCmd=function(s,f){var v=this.cmdHistory,S=(s===20||s===28||s===21||s===29)&&f>=32&&f<=47,x=(s===23||s===31)&&f>=33&&f<=35;if(!(S||x))return!1;if(l(s,f,v))return r(null,null,v),this.logger.log(E.DEBUG,"Repeated command ("+p([s,f])+") is dropped"),!0;var I=s===20||s===21||s===23?1:2,B=this.channels[I];return s===20||s===21||s===28||s===29?f===32?B.ccRCL():f===33?B.ccBS():f===34?B.ccAOF():f===35?B.ccAON():f===36?B.ccDER():f===37?B.ccRU(2):f===38?B.ccRU(3):f===39?B.ccRU(4):f===40?B.ccFON():f===41?B.ccRDC():f===42?B.ccTR():f===43?B.ccRTD():f===44?B.ccEDM():f===45?B.ccCR():f===46?B.ccENM():f===47&&B.ccEOC():B.ccTO(f-32),r(s,f,v),this.currentChannel=I,!0},a.parseMidrow=function(s,f){var v=0;if((s===17||s===25)&&f>=32&&f<=47){if(s===17?v=1:v=2,v!==this.currentChannel)return this.logger.log(E.ERROR,"Mismatch channel in midrow parsing"),!1;var S=this.channels[v];return S?(S.ccMIDROW(f),this.logger.log(E.DEBUG,"MIDROW ("+p([s,f])+")"),!0):!1}return!1},a.parsePAC=function(s,f){var v,S=this.cmdHistory,x=(s>=17&&s<=23||s>=25&&s<=31)&&f>=64&&f<=127,I=(s===16||s===24)&&f>=64&&f<=95;if(!(x||I))return!1;if(l(s,f,S))return r(null,null,S),!0;var B=s<=23?1:2;f>=64&&f<=95?v=B===1?O[s]:y[s]:v=B===1?_[s]:T[s];var k=this.channels[B];return k?(k.setPAC(this.interpretPAC(v,f)),r(s,f,S),this.currentChannel=B,!0):!1},a.interpretPAC=function(s,f){var v,S={color:null,italics:!1,indent:null,underline:!1,row:s};return f>95?v=f-96:v=f-64,S.underline=(v&1)===1,v<=13?S.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(v/2)]:v<=15?(S.italics=!0,S.color="white"):S.indent=Math.floor((v-16)/2)*4,S},a.parseChars=function(s,f){var v,S=null,x=null;if(s>=25?(v=2,x=s-8):(v=1,x=s),x>=17&&x<=19){var I;x===17?I=f+80:x===18?I=f+112:I=f+144,this.logger.log(E.INFO,"Special char '"+A(I)+"' in channel "+v),S=[I]}else s>=32&&s<=127&&(S=f===0?[s]:[s,f]);if(S){var B=p(S);this.logger.log(E.DEBUG,"Char codes = "+B.join(",")),r(s,f,this.cmdHistory)}return S},a.parseBackgroundAttributes=function(s,f){var v=(s===16||s===24)&&f>=32&&f<=47,S=(s===23||s===31)&&f>=45&&f<=47;if(!(v||S))return!1;var x,I={};s===16||s===24?(x=Math.floor((f-32)/2),I.background=D[x],f%2===1&&(I.background=I.background+"_semi")):f===45?I.background="transparent":(I.foreground="black",f===47&&(I.underline=!0));var B=s<=23?1:2,k=this.channels[B];return k.setBkgData(I),r(s,f,this.cmdHistory),!0},a.reset=function(){for(var s=0;s<Object.keys(this.channels).length;s++){var f=this.channels[s];f&&f.reset()}this.cmdHistory=c()},a.cueSplitAtTime=function(s){for(var f=0;f<this.channels.length;f++){var v=this.channels[f];v&&v.cueSplitAtTime(s)}},t}();function r(t,a,u){u.a=t,u.b=a}function l(t,a,u){return u.a===t&&u.b===a}function c(){return{a:null,b:null}}b.default=i},"./src/utils/codecs.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"isCodecType",function(){return L}),n.d(b,"isCodecSupportedInMp4",function(){return A});var P={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,av01:!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},text:{stpp:!0,wvtt:!0}};function L(M,R){var O=P[R];return!!O&&O[M.slice(0,4)]===!0}function A(M,R){return MediaSource.isTypeSupported((R||"video")+'/mp4;codecs="'+M+'"')}},"./src/utils/cues.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/utils/vttparser.ts"),L=n("./src/utils/webvtt-parser.ts"),A=n("./src/utils/texttrack-utils.ts"),M=/\s/,R={newCue:function(_,y,T,D){for(var E=[],m,p,d,e,o,h=self.VTTCue||self.TextTrackCue,g=0;g<D.rows.length;g++)if(m=D.rows[g],d=!0,e=0,o="",!m.isEmpty()){for(var i=0;i<m.chars.length;i++)M.test(m.chars[i].uchar)&&d?e++:(o+=m.chars[i].uchar,d=!1);m.cueStartTime=y,y===T&&(T+=1e-4),e>=16?e--:e++;var r=Object(P.fixLineBreaks)(o.trim()),l=Object(L.generateCueId)(y,T,r);(!_||!_.cues||!_.cues.getCueById(l))&&(p=new h(y,T,r),p.id=l,p.line=g+1,p.align="left",p.position=10+Math.min(80,Math.floor(e*8/32)*10),E.push(p))}return _&&E.length&&(E.sort(function(c,t){return c.line==="auto"||t.line==="auto"?0:c.line>8&&t.line>8?t.line-c.line:c.line-t.line}),E.forEach(function(c){return Object(A.addCueToTrack)(_,c)})),E}};b.default=R},"./src/utils/discontinuities.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"findFirstFragWithCC",function(){return M}),n.d(b,"shouldAlignOnDiscontinuities",function(){return R}),n.d(b,"findDiscontinuousReferenceFrag",function(){return O}),n.d(b,"adjustSlidingStart",function(){return y}),n.d(b,"alignStream",function(){return T}),n.d(b,"alignPDT",function(){return E}),n.d(b,"alignFragmentByPDTDelta",function(){return m}),n.d(b,"alignMediaPlaylistByPDT",function(){return p});var P=n("./src/polyfills/number.ts"),L=n("./src/utils/logger.ts"),A=n("./src/controller/level-helper.ts");function M(d,e){for(var o=null,h=0,g=d.length;h<g;h++){var i=d[h];if(i&&i.cc===e){o=i;break}}return o}function R(d,e,o){return!!(e.details&&(o.endCC>o.startCC||d&&d.cc<o.startCC))}function O(d,e){var o=d.fragments,h=e.fragments;if(!h.length||!o.length){L.logger.log("No fragments to align");return}var g=M(o,h[0].cc);if(!g||g&&!g.startPTS){L.logger.log("No frag in previous level to align on");return}return g}function _(d,e){if(d){var o=d.start+e;d.start=d.startPTS=o,d.endPTS=o+d.duration}}function y(d,e){for(var o=e.fragments,h=0,g=o.length;h<g;h++)_(o[h],d);e.fragmentHint&&_(e.fragmentHint,d),e.alignedSliding=!0}function T(d,e,o){!e||(D(d,o,e),!o.alignedSliding&&e.details&&E(o,e.details),!o.alignedSliding&&e.details&&!o.skippedSegments&&Object(A.adjustSliding)(e.details,o))}function D(d,e,o){if(R(d,o,e)){var h=O(o.details,e);h&&Object(P.isFiniteNumber)(h.start)&&(L.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),y(h.start,e))}}function E(d,e){if(!(!e.fragments.length||!d.hasProgramDateTime||!e.hasProgramDateTime)){var o=e.fragments[0].programDateTime,h=d.fragments[0].programDateTime,g=(h-o)/1e3+e.fragments[0].start;g&&Object(P.isFiniteNumber)(g)&&(L.logger.log("Adjusting PTS using programDateTime delta "+(h-o)+"ms, sliding:"+g.toFixed(3)+" "+d.url+" "),y(g,d))}}function m(d,e){var o=d.programDateTime;if(!!o){var h=(o-e)/1e3;d.start=d.startPTS=h,d.endPTS=h+d.duration}}function p(d,e){if(!(!e.fragments.length||!d.hasProgramDateTime||!e.hasProgramDateTime)){var o=e.fragments[0].programDateTime,h=e.fragments[0].start,g=o-h*1e3;d.fragments.forEach(function(i){m(i,g)}),d.fragmentHint&&m(d.fragmentHint,g),d.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/utils/ewma.ts"),L=function(){function A(R,O,_){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=_,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new P.default(R),this.fast_=new P.default(O)}var M=A.prototype;return M.update=function(O,_){var y=this.slow_,T=this.fast_;this.slow_.halfLife!==O&&(this.slow_=new P.default(O,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new P.default(_,T.getEstimate(),T.getTotalWeight()))},M.sample=function(O,_){O=Math.max(O,this.minDelayMs_);var y=8*_,T=O/1e3,D=y/T;this.fast_.sample(T,D),this.slow_.sample(T,D)},M.canEstimate=function(){var O=this.fast_;return O&&O.getTotalWeight()>=this.minWeight_},M.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},M.destroy=function(){},A}();b.default=L},"./src/utils/ewma.ts":function(K,b,n){"use strict";n.r(b);var P=function(){function L(M,R,O){R===void 0&&(R=0),O===void 0&&(O=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=M,this.alpha_=M?Math.exp(Math.log(.5)/M):0,this.estimate_=R,this.totalWeight_=O}var A=L.prototype;return A.sample=function(R,O){var _=Math.pow(this.alpha_,R);this.estimate_=O*(1-_)+_*this.estimate_,this.totalWeight_+=R},A.getTotalWeight=function(){return this.totalWeight_},A.getEstimate=function(){if(this.alpha_){var R=1-Math.pow(this.alpha_,this.totalWeight_);if(R)return this.estimate_/R}return this.estimate_},L}();b.default=P},"./src/utils/fetch-loader.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"fetchSupported",function(){return m});var P=n("./src/polyfills/number.ts"),L=n("./src/loader/load-stats.ts"),A=n("./src/demux/chunk-cache.ts");function M(h,g){h.prototype=Object.create(g.prototype),h.prototype.constructor=h,T(h,g)}function R(h){var g=typeof Map=="function"?new Map:void 0;return R=function(r){if(r===null||!y(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof g!="undefined"){if(g.has(r))return g.get(r);g.set(r,l)}function l(){return O(r,arguments,D(this).constructor)}return l.prototype=Object.create(r.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),T(l,r)},R(h)}function O(h,g,i){return _()?O=Reflect.construct.bind():O=function(l,c,t){var a=[null];a.push.apply(a,c);var u=Function.bind.apply(l,a),s=new u;return t&&T(s,t.prototype),s},O.apply(null,arguments)}function _(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function y(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function T(h,g){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,l){return r.__proto__=l,r},T(h,g)}function D(h){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},D(h)}function E(){return E=Object.assign?Object.assign.bind():function(h){for(var g=1;g<arguments.length;g++){var i=arguments[g];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(h[r]=i[r])}return h},E.apply(this,arguments)}function m(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var p=function(){function h(i){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=i.fetchSetup||e,this.controller=new self.AbortController,this.stats=new L.LoadStats}var g=h.prototype;return g.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},g.abortInternal=function(){var r=this.response;(!r||!r.ok)&&(this.stats.aborted=!0,this.controller.abort())},g.abort=function(){var r;this.abortInternal(),(r=this.callbacks)!==null&&r!==void 0&&r.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},g.load=function(r,l,c){var t=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var u=d(r,this.controller.signal),s=c.onProgress,f=r.responseType==="arraybuffer",v=f?"byteLength":"length";this.context=r,this.config=l,this.callbacks=c,this.request=this.fetchSetup(r,u),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){t.abortInternal(),c.onTimeout(a,r,t.response)},l.timeout),self.fetch(this.request).then(function(S){if(t.response=t.loader=S,!S.ok){var x=S.status,I=S.statusText;throw new o(I||"fetch, bad network response",x,S)}return a.loading.first=Math.max(self.performance.now(),a.loading.start),a.total=parseInt(S.headers.get("Content-Length")||"0"),s&&Object(P.isFiniteNumber)(l.highWaterMark)?t.loadProgressively(S,a,r,l.highWaterMark,s):f?S.arrayBuffer():S.text()}).then(function(S){var x=t.response;self.clearTimeout(t.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first),a.loaded=a.total=S[v];var I={url:x.url,data:S};s&&!Object(P.isFiniteNumber)(l.highWaterMark)&&s(a,r,S,x),c.onSuccess(I,a,r,x)}).catch(function(S){if(self.clearTimeout(t.requestTimeout),!a.aborted){var x=S&&S.code||0,I=S?S.message:null;c.onError({code:x,text:I},r,S?S.details:null)}})},g.getCacheAge=function(){var r=null;if(this.response){var l=this.response.headers.get("age");r=l?parseFloat(l):null}return r},g.loadProgressively=function(r,l,c,t,a){t===void 0&&(t=0);var u=new A.default,s=r.body.getReader(),f=function v(){return s.read().then(function(S){if(S.done)return u.dataLength&&a(l,c,u.flush(),r),Promise.resolve(new ArrayBuffer(0));var x=S.value,I=x.length;return l.loaded+=I,I<t||u.dataLength?(u.push(x),u.dataLength>=t&&a(l,c,u.flush(),r)):a(l,c,x,r),v()}).catch(function(){return Promise.reject()})};return f()},h}();function d(h,g){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:g,headers:new self.Headers(E({},h.headers))};return h.rangeEnd&&i.headers.set("Range","bytes="+h.rangeStart+"-"+String(h.rangeEnd-1)),i}function e(h,g){return new self.Request(h.url,g)}var o=function(h){M(g,h);function g(i,r,l){var c;return c=h.call(this,i)||this,c.code=void 0,c.details=void 0,c.code=r,c.details=l,c}return g}(R(Error));b.default=p},"./src/utils/imsc1-ttml-parser.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"IMSC1_CODEC",function(){return y}),n.d(b,"parseIMSC1",function(){return m});var P=n("./src/utils/mp4-tools.ts"),L=n("./src/utils/vttparser.ts"),A=n("./src/utils/vttcue.ts"),M=n("./src/demux/id3.ts"),R=n("./src/utils/timescale-conversion.ts"),O=n("./src/utils/webvtt-parser.ts");function _(){return _=Object.assign?Object.assign.bind():function(t){for(var a=1;a<arguments.length;a++){var u=arguments[a];for(var s in u)Object.prototype.hasOwnProperty.call(u,s)&&(t[s]=u[s])}return t},_.apply(this,arguments)}var y="stpp.ttml.im1t",T=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,D=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,E={left:"start",center:"center",right:"end",start:"start",end:"end"};function m(t,a,u,s,f){var v=Object(P.findBox)(new Uint8Array(t),["mdat"]);if(v.length===0){f(new Error("Could not parse IMSC1 mdat"));return}var S=v.map(function(I){return Object(M.utf8ArrayToStr)(I)}),x=Object(R.toTimescaleFromScale)(a,1,u);try{S.forEach(function(I){return s(p(I,x))})}catch(I){f(I)}}function p(t,a){var u=new DOMParser,s=u.parseFromString(t,"text/xml"),f=s.getElementsByTagName("tt")[0];if(!f)throw new Error("Invalid ttml");var v={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},S=Object.keys(v).reduce(function(U,W){return U[W]=f.getAttribute("ttp:"+W)||v[W],U},{}),x=f.getAttribute("xml:space")!=="preserve",I=e(d(f,"styling","style")),B=e(d(f,"layout","region")),k=d(f,"body","[begin]");return[].map.call(k,function(U){var W=o(U,x);if(!W||!U.hasAttribute("begin"))return null;var G=r(U.getAttribute("begin"),S),X=r(U.getAttribute("dur"),S),Y=r(U.getAttribute("end"),S);if(G===null)throw i(U);if(Y===null){if(X===null)throw i(U);Y=G+X}var J=new A.default(G-a,Y-a,W);J.id=Object(O.generateCueId)(J.startTime,J.endTime,J.text);var ee=B[U.getAttribute("region")],z=I[U.getAttribute("style")];J.position=10,J.size=80;var q=h(ee,z,I),ie=q.textAlign;if(ie){var ae=E[ie];ae&&(J.lineAlign=ae),J.align=ie}return _(J,q),J}).filter(function(U){return U!==null})}function d(t,a,u){var s=t.getElementsByTagName(a)[0];return s?[].slice.call(s.querySelectorAll(u)):[]}function e(t){return t.reduce(function(a,u){var s=u.getAttribute("xml:id");return s&&(a[s]=u),a},{})}function o(t,a){return[].slice.call(t.childNodes).reduce(function(u,s,f){var v;return s.nodeName==="br"&&f?u+`
21
- `:(v=s.childNodes)!==null&&v!==void 0&&v.length?o(s,a):a?u+s.textContent.trim().replace(/\s+/g," "):u+s.textContent},"")}function h(t,a,u){var s="http://www.w3.org/ns/ttml#styling",f=null,v=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],S=t!=null&&t.hasAttribute("style")?t.getAttribute("style"):null;return S&&u.hasOwnProperty(S)&&(f=u[S]),v.reduce(function(x,I){var B=g(a,s,I)||g(t,s,I)||g(f,s,I);return B&&(x[I]=B),x},{})}function g(t,a,u){return t&&t.hasAttributeNS(a,u)?t.getAttributeNS(a,u):null}function i(t){return new Error("Could not parse ttml timestamp "+t)}function r(t,a){if(!t)return null;var u=Object(L.parseTimeStamp)(t);return u===null&&(T.test(t)?u=l(t,a):D.test(t)&&(u=c(t,a))),u}function l(t,a){var u=T.exec(t),s=(u[4]|0)+(u[5]|0)/a.subFrameRate;return(u[1]|0)*3600+(u[2]|0)*60+(u[3]|0)+s/a.frameRate}function c(t,a){var u=D.exec(t),s=Number(u[1]),f=u[2];switch(f){case"h":return s*3600;case"m":return s*60;case"ms":return s*1e3;case"f":return s/a.frameRate;case"t":return s/a.tickRate}return s}},"./src/utils/logger.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"enableLogs",function(){return O}),n.d(b,"logger",function(){return _});var P=function(){},L={trace:P,debug:P,log:P,warn:P,info:P,error:P},A=L;function M(y){var T=self.console[y];return T?T.bind(self.console,"["+y+"] >"):P}function R(y){for(var T=arguments.length,D=new Array(T>1?T-1:0),E=1;E<T;E++)D[E-1]=arguments[E];D.forEach(function(m){A[m]=y[m]?y[m].bind(y):M(m)})}function O(y){if(self.console&&y===!0||typeof y=="object"){R(y,"debug","log","info","warn","error");try{A.log()}catch{A=L}}else A=L}var _=A},"./src/utils/mediakeys-helper.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"KeySystems",function(){return P}),n.d(b,"requestMediaKeySystemAccess",function(){return L});var P;(function(A){A.WIDEVINE="com.widevine.alpha",A.PLAYREADY="com.microsoft.playready"})(P||(P={}));var L=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"getMediaSource",function(){return P});function P(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"RemuxerTrackIdConfig",function(){return O}),n.d(b,"bin2str",function(){return _}),n.d(b,"readUint16",function(){return y}),n.d(b,"readUint32",function(){return T}),n.d(b,"readSint32",function(){return D}),n.d(b,"writeUint32",function(){return E}),n.d(b,"findBox",function(){return m}),n.d(b,"parseSegmentIndex",function(){return p}),n.d(b,"parseInitSegment",function(){return d}),n.d(b,"getStartDTS",function(){return e}),n.d(b,"getDuration",function(){return o}),n.d(b,"computeRawDurationFromSamples",function(){return h}),n.d(b,"offsetStartDTS",function(){return g}),n.d(b,"segmentValidRange",function(){return i}),n.d(b,"appendUint8Array",function(){return r}),n.d(b,"parseSamples",function(){return l}),n.d(b,"parseSEIMessageFromNALu",function(){return a}),n.d(b,"parseEmsg",function(){return s});var P=n("./src/utils/typed-array.ts"),L=n("./src/loader/fragment.ts"),A=n("./src/demux/id3.ts"),M=Math.pow(2,32)-1,R=[].push,O={video:1,audio:2,id3:3,text:4};function _(f){return String.fromCharCode.apply(null,f)}function y(f,v){var S=f[v]<<8|f[v+1];return S<0?65536+S:S}function T(f,v){var S=D(f,v);return S<0?4294967296+S:S}function D(f,v){return f[v]<<24|f[v+1]<<16|f[v+2]<<8|f[v+3]}function E(f,v,S){f[v]=S>>24,f[v+1]=S>>16&255,f[v+2]=S>>8&255,f[v+3]=S&255}function m(f,v){var S=[];if(!v.length)return S;for(var x=f.byteLength,I=0;I<x;){var B=T(f,I),k=_(f.subarray(I+4,I+8)),U=B>1?I+B:x;if(k===v[0])if(v.length===1)S.push(f.subarray(I+8,U));else{var W=m(f.subarray(I+8,U),v.slice(1));W.length&&R.apply(S,W)}I=U}return S}function p(f){var v=[],S=f[0],x=8,I=T(f,x);x+=4;var B=0,k=0;S===0?x+=8:x+=16,x+=2;var U=f.length+k,W=y(f,x);x+=2;for(var G=0;G<W;G++){var X=x,Y=T(f,X);X+=4;var J=Y&2147483647,ee=(Y&2147483648)>>>31;if(ee===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var z=T(f,X);X+=4,v.push({referenceSize:J,subsegmentDuration:z,info:{duration:z/I,start:U,end:U+J-1}}),U+=J,X+=4,x=X}return{earliestPresentationTime:B,timescale:I,version:S,referencesCount:W,references:v}}function d(f){for(var v=[],S=m(f,["moov","trak"]),x=0;x<S.length;x++){var I=S[x],B=m(I,["tkhd"])[0];if(B){var k=B[0],U=k===0?12:20,W=T(B,U),G=m(I,["mdia","mdhd"])[0];if(G){k=G[0],U=k===0?12:20;var X=T(G,U),Y=m(I,["mdia","hdlr"])[0];if(Y){var J=_(Y.subarray(8,12)),ee={soun:L.ElementaryStreamTypes.AUDIO,vide:L.ElementaryStreamTypes.VIDEO}[J];if(ee){var z=m(I,["mdia","minf","stbl","stsd"])[0],q=void 0;z&&(q=_(z.subarray(12,16))),v[W]={timescale:X,type:ee},v[ee]={timescale:X,id:W,codec:q}}}}}}var ie=m(f,["moov","mvex","trex"]);return ie.forEach(function(ae){var te=T(ae,4),oe=v[te];oe&&(oe.default={duration:T(ae,12),flags:T(ae,20)})}),v}function e(f,v){return m(v,["moof","traf"]).reduce(function(S,x){var I=m(x,["tfdt"])[0],B=I[0],k=m(x,["tfhd"]).reduce(function(U,W){var G=T(W,4),X=f[G];if(X){var Y=T(I,4);B===1&&(Y*=Math.pow(2,32),Y+=T(I,8));var J=X.timescale||9e4,ee=Y/J;if(isFinite(ee)&&(U===null||ee<U))return ee}return U},null);return k!==null&&isFinite(k)&&(S===null||k<S)?k:S},null)||0}function o(f,v){for(var S=0,x=0,I=0,B=m(f,["moof","traf"]),k=0;k<B.length;k++){var U=B[k],W=m(U,["tfhd"])[0],G=T(W,4),X=v[G];if(!!X){var Y=X.default,J=T(W,0)|(Y==null?void 0:Y.flags),ee=Y==null?void 0:Y.duration;J&8&&(J&2?ee=T(W,12):ee=T(W,8));for(var z=X.timescale||9e4,q=m(U,["trun"]),ie=0;ie<q.length;ie++){if(S=h(q[ie]),!S&&ee){var ae=T(q[ie],4);S=ee*ae}X.type===L.ElementaryStreamTypes.VIDEO?x+=S/z:X.type===L.ElementaryStreamTypes.AUDIO&&(I+=S/z)}}}if(x===0&&I===0){for(var te=0,oe=m(f,["sidx"]),ue=0;ue<oe.length;ue++){var re=p(oe[ue]);re!=null&&re.references&&(te+=re.references.reduce(function(he,ge){return he+ge.info.duration||0},0))}return te}return x||I}function h(f){var v=T(f,0),S=8;v&1&&(S+=4),v&4&&(S+=4);for(var x=0,I=T(f,4),B=0;B<I;B++){if(v&256){var k=T(f,S);x+=k,S+=4}v&512&&(S+=4),v&1024&&(S+=4),v&2048&&(S+=4)}return x}function g(f,v,S){m(v,["moof","traf"]).forEach(function(x){m(x,["tfhd"]).forEach(function(I){var B=T(I,4),k=f[B];if(!!k){var U=k.timescale||9e4;m(x,["tfdt"]).forEach(function(W){var G=W[0],X=T(W,4);if(G===0)X-=S*U,X=Math.max(X,0),E(W,4,X);else{X*=Math.pow(2,32),X+=T(W,8),X-=S*U,X=Math.max(X,0);var Y=Math.floor(X/(M+1)),J=Math.floor(X%(M+1));E(W,4,Y),E(W,8,J)}})}})})}function i(f){var v={valid:null,remainder:null},S=m(f,["moof"]);if(S){if(S.length<2)return v.remainder=f,v}else return v;var x=S[S.length-1];return v.valid=Object(P.sliceUint8)(f,0,x.byteOffset-8),v.remainder=Object(P.sliceUint8)(f,x.byteOffset-8),v}function r(f,v){var S=new Uint8Array(f.length+v.length);return S.set(f),S.set(v,f.length),S}function l(f,v){var S=[],x=v.samples,I=v.timescale,B=v.id,k=!1,U=m(x,["moof"]);return U.map(function(W){var G=W.byteOffset-8,X=m(W,["traf"]);X.map(function(Y){var J=m(Y,["tfdt"]).map(function(ee){var z=ee[0],q=T(ee,4);return z===1&&(q*=Math.pow(2,32),q+=T(ee,8)),q/I})[0];return J!==void 0&&(f=J),m(Y,["tfhd"]).map(function(ee){var z=T(ee,4),q=T(ee,0)&16777215,ie=(q&1)!==0,ae=(q&2)!==0,te=(q&8)!==0,oe=0,ue=(q&16)!==0,re=0,he=(q&32)!==0,ge=8;z===B&&(ie&&(ge+=8),ae&&(ge+=4),te&&(oe=T(ee,ge),ge+=4),ue&&(re=T(ee,ge),ge+=4),he&&(ge+=4),v.type==="video"&&(k=c(v.codec)),m(Y,["trun"]).map(function(Se){var Me=Se[0],Oe=T(Se,0)&16777215,Ne=(Oe&1)!==0,Ie=0,Ke=(Oe&4)!==0,me=(Oe&256)!==0,ke=0,je=(Oe&512)!==0,He=0,We=(Oe&1024)!==0,Ye=(Oe&2048)!==0,Ge=0,nt=T(Se,4),we=8;Ne&&(Ie=T(Se,we),we+=4),Ke&&(we+=4);for(var Be=Ie+G,$e=0;$e<nt;$e++){if(me?(ke=T(Se,we),we+=4):ke=oe,je?(He=T(Se,we),we+=4):He=re,We&&(we+=4),Ye&&(Me===0?Ge=T(Se,we):Ge=D(Se,we),we+=4),v.type===L.ElementaryStreamTypes.VIDEO)for(var Ue=0;Ue<He;){var Pe=T(x,Be);Be+=4;var ot=x[Be]&31;if(t(k,ot)){var Xe=x.subarray(Be,Be+Pe);a(Xe,f+Ge/I,S)}Be+=Pe,Ue+=Pe+4}f+=ke/I}}))})})}),S}function c(f){if(!f)return!1;var v=f.indexOf("."),S=v<0?f:f.substring(0,v);return S==="hvc1"||S==="hev1"||S==="dvh1"||S==="dvhe"}function t(f,v){return f?v===39||v===40:v===6}function a(f,v,S){var x=u(f),I=0;I++;for(var B=0,k=0,U=!1,W=0;I<x.length;){B=0;do{if(I>=x.length)break;W=x[I++],B+=W}while(W===255);k=0;do{if(I>=x.length)break;W=x[I++],k+=W}while(W===255);var G=x.length-I;if(!U&&B===4&&I<x.length){U=!0;var X=x[I++];if(X===181){var Y=y(x,I);if(I+=2,Y===49){var J=T(x,I);if(I+=4,J===1195456820){var ee=x[I++];if(ee===3){var z=x[I++],q=31&z,ie=64&z,ae=ie?2+q*3:0,te=new Uint8Array(ae);if(ie){te[0]=z;for(var oe=1;oe<ae;oe++)te[oe]=x[I++]}S.push({type:ee,payloadType:B,pts:v,bytes:te})}}}}}else if(B===5&&k<G){if(U=!0,k>16){for(var ue=[],re=0;re<16;re++){var he=x[I++].toString(16);ue.push(he.length==1?"0"+he:he),(re===3||re===5||re===7||re===9)&&ue.push("-")}for(var ge=k-16,Se=new Uint8Array(ge),Me=0;Me<ge;Me++)Se[Me]=x[I++];S.push({payloadType:B,pts:v,uuid:ue.join(""),userData:Object(A.utf8ArrayToStr)(Se),userDataBytes:Se})}}else if(k<G)I+=k;else if(k>G)break}}function u(f){for(var v=f.byteLength,S=[],x=1;x<v-2;)f[x]===0&&f[x+1]===0&&f[x+2]===3?(S.push(x+2),x+=2):x++;if(S.length===0)return f;var I=v-S.length,B=new Uint8Array(I),k=0;for(x=0;x<I;k++,x++)k===S[0]&&(k++,S.shift()),B[x]=f[k];return B}function s(f){var v=f[0],S="",x="",I=0,B=0,k=0,U=0,W=0,G=0;if(v===0){for(;_(f.subarray(G,G+1))!=="\0";)S+=_(f.subarray(G,G+1)),G+=1;for(S+=_(f.subarray(G,G+1)),G+=1;_(f.subarray(G,G+1))!=="\0";)x+=_(f.subarray(G,G+1)),G+=1;x+=_(f.subarray(G,G+1)),G+=1,I=T(f,12),B=T(f,16),U=T(f,20),W=T(f,24),G=28}else if(v===1){G+=4,I=T(f,G),G+=4;var X=T(f,G);G+=4;var Y=T(f,G);for(G+=4,k=Math.pow(2,32)*X+Y,Number.isSafeInteger(k)||(k=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),U=T(f,G),G+=4,W=T(f,G),G+=4;_(f.subarray(G,G+1))!=="\0";)S+=_(f.subarray(G,G+1)),G+=1;for(S+=_(f.subarray(G,G+1)),G+=1;_(f.subarray(G,G+1))!=="\0";)x+=_(f.subarray(G,G+1)),G+=1;x+=_(f.subarray(G,G+1)),G+=1}var J=f.subarray(G,f.byteLength);return{schemeIdUri:S,value:x,timeScale:I,presentationTime:k,presentationTimeDelta:B,eventDuration:U,id:W,payload:J}}},"./src/utils/output-filter.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return P});var P=function(){function L(M,R){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=M,this.trackName=R}var A=L.prototype;return A.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},A.newCue=function(R,O,_){(this.startTime===null||this.startTime>R)&&(this.startTime=R),this.endTime=O,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},A.reset=function(){this.cueRanges=[],this.startTime=null},L}()},"./src/utils/texttrack-utils.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"sendAddTrackEvent",function(){return L}),n.d(b,"addCueToTrack",function(){return A}),n.d(b,"clearCurrentCues",function(){return M}),n.d(b,"removeCuesInRange",function(){return R}),n.d(b,"getCuesInRange",function(){return _});var P=n("./src/utils/logger.ts");function L(y,T){var D;try{D=new Event("addtrack")}catch{D=document.createEvent("Event"),D.initEvent("addtrack",!1,!1)}D.track=y,T.dispatchEvent(D)}function A(y,T){var D=y.mode;if(D==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(T.id))try{if(y.addCue(T),!y.cues.getCueById(T.id))throw new Error("addCue is failed for: "+T)}catch(m){P.logger.debug("[texttrack-utils]: "+m);var E=new self.TextTrackCue(T.startTime,T.endTime,T.text);E.id=T.id,y.addCue(E)}D==="disabled"&&(y.mode=D)}function M(y){var T=y.mode;if(T==="disabled"&&(y.mode="hidden"),y.cues)for(var D=y.cues.length;D--;)y.removeCue(y.cues[D]);T==="disabled"&&(y.mode=T)}function R(y,T,D,E){var m=y.mode;if(m==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var p=_(y.cues,T,D),d=0;d<p.length;d++)(!E||E(p[d]))&&y.removeCue(p[d]);m==="disabled"&&(y.mode=m)}function O(y,T){if(T<y[0].startTime)return 0;var D=y.length-1;if(T>y[D].endTime)return-1;for(var E=0,m=D;E<=m;){var p=Math.floor((m+E)/2);if(T<y[p].startTime)m=p-1;else if(T>y[p].startTime&&E<D)E=p+1;else return p}return y[E].startTime-T<T-y[m].startTime?E:m}function _(y,T,D){var E=[],m=O(y,T);if(m>-1)for(var p=m,d=y.length;p<d;p++){var e=y[p];if(e.startTime>=T&&e.endTime<=D)E.push(e);else if(e.startTime>D)return E}return E}},"./src/utils/time-ranges.ts":function(K,b,n){"use strict";n.r(b);var P={toString:function(A){for(var M="",R=A.length,O=0;O<R;O++)M+="["+A.start(O).toFixed(3)+","+A.end(O).toFixed(3)+"]";return M}};b.default=P},"./src/utils/timescale-conversion.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"toTimescaleFromBase",function(){return L}),n.d(b,"toTimescaleFromScale",function(){return A}),n.d(b,"toMsFromMpegTsClock",function(){return M}),n.d(b,"toMpegTsClockFromTimescale",function(){return R});var P=9e4;function L(O,_,y,T){y===void 0&&(y=1),T===void 0&&(T=!1);var D=O*_*y;return T?Math.round(D):D}function A(O,_,y,T){return y===void 0&&(y=1),T===void 0&&(T=!1),L(O,_,1/y,T)}function M(O,_){return _===void 0&&(_=!1),L(O,1e3,1/P,_)}function R(O,_){return _===void 0&&(_=1),L(O,P,1/_)}},"./src/utils/typed-array.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"sliceUint8",function(){return P});function P(L,A,M){return Uint8Array.prototype.slice?L.slice(A,M):new Uint8Array(Array.prototype.slice.call(L,A,M))}},"./src/utils/vttcue.ts":function(K,b,n){"use strict";n.r(b),b.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var P=["","lr","rl"],L=["start","middle","end","left","right"];function A(y,T){if(typeof T!="string"||!Array.isArray(y))return!1;var D=T.toLowerCase();return~y.indexOf(D)?D:!1}function M(y){return A(P,y)}function R(y){return A(L,y)}function O(y){for(var T=arguments.length,D=new Array(T>1?T-1:0),E=1;E<T;E++)D[E-1]=arguments[E];for(var m=1;m<arguments.length;m++){var p=arguments[m];for(var d in p)y[d]=p[d]}return y}function _(y,T,D){var E=this,m={enumerable:!0};E.hasBeenReset=!1;var p="",d=!1,e=y,o=T,h=D,g=null,i="",r=!0,l="auto",c="start",t=50,a="middle",u=50,s="middle";Object.defineProperty(E,"id",O({},m,{get:function(){return p},set:function(v){p=""+v}})),Object.defineProperty(E,"pauseOnExit",O({},m,{get:function(){return d},set:function(v){d=!!v}})),Object.defineProperty(E,"startTime",O({},m,{get:function(){return e},set:function(v){if(typeof v!="number")throw new TypeError("Start time must be set to a number.");e=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"endTime",O({},m,{get:function(){return o},set:function(v){if(typeof v!="number")throw new TypeError("End time must be set to a number.");o=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"text",O({},m,{get:function(){return h},set:function(v){h=""+v,this.hasBeenReset=!0}})),Object.defineProperty(E,"region",O({},m,{get:function(){return g},set:function(v){g=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"vertical",O({},m,{get:function(){return i},set:function(v){var S=M(v);if(S===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"snapToLines",O({},m,{get:function(){return r},set:function(v){r=!!v,this.hasBeenReset=!0}})),Object.defineProperty(E,"line",O({},m,{get:function(){return l},set:function(v){if(typeof v!="number"&&v!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");l=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"lineAlign",O({},m,{get:function(){return c},set:function(v){var S=R(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");c=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"position",O({},m,{get:function(){return t},set:function(v){if(v<0||v>100)throw new Error("Position must be between 0 and 100.");t=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"positionAlign",O({},m,{get:function(){return a},set:function(v){var S=R(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");a=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"size",O({},m,{get:function(){return u},set:function(v){if(v<0||v>100)throw new Error("Size must be between 0 and 100.");u=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"align",O({},m,{get:function(){return s},set:function(v){var S=R(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");s=S,this.hasBeenReset=!0}})),E.displayState=void 0}return _.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"parseTimeStamp",function(){return A}),n.d(b,"fixLineBreaks",function(){return T}),n.d(b,"VTTParser",function(){return D});var P=n("./src/utils/vttcue.ts"),L=function(){function E(){}var m=E.prototype;return m.decode=function(d,e){if(!d)return"";if(typeof d!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(d))},E}();function A(E){function m(d,e,o,h){return(d|0)*3600+(e|0)*60+(o|0)+parseFloat(h||0)}var p=E.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return p?parseFloat(p[2])>59?m(p[2],p[3],0,p[4]):m(p[1],p[2],p[3],p[4]):null}var M=function(){function E(){this.values=Object.create(null)}var m=E.prototype;return m.set=function(d,e){!this.get(d)&&e!==""&&(this.values[d]=e)},m.get=function(d,e,o){return o?this.has(d)?this.values[d]:e[o]:this.has(d)?this.values[d]:e},m.has=function(d){return d in this.values},m.alt=function(d,e,o){for(var h=0;h<o.length;++h)if(e===o[h]){this.set(d,e);break}},m.integer=function(d,e){/^-?\d+$/.test(e)&&this.set(d,parseInt(e,10))},m.percent=function(d,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var o=parseFloat(e);if(o>=0&&o<=100)return this.set(d,o),!0}return!1},E}();function R(E,m,p,d){var e=d?E.split(d):[E];for(var o in e)if(typeof e[o]=="string"){var h=e[o].split(p);if(h.length===2){var g=h[0],i=h[1];m(g,i)}}}var O=new P.default(0,0,""),_=O.align==="middle"?"middle":"center";function y(E,m,p){var d=E;function e(){var g=A(E);if(g===null)throw new Error("Malformed timestamp: "+d);return E=E.replace(/^[^\sa-zA-Z-]+/,""),g}function o(g,i){var r=new M;R(g,function(t,a){var u;switch(t){case"region":for(var s=p.length-1;s>=0;s--)if(p[s].id===a){r.set(t,p[s].region);break}break;case"vertical":r.alt(t,a,["rl","lr"]);break;case"line":u=a.split(","),r.integer(t,u[0]),r.percent(t,u[0])&&r.set("snapToLines",!1),r.alt(t,u[0],["auto"]),u.length===2&&r.alt("lineAlign",u[1],["start",_,"end"]);break;case"position":u=a.split(","),r.percent(t,u[0]),u.length===2&&r.alt("positionAlign",u[1],["start",_,"end","line-left","line-right","auto"]);break;case"size":r.percent(t,a);break;case"align":r.alt(t,a,["start",_,"end","left","right"]);break}},/:/,/\s/),i.region=r.get("region",null),i.vertical=r.get("vertical","");var l=r.get("line","auto");l==="auto"&&O.line===-1&&(l=-1),i.line=l,i.lineAlign=r.get("lineAlign","start"),i.snapToLines=r.get("snapToLines",!0),i.size=r.get("size",100),i.align=r.get("align",_);var c=r.get("position","auto");c==="auto"&&O.position===50&&(c=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50),i.position=c}function h(){E=E.replace(/^\s+/,"")}if(h(),m.startTime=e(),h(),E.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+d);E=E.slice(3),h(),m.endTime=e(),h(),o(E,m)}function T(E){return E.replace(/<br(?: \/)?>/gi,`
22
- `)}var D=function(){function E(){this.state="INITIAL",this.buffer="",this.decoder=new L,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var m=E.prototype;return m.parse=function(d){var e=this;d&&(e.buffer+=e.decoder.decode(d,{stream:!0}));function o(){var c=e.buffer,t=0;for(c=T(c);t<c.length&&c[t]!=="\r"&&c[t]!==`
19
+ initSegmentChange: `+ee);var q=new M.TransmuxConfig(h,g,o,l,a);this.configureTransmuxer(q)}if(this.frag=i,this.part=r,S)S.postMessage({cmd:"demux",data:e,decryptdata:P,chunkMeta:t,state:X},e instanceof ArrayBuffer?[e]:[]);else if(v){var ie=v.push(e,P,t,X);Object(M.isPromise)(ie)?ie.then(function(ae){d.handleTransmuxComplete(ae)}):this.handleTransmuxComplete(ie)}},p.flush=function(e){var o=this;e.transmuxing.start=self.performance.now();var h=this.transmuxer,g=this.worker;if(g)g.postMessage({cmd:"flush",chunkMeta:e});else if(h){var i=h.flush(e);Object(M.isPromise)(i)?i.then(function(r){o.handleFlushResult(r,e)}):this.handleFlushResult(i,e)}},p.handleFlushResult=function(e,o){var h=this;e.forEach(function(g){h.handleTransmuxComplete(g)}),this.onFlush(o)},p.onWorkerMessage=function(e){var o=e.data,h=this.hls;switch(o.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(o.data);break}case"flush":{this.onFlush(o.data);break}case"workerLog":R.logger[o.data.logType]&&R.logger[o.data.logType](o.data.message);break;default:{o.data=o.data||{},o.data.frag=this.frag,o.data.id=this.id,h.trigger(o.event,o.data);break}}},p.configureTransmuxer=function(e){var o=this.worker,h=this.transmuxer;o?o.postMessage({cmd:"configure",config:e}):h&&h.configure(e)},p.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},m}()},"./src/demux/transmuxer-worker.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return O});var I=n("./src/demux/transmuxer.ts"),L=n("./src/events.ts"),D=n("./src/utils/logger.ts"),M=n("./node_modules/eventemitter3/index.js"),R=n.n(M);function O(E){var m=new M.EventEmitter,p=function(o,h){E.postMessage({event:o,data:h})};m.on(L.Events.FRAG_DECRYPTED,p),m.on(L.Events.ERROR,p);var f=function(){var o=function(i){var r=function(c){p("workerLog",{logType:i,message:c})};D.logger[i]=r};for(var h in D.logger)o(h)};E.addEventListener("message",function(e){var o=e.data;switch(o.cmd){case"init":{var h=JSON.parse(o.config);E.transmuxer=new I.default(m,o.typeSupported,h,o.vendor,o.id),Object(D.enableLogs)(h.debug),f(),p("init",null);break}case"configure":{E.transmuxer.configure(o.config);break}case"demux":{var g=E.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(I.isPromise)(g)?g.then(function(l){_(E,l)}):_(E,g);break}case"flush":{var i=o.chunkMeta,r=E.transmuxer.flush(i);Object(I.isPromise)(r)?r.then(function(l){T(E,l,i)}):T(E,r,i);break}default:break}})}function _(E,m){if(A(m.remuxResult))return!1;var p=[],f=m.remuxResult,e=f.audio,o=f.video;return e&&y(p,e),o&&y(p,o),E.postMessage({event:"transmuxComplete",data:m},p),!0}function y(E,m){m.data1&&E.push(m.data1.buffer),m.data2&&E.push(m.data2.buffer)}function T(E,m,p){var f=m.reduce(function(e,o){return _(E,o)||e},!1);f||E.postMessage({event:"transmuxComplete",data:m[0]}),E.postMessage({event:"flush",data:p})}function A(E){return!E.audio&&!E.video&&!E.text&&!E.id3&&!E.initSegment}},"./src/demux/transmuxer.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return p}),n.d(b,"isPromise",function(){return o}),n.d(b,"TransmuxConfig",function(){return h}),n.d(b,"TransmuxState",function(){return g});var I=n("./src/events.ts"),L=n("./src/errors.ts"),D=n("./src/crypt/decrypter.ts"),M=n("./src/demux/aacdemuxer.ts"),R=n("./src/demux/mp4demuxer.ts"),O=n("./src/demux/tsdemuxer.ts"),_=n("./src/demux/mp3demuxer.ts"),y=n("./src/remux/mp4-remuxer.ts"),T=n("./src/remux/passthrough-remuxer.ts"),A=n("./src/utils/logger.ts"),E;try{E=self.performance.now.bind(self.performance)}catch{A.logger.debug("Unable to use Performance API on this environment"),E=self.Date.now}var m=[{demux:O.default,remux:y.default},{demux:R.default,remux:T.default},{demux:M.default,remux:y.default},{demux:_.default,remux:y.default}],p=function(){function i(l,c,t,a,u){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=l,this.typeSupported=c,this.config=t,this.vendor=a,this.id=u}var r=i.prototype;return r.configure=function(c){this.transmuxConfig=c,this.decrypter&&this.decrypter.reset()},r.push=function(c,t,a,u){var s=this,d=a.transmuxing;d.executeStart=E();var v=new Uint8Array(c),S=this.config,x=this.currentTransmuxState,P=this.transmuxConfig;u&&(this.currentTransmuxState=u);var B=u||x,k=B.contiguous,U=B.discontinuity,W=B.trackSwitch,G=B.accurateTimeOffset,z=B.timeOffset,Y=B.initSegmentChange,J=P.audioCodec,ee=P.videoCodec,X=P.defaultInitPts,q=P.duration,ie=P.initSegmentData;(U||W||Y)&&this.resetInitSegment(ie,J,ee,q),(U||Y)&&this.resetInitialTimestamp(X),k||this.resetContiguity();var ae=f(v,t);if(ae&&ae.method==="AES-128"){var te=this.getDecrypter();if(S.enableSoftwareAES){var oe=te.softwareDecrypt(v,ae.key.buffer,ae.iv.buffer);if(!oe)return d.executeEnd=E(),e(a);v=new Uint8Array(oe)}else return this.decryptionPromise=te.webCryptoDecrypt(v,ae.key.buffer,ae.iv.buffer).then(function(he){var ve=s.push(he,null,a);return s.decryptionPromise=null,ve}),this.decryptionPromise}this.needsProbing(v,U,W)&&this.configureTransmuxer(v,P);var ue=this.transmux(v,ae,z,G,a),re=this.currentTransmuxState;return re.contiguous=!0,re.discontinuity=!1,re.trackSwitch=!1,d.executeEnd=E(),ue},r.flush=function(c){var t=this,a=c.transmuxing;a.executeStart=E();var u=this.decrypter,s=this.currentTransmuxState,d=this.decryptionPromise;if(d)return d.then(function(){return t.flush(c)});var v=[],S=s.timeOffset;if(u){var x=u.flush();x&&v.push(this.push(x,null,c))}var P=this.demuxer,B=this.remuxer;if(!P||!B)return this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),a.executeEnd=E(),[e(c)];var k=P.flush(S);return o(k)?k.then(function(U){return t.flushRemux(v,U,c),v}):(this.flushRemux(v,k,c),v)},r.flushRemux=function(c,t,a){var u=t.audioTrack,s=t.videoTrack,d=t.id3Track,v=t.textTrack,S=this.currentTransmuxState,x=S.accurateTimeOffset,P=S.timeOffset;A.logger.log("[transmuxer.ts]: Flushed fragment "+a.sn+(a.part>-1?" p: "+a.part:"")+" of level "+a.level);var B=this.remuxer.remux(u,s,d,v,P,x,!0,this.id);c.push({remuxResult:B,chunkMeta:a}),a.transmuxing.executeEnd=E()},r.resetInitialTimestamp=function(c){var t=this.demuxer,a=this.remuxer;!t||!a||(t.resetTimeStamp(c),a.resetTimeStamp(c))},r.resetContiguity=function(){var c=this.demuxer,t=this.remuxer;!c||!t||(c.resetContiguity(),t.resetNextTimestamp())},r.resetInitSegment=function(c,t,a,u){var s=this.demuxer,d=this.remuxer;!s||!d||(s.resetInitSegment(c,t,a,u),d.resetInitSegment(c,t,a))},r.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},r.transmux=function(c,t,a,u,s){var d;return t&&t.method==="SAMPLE-AES"?d=this.transmuxSampleAes(c,t,a,u,s):d=this.transmuxUnencrypted(c,a,u,s),d},r.transmuxUnencrypted=function(c,t,a,u){var s=this.demuxer.demux(c,t,!1,!this.config.progressive),d=s.audioTrack,v=s.videoTrack,S=s.id3Track,x=s.textTrack,P=this.remuxer.remux(d,v,S,x,t,a,!1,this.id);return{remuxResult:P,chunkMeta:u}},r.transmuxSampleAes=function(c,t,a,u,s){var d=this;return this.demuxer.demuxSampleAes(c,t,a).then(function(v){var S=d.remuxer.remux(v.audioTrack,v.videoTrack,v.id3Track,v.textTrack,a,u,!1,d.id);return{remuxResult:S,chunkMeta:s}})},r.configureTransmuxer=function(c,t){for(var a=this.config,u=this.observer,s=this.typeSupported,d=this.vendor,v=t.audioCodec,S=t.defaultInitPts,x=t.duration,P=t.initSegmentData,B=t.videoCodec,k,U=0,W=m.length;U<W;U++)if(m[U].demux.probe(c)){k=m[U];break}k||(A.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),k={demux:R.default,remux:T.default});var G=this.demuxer,z=this.remuxer,Y=k.remux,J=k.demux;(!z||!(z instanceof Y))&&(this.remuxer=new Y(u,a,s,d)),(!G||!(G instanceof J))&&(this.demuxer=new J(u,a,s),this.probe=J.probe),this.resetInitSegment(P,v,B,x),this.resetInitialTimestamp(S)},r.needsProbing=function(c,t,a){return!this.demuxer||!this.remuxer||t||a},r.getDecrypter=function(){var c=this.decrypter;return c||(c=this.decrypter=new D.default(this.observer,this.config)),c},i}();function f(i,r){var l=null;return i.byteLength>0&&r!=null&&r.key!=null&&r.iv!==null&&r.method!=null&&(l=r),l}var e=function(r){return{remuxResult:{},chunkMeta:r}};function o(i){return"then"in i&&i.then instanceof Function}var h=function(r,l,c,t,a){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=r,this.videoCodec=l,this.initSegmentData=c,this.duration=t,this.defaultInitPts=a},g=function(r,l,c,t,a,u){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=r,this.contiguous=l,this.accurateTimeOffset=c,this.trackSwitch=t,this.timeOffset=a,this.initSegmentChange=u}},"./src/demux/tsdemuxer.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"discardEPB",function(){return h});var I=n("./src/demux/adts.ts"),L=n("./src/demux/mpegaudio.ts"),D=n("./src/demux/exp-golomb.ts"),M=n("./src/demux/sample-aes.ts"),R=n("./src/events.ts"),O=n("./src/utils/mp4-tools.ts"),_=n("./src/utils/logger.ts"),y=n("./src/errors.ts"),T=n("./src/types/demuxer.ts");function A(){return A=Object.assign?Object.assign.bind():function(g){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var l in r)Object.prototype.hasOwnProperty.call(r,l)&&(g[l]=r[l])}return g},A.apply(this,arguments)}var E=function(){function g(r,l,c){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=r,this.config=l,this.typeSupported=c}g.probe=function(l){return l[0]===71&&l[188]===71},g.createTrack=function(l,c){return{container:l==="video"||l==="audio"?"video/mp2t":void 0,type:l,id:O.RemuxerTrackIdConfig[l],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:l==="audio"?c:void 0}};var i=g.prototype;return i.resetInitSegment=function(l,c,t,a){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=g.createTrack("video"),this._audioTrack=g.createTrack("audio",a),this._id3Track=g.createTrack("id3"),this._txtTrack=g.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=c,this.videoCodec=t,this._duration=a},i.resetTimeStamp=function(){},i.resetContiguity=function(){var l=this._audioTrack,c=this._avcTrack,t=this._id3Track;l&&(l.pesData=null),c&&(c.pesData=null),t&&(t.pesData=null),this.aacOverFlow=null},i.demux=function(l,c,t,a){t===void 0&&(t=!1),a===void 0&&(a=!1),t||(this.sampleAes=null);var u,s=this._avcTrack,d=this._audioTrack,v=this._id3Track,S=this._txtTrack,x=s.pid,P=s.pesData,B=d.pid,k=v.pid,U=d.pesData,W=v.pesData,G=null,z=this.pmtParsed,Y=this._pmtId,J=l.length;if(this.remainderData&&(l=Object(O.appendUint8Array)(this.remainderData,l),J=l.length,this.remainderData=null),J<188&&!a)return this.remainderData=l,{audioTrack:d,videoTrack:s,id3Track:v,textTrack:S};J-=J%188,J<l.byteLength&&!a&&(this.remainderData=new Uint8Array(l.buffer,J,l.buffer.byteLength-J));for(var ee=0,X=0;X<J;X+=188)if(l[X]===71){var q=!!(l[X+1]&64),ie=((l[X+1]&31)<<8)+l[X+2],ae=(l[X+3]&48)>>4,te=void 0;if(ae>1){if(te=X+5+l[X+4],te===X+188)continue}else te=X+4;switch(ie){case x:q&&(P&&(u=e(P))&&this.parseAVCPES(s,S,u,!1),P={data:[],size:0}),P&&(P.data.push(l.subarray(te,X+188)),P.size+=X+188-te);break;case B:if(q){if(U&&(u=e(U)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,u);break;case"mp3":this.parseMPEGPES(d,u);break}U={data:[],size:0}}U&&(U.data.push(l.subarray(te,X+188)),U.size+=X+188-te);break;case k:q&&(W&&(u=e(W))&&this.parseID3PES(v,u),W={data:[],size:0}),W&&(W.data.push(l.subarray(te,X+188)),W.size+=X+188-te);break;case 0:q&&(te+=l[te]+1),Y=this._pmtId=p(l,te);break;case Y:{q&&(te+=l[te]+1);var oe=f(l,te,this.typeSupported,t);x=oe.avc,x>0&&(s.pid=x),B=oe.audio,B>0&&(d.pid=B,d.segmentCodec=oe.segmentCodec),k=oe.id3,k>0&&(v.pid=k),G!==null&&!z&&(_.logger.log("unknown PID '"+G+"' in TS found"),G=null),z=this.pmtParsed=!0;break}case 17:case 8191:break;default:G=ie;break}}else ee++;ee>0&&this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+ee+" TS packet/s that do not start with 0x47"}),s.pesData=P,d.pesData=U,v.pesData=W;var ue={audioTrack:d,videoTrack:s,id3Track:v,textTrack:S};return a&&this.extractRemainingSamples(ue),ue},i.flush=function(){var l=this.remainderData;this.remainderData=null;var c;return l?c=this.demux(l,-1,!1,!0):c={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(c),this.sampleAes?this.decrypt(c,this.sampleAes):c},i.extractRemainingSamples=function(l){var c=l.audioTrack,t=l.videoTrack,a=l.id3Track,u=l.textTrack,s=t.pesData,d=c.pesData,v=a.pesData,S;if(s&&(S=e(s))?(this.parseAVCPES(t,u,S,!0),t.pesData=null):t.pesData=s,d&&(S=e(d))){switch(c.segmentCodec){case"aac":this.parseAACPES(c,S);break;case"mp3":this.parseMPEGPES(c,S);break}c.pesData=null}else d!=null&&d.size&&_.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=d;v&&(S=e(v))?(this.parseID3PES(a,S),a.pesData=null):a.pesData=v},i.demuxSampleAes=function(l,c,t){var a=this.demux(l,t,!0,!this.config.progressive),u=this.sampleAes=new M.default(this.observer,this.config,c);return this.decrypt(a,u)},i.decrypt=function(l,c){return new Promise(function(t){var a=l.audioTrack,u=l.videoTrack;a.samples&&a.segmentCodec==="aac"?c.decryptAacSamples(a.samples,0,function(){u.samples?c.decryptAvcSamples(u.samples,0,0,function(){t(l)}):t(l)}):u.samples&&c.decryptAvcSamples(u.samples,0,0,function(){t(l)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(l,c,t,a){var u=this,s=this.parseAVCNALu(l,t.data),d=!1,v=this.avcSample,S,x=!1;t.data=null,v&&s.length&&!l.audFound&&(o(v,l),v=this.avcSample=m(!1,t.pts,t.dts,"")),s.forEach(function(P){switch(P.type){case 1:{S=!0,v||(v=u.avcSample=m(!0,t.pts,t.dts,"")),d&&(v.debug+="NDR "),v.frame=!0;var B=P.data;if(x&&B.length>4){var k=new D.default(B).readSliceType();(k===2||k===4||k===7||k===9)&&(v.key=!0)}break}case 5:S=!0,v||(v=u.avcSample=m(!0,t.pts,t.dts,"")),d&&(v.debug+="IDR "),v.key=!0,v.frame=!0;break;case 6:{S=!0,d&&v&&(v.debug+="SEI "),Object(O.parseSEIMessageFromNALu)(h(P.data),t.pts,c.samples);break}case 7:if(S=!0,x=!0,d&&v&&(v.debug+="SPS "),!l.sps){var U=new D.default(P.data),W=U.readSPS();l.width=W.width,l.height=W.height,l.pixelRatio=W.pixelRatio,l.sps=[P.data],l.duration=u._duration;for(var G=P.data.subarray(1,4),z="avc1.",Y=0;Y<3;Y++){var J=G[Y].toString(16);J.length<2&&(J="0"+J),z+=J}l.codec=z}break;case 8:S=!0,d&&v&&(v.debug+="PPS "),l.pps||(l.pps=[P.data]);break;case 9:S=!1,l.audFound=!0,v&&o(v,l),v=u.avcSample=m(!1,t.pts,t.dts,d?"AUD ":"");break;case 12:S=!0;break;default:S=!1,v&&(v.debug+="unknown NAL "+P.type+" ");break}if(v&&S){var ee=v.units;ee.push(P)}}),a&&v&&(o(v,l),this.avcSample=null)},i.getLastNalUnit=function(l){var c,t=this.avcSample,a;if((!t||t.units.length===0)&&(t=l[l.length-1]),(c=t)!==null&&c!==void 0&&c.units){var u=t.units;a=u[u.length-1]}return a},i.parseAVCNALu=function(l,c){var t=c.byteLength,a=l.naluState||0,u=a,s=[],d=0,v,S,x,P=-1,B=0;for(a===-1&&(P=0,B=c[0]&31,a=0,d=1);d<t;){if(v=c[d++],!a){a=v?0:1;continue}if(a===1){a=v?0:2;continue}if(!v)a=3;else if(v===1){if(P>=0){var k={data:c.subarray(P,d-a-1),type:B};s.push(k)}else{var U=this.getLastNalUnit(l.samples);if(U&&(u&&d<=4-u&&U.state&&(U.data=U.data.subarray(0,U.data.byteLength-u)),S=d-a-1,S>0)){var W=new Uint8Array(U.data.byteLength+S);W.set(U.data,0),W.set(c.subarray(0,S),U.data.byteLength),U.data=W,U.state=0}}d<t?(x=c[d]&31,P=d,B=x,a=0):a=-1}else a=0}if(P>=0&&a>=0){var G={data:c.subarray(P,t),type:B,state:a};s.push(G)}if(s.length===0){var z=this.getLastNalUnit(l.samples);if(z){var Y=new Uint8Array(z.data.byteLength+c.byteLength);Y.set(z.data,0),Y.set(c,z.data.byteLength),z.data=Y}}return l.naluState=a,s},i.parseAACPES=function(l,c){var t=0,a=this.aacOverFlow,u=c.data;if(a){this.aacOverFlow=null;var s=a.missing,d=a.sample.unit.byteLength;if(s===-1){var v=new Uint8Array(d+u.byteLength);v.set(a.sample.unit,0),v.set(u,d),u=v}else{var S=d-s;a.sample.unit.set(u.subarray(0,s),S),l.samples.push(a.sample),t=a.missing}}var x,P;for(x=t,P=u.length;x<P-1&&!I.isHeader(u,x);x++);if(x!==t){var B,k;if(x<P-1?(B="AAC PES did not start with ADTS header,offset:"+x,k=!1):(B="no ADTS header found in AAC PES",k=!0),_.logger.warn("parsing error:"+B),this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:k,reason:B}),k)return}I.initTrackConfig(l,this.observer,u,x,this.audioCodec);var U;if(c.pts!==void 0)U=c.pts;else if(a){var W=I.getFrameDuration(l.samplerate);U=a.sample.pts+W}else{_.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var G=0,z;x<P;)if(z=I.appendFrame(l,u,x,U,G),x+=z.length,z.missing){this.aacOverFlow=z;break}else for(G++;x<P-1&&!I.isHeader(u,x);x++);},i.parseMPEGPES=function(l,c){var t=c.data,a=t.length,u=0,s=0,d=c.pts;if(d===void 0){_.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;s<a;)if(L.isHeader(t,s)){var v=L.appendFrame(l,t,s,d,u);if(v)s+=v.length,u++;else break}else s++},i.parseID3PES=function(l,c){if(c.pts===void 0){_.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var t=A({},c,{type:this._avcTrack?T.MetadataSchema.emsg:T.MetadataSchema.audioId3});l.samples.push(t)},g}();function m(g,i,r,l){return{key:g,frame:!1,pts:i,dts:r,units:[],debug:l,length:0}}function p(g,i){return(g[i+10]&31)<<8|g[i+11]}function f(g,i,r,l){var c={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},t=(g[i+1]&15)<<8|g[i+2],a=i+3+t-4,u=(g[i+10]&15)<<8|g[i+11];for(i+=12+u;i<a;){var s=(g[i+1]&31)<<8|g[i+2];switch(g[i]){case 207:if(!l){_.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:c.audio===-1&&(c.audio=s);break;case 21:c.id3===-1&&(c.id3=s);break;case 219:if(!l){_.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:c.avc===-1&&(c.avc=s);break;case 3:case 4:r.mpeg!==!0&&r.mp3!==!0?_.logger.log("MPEG audio found, not supported in this browser"):c.audio===-1&&(c.audio=s,c.segmentCodec="mp3");break;case 36:_.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((g[i+3]&15)<<8|g[i+4])+5}return c}function e(g){var i=0,r,l,c,t,a,u=g.data;if(!g||g.size===0)return null;for(;u[0].length<19&&u.length>1;){var s=new Uint8Array(u[0].length+u[1].length);s.set(u[0]),s.set(u[1],u[0].length),u[0]=s,u.splice(1,1)}r=u[0];var d=(r[0]<<16)+(r[1]<<8)+r[2];if(d===1){if(l=(r[4]<<8)+r[5],l&&l>g.size-6)return null;var v=r[7];v&192&&(t=(r[9]&14)*536870912+(r[10]&255)*4194304+(r[11]&254)*16384+(r[12]&255)*128+(r[13]&254)/2,v&64?(a=(r[14]&14)*536870912+(r[15]&255)*4194304+(r[16]&254)*16384+(r[17]&255)*128+(r[18]&254)/2,t-a>60*9e4&&(_.logger.warn(Math.round((t-a)/9e4)+"s delta between PTS and DTS, align them"),t=a)):a=t),c=r[8];var S=c+9;if(g.size<=S)return null;g.size-=S;for(var x=new Uint8Array(g.size),P=0,B=u.length;P<B;P++){r=u[P];var k=r.byteLength;if(S)if(S>k){S-=k;continue}else r=r.subarray(S),k-=S,S=0;x.set(r,i),i+=k}return l&&(l-=c+3),{data:x,pts:t,dts:a,len:l}}return null}function o(g,i){if(g.units.length&&g.frame){if(g.pts===void 0){var r=i.samples,l=r.length;if(l){var c=r[l-1];g.pts=c.pts,g.dts=c.dts}else{i.dropped++;return}}i.samples.push(g)}g.debug.length&&_.logger.log(g.pts+"/"+g.dts+":"+g.debug)}function h(g){for(var i=g.byteLength,r=[],l=1;l<i-2;)g[l]===0&&g[l+1]===0&&g[l+2]===3?(r.push(l+2),l+=2):l++;if(r.length===0)return g;var c=i-r.length,t=new Uint8Array(c),a=0;for(l=0;l<c;a++,l++)a===r[0]&&(a++,r.shift()),t[l]=g[a];return t}b.default=E},"./src/errors.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"ErrorTypes",function(){return I}),n.d(b,"ErrorDetails",function(){return L});var I;(function(D){D.NETWORK_ERROR="networkError",D.MEDIA_ERROR="mediaError",D.KEY_SYSTEM_ERROR="keySystemError",D.MUX_ERROR="muxError",D.OTHER_ERROR="otherError"})(I||(I={}));var L;(function(D){D.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",D.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",D.KEY_SYSTEM_NO_SESSION="keySystemNoSession",D.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",D.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",D.MANIFEST_LOAD_ERROR="manifestLoadError",D.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",D.MANIFEST_PARSING_ERROR="manifestParsingError",D.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",D.LEVEL_EMPTY_ERROR="levelEmptyError",D.LEVEL_LOAD_ERROR="levelLoadError",D.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",D.LEVEL_SWITCH_ERROR="levelSwitchError",D.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",D.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",D.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",D.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",D.FRAG_LOAD_ERROR="fragLoadError",D.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",D.FRAG_DECRYPT_ERROR="fragDecryptError",D.FRAG_PARSING_ERROR="fragParsingError",D.REMUX_ALLOC_ERROR="remuxAllocError",D.KEY_LOAD_ERROR="keyLoadError",D.KEY_LOAD_TIMEOUT="keyLoadTimeOut",D.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",D.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",D.BUFFER_APPEND_ERROR="bufferAppendError",D.BUFFER_APPENDING_ERROR="bufferAppendingError",D.BUFFER_STALLED_ERROR="bufferStalledError",D.BUFFER_FULL_ERROR="bufferFullError",D.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",D.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",D.INTERNAL_EXCEPTION="internalException",D.INTERNAL_ABORTED="aborted",D.UNKNOWN="unknown"})(L||(L={}))},"./src/events.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"Events",function(){return I});var I;(function(L){L.MEDIA_ATTACHING="hlsMediaAttaching",L.MEDIA_ATTACHED="hlsMediaAttached",L.MEDIA_DETACHING="hlsMediaDetaching",L.MEDIA_DETACHED="hlsMediaDetached",L.BUFFER_RESET="hlsBufferReset",L.BUFFER_CODECS="hlsBufferCodecs",L.BUFFER_CREATED="hlsBufferCreated",L.BUFFER_APPENDING="hlsBufferAppending",L.BUFFER_APPENDED="hlsBufferAppended",L.BUFFER_EOS="hlsBufferEos",L.BUFFER_FLUSHING="hlsBufferFlushing",L.BUFFER_FLUSHED="hlsBufferFlushed",L.MANIFEST_LOADING="hlsManifestLoading",L.MANIFEST_LOADED="hlsManifestLoaded",L.MANIFEST_PARSED="hlsManifestParsed",L.LEVEL_SWITCHING="hlsLevelSwitching",L.LEVEL_SWITCHED="hlsLevelSwitched",L.LEVEL_LOADING="hlsLevelLoading",L.LEVEL_LOADED="hlsLevelLoaded",L.LEVEL_UPDATED="hlsLevelUpdated",L.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",L.LEVELS_UPDATED="hlsLevelsUpdated",L.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",L.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",L.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",L.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",L.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",L.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",L.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",L.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",L.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",L.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",L.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",L.CUES_PARSED="hlsCuesParsed",L.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",L.INIT_PTS_FOUND="hlsInitPtsFound",L.FRAG_LOADING="hlsFragLoading",L.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",L.FRAG_LOADED="hlsFragLoaded",L.FRAG_DECRYPTED="hlsFragDecrypted",L.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",L.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",L.FRAG_PARSING_METADATA="hlsFragParsingMetadata",L.FRAG_PARSED="hlsFragParsed",L.FRAG_BUFFERED="hlsFragBuffered",L.FRAG_CHANGED="hlsFragChanged",L.FPS_DROP="hlsFpsDrop",L.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",L.ERROR="hlsError",L.DESTROYING="hlsDestroying",L.KEY_LOADING="hlsKeyLoading",L.KEY_LOADED="hlsKeyLoaded",L.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",L.BACK_BUFFER_REACHED="hlsBackBufferReached"})(I||(I={}))},"./src/hls.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return i});var I=n("./node_modules/url-toolkit/src/url-toolkit.js"),L=n.n(I),D=n("./src/loader/playlist-loader.ts"),M=n("./src/loader/key-loader.ts"),R=n("./src/controller/id3-track-controller.ts"),O=n("./src/controller/latency-controller.ts"),_=n("./src/controller/level-controller.ts"),y=n("./src/controller/fragment-tracker.ts"),T=n("./src/controller/stream-controller.ts"),A=n("./src/is-supported.ts"),E=n("./src/utils/logger.ts"),m=n("./src/config.ts"),p=n("./node_modules/eventemitter3/index.js"),f=n.n(p),e=n("./src/events.ts"),o=n("./src/errors.ts");function h(r,l){for(var c=0;c<l.length;c++){var t=l[c];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,t.key,t)}}function g(r,l,c){return l&&h(r.prototype,l),c&&h(r,c),Object.defineProperty(r,"prototype",{writable:!1}),r}var i=function(){r.isSupported=function(){return Object(A.isSupported)()};function r(c){c===void 0&&(c={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new p.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var t=this.config=Object(m.mergeConfig)(r.DefaultConfig,c);this.userConfig=c,Object(E.enableLogs)(t.debug),this._autoLevelCapping=-1,t.progressive&&Object(m.enableStreamingMode)(t);var a=t.abrController,u=t.bufferController,s=t.capLevelController,d=t.fpsController,v=this.abrController=new a(this),S=this.bufferController=new u(this),x=this.capLevelController=new s(this),P=new d(this),B=new D.default(this),k=new M.default(this),U=new R.default(this),W=this.levelController=new _.default(this),G=new y.FragmentTracker(this),z=this.streamController=new T.default(this,G);x.setStreamController(z),P.setStreamController(z);var Y=[B,k,W,z];this.networkControllers=Y;var J=[v,S,x,P,U,G];this.audioTrackController=this.createController(t.audioTrackController,null,Y),this.createController(t.audioStreamController,G,Y),this.subtitleTrackController=this.createController(t.subtitleTrackController,null,Y),this.createController(t.subtitleStreamController,G,Y),this.createController(t.timelineController,null,J),this.emeController=this.createController(t.emeController,null,J),this.cmcdController=this.createController(t.cmcdController,null,J),this.latencyController=this.createController(O.default,null,J),this.coreComponents=J}var l=r.prototype;return l.createController=function(t,a,u){if(t){var s=a?new t(this,a):new t(this);return u&&u.push(s),s}return null},l.on=function(t,a,u){u===void 0&&(u=this),this._emitter.on(t,a,u)},l.once=function(t,a,u){u===void 0&&(u=this),this._emitter.once(t,a,u)},l.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},l.off=function(t,a,u,s){u===void 0&&(u=this),this._emitter.off(t,a,u,s)},l.listeners=function(t){return this._emitter.listeners(t)},l.emit=function(t,a,u){return this._emitter.emit(t,a,u)},l.trigger=function(t,a){if(this.config.debug)return this.emit(t,t,a);try{return this.emit(t,t,a)}catch(u){E.logger.error("An internal error happened while handling event "+t+'. Error message: "'+u.message+'". Here is a stacktrace:',u),this.trigger(e.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:u})}return!1},l.listenerCount=function(t){return this._emitter.listenerCount(t)},l.destroy=function(){E.logger.log("destroy"),this.trigger(e.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(t){return t.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(t){return t.destroy()}),this.coreComponents.length=0},l.attachMedia=function(t){E.logger.log("attachMedia"),this._media=t,this.trigger(e.Events.MEDIA_ATTACHING,{media:t})},l.detachMedia=function(){E.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},l.loadSource=function(t){this.stopLoad();var a=this.media,u=this.url,s=this.url=I.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});E.logger.log("loadSource:"+s),a&&u&&u!==s&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(a)),this.trigger(e.Events.MANIFEST_LOADING,{url:t})},l.startLoad=function(t){t===void 0&&(t=-1),E.logger.log("startLoad("+t+")"),this.networkControllers.forEach(function(a){a.startLoad(t)})},l.stopLoad=function(){E.logger.log("stopLoad"),this.networkControllers.forEach(function(t){t.stopLoad()})},l.swapAudioCodec=function(){E.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},l.recoverMediaError=function(){E.logger.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},l.removeLevel=function(t,a){a===void 0&&(a=0),this.levelController.removeLevel(t,a)},g(r,[{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){E.logger.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){E.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){E.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){E.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){E.logger.log("set startLevel:"+t),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var a=!!t;a!==this.config.capLevelToPlayerSize&&(a?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=a)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(E.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,a=this.config.minAutoBitrate;if(!t)return 0;for(var u=t.length,s=0;s<u;s++)if(t[s].maxBitrate>=a)return s;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,a=this.autoLevelCapping,u;return a===-1&&t&&t.length?u=t.length-1:u=a,u}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var a=this.audioTrackController;a&&(a.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var a=this.subtitleTrackController;a&&(a.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return t?t.subtitleDisplay:!1},set:function(t){var a=this.subtitleTrackController;a&&(a.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.2.3"}},{key:"Events",get:function(){return e.Events}},{key:"ErrorTypes",get:function(){return o.ErrorTypes}},{key:"ErrorDetails",get:function(){return o.ErrorDetails}},{key:"DefaultConfig",get:function(){return r.defaultConfig?r.defaultConfig:m.hlsDefaultConfig},set:function(t){r.defaultConfig=t}}]),r}();i.defaultConfig=void 0},"./src/is-supported.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"isSupported",function(){return D}),n.d(b,"changeTypeSupported",function(){return M});var I=n("./src/utils/mediasource-helper.ts");function L(){return self.SourceBuffer||self.WebKitSourceBuffer}function D(){var R=Object(I.getMediaSource)();if(!R)return!1;var O=L(),_=R&&typeof R.isTypeSupported=="function"&&R.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!_&&!!y}function M(){var R,O=L();return typeof(O==null||(R=O.prototype)===null||R===void 0?void 0:R.changeType)=="function"}},"./src/loader/date-range.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"DateRangeAttribute",function(){return _}),n.d(b,"DateRange",function(){return y});var I=n("./src/polyfills/number.ts"),L=n("./src/utils/attr-list.ts"),D=n("./src/utils/logger.ts");function M(){return M=Object.assign?Object.assign.bind():function(T){for(var A=1;A<arguments.length;A++){var E=arguments[A];for(var m in E)Object.prototype.hasOwnProperty.call(E,m)&&(T[m]=E[m])}return T},M.apply(this,arguments)}function R(T,A){for(var E=0;E<A.length;E++){var m=A[E];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(T,m.key,m)}}function O(T,A,E){return A&&R(T.prototype,A),E&&R(T,E),Object.defineProperty(T,"prototype",{writable:!1}),T}var _;(function(T){T.ID="ID",T.CLASS="CLASS",T.START_DATE="START-DATE",T.DURATION="DURATION",T.END_DATE="END-DATE",T.END_ON_NEXT="END-ON-NEXT",T.PLANNED_DURATION="PLANNED-DURATION",T.SCTE35_OUT="SCTE35-OUT",T.SCTE35_IN="SCTE35-IN"})(_||(_={}));var y=function(){function T(A,E){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,E){var m=E.attr;for(var p in m)if(Object.prototype.hasOwnProperty.call(A,p)&&A[p]!==m[p]){D.logger.warn('DATERANGE tag attribute: "'+p+'" does not match for tags with ID: "'+A.ID+'"'),this._badValueForSameId=p;break}A=M(new L.AttrList({}),m,A)}if(this.attr=A,this._startDate=new Date(A[_.START_DATE]),_.END_DATE in this.attr){var f=new Date(this.attr[_.END_DATE]);Object(I.isFiniteNumber)(f.getTime())&&(this._endDate=f)}}return O(T,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var E=this.duration;return E!==null?new Date(this._startDate.getTime()+E*1e3):null}},{key:"duration",get:function(){if(_.DURATION in this.attr){var E=this.attr.decimalFloatingPoint(_.DURATION);if(Object(I.isFiniteNumber)(E))return E}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return _.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(_.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(_.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&Object(I.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),T}()},"./src/loader/fragment-loader.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return E}),n.d(b,"LoadError",function(){return p});var I=n("./src/polyfills/number.ts"),L=n("./src/errors.ts");function D(f,e){f.prototype=Object.create(e.prototype),f.prototype.constructor=f,y(f,e)}function M(f){var e=typeof Map=="function"?new Map:void 0;return M=function(h){if(h===null||!_(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(h))return e.get(h);e.set(h,g)}function g(){return R(h,arguments,T(this).constructor)}return g.prototype=Object.create(h.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),y(g,h)},M(f)}function R(f,e,o){return O()?R=Reflect.construct.bind():R=function(g,i,r){var l=[null];l.push.apply(l,i);var c=Function.bind.apply(g,l),t=new c;return r&&y(t,r.prototype),t},R.apply(null,arguments)}function O(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function _(f){return Function.toString.call(f).indexOf("[native code]")!==-1}function y(f,e){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(h,g){return h.__proto__=g,h},y(f,e)}function T(f){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},T(f)}var A=Math.pow(2,17),E=function(){function f(o){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=o}var e=f.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(h,g){var i=this,r=h.url;if(!r)return Promise.reject(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,networkDetails:null},"Fragment does not have a "+(r?"part list":"url")));this.abort();var l=this.config,c=l.fLoader,t=l.loader;return new Promise(function(a,u){i.loader&&i.loader.destroy();var s=i.loader=h.loader=c?new c(l):new t(l),d=m(h),v={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:h.sn==="initSegment"?1/0:A};h.stats=s.stats,s.load(d,v,{onSuccess:function(x,P,B,k){i.resetLoader(h,s),a({frag:h,part:null,payload:x.data,networkDetails:k})},onError:function(x,P,B){i.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,response:x,networkDetails:B}))},onAbort:function(x,P,B){i.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,networkDetails:B}))},onTimeout:function(x,P,B){i.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,networkDetails:B}))},onProgress:function(x,P,B,k){g&&g({frag:h,part:null,payload:B,networkDetails:k})}})})},e.loadPart=function(h,g,i){var r=this;this.abort();var l=this.config,c=l.fLoader,t=l.loader;return new Promise(function(a,u){r.loader&&r.loader.destroy();var s=r.loader=h.loader=c?new c(l):new t(l),d=m(h,g),v={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:A};g.stats=s.stats,s.load(d,v,{onSuccess:function(x,P,B,k){r.resetLoader(h,s),r.updateStatsFromPart(h,g);var U={frag:h,part:g,payload:x.data,networkDetails:k};i(U),a(U)},onError:function(x,P,B){r.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,part:g,response:x,networkDetails:B}))},onAbort:function(x,P,B){h.stats.aborted=g.stats.aborted,r.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,part:g,networkDetails:B}))},onTimeout:function(x,P,B){r.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,part:g,networkDetails:B}))}})})},e.updateStatsFromPart=function(h,g){var i=h.stats,r=g.stats,l=r.total;if(i.loaded+=r.loaded,l){var c=Math.round(h.duration/g.duration),t=Math.min(Math.round(i.loaded/l),c),a=c-t,u=a*Math.round(i.loaded/t);i.total=i.loaded+u}else i.total=Math.max(i.loaded,i.total);var s=i.loading,d=r.loading;s.start?s.first+=d.first-d.start:(s.start=d.start,s.first=d.first),s.end=d.end},e.resetLoader=function(h,g){h.loader=null,this.loader===g&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),g.destroy()},f}();function m(f,e){e===void 0&&(e=null);var o=e||f,h={frag:f,part:e,responseType:"arraybuffer",url:o.url,headers:{},rangeStart:0,rangeEnd:0},g=o.byteRangeStartOffset,i=o.byteRangeEndOffset;return Object(I.isFiniteNumber)(g)&&Object(I.isFiniteNumber)(i)&&(h.rangeStart=g,h.rangeEnd=i),h}var p=function(f){D(e,f);function e(o){for(var h,g=arguments.length,i=new Array(g>1?g-1:0),r=1;r<g;r++)i[r-1]=arguments[r];return h=f.call.apply(f,[this].concat(i))||this,h.data=void 0,h.data=o,h}return e}(M(Error))},"./src/loader/fragment.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"ElementaryStreamTypes",function(){return E}),n.d(b,"BaseSegment",function(){return m}),n.d(b,"Fragment",function(){return p}),n.d(b,"Part",function(){return f});var I=n("./src/polyfills/number.ts"),L=n("./node_modules/url-toolkit/src/url-toolkit.js"),D=n.n(L),M=n("./src/utils/logger.ts"),R=n("./src/loader/level-key.ts"),O=n("./src/loader/load-stats.ts");function _(e,o){e.prototype=Object.create(o.prototype),e.prototype.constructor=e,y(e,o)}function y(e,o){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,i){return g.__proto__=i,g},y(e,o)}function T(e,o){for(var h=0;h<o.length;h++){var g=o[h];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(e,g.key,g)}}function A(e,o,h){return o&&T(e.prototype,o),h&&T(e,h),Object.defineProperty(e,"prototype",{writable:!1}),e}var E;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(E||(E={}));var m=function(){function e(h){var g;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(g={},g[E.AUDIO]=null,g[E.VIDEO]=null,g[E.AUDIOVIDEO]=null,g),this.baseurl=h}var o=e.prototype;return o.setByteRange=function(g,i){var r=g.split("@",2),l=[];r.length===1?l[0]=i?i.byteRangeEndOffset:0:l[0]=parseInt(r[1]),l[1]=parseInt(r[0])+l[0],this._byteRange=l},A(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:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(L.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(g){this._url=g}}]),e}(),p=function(e){_(o,e);function o(g,i){var r;return r=e.call(this,i)||this,r._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkey=void 0,r.type=void 0,r.loader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.appendedPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new O.LoadStats,r.urlId=0,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.type=g,r}var h=o.prototype;return h.createInitializationVector=function(i){for(var r=new Uint8Array(16),l=12;l<16;l++)r[l]=i>>8*(15-l)&255;return r},h.setDecryptDataFromLevelKey=function(i,r){var l=i;return(i==null?void 0:i.method)==="AES-128"&&i.uri&&!i.iv&&(l=R.LevelKey.fromURI(i.uri),l.method=i.method,l.iv=this.createInitializationVector(r),l.keyFormat="identity"),l},h.setElementaryStreamInfo=function(i,r,l,c,t,a){a===void 0&&(a=!1);var u=this.elementaryStreams,s=u[i];if(!s){u[i]={startPTS:r,endPTS:l,startDTS:c,endDTS:t,partial:a};return}s.startPTS=Math.min(s.startPTS,r),s.endPTS=Math.max(s.endPTS,l),s.startDTS=Math.min(s.startDTS,c),s.endDTS=Math.max(s.endDTS,t)},h.clearElementaryStreamInfo=function(){var i=this.elementaryStreams;i[E.AUDIO]=null,i[E.VIDEO]=null,i[E.AUDIOVIDEO]=null},A(o,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var i=this.sn;typeof i!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&M.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),i=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,i)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(I.isFiniteNumber)(this.programDateTime))return null;var i=Object(I.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+i*1e3}},{key:"encrypted",get:function(){var i;return!!((i=this.decryptdata)!==null&&i!==void 0&&i.keyFormat&&this.decryptdata.uri)}}]),o}(m),f=function(e){_(o,e);function o(h,g,i,r,l){var c;c=e.call(this,i)||this,c.fragOffset=0,c.duration=0,c.gap=!1,c.independent=!1,c.relurl=void 0,c.fragment=void 0,c.index=void 0,c.stats=new O.LoadStats,c.duration=h.decimalFloatingPoint("DURATION"),c.gap=h.bool("GAP"),c.independent=h.bool("INDEPENDENT"),c.relurl=h.enumeratedString("URI"),c.fragment=g,c.index=r;var t=h.enumeratedString("BYTERANGE");return t&&c.setByteRange(t,l),l&&(c.fragOffset=l.fragOffset+l.duration),c}return A(o,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var g=this.elementaryStreams;return!!(g.audio||g.video||g.audiovideo)}}]),o}(m)},"./src/loader/key-loader.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return M});var I=n("./src/events.ts"),L=n("./src/errors.ts"),D=n("./src/utils/logger.ts"),M=function(){function R(_){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=_,this.registerListeners()}var O=R.prototype;return O.startLoad=function(y){},O.stopLoad=function(){this.destroyInternalLoaders()},O.registerListeners=function(){this.hls.on(I.Events.KEY_LOADING,this.onKeyLoading,this)},O.unregisterListeners=function(){this.hls.off(I.Events.KEY_LOADING,this.onKeyLoading)},O.destroyInternalLoaders=function(){for(var y in this.loaders){var T=this.loaders[y];T&&T.destroy()}this.loaders={}},O.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},O.onKeyLoading=function(y,T){var A=T.frag,E=A.type,m=this.loaders[E];if(!A.decryptdata){D.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var p=A.decryptdata.uri;if(p!==this.decrypturl||this.decryptkey===null){var f=this.hls.config;if(m&&(D.logger.warn("abort previous key loader for type:"+E),m.abort()),!p){D.logger.warn("key uri is falsy");return}var e=f.loader,o=A.loader=this.loaders[E]=new e(f);this.decrypturl=p,this.decryptkey=null;var h={url:p,frag:A,responseType:"arraybuffer"},g={timeout:f.fragLoadingTimeOut,maxRetry:0,retryDelay:f.fragLoadingRetryDelay,maxRetryDelay:f.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};o.load(h,g,i)}else this.decryptkey&&(A.decryptdata.key=this.decryptkey,this.hls.trigger(I.Events.KEY_LOADED,{frag:A}))},O.loadsuccess=function(y,T,A){var E=A.frag;if(!E.decryptdata){D.logger.error("after key load, decryptdata unset");return}this.decryptkey=E.decryptdata.key=new Uint8Array(y.data),E.loader=null,delete this.loaders[E.type],this.hls.trigger(I.Events.KEY_LOADED,{frag:E})},O.loaderror=function(y,T){var A=T.frag,E=A.loader;E&&E.abort(),delete this.loaders[A.type],this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:A,response:y})},O.loadtimeout=function(y,T){var A=T.frag,E=A.loader;E&&E.abort(),delete this.loaders[A.type],this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:A})},R}()},"./src/loader/level-details.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"LevelDetails",function(){return R});var I=n("./src/polyfills/number.ts");function L(O,_){for(var y=0;y<_.length;y++){var T=_[y];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function D(O,_,y){return _&&L(O.prototype,_),y&&L(O,y),Object.defineProperty(O,"prototype",{writable:!1}),O}var M=10,R=function(){function O(y){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.dateRanges={},this.url=y}var _=O.prototype;return _.reloaded=function(T){if(!T){this.advanced=!0,this.updated=!0;return}var A=this.lastPartSn-T.lastPartSn,E=this.lastPartIndex-T.lastPartIndex;this.updated=this.endSN!==T.endSN||!!E||!!A,this.advanced=this.endSN>T.endSN||A>0||A===0&&E>0,this.updated||this.advanced?this.misses=Math.floor(T.misses*.6):this.misses=T.misses+1,this.availabilityDelay=T.availabilityDelay},D(O,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(I.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||M}},{key:"drift",get:function(){var T=this.driftEndTime-this.driftStartTime;if(T>0){var A=this.driftEnd-this.driftStart;return A*1e3/T}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var T;return(T=this.fragments)!==null&&T!==void 0&&T.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),O}()},"./src/loader/level-key.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"LevelKey",function(){return R});var I=n("./node_modules/url-toolkit/src/url-toolkit.js"),L=n.n(I);function D(O,_){for(var y=0;y<_.length;y++){var T=_[y];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function M(O,_,y){return _&&D(O.prototype,_),y&&D(O,y),Object.defineProperty(O,"prototype",{writable:!1}),O}var R=function(){O.fromURL=function(y,T){return new O(y,T)},O.fromURI=function(y){return new O(y)};function O(_,y){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,y?this._uri=Object(I.buildAbsoluteURL)(_,y,{alwaysNormalize:!0}):this._uri=_}return M(O,[{key:"uri",get:function(){return this._uri}}]),O}()},"./src/loader/load-stats.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"LoadStats",function(){return I});var I=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return h});var I=n("./src/polyfills/number.ts"),L=n("./node_modules/url-toolkit/src/url-toolkit.js"),D=n.n(L),M=n("./src/loader/date-range.ts"),R=n("./src/loader/fragment.ts"),O=n("./src/loader/level-details.ts"),_=n("./src/loader/level-key.ts"),y=n("./src/utils/attr-list.ts"),T=n("./src/utils/logger.ts"),A=n("./src/utils/codecs.ts"),E=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,m=/#EXT-X-MEDIA:(.*)/g,p=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),f=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),e=/\.(mp4|m4s|m4v|m4a)$/i;function o(t){var a,u;return e.test((a=(u=L.parseURL(t))===null||u===void 0?void 0:u.path)!=null?a:"")}var h=function(){function t(){}return t.findGroup=function(u,s){for(var d=0;d<u.length;d++){var v=u[d];if(v.id===s)return v}},t.convertAVC1ToAVCOTI=function(u){var s=u.split(".");if(s.length>2){var d=s.shift()+".";return d+=parseInt(s.shift()).toString(16),d+=("000"+parseInt(s.shift()).toString(16)).slice(-4),d}return u},t.resolve=function(u,s){return L.buildAbsoluteURL(s,u,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(u,s){var d=[],v={},S=!1;E.lastIndex=0;for(var x;(x=E.exec(u))!=null;)if(x[1]){var P=new y.AttrList(x[1]),B={attrs:P,bitrate:P.decimalInteger("AVERAGE-BANDWIDTH")||P.decimalInteger("BANDWIDTH"),name:P.NAME,url:t.resolve(x[2],s)},k=P.decimalResolution("RESOLUTION");k&&(B.width=k.width,B.height=k.height),g((P.CODECS||"").split(/[ ,]+/).filter(function(W){return W}),B),B.videoCodec&&B.videoCodec.indexOf("avc1")!==-1&&(B.videoCodec=t.convertAVC1ToAVCOTI(B.videoCodec)),d.push(B)}else if(x[3]){var U=new y.AttrList(x[3]);U["DATA-ID"]&&(S=!0,v[U["DATA-ID"]]=U)}return{levels:d,sessionData:S?v:null}},t.parseMasterPlaylistMedia=function(u,s,d,v){v===void 0&&(v=[]);var S,x=[],P=0;for(m.lastIndex=0;(S=m.exec(u))!==null;){var B=new y.AttrList(S[1]);if(B.TYPE===d){var k={attrs:B,bitrate:0,id:P++,groupId:B["GROUP-ID"],instreamId:B["INSTREAM-ID"],name:B.NAME||B.LANGUAGE||"",type:d,default:B.bool("DEFAULT"),autoselect:B.bool("AUTOSELECT"),forced:B.bool("FORCED"),lang:B.LANGUAGE,url:B.URI?t.resolve(B.URI,s):""};if(v.length){var U=t.findGroup(v,k.groupId)||v[0];i(k,U,"audioCodec"),i(k,U,"textCodec")}x.push(k)}}return x},t.parseLevelPlaylist=function(u,s,d,v,S){var x=new O.LevelDetails(s),P=x.fragments,B=null,k=0,U=0,W=0,G=0,z=null,Y=new R.Fragment(v,s),J,ee,X,q=-1,ie=!1;for(p.lastIndex=0,x.m3u8=u;(J=p.exec(u))!==null;){ie&&(ie=!1,Y=new R.Fragment(v,s),Y.start=W,Y.sn=k,Y.cc=G,Y.level=d,B&&(Y.initSegment=B,Y.rawProgramDateTime=B.rawProgramDateTime,B.rawProgramDateTime=null));var ae=J[1];if(ae){Y.duration=parseFloat(ae);var te=(" "+J[2]).slice(1);Y.title=te||null,Y.tagList.push(te?["INF",ae,te]:["INF",ae])}else if(J[3])Object(I.isFiniteNumber)(Y.duration)&&(Y.start=W,X&&(Y.levelkey=X),Y.sn=k,Y.level=d,Y.cc=G,Y.urlId=S,P.push(Y),Y.relurl=(" "+J[3]).slice(1),l(Y,z),z=Y,W+=Y.duration,k++,U=0,ie=!0);else if(J[4]){var oe=(" "+J[4]).slice(1);z?Y.setByteRange(oe,z):Y.setByteRange(oe)}else if(J[5])Y.rawProgramDateTime=(" "+J[5]).slice(1),Y.tagList.push(["PROGRAM-DATE-TIME",Y.rawProgramDateTime]),q===-1&&(q=P.length);else{if(J=J[0].match(f),!J){T.logger.warn("No matches on slow regex match for level playlist!");continue}for(ee=1;ee<J.length&&typeof J[ee]=="undefined";ee++);var ue=(" "+J[ee]).slice(1),re=(" "+J[ee+1]).slice(1),he=J[ee+2]?(" "+J[ee+2]).slice(1):"";switch(ue){case"PLAYLIST-TYPE":x.type=re.toUpperCase();break;case"MEDIA-SEQUENCE":k=x.startSN=parseInt(re);break;case"SKIP":{var ve=new y.AttrList(re),Se=ve.decimalInteger("SKIPPED-SEGMENTS");if(Object(I.isFiniteNumber)(Se)){x.skippedSegments=Se;for(var Me=Se;Me--;)P.unshift(null);k+=Se}var Oe=ve.enumeratedString("RECENTLY-REMOVED-DATERANGES");Oe&&(x.recentlyRemovedDateranges=Oe.split(" "));break}case"TARGETDURATION":x.targetduration=parseFloat(re);break;case"VERSION":x.version=parseInt(re);break;case"EXTM3U":break;case"ENDLIST":x.live=!1;break;case"#":(re||he)&&Y.tagList.push(he?[re,he]:[re]);break;case"DISCONTINUITY":G++,Y.tagList.push(["DIS"]);break;case"GAP":Y.tagList.push([ue]);break;case"BITRATE":Y.tagList.push([ue,re]);break;case"DATERANGE":{var Ne=new y.AttrList(re),Pe=new M.DateRange(Ne,x.dateRanges[Ne.ID]);Pe.isValid||x.skippedSegments?x.dateRanges[Pe.id]=Pe:T.logger.warn('Ignoring invalid DATERANGE tag: "'+re+'"'),Y.tagList.push(["EXT-X-DATERANGE",re]);break}case"DISCONTINUITY-SEQUENCE":G=parseInt(re);break;case"KEY":{var Ke,ge=new y.AttrList(re),ke=ge.enumeratedString("METHOD"),je=ge.URI,He=ge.hexadecimalInteger("IV"),We=ge.enumeratedString("KEYFORMATVERSIONS"),Ye=ge.enumeratedString("KEYID"),Ge=(Ke=ge.enumeratedString("KEYFORMAT"))!=null?Ke:"identity",nt=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(nt.indexOf(Ge)>-1){T.logger.warn("Keyformat "+Ge+" is not supported from the manifest");continue}else if(Ge!=="identity")continue;ke&&(X=_.LevelKey.fromURL(s,je),je&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(ke)>=0&&(X.method=ke,X.keyFormat=Ge,Ye&&(X.keyID=Ye),We&&(X.keyFormatVersions=We),X.iv=He));break}case"START":{var we=new y.AttrList(re),Be=we.decimalFloatingPoint("TIME-OFFSET");Object(I.isFiniteNumber)(Be)&&(x.startTimeOffset=Be);break}case"MAP":{var $e=new y.AttrList(re);if(Y.duration){var Ue=new R.Fragment(v,s);c(Ue,$e,d,X),B=Ue,Y.initSegment=B,B.rawProgramDateTime&&!Y.rawProgramDateTime&&(Y.rawProgramDateTime=B.rawProgramDateTime)}else c(Y,$e,d,X),B=Y,ie=!0;break}case"SERVER-CONTROL":{var Ie=new y.AttrList(re);x.canBlockReload=Ie.bool("CAN-BLOCK-RELOAD"),x.canSkipUntil=Ie.optionalFloat("CAN-SKIP-UNTIL",0),x.canSkipDateRanges=x.canSkipUntil>0&&Ie.bool("CAN-SKIP-DATERANGES"),x.partHoldBack=Ie.optionalFloat("PART-HOLD-BACK",0),x.holdBack=Ie.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var ot=new y.AttrList(re);x.partTarget=ot.decimalFloatingPoint("PART-TARGET");break}case"PART":{var ze=x.partList;ze||(ze=x.partList=[]);var dt=U>0?ze[ze.length-1]:void 0,St=U++,qe=new R.Part(new y.AttrList(re),Y,s,St,dt);ze.push(qe),Y.duration+=qe.duration;break}case"PRELOAD-HINT":{var Rt=new y.AttrList(re);x.preloadHint=Rt;break}case"RENDITION-REPORT":{var Dt=new y.AttrList(re);x.renditionReports=x.renditionReports||[],x.renditionReports.push(Dt);break}default:T.logger.warn("line parsed but not handled: "+J);break}}}z&&!z.relurl?(P.pop(),W-=z.duration,x.partList&&(x.fragmentHint=z)):x.partList&&(l(Y,z),Y.cc=G,x.fragmentHint=Y);var lt=P.length,ct=P[0],ut=P[lt-1];if(W+=x.skippedSegments*x.targetduration,W>0&&lt&&ut){x.averagetargetduration=W/lt;var At=ut.sn;x.endSN=At!=="initSegment"?At:0,ct&&(x.startCC=ct.cc,ct.initSegment||x.fragments.every(function(Tt){return Tt.relurl&&o(Tt.relurl)})&&(T.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),Y=new R.Fragment(v,s),Y.relurl=ut.relurl,Y.level=d,Y.sn="initSegment",ct.initSegment=Y,x.needSidxRanges=!0))}else x.endSN=0,x.startCC=0;return x.fragmentHint&&(W+=x.fragmentHint.duration),x.totalduration=W,x.endCC=G,q>0&&r(P,q),x},t}();function g(t,a){["video","audio","text"].forEach(function(u){var s=t.filter(function(v){return Object(A.isCodecType)(v,u)});if(s.length){var d=s.filter(function(v){return v.lastIndexOf("avc1",0)===0||v.lastIndexOf("mp4a",0)===0});a[u+"Codec"]=d.length>0?d[0]:s[0],t=t.filter(function(v){return s.indexOf(v)===-1})}}),a.unknownCodecs=t}function i(t,a,u){var s=a[u];s&&(t[u]=s)}function r(t,a){for(var u=t[a],s=a;s--;){var d=t[s];if(!d)return;d.programDateTime=u.programDateTime-d.duration*1e3,u=d}}function l(t,a){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):a!=null&&a.programDateTime&&(t.programDateTime=a.endProgramDateTime),Object(I.isFiniteNumber)(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function c(t,a,u,s){t.relurl=a.URI,a.BYTERANGE&&t.setByteRange(a.BYTERANGE),t.level=u,t.sn="initSegment",s&&(t.levelkey=s),t.initSegment=null}},"./src/loader/playlist-loader.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/polyfills/number.ts"),L=n("./src/events.ts"),D=n("./src/errors.ts"),M=n("./src/utils/logger.ts"),R=n("./src/utils/mp4-tools.ts"),O=n("./src/loader/m3u8-parser.ts"),_=n("./src/types/loader.ts"),y=n("./src/utils/attr-list.ts");function T(m){var p=m.type;switch(p){case _.PlaylistContextType.AUDIO_TRACK:return _.PlaylistLevelType.AUDIO;case _.PlaylistContextType.SUBTITLE_TRACK:return _.PlaylistLevelType.SUBTITLE;default:return _.PlaylistLevelType.MAIN}}function A(m,p){var f=m.url;return(f===void 0||f.indexOf("data:")===0)&&(f=p.url),f}var E=function(){function m(f){this.hls=void 0,this.loaders=Object.create(null),this.hls=f,this.registerListeners()}var p=m.prototype;return p.startLoad=function(e){},p.stopLoad=function(){this.destroyInternalLoaders()},p.registerListeners=function(){var e=this.hls;e.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(L.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.unregisterListeners=function(){var e=this.hls;e.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(L.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.createInternalLoader=function(e){var o=this.hls.config,h=o.pLoader,g=o.loader,i=h||g,r=new i(o);return e.loader=r,this.loaders[e.type]=r,r},p.getInternalLoader=function(e){return this.loaders[e.type]},p.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},p.destroyInternalLoaders=function(){for(var e in this.loaders){var o=this.loaders[e];o&&o.destroy(),this.resetInternalLoader(e)}},p.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},p.onManifestLoading=function(e,o){var h=o.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:_.PlaylistContextType.MANIFEST,url:h,deliveryDirectives:null})},p.onLevelLoading=function(e,o){var h=o.id,g=o.level,i=o.url,r=o.deliveryDirectives;this.load({id:h,groupId:null,level:g,responseType:"text",type:_.PlaylistContextType.LEVEL,url:i,deliveryDirectives:r})},p.onAudioTrackLoading=function(e,o){var h=o.id,g=o.groupId,i=o.url,r=o.deliveryDirectives;this.load({id:h,groupId:g,level:null,responseType:"text",type:_.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:r})},p.onSubtitleTrackLoading=function(e,o){var h=o.id,g=o.groupId,i=o.url,r=o.deliveryDirectives;this.load({id:h,groupId:g,level:null,responseType:"text",type:_.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:r})},p.load=function(e){var o,h=this.hls.config,g=this.getInternalLoader(e);if(g){var i=g.context;if(i&&i.url===e.url){M.logger.trace("[playlist-loader]: playlist request ongoing");return}M.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),g.abort()}var r,l,c,t;switch(e.type){case _.PlaylistContextType.MANIFEST:r=h.manifestLoadingMaxRetry,l=h.manifestLoadingTimeOut,c=h.manifestLoadingRetryDelay,t=h.manifestLoadingMaxRetryTimeout;break;case _.PlaylistContextType.LEVEL:case _.PlaylistContextType.AUDIO_TRACK:case _.PlaylistContextType.SUBTITLE_TRACK:r=0,l=h.levelLoadingTimeOut;break;default:r=h.levelLoadingMaxRetry,l=h.levelLoadingTimeOut,c=h.levelLoadingRetryDelay,t=h.levelLoadingMaxRetryTimeout;break}if(g=this.createInternalLoader(e),(o=e.deliveryDirectives)!==null&&o!==void 0&&o.part){var a;if(e.type===_.PlaylistContextType.LEVEL&&e.level!==null?a=this.hls.levels[e.level].details:e.type===_.PlaylistContextType.AUDIO_TRACK&&e.id!==null?a=this.hls.audioTracks[e.id].details:e.type===_.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(a=this.hls.subtitleTracks[e.id].details),a){var u=a.partTarget,s=a.targetduration;u&&s&&(l=Math.min(Math.max(u*3,s*.8)*1e3,l))}}var d={timeout:l,maxRetry:r,retryDelay:c,maxRetryDelay:t,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};g.load(e,d,v)},p.loadsuccess=function(e,o,h,g){if(g===void 0&&(g=null),h.isSidxRequest){this.handleSidxRequest(e,h),this.handlePlaylistLoaded(e,o,h,g);return}this.resetInternalLoader(h.type);var i=e.data;if(i.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,h,"no EXTM3U delimiter",g);return}o.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,o,h,g):this.handleMasterPlaylist(e,o,h,g)},p.loaderror=function(e,o,h){h===void 0&&(h=null),this.handleNetworkError(o,h,!1,e)},p.loadtimeout=function(e,o,h){h===void 0&&(h=null),this.handleNetworkError(o,h,!0)},p.handleMasterPlaylist=function(e,o,h,g){var i=this.hls,r=e.data,l=A(e,h),c=O.default.parseMasterPlaylist(r,l),t=c.levels,a=c.sessionData;if(!t.length){this.handleManifestParsingError(e,h,"no level found in manifest",g);return}var u=t.map(function(P){return{id:P.attrs.AUDIO,audioCodec:P.audioCodec}}),s=t.map(function(P){return{id:P.attrs.SUBTITLES,textCodec:P.textCodec}}),d=O.default.parseMasterPlaylistMedia(r,l,"AUDIO",u),v=O.default.parseMasterPlaylistMedia(r,l,"SUBTITLES",s),S=O.default.parseMasterPlaylistMedia(r,l,"CLOSED-CAPTIONS");if(d.length){var x=d.some(function(P){return!P.url});!x&&t[0].audioCodec&&!t[0].attrs.AUDIO&&(M.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),d.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}i.trigger(L.Events.MANIFEST_LOADED,{levels:t,audioTracks:d,subtitles:v,captions:S,url:l,stats:o,networkDetails:g,sessionData:a})},p.handleTrackOrLevelPlaylist=function(e,o,h,g){var i=this.hls,r=h.id,l=h.level,c=h.type,t=A(e,h),a=Object(I.isFiniteNumber)(r)?r:0,u=Object(I.isFiniteNumber)(l)?l:a,s=T(h),d=O.default.parseLevelPlaylist(e.data,t,u,s,a);if(!d.fragments.length){i.trigger(L.Events.ERROR,{type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:t,reason:"no fragments found in level",level:typeof h.level=="number"?h.level:void 0});return}if(c===_.PlaylistContextType.MANIFEST){var v={attrs:new y.AttrList({}),bitrate:0,details:d,name:"",url:t};i.trigger(L.Events.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:t,stats:o,networkDetails:g,sessionData:null})}if(o.parsing.end=performance.now(),d.needSidxRanges){var S,x=(S=d.fragments[0].initSegment)===null||S===void 0?void 0:S.url;this.load({url:x,isSidxRequest:!0,type:c,level:l,levelDetails:d,id:r,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}h.levelDetails=d,this.handlePlaylistLoaded(e,o,h,g)},p.handleSidxRequest=function(e,o){var h=new Uint8Array(e.data),g=Object(R.findBox)(h,["sidx"])[0];if(!!g){var i=Object(R.parseSegmentIndex)(g);if(!!i){var r=i.references,l=o.levelDetails;r.forEach(function(c,t){var a=c.info,u=l.fragments[t];if(u.byteRange.length===0&&u.setByteRange(String(1+a.end-a.start)+"@"+String(a.start)),u.initSegment){var s=Object(R.findBox)(h,["moov"])[0],d=s?s.length:null;u.initSegment.setByteRange(String(d)+"@0")}})}}},p.handleManifestParsingError=function(e,o,h,g){this.hls.trigger(L.Events.ERROR,{type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:o.type===_.PlaylistContextType.MANIFEST,url:e.url,reason:h,response:e,context:o,networkDetails:g})},p.handleNetworkError=function(e,o,h,g){h===void 0&&(h=!1),M.logger.warn("[playlist-loader]: A network "+(h?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var i=D.ErrorDetails.UNKNOWN,r=!1,l=this.getInternalLoader(e);switch(e.type){case _.PlaylistContextType.MANIFEST:i=h?D.ErrorDetails.MANIFEST_LOAD_TIMEOUT:D.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0;break;case _.PlaylistContextType.LEVEL:i=h?D.ErrorDetails.LEVEL_LOAD_TIMEOUT:D.ErrorDetails.LEVEL_LOAD_ERROR,r=!1;break;case _.PlaylistContextType.AUDIO_TRACK:i=h?D.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:D.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,r=!1;break;case _.PlaylistContextType.SUBTITLE_TRACK:i=h?D.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:D.ErrorDetails.SUBTITLE_LOAD_ERROR,r=!1;break}l&&this.resetInternalLoader(e.type);var c={type:D.ErrorTypes.NETWORK_ERROR,details:i,fatal:r,url:e.url,loader:l,context:e,networkDetails:o};g&&(c.response=g),this.hls.trigger(L.Events.ERROR,c)},p.handlePlaylistLoaded=function(e,o,h,g){var i=h.type,r=h.level,l=h.id,c=h.groupId,t=h.loader,a=h.levelDetails,u=h.deliveryDirectives;if(!(a!=null&&a.targetduration)){this.handleManifestParsingError(e,h,"invalid target duration",g);return}if(!!t)switch(a.live&&(t.getCacheAge&&(a.ageHeader=t.getCacheAge()||0),(!t.getCacheAge||isNaN(a.ageHeader))&&(a.ageHeader=0)),i){case _.PlaylistContextType.MANIFEST:case _.PlaylistContextType.LEVEL:this.hls.trigger(L.Events.LEVEL_LOADED,{details:a,level:r||0,id:l||0,stats:o,networkDetails:g,deliveryDirectives:u});break;case _.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(L.Events.AUDIO_TRACK_LOADED,{details:a,id:l||0,groupId:c||"",stats:o,networkDetails:g,deliveryDirectives:u});break;case _.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(L.Events.SUBTITLE_TRACK_LOADED,{details:a,id:l||0,groupId:c||"",stats:o,networkDetails:g,deliveryDirectives:u});break}},m}();b.default=E},"./src/polyfills/number.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"isFiniteNumber",function(){return I}),n.d(b,"MAX_SAFE_INTEGER",function(){return L});var I=Number.isFinite||function(D){return typeof D=="number"&&isFinite(D)},L=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(K,b,n){"use strict";n.r(b);var I=function(){function L(){}return L.getSilentFrame=function(M,R){switch(M){case"mp4a.40.2":if(R===1)return new Uint8Array([0,200,0,128,35,128]);if(R===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(R===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(R===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(R===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(R===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(R===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(R===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(R===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}},L}();b.default=I},"./src/remux/mp4-generator.ts":function(K,b,n){"use strict";n.r(b);var I=Math.pow(2,32)-1,L=function(){function D(){}return D.init=function(){D.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var R;for(R in D.types)D.types.hasOwnProperty(R)&&(D.types[R]=[R.charCodeAt(0),R.charCodeAt(1),R.charCodeAt(2),R.charCodeAt(3)]);var O=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]),_=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]);D.HDLR_TYPES={video:O,audio:_};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),T=new Uint8Array([0,0,0,0,0,0,0,0]);D.STTS=D.STSC=D.STCO=T,D.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),D.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),D.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),D.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var A=new Uint8Array([105,115,111,109]),E=new Uint8Array([97,118,99,49]),m=new Uint8Array([0,0,0,1]);D.FTYP=D.box(D.types.ftyp,A,m,A,E),D.DINF=D.box(D.types.dinf,D.box(D.types.dref,y))},D.box=function(R){for(var O=8,_=arguments.length,y=new Array(_>1?_-1:0),T=1;T<_;T++)y[T-1]=arguments[T];for(var A=y.length,E=A;A--;)O+=y[A].byteLength;var m=new Uint8Array(O);for(m[0]=O>>24&255,m[1]=O>>16&255,m[2]=O>>8&255,m[3]=O&255,m.set(R,4),A=0,O=8;A<E;A++)m.set(y[A],O),O+=y[A].byteLength;return m},D.hdlr=function(R){return D.box(D.types.hdlr,D.HDLR_TYPES[R])},D.mdat=function(R){return D.box(D.types.mdat,R)},D.mdhd=function(R,O){O*=R;var _=Math.floor(O/(I+1)),y=Math.floor(O%(I+1));return D.box(D.types.mdhd,new Uint8Array([1,0,0,0,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,R&255,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},D.mdia=function(R){return D.box(D.types.mdia,D.mdhd(R.timescale,R.duration),D.hdlr(R.type),D.minf(R))},D.mfhd=function(R){return D.box(D.types.mfhd,new Uint8Array([0,0,0,0,R>>24,R>>16&255,R>>8&255,R&255]))},D.minf=function(R){return R.type==="audio"?D.box(D.types.minf,D.box(D.types.smhd,D.SMHD),D.DINF,D.stbl(R)):D.box(D.types.minf,D.box(D.types.vmhd,D.VMHD),D.DINF,D.stbl(R))},D.moof=function(R,O,_){return D.box(D.types.moof,D.mfhd(R),D.traf(_,O))},D.moov=function(R){for(var O=R.length,_=[];O--;)_[O]=D.trak(R[O]);return D.box.apply(null,[D.types.moov,D.mvhd(R[0].timescale,R[0].duration)].concat(_).concat(D.mvex(R)))},D.mvex=function(R){for(var O=R.length,_=[];O--;)_[O]=D.trex(R[O]);return D.box.apply(null,[D.types.mvex].concat(_))},D.mvhd=function(R,O){O*=R;var _=Math.floor(O/(I+1)),y=Math.floor(O%(I+1)),T=new Uint8Array([1,0,0,0,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,R&255,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return D.box(D.types.mvhd,T)},D.sdtp=function(R){var O=R.samples||[],_=new Uint8Array(4+O.length),y,T;for(y=0;y<O.length;y++)T=O[y].flags,_[y+4]=T.dependsOn<<4|T.isDependedOn<<2|T.hasRedundancy;return D.box(D.types.sdtp,_)},D.stbl=function(R){return D.box(D.types.stbl,D.stsd(R),D.box(D.types.stts,D.STTS),D.box(D.types.stsc,D.STSC),D.box(D.types.stsz,D.STSZ),D.box(D.types.stco,D.STCO))},D.avc1=function(R){var O=[],_=[],y,T,A;for(y=0;y<R.sps.length;y++)T=R.sps[y],A=T.byteLength,O.push(A>>>8&255),O.push(A&255),O=O.concat(Array.prototype.slice.call(T));for(y=0;y<R.pps.length;y++)T=R.pps[y],A=T.byteLength,_.push(A>>>8&255),_.push(A&255),_=_.concat(Array.prototype.slice.call(T));var E=D.box(D.types.avcC,new Uint8Array([1,O[3],O[4],O[5],255,224|R.sps.length].concat(O).concat([R.pps.length]).concat(_))),m=R.width,p=R.height,f=R.pixelRatio[0],e=R.pixelRatio[1];return D.box(D.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,m>>8&255,m&255,p>>8&255,p&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),E,D.box(D.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),D.box(D.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,f&255,e>>24,e>>16&255,e>>8&255,e&255])))},D.esds=function(R){var O=R.config.length;return new Uint8Array([0,0,0,0,3,23+O,0,1,0,4,15+O,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([O]).concat(R.config).concat([6,1,2]))},D.mp4a=function(R){var O=R.samplerate;return D.box(D.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,R.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]),D.box(D.types.esds,D.esds(R)))},D.mp3=function(R){var O=R.samplerate;return D.box(D.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,R.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]))},D.stsd=function(R){return R.type==="audio"?R.segmentCodec==="mp3"&&R.codec==="mp3"?D.box(D.types.stsd,D.STSD,D.mp3(R)):D.box(D.types.stsd,D.STSD,D.mp4a(R)):D.box(D.types.stsd,D.STSD,D.avc1(R))},D.tkhd=function(R){var O=R.id,_=R.duration*R.timescale,y=R.width,T=R.height,A=Math.floor(_/(I+1)),E=Math.floor(_%(I+1));return D.box(D.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,O>>24&255,O>>16&255,O>>8&255,O&255,0,0,0,0,A>>24,A>>16&255,A>>8&255,A&255,E>>24,E>>16&255,E>>8&255,E&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,y>>8&255,y&255,0,0,T>>8&255,T&255,0,0]))},D.traf=function(R,O){var _=D.sdtp(R),y=R.id,T=Math.floor(O/(I+1)),A=Math.floor(O%(I+1));return D.box(D.types.traf,D.box(D.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),D.box(D.types.tfdt,new Uint8Array([1,0,0,0,T>>24,T>>16&255,T>>8&255,T&255,A>>24,A>>16&255,A>>8&255,A&255])),D.trun(R,_.length+16+20+8+16+8+8),_)},D.trak=function(R){return R.duration=R.duration||4294967295,D.box(D.types.trak,D.tkhd(R),D.mdia(R))},D.trex=function(R){var O=R.id;return D.box(D.types.trex,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},D.trun=function(R,O){var _=R.samples||[],y=_.length,T=12+16*y,A=new Uint8Array(T),E,m,p,f,e,o;for(O+=8+T,A.set([R.type==="video"?1:0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,O>>>24&255,O>>>16&255,O>>>8&255,O&255],0),E=0;E<y;E++)m=_[E],p=m.duration,f=m.size,e=m.flags,o=m.cts,A.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,o>>>24&255,o>>>16&255,o>>>8&255,o&255],12+16*E);return D.box(D.types.trun,A)},D.initSegment=function(R){D.types||D.init();var O=D.moov(R),_=new Uint8Array(D.FTYP.byteLength+O.byteLength);return _.set(D.FTYP),_.set(O,D.FTYP.byteLength),_},D}();L.types=void 0,L.HDLR_TYPES=void 0,L.STTS=void 0,L.STSC=void 0,L.STCO=void 0,L.STSZ=void 0,L.VMHD=void 0,L.SMHD=void 0,L.STSD=void 0,L.FTYP=void 0,L.DINF=void 0,b.default=L},"./src/remux/mp4-remuxer.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return e}),n.d(b,"normalizePts",function(){return o}),n.d(b,"flushTextTrackMetadataCueSamples",function(){return g}),n.d(b,"flushTextTrackUserdataCueSamples",function(){return i});var I=n("./src/polyfills/number.ts"),L=n("./src/remux/aac-helper.ts"),D=n("./src/remux/mp4-generator.ts"),M=n("./src/events.ts"),R=n("./src/errors.ts"),O=n("./src/utils/logger.ts"),_=n("./src/types/loader.ts"),y=n("./src/utils/timescale-conversion.ts");function T(){return T=Object.assign?Object.assign.bind():function(c){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var u in a)Object.prototype.hasOwnProperty.call(a,u)&&(c[u]=a[u])}return c},T.apply(this,arguments)}var A=10*1e3,E=1024,m=1152,p=null,f=null,e=function(){function c(a,u,s,d){if(d===void 0&&(d=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=a,this.config=u,this.typeSupported=s,this.ISGenerated=!1,p===null){var v=navigator.userAgent||"",S=v.match(/Chrome\/(\d+)/i);p=S?parseInt(S[1]):0}if(f===null){var x=navigator.userAgent.match(/Safari\/(\d+)/i);f=x?parseInt(x[1]):0}}var t=c.prototype;return t.destroy=function(){},t.resetTimeStamp=function(u){O.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=u},t.resetNextTimestamp=function(){O.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){O.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},t.getVideoStartPts=function(u){var s=!1,d=u.reduce(function(v,S){var x=S.pts-v;return x<-4294967296?(s=!0,o(v,S.pts)):x>0?v:S.pts},u[0].pts);return s&&O.logger.debug("PTS rollover detected"),d},t.remux=function(u,s,d,v,S,x,P,B){var k,U,W,G,z,Y,J=S,ee=S,X=u.pid>-1,q=s.pid>-1,ie=s.samples.length,ae=u.samples.length>0,te=P&&ie>0||ie>1,oe=(!X||ae)&&(!q||te)||this.ISGenerated||P;if(oe){this.ISGenerated||(W=this.generateIS(u,s,S));var ue=this.isVideoContiguous,re=-1,he;if(te&&(re=h(s.samples),!ue&&this.config.forceKeyFrameOnDiscontinuity))if(Y=!0,re>0){O.logger.warn("[mp4-remuxer]: Dropped "+re+" out of "+ie+" video samples due to a missing keyframe");var ve=this.getVideoStartPts(s.samples);s.samples=s.samples.slice(re),s.dropped+=re,ee+=(s.samples[0].pts-ve)/s.inputTimeScale,he=ee}else re===-1&&(O.logger.warn("[mp4-remuxer]: No keyframe found out of "+ie+" video samples"),Y=!1);if(this.ISGenerated){if(ae&&te){var Se=this.getVideoStartPts(s.samples),Me=o(u.samples[0].pts,Se)-Se,Oe=Me/s.inputTimeScale;J+=Math.max(0,Oe),ee+=Math.max(0,-Oe)}if(ae){if(u.samplerate||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),W=this.generateIS(u,s,S)),U=this.remuxAudio(u,J,this.isAudioContiguous,x,q||te||B===_.PlaylistLevelType.AUDIO?ee:void 0),te){var Ne=U?U.endPTS-U.startPTS:0;s.inputTimeScale||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),W=this.generateIS(u,s,S)),k=this.remuxVideo(s,ee,ue,Ne)}}else te&&(k=this.remuxVideo(s,ee,ue,0));k&&(k.firstKeyFrame=re,k.independent=re!==-1,k.firstKeyFramePTS=he)}}return this.ISGenerated&&(d.samples.length&&(z=g(d,S,this._initPTS,this._initDTS)),v.samples.length&&(G=i(v,S,this._initPTS))),{audio:U,video:k,initSegment:W,independent:Y,text:G,id3:z}},t.generateIS=function(u,s,d){var v=u.samples,S=s.samples,x=this.typeSupported,P={},B=!Object(I.isFiniteNumber)(this._initPTS),k="audio/mp4",U,W,G;if(B&&(U=W=1/0),u.config&&v.length){switch(u.timescale=u.samplerate,u.segmentCodec){case"mp3":x.mpeg?(k="audio/mpeg",u.codec=""):x.mp3&&(u.codec="mp3");break}P.audio={id:"audio",container:k,codec:u.codec,initSegment:u.segmentCodec==="mp3"&&x.mpeg?new Uint8Array(0):D.default.initSegment([u]),metadata:{channelCount:u.channelCount}},B&&(G=u.inputTimeScale,U=W=v[0].pts-Math.round(G*d))}if(s.sps&&s.pps&&S.length&&(s.timescale=s.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:s.codec,initSegment:D.default.initSegment([s]),metadata:{width:s.width,height:s.height}},B)){G=s.inputTimeScale;var z=this.getVideoStartPts(S),Y=Math.round(G*d);W=Math.min(W,o(S[0].dts,z)-Y),U=Math.min(U,z-Y)}if(Object.keys(P).length)return this.ISGenerated=!0,B&&(this._initPTS=U,this._initDTS=W),{tracks:P,initPTS:U,timescale:G}},t.remuxVideo=function(u,s,d,v){var S=u.inputTimeScale,x=u.samples,P=[],B=x.length,k=this._initPTS,U=this.nextAvcDts,W=8,G=this.videoSampleDuration,z,Y,J=Number.POSITIVE_INFINITY,ee=Number.NEGATIVE_INFINITY,X=!1;if(!d||U===null){var q=s*S,ie=x[0].pts-o(x[0].dts,x[0].pts);U=q-ie}for(var ae=0;ae<B;ae++){var te=x[ae];te.pts=o(te.pts-k,U),te.dts=o(te.dts-k,U),te.dts<x[ae>0?ae-1:ae].dts&&(X=!0)}X&&x.sort(function(It,ur){var Lt=It.dts-ur.dts,Lr=It.pts-ur.pts;return Lt||Lr}),z=x[0].dts,Y=x[x.length-1].dts;var oe=Y-z,ue=oe?Math.round(oe/(B-1)):G||u.inputTimeScale/30;if(d){var re=z-U,he=re>ue,ve=re<-1;if(he||ve){he?O.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(re,!0)+" ms ("+re+"dts) hole between fragments detected, filling it"):O.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-re,!0)+" ms ("+re+"dts) overlapping between fragments detected"),z=U;var Se=x[0].pts-re;x[0].dts=z,x[0].pts=Se,O.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(Se,!0)+"/"+Object(y.toMsFromMpegTsClock)(z,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(re,!0)+" ms")}}z=Math.max(0,z);for(var Me=0,Oe=0,Ne=0;Ne<B;Ne++){for(var Pe=x[Ne],Ke=Pe.units,ge=Ke.length,ke=0,je=0;je<ge;je++)ke+=Ke[je].data.length;Oe+=ke,Me+=ge,Pe.length=ke,Pe.dts=Math.max(Pe.dts,z),J=Math.min(Pe.pts,J),ee=Math.max(Pe.pts,ee)}Y=x[B-1].dts;var He=Oe+4*Me+8,We;try{We=new Uint8Array(He)}catch{this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:R.ErrorTypes.MUX_ERROR,details:R.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:He,reason:"fail allocating video mdat "+He});return}var Ye=new DataView(We.buffer);Ye.setUint32(0,He),We.set(D.default.types.mdat,4);for(var Ge=!1,nt=Number.POSITIVE_INFINITY,we=Number.POSITIVE_INFINITY,Be=Number.NEGATIVE_INFINITY,$e=Number.NEGATIVE_INFINITY,Ue=0;Ue<B;Ue++){for(var Ie=x[Ue],ot=Ie.units,ze=0,dt=0,St=ot.length;dt<St;dt++){var qe=ot[dt],Rt=qe.data,Dt=qe.data.byteLength;Ye.setUint32(W,Dt),W+=4,We.set(Rt,W),W+=Dt,ze+=4+Dt}var lt=void 0;if(Ue<B-1)G=x[Ue+1].dts-Ie.dts,lt=x[Ue+1].pts-Ie.pts;else{var ct=this.config,ut=Ue>0?Ie.dts-x[Ue-1].dts:ue;if(lt=Ue>0?Ie.pts-x[Ue-1].pts:ue,ct.stretchShortVideoTrack&&this.nextAudioPts!==null){var At=Math.floor(ct.maxBufferHole*S),Tt=(v?J+v*S:this.nextAudioPts)-Ie.pts;Tt>At?(G=Tt-ut,G<0?G=ut:Ge=!0,O.logger.log("[mp4-remuxer]: It is approximately "+Tt/90+" ms to the next segment; using duration "+G/90+" ms for the last video frame.")):G=ut}else G=ut}var Sr=Math.round(Ie.pts-Ie.dts);nt=Math.min(nt,G),Be=Math.max(Be,G),we=Math.min(we,lt),$e=Math.max($e,lt),P.push(new r(Ie.key,G,ze,Sr))}if(P.length){if(p){if(p<70){var Kt=P[0].flags;Kt.dependsOn=2,Kt.isNonSync=0}}else if(f&&$e-we<Be-nt&&ue/Be<.025&&P[0].cts===0){O.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var Pt=z,et=0,or=P.length;et<or;et++){var jt=Pt+P[et].duration,lr=Pt+P[et].cts;if(et<or-1){var Wt=jt+P[et+1].cts;P[et].duration=Wt-lr}else P[et].duration=et?P[et-1].duration:ue;P[et].cts=0,Pt=jt}}}console.assert(G!==null,"mp4SampleDuration must be computed"),G=Ge||!G?ue:G,this.nextAvcDts=U=Y+G,this.videoSampleDuration=G,this.isVideoContiguous=!0;var Dr=D.default.moof(u.sequenceNumber++,z,T({},u,{samples:P})),Ar="video",ft={data1:Dr,data2:We,startPTS:J/S,endPTS:(ee+G)/S,startDTS:z/S,endDTS:U/S,type:Ar,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:u.dropped};return u.samples=[],u.dropped=0,console.assert(We.length,"MDAT length must not be zero"),ft},t.remuxAudio=function(u,s,d,v,S){var x=u.inputTimeScale,P=u.samplerate?u.samplerate:x,B=x/P,k=u.segmentCodec==="aac"?E:m,U=k*B,W=this._initPTS,G=u.segmentCodec==="mp3"&&this.typeSupported.mpeg,z=[],Y=S!==void 0,J=u.samples,ee=G?0:8,X=this.nextAudioPts||-1,q=s*x;if(this.isAudioContiguous=d=d||J.length&&X>0&&(v&&Math.abs(q-X)<9e3||Math.abs(o(J[0].pts-W,q)-X)<20*U),J.forEach(function(qe){qe.pts=o(qe.pts-W,q)}),!d||X<0){if(J=J.filter(function(qe){return qe.pts>=0}),!J.length)return;S===0?X=0:v&&!Y?X=Math.max(0,q):X=J[0].pts}if(u.segmentCodec==="aac")for(var ie=this.config.maxAudioFramesDrift,ae=0,te=X;ae<J.length;ae++){var oe=J[ae],ue=oe.pts,re=ue-te,he=Math.abs(1e3*re/x);if(re<=-ie*U&&Y)ae===0&&(O.logger.warn("Audio frame @ "+(ue/x).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*re/x)+" ms."),this.nextAudioPts=X=te=ue);else if(re>=ie*U&&he<A&&Y){var ve=Math.round(re/U);te=ue-ve*U,te<0&&(ve--,te+=U),ae===0&&(this.nextAudioPts=X=te),O.logger.warn("[mp4-remuxer]: Injecting "+ve+" audio frame @ "+(te/x).toFixed(3)+"s due to "+Math.round(1e3*re/x)+" ms gap.");for(var Se=0;Se<ve;Se++){var Me=Math.max(te,0),Oe=L.default.getSilentFrame(u.manifestCodec||u.codec,u.channelCount);Oe||(O.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Oe=oe.unit.subarray()),J.splice(ae,0,{unit:Oe,pts:Me}),te+=U,ae++}}oe.pts=te,te+=U}for(var Ne=null,Pe=null,Ke,ge=0,ke=J.length;ke--;)ge+=J[ke].unit.byteLength;for(var je=0,He=J.length;je<He;je++){var We=J[je],Ye=We.unit,Ge=We.pts;if(Pe!==null){var nt=z[je-1];nt.duration=Math.round((Ge-Pe)/B)}else if(d&&u.segmentCodec==="aac"&&(Ge=X),Ne=Ge,ge>0){ge+=ee;try{Ke=new Uint8Array(ge)}catch{this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:R.ErrorTypes.MUX_ERROR,details:R.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ge,reason:"fail allocating audio mdat "+ge});return}if(!G){var we=new DataView(Ke.buffer);we.setUint32(0,ge),Ke.set(D.default.types.mdat,4)}}else return;Ke.set(Ye,ee);var Be=Ye.byteLength;ee+=Be,z.push(new r(!0,k,Be,0)),Pe=Ge}var $e=z.length;if(!!$e){var Ue=z[z.length-1];this.nextAudioPts=X=Pe+B*Ue.duration;var Ie=G?new Uint8Array(0):D.default.moof(u.sequenceNumber++,Ne/B,T({},u,{samples:z}));u.samples=[];var ot=Ne/x,ze=X/x,dt="audio",St={data1:Ie,data2:Ke,startPTS:ot,endPTS:ze,startDTS:ot,endDTS:ze,type:dt,hasAudio:!0,hasVideo:!1,nb:$e};return this.isAudioContiguous=!0,console.assert(Ke.length,"MDAT length must not be zero"),St}},t.remuxEmptyAudio=function(u,s,d,v){var S=u.inputTimeScale,x=u.samplerate?u.samplerate:S,P=S/x,B=this.nextAudioPts,k=(B!==null?B:v.startDTS*S)+this._initDTS,U=v.endDTS*S+this._initDTS,W=P*E,G=Math.ceil((U-k)/W),z=L.default.getSilentFrame(u.manifestCodec||u.codec,u.channelCount);if(O.logger.warn("[mp4-remuxer]: remux empty Audio"),!z){O.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var Y=[],J=0;J<G;J++){var ee=k+J*W;Y.push({unit:z,pts:ee,dts:ee})}return u.samples=Y,this.remuxAudio(u,s,d,!1)},c}();function o(c,t){var a;if(t===null)return c;for(t<c?a=-8589934592:a=8589934592;Math.abs(c-t)>4294967296;)c+=a;return c}function h(c){for(var t=0;t<c.length;t++)if(c[t].key)return t;return-1}function g(c,t,a,u){var s=c.samples.length;if(!!s){for(var d=c.inputTimeScale,v=0;v<s;v++){var S=c.samples[v];S.pts=o(S.pts-a,t*d)/d,S.dts=o(S.dts-u,t*d)/d}var x=c.samples;return c.samples=[],{samples:x}}}function i(c,t,a){var u=c.samples.length;if(!!u){for(var s=c.inputTimeScale,d=0;d<u;d++){var v=c.samples[d];v.pts=o(v.pts-a,t*s)/s}c.samples.sort(function(x,P){return x.pts-P.pts});var S=c.samples;return c.samples=[],{samples:S}}}var r=function(t,a,u,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=a,this.size=u,this.cts=s,this.flags=new l(t)},l=function(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}},"./src/remux/passthrough-remuxer.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/polyfills/number.ts"),L=n("./src/remux/mp4-remuxer.ts"),D=n("./src/utils/mp4-tools.ts"),M=n("./src/loader/fragment.ts"),R=n("./src/utils/logger.ts"),O=function(){function y(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var T=y.prototype;return T.destroy=function(){},T.resetTimeStamp=function(E){this.initPTS=E,this.lastEndTime=null},T.resetNextTimestamp=function(){this.lastEndTime=null},T.resetInitSegment=function(E,m,p){this.audioCodec=m,this.videoCodec=p,this.generateInitSegment(E),this.emitInitSegment=!0},T.generateInitSegment=function(E){var m=this.audioCodec,p=this.videoCodec;if(!E||!E.byteLength){this.initTracks=void 0,this.initData=void 0;return}var f=this.initData=Object(D.parseInitSegment)(E);m||(m=_(f.audio,M.ElementaryStreamTypes.AUDIO)),p||(p=_(f.video,M.ElementaryStreamTypes.VIDEO));var e={};f.audio&&f.video?e.audiovideo={container:"video/mp4",codec:m+","+p,initSegment:E,id:"main"}:f.audio?e.audio={container:"audio/mp4",codec:m,initSegment:E,id:"audio"}:f.video?e.video={container:"video/mp4",codec:p,initSegment:E,id:"main"}:R.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},T.remux=function(E,m,p,f,e){var o,h=this.initPTS,g=this.lastEndTime,i={audio:void 0,video:void 0,text:f,id3:p,initSegment:void 0};Object(I.isFiniteNumber)(g)||(g=this.lastEndTime=e||0);var r=m.samples;if(!r||!r.length)return i;var l={initPTS:void 0,timescale:1},c=this.initData;if((!c||!c.length)&&(this.generateInitSegment(r),c=this.initData),!c||!c.length)return R.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(l.tracks=this.initTracks,this.emitInitSegment=!1);var t=Object(D.getStartDTS)(c,r);Object(I.isFiniteNumber)(h)||(this.initPTS=l.initPTS=h=t-e);var a=Object(D.getDuration)(r,c),u=E?t-h:g,s=u+a;Object(D.offsetStartDTS)(c,r,h),a>0?this.lastEndTime=s:(R.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var d=!!c.audio,v=!!c.video,S="";d&&(S+="audio"),v&&(S+="video");var x={data1:r,startPTS:u,startDTS:u,endPTS:s,endDTS:s,type:S,hasAudio:d,hasVideo:v,nb:1,dropped:0};i.audio=x.type==="audio"?x:void 0,i.video=x.type!=="audio"?x:void 0,i.initSegment=l;var P=(o=this.initPTS)!=null?o:0;return i.id3=Object(L.flushTextTrackMetadataCueSamples)(p,e,P,P),f.samples.length&&(i.text=Object(L.flushTextTrackUserdataCueSamples)(f,e,P)),i},y}();function _(y,T){var A=y==null?void 0:y.codec;return A&&A.length>4?A:A==="hvc1"||A==="hev1"?"hvc1.1.c.L120.90":A==="av01"?"av01.0.04M.08":A==="avc1"||T===M.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}b.default=O},"./src/task-loop.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return I});var I=function(){function L(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var D=L.prototype;return D.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},D.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},D.onHandlerDestroyed=function(){},D.hasInterval=function(){return!!this._tickInterval},D.hasNextTick=function(){return!!this._tickTimer},D.setInterval=function(R){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,R),!0)},D.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},D.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},D.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},D.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},D.doTick=function(){},L}()},"./src/types/cmcd.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"CMCDVersion",function(){return I}),n.d(b,"CMCDObjectType",function(){return L}),n.d(b,"CMCDStreamingFormat",function(){return D}),n.d(b,"CMCDStreamType",function(){return M});var I=1,L;(function(R){R.MANIFEST="m",R.AUDIO="a",R.VIDEO="v",R.MUXED="av",R.INIT="i",R.CAPTION="c",R.TIMED_TEXT="tt",R.KEY="k",R.OTHER="o"})(L||(L={}));var D;(function(R){R.DASH="d",R.HLS="h",R.SMOOTH="s",R.OTHER="o"})(D||(D={}));var M;(function(R){R.VOD="v",R.LIVE="l"})(M||(M={}))},"./src/types/demuxer.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"MetadataSchema",function(){return I});var I;(function(L){L.audioId3="org.id3",L.dateRange="com.apple.quicktime.HLS",L.emsg="https://aomedia.org/emsg/ID3"})(I||(I={}))},"./src/types/level.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"HlsSkip",function(){return D}),n.d(b,"getSkipValue",function(){return M}),n.d(b,"HlsUrlParameters",function(){return R}),n.d(b,"Level",function(){return O});function I(_,y){for(var T=0;T<y.length;T++){var A=y[T];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(_,A.key,A)}}function L(_,y,T){return y&&I(_.prototype,y),T&&I(_,T),Object.defineProperty(_,"prototype",{writable:!1}),_}var D;(function(_){_.No="",_.Yes="YES",_.v2="v2"})(D||(D={}));function M(_,y){var T=_.canSkipUntil,A=_.canSkipDateRanges,E=_.endSN,m=y!==void 0?y-E:0;return T&&m<T?A?D.v2:D.Yes:D.No}var R=function(){function _(T,A,E){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=T,this.part=A,this.skip=E}var y=_.prototype;return y.addDirectives=function(A){var E=new self.URL(A);return this.msn!==void 0&&E.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&E.searchParams.set("_HLS_part",this.part.toString()),this.skip&&E.searchParams.set("_HLS_skip",this.skip),E.toString()},_}(),O=function(){function _(y){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[y.url],this.attrs=y.attrs,this.bitrate=y.bitrate,y.details&&(this.details=y.details),this.id=y.id||0,this.name=y.name,this.width=y.width||0,this.height=y.height||0,this.audioCodec=y.audioCodec,this.videoCodec=y.videoCodec,this.unknownCodecs=y.unknownCodecs,this.codecSet=[y.videoCodec,y.audioCodec].filter(function(T){return T}).join(",").replace(/\.[^.,]+/g,"")}return L(_,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(T){var A=T%this.url.length;this._urlId!==A&&(this.details=void 0,this._urlId=A)}}]),_}()},"./src/types/loader.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"PlaylistContextType",function(){return I}),n.d(b,"PlaylistLevelType",function(){return L});var I;(function(D){D.MANIFEST="manifest",D.LEVEL="level",D.AUDIO_TRACK="audioTrack",D.SUBTITLE_TRACK="subtitleTrack"})(I||(I={}));var L;(function(D){D.MAIN="main",D.AUDIO="audio",D.SUBTITLE="subtitle"})(L||(L={}))},"./src/types/transmuxer.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"ChunkMetadata",function(){return I});var I=function(M,R,O,_,y,T){_===void 0&&(_=0),y===void 0&&(y=-1),T===void 0&&(T=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=L(),this.buffering={audio:L(),video:L(),audiovideo:L()},this.level=M,this.sn=R,this.id=O,this.size=_,this.part=y,this.partial=T};function L(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"AttrList",function(){return D});var I=/^(\d+)x(\d+)$/,L=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,D=function(){function M(O){typeof O=="string"&&(O=M.parseAttrList(O));for(var _ in O)O.hasOwnProperty(_)&&(this[_]=O[_])}var R=M.prototype;return R.decimalInteger=function(_){var y=parseInt(this[_],10);return y>Number.MAX_SAFE_INTEGER?1/0:y},R.hexadecimalInteger=function(_){if(this[_]){var y=(this[_]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var T=new Uint8Array(y.length/2),A=0;A<y.length/2;A++)T[A]=parseInt(y.slice(A*2,A*2+2),16);return T}else return null},R.hexadecimalIntegerAsNumber=function(_){var y=parseInt(this[_],16);return y>Number.MAX_SAFE_INTEGER?1/0:y},R.decimalFloatingPoint=function(_){return parseFloat(this[_])},R.optionalFloat=function(_,y){var T=this[_];return T?parseFloat(T):y},R.enumeratedString=function(_){return this[_]},R.bool=function(_){return this[_]==="YES"},R.decimalResolution=function(_){var y=I.exec(this[_]);if(y!==null)return{width:parseInt(y[1],10),height:parseInt(y[2],10)}},M.parseAttrList=function(_){var y,T={},A='"';for(L.lastIndex=0;(y=L.exec(_))!==null;){var E=y[2];E.indexOf(A)===0&&E.lastIndexOf(A)===E.length-1&&(E=E.slice(1,-1)),T[y[1]]=E}return T},M}()},"./src/utils/binary-search.ts":function(K,b,n){"use strict";n.r(b);var I={search:function(D,M){for(var R=0,O=D.length-1,_=null,y=null;R<=O;){_=(R+O)/2|0,y=D[_];var T=M(y);if(T>0)R=_+1;else if(T<0)O=_-1;else return y}return null}};b.default=I},"./src/utils/buffer-helper.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"BufferHelper",function(){return D});var I=n("./src/utils/logger.ts"),L={length:0,start:function(){return 0},end:function(){return 0}},D=function(){function M(){}return M.isBuffered=function(O,_){try{if(O){for(var y=M.getBuffered(O),T=0;T<y.length;T++)if(_>=y.start(T)&&_<=y.end(T))return!0}}catch{}return!1},M.bufferInfo=function(O,_,y){try{if(O){var T=M.getBuffered(O),A=[],E;for(E=0;E<T.length;E++)A.push({start:T.start(E),end:T.end(E)});return this.bufferedInfo(A,_,y)}}catch{}return{len:0,start:_,end:_,nextStart:void 0}},M.bufferedInfo=function(O,_,y){_=Math.max(0,_),O.sort(function(r,l){var c=r.start-l.start;return c||l.end-r.end});var T=[];if(y)for(var A=0;A<O.length;A++){var E=T.length;if(E){var m=T[E-1].end;O[A].start-m<y?O[A].end>m&&(T[E-1].end=O[A].end):T.push(O[A])}else T.push(O[A])}else T=O;for(var p=0,f,e=_,o=_,h=0;h<T.length;h++){var g=T[h].start,i=T[h].end;if(_+y>=g&&_<i)e=g,o=i,p=o-_;else if(_+y<g){f=g;break}}return{len:p,start:e||0,end:o||0,nextStart:f}},M.getBuffered=function(O){try{return O.buffered}catch(_){return I.logger.log("failed to get media.buffered",_),L}},M}()},"./src/utils/cea-608-parser.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"Row",function(){return o}),n.d(b,"CaptionScreen",function(){return h});var I=n("./src/utils/logger.ts"),L={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},D=function(a){var u=a;return L.hasOwnProperty(a)&&(u=L[a]),String.fromCharCode(u)},M=15,R=100,O={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_={17:2,18:4,21:6,22:8,23:10,19:13,20:15},y={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},T={25:2,26:4,29:6,30:8,31:10,27:13,28:15},A=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],E;(function(t){t[t.ERROR=0]="ERROR",t[t.TEXT=1]="TEXT",t[t.WARNING=2]="WARNING",t[t.INFO=2]="INFO",t[t.DEBUG=3]="DEBUG",t[t.DATA=3]="DATA"})(E||(E={}));var m=function(){function t(){this.time=null,this.verboseLevel=E.ERROR}var a=t.prototype;return a.log=function(s,d){this.verboseLevel>=s&&I.logger.log(this.time+" ["+s+"] "+d)},t}(),p=function(a){for(var u=[],s=0;s<a.length;s++)u.push(a[s].toString(16));return u},f=function(){function t(u,s,d,v,S){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=u||"white",this.underline=s||!1,this.italics=d||!1,this.background=v||"black",this.flash=S||!1}var a=t.prototype;return a.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},a.setStyles=function(s){for(var d=["foreground","underline","italics","background","flash"],v=0;v<d.length;v++){var S=d[v];s.hasOwnProperty(S)&&(this[S]=s[S])}},a.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},a.equals=function(s){return this.foreground===s.foreground&&this.underline===s.underline&&this.italics===s.italics&&this.background===s.background&&this.flash===s.flash},a.copy=function(s){this.foreground=s.foreground,this.underline=s.underline,this.italics=s.italics,this.background=s.background,this.flash=s.flash},a.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},t}(),e=function(){function t(u,s,d,v,S,x){this.uchar=void 0,this.penState=void 0,this.uchar=u||" ",this.penState=new f(s,d,v,S,x)}var a=t.prototype;return a.reset=function(){this.uchar=" ",this.penState.reset()},a.setChar=function(s,d){this.uchar=s,this.penState.copy(d)},a.setPenState=function(s){this.penState.copy(s)},a.equals=function(s){return this.uchar===s.uchar&&this.penState.equals(s.penState)},a.copy=function(s){this.uchar=s.uchar,this.penState.copy(s.penState)},a.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},t}(),o=function(){function t(u){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var s=0;s<R;s++)this.chars.push(new e);this.logger=u,this.pos=0,this.currPenState=new f}var a=t.prototype;return a.equals=function(s){for(var d=!0,v=0;v<R;v++)if(!this.chars[v].equals(s.chars[v])){d=!1;break}return d},a.copy=function(s){for(var d=0;d<R;d++)this.chars[d].copy(s.chars[d])},a.isEmpty=function(){for(var s=!0,d=0;d<R;d++)if(!this.chars[d].isEmpty()){s=!1;break}return s},a.setCursor=function(s){this.pos!==s&&(this.pos=s),this.pos<0?(this.logger.log(E.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>R&&(this.logger.log(E.DEBUG,"Too large cursor position "+this.pos),this.pos=R)},a.moveCursor=function(s){var d=this.pos+s;if(s>1)for(var v=this.pos+1;v<d+1;v++)this.chars[v].setPenState(this.currPenState);this.setCursor(d)},a.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},a.insertChar=function(s){s>=144&&this.backSpace();var d=D(s);if(this.pos>=R){this.logger.log(E.ERROR,"Cannot insert "+s.toString(16)+" ("+d+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(d,this.currPenState),this.moveCursor(1)},a.clearFromPos=function(s){var d;for(d=s;d<R;d++)this.chars[d].reset()},a.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},a.clearToEndOfRow=function(){this.clearFromPos(this.pos)},a.getTextString=function(){for(var s=[],d=!0,v=0;v<R;v++){var S=this.chars[v].uchar;S!==" "&&(d=!1),s.push(S)}return d?"":s.join("")},a.setPenStyles=function(s){this.currPenState.setStyles(s);var d=this.chars[this.pos];d.setPenState(this.currPenState)},t}(),h=function(){function t(u){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var s=0;s<M;s++)this.rows.push(new o(u));this.logger=u,this.currRow=M-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var a=t.prototype;return a.reset=function(){for(var s=0;s<M;s++)this.rows[s].clear();this.currRow=M-1},a.equals=function(s){for(var d=!0,v=0;v<M;v++)if(!this.rows[v].equals(s.rows[v])){d=!1;break}return d},a.copy=function(s){for(var d=0;d<M;d++)this.rows[d].copy(s.rows[d])},a.isEmpty=function(){for(var s=!0,d=0;d<M;d++)if(!this.rows[d].isEmpty()){s=!1;break}return s},a.backSpace=function(){var s=this.rows[this.currRow];s.backSpace()},a.clearToEndOfRow=function(){var s=this.rows[this.currRow];s.clearToEndOfRow()},a.insertChar=function(s){var d=this.rows[this.currRow];d.insertChar(s)},a.setPen=function(s){var d=this.rows[this.currRow];d.setPenStyles(s)},a.moveCursor=function(s){var d=this.rows[this.currRow];d.moveCursor(s)},a.setCursor=function(s){this.logger.log(E.INFO,"setCursor: "+s);var d=this.rows[this.currRow];d.setCursor(s)},a.setPAC=function(s){this.logger.log(E.INFO,"pacData = "+JSON.stringify(s));var d=s.row-1;if(this.nrRollUpRows&&d<this.nrRollUpRows-1&&(d=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==d){for(var v=0;v<M;v++)this.rows[v].clear();var S=this.currRow+1-this.nrRollUpRows,x=this.lastOutputScreen;if(x){var P=x.rows[S].cueStartTime,B=this.logger.time;if(P&&B!==null&&P<B)for(var k=0;k<this.nrRollUpRows;k++)this.rows[d-this.nrRollUpRows+k+1].copy(x.rows[S+k])}}this.currRow=d;var U=this.rows[this.currRow];if(s.indent!==null){var W=s.indent,G=Math.max(W-1,0);U.setCursor(s.indent),s.color=U.chars[G].penState.foreground}var z={foreground:s.color,underline:s.underline,italics:s.italics,background:"black",flash:!1};this.setPen(z)},a.setBkgData=function(s){this.logger.log(E.INFO,"bkgData = "+JSON.stringify(s)),this.backSpace(),this.setPen(s),this.insertChar(32)},a.setRollUpRows=function(s){this.nrRollUpRows=s},a.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(E.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(E.TEXT,this.getDisplayText());var s=this.currRow+1-this.nrRollUpRows,d=this.rows.splice(s,1)[0];d.clear(),this.rows.splice(this.currRow,0,d),this.logger.log(E.INFO,"Rolling up")},a.getDisplayText=function(s){s=s||!1;for(var d=[],v="",S=-1,x=0;x<M;x++){var P=this.rows[x].getTextString();P&&(S=x+1,s?d.push("Row "+S+": '"+P+"'"):d.push(P.trim()))}return d.length>0&&(s?v="["+d.join(" | ")+"]":v=d.join(`
20
+ `)),v},a.getTextAndFormat=function(){return this.rows},t}(),g=function(){function t(u,s,d){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=u,this.outputFilter=s,this.mode=null,this.verbose=0,this.displayedMemory=new h(d),this.nonDisplayedMemory=new h(d),this.lastOutputScreen=new h(d),this.currRollUpRow=this.displayedMemory.rows[M-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=d}var a=t.prototype;return a.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[M-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},a.getHandler=function(){return this.outputFilter},a.setHandler=function(s){this.outputFilter=s},a.setPAC=function(s){this.writeScreen.setPAC(s)},a.setBkgData=function(s){this.writeScreen.setBkgData(s)},a.setMode=function(s){s!==this.mode&&(this.mode=s,this.logger.log(E.INFO,"MODE="+s),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=s)},a.insertChars=function(s){for(var d=0;d<s.length;d++)this.writeScreen.insertChar(s[d]);var v=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(E.INFO,v+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(E.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},a.ccRCL=function(){this.logger.log(E.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},a.ccBS=function(){this.logger.log(E.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},a.ccAOF=function(){},a.ccAON=function(){},a.ccDER=function(){this.logger.log(E.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},a.ccRU=function(s){this.logger.log(E.INFO,"RU("+s+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(s)},a.ccFON=function(){this.logger.log(E.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},a.ccRDC=function(){this.logger.log(E.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},a.ccTR=function(){this.logger.log(E.INFO,"TR"),this.setMode("MODE_TEXT")},a.ccRTD=function(){this.logger.log(E.INFO,"RTD"),this.setMode("MODE_TEXT")},a.ccEDM=function(){this.logger.log(E.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},a.ccCR=function(){this.logger.log(E.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},a.ccENM=function(){this.logger.log(E.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},a.ccEOC=function(){if(this.logger.log(E.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var s=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=s,this.writeScreen=this.nonDisplayedMemory,this.logger.log(E.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},a.ccTO=function(s){this.logger.log(E.INFO,"TO("+s+") - Tab Offset"),this.writeScreen.moveCursor(s)},a.ccMIDROW=function(s){var d={flash:!1};if(d.underline=s%2===1,d.italics=s>=46,d.italics)d.foreground="white";else{var v=Math.floor(s/2)-16,S=["white","green","blue","cyan","red","yellow","magenta"];d.foreground=S[v]}this.logger.log(E.INFO,"MIDROW: "+JSON.stringify(d)),this.writeScreen.setPen(d)},a.outputDataUpdate=function(s){s===void 0&&(s=!1);var d=this.logger.time;d!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=d:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,d,this.lastOutputScreen),s&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:d),this.lastOutputScreen.copy(this.displayedMemory))},a.cueSplitAtTime=function(s){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,s,this.displayedMemory),this.cueStartTime=s))},t}(),i=function(){function t(u,s,d){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var v=new m;this.channels=[null,new g(u,s,v),new g(u+1,d,v)],this.cmdHistory=c(),this.logger=v}var a=t.prototype;return a.getHandler=function(s){return this.channels[s].getHandler()},a.setHandler=function(s,d){this.channels[s].setHandler(d)},a.addData=function(s,d){var v,S,x,P=!1;this.logger.time=s;for(var B=0;B<d.length;B+=2)if(S=d[B]&127,x=d[B+1]&127,!(S===0&&x===0)){if(this.logger.log(E.DATA,"["+p([d[B],d[B+1]])+"] -> ("+p([S,x])+")"),v=this.parseCmd(S,x),v||(v=this.parseMidrow(S,x)),v||(v=this.parsePAC(S,x)),v||(v=this.parseBackgroundAttributes(S,x)),!v&&(P=this.parseChars(S,x),P)){var k=this.currentChannel;if(k&&k>0){var U=this.channels[k];U.insertChars(P)}else this.logger.log(E.WARNING,"No channel found yet. TEXT-MODE?")}!v&&!P&&this.logger.log(E.WARNING,"Couldn't parse cleaned data "+p([S,x])+" orig: "+p([d[B],d[B+1]]))}},a.parseCmd=function(s,d){var v=this.cmdHistory,S=(s===20||s===28||s===21||s===29)&&d>=32&&d<=47,x=(s===23||s===31)&&d>=33&&d<=35;if(!(S||x))return!1;if(l(s,d,v))return r(null,null,v),this.logger.log(E.DEBUG,"Repeated command ("+p([s,d])+") is dropped"),!0;var P=s===20||s===21||s===23?1:2,B=this.channels[P];return s===20||s===21||s===28||s===29?d===32?B.ccRCL():d===33?B.ccBS():d===34?B.ccAOF():d===35?B.ccAON():d===36?B.ccDER():d===37?B.ccRU(2):d===38?B.ccRU(3):d===39?B.ccRU(4):d===40?B.ccFON():d===41?B.ccRDC():d===42?B.ccTR():d===43?B.ccRTD():d===44?B.ccEDM():d===45?B.ccCR():d===46?B.ccENM():d===47&&B.ccEOC():B.ccTO(d-32),r(s,d,v),this.currentChannel=P,!0},a.parseMidrow=function(s,d){var v=0;if((s===17||s===25)&&d>=32&&d<=47){if(s===17?v=1:v=2,v!==this.currentChannel)return this.logger.log(E.ERROR,"Mismatch channel in midrow parsing"),!1;var S=this.channels[v];return S?(S.ccMIDROW(d),this.logger.log(E.DEBUG,"MIDROW ("+p([s,d])+")"),!0):!1}return!1},a.parsePAC=function(s,d){var v,S=this.cmdHistory,x=(s>=17&&s<=23||s>=25&&s<=31)&&d>=64&&d<=127,P=(s===16||s===24)&&d>=64&&d<=95;if(!(x||P))return!1;if(l(s,d,S))return r(null,null,S),!0;var B=s<=23?1:2;d>=64&&d<=95?v=B===1?O[s]:y[s]:v=B===1?_[s]:T[s];var k=this.channels[B];return k?(k.setPAC(this.interpretPAC(v,d)),r(s,d,S),this.currentChannel=B,!0):!1},a.interpretPAC=function(s,d){var v,S={color:null,italics:!1,indent:null,underline:!1,row:s};return d>95?v=d-96:v=d-64,S.underline=(v&1)===1,v<=13?S.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(v/2)]:v<=15?(S.italics=!0,S.color="white"):S.indent=Math.floor((v-16)/2)*4,S},a.parseChars=function(s,d){var v,S=null,x=null;if(s>=25?(v=2,x=s-8):(v=1,x=s),x>=17&&x<=19){var P;x===17?P=d+80:x===18?P=d+112:P=d+144,this.logger.log(E.INFO,"Special char '"+D(P)+"' in channel "+v),S=[P]}else s>=32&&s<=127&&(S=d===0?[s]:[s,d]);if(S){var B=p(S);this.logger.log(E.DEBUG,"Char codes = "+B.join(",")),r(s,d,this.cmdHistory)}return S},a.parseBackgroundAttributes=function(s,d){var v=(s===16||s===24)&&d>=32&&d<=47,S=(s===23||s===31)&&d>=45&&d<=47;if(!(v||S))return!1;var x,P={};s===16||s===24?(x=Math.floor((d-32)/2),P.background=A[x],d%2===1&&(P.background=P.background+"_semi")):d===45?P.background="transparent":(P.foreground="black",d===47&&(P.underline=!0));var B=s<=23?1:2,k=this.channels[B];return k.setBkgData(P),r(s,d,this.cmdHistory),!0},a.reset=function(){for(var s=0;s<Object.keys(this.channels).length;s++){var d=this.channels[s];d&&d.reset()}this.cmdHistory=c()},a.cueSplitAtTime=function(s){for(var d=0;d<this.channels.length;d++){var v=this.channels[d];v&&v.cueSplitAtTime(s)}},t}();function r(t,a,u){u.a=t,u.b=a}function l(t,a,u){return u.a===t&&u.b===a}function c(){return{a:null,b:null}}b.default=i},"./src/utils/codecs.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"isCodecType",function(){return L}),n.d(b,"isCodecSupportedInMp4",function(){return D});var I={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,av01:!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},text:{stpp:!0,wvtt:!0}};function L(M,R){var O=I[R];return!!O&&O[M.slice(0,4)]===!0}function D(M,R){return MediaSource.isTypeSupported((R||"video")+'/mp4;codecs="'+M+'"')}},"./src/utils/cues.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/utils/vttparser.ts"),L=n("./src/utils/webvtt-parser.ts"),D=n("./src/utils/texttrack-utils.ts"),M=/\s/,R={newCue:function(_,y,T,A){for(var E=[],m,p,f,e,o,h=self.VTTCue||self.TextTrackCue,g=0;g<A.rows.length;g++)if(m=A.rows[g],f=!0,e=0,o="",!m.isEmpty()){for(var i=0;i<m.chars.length;i++)M.test(m.chars[i].uchar)&&f?e++:(o+=m.chars[i].uchar,f=!1);m.cueStartTime=y,y===T&&(T+=1e-4),e>=16?e--:e++;var r=Object(I.fixLineBreaks)(o.trim()),l=Object(L.generateCueId)(y,T,r);(!_||!_.cues||!_.cues.getCueById(l))&&(p=new h(y,T,r),p.id=l,p.line=g+1,p.align="left",p.position=10+Math.min(80,Math.floor(e*8/32)*10),E.push(p))}return _&&E.length&&(E.sort(function(c,t){return c.line==="auto"||t.line==="auto"?0:c.line>8&&t.line>8?t.line-c.line:c.line-t.line}),E.forEach(function(c){return Object(D.addCueToTrack)(_,c)})),E}};b.default=R},"./src/utils/discontinuities.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"findFirstFragWithCC",function(){return M}),n.d(b,"shouldAlignOnDiscontinuities",function(){return R}),n.d(b,"findDiscontinuousReferenceFrag",function(){return O}),n.d(b,"adjustSlidingStart",function(){return y}),n.d(b,"alignStream",function(){return T}),n.d(b,"alignPDT",function(){return E}),n.d(b,"alignFragmentByPDTDelta",function(){return m}),n.d(b,"alignMediaPlaylistByPDT",function(){return p});var I=n("./src/polyfills/number.ts"),L=n("./src/utils/logger.ts"),D=n("./src/controller/level-helper.ts");function M(f,e){for(var o=null,h=0,g=f.length;h<g;h++){var i=f[h];if(i&&i.cc===e){o=i;break}}return o}function R(f,e,o){return!!(e.details&&(o.endCC>o.startCC||f&&f.cc<o.startCC))}function O(f,e){var o=f.fragments,h=e.fragments;if(!h.length||!o.length){L.logger.log("No fragments to align");return}var g=M(o,h[0].cc);if(!g||g&&!g.startPTS){L.logger.log("No frag in previous level to align on");return}return g}function _(f,e){if(f){var o=f.start+e;f.start=f.startPTS=o,f.endPTS=o+f.duration}}function y(f,e){for(var o=e.fragments,h=0,g=o.length;h<g;h++)_(o[h],f);e.fragmentHint&&_(e.fragmentHint,f),e.alignedSliding=!0}function T(f,e,o){!e||(A(f,o,e),!o.alignedSliding&&e.details&&E(o,e.details),!o.alignedSliding&&e.details&&!o.skippedSegments&&Object(D.adjustSliding)(e.details,o))}function A(f,e,o){if(R(f,o,e)){var h=O(o.details,e);h&&Object(I.isFiniteNumber)(h.start)&&(L.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),y(h.start,e))}}function E(f,e){if(!(!e.fragments.length||!f.hasProgramDateTime||!e.hasProgramDateTime)){var o=e.fragments[0].programDateTime,h=f.fragments[0].programDateTime,g=(h-o)/1e3+e.fragments[0].start;g&&Object(I.isFiniteNumber)(g)&&(L.logger.log("Adjusting PTS using programDateTime delta "+(h-o)+"ms, sliding:"+g.toFixed(3)+" "+f.url+" "),y(g,f))}}function m(f,e){var o=f.programDateTime;if(!!o){var h=(o-e)/1e3;f.start=f.startPTS=h,f.endPTS=h+f.duration}}function p(f,e){if(!(!e.fragments.length||!f.hasProgramDateTime||!e.hasProgramDateTime)){var o=e.fragments[0].programDateTime,h=e.fragments[0].start,g=o-h*1e3;f.fragments.forEach(function(i){m(i,g)}),f.fragmentHint&&m(f.fragmentHint,g),f.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/utils/ewma.ts"),L=function(){function D(R,O,_){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=_,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new I.default(R),this.fast_=new I.default(O)}var M=D.prototype;return M.update=function(O,_){var y=this.slow_,T=this.fast_;this.slow_.halfLife!==O&&(this.slow_=new I.default(O,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new I.default(_,T.getEstimate(),T.getTotalWeight()))},M.sample=function(O,_){O=Math.max(O,this.minDelayMs_);var y=8*_,T=O/1e3,A=y/T;this.fast_.sample(T,A),this.slow_.sample(T,A)},M.canEstimate=function(){var O=this.fast_;return O&&O.getTotalWeight()>=this.minWeight_},M.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},M.destroy=function(){},D}();b.default=L},"./src/utils/ewma.ts":function(K,b,n){"use strict";n.r(b);var I=function(){function L(M,R,O){R===void 0&&(R=0),O===void 0&&(O=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=M,this.alpha_=M?Math.exp(Math.log(.5)/M):0,this.estimate_=R,this.totalWeight_=O}var D=L.prototype;return D.sample=function(R,O){var _=Math.pow(this.alpha_,R);this.estimate_=O*(1-_)+_*this.estimate_,this.totalWeight_+=R},D.getTotalWeight=function(){return this.totalWeight_},D.getEstimate=function(){if(this.alpha_){var R=1-Math.pow(this.alpha_,this.totalWeight_);if(R)return this.estimate_/R}return this.estimate_},L}();b.default=I},"./src/utils/fetch-loader.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"fetchSupported",function(){return m});var I=n("./src/polyfills/number.ts"),L=n("./src/loader/load-stats.ts"),D=n("./src/demux/chunk-cache.ts");function M(h,g){h.prototype=Object.create(g.prototype),h.prototype.constructor=h,T(h,g)}function R(h){var g=typeof Map=="function"?new Map:void 0;return R=function(r){if(r===null||!y(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof g!="undefined"){if(g.has(r))return g.get(r);g.set(r,l)}function l(){return O(r,arguments,A(this).constructor)}return l.prototype=Object.create(r.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),T(l,r)},R(h)}function O(h,g,i){return _()?O=Reflect.construct.bind():O=function(l,c,t){var a=[null];a.push.apply(a,c);var u=Function.bind.apply(l,a),s=new u;return t&&T(s,t.prototype),s},O.apply(null,arguments)}function _(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function y(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function T(h,g){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,l){return r.__proto__=l,r},T(h,g)}function A(h){return A=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},A(h)}function E(){return E=Object.assign?Object.assign.bind():function(h){for(var g=1;g<arguments.length;g++){var i=arguments[g];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(h[r]=i[r])}return h},E.apply(this,arguments)}function m(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var p=function(){function h(i){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=i.fetchSetup||e,this.controller=new self.AbortController,this.stats=new L.LoadStats}var g=h.prototype;return g.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},g.abortInternal=function(){var r=this.response;(!r||!r.ok)&&(this.stats.aborted=!0,this.controller.abort())},g.abort=function(){var r;this.abortInternal(),(r=this.callbacks)!==null&&r!==void 0&&r.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},g.load=function(r,l,c){var t=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var u=f(r,this.controller.signal),s=c.onProgress,d=r.responseType==="arraybuffer",v=d?"byteLength":"length";this.context=r,this.config=l,this.callbacks=c,this.request=this.fetchSetup(r,u),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){t.abortInternal(),c.onTimeout(a,r,t.response)},l.timeout),self.fetch(this.request).then(function(S){if(t.response=t.loader=S,!S.ok){var x=S.status,P=S.statusText;throw new o(P||"fetch, bad network response",x,S)}return a.loading.first=Math.max(self.performance.now(),a.loading.start),a.total=parseInt(S.headers.get("Content-Length")||"0"),s&&Object(I.isFiniteNumber)(l.highWaterMark)?t.loadProgressively(S,a,r,l.highWaterMark,s):d?S.arrayBuffer():S.text()}).then(function(S){var x=t.response;self.clearTimeout(t.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first),a.loaded=a.total=S[v];var P={url:x.url,data:S};s&&!Object(I.isFiniteNumber)(l.highWaterMark)&&s(a,r,S,x),c.onSuccess(P,a,r,x)}).catch(function(S){if(self.clearTimeout(t.requestTimeout),!a.aborted){var x=S&&S.code||0,P=S?S.message:null;c.onError({code:x,text:P},r,S?S.details:null)}})},g.getCacheAge=function(){var r=null;if(this.response){var l=this.response.headers.get("age");r=l?parseFloat(l):null}return r},g.loadProgressively=function(r,l,c,t,a){t===void 0&&(t=0);var u=new D.default,s=r.body.getReader(),d=function v(){return s.read().then(function(S){if(S.done)return u.dataLength&&a(l,c,u.flush(),r),Promise.resolve(new ArrayBuffer(0));var x=S.value,P=x.length;return l.loaded+=P,P<t||u.dataLength?(u.push(x),u.dataLength>=t&&a(l,c,u.flush(),r)):a(l,c,x,r),v()}).catch(function(){return Promise.reject()})};return d()},h}();function f(h,g){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:g,headers:new self.Headers(E({},h.headers))};return h.rangeEnd&&i.headers.set("Range","bytes="+h.rangeStart+"-"+String(h.rangeEnd-1)),i}function e(h,g){return new self.Request(h.url,g)}var o=function(h){M(g,h);function g(i,r,l){var c;return c=h.call(this,i)||this,c.code=void 0,c.details=void 0,c.code=r,c.details=l,c}return g}(R(Error));b.default=p},"./src/utils/imsc1-ttml-parser.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"IMSC1_CODEC",function(){return y}),n.d(b,"parseIMSC1",function(){return m});var I=n("./src/utils/mp4-tools.ts"),L=n("./src/utils/vttparser.ts"),D=n("./src/utils/vttcue.ts"),M=n("./src/demux/id3.ts"),R=n("./src/utils/timescale-conversion.ts"),O=n("./src/utils/webvtt-parser.ts");function _(){return _=Object.assign?Object.assign.bind():function(t){for(var a=1;a<arguments.length;a++){var u=arguments[a];for(var s in u)Object.prototype.hasOwnProperty.call(u,s)&&(t[s]=u[s])}return t},_.apply(this,arguments)}var y="stpp.ttml.im1t",T=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,A=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,E={left:"start",center:"center",right:"end",start:"start",end:"end"};function m(t,a,u,s,d){var v=Object(I.findBox)(new Uint8Array(t),["mdat"]);if(v.length===0){d(new Error("Could not parse IMSC1 mdat"));return}var S=v.map(function(P){return Object(M.utf8ArrayToStr)(P)}),x=Object(R.toTimescaleFromScale)(a,1,u);try{S.forEach(function(P){return s(p(P,x))})}catch(P){d(P)}}function p(t,a){var u=new DOMParser,s=u.parseFromString(t,"text/xml"),d=s.getElementsByTagName("tt")[0];if(!d)throw new Error("Invalid ttml");var v={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},S=Object.keys(v).reduce(function(U,W){return U[W]=d.getAttribute("ttp:"+W)||v[W],U},{}),x=d.getAttribute("xml:space")!=="preserve",P=e(f(d,"styling","style")),B=e(f(d,"layout","region")),k=f(d,"body","[begin]");return[].map.call(k,function(U){var W=o(U,x);if(!W||!U.hasAttribute("begin"))return null;var G=r(U.getAttribute("begin"),S),z=r(U.getAttribute("dur"),S),Y=r(U.getAttribute("end"),S);if(G===null)throw i(U);if(Y===null){if(z===null)throw i(U);Y=G+z}var J=new D.default(G-a,Y-a,W);J.id=Object(O.generateCueId)(J.startTime,J.endTime,J.text);var ee=B[U.getAttribute("region")],X=P[U.getAttribute("style")];J.position=10,J.size=80;var q=h(ee,X,P),ie=q.textAlign;if(ie){var ae=E[ie];ae&&(J.lineAlign=ae),J.align=ie}return _(J,q),J}).filter(function(U){return U!==null})}function f(t,a,u){var s=t.getElementsByTagName(a)[0];return s?[].slice.call(s.querySelectorAll(u)):[]}function e(t){return t.reduce(function(a,u){var s=u.getAttribute("xml:id");return s&&(a[s]=u),a},{})}function o(t,a){return[].slice.call(t.childNodes).reduce(function(u,s,d){var v;return s.nodeName==="br"&&d?u+`
21
+ `:(v=s.childNodes)!==null&&v!==void 0&&v.length?o(s,a):a?u+s.textContent.trim().replace(/\s+/g," "):u+s.textContent},"")}function h(t,a,u){var s="http://www.w3.org/ns/ttml#styling",d=null,v=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],S=t!=null&&t.hasAttribute("style")?t.getAttribute("style"):null;return S&&u.hasOwnProperty(S)&&(d=u[S]),v.reduce(function(x,P){var B=g(a,s,P)||g(t,s,P)||g(d,s,P);return B&&(x[P]=B),x},{})}function g(t,a,u){return t&&t.hasAttributeNS(a,u)?t.getAttributeNS(a,u):null}function i(t){return new Error("Could not parse ttml timestamp "+t)}function r(t,a){if(!t)return null;var u=Object(L.parseTimeStamp)(t);return u===null&&(T.test(t)?u=l(t,a):A.test(t)&&(u=c(t,a))),u}function l(t,a){var u=T.exec(t),s=(u[4]|0)+(u[5]|0)/a.subFrameRate;return(u[1]|0)*3600+(u[2]|0)*60+(u[3]|0)+s/a.frameRate}function c(t,a){var u=A.exec(t),s=Number(u[1]),d=u[2];switch(d){case"h":return s*3600;case"m":return s*60;case"ms":return s*1e3;case"f":return s/a.frameRate;case"t":return s/a.tickRate}return s}},"./src/utils/logger.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"enableLogs",function(){return O}),n.d(b,"logger",function(){return _});var I=function(){},L={trace:I,debug:I,log:I,warn:I,info:I,error:I},D=L;function M(y){var T=self.console[y];return T?T.bind(self.console,"["+y+"] >"):I}function R(y){for(var T=arguments.length,A=new Array(T>1?T-1:0),E=1;E<T;E++)A[E-1]=arguments[E];A.forEach(function(m){D[m]=y[m]?y[m].bind(y):M(m)})}function O(y){if(self.console&&y===!0||typeof y=="object"){R(y,"debug","log","info","warn","error");try{D.log()}catch{D=L}}else D=L}var _=D},"./src/utils/mediakeys-helper.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"KeySystems",function(){return I}),n.d(b,"requestMediaKeySystemAccess",function(){return L});var I;(function(D){D.WIDEVINE="com.widevine.alpha",D.PLAYREADY="com.microsoft.playready"})(I||(I={}));var L=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"getMediaSource",function(){return I});function I(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"RemuxerTrackIdConfig",function(){return O}),n.d(b,"bin2str",function(){return _}),n.d(b,"readUint16",function(){return y}),n.d(b,"readUint32",function(){return T}),n.d(b,"readSint32",function(){return A}),n.d(b,"writeUint32",function(){return E}),n.d(b,"findBox",function(){return m}),n.d(b,"parseSegmentIndex",function(){return p}),n.d(b,"parseInitSegment",function(){return f}),n.d(b,"getStartDTS",function(){return e}),n.d(b,"getDuration",function(){return o}),n.d(b,"computeRawDurationFromSamples",function(){return h}),n.d(b,"offsetStartDTS",function(){return g}),n.d(b,"segmentValidRange",function(){return i}),n.d(b,"appendUint8Array",function(){return r}),n.d(b,"parseSamples",function(){return l}),n.d(b,"parseSEIMessageFromNALu",function(){return a}),n.d(b,"parseEmsg",function(){return s});var I=n("./src/utils/typed-array.ts"),L=n("./src/loader/fragment.ts"),D=n("./src/demux/id3.ts"),M=Math.pow(2,32)-1,R=[].push,O={video:1,audio:2,id3:3,text:4};function _(d){return String.fromCharCode.apply(null,d)}function y(d,v){var S=d[v]<<8|d[v+1];return S<0?65536+S:S}function T(d,v){var S=A(d,v);return S<0?4294967296+S:S}function A(d,v){return d[v]<<24|d[v+1]<<16|d[v+2]<<8|d[v+3]}function E(d,v,S){d[v]=S>>24,d[v+1]=S>>16&255,d[v+2]=S>>8&255,d[v+3]=S&255}function m(d,v){var S=[];if(!v.length)return S;for(var x=d.byteLength,P=0;P<x;){var B=T(d,P),k=_(d.subarray(P+4,P+8)),U=B>1?P+B:x;if(k===v[0])if(v.length===1)S.push(d.subarray(P+8,U));else{var W=m(d.subarray(P+8,U),v.slice(1));W.length&&R.apply(S,W)}P=U}return S}function p(d){var v=[],S=d[0],x=8,P=T(d,x);x+=4;var B=0,k=0;S===0?x+=8:x+=16,x+=2;var U=d.length+k,W=y(d,x);x+=2;for(var G=0;G<W;G++){var z=x,Y=T(d,z);z+=4;var J=Y&2147483647,ee=(Y&2147483648)>>>31;if(ee===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var X=T(d,z);z+=4,v.push({referenceSize:J,subsegmentDuration:X,info:{duration:X/P,start:U,end:U+J-1}}),U+=J,z+=4,x=z}return{earliestPresentationTime:B,timescale:P,version:S,referencesCount:W,references:v}}function f(d){for(var v=[],S=m(d,["moov","trak"]),x=0;x<S.length;x++){var P=S[x],B=m(P,["tkhd"])[0];if(B){var k=B[0],U=k===0?12:20,W=T(B,U),G=m(P,["mdia","mdhd"])[0];if(G){k=G[0],U=k===0?12:20;var z=T(G,U),Y=m(P,["mdia","hdlr"])[0];if(Y){var J=_(Y.subarray(8,12)),ee={soun:L.ElementaryStreamTypes.AUDIO,vide:L.ElementaryStreamTypes.VIDEO}[J];if(ee){var X=m(P,["mdia","minf","stbl","stsd"])[0],q=void 0;X&&(q=_(X.subarray(12,16))),v[W]={timescale:z,type:ee},v[ee]={timescale:z,id:W,codec:q}}}}}}var ie=m(d,["moov","mvex","trex"]);return ie.forEach(function(ae){var te=T(ae,4),oe=v[te];oe&&(oe.default={duration:T(ae,12),flags:T(ae,20)})}),v}function e(d,v){return m(v,["moof","traf"]).reduce(function(S,x){var P=m(x,["tfdt"])[0],B=P[0],k=m(x,["tfhd"]).reduce(function(U,W){var G=T(W,4),z=d[G];if(z){var Y=T(P,4);B===1&&(Y*=Math.pow(2,32),Y+=T(P,8));var J=z.timescale||9e4,ee=Y/J;if(isFinite(ee)&&(U===null||ee<U))return ee}return U},null);return k!==null&&isFinite(k)&&(S===null||k<S)?k:S},null)||0}function o(d,v){for(var S=0,x=0,P=0,B=m(d,["moof","traf"]),k=0;k<B.length;k++){var U=B[k],W=m(U,["tfhd"])[0],G=T(W,4),z=v[G];if(!!z){var Y=z.default,J=T(W,0)|(Y==null?void 0:Y.flags),ee=Y==null?void 0:Y.duration;J&8&&(J&2?ee=T(W,12):ee=T(W,8));for(var X=z.timescale||9e4,q=m(U,["trun"]),ie=0;ie<q.length;ie++){if(S=h(q[ie]),!S&&ee){var ae=T(q[ie],4);S=ee*ae}z.type===L.ElementaryStreamTypes.VIDEO?x+=S/X:z.type===L.ElementaryStreamTypes.AUDIO&&(P+=S/X)}}}if(x===0&&P===0){for(var te=0,oe=m(d,["sidx"]),ue=0;ue<oe.length;ue++){var re=p(oe[ue]);re!=null&&re.references&&(te+=re.references.reduce(function(he,ve){return he+ve.info.duration||0},0))}return te}return x||P}function h(d){var v=T(d,0),S=8;v&1&&(S+=4),v&4&&(S+=4);for(var x=0,P=T(d,4),B=0;B<P;B++){if(v&256){var k=T(d,S);x+=k,S+=4}v&512&&(S+=4),v&1024&&(S+=4),v&2048&&(S+=4)}return x}function g(d,v,S){m(v,["moof","traf"]).forEach(function(x){m(x,["tfhd"]).forEach(function(P){var B=T(P,4),k=d[B];if(!!k){var U=k.timescale||9e4;m(x,["tfdt"]).forEach(function(W){var G=W[0],z=T(W,4);if(G===0)z-=S*U,z=Math.max(z,0),E(W,4,z);else{z*=Math.pow(2,32),z+=T(W,8),z-=S*U,z=Math.max(z,0);var Y=Math.floor(z/(M+1)),J=Math.floor(z%(M+1));E(W,4,Y),E(W,8,J)}})}})})}function i(d){var v={valid:null,remainder:null},S=m(d,["moof"]);if(S){if(S.length<2)return v.remainder=d,v}else return v;var x=S[S.length-1];return v.valid=Object(I.sliceUint8)(d,0,x.byteOffset-8),v.remainder=Object(I.sliceUint8)(d,x.byteOffset-8),v}function r(d,v){var S=new Uint8Array(d.length+v.length);return S.set(d),S.set(v,d.length),S}function l(d,v){var S=[],x=v.samples,P=v.timescale,B=v.id,k=!1,U=m(x,["moof"]);return U.map(function(W){var G=W.byteOffset-8,z=m(W,["traf"]);z.map(function(Y){var J=m(Y,["tfdt"]).map(function(ee){var X=ee[0],q=T(ee,4);return X===1&&(q*=Math.pow(2,32),q+=T(ee,8)),q/P})[0];return J!==void 0&&(d=J),m(Y,["tfhd"]).map(function(ee){var X=T(ee,4),q=T(ee,0)&16777215,ie=(q&1)!==0,ae=(q&2)!==0,te=(q&8)!==0,oe=0,ue=(q&16)!==0,re=0,he=(q&32)!==0,ve=8;X===B&&(ie&&(ve+=8),ae&&(ve+=4),te&&(oe=T(ee,ve),ve+=4),ue&&(re=T(ee,ve),ve+=4),he&&(ve+=4),v.type==="video"&&(k=c(v.codec)),m(Y,["trun"]).map(function(Se){var Me=Se[0],Oe=T(Se,0)&16777215,Ne=(Oe&1)!==0,Pe=0,Ke=(Oe&4)!==0,ge=(Oe&256)!==0,ke=0,je=(Oe&512)!==0,He=0,We=(Oe&1024)!==0,Ye=(Oe&2048)!==0,Ge=0,nt=T(Se,4),we=8;Ne&&(Pe=T(Se,we),we+=4),Ke&&(we+=4);for(var Be=Pe+G,$e=0;$e<nt;$e++){if(ge?(ke=T(Se,we),we+=4):ke=oe,je?(He=T(Se,we),we+=4):He=re,We&&(we+=4),Ye&&(Me===0?Ge=T(Se,we):Ge=A(Se,we),we+=4),v.type===L.ElementaryStreamTypes.VIDEO)for(var Ue=0;Ue<He;){var Ie=T(x,Be);Be+=4;var ot=x[Be]&31;if(t(k,ot)){var ze=x.subarray(Be,Be+Ie);a(ze,d+Ge/P,S)}Be+=Ie,Ue+=Ie+4}d+=ke/P}}))})})}),S}function c(d){if(!d)return!1;var v=d.indexOf("."),S=v<0?d:d.substring(0,v);return S==="hvc1"||S==="hev1"||S==="dvh1"||S==="dvhe"}function t(d,v){return d?v===39||v===40:v===6}function a(d,v,S){var x=u(d),P=0;P++;for(var B=0,k=0,U=!1,W=0;P<x.length;){B=0;do{if(P>=x.length)break;W=x[P++],B+=W}while(W===255);k=0;do{if(P>=x.length)break;W=x[P++],k+=W}while(W===255);var G=x.length-P;if(!U&&B===4&&P<x.length){U=!0;var z=x[P++];if(z===181){var Y=y(x,P);if(P+=2,Y===49){var J=T(x,P);if(P+=4,J===1195456820){var ee=x[P++];if(ee===3){var X=x[P++],q=31&X,ie=64&X,ae=ie?2+q*3:0,te=new Uint8Array(ae);if(ie){te[0]=X;for(var oe=1;oe<ae;oe++)te[oe]=x[P++]}S.push({type:ee,payloadType:B,pts:v,bytes:te})}}}}}else if(B===5&&k<G){if(U=!0,k>16){for(var ue=[],re=0;re<16;re++){var he=x[P++].toString(16);ue.push(he.length==1?"0"+he:he),(re===3||re===5||re===7||re===9)&&ue.push("-")}for(var ve=k-16,Se=new Uint8Array(ve),Me=0;Me<ve;Me++)Se[Me]=x[P++];S.push({payloadType:B,pts:v,uuid:ue.join(""),userData:Object(D.utf8ArrayToStr)(Se),userDataBytes:Se})}}else if(k<G)P+=k;else if(k>G)break}}function u(d){for(var v=d.byteLength,S=[],x=1;x<v-2;)d[x]===0&&d[x+1]===0&&d[x+2]===3?(S.push(x+2),x+=2):x++;if(S.length===0)return d;var P=v-S.length,B=new Uint8Array(P),k=0;for(x=0;x<P;k++,x++)k===S[0]&&(k++,S.shift()),B[x]=d[k];return B}function s(d){var v=d[0],S="",x="",P=0,B=0,k=0,U=0,W=0,G=0;if(v===0){for(;_(d.subarray(G,G+1))!=="\0";)S+=_(d.subarray(G,G+1)),G+=1;for(S+=_(d.subarray(G,G+1)),G+=1;_(d.subarray(G,G+1))!=="\0";)x+=_(d.subarray(G,G+1)),G+=1;x+=_(d.subarray(G,G+1)),G+=1,P=T(d,12),B=T(d,16),U=T(d,20),W=T(d,24),G=28}else if(v===1){G+=4,P=T(d,G),G+=4;var z=T(d,G);G+=4;var Y=T(d,G);for(G+=4,k=Math.pow(2,32)*z+Y,Number.isSafeInteger(k)||(k=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),U=T(d,G),G+=4,W=T(d,G),G+=4;_(d.subarray(G,G+1))!=="\0";)S+=_(d.subarray(G,G+1)),G+=1;for(S+=_(d.subarray(G,G+1)),G+=1;_(d.subarray(G,G+1))!=="\0";)x+=_(d.subarray(G,G+1)),G+=1;x+=_(d.subarray(G,G+1)),G+=1}var J=d.subarray(G,d.byteLength);return{schemeIdUri:S,value:x,timeScale:P,presentationTime:k,presentationTimeDelta:B,eventDuration:U,id:W,payload:J}}},"./src/utils/output-filter.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"default",function(){return I});var I=function(){function L(M,R){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=M,this.trackName=R}var D=L.prototype;return D.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},D.newCue=function(R,O,_){(this.startTime===null||this.startTime>R)&&(this.startTime=R),this.endTime=O,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},D.reset=function(){this.cueRanges=[],this.startTime=null},L}()},"./src/utils/texttrack-utils.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"sendAddTrackEvent",function(){return L}),n.d(b,"addCueToTrack",function(){return D}),n.d(b,"clearCurrentCues",function(){return M}),n.d(b,"removeCuesInRange",function(){return R}),n.d(b,"getCuesInRange",function(){return _});var I=n("./src/utils/logger.ts");function L(y,T){var A;try{A=new Event("addtrack")}catch{A=document.createEvent("Event"),A.initEvent("addtrack",!1,!1)}A.track=y,T.dispatchEvent(A)}function D(y,T){var A=y.mode;if(A==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(T.id))try{if(y.addCue(T),!y.cues.getCueById(T.id))throw new Error("addCue is failed for: "+T)}catch(m){I.logger.debug("[texttrack-utils]: "+m);var E=new self.TextTrackCue(T.startTime,T.endTime,T.text);E.id=T.id,y.addCue(E)}A==="disabled"&&(y.mode=A)}function M(y){var T=y.mode;if(T==="disabled"&&(y.mode="hidden"),y.cues)for(var A=y.cues.length;A--;)y.removeCue(y.cues[A]);T==="disabled"&&(y.mode=T)}function R(y,T,A,E){var m=y.mode;if(m==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var p=_(y.cues,T,A),f=0;f<p.length;f++)(!E||E(p[f]))&&y.removeCue(p[f]);m==="disabled"&&(y.mode=m)}function O(y,T){if(T<y[0].startTime)return 0;var A=y.length-1;if(T>y[A].endTime)return-1;for(var E=0,m=A;E<=m;){var p=Math.floor((m+E)/2);if(T<y[p].startTime)m=p-1;else if(T>y[p].startTime&&E<A)E=p+1;else return p}return y[E].startTime-T<T-y[m].startTime?E:m}function _(y,T,A){var E=[],m=O(y,T);if(m>-1)for(var p=m,f=y.length;p<f;p++){var e=y[p];if(e.startTime>=T&&e.endTime<=A)E.push(e);else if(e.startTime>A)return E}return E}},"./src/utils/time-ranges.ts":function(K,b,n){"use strict";n.r(b);var I={toString:function(D){for(var M="",R=D.length,O=0;O<R;O++)M+="["+D.start(O).toFixed(3)+","+D.end(O).toFixed(3)+"]";return M}};b.default=I},"./src/utils/timescale-conversion.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"toTimescaleFromBase",function(){return L}),n.d(b,"toTimescaleFromScale",function(){return D}),n.d(b,"toMsFromMpegTsClock",function(){return M}),n.d(b,"toMpegTsClockFromTimescale",function(){return R});var I=9e4;function L(O,_,y,T){y===void 0&&(y=1),T===void 0&&(T=!1);var A=O*_*y;return T?Math.round(A):A}function D(O,_,y,T){return y===void 0&&(y=1),T===void 0&&(T=!1),L(O,_,1/y,T)}function M(O,_){return _===void 0&&(_=!1),L(O,1e3,1/I,_)}function R(O,_){return _===void 0&&(_=1),L(O,I,1/_)}},"./src/utils/typed-array.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"sliceUint8",function(){return I});function I(L,D,M){return Uint8Array.prototype.slice?L.slice(D,M):new Uint8Array(Array.prototype.slice.call(L,D,M))}},"./src/utils/vttcue.ts":function(K,b,n){"use strict";n.r(b),b.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var I=["","lr","rl"],L=["start","middle","end","left","right"];function D(y,T){if(typeof T!="string"||!Array.isArray(y))return!1;var A=T.toLowerCase();return~y.indexOf(A)?A:!1}function M(y){return D(I,y)}function R(y){return D(L,y)}function O(y){for(var T=arguments.length,A=new Array(T>1?T-1:0),E=1;E<T;E++)A[E-1]=arguments[E];for(var m=1;m<arguments.length;m++){var p=arguments[m];for(var f in p)y[f]=p[f]}return y}function _(y,T,A){var E=this,m={enumerable:!0};E.hasBeenReset=!1;var p="",f=!1,e=y,o=T,h=A,g=null,i="",r=!0,l="auto",c="start",t=50,a="middle",u=50,s="middle";Object.defineProperty(E,"id",O({},m,{get:function(){return p},set:function(v){p=""+v}})),Object.defineProperty(E,"pauseOnExit",O({},m,{get:function(){return f},set:function(v){f=!!v}})),Object.defineProperty(E,"startTime",O({},m,{get:function(){return e},set:function(v){if(typeof v!="number")throw new TypeError("Start time must be set to a number.");e=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"endTime",O({},m,{get:function(){return o},set:function(v){if(typeof v!="number")throw new TypeError("End time must be set to a number.");o=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"text",O({},m,{get:function(){return h},set:function(v){h=""+v,this.hasBeenReset=!0}})),Object.defineProperty(E,"region",O({},m,{get:function(){return g},set:function(v){g=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"vertical",O({},m,{get:function(){return i},set:function(v){var S=M(v);if(S===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"snapToLines",O({},m,{get:function(){return r},set:function(v){r=!!v,this.hasBeenReset=!0}})),Object.defineProperty(E,"line",O({},m,{get:function(){return l},set:function(v){if(typeof v!="number"&&v!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");l=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"lineAlign",O({},m,{get:function(){return c},set:function(v){var S=R(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");c=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"position",O({},m,{get:function(){return t},set:function(v){if(v<0||v>100)throw new Error("Position must be between 0 and 100.");t=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"positionAlign",O({},m,{get:function(){return a},set:function(v){var S=R(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");a=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"size",O({},m,{get:function(){return u},set:function(v){if(v<0||v>100)throw new Error("Size must be between 0 and 100.");u=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"align",O({},m,{get:function(){return s},set:function(v){var S=R(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");s=S,this.hasBeenReset=!0}})),E.displayState=void 0}return _.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"parseTimeStamp",function(){return D}),n.d(b,"fixLineBreaks",function(){return T}),n.d(b,"VTTParser",function(){return A});var I=n("./src/utils/vttcue.ts"),L=function(){function E(){}var m=E.prototype;return m.decode=function(f,e){if(!f)return"";if(typeof f!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(f))},E}();function D(E){function m(f,e,o,h){return(f|0)*3600+(e|0)*60+(o|0)+parseFloat(h||0)}var p=E.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return p?parseFloat(p[2])>59?m(p[2],p[3],0,p[4]):m(p[1],p[2],p[3],p[4]):null}var M=function(){function E(){this.values=Object.create(null)}var m=E.prototype;return m.set=function(f,e){!this.get(f)&&e!==""&&(this.values[f]=e)},m.get=function(f,e,o){return o?this.has(f)?this.values[f]:e[o]:this.has(f)?this.values[f]:e},m.has=function(f){return f in this.values},m.alt=function(f,e,o){for(var h=0;h<o.length;++h)if(e===o[h]){this.set(f,e);break}},m.integer=function(f,e){/^-?\d+$/.test(e)&&this.set(f,parseInt(e,10))},m.percent=function(f,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var o=parseFloat(e);if(o>=0&&o<=100)return this.set(f,o),!0}return!1},E}();function R(E,m,p,f){var e=f?E.split(f):[E];for(var o in e)if(typeof e[o]=="string"){var h=e[o].split(p);if(h.length===2){var g=h[0],i=h[1];m(g,i)}}}var O=new I.default(0,0,""),_=O.align==="middle"?"middle":"center";function y(E,m,p){var f=E;function e(){var g=D(E);if(g===null)throw new Error("Malformed timestamp: "+f);return E=E.replace(/^[^\sa-zA-Z-]+/,""),g}function o(g,i){var r=new M;R(g,function(t,a){var u;switch(t){case"region":for(var s=p.length-1;s>=0;s--)if(p[s].id===a){r.set(t,p[s].region);break}break;case"vertical":r.alt(t,a,["rl","lr"]);break;case"line":u=a.split(","),r.integer(t,u[0]),r.percent(t,u[0])&&r.set("snapToLines",!1),r.alt(t,u[0],["auto"]),u.length===2&&r.alt("lineAlign",u[1],["start",_,"end"]);break;case"position":u=a.split(","),r.percent(t,u[0]),u.length===2&&r.alt("positionAlign",u[1],["start",_,"end","line-left","line-right","auto"]);break;case"size":r.percent(t,a);break;case"align":r.alt(t,a,["start",_,"end","left","right"]);break}},/:/,/\s/),i.region=r.get("region",null),i.vertical=r.get("vertical","");var l=r.get("line","auto");l==="auto"&&O.line===-1&&(l=-1),i.line=l,i.lineAlign=r.get("lineAlign","start"),i.snapToLines=r.get("snapToLines",!0),i.size=r.get("size",100),i.align=r.get("align",_);var c=r.get("position","auto");c==="auto"&&O.position===50&&(c=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50),i.position=c}function h(){E=E.replace(/^\s+/,"")}if(h(),m.startTime=e(),h(),E.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+f);E=E.slice(3),h(),m.endTime=e(),h(),o(E,m)}function T(E){return E.replace(/<br(?: \/)?>/gi,`
22
+ `)}var A=function(){function E(){this.state="INITIAL",this.buffer="",this.decoder=new L,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var m=E.prototype;return m.parse=function(f){var e=this;f&&(e.buffer+=e.decoder.decode(f,{stream:!0}));function o(){var c=e.buffer,t=0;for(c=T(c);t<c.length&&c[t]!=="\r"&&c[t]!==`
23
23
  `;)++t;var a=c.slice(0,t);return c[t]==="\r"&&++t,c[t]===`
24
- `&&++t,e.buffer=c.slice(t),a}function h(c){R(c,function(t,a){},/:/)}try{var g="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;g=o();var i=g.match(/^()?WEBVTT([ \t].*)?$/);if(!i||!i[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var r=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(r?r=!1:g=o(),e.state){case"HEADER":/:/.test(g)?h(g):g||(e.state="ID");continue;case"NOTE":g||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(g)){e.state="NOTE";break}if(!g)continue;if(e.cue=new P.default(0,0,""),e.state="CUE",g.indexOf("-->")===-1){e.cue.id=g;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{y(g,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{var l=g.indexOf("-->")!==-1;if(!g||l&&(r=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
25
- `),e.cue.text+=g}continue;case"BADCUE":g||(e.state="ID")}}}catch{e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},m.flush=function(){var d=this;try{if((d.cue||d.state==="HEADER")&&(d.buffer+=`
24
+ `&&++t,e.buffer=c.slice(t),a}function h(c){R(c,function(t,a){},/:/)}try{var g="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;g=o();var i=g.match(/^()?WEBVTT([ \t].*)?$/);if(!i||!i[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var r=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(r?r=!1:g=o(),e.state){case"HEADER":/:/.test(g)?h(g):g||(e.state="ID");continue;case"NOTE":g||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(g)){e.state="NOTE";break}if(!g)continue;if(e.cue=new I.default(0,0,""),e.state="CUE",g.indexOf("-->")===-1){e.cue.id=g;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{y(g,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{var l=g.indexOf("-->")!==-1;if(!g||l&&(r=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
25
+ `),e.cue.text+=g}continue;case"BADCUE":g||(e.state="ID")}}}catch{e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},m.flush=function(){var f=this;try{if((f.cue||f.state==="HEADER")&&(f.buffer+=`
26
26
 
27
- `,d.parse()),d.state==="INITIAL"||d.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){d.onparsingerror&&d.onparsingerror(e)}return d.onflush&&d.onflush(),this},E}()},"./src/utils/webvtt-parser.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"generateCueId",function(){return D}),n.d(b,"parseWebVTT",function(){return m});var P=n("./src/polyfills/number.ts"),L=n("./src/utils/vttparser.ts"),A=n("./src/demux/id3.ts"),M=n("./src/utils/timescale-conversion.ts"),R=n("./src/remux/mp4-remuxer.ts"),O=/\r\n|\n\r|\n|\r/g,_=function(d,e,o){return o===void 0&&(o=0),d.slice(o,o+e.length)===e},y=function(d){var e=parseInt(d.slice(-3)),o=parseInt(d.slice(-6,-4)),h=parseInt(d.slice(-9,-7)),g=d.length>9?parseInt(d.substring(0,d.indexOf(":"))):0;if(!Object(P.isFiniteNumber)(e)||!Object(P.isFiniteNumber)(o)||!Object(P.isFiniteNumber)(h)||!Object(P.isFiniteNumber)(g))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+d);return e+=1e3*o,e+=60*1e3*h,e+=60*60*1e3*g,e},T=function(d){for(var e=5381,o=d.length;o;)e=e*33^d.charCodeAt(--o);return(e>>>0).toString()};function D(p,d,e){return T(p.toString())+T(d.toString())+T(e)}var E=function(d,e,o){var h=d[e],g=d[h.prevCC];if(!g||!g.new&&h.new){d.ccOffset=d.presentationOffset=h.start,h.new=!1;return}for(;(i=g)!==null&&i!==void 0&&i.new;){var i;d.ccOffset+=h.start-g.start,h.new=!1,h=g,g=d[h.prevCC]}d.presentationOffset=o};function m(p,d,e,o,h,g,i,r){var l=new L.VTTParser,c=Object(A.utf8ArrayToStr)(new Uint8Array(p)).trim().replace(O,`
27
+ `,f.parse()),f.state==="INITIAL"||f.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){f.onparsingerror&&f.onparsingerror(e)}return f.onflush&&f.onflush(),this},E}()},"./src/utils/webvtt-parser.ts":function(K,b,n){"use strict";n.r(b),n.d(b,"generateCueId",function(){return A}),n.d(b,"parseWebVTT",function(){return m});var I=n("./src/polyfills/number.ts"),L=n("./src/utils/vttparser.ts"),D=n("./src/demux/id3.ts"),M=n("./src/utils/timescale-conversion.ts"),R=n("./src/remux/mp4-remuxer.ts"),O=/\r\n|\n\r|\n|\r/g,_=function(f,e,o){return o===void 0&&(o=0),f.slice(o,o+e.length)===e},y=function(f){var e=parseInt(f.slice(-3)),o=parseInt(f.slice(-6,-4)),h=parseInt(f.slice(-9,-7)),g=f.length>9?parseInt(f.substring(0,f.indexOf(":"))):0;if(!Object(I.isFiniteNumber)(e)||!Object(I.isFiniteNumber)(o)||!Object(I.isFiniteNumber)(h)||!Object(I.isFiniteNumber)(g))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+f);return e+=1e3*o,e+=60*1e3*h,e+=60*60*1e3*g,e},T=function(f){for(var e=5381,o=f.length;o;)e=e*33^f.charCodeAt(--o);return(e>>>0).toString()};function A(p,f,e){return T(p.toString())+T(f.toString())+T(e)}var E=function(f,e,o){var h=f[e],g=f[h.prevCC];if(!g||!g.new&&h.new){f.ccOffset=f.presentationOffset=h.start,h.new=!1;return}for(;(i=g)!==null&&i!==void 0&&i.new;){var i;f.ccOffset+=h.start-g.start,h.new=!1,h=g,g=f[h.prevCC]}f.presentationOffset=o};function m(p,f,e,o,h,g,i,r){var l=new L.VTTParser,c=Object(D.utf8ArrayToStr)(new Uint8Array(p)).trim().replace(O,`
28
28
  `).split(`
29
- `),t=[],a=Object(M.toMpegTsClockFromTimescale)(d,e),u="00:00.000",s=0,f=0,v,S=!0;l.oncue=function(x){var I=o[h],B=o.ccOffset,k=(s-a)/9e4;I!=null&&I.new&&(f!==void 0?B=o.ccOffset=I.start:E(o,h,k)),k&&(B=k-o.presentationOffset);var U=x.endTime-x.startTime,W=Object(R.normalizePts)((x.startTime+B-f)*9e4,g*9e4)/9e4;x.startTime=Math.max(W,0),x.endTime=Math.max(W+U,0);var G=x.text.trim();x.text=decodeURIComponent(encodeURIComponent(G)),x.id||(x.id=D(x.startTime,x.endTime,G)),x.endTime>0&&t.push(x)},l.onparsingerror=function(x){v=x},l.onflush=function(){if(v){r(v);return}i(t)},c.forEach(function(x){if(S)if(_(x,"X-TIMESTAMP-MAP=")){S=!1,x.slice(16).split(",").forEach(function(I){_(I,"LOCAL:")?u=I.slice(6):_(I,"MPEGTS:")&&(s=parseInt(I.slice(7)))});try{f=y(u)/1e3}catch(I){v=I}return}else x===""&&(S=!1);l.parse(x+`
30
- `)}),l.flush()}},"./src/utils/xhr-loader.ts":function(K,b,n){"use strict";n.r(b);var P=n("./src/utils/logger.ts"),L=n("./src/loader/load-stats.ts"),A=/^age:\s*[\d.]+\s*$/m,M=function(){function R(_){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=_?_.xhrSetup:null,this.stats=new L.LoadStats,this.retryDelay=0}var O=R.prototype;return O.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},O.abortInternal=function(){var y=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),y&&(y.onreadystatechange=null,y.onprogress=null,y.readyState!==4&&(this.stats.aborted=!0,y.abort()))},O.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},O.load=function(y,T,D){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=y,this.config=T,this.callbacks=D,this.retryDelay=T.retryDelay,this.loadInternal()},O.loadInternal=function(){var y=this.config,T=this.context;if(!!y){var D=this.loader=new self.XMLHttpRequest,E=this.stats;E.loading.first=0,E.loaded=0;var m=this.xhrSetup;try{if(m)try{m(D,T.url)}catch{D.open("GET",T.url,!0),m(D,T.url)}D.readyState||D.open("GET",T.url,!0);var p=this.context.headers;if(p)for(var d in p)D.setRequestHeader(d,p[d])}catch(e){this.callbacks.onError({code:D.status,text:e.message},T,D);return}T.rangeEnd&&D.setRequestHeader("Range","bytes="+T.rangeStart+"-"+(T.rangeEnd-1)),D.onreadystatechange=this.readystatechange.bind(this),D.onprogress=this.loadprogress.bind(this),D.responseType=T.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),D.send()}},O.readystatechange=function(){var y=this.context,T=this.loader,D=this.stats;if(!(!y||!T)){var E=T.readyState,m=this.config;if(!D.aborted&&E>=2)if(self.clearTimeout(this.requestTimeout),D.loading.first===0&&(D.loading.first=Math.max(self.performance.now(),D.loading.start)),E===4){T.onreadystatechange=null,T.onprogress=null;var p=T.status;if(p>=200&&p<300){D.loading.end=Math.max(self.performance.now(),D.loading.first);var d,e;if(y.responseType==="arraybuffer"?(d=T.response,e=d.byteLength):(d=T.responseText,e=d.length),D.loaded=D.total=e,!this.callbacks)return;var o=this.callbacks.onProgress;if(o&&o(D,y,d,T),!this.callbacks)return;var h={url:T.responseURL,data:d};this.callbacks.onSuccess(h,D,y,T)}else D.retry>=m.maxRetry||p>=400&&p<499?(P.logger.error(p+" while loading "+y.url),this.callbacks.onError({code:p,text:T.statusText},y,T)):(P.logger.warn(p+" while loading "+y.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,m.maxRetryDelay),D.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),m.timeout)}},O.loadtimeout=function(){P.logger.warn("timeout while loading "+this.context.url);var y=this.callbacks;y&&(this.abortInternal(),y.onTimeout(this.stats,this.context,this.loader))},O.loadprogress=function(y){var T=this.stats;T.loaded=y.loaded,y.lengthComputable&&(T.total=y.total)},O.getCacheAge=function(){var y=null;if(this.loader&&A.test(this.loader.getAllResponseHeaders())){var T=this.loader.getResponseHeader("age");y=T?parseFloat(T):null}return y},R}();b.default=M}}).default})});var Mt=class{addEventListener(){}removeEventListener(){}dispatchEvent(b){return!0}};if(typeof DocumentFragment=="undefined"){class K extends Mt{}globalThis.DocumentFragment=K}var Xt=class extends Mt{},Fr=class extends Mt{},On={get(K){},define(K,b,n){},upgrade(K){},whenDefined(K){return Promise.resolve(Xt)}},zt,kr=class{constructor(b,n={}){ye(this,zt,void 0);be(this,zt,n==null?void 0:n.detail)}get detail(){return se(this,zt)}initCustomEvent(){}};zt=new WeakMap;function Rn(K,b){return new Xt}var ui={document:{createElement:Rn},DocumentFragment,customElements:On,CustomEvent:kr,EventTarget:Mt,HTMLElement:Xt,HTMLVideoElement:Fr},di=typeof window=="undefined"||typeof globalThis.customElements=="undefined",pt=di?ui:globalThis,Br=di?ui.document:globalThis.document;var pr=hr(fi(),1),bt=hr(gr(),1),jr=hr(gr(),1),wt=hr(gr(),1),$t=class extends Error{constructor(K,b=$t.MEDIA_ERR_CUSTOM,n){var P;super(K),this.name="MediaError",this.code=b,this.fatal=n!=null?n:b>=$t.MEDIA_ERR_NETWORK&&b<=$t.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(P=$t.defaultMessages[this.code])!=null?P:"")}},Ze=$t;Ze.MEDIA_ERR_ABORTED=1,Ze.MEDIA_ERR_NETWORK=2,Ze.MEDIA_ERR_DECODE=3,Ze.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Ze.MEDIA_ERR_ENCRYPTED=5,Ze.MEDIA_ERR_CUSTOM=100,Ze.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var pi=(K,b)=>K in b,Wr={ANY:"any",MUTED:"muted"},mr={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},Ot={MSE:"mse",NATIVE:"native"},Ei={HEADER:"header",QUERY:"query"},Vr=Object.values(Ei),Ft={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Gr={HLS:Ft.M3U8},aa=Object.keys(Gr),sa=[...Object.values(Ft),"hls","HLS"],Jt=(K,b,n,P)=>{K.addEventListener(b,n,P),K.addEventListener("teardown",()=>{K.removeEventListener(b,n)},{once:!0})};function In(K,b,n){b&&n>b&&(n=b);for(let P=0;P<K.length;P++)if(K.start(P)<=n&&K.end(P)>=n)return!0;return!1}var Pn=K=>{let b=K.indexOf("?");if(b<0)return[K];let n=K.slice(0,b),P=K.slice(b);return[n,P]},yi=K=>{let b=K.type;if(b){let P=b.toUpperCase();return pi(P,Gr)?Gr[P]:b}let{src:n}=K;return n?Cn(n):""},Cn=K=>{let b="";try{b=new URL(K).pathname}catch{console.error("invalid url")}let n=b.lastIndexOf(".");if(n<0)return"";let P=b.slice(n+1).toUpperCase();return pi(P,Ft)?Ft[P]:""},Mn=Object.values(Wr),ci=K=>typeof K=="boolean"||typeof K=="string"&&Mn.includes(K),wn=({autoplay:K},b,n)=>{let P=!1,L=!1,A=ci(K)?K:!!K,M=()=>{P||Jt(b,"playing",()=>{P=!0},{once:!0})};if(M(),Jt(b,"loadstart",()=>{P=!1,M(),Kr(b,A)},{once:!0}),Jt(b,"loadstart",()=>{n||(L=!Number.isFinite(b.duration)),Kr(b,A)},{once:!0}),n&&n.once(jr.default.Events.LEVEL_LOADED,(R,O)=>{var _;L=(_=O.details.live)!=null?_:!1}),!A){let R=()=>{!L||(n!=null&&n.liveSyncPosition?b.currentTime=n.liveSyncPosition:Number.isFinite(b.seekable.end(0))&&(b.currentTime=b.seekable.end(0)))};n&&Jt(b,"play",()=>{b.preload==="metadata"?n.once(jr.default.Events.LEVEL_UPDATED,R):R()},{once:!0})}return R=>{P||(A=ci(R)?R:!!R,Kr(b,A))}},Kr=(K,b)=>{if(!b)return;let n=K.muted,P=()=>K.muted=n;switch(b){case Wr.ANY:K.play().catch(()=>{K.muted=!0,K.play().catch(P)});break;case Wr.MUTED:K.muted=!0,K.play().catch(P);break;default:K.play().catch(()=>{});break}},Fn=({preload:K,src:b},n,P)=>{let L=T=>{T!=null&&["","none","metadata","auto"].includes(T)?n.setAttribute("preload",T):n.removeAttribute("preload")};if(!P)return L(K),L;let A=!1,M=!1,R=P.config.maxBufferLength,O=P.config.maxBufferSize,_=T=>{L(T);let D=T!=null?T:n.preload;M||D==="none"||(D==="metadata"?(P.config.maxBufferLength=1,P.config.maxBufferSize=1):(P.config.maxBufferLength=R,P.config.maxBufferSize=O),y())},y=()=>{!A&&b&&(A=!0,P.loadSource(b))};return Jt(n,"play",()=>{M=!0,P.config.maxBufferLength=R,P.config.maxBufferSize=O,y()},{once:!0}),_(K),_};function kn(K,b){b.on(wt.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(L,{tracks:A})=>{A.forEach(M=>{var R;let O=(R=M.subtitleTrack)!=null?R:M.closedCaptions,_=b.subtitleTracks.findIndex(({lang:y,name:T,type:D})=>y==(O==null?void 0:O.lang)&&T===M.label&&D.toLowerCase()===M.kind);Bn(K,M.kind,M.label,O==null?void 0:O.lang,`${M.kind}${_}`)})});let n=()=>{var L;if(!b.subtitleTracks.length)return;let A=Array.from(K.textTracks).find(R=>R.id&&R.mode==="showing"&&["subtitles","captions"].includes(R.kind)),M=`${(L=b.subtitleTracks[b.subtitleTrack])==null?void 0:L.type.toLowerCase()}${b.subtitleTrack}`;if(A&&(b.subtitleTrack<0||(A==null?void 0:A.id)!==M)){let R=b.subtitleTracks.findIndex(({lang:O,name:_,type:y})=>O==A.language&&_===A.label&&y.toLowerCase()===A.kind);b.subtitleTrack=R}A&&(A==null?void 0:A.id)===M&&A.cues&&Array.from(A.cues).forEach(R=>{A.addCue(R)})};K.textTracks.addEventListener("change",n),b.on(wt.default.Events.CUES_PARSED,(L,{track:A,cues:M})=>{let R=K.textTracks.getTrackById(A);if(!R)return;let O=R.mode==="disabled";O&&(R.mode="hidden"),M.forEach(_=>{var y;(y=R.cues)!=null&&y.getCueById(_.id)||R.addCue(_)}),O&&(R.mode="disabled")}),b.once(wt.default.Events.DESTROYING,()=>{K.textTracks.removeEventListener("change",n),K.querySelectorAll("track[data-removeondestroy]").forEach(L=>{L.remove()})});let P=()=>{Array.from(K.textTracks).forEach(L=>{var A,M;if(!["subtitles","caption"].includes(L.kind)&&L.label==="thumbnails"){if(!((A=L.cues)!=null&&A.length)){let R=K.querySelector('track[label="thumbnails"]'),O=(M=R==null?void 0:R.getAttribute("src"))!=null?M:"";R==null||R.removeAttribute("src"),setTimeout(()=>{R==null||R.setAttribute("src",O)},0)}L.mode!=="hidden"&&(L.mode="hidden")}})};b.once(wt.default.Events.MANIFEST_LOADED,P),b.once(wt.default.Events.MEDIA_ATTACHED,P)}function Bn(K,b,n,P,L){let A=document.createElement("track");return A.kind=b,A.label=n,P&&(A.srclang=P),L&&(A.id=L),A.track.mode="disabled",A.setAttribute("data-removeondestroy",""),K.append(A),A.track}var hi,vi,Un=(vi=(hi=globalThis==null?void 0:globalThis.navigator)==null?void 0:hi.userAgent)!=null?vi:"",Nn=Un.toLowerCase().indexOf("android")!==-1,kt=new WeakMap,Ti="mux.com",gi,mi,xi=(mi=(gi=bt.default).isSupported)==null?void 0:mi.call(gi),Kn=Nn,Si=()=>pr.default.utils.now(),jn=pr.default.utils.generateUUID,Di=(K,{domain:b=Ti}={})=>{if(!K)return;let[n,P=""]=Pn(K);return`https://stream.${b}/${n}.m3u8${P}`},Wn=K=>{if(!K)return;let[b]=K.split("?");return b||void 0},Gn=K=>{if(!K||!K.startsWith("https://stream."))return;let[b]=new URL(K).pathname.slice(1).split(".m3u8");return b||void 0},Hn=K=>{var b,n,P;return(b=K==null?void 0:K.metadata)!=null&&b.video_id?K.metadata.video_id:bi(K)&&(P=(n=Wn(K.playbackId))!=null?n:Gn(K.src))!=null?P:K.src},Ai=K=>{var b;return(b=kt.get(K))==null?void 0:b.error},Li=(K,b,n)=>{Yr(b,n);let{metadata:P={}}=K,{view_session_id:L=jn()}=P,A=Hn(K);P.view_session_id=L,P.video_id=A,K.metadata=P,kt.set(b,{});let M=Vn(K,b);Xn(K,b,M),zn(K,b,M);let R=wn(K,b,M),O=Fn(K,b,M);return{engine:M,setAutoplay:R,setPreload:O}},Yr=(K,b)=>{let n=b==null?void 0:b.engine;n&&(n.detachMedia(),n.destroy()),(K==null?void 0:K.mux)&&!K.mux.deleted&&(K.mux.destroy(),delete K.mux),K&&(K.removeAttribute("src"),K.load(),K.removeEventListener("error",Ri),K.removeEventListener("error",Hr),K.removeEventListener("durationchange",Oi),kt.delete(K),K.dispatchEvent(new Event("teardown")))};function _i(K,b){var n;let P=yi(K);if(P!==Ft.M3U8)return!0;let L=!P||((n=b.canPlayType(P))!=null?n:!0),{preferPlayback:A}=K,M=A===Ot.MSE,R=A===Ot.NATIVE;return L&&(R||!(xi&&(M||Kn)))}var Vn=(K,b)=>{let{debug:n,streamType:P,startTime:L=-1,metadata:A,experimentalCmcd:M,preferCmcd:R}=K,O=yi(K)===Ft.M3U8,_=_i(K,b);if(O&&!_&&xi){let y={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},T=Yn(P),D=M?{useHeaders:R===Ei.HEADER,sessionId:A.view_session_id,contentId:A.video_id}:void 0;return new bt.default({debug:n,startPosition:L,cmcd:D,...y,...T})}},Yn=K=>[mr.LIVE,mr.DVR].includes(K)?{backBufferLength:8}:[mr.LL_LIVE,mr.LL_DVR].includes(K)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},bi=({playbackId:K,src:b,customDomain:n})=>{if(K)return!0;if(typeof b!="string")return!1;let P=window==null?void 0:window.location.href,L=new URL(b,P).hostname.toLocaleLowerCase();return L.includes(Ti)||!!n&&L.includes(n.toLocaleLowerCase())},Xn=(K,b,n)=>{var P;let{envKey:L}=K,A=bi(K);if(L||A){let{playerInitTime:M,playerSoftwareName:R,playerSoftwareVersion:O,beaconCollectionDomain:_,debug:y,disableCookies:T}=K,D={...K.metadata,video_title:((P=K==null?void 0:K.metadata)==null?void 0:P.video_title)||void 0},E=m=>typeof m.player_error_code=="string"?!1:typeof K.errorTranslator=="function"?K.errorTranslator(m):m;pr.default.monitor(b,{debug:y,beaconCollectionDomain:_,hlsjs:n,Hls:n?bt.default:void 0,automaticErrorTracking:!1,errorTranslator:E,disableCookies:T,data:{...L?{env_key:L}:{},player_software_name:R,player_software:R,player_software_version:O,player_init_time:M,...D}})}},zn=(K,b,n)=>{var P;let L=_i(K,b),{src:A}=K;b&&L?(typeof A=="string"?(b.setAttribute("src",A),K.startTime&&(((P=kt.get(b))!=null?P:{}).startTime=K.startTime,b.addEventListener("durationchange",Oi,{once:!0}))):b.removeAttribute("src"),b.addEventListener("error",Ri),b.addEventListener("error",Hr)):n&&A?(n.on(bt.default.Events.ERROR,(M,R)=>{let O={[bt.default.ErrorTypes.NETWORK_ERROR]:Ze.MEDIA_ERR_NETWORK,[bt.default.ErrorTypes.MEDIA_ERROR]:Ze.MEDIA_ERR_DECODE},_=new Ze("",O[R.type]);_.fatal=R.fatal,_.data=R,b.dispatchEvent(new CustomEvent("error",{detail:_}))}),b.addEventListener("error",Hr),kn(b,n),n.attachMedia(b)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function Oi(K){var b;let n=K.target,P=(b=kt.get(n))==null?void 0:b.startTime;if(!!P&&In(n.seekable,n.duration,P)){let L=n.preload==="auto";L&&(n.preload="none"),n.currentTime=P,L&&(n.preload="auto")}}async function Ri(K){if(!K.isTrusted)return;K.stopImmediatePropagation();let b=K.target;if(!(b!=null&&b.error))return;let{message:n,code:P}=b.error,L=new Ze(n,P);if(b.src&&(P!==Ze.MEDIA_ERR_DECODE||P!==void 0))try{let{status:A}=await fetch(b.src);L.data={response:{code:A}}}catch{}b.dispatchEvent(new CustomEvent("error",{detail:L}))}function Hr(K){var b,n;if(!(K instanceof CustomEvent)||!(K.detail instanceof Ze))return;let P=K.target,L=K.detail;!L||!L.fatal||(((b=kt.get(P))!=null?b:{}).error=L,(n=P.mux)==null||n.emit("error",{player_error_code:L.code,player_error_message:L.message}))}var Qn=()=>{try{return"0.11.0"}catch{}return"UNKNOWN"},$n=Qn(),Ii=()=>$n;var Jn=K=>{var b,n,P,L,A,Pi,R,Er,_,Et,T,yr,E,Tr,p,Ci,e,Mi,h,Xr,i,r,l,c,t,a,u,Zt,f,wi,S,zr,I,Fi,k,Qr,W,ki,X,$r;return b=class extends K{constructor(){super();ye(this,u);ye(this,f);ye(this,S);ye(this,I);ye(this,k);ye(this,W);ye(this,X);Yt(this,"castEnabled",!1);ye(this,i,{paused:!1});ye(this,r,void 0);ye(this,l,{});ye(this,c,void 0);ye(this,t,void 0);ye(this,a,void 0);b.instances.add(this),Ce(this,k,Qr).call(this)}static get castElement(){return se(b,n)}static get castEnabled(){return se(b,P)}static get castState(){var z;return(z=se(b,_,Et))==null?void 0:z.getCastState()}static async exitCast(){try{await se(b,_,Et).endCurrentSession(!0)}catch(q){console.error(q);return}}get castPlayer(){if(b.castElement===this)return se(this,r)}attributeChangedCallback(z){if(!!this.castPlayer)switch(z){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(z={}){var q;Ce(q=b,h,Xr).call(q,z),be(b,n,this),Object.entries(se(this,l)).forEach(([ie,ae])=>{se(this,r).controller.addEventListener(ie,ae)});try{await se(b,_,Et).requestSession()}catch{be(b,n,void 0);return}se(this,i).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(ie){console.error(ie)}}async load(){var oe,ue;if(!this.castPlayer)return super.load();let z=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),q=[...this.querySelectorAll("track")].filter(({kind:re,src:he})=>he&&(re==="subtitles"||re==="captions")),ie=[],ae=0;q.length&&(z.tracks=q.map(re=>{let he=++ae;ie.length===0&&re.track.mode==="showing"&&ie.push(he);let ge=new chrome.cast.media.Track(he,chrome.cast.media.TrackType.TEXT);return ge.trackContentId=re.src,ge.trackContentType="text/vtt",ge.subtype=re.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,ge.name=re.label,ge.language=re.srclang,ge})),this.castStreamType==="live"?z.streamType=chrome.cast.media.StreamType.LIVE:z.streamType=chrome.cast.media.StreamType.BUFFERED,z.metadata=new chrome.cast.media.GenericMediaMetadata,z.metadata.title=this.title,z.metadata.images=[{url:this.poster}];let te=new chrome.cast.media.LoadRequest(z);te.currentTime=(oe=super.currentTime)!=null?oe:0,te.autoplay=!se(this,i).paused,te.activeTrackIds=ie,await((ue=se(b,T,yr))==null?void 0:ue.loadMedia(te)),this.dispatchEvent(new Event("volumechange"))}play(){var z;if(this.castPlayer){this.castPlayer.isPaused&&((z=this.castPlayer.controller)==null||z.playOrPause());return}return super.play()}pause(){var z;if(this.castPlayer){this.castPlayer.isPaused||(z=this.castPlayer.controller)==null||z.playOrPause();return}super.pause()}get castSrc(){var z,q,ie;return(ie=(q=this.getAttribute("cast-src"))!=null?q:(z=this.querySelector("source"))==null?void 0:z.src)!=null?ie:this.currentSrc}set castSrc(z){this.castSrc!=z&&this.setAttribute("cast-src",`${z}`)}get castContentType(){var z;return(z=this.getAttribute("cast-content-type"))!=null?z:void 0}set castContentType(z){this.setAttribute("cast-content-type",`${z}`)}get castStreamType(){var z;return(z=this.getAttribute("cast-stream-type"))!=null?z:void 0}set castStreamType(z){this.setAttribute("cast-stream-type",`${z}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var z;return this.castPlayer?(z=this.castPlayer)==null?void 0:z.isMuted:super.muted}set muted(z){var q;if(this.castPlayer){(z&&!this.castPlayer.isMuted||!z&&this.castPlayer.isMuted)&&((q=this.castPlayer.controller)==null||q.muteOrUnmute());return}super.muted=z}get volume(){var z,q;return this.castPlayer?(q=(z=this.castPlayer)==null?void 0:z.volumeLevel)!=null?q:1:super.volume}set volume(z){var q;if(this.castPlayer){this.castPlayer.volumeLevel=z,(q=this.castPlayer.controller)==null||q.setVolumeLevel();return}super.volume=z}get duration(){var z,q;return this.castPlayer&&se(this,u,Zt)?(q=(z=this.castPlayer)==null?void 0:z.duration)!=null?q:NaN:super.duration}get currentTime(){var z,q;return this.castPlayer&&se(this,u,Zt)?(q=(z=this.castPlayer)==null?void 0:z.currentTime)!=null?q:0:super.currentTime}set currentTime(z){var q;if(this.castPlayer){this.castPlayer.currentTime=z,(q=this.castPlayer.controller)==null||q.seek();return}super.currentTime=z}get onentercast(){return se(this,c)}set onentercast(z){se(this,c)&&(this.removeEventListener("entercast",se(this,c)),be(this,c,null)),typeof z=="function"&&(be(this,c,z),this.addEventListener("entercast",z))}get onleavecast(){return se(this,t)}set onleavecast(z){se(this,t)&&(this.removeEventListener("leavecast",se(this,t)),be(this,t,null)),typeof z=="function"&&(be(this,t,z),this.addEventListener("leavecast",z))}get oncastchange(){return se(this,a)}set oncastchange(z){se(this,a)&&(this.removeEventListener("castchange",se(this,a)),be(this,a,null)),typeof z=="function"&&(be(this,a,z),this.addEventListener("castchange",z))}},n=new WeakMap,P=new WeakMap,L=new WeakMap,A=new WeakSet,Pi=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},R=new WeakSet,Er=function(){return typeof cast!="undefined"&&cast.framework},_=new WeakSet,Et=function(){if(se(b,R,Er))return cast.framework.CastContext.getInstance()},T=new WeakSet,yr=function(){var z;return(z=se(b,_,Et))==null?void 0:z.getCurrentSession()},E=new WeakSet,Tr=function(){var z;return(z=se(b,T,yr))==null?void 0:z.getSessionObj().media[0]},p=new WeakSet,Ci=function(z){return new Promise((q,ie)=>{se(b,E,Tr).editTracksInfo(z,q,ie)})},e=new WeakSet,Mi=function(z){return new Promise((q,ie)=>{se(b,E,Tr).getStatus(z,q,ie)})},h=new WeakSet,Xr=function(z){return se(b,_,Et).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...z})},i=new WeakMap,r=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakMap,a=new WeakMap,u=new WeakSet,Zt=function(){var z;return(z=this.castPlayer)==null?void 0:z.isMediaLoaded},f=new WeakSet,wi=function(){se(b,n)===this&&(Object.entries(se(this,l)).forEach(([z,q])=>{se(this,r).controller.removeEventListener(z,q)}),be(b,n,void 0),this.muted=se(this,r).isMuted,this.currentTime=se(this,r).savedPlayerState.currentTime,se(this,r).savedPlayerState.isPaused===!1&&this.play())},S=new WeakSet,zr=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:se(b,_,Et).getCastState()}))},I=new WeakSet,Fi=async function(){var q,ie;let{SESSION_RESUMED:z}=cast.framework.SessionState;if(se(b,_,Et).getSessionState()===z&&this.castSrc===((q=se(b,E,Tr))==null?void 0:q.media.contentId)){be(b,n,this),Object.entries(se(this,l)).forEach(([ae,te])=>{se(this,r).controller.addEventListener(ae,te)});try{await Ce(ie=b,e,Mi).call(ie,new chrome.cast.media.GetStatusRequest)}catch(ae){console.error(ae)}se(this,l)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),se(this,l)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},k=new WeakSet,Qr=function(){var z;!se(b,R,Er)||this.castEnabled||(this.castEnabled=!0,Ce(z=b,h,Xr).call(z),this.textTracks.addEventListener("change",Ce(this,X,$r).bind(this)),Ce(this,S,zr).call(this),be(this,r,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(se(this,r)),be(this,l,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:q})=>{q===!1&&Ce(this,f,wi).call(this),this.dispatchEvent(new Event(q?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!se(this,u,Zt)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var q,ie;((q=this.castPlayer)==null?void 0:q.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(ie=this.castPlayer)==null?void 0:ie.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!se(this,u,Zt)||(await Promise.resolve(),Ce(this,W,ki).call(this))}}))},W=new WeakSet,ki=function(){Ce(this,X,$r).call(this)},X=new WeakSet,$r=async function(){var Se,Me,Oe,Ne,Ie,Ke;if(!this.castPlayer)return;let q=((Me=(Se=se(this,r).mediaInfo)==null?void 0:Se.tracks)!=null?Me:[]).filter(({type:me})=>me===chrome.cast.media.TrackType.TEXT),ie=[...this.textTracks].filter(({kind:me})=>me==="subtitles"||me==="captions"),ae=q.map(({language:me,name:ke,trackId:je})=>{var We;let{mode:He}=(We=ie.find(Ye=>Ye.language===me&&Ye.label===ke))!=null?We:{};return He?{mode:He,trackId:je}:!1}).filter(Boolean),oe=ae.filter(({mode:me})=>me!=="showing").map(({trackId:me})=>me),ue=ae.find(({mode:me})=>me==="showing"),re=(Ie=(Ne=(Oe=se(b,T,yr))==null?void 0:Oe.getSessionObj().media[0])==null?void 0:Ne.activeTrackIds)!=null?Ie:[],he=re;if(re.length&&(he=he.filter(me=>!oe.includes(me))),ue!=null&&ue.trackId&&(he=[...he,ue.trackId]),he=[...new Set(he)],!((me,ke)=>me.length===ke.length&&me.every(je=>ke.includes(je)))(re,he))try{let me=new chrome.cast.media.EditTracksInfoRequest(he);await Ce(Ke=b,p,Ci).call(Ke,me)}catch(me){console.error(me)}},ye(b,A),ye(b,R),ye(b,_),ye(b,T),ye(b,E),ye(b,p),ye(b,e),ye(b,h),Yt(b,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),Yt(b,"instances",new Set),ye(b,n,void 0),ye(b,P,!1),Yt(b,"initCast",()=>{var z;se(b,A,Pi)?se(b,R,Er)?se(z=b,L).call(z,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var q;return se(q=b,L).call(q,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var q;return se(q=b,L).call(q,chrome.cast.isAvailable)})}}),ye(b,L,z=>{if(z){be(b,P,!0);let{CAST_STATE_CHANGED:q}=cast.framework.CastContextEventType;se(b,_,Et).addEventListener(q,ae=>{b.instances.forEach(te=>{var oe;return Ce(oe=te,S,zr).call(oe,ae)})});let{SESSION_STATE_CHANGED:ie}=cast.framework.CastContextEventType;se(b,_,Et).addEventListener(ie,ae=>{b.instances.forEach(te=>{var oe;return Ce(oe=te,I,Fi).call(oe,ae)})}),b.instances.forEach(ae=>{var te;return Ce(te=ae,k,Qr).call(te)})}}),b};if(globalThis.HTMLVideoElement&&globalThis.customElements){let K=Jn(HTMLVideoElement);globalThis.customElements.get("castable-video")||(globalThis.customElements.define("castable-video",K,{extends:"video"}),globalThis.CastableVideoElement=K),K.initCast()}var Bi=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],Ui=Br.createElement("template");Ui.innerHTML=`
29
+ `),t=[],a=Object(M.toMpegTsClockFromTimescale)(f,e),u="00:00.000",s=0,d=0,v,S=!0;l.oncue=function(x){var P=o[h],B=o.ccOffset,k=(s-a)/9e4;P!=null&&P.new&&(d!==void 0?B=o.ccOffset=P.start:E(o,h,k)),k&&(B=k-o.presentationOffset);var U=x.endTime-x.startTime,W=Object(R.normalizePts)((x.startTime+B-d)*9e4,g*9e4)/9e4;x.startTime=Math.max(W,0),x.endTime=Math.max(W+U,0);var G=x.text.trim();x.text=decodeURIComponent(encodeURIComponent(G)),x.id||(x.id=A(x.startTime,x.endTime,G)),x.endTime>0&&t.push(x)},l.onparsingerror=function(x){v=x},l.onflush=function(){if(v){r(v);return}i(t)},c.forEach(function(x){if(S)if(_(x,"X-TIMESTAMP-MAP=")){S=!1,x.slice(16).split(",").forEach(function(P){_(P,"LOCAL:")?u=P.slice(6):_(P,"MPEGTS:")&&(s=parseInt(P.slice(7)))});try{d=y(u)/1e3}catch(P){v=P}return}else x===""&&(S=!1);l.parse(x+`
30
+ `)}),l.flush()}},"./src/utils/xhr-loader.ts":function(K,b,n){"use strict";n.r(b);var I=n("./src/utils/logger.ts"),L=n("./src/loader/load-stats.ts"),D=/^age:\s*[\d.]+\s*$/m,M=function(){function R(_){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=_?_.xhrSetup:null,this.stats=new L.LoadStats,this.retryDelay=0}var O=R.prototype;return O.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},O.abortInternal=function(){var y=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),y&&(y.onreadystatechange=null,y.onprogress=null,y.readyState!==4&&(this.stats.aborted=!0,y.abort()))},O.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},O.load=function(y,T,A){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=y,this.config=T,this.callbacks=A,this.retryDelay=T.retryDelay,this.loadInternal()},O.loadInternal=function(){var y=this.config,T=this.context;if(!!y){var A=this.loader=new self.XMLHttpRequest,E=this.stats;E.loading.first=0,E.loaded=0;var m=this.xhrSetup;try{if(m)try{m(A,T.url)}catch{A.open("GET",T.url,!0),m(A,T.url)}A.readyState||A.open("GET",T.url,!0);var p=this.context.headers;if(p)for(var f in p)A.setRequestHeader(f,p[f])}catch(e){this.callbacks.onError({code:A.status,text:e.message},T,A);return}T.rangeEnd&&A.setRequestHeader("Range","bytes="+T.rangeStart+"-"+(T.rangeEnd-1)),A.onreadystatechange=this.readystatechange.bind(this),A.onprogress=this.loadprogress.bind(this),A.responseType=T.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),A.send()}},O.readystatechange=function(){var y=this.context,T=this.loader,A=this.stats;if(!(!y||!T)){var E=T.readyState,m=this.config;if(!A.aborted&&E>=2)if(self.clearTimeout(this.requestTimeout),A.loading.first===0&&(A.loading.first=Math.max(self.performance.now(),A.loading.start)),E===4){T.onreadystatechange=null,T.onprogress=null;var p=T.status;if(p>=200&&p<300){A.loading.end=Math.max(self.performance.now(),A.loading.first);var f,e;if(y.responseType==="arraybuffer"?(f=T.response,e=f.byteLength):(f=T.responseText,e=f.length),A.loaded=A.total=e,!this.callbacks)return;var o=this.callbacks.onProgress;if(o&&o(A,y,f,T),!this.callbacks)return;var h={url:T.responseURL,data:f};this.callbacks.onSuccess(h,A,y,T)}else A.retry>=m.maxRetry||p>=400&&p<499?(I.logger.error(p+" while loading "+y.url),this.callbacks.onError({code:p,text:T.statusText},y,T)):(I.logger.warn(p+" while loading "+y.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,m.maxRetryDelay),A.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),m.timeout)}},O.loadtimeout=function(){I.logger.warn("timeout while loading "+this.context.url);var y=this.callbacks;y&&(this.abortInternal(),y.onTimeout(this.stats,this.context,this.loader))},O.loadprogress=function(y){var T=this.stats;T.loaded=y.loaded,y.lengthComputable&&(T.total=y.total)},O.getCacheAge=function(){var y=null;if(this.loader&&D.test(this.loader.getAllResponseHeaders())){var T=this.loader.getResponseHeader("age");y=T?parseFloat(T):null}return y},R}();b.default=M}}).default})});var Mt=class{addEventListener(){}removeEventListener(){}dispatchEvent(b){return!0}};if(typeof DocumentFragment=="undefined"){class K extends Mt{}globalThis.DocumentFragment=K}var zt=class extends Mt{},Fr=class extends Mt{},On={get(K){},define(K,b,n){},upgrade(K){},whenDefined(K){return Promise.resolve(zt)}},Xt,kr=class{constructor(b,n={}){Ee(this,Xt,void 0);be(this,Xt,n==null?void 0:n.detail)}get detail(){return se(this,Xt)}initCustomEvent(){}};Xt=new WeakMap;function Rn(K,b){return new zt}var fi={document:{createElement:Rn},DocumentFragment,customElements:On,CustomEvent:kr,EventTarget:Mt,HTMLElement:zt,HTMLVideoElement:Fr},di=typeof window=="undefined"||typeof globalThis.customElements=="undefined",pt=di?fi:globalThis,Br=di?fi.document:globalThis.document;var pr=hr(ci(),1),bt=hr(gr(),1),jr=hr(gr(),1),wt=hr(gr(),1),$t=class extends Error{constructor(K,b=$t.MEDIA_ERR_CUSTOM,n){var I;super(K),this.name="MediaError",this.code=b,this.fatal=n!=null?n:b>=$t.MEDIA_ERR_NETWORK&&b<=$t.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(I=$t.defaultMessages[this.code])!=null?I:"")}},Ze=$t;Ze.MEDIA_ERR_ABORTED=1,Ze.MEDIA_ERR_NETWORK=2,Ze.MEDIA_ERR_DECODE=3,Ze.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Ze.MEDIA_ERR_ENCRYPTED=5,Ze.MEDIA_ERR_CUSTOM=100,Ze.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var Ei=(K,b)=>K in b,Wr={ANY:"any",MUTED:"muted"},mr={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},Ot={MSE:"mse",NATIVE:"native"},Gr={HEADER:"header",QUERY:"query",NONE:"none"},Yr=Object.values(Gr),Ft={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Hr={HLS:Ft.M3U8},aa=Object.keys(Hr),sa=[...Object.values(Ft),"hls","HLS"],Jt=(K,b,n,I)=>{K.addEventListener(b,n,I),K.addEventListener("teardown",()=>{K.removeEventListener(b,n)},{once:!0})};function Pn(K,b,n){b&&n>b&&(n=b);for(let I=0;I<K.length;I++)if(K.start(I)<=n&&K.end(I)>=n)return!0;return!1}var In=K=>{let b=K.indexOf("?");if(b<0)return[K];let n=K.slice(0,b),I=K.slice(b);return[n,I]},yi=K=>{let b=K.type;if(b){let I=b.toUpperCase();return Ei(I,Hr)?Hr[I]:b}let{src:n}=K;return n?Cn(n):""},Cn=K=>{let b="";try{b=new URL(K).pathname}catch{console.error("invalid url")}let n=b.lastIndexOf(".");if(n<0)return"";let I=b.slice(n+1).toUpperCase();return Ei(I,Ft)?Ft[I]:""},Mn=Object.values(Wr),hi=K=>typeof K=="boolean"||typeof K=="string"&&Mn.includes(K),wn=({autoplay:K},b,n)=>{let I=!1,L=!1,D=hi(K)?K:!!K,M=()=>{I||Jt(b,"playing",()=>{I=!0},{once:!0})};if(M(),Jt(b,"loadstart",()=>{I=!1,M(),Kr(b,D)},{once:!0}),Jt(b,"loadstart",()=>{n||(L=!Number.isFinite(b.duration)),Kr(b,D)},{once:!0}),n&&n.once(jr.default.Events.LEVEL_LOADED,(R,O)=>{var _;L=(_=O.details.live)!=null?_:!1}),!D){let R=()=>{!L||(n!=null&&n.liveSyncPosition?b.currentTime=n.liveSyncPosition:Number.isFinite(b.seekable.end(0))&&(b.currentTime=b.seekable.end(0)))};n&&Jt(b,"play",()=>{b.preload==="metadata"?n.once(jr.default.Events.LEVEL_UPDATED,R):R()},{once:!0})}return R=>{I||(D=hi(R)?R:!!R,Kr(b,D))}},Kr=(K,b)=>{if(!b)return;let n=K.muted,I=()=>K.muted=n;switch(b){case Wr.ANY:K.play().catch(()=>{K.muted=!0,K.play().catch(I)});break;case Wr.MUTED:K.muted=!0,K.play().catch(I);break;default:K.play().catch(()=>{});break}},Fn=({preload:K,src:b},n,I)=>{let L=T=>{T!=null&&["","none","metadata","auto"].includes(T)?n.setAttribute("preload",T):n.removeAttribute("preload")};if(!I)return L(K),L;let D=!1,M=!1,R=I.config.maxBufferLength,O=I.config.maxBufferSize,_=T=>{L(T);let A=T!=null?T:n.preload;M||A==="none"||(A==="metadata"?(I.config.maxBufferLength=1,I.config.maxBufferSize=1):(I.config.maxBufferLength=R,I.config.maxBufferSize=O),y())},y=()=>{!D&&b&&(D=!0,I.loadSource(b))};return Jt(n,"play",()=>{M=!0,I.config.maxBufferLength=R,I.config.maxBufferSize=O,y()},{once:!0}),_(K),_};function kn(K,b){b.on(wt.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(L,{tracks:D})=>{D.forEach(M=>{var R;let O=(R=M.subtitleTrack)!=null?R:M.closedCaptions,_=b.subtitleTracks.findIndex(({lang:y,name:T,type:A})=>y==(O==null?void 0:O.lang)&&T===M.label&&A.toLowerCase()===M.kind);Bn(K,M.kind,M.label,O==null?void 0:O.lang,`${M.kind}${_}`)})});let n=()=>{var L;if(!b.subtitleTracks.length)return;let D=Array.from(K.textTracks).find(R=>R.id&&R.mode==="showing"&&["subtitles","captions"].includes(R.kind)),M=`${(L=b.subtitleTracks[b.subtitleTrack])==null?void 0:L.type.toLowerCase()}${b.subtitleTrack}`;if(D&&(b.subtitleTrack<0||(D==null?void 0:D.id)!==M)){let R=b.subtitleTracks.findIndex(({lang:O,name:_,type:y})=>O==D.language&&_===D.label&&y.toLowerCase()===D.kind);b.subtitleTrack=R}D&&(D==null?void 0:D.id)===M&&D.cues&&Array.from(D.cues).forEach(R=>{D.addCue(R)})};K.textTracks.addEventListener("change",n),b.on(wt.default.Events.CUES_PARSED,(L,{track:D,cues:M})=>{let R=K.textTracks.getTrackById(D);if(!R)return;let O=R.mode==="disabled";O&&(R.mode="hidden"),M.forEach(_=>{var y;(y=R.cues)!=null&&y.getCueById(_.id)||R.addCue(_)}),O&&(R.mode="disabled")}),b.once(wt.default.Events.DESTROYING,()=>{K.textTracks.removeEventListener("change",n),K.querySelectorAll("track[data-removeondestroy]").forEach(L=>{L.remove()})});let I=()=>{Array.from(K.textTracks).forEach(L=>{var D,M;if(!["subtitles","caption"].includes(L.kind)&&L.label==="thumbnails"){if(!((D=L.cues)!=null&&D.length)){let R=K.querySelector('track[label="thumbnails"]'),O=(M=R==null?void 0:R.getAttribute("src"))!=null?M:"";R==null||R.removeAttribute("src"),setTimeout(()=>{R==null||R.setAttribute("src",O)},0)}L.mode!=="hidden"&&(L.mode="hidden")}})};b.once(wt.default.Events.MANIFEST_LOADED,I),b.once(wt.default.Events.MEDIA_ATTACHED,I)}function Bn(K,b,n,I,L){let D=document.createElement("track");return D.kind=b,D.label=n,I&&(D.srclang=I),L&&(D.id=L),D.track.mode="disabled",D.setAttribute("data-removeondestroy",""),K.append(D),D.track}var vi,gi,Un=(gi=(vi=globalThis==null?void 0:globalThis.navigator)==null?void 0:vi.userAgent)!=null?gi:"",Nn=Un.toLowerCase().indexOf("android")!==-1,kt=new WeakMap,Ti="mux.com",mi,pi,xi=(pi=(mi=bt.default).isSupported)==null?void 0:pi.call(mi),Kn=Nn,Si=()=>pr.default.utils.now(),jn=pr.default.utils.generateUUID,Di=(K,{domain:b=Ti}={})=>{if(!K)return;let[n,I=""]=In(K);return`https://stream.${b}/${n}.m3u8${I}`},Wn=K=>{if(!K)return;let[b]=K.split("?");return b||void 0},Gn=K=>{if(!K||!K.startsWith("https://stream."))return;let[b]=new URL(K).pathname.slice(1).split(".m3u8");return b||void 0},Hn=K=>{var b,n,I;return(b=K==null?void 0:K.metadata)!=null&&b.video_id?K.metadata.video_id:bi(K)&&(I=(n=Wn(K.playbackId))!=null?n:Gn(K.src))!=null?I:K.src},Ai=K=>{var b;return(b=kt.get(K))==null?void 0:b.error},Li=(K,b,n)=>{zr(b,n);let{metadata:I={}}=K,{view_session_id:L=jn()}=I,D=Hn(K);I.view_session_id=L,I.video_id=D,K.metadata=I,kt.set(b,{});let M=Vn(K,b);zn(K,b,M),Xn(K,b,M);let R=wn(K,b,M),O=Fn(K,b,M);return{engine:M,setAutoplay:R,setPreload:O}},zr=(K,b)=>{let n=b==null?void 0:b.engine;n&&(n.detachMedia(),n.destroy()),(K==null?void 0:K.mux)&&!K.mux.deleted&&(K.mux.destroy(),delete K.mux),K&&(K.removeAttribute("src"),K.load(),K.removeEventListener("error",Ri),K.removeEventListener("error",Vr),K.removeEventListener("durationchange",Oi),kt.delete(K),K.dispatchEvent(new Event("teardown")))};function _i(K,b){var n;let I=yi(K);if(I!==Ft.M3U8)return!0;let L=!I||((n=b.canPlayType(I))!=null?n:!0),{preferPlayback:D}=K,M=D===Ot.MSE,R=D===Ot.NATIVE;return L&&(R||!(xi&&(M||Kn)))}var Vn=(K,b)=>{let{debug:n,streamType:I,startTime:L=-1,metadata:D,preferCmcd:M}=K,R=yi(K)===Ft.M3U8,O=_i(K,b);if(R&&!O&&xi){let _={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},y=Yn(I),T=M!==Gr.NONE?{useHeaders:M===Gr.HEADER,sessionId:D.view_session_id,contentId:D.video_id}:void 0;return new bt.default({debug:n,startPosition:L,cmcd:T,..._,...y})}},Yn=K=>[mr.LIVE,mr.DVR].includes(K)?{backBufferLength:8}:[mr.LL_LIVE,mr.LL_DVR].includes(K)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},bi=({playbackId:K,src:b,customDomain:n})=>{if(K)return!0;if(typeof b!="string")return!1;let I=window==null?void 0:window.location.href,L=new URL(b,I).hostname.toLocaleLowerCase();return L.includes(Ti)||!!n&&L.includes(n.toLocaleLowerCase())},zn=(K,b,n)=>{var I;let{envKey:L}=K,D=bi(K);if(L||D){let{playerInitTime:M,playerSoftwareName:R,playerSoftwareVersion:O,beaconCollectionDomain:_,debug:y,disableCookies:T}=K,A={...K.metadata,video_title:((I=K==null?void 0:K.metadata)==null?void 0:I.video_title)||void 0},E=m=>typeof m.player_error_code=="string"?!1:typeof K.errorTranslator=="function"?K.errorTranslator(m):m;pr.default.monitor(b,{debug:y,beaconCollectionDomain:_,hlsjs:n,Hls:n?bt.default:void 0,automaticErrorTracking:!1,errorTranslator:E,disableCookies:T,data:{...L?{env_key:L}:{},player_software_name:R,player_software:R,player_software_version:O,player_init_time:M,...A}})}},Xn=(K,b,n)=>{var I;let L=_i(K,b),{src:D}=K;b&&L?(typeof D=="string"?(b.setAttribute("src",D),K.startTime&&(((I=kt.get(b))!=null?I:{}).startTime=K.startTime,b.addEventListener("durationchange",Oi,{once:!0}))):b.removeAttribute("src"),b.addEventListener("error",Ri),b.addEventListener("error",Vr)):n&&D?(n.on(bt.default.Events.ERROR,(M,R)=>{let O={[bt.default.ErrorTypes.NETWORK_ERROR]:Ze.MEDIA_ERR_NETWORK,[bt.default.ErrorTypes.MEDIA_ERROR]:Ze.MEDIA_ERR_DECODE},_=new Ze("",O[R.type]);_.fatal=R.fatal,_.data=R,b.dispatchEvent(new CustomEvent("error",{detail:_}))}),b.addEventListener("error",Vr),kn(b,n),n.attachMedia(b)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function Oi(K){var b;let n=K.target,I=(b=kt.get(n))==null?void 0:b.startTime;if(!!I&&Pn(n.seekable,n.duration,I)){let L=n.preload==="auto";L&&(n.preload="none"),n.currentTime=I,L&&(n.preload="auto")}}async function Ri(K){if(!K.isTrusted)return;K.stopImmediatePropagation();let b=K.target;if(!(b!=null&&b.error))return;let{message:n,code:I}=b.error,L=new Ze(n,I);if(b.src&&(I!==Ze.MEDIA_ERR_DECODE||I!==void 0))try{let{status:D}=await fetch(b.src);L.data={response:{code:D}}}catch{}b.dispatchEvent(new CustomEvent("error",{detail:L}))}function Vr(K){var b,n;if(!(K instanceof CustomEvent)||!(K.detail instanceof Ze))return;let I=K.target,L=K.detail;!L||!L.fatal||(((b=kt.get(I))!=null?b:{}).error=L,(n=I.mux)==null||n.emit("error",{player_error_code:L.code,player_error_message:L.message}))}var Qn=()=>{try{return"0.12.0"}catch{}return"UNKNOWN"},$n=Qn(),Pi=()=>$n;var Jn=K=>{var b,n,I,L,D,Ii,R,Er,_,Et,T,yr,E,Tr,p,Ci,e,Mi,h,Xr,i,r,l,c,t,a,u,Zt,d,wi,S,Qr,P,Fi,k,$r,W,ki,z,Jr;return b=class extends K{constructor(){super();Ee(this,u);Ee(this,d);Ee(this,S);Ee(this,P);Ee(this,k);Ee(this,W);Ee(this,z);Yt(this,"castEnabled",!1);Ee(this,i,{paused:!1});Ee(this,r,void 0);Ee(this,l,{});Ee(this,c,void 0);Ee(this,t,void 0);Ee(this,a,void 0);b.instances.add(this),Ce(this,k,$r).call(this)}static get castElement(){return se(b,n)}static get castEnabled(){return se(b,I)}static get castState(){var X;return(X=se(b,_,Et))==null?void 0:X.getCastState()}static async exitCast(){try{await se(b,_,Et).endCurrentSession(!0)}catch(q){console.error(q);return}}get castPlayer(){if(b.castElement===this)return se(this,r)}attributeChangedCallback(X){if(!!this.castPlayer)switch(X){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(X={}){var q;Ce(q=b,h,Xr).call(q,X),be(b,n,this),Object.entries(se(this,l)).forEach(([ie,ae])=>{se(this,r).controller.addEventListener(ie,ae)});try{await se(b,_,Et).requestSession()}catch{be(b,n,void 0);return}se(this,i).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(ie){console.error(ie)}}async load(){var oe,ue;if(!this.castPlayer)return super.load();let X=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),q=[...this.querySelectorAll("track")].filter(({kind:re,src:he})=>he&&(re==="subtitles"||re==="captions")),ie=[],ae=0;q.length&&(X.tracks=q.map(re=>{let he=++ae;ie.length===0&&re.track.mode==="showing"&&ie.push(he);let ve=new chrome.cast.media.Track(he,chrome.cast.media.TrackType.TEXT);return ve.trackContentId=re.src,ve.trackContentType="text/vtt",ve.subtype=re.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,ve.name=re.label,ve.language=re.srclang,ve})),this.castStreamType==="live"?X.streamType=chrome.cast.media.StreamType.LIVE:X.streamType=chrome.cast.media.StreamType.BUFFERED,X.metadata=new chrome.cast.media.GenericMediaMetadata,X.metadata.title=this.title,X.metadata.images=[{url:this.poster}];let te=new chrome.cast.media.LoadRequest(X);te.currentTime=(oe=super.currentTime)!=null?oe:0,te.autoplay=!se(this,i).paused,te.activeTrackIds=ie,await((ue=se(b,T,yr))==null?void 0:ue.loadMedia(te)),this.dispatchEvent(new Event("volumechange"))}play(){var X;if(this.castPlayer){this.castPlayer.isPaused&&((X=this.castPlayer.controller)==null||X.playOrPause());return}return super.play()}pause(){var X;if(this.castPlayer){this.castPlayer.isPaused||(X=this.castPlayer.controller)==null||X.playOrPause();return}super.pause()}get castSrc(){var X,q,ie;return(ie=(q=this.getAttribute("cast-src"))!=null?q:(X=this.querySelector("source"))==null?void 0:X.src)!=null?ie:this.currentSrc}set castSrc(X){this.castSrc!=X&&this.setAttribute("cast-src",`${X}`)}get castContentType(){var X;return(X=this.getAttribute("cast-content-type"))!=null?X:void 0}set castContentType(X){this.setAttribute("cast-content-type",`${X}`)}get castStreamType(){var X;return(X=this.getAttribute("cast-stream-type"))!=null?X:void 0}set castStreamType(X){this.setAttribute("cast-stream-type",`${X}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var X;return this.castPlayer?(X=this.castPlayer)==null?void 0:X.isMuted:super.muted}set muted(X){var q;if(this.castPlayer){(X&&!this.castPlayer.isMuted||!X&&this.castPlayer.isMuted)&&((q=this.castPlayer.controller)==null||q.muteOrUnmute());return}super.muted=X}get volume(){var X,q;return this.castPlayer?(q=(X=this.castPlayer)==null?void 0:X.volumeLevel)!=null?q:1:super.volume}set volume(X){var q;if(this.castPlayer){this.castPlayer.volumeLevel=X,(q=this.castPlayer.controller)==null||q.setVolumeLevel();return}super.volume=X}get duration(){var X,q;return this.castPlayer&&se(this,u,Zt)?(q=(X=this.castPlayer)==null?void 0:X.duration)!=null?q:NaN:super.duration}get currentTime(){var X,q;return this.castPlayer&&se(this,u,Zt)?(q=(X=this.castPlayer)==null?void 0:X.currentTime)!=null?q:0:super.currentTime}set currentTime(X){var q;if(this.castPlayer){this.castPlayer.currentTime=X,(q=this.castPlayer.controller)==null||q.seek();return}super.currentTime=X}get onentercast(){return se(this,c)}set onentercast(X){se(this,c)&&(this.removeEventListener("entercast",se(this,c)),be(this,c,null)),typeof X=="function"&&(be(this,c,X),this.addEventListener("entercast",X))}get onleavecast(){return se(this,t)}set onleavecast(X){se(this,t)&&(this.removeEventListener("leavecast",se(this,t)),be(this,t,null)),typeof X=="function"&&(be(this,t,X),this.addEventListener("leavecast",X))}get oncastchange(){return se(this,a)}set oncastchange(X){se(this,a)&&(this.removeEventListener("castchange",se(this,a)),be(this,a,null)),typeof X=="function"&&(be(this,a,X),this.addEventListener("castchange",X))}},n=new WeakMap,I=new WeakMap,L=new WeakMap,D=new WeakSet,Ii=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},R=new WeakSet,Er=function(){return typeof cast!="undefined"&&cast.framework},_=new WeakSet,Et=function(){if(se(b,R,Er))return cast.framework.CastContext.getInstance()},T=new WeakSet,yr=function(){var X;return(X=se(b,_,Et))==null?void 0:X.getCurrentSession()},E=new WeakSet,Tr=function(){var X;return(X=se(b,T,yr))==null?void 0:X.getSessionObj().media[0]},p=new WeakSet,Ci=function(X){return new Promise((q,ie)=>{se(b,E,Tr).editTracksInfo(X,q,ie)})},e=new WeakSet,Mi=function(X){return new Promise((q,ie)=>{se(b,E,Tr).getStatus(X,q,ie)})},h=new WeakSet,Xr=function(X){return se(b,_,Et).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...X})},i=new WeakMap,r=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakMap,a=new WeakMap,u=new WeakSet,Zt=function(){var X;return(X=this.castPlayer)==null?void 0:X.isMediaLoaded},d=new WeakSet,wi=function(){se(b,n)===this&&(Object.entries(se(this,l)).forEach(([X,q])=>{se(this,r).controller.removeEventListener(X,q)}),be(b,n,void 0),this.muted=se(this,r).isMuted,this.currentTime=se(this,r).savedPlayerState.currentTime,se(this,r).savedPlayerState.isPaused===!1&&this.play())},S=new WeakSet,Qr=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:se(b,_,Et).getCastState()}))},P=new WeakSet,Fi=async function(){var q,ie;let{SESSION_RESUMED:X}=cast.framework.SessionState;if(se(b,_,Et).getSessionState()===X&&this.castSrc===((q=se(b,E,Tr))==null?void 0:q.media.contentId)){be(b,n,this),Object.entries(se(this,l)).forEach(([ae,te])=>{se(this,r).controller.addEventListener(ae,te)});try{await Ce(ie=b,e,Mi).call(ie,new chrome.cast.media.GetStatusRequest)}catch(ae){console.error(ae)}se(this,l)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),se(this,l)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},k=new WeakSet,$r=function(){var X;!se(b,R,Er)||this.castEnabled||(this.castEnabled=!0,Ce(X=b,h,Xr).call(X),this.textTracks.addEventListener("change",Ce(this,z,Jr).bind(this)),Ce(this,S,Qr).call(this),be(this,r,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(se(this,r)),be(this,l,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:q})=>{q===!1&&Ce(this,d,wi).call(this),this.dispatchEvent(new Event(q?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!se(this,u,Zt)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var q,ie;((q=this.castPlayer)==null?void 0:q.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(ie=this.castPlayer)==null?void 0:ie.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!se(this,u,Zt)||(await Promise.resolve(),Ce(this,W,ki).call(this))}}))},W=new WeakSet,ki=function(){Ce(this,z,Jr).call(this)},z=new WeakSet,Jr=async function(){var Se,Me,Oe,Ne,Pe,Ke;if(!this.castPlayer)return;let q=((Me=(Se=se(this,r).mediaInfo)==null?void 0:Se.tracks)!=null?Me:[]).filter(({type:ge})=>ge===chrome.cast.media.TrackType.TEXT),ie=[...this.textTracks].filter(({kind:ge})=>ge==="subtitles"||ge==="captions"),ae=q.map(({language:ge,name:ke,trackId:je})=>{var We;let{mode:He}=(We=ie.find(Ye=>Ye.language===ge&&Ye.label===ke))!=null?We:{};return He?{mode:He,trackId:je}:!1}).filter(Boolean),oe=ae.filter(({mode:ge})=>ge!=="showing").map(({trackId:ge})=>ge),ue=ae.find(({mode:ge})=>ge==="showing"),re=(Pe=(Ne=(Oe=se(b,T,yr))==null?void 0:Oe.getSessionObj().media[0])==null?void 0:Ne.activeTrackIds)!=null?Pe:[],he=re;if(re.length&&(he=he.filter(ge=>!oe.includes(ge))),ue!=null&&ue.trackId&&(he=[...he,ue.trackId]),he=[...new Set(he)],!((ge,ke)=>ge.length===ke.length&&ge.every(je=>ke.includes(je)))(re,he))try{let ge=new chrome.cast.media.EditTracksInfoRequest(he);await Ce(Ke=b,p,Ci).call(Ke,ge)}catch(ge){console.error(ge)}},Ee(b,D),Ee(b,R),Ee(b,_),Ee(b,T),Ee(b,E),Ee(b,p),Ee(b,e),Ee(b,h),Yt(b,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),Yt(b,"instances",new Set),Ee(b,n,void 0),Ee(b,I,!1),Yt(b,"initCast",()=>{var X;se(b,D,Ii)?se(b,R,Er)?se(X=b,L).call(X,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var q;return se(q=b,L).call(q,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var q;return se(q=b,L).call(q,chrome.cast.isAvailable)})}}),Ee(b,L,X=>{if(X){be(b,I,!0);let{CAST_STATE_CHANGED:q}=cast.framework.CastContextEventType;se(b,_,Et).addEventListener(q,ae=>{b.instances.forEach(te=>{var oe;return Ce(oe=te,S,Qr).call(oe,ae)})});let{SESSION_STATE_CHANGED:ie}=cast.framework.CastContextEventType;se(b,_,Et).addEventListener(ie,ae=>{b.instances.forEach(te=>{var oe;return Ce(oe=te,P,Fi).call(oe,ae)})}),b.instances.forEach(ae=>{var te;return Ce(te=ae,k,$r).call(te)})}}),b};if(globalThis.HTMLVideoElement&&globalThis.customElements){let K=Jn(HTMLVideoElement);globalThis.customElements.get("castable-video")||(globalThis.customElements.define("castable-video",K,{extends:"video"}),globalThis.CastableVideoElement=K),K.initCast()}var Bi=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],Ui=Br.createElement("template");Ui.innerHTML=`
31
31
  <style>
32
32
  :host {
33
33
  display: inline-block;
@@ -47,7 +47,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
47
47
  </style>
48
48
  <video is="castable-video" part="video" crossorigin></video>
49
49
  <slot></slot>
50
- `;var qt,Bt,xr,er,Jr,xt=class extends pt.HTMLElement{constructor(){super();ye(this,Bt);ye(this,er);ye(this,qt,void 0);this.attachShadow({mode:"open"}),this.isConnected&&Ce(this,Bt,xr).call(this)}static get observedAttributes(){let n=[],P=A=>A.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(A=>{let M=!1;try{typeof this.prototype[A]=="function"&&(M=!0)}catch{}!M&&A!==A.toUpperCase()&&n.push(A.toLowerCase(),P(A))});let L=Object.getPrototypeOf(this).observedAttributes;return L&&(n=n.concat(L)),n}attributeChangedCallback(n,P,L){Ce(this,Bt,xr).call(this),Ce(this,er,Jr).call(this,n,P,L)}connectedCallback(){Ce(this,Bt,xr).call(this)}};qt=new WeakMap,Bt=new WeakSet,xr=function(){if(se(this,qt))return;be(this,qt,!0),this.shadowRoot.append(Ui.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),Bi.forEach(P=>{this.nativeEl.addEventListener(P,L=>{this.dispatchEvent(new CustomEvent(L.type,{detail:L.detail}))})});let n=this.shadowRoot.querySelector("slot");n.addEventListener("slotchange",()=>{n.assignedElements().forEach(P=>{!["track","source"].includes(P.localName)||this.nativeEl.append(P)})}),Array.prototype.forEach.call(this.attributes,P=>{Ce(this,er,Jr).call(this,P.name,null,P.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},er=new WeakSet,Jr=function(n,P,L){let A=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),M=qn(A,n),R=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;M&&!R?typeof this[M]=="boolean"?L===null?this[M]=!1:this[M]=!0:this[M]=L:L===null?this.nativeEl.removeAttribute(n):["id","class"].indexOf(n)===-1&&this.nativeEl.setAttribute(n,L)};var Ni=[],Ki=Br.createElement("video",{is:"castable-video"}),Zn=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let K=Object.getPrototypeOf(Ki);K&&K!==pt.HTMLElement.prototype;K=Object.getPrototypeOf(K))Object.getOwnPropertyNames(K).forEach(b=>{Zn.indexOf(b)===-1&&Ni.push(b)});Ni.forEach(K=>{if(K in xt.prototype)return;if(typeof Ki[K]=="function")xt.prototype[K]=function(){return this.nativeEl[K].apply(this.nativeEl,arguments)};else{let n={get(){return this.nativeEl[K]}};K!==K.toUpperCase()&&(n.set=function(P){this.nativeEl[K]=P}),Object.defineProperty(xt.prototype,K,n)}});function qn(K,b){let n=null;return K.forEach(P=>{P.toLowerCase()==b.toLowerCase()&&(n=P)}),n}pt.customElements.get("custom-video")||(pt.customElements.define("custom-video",xt),pt.CustomVideoElement=xt);var Zr=xt;var ve={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_PLAYBACK:"prefer-playback",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_SOFTWARE_NAME:"player-software-name",METADATA_VIDEO_ID:"metadata-video-id",METADATA_VIDEO_TITLE:"metadata-video-title",METADATA_VIEWER_USER_ID:"metadata-viewer-user-id",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DISABLE_COOKIES:"disable-cookies",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time",PREFER_CMCD:"prefer-cmcd",EXPERIMENTAL_CMCD:"experimental-cmcd"},ea=Object.values(ve),ta=Ii(),ra="mux-video",yt,Ut,rr,Nt,ir,nr,ar,sr,qr,tr=class extends Zr{constructor(){super();ye(this,sr);ye(this,yt,void 0);ye(this,Ut,void 0);ye(this,rr,void 0);ye(this,Nt,{});ye(this,ir,void 0);ye(this,nr,void 0);ye(this,ar,void 0);be(this,rr,Si())}static get observedAttributes(){var n;return[...ea,...(n=Zr.observedAttributes)!=null?n:[]]}get experimentalCmcd(){return this.hasAttribute(ve.EXPERIMENTAL_CMCD)}set experimentalCmcd(n){!!n!==this.experimentalCmcd&&(n?this.setAttribute(ve.EXPERIMENTAL_CMCD,""):this.removeAttribute(ve.EXPERIMENTAL_CMCD))}get preferCmcd(){var n;return(n=this.getAttribute(ve.PREFER_CMCD))!=null?n:void 0}set preferCmcd(n){n!==this.preferCmcd&&(n?Vr.includes(n)?this.setAttribute(ve.PREFER_CMCD,n):console.warn(`Invalid value for preferCmcd. Must be one of ${Vr.join()}`):this.removeAttribute(ve.PREFER_CMCD))}get playerInitTime(){return se(this,rr)}get playerSoftwareName(){var n;return(n=se(this,nr))!=null?n:ra}set playerSoftwareName(n){be(this,nr,n)}get playerSoftwareVersion(){var n;return(n=se(this,ir))!=null?n:ta}set playerSoftwareVersion(n){be(this,ir,n)}get _hls(){var n;return(n=se(this,yt))==null?void 0:n.engine}get mux(){return this.nativeEl.mux}get error(){var n;return(n=Ai(this.nativeEl))!=null?n:null}get errorTranslator(){return se(this,ar)}set errorTranslator(n){be(this,ar,n)}get src(){return this.getAttribute("src")}set src(n){n!==this.src&&(n==null?this.removeAttribute("src"):this.setAttribute("src",n))}get type(){var n;return(n=this.getAttribute(ve.TYPE))!=null?n:void 0}set type(n){n!==this.type&&(n?this.setAttribute(ve.TYPE,n):this.removeAttribute(ve.TYPE))}get autoplay(){let n=this.getAttribute("autoplay");return n===null?!1:n===""?!0:n}set autoplay(n){let P=this.autoplay;n!==P&&(n?this.setAttribute("autoplay",typeof n=="string"?n:""):this.removeAttribute("autoplay"))}get preload(){let n=this.getAttribute("preload");return n===""?"auto":["none","metadata","auto"].includes(n)?n:super.preload}set preload(n){n!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(n)?this.setAttribute("preload",n):this.removeAttribute("preload"))}get debug(){return this.getAttribute(ve.DEBUG)!=null}set debug(n){n!==this.debug&&(n?this.setAttribute(ve.DEBUG,""):this.removeAttribute(ve.DEBUG))}get disableCookies(){return this.hasAttribute(ve.DISABLE_COOKIES)}set disableCookies(n){n!==this.disableCookies&&(n?this.setAttribute(ve.DISABLE_COOKIES,""):this.removeAttribute(ve.DISABLE_COOKIES))}get startTime(){let n=this.getAttribute(ve.START_TIME);if(n==null)return;let P=+n;return Number.isNaN(P)?void 0:P}set startTime(n){n!==this.startTime&&(n==null?this.removeAttribute(ve.START_TIME):this.setAttribute(ve.START_TIME,`${n}`))}get playbackId(){var n;return(n=this.getAttribute(ve.PLAYBACK_ID))!=null?n:void 0}set playbackId(n){n!==this.playbackId&&(n?this.setAttribute(ve.PLAYBACK_ID,n):this.removeAttribute(ve.PLAYBACK_ID))}get customDomain(){var n;return(n=this.getAttribute(ve.CUSTOM_DOMAIN))!=null?n:void 0}set customDomain(n){n!==this.customDomain&&(n?this.setAttribute(ve.CUSTOM_DOMAIN,n):this.removeAttribute(ve.CUSTOM_DOMAIN))}get envKey(){var n;return(n=this.getAttribute(ve.ENV_KEY))!=null?n:void 0}set envKey(n){n!==this.envKey&&(n?this.setAttribute(ve.ENV_KEY,n):this.removeAttribute(ve.ENV_KEY))}get beaconCollectionDomain(){var n;return(n=this.getAttribute(ve.BEACON_COLLECTION_DOMAIN))!=null?n:void 0}set beaconCollectionDomain(n){n!==this.beaconCollectionDomain&&(n?this.setAttribute(ve.BEACON_COLLECTION_DOMAIN,n):this.removeAttribute(ve.BEACON_COLLECTION_DOMAIN))}get streamType(){var n;return(n=this.getAttribute(ve.STREAM_TYPE))!=null?n:void 0}set streamType(n){n!==this.streamType&&(n?this.setAttribute(ve.STREAM_TYPE,n):this.removeAttribute(ve.STREAM_TYPE))}get preferPlayback(){let n=this.getAttribute(ve.PREFER_PLAYBACK);if(n===Ot.MSE||n===Ot.NATIVE)return n}set preferPlayback(n){n!==this.preferPlayback&&(n===Ot.MSE||n===Ot.NATIVE?this.setAttribute(ve.PREFER_PLAYBACK,n):this.removeAttribute(ve.PREFER_PLAYBACK))}get metadata(){let n=this.getAttribute(ve.METADATA_VIDEO_ID),P=this.getAttribute(ve.METADATA_VIDEO_TITLE),L=this.getAttribute(ve.METADATA_VIEWER_USER_ID);return{...se(this,Nt),...n!=null?{video_id:n}:{},...P!=null?{video_title:P}:{},...L!=null?{viewer_user_id:L}:{}}}set metadata(n){be(this,Nt,n!=null?n:{}),this.mux&&this.mux.emit("hb",se(this,Nt))}load(){be(this,yt,Li(this,this.nativeEl,se(this,yt)))}unload(){Yr(this.nativeEl,se(this,yt)),be(this,yt,void 0)}attributeChangedCallback(n,P,L){var A,M;switch(super.attributeChangedCallback(n,P,L),n){case ve.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=L!=null?L:void 0;break;case ve.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=L!=null?L:void 0;break;case"src":{let R=!!P,O=!!L;!R&&O?Ce(this,sr,qr).call(this):R&&!O?this.unload():R&&O&&(this.unload(),Ce(this,sr,qr).call(this));break}case"autoplay":if(L===P)break;(A=se(this,yt))==null||A.setAutoplay(this.autoplay);break;case"preload":if(L===P)break;(M=se(this,yt))==null||M.setPreload(L);break;case ve.PLAYBACK_ID:this.src=Di(L!=null?L:void 0,{domain:this.customDomain});break;case ve.DEBUG:{let R=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=R);break}case ve.METADATA_URL:L&&fetch(L).then(R=>R.json()).then(R=>this.metadata=R).catch(R=>console.error(`Unable to load or parse metadata JSON from metadata-url ${L}!`));break;default:break}}disconnectedCallback(){this.unload()}};yt=new WeakMap,Ut=new WeakMap,rr=new WeakMap,Nt=new WeakMap,ir=new WeakMap,nr=new WeakMap,ar=new WeakMap,sr=new WeakSet,qr=async function(){se(this,Ut)||(await be(this,Ut,Promise.resolve()),be(this,Ut,null),this.load())};pt.customElements.get("mux-video")||(pt.customElements.define("mux-video",tr),pt.MuxVideoElement=tr);var Sa=tr;export{ve as Attributes,Ze as MediaError,Bi as VideoEvents,Sa as default};
50
+ `;var qt,Bt,xr,er,Zr,xt=class extends pt.HTMLElement{constructor(){super();Ee(this,Bt);Ee(this,er);Ee(this,qt,void 0);this.attachShadow({mode:"open"}),this.isConnected&&Ce(this,Bt,xr).call(this)}static get observedAttributes(){let n=[],I=D=>D.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(D=>{let M=!1;try{typeof this.prototype[D]=="function"&&(M=!0)}catch{}!M&&D!==D.toUpperCase()&&n.push(D.toLowerCase(),I(D))});let L=Object.getPrototypeOf(this).observedAttributes;return L&&(n=n.concat(L)),n}attributeChangedCallback(n,I,L){Ce(this,Bt,xr).call(this),Ce(this,er,Zr).call(this,n,I,L)}connectedCallback(){Ce(this,Bt,xr).call(this)}};qt=new WeakMap,Bt=new WeakSet,xr=function(){if(se(this,qt))return;be(this,qt,!0),this.shadowRoot.append(Ui.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),Bi.forEach(I=>{this.nativeEl.addEventListener(I,L=>{this.dispatchEvent(new CustomEvent(L.type,{detail:L.detail}))})});let n=this.shadowRoot.querySelector("slot");n.addEventListener("slotchange",()=>{n.assignedElements().forEach(I=>{!["track","source"].includes(I.localName)||this.nativeEl.append(I)})}),Array.prototype.forEach.call(this.attributes,I=>{Ce(this,er,Zr).call(this,I.name,null,I.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},er=new WeakSet,Zr=function(n,I,L){let D=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),M=qn(D,n),R=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;M&&!R?typeof this[M]=="boolean"?L===null?this[M]=!1:this[M]=!0:this[M]=L:L===null?this.nativeEl.removeAttribute(n):["id","class"].indexOf(n)===-1&&this.nativeEl.setAttribute(n,L)};var Ni=[],Ki=Br.createElement("video",{is:"castable-video"}),Zn=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let K=Object.getPrototypeOf(Ki);K&&K!==pt.HTMLElement.prototype;K=Object.getPrototypeOf(K))Object.getOwnPropertyNames(K).forEach(b=>{Zn.indexOf(b)===-1&&Ni.push(b)});Ni.forEach(K=>{if(K in xt.prototype)return;if(typeof Ki[K]=="function")xt.prototype[K]=function(){return this.nativeEl[K].apply(this.nativeEl,arguments)};else{let n={get(){return this.nativeEl[K]}};K!==K.toUpperCase()&&(n.set=function(I){this.nativeEl[K]=I}),Object.defineProperty(xt.prototype,K,n)}});function qn(K,b){let n=null;return K.forEach(I=>{I.toLowerCase()==b.toLowerCase()&&(n=I)}),n}pt.customElements.get("custom-video")||(pt.customElements.define("custom-video",xt),pt.CustomVideoElement=xt);var qr=xt;var ye={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_PLAYBACK:"prefer-playback",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_SOFTWARE_NAME:"player-software-name",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DISABLE_COOKIES:"disable-cookies",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time",PREFER_CMCD:"prefer-cmcd"},ea=Object.values(ye),ta=Pi(),ra="mux-video",yt,Ut,rr,Nt,ir,nr,ar,sr,ei,tr=class extends qr{constructor(){super();Ee(this,sr);Ee(this,yt,void 0);Ee(this,Ut,void 0);Ee(this,rr,void 0);Ee(this,Nt,{});Ee(this,ir,void 0);Ee(this,nr,void 0);Ee(this,ar,void 0);be(this,rr,Si())}static get observedAttributes(){var n;return[...ea,...(n=qr.observedAttributes)!=null?n:[]]}get preferCmcd(){var n;return(n=this.getAttribute(ye.PREFER_CMCD))!=null?n:void 0}set preferCmcd(n){n!==this.preferCmcd&&(n?Yr.includes(n)?this.setAttribute(ye.PREFER_CMCD,n):console.warn(`Invalid value for preferCmcd. Must be one of ${Yr.join()}`):this.removeAttribute(ye.PREFER_CMCD))}get playerInitTime(){return se(this,rr)}get playerSoftwareName(){var n;return(n=se(this,nr))!=null?n:ra}set playerSoftwareName(n){be(this,nr,n)}get playerSoftwareVersion(){var n;return(n=se(this,ir))!=null?n:ta}set playerSoftwareVersion(n){be(this,ir,n)}get _hls(){var n;return(n=se(this,yt))==null?void 0:n.engine}get mux(){return this.nativeEl.mux}get error(){var n;return(n=Ai(this.nativeEl))!=null?n:null}get errorTranslator(){return se(this,ar)}set errorTranslator(n){be(this,ar,n)}get src(){return this.getAttribute("src")}set src(n){n!==this.src&&(n==null?this.removeAttribute("src"):this.setAttribute("src",n))}get type(){var n;return(n=this.getAttribute(ye.TYPE))!=null?n:void 0}set type(n){n!==this.type&&(n?this.setAttribute(ye.TYPE,n):this.removeAttribute(ye.TYPE))}get autoplay(){let n=this.getAttribute("autoplay");return n===null?!1:n===""?!0:n}set autoplay(n){let I=this.autoplay;n!==I&&(n?this.setAttribute("autoplay",typeof n=="string"?n:""):this.removeAttribute("autoplay"))}get preload(){let n=this.getAttribute("preload");return n===""?"auto":["none","metadata","auto"].includes(n)?n:super.preload}set preload(n){n!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(n)?this.setAttribute("preload",n):this.removeAttribute("preload"))}get debug(){return this.getAttribute(ye.DEBUG)!=null}set debug(n){n!==this.debug&&(n?this.setAttribute(ye.DEBUG,""):this.removeAttribute(ye.DEBUG))}get disableCookies(){return this.hasAttribute(ye.DISABLE_COOKIES)}set disableCookies(n){n!==this.disableCookies&&(n?this.setAttribute(ye.DISABLE_COOKIES,""):this.removeAttribute(ye.DISABLE_COOKIES))}get startTime(){let n=this.getAttribute(ye.START_TIME);if(n==null)return;let I=+n;return Number.isNaN(I)?void 0:I}set startTime(n){n!==this.startTime&&(n==null?this.removeAttribute(ye.START_TIME):this.setAttribute(ye.START_TIME,`${n}`))}get playbackId(){var n;return(n=this.getAttribute(ye.PLAYBACK_ID))!=null?n:void 0}set playbackId(n){n!==this.playbackId&&(n?this.setAttribute(ye.PLAYBACK_ID,n):this.removeAttribute(ye.PLAYBACK_ID))}get customDomain(){var n;return(n=this.getAttribute(ye.CUSTOM_DOMAIN))!=null?n:void 0}set customDomain(n){n!==this.customDomain&&(n?this.setAttribute(ye.CUSTOM_DOMAIN,n):this.removeAttribute(ye.CUSTOM_DOMAIN))}get envKey(){var n;return(n=this.getAttribute(ye.ENV_KEY))!=null?n:void 0}set envKey(n){n!==this.envKey&&(n?this.setAttribute(ye.ENV_KEY,n):this.removeAttribute(ye.ENV_KEY))}get beaconCollectionDomain(){var n;return(n=this.getAttribute(ye.BEACON_COLLECTION_DOMAIN))!=null?n:void 0}set beaconCollectionDomain(n){n!==this.beaconCollectionDomain&&(n?this.setAttribute(ye.BEACON_COLLECTION_DOMAIN,n):this.removeAttribute(ye.BEACON_COLLECTION_DOMAIN))}get streamType(){var n;return(n=this.getAttribute(ye.STREAM_TYPE))!=null?n:void 0}set streamType(n){n!==this.streamType&&(n?this.setAttribute(ye.STREAM_TYPE,n):this.removeAttribute(ye.STREAM_TYPE))}get preferPlayback(){let n=this.getAttribute(ye.PREFER_PLAYBACK);if(n===Ot.MSE||n===Ot.NATIVE)return n}set preferPlayback(n){n!==this.preferPlayback&&(n===Ot.MSE||n===Ot.NATIVE?this.setAttribute(ye.PREFER_PLAYBACK,n):this.removeAttribute(ye.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(I=>I.startsWith("metadata-")&&![ye.METADATA_URL].includes(I)).reduce((I,L)=>{let D=this.getAttribute(L);return D!=null&&(I[L.replace(/^metadata-/,"").replace(/-/g,"_")]=D),I},{}),...se(this,Nt)}}set metadata(n){be(this,Nt,n!=null?n:{}),this.mux&&this.mux.emit("hb",se(this,Nt))}load(){be(this,yt,Li(this,this.nativeEl,se(this,yt)))}unload(){zr(this.nativeEl,se(this,yt)),be(this,yt,void 0)}attributeChangedCallback(n,I,L){var D,M;switch(super.attributeChangedCallback(n,I,L),n){case ye.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=L!=null?L:void 0;break;case ye.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=L!=null?L:void 0;break;case"src":{let R=!!I,O=!!L;!R&&O?Ce(this,sr,ei).call(this):R&&!O?this.unload():R&&O&&(this.unload(),Ce(this,sr,ei).call(this));break}case"autoplay":if(L===I)break;(D=se(this,yt))==null||D.setAutoplay(this.autoplay);break;case"preload":if(L===I)break;(M=se(this,yt))==null||M.setPreload(L);break;case ye.PLAYBACK_ID:this.src=Di(L!=null?L:void 0,{domain:this.customDomain});break;case ye.DEBUG:{let R=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=R);break}case ye.METADATA_URL:L&&fetch(L).then(R=>R.json()).then(R=>this.metadata=R).catch(R=>console.error(`Unable to load or parse metadata JSON from metadata-url ${L}!`));break;default:break}}disconnectedCallback(){this.unload()}};yt=new WeakMap,Ut=new WeakMap,rr=new WeakMap,Nt=new WeakMap,ir=new WeakMap,nr=new WeakMap,ar=new WeakMap,sr=new WeakSet,ei=async function(){se(this,Ut)||(await be(this,Ut,Promise.resolve()),be(this,Ut,null),this.load())};pt.customElements.get("mux-video")||(pt.customElements.define("mux-video",tr),pt.MuxVideoElement=tr);var Sa=tr;export{ye as Attributes,Ze as MediaError,Bi as VideoEvents,Sa as default};
51
51
  /*!
52
52
  * JavaScript Cookie v2.1.3
53
53
  * https://github.com/js-cookie/js-cookie