@mux/playback-core 0.15.0 → 0.16.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,35 @@
1
- "use strict";(()=>{var xi=Object.create;var Sr=Object.defineProperty;var Si=Object.getOwnPropertyDescriptor;var Di=Object.getOwnPropertyNames;var Li=Object.getPrototypeOf,Ai=Object.prototype.hasOwnProperty;var Dr=(j,R)=>()=>(R||j((R={exports:{}}).exports,R),R.exports);var _i=(j,R,m,M)=>{if(R&&typeof R=="object"||typeof R=="function")for(let _ of Di(R))!Ai.call(j,_)&&_!==m&&Sr(j,_,{get:()=>R[_],enumerable:!(M=Si(R,_))||M.enumerable});return j};var jt=(j,R,m)=>(m=j!=null?xi(Li(j)):{},_i(R||!j||!j.__esModule?Sr(m,"default",{value:j,enumerable:!0}):m,j));var Lr=Dr((Gt,sr)=>{(function(){var j,R;j=this,R=function(){return function(){var m={80:function(L,C,b){L.exports=b(728).default},728:function(L,C,b){"use strict";b.d(C,{default:function(){return Ti}});var O=b(48),A=b.n(O),y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(w){var I=16*Math.random()|0;return(w==="x"?I:3&I|8).toString(16)})},T=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},D=function(w){return w&&w.nodeName!==void 0?(w.muxId||(w.muxId=w.id||T()),w.muxId):w},E=function(w){var I;w&&w.nodeName!==void 0?w=D(I=w):I=document.querySelector(w);var F=I&&I.nodeName?I.nodeName.toLowerCase():"";return[I,w,F]},g=b(640),p=b.n(g),u=p().methodFactory;p().methodFactory=function(w,I,F){var N=u(w,I,F);return function(){for(var K=["[mux]"],V=0;V<arguments.length;V++)K.push(arguments[V]);N.apply(void 0,K)}},p().setLevel(p().getLevel());var e=p();function s(){return(A().doNotTrack||A().navigator&&A().navigator.doNotTrack)==="1"}var c={now:function(){var w=A().performance,I=w&&w.timing,F=w&&w.timeOrigin||I&&I.navigationStart;return typeof F=="number"&&typeof w.now=="function"?F+w.now():Date.now()}},v=b(678),i=b.n(v),r=function(w){return o(w)[0]},o=function(w){if(typeof w!="string"||w==="")return["localhost"];var I,F=(w.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return F&&(I=(F.match(/[^\.]+\.[^\.]+$/)||[])[0]),[F,I]},d={exists:function(){var w=A().performance;return(w&&w.timing)!==void 0},domContentLoadedEventEnd:function(){var w=A().performance,I=w&&w.timing;return I&&I.domContentLoadedEventEnd},navigationStart:function(){var w=A().performance,I=w&&w.timing;return I&&I.navigationStart}};function t(w,I,F){F=F===void 0?1:F,w[I]=w[I]||0,w[I]+=F}var n=["x-cdn","content-type","x-request-id"];function l(w){var I={};return(w=w||"").trim().split(/[\r\n]+/).forEach(function(F){if(F){var N=F.split(": "),K=N.shift();K&&(n.indexOf(K.toLowerCase())>=0||K.toLowerCase().indexOf("x-litix-")===0)&&(I[K]=N.join(": "))}}),I}var a=function(w){var I={};for(var F in w){var N=w[F];N["DATA-ID"].search("io.litix.data.")!==-1&&(I[N["DATA-ID"].replace("io.litix.data.","")]=N.VALUE)}return I};function f(w,I){var F=Object.keys(w);if(Object.getOwnPropertySymbols){var N=Object.getOwnPropertySymbols(w);I&&(N=N.filter(function(K){return Object.getOwnPropertyDescriptor(w,K).enumerable})),F.push.apply(F,N)}return F}function h(w){for(var I=1;I<arguments.length;I++){var F=arguments[I]!=null?arguments[I]:{};I%2?f(Object(F),!0).forEach(function(N){S(w,N,F[N])}):Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(F)):f(Object(F)).forEach(function(N){Object.defineProperty(w,N,Object.getOwnPropertyDescriptor(F,N))})}return w}function S(w,I,F){return I in w?Object.defineProperty(w,I,{value:F,enumerable:!0,configurable:!0,writable:!0}):w[I]=F,w}var x=function(w){if(!w)return{};var I=d.navigationStart(),F=w.loading,N=F?F.start:w.trequest,K=F?F.first:w.tfirst,V=F?F.end:w.tload;return{bytesLoaded:w.total,requestStart:Math.round(I+N),responseStart:Math.round(I+K),responseEnd:Math.round(I+V)}},P=function(w){if(w&&typeof w.getAllResponseHeaders=="function")return l(w.getAllResponseHeaders())},k=function(w,I){if(!w||typeof w.getRequests!="function")return{};var F=w.getRequests({state:"executed"});if(F.length===0)return{};var N,K=F[F.length-1],V=r(K.url),H=K.bytesLoaded,Q=new Date(K.requestStartDate).getTime(),J=new Date(K.firstByteDate).getTime(),X=new Date(K.requestEndDate).getTime(),ee=isNaN(K.duration)?0:K.duration,ce=typeof I.getMetricsFor=="function"?I.getMetricsFor(K.mediaType).HttpList:I.getDashMetrics().getHttpRequests(K.mediaType);return ce.length>0&&(N=l(ce[ce.length-1]._responseHeaders||"")),{requestStart:Q,requestResponseStart:J,requestResponseEnd:X,requestBytesLoaded:H,requestResponseHeaders:N,requestMediaDuration:ee,requestHostname:V}},B=function(w,I){var F=I.getQualityFor(w),N=I.getCurrentTrackFor(w).bitrateList;return N?{currentLevel:F,renditionWidth:N[F].width||null,renditionHeight:N[F].height||null,renditionBitrate:N[F].bandwidth}:{}};function U(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var W=0,G=function(){function w(){(function(K,V){if(!(K instanceof V))throw new TypeError("Cannot call a class as a function")})(this,w)}var I,F,N;return I=w,F=[{key:"on",value:function(K,V,H){return V._eventEmitterGuid=V._eventEmitterGuid||++W,this._listeners=this._listeners||{},this._listeners[K]=this._listeners[K]||[],H&&(V=V.bind(H)),this._listeners[K].push(V),V}},{key:"off",value:function(K,V){var H=this._listeners&&this._listeners[K];H&&H.forEach(function(Q,J){Q._eventEmitterGuid===V._eventEmitterGuid&&H.splice(J,1)})}},{key:"one",value:function(K,V,H){var Q=this;V._eventEmitterGuid=V._eventEmitterGuid||++W;var J=function X(){Q.off(K,X),V.apply(H||this,arguments)};J._eventEmitterGuid=V._eventEmitterGuid,this.on(K,J)}},{key:"emit",value:function(K,V){var H=this;if(this._listeners){V=V||{};var Q=this._listeners["before*"]||[],J=this._listeners[K]||[],X=this._listeners["after"+K]||[],ee=function(ce,ye){(ce=ce.slice()).forEach(function(ve){ve.call(H,{type:K},ye)})};ee(Q,V),ee(J,V),ee(X,V)}}}],F&&U(I.prototype,F),N&&U(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}(),z=G;function Y(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var $=function(){function w(K){var V=this;(function(H,Q){if(!(H instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,K.on("playing",function(){V._playheadShouldBeProgressing=!0}),K.on("play",this._startPlaybackHeartbeatInterval.bind(this)),K.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),K.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),K.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),K.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),K.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),K.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),K.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),K.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),K.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("seeked",function(){K.data.player_is_paused?V._stopPlaybackHeartbeatInterval():V._startPlaybackHeartbeatInterval()}),K.on("timeupdate",function(){V._playbackHeartbeatInterval!==null&&K.emit("playbackheartbeat")}),K.on("devicesleep",function(H,Q){V._playbackHeartbeatInterval!==null&&(A().clearInterval(V._playbackHeartbeatInterval),K.emit("playbackheartbeatend",{viewer_time:Q.viewer_time}),V._playbackHeartbeatInterval=null)})}var I,F,N;return I=w,(F=[{key:"_startPlaybackHeartbeatInterval",value:function(){var K=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=A().setInterval(function(){K.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(A().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Y(I.prototype,F),N&&Y(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function Z(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function q(w,I,F){return I&&Z(w.prototype,I),F&&Z(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var ie=q(function w(I){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),I.on("viewinit",function(){F.viewErrored=!1}),I.on("error",function(){try{var N=I.errorTranslator({player_error_code:I.data.player_error_code,player_error_message:I.data.player_error_message});N?(I.data.player_error_code=N.player_error_code,I.data.player_error_message=N.player_error_message,F.viewErrored=!0):(delete I.data.player_error_code,delete I.data.player_error_message)}catch(K){I.mux.log.warn("Exception in error translator callback.",K),F.viewErrored=!0}})});function ne(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var ae=function(){function w(K){(function(V,H){if(!(V instanceof H))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,this._watchTimeTrackerLastCheckedTime=null,K.on("playbackheartbeat",this._updateWatchTime.bind(this)),K.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var I,F,N;return I=w,(F=[{key:"_updateWatchTime",value:function(K,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(K,V){this._updateWatchTime(K,V),this._watchTimeTrackerLastCheckedTime=null}}])&&ne(I.prototype,F),N&&ne(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function te(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var fe=function(){function w(K){(function(V,H){if(!(V instanceof H))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,this._playbackTimeTrackerLastPlayheadPosition=-1,K.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),K.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),K.on("seeking",this._clearPlaybackTimeState.bind(this))}var I,F,N;return I=w,(F=[{key:"_updatePlaybackTime",value:function(){var K=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&K>this._playbackTimeTrackerLastPlayheadPosition){var V=K-this._playbackTimeTrackerLastPlayheadPosition;V<=1e3&&t(this.pm.data,"view_content_playback_time",V)}this._playbackTimeTrackerLastPlayheadPosition=K}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&te(I.prototype,F),N&&te(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function de(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var re=function(){function w(K){(function(H,Q){if(!(H instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K;var V=this._updatePlayheadTime.bind(this);K.on("playbackheartbeat",V),K.on("playbackheartbeatend",V),K.on("timeupdate",V),K.on("destroy",function(){K.off("timeupdate",V)})}var I,F,N;return I=w,(F=[{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(K,V){var H=this,Q=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,Q(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var J=this.pm.getPlayheadTime();J!==void 0&&(this.pm.data.player_playhead_time=J,Q(),this._updateMaxPlayheadPosition())}}}])&&de(I.prototype,F),N&&de(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function Ee(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function me(w,I,F){return I&&Ee(w.prototype,I),F&&Ee(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Te=me(function w(I){if(function(K,V){if(!(K instanceof V))throw new TypeError("Cannot call a class as a function")}(this,w),!I.disableRebufferTracking){var F,N=function(){if(F){var K=I.data.viewer_time-F;t(I.data,"view_rebuffer_duration",K),F=I.data.viewer_time}I.data.view_watch_time>=0&&I.data.view_rebuffer_count>0&&(I.data.view_rebuffer_frequency=I.data.view_rebuffer_count/I.data.view_watch_time,I.data.view_rebuffer_percentage=I.data.view_rebuffer_duration/I.data.view_watch_time)};I.on("playbackheartbeat",function(){return N()}),I.on("rebufferstart",function(){F||(t(I.data,"view_rebuffer_count",1),F=I.data.viewer_time,I.one("rebufferend",function(){N(),F=void 0}))})}});function Me(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var Ae=function(){function w(K){var V=this;(function(H,Q){if(!(H instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,K.disableRebufferTracking||K.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,K.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),K.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),K.on("seeking",function(){V._cleanupRebufferTracker(null,{viewer_time:c.now()})}))}var I,F,N;return I=w,F=[{key:"_checkIfRebuffering",value:function(K,V){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(K,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(K,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(K){this._lastCheckedTime=K,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=K}},{key:"_cleanupRebufferTracker",value:function(K,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 Q=this.pm.data.player_playhead_time-this._lastPlayheadTime,J=V.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&Q>0&&J-Q>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+J-Q}))}H?this._prepareRebufferTrackerState(V.viewer_time):this._clearRebufferTrackerState()}}],F&&Me(I.prototype,F),N&&Me(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}(),we=Ae;function Re(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var ke=function(){function w(K){var V=this;(function(H,Q){if(!(H instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,K.on("viewinit",function(){var H=K.data,Q=H.view_id;if(!H.view_program_changed){var J=function(X,ee){var ce=ee.viewer_time;X.type==="playing"&&K.data.view_time_to_first_frame===void 0?V.calculateTimeToFirstFrame(ce||c.now(),Q):X.type!=="adplaying"||K.data.view_time_to_first_frame!==void 0&&!V._inPrerollPosition()||V.calculateTimeToFirstFrame(ce||c.now(),Q)};K.one("playing",J),K.one("adplaying",J),K.one("viewend",function(){K.off("playing",J),K.off("adplaying",J)})}})}var I,F,N;return I=w,(F=[{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(K,V){V===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:K}),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))}}])&&Re(I.prototype,F),N&&Re(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function _e(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function Be(w,I,F){return I&&_e(w.prototype,I),F&&_e(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Ke=Be(function w(I){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),I.on("viewinit",function(){F._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(N){I.on(N,function(){if(F._lastPlayheadPosition>=0&&I.data.player_playhead_time>=0&&F._lastPlayerWidth>=0&&F._lastSourceWidth>0&&F._lastPlayerHeight>=0&&F._lastSourceHeight>0){var K=I.data.player_playhead_time-F._lastPlayheadPosition;if(K<0)return void(F._lastPlayheadPosition=-1);var V=Math.min(F._lastPlayerWidth/F._lastSourceWidth,F._lastPlayerHeight/F._lastSourceHeight),H=Math.max(0,V-1),Q=Math.max(0,1-V);I.data.view_max_upscale_percentage=Math.max(I.data.view_max_upscale_percentage||0,H),I.data.view_max_downscale_percentage=Math.max(I.data.view_max_downscale_percentage||0,Q),t(I.data,"view_total_content_playback_time",K),t(I.data,"view_total_upscaling",H*K),t(I.data,"view_total_downscaling",Q*K)}F._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(N){I.on(N,function(){F._lastPlayheadPosition=I.data.player_playhead_time,F._lastPlayerWidth=I.data.player_width,F._lastPlayerHeight=I.data.player_height,F._lastSourceWidth=I.data.video_source_width,F._lastSourceHeight=I.data.video_source_height})})});function We(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function Ue(w,I,F){return I&&We(w.prototype,I),F&&We(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Ze=Ue(function w(I){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),this.isSeeking=!1,I.on("seeking",function(N,K){i()(I.data,K),F._lastSeekingTime=c.now(),F.isSeeking===!1&&(F.isSeeking=!0,I.send("seeking"))}),I.on("seeked",function(){F.isSeeking=!1;var N=F._lastSeekingTime||c.now(),K=c.now()-N;t(I.data,"view_seek_count",1),t(I.data,"view_seek_duration",K);var V=I.data.view_max_seek_time||0;I.data.view_max_seek_time=Math.max(V,K)}),I.on("viewend",function(){F.isSeeking=!1})});function Ce(w,I){return function(F){if(Array.isArray(F))return F}(w)||function(F,N){var K=F==null?null:typeof Symbol!="undefined"&&F[Symbol.iterator]||F["@@iterator"];if(K!=null){var V,H,Q=[],J=!0,X=!1;try{for(K=K.call(F);!(J=(V=K.next()).done)&&(Q.push(V.value),!N||Q.length!==N);J=!0);}catch(ee){X=!0,H=ee}finally{try{J||K.return==null||K.return()}finally{if(X)throw H}}return Q}}(w,I)||function(F,N){if(F){if(typeof F=="string")return qe(F,N);var K=Object.prototype.toString.call(F).slice(8,-1);return K==="Object"&&F.constructor&&(K=F.constructor.name),K==="Map"||K==="Set"?Array.from(F):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?qe(F,N):void 0}}(w,I)||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 qe(w,I){(I==null||I>w.length)&&(I=w.length);for(var F=0,N=new Array(I);F<I;F++)N[F]=w[F];return N}function Oe(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var Pe=function(w,I){w.push(I),w.sort(function(F,N){return F.viewer_time-N.viewer_time})},Ve=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Ie=function(){function w(K){var V=this;(function(Q,J){if(!(Q instanceof J))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,K.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}),Ve.forEach(function(Q){return K.on(Q,V._updateAdData.bind(V))});var H=function(){V.isAdBreak=!1};K.on("adbreakstart",function(){V.isAdBreak=!0}),K.on("play",H),K.on("playing",H),K.on("viewend",H),K.on("adrequest",function(Q,J){J=i()({ad_request_id:"generatedAdRequestId"+V._currentAdRequestNumber++},J),Pe(V._adRequests,J),t(K.data,"view_ad_request_count"),V.inPrerollPosition()&&(K.data.view_preroll_requested=!0,V._adHasPlayed||t(K.data,"view_preroll_request_count"))}),K.on("adresponse",function(Q,J){J=i()({ad_request_id:"generatedAdRequestId"+V._currentAdResponseNumber++},J),Pe(V._adResponses,J);var X=V.findAdRequest(J.ad_request_id);X&&t(K.data,"view_ad_request_time",Math.max(0,J.viewer_time-X.viewer_time))}),K.on("adplay",function(Q,J){V._adHasPlayed=!0,V._wouldBeNewAdPlay&&(V._wouldBeNewAdPlay=!1,t(K.data,"view_ad_played_count")),V.inPrerollPosition()&&!K.data.view_preroll_played&&(K.data.view_preroll_played=!0,V._adRequests.length>0&&(K.data.view_preroll_request_time=Math.max(0,J.viewer_time-V._adRequests[0].viewer_time)),K.data.view_start&&(K.data.view_startup_preroll_request_time=Math.max(0,J.viewer_time-K.data.view_start)),V._prerollPlayTime=J.viewer_time)}),K.on("adplaying",function(Q,J){V.inPrerollPosition()&&K.data.view_preroll_load_time===void 0&&V._prerollPlayTime!==void 0&&(K.data.view_preroll_load_time=J.viewer_time-V._prerollPlayTime,K.data.view_startup_preroll_load_time=J.viewer_time-V._prerollPlayTime)}),K.on("adended",function(){V._wouldBeNewAdPlay=!0}),K.on("aderror",function(){V._wouldBeNewAdPlay=!0})}var I,F,N;return I=w,(F=[{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(K){for(var V=0;V<this._adRequests.length;V++)if(this._adRequests[V].ad_request_id===K)return this._adRequests[V]}},{key:"_updateAdData",value:function(K,V){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&V.ad_tag_url){var H=Ce(o(V.ad_tag_url),2),Q=H[0],J=H[1];this.pm.data.view_preroll_ad_tag_domain=J,this.pm.data.view_preroll_ad_tag_hostname=Q}if(!this.pm.data.view_preroll_ad_asset_hostname&&V.ad_asset_url){var X=Ce(o(V.ad_asset_url),2),ee=X[0],ce=X[1];this.pm.data.view_preroll_ad_asset_domain=ce,this.pm.data.view_preroll_ad_asset_hostname=ee}}}}])&&Oe(I.prototype,F),N&&Oe(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function Le(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function rt(w,I,F){return I&&Le(w.prototype,I),F&&Le(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var je=rt(function w(I){var F,N;(function(Q,J){if(!(Q instanceof J))throw new TypeError("Cannot call a class as a function")})(this,w);var K=function(){I.disableRebufferTracking||F&&(t(I.data,"view_waiting_rebuffer_duration",c.now()-F),F=!1,A().clearInterval(N))},V=!1,H=function(){V=!1,K()};I.on("waiting",function(){V&&(I.disableRebufferTracking||(t(I.data,"view_waiting_rebuffer_count",1),F=c.now(),N=A().setInterval(function(){if(F){var Q=c.now();t(I.data,"view_waiting_rebuffer_duration",Q-F),F=Q}},250)))}),I.on("playing",function(){K(),V=!0}),I.on("pause",H),I.on("seeking",H)});function st(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function vt(w,I,F){return I&&st(w.prototype,I),F&&st(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var ze=vt(function w(I){var F=this;(function(V,H){if(!(V instanceof H))throw new TypeError("Cannot call a class as a function")})(this,w);var N=function(){F.lastWallClockTime=c.now(),I.on("before*",K)},K=function(V){var H=c.now(),Q=F.lastWallClockTime;F.lastWallClockTime=H,H-Q>3e4&&(I.emit("devicesleep",{viewer_time:Q}),i()(I.data,{viewer_time:Q}),I.send("devicesleep"),I.emit("devicewake",{viewer_time:H}),i()(I.data,{viewer_time:H}),I.send("devicewake"))};I.one("playbackheartbeat",N),I.on("playbackheartbeatend",function(){I.off("before*",K),I.one("playbackheartbeat",N)})}),xt=b(375),gt=b(655),it=b.n(gt),ot="muxData",nt=function(){var w;try{w=xt.parse(it().get(ot)||"")}catch{w={}}return w},mt=function(w){try{it().set(ot,xt.stringify(w),{expires:7300})}catch{}},ct=function(){var w=nt();return w.mux_viewer_id=w.mux_viewer_id||y(),w.msn=w.msn||Math.random(),mt(w),{mux_viewer_id:w.mux_viewer_id,mux_sample_number:w.msn}};function Qt(w,I){var F=I.beaconCollectionDomain,N=I.beaconDomain;if(F)return"https://"+F;var K=N||"litix.io";return(w=w||"inferred").match(/^[a-z0-9]+$/)?"https://"+w+"."+K:"https://img.litix.io/a.gif"}var bt=function(){var w;switch(St()){case"cellular":w="cellular";break;case"ethernet":w="wired";break;case"wifi":w="wifi";break;case void 0:break;default:w="other"}return w},St=function(){var w=A().navigator,I=w&&(w.connection||w.mozConnection||w.webkitConnection);return I&&I.type};bt.getConnectionFromAPI=St;var Xe=bt,kt=Bt({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"}),Rt=Bt({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 Bt(w){var I={};for(var F in w)w.hasOwnProperty(F)&&(I[w[F]]=F);return I}function Pt(w){var I={},F={};return Object.keys(w).forEach(function(N){var K=!1;if(w.hasOwnProperty(N)&&w[N]!==void 0){var V=N.split("_"),H=V[0],Q=kt[H];Q||(e.info("Data key word `"+V[0]+"` not expected in "+N),Q=H+"_"),V.splice(1).forEach(function(J){J==="url"&&(K=!0),Rt[J]?Q+=Rt[J]:Number(J)&&Math.floor(Number(J))===Number(J)?Q+=J:(e.info("Data key word `"+J+"` not expected in "+N),Q+="_"+J+"_")}),K?F[Q]=w[N]:I[Q]=w[N]}}),i()(I,F)}var $t={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},Jt=["hb","requestcompleted","requestfailed","requestcanceled"],at=function(w,I){this._beaconUrl=w||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=i()({},$t,I)};at.prototype.queueEvent=function(w,I){var F=i()({},I);return(this._eventQueue.length<=this._options.maxQueueLength||w==="eventrateexceeded")&&(this._eventQueue.push(F),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},at.prototype.flushEvents=function(){this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()},at.prototype.destroy=function(){var w=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,w?this._clearBeaconQueue():this.flushEvents(),A().clearTimeout(this._sendTimeout)},at.prototype._clearBeaconQueue=function(){var w=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,I=this._eventQueue.slice(w);w>0&&i()(I[I.length-1],Pt({mux_view_message:"event queue truncated"}));var F=this._createPayload(I);Dt(this._beaconUrl,F,!0,function(){})},at.prototype._sendBeaconQueue=function(){var w=this;if(!this._postInFlight){var I=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var F=this._createPayload(I),N=c.now();Dt(this._beaconUrl,F,!1,function(K,V){V?(w._eventQueue=I.concat(w._eventQueue),w._failureCount+=1,e.info("Error sending beacon: "+V)):w._failureCount=0,w._roundTripTime=c.now()-N,w._postInFlight=!1})}},at.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var w=Math.pow(2,this._failureCount-1);return(1+(w*=Math.random()))*this._options.baseTimeBetweenBeacons},at.prototype._startBeaconSending=function(){var w=this;A().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=A().setTimeout(function(){w._eventQueue.length&&w._sendBeaconQueue(),w._startBeaconSending()},this._getNextBeaconTime()))},at.prototype._createPayload=function(w){var I,F,N,K=this,V={transmission_timestamp:Math.round(c.now())};this._roundTripTime&&(V.rtt_ms=Math.round(this._roundTripTime));var H=function(){I=JSON.stringify({metadata:V,events:F||w}),N=I.length/1024},Q=function(){return N<=K._options.maxPayloadKBSize};return H(),Q()||(e.info("Payload size is too big ("+N+" kb). Removing unnecessary events."),F=w.filter(function(J){return Jt.indexOf(J.e)===-1}),H()),Q()||(e.info("Payload size still too big ("+N+" kb). Cropping fields.."),F.forEach(function(J){for(var X in J){var ee=J[X];typeof ee=="string"&&ee.length>51200&&(J[X]=ee.substring(0,51200))}}),H()),I};var Dt=function(w,I,F,N){if(F&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(w,I))N();else if(A().fetch)A().fetch(w,{method:"POST",body:I,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(A().XMLHttpRequest){var K=new(A()).XMLHttpRequest;return K.onreadystatechange=function(){if(K.readyState===4)return N(null,K.status!==200?"error":void 0)},K.open("POST",w),K.setRequestHeader("Content-Type","text/plain"),void K.send(I)}N()}},Ut=at;function pt(w){return pt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(I){return typeof I}:function(I){return I&&typeof Symbol=="function"&&I.constructor===Symbol&&I!==Symbol.prototype?"symbol":typeof I},pt(w)}var Zt=["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"],jr=["viewstart","error","ended","viewend"],Nt=function(w,I){var F=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=w,this.envKey=I,this.eventQueue=new Ut(Qt(I,F)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=F.sampleRate,this.disableCookies=F.disableCookies,this.respectDoNotTrack=F.respectDoNotTrack;var N=F.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 K=Xe();K&&(this.pageLevelData=i()(this.pageLevelData,{viewer_connection_type:K})),A()!==void 0&&A().location&&A().location.href&&(this.pageLevelData.page_url=A().location.href),this.viewerData=this.disableCookies?{}:ct()};Nt.prototype.send=function(w,I){if(w){if(this.respectDoNotTrack&&s())return e.info("Not sending `"+w+"` because Do Not Track is enabled");if(!I||pt(I)!=="object")return e.error("A data object was expected in send() but was not provided");var F,N,K=this.disableCookies?{}:(F=nt(),N=c.now(),F.session_start&&(F.sst=F.session_start,delete F.session_start),F.session_id&&(F.sid=F.session_id,delete F.session_id),F.session_expires&&(F.sex=F.session_expires,delete F.session_expires),(!F.sex||F.sex<N)&&(F.sid=y(),F.sst=N),F.sex=N+15e5,mt(F),{session_id:F.sid,session_start:F.sst,session_expires:F.sex}),V={};i()(V,this.pageLevelData),i()(V,I),i()(V,K),i()(V,this.viewerData),V.event=w,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,Q=Pt(this._deduplicateBeaconData(w,V));if(this.lastEventTime=this.mux.utils.now(),H)return e.info("Not sending event due to sample rate restriction",w,V,Q);if(this.envKey||e.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",w,V,Q),!this.rateLimited){if(e.info("Sending event",w,V,Q),this.rateLimited=!this.eventQueue.queueEvent(w,Q),this.mux.WINDOW_UNLOADING&&w==="viewend")this.eventQueue.destroy(!0);else if((jr.indexOf(w)>=0||this.mux.WINDOW_HIDDEN&&w==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return V.event="eventrateexceeded",Q=Pt(V),this.eventQueue.queueEvent(V.event,Q),e.error("Beaconing disabled due to rate limit.")}}},Nt.prototype.destroy=function(){this.eventQueue.destroy(!1)},Nt.prototype._deduplicateBeaconData=function(w,I){var F=this,N={},K=I.view_id;if(!K||w==="viewstart"||w==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)N=i()({},I),K&&(this.previousBeaconData=N),K&&w==="viewend"&&(this.previousBeaconData=null);else{var V=w.indexOf("request")===0;Object.keys(I).forEach(function(H){var Q=I[H];(Q!==F.previousBeaconData[H]||Zt.indexOf(H)>-1||function(J,X,ee,ce){return!(!J||X.indexOf("request_")!==0||X!=="request_response_headers"&&pt(ee)==="object"&&pt(ce)==="object"&&Object.keys(ee||{}).length===Object.keys(ce||{}).length)}(V,H,Q,F.previousBeaconData[H])||function(J,X){return J==="renditionchange"&&X.indexOf("video_source_")===0}(w,H))&&(N[H]=Q,F.previousBeaconData[H]=Q)})}return N};var Gr=Nt;function vr(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function Hr(w,I,F){return I&&vr(w.prototype,I),F&&vr(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Vr=Hr(function w(I){(function(X,ee){if(!(X instanceof ee))throw new TypeError("Cannot call a class as a function")})(this,w);var F=0,N=0,K=0,V=0,H=0,Q=0,J=0;I.on("requestcompleted",function(X,ee){var ce,ye,ve=ee.request_start,se=ee.request_response_start,le=ee.request_response_end,xe=ee.request_bytes_loaded;if(V++,se?(ce=se-ve,ye=le-se):ye=le-ve,ye>0&&xe>0){var Ye=xe/ye*8e3;H++,N+=xe,K+=ye,I.data.view_min_request_throughput=Math.min(I.data.view_min_request_throughput||1/0,Ye),I.data.view_average_request_throughput=N/K*8e3,I.data.view_request_count=V,ce>0&&(F+=ce,I.data.view_max_request_latency=Math.max(I.data.view_max_request_latency||0,ce),I.data.view_average_request_latency=F/H)}}),I.on("requestfailed",function(X,ee){V++,Q++,I.data.view_request_count=V,I.data.view_request_failed_count=Q}),I.on("requestcanceled",function(X,ee){V++,J++,I.data.view_request_count=V,I.data.view_request_canceled_count=J})});function gr(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function Yr(w,I,F){return I&&gr(w.prototype,I),F&&gr(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var zr=Yr(function w(I){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),I.on("before*",function(N,K){var V=K.viewer_time,H=c.now(),Q=F._lastEventTime;if(F._lastEventTime=H,Q&&H-Q>36e5){var J=Object.keys(I.data).reduce(function(X,ee){return ee.indexOf("video_")===0?i()(X,function(ce,ye,ve){return ye in ce?Object.defineProperty(ce,ye,{value:ve,enumerable:!0,configurable:!0,writable:!0}):ce[ye]=ve,ce}({},ee,I.data[ee])):X},{});I.mux.log.info("Received event after at least an hour inactivity, creating a new view"),I.emit("viewinit",i()({viewer_time:V},J)),I.playbackHeartbeat._playheadShouldBeProgressing&&N.type!=="play"&&N.type!=="adbreakstart"&&(I.emit("play",{viewer_time:V}),N.type!=="playing"&&I.emit("playing",{viewer_time:V}))}})});function qt(w){return qt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(I){return typeof I}:function(I){return I&&typeof Symbol=="function"&&I.constructor===Symbol&&I!==Symbol.prototype?"symbol":typeof I},qt(w)}function Xr(w,I){return function(F){if(Array.isArray(F))return F}(w)||function(F,N){var K=F==null?null:typeof Symbol!="undefined"&&F[Symbol.iterator]||F["@@iterator"];if(K!=null){var V,H,Q=[],J=!0,X=!1;try{for(K=K.call(F);!(J=(V=K.next()).done)&&(Q.push(V.value),!N||Q.length!==N);J=!0);}catch(ee){X=!0,H=ee}finally{try{J||K.return==null||K.return()}finally{if(X)throw H}}return Q}}(w,I)||function(F,N){if(F){if(typeof F=="string")return mr(F,N);var K=Object.prototype.toString.call(F).slice(8,-1);return K==="Object"&&F.constructor&&(K=F.constructor.name),K==="Map"||K==="Set"?Array.from(F):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?mr(F,N):void 0}}(w,I)||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 mr(w,I){(I==null||I>w.length)&&(I=w.length);for(var F=0,N=new Array(I);F<I;F++)N[F]=w[F];return N}function pr(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function er(w,I){return er=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(F,N){return F.__proto__=N,F},er(w,I)}function Qr(w){var I=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 F,N=Kt(w);if(I){var K=Kt(this).constructor;F=Reflect.construct(N,arguments,K)}else F=N.apply(this,arguments);return $r(this,F)}}function $r(w,I){if(I&&(qt(I)==="object"||typeof I=="function"))return I;if(I!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Fe(w)}function Fe(w){if(w===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return w}function Kt(w){return Kt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(I){return I.__proto__||Object.getPrototypeOf(I)},Kt(w)}var Jr=["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"],Zr=function(w){(function(H,Q){if(typeof Q!="function"&&Q!==null)throw new TypeError("Super expression must either be null or a function");H.prototype=Object.create(Q&&Q.prototype,{constructor:{value:H,writable:!0,configurable:!0}}),Object.defineProperty(H,"prototype",{writable:!1}),Q&&er(H,Q)})(V,w);var I,F,N,K=Qr(V);function V(H,Q,J){var X;(function(se,le){if(!(se instanceof le))throw new TypeError("Cannot call a class as a function")})(this,V),(X=K.call(this)).DOM_CONTENT_LOADED_EVENT_END=d.domContentLoadedEventEnd(),X.NAVIGATION_START=d.navigationStart(),X.mux=H,X.id=Q,(J=i()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(se){return se}},J)).data=J.data||{},J.data.property_key&&(J.data.env_key=J.data.property_key,delete J.data.property_key),e.setLevel(J.debug?"debug":"warn"),X.getPlayheadTime=J.getPlayheadTime,X.getStateData=J.getStateData||function(){return{}},X.getAdData=J.getAdData||function(){},X.minimumRebufferDuration=J.minimumRebufferDuration,X.sustainedRebufferThreshold=J.sustainedRebufferThreshold,X.playbackHeartbeatTime=J.playbackHeartbeatTime,X.disableRebufferTracking=J.disableRebufferTracking,X.disableRebufferTracking&&X.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."),X.disablePlayheadRebufferTracking=J.disablePlayheadRebufferTracking,X.errorTranslator=J.errorTranslator,X.playbackEventDispatcher=new Gr(H,J.data.env_key,J),X.data={player_instance_id:y(),mux_sample_rate:J.sampleRate,beacon_domain:J.beaconCollectionDomain?J.beaconCollectionDomain:J.beaconDomain},X.data.view_sequence_number=1,X.data.player_sequence_number=1,X.oldEmit=X.emit,X.emit=function(se,le){le=i()({viewer_time:this.mux.utils.now()},le),this.oldEmit(se,le)};var ee=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(Fe(X));X.on("viewinit",function(se,le){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),i()(this.data,le),this._initializeViewData(),this.one("play",ee),this.one("adbreakstart",ee)});var ce=function(se){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",se)}.bind(Fe(X));if(X.on("videochange",function(se,le){ce(le)}),X.on("programchange",function(se,le){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."),ce(i()(le,{view_program_changed:!0})),ee(),this.emit("play"),this.emit("playing")}),X.on("fragmentchange",function(se,le){this.currentFragmentPDT=le.currentFragmentPDT,this.currentFragmentStart=le.currentFragmentStart}),X.on("destroy",X.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ye=function(){var se=X.data.view_start!==void 0;X.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",se&&X.mux.WINDOW_HIDDEN&&(X.data.player_is_paused||X.emit("hb"))};window.addEventListener("visibilitychange",ye,!1);var ve=function(se){se.persisted||X.destroy()};window.addEventListener("pagehide",ve,!1),X.on("destroy",function(){window.removeEventListener("visibilitychange",ye),window.removeEventListener("pagehide",ve)})}return X.on("playerready",function(se,le){i()(this.data,le)}),Jr.forEach(function(se){X.on(se,function(le,xe){se.indexOf("ad")!==0&&this._updateStateData(),i()(this.data,xe),this._sanitizeData()}),X.on("after"+se,function(){(se!=="error"||this.errorTracker.viewErrored)&&this.send(se)})}),X.on("viewend",function(se,le){i()(X.data,le)}),X.one("playerready",function(se){var le=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=le-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}),X.longResumeTracker=new zr(Fe(X)),X.errorTracker=new ie(Fe(X)),new ze(Fe(X)),X.seekingTracker=new Ze(Fe(X)),X.playheadTime=new re(Fe(X)),X.playbackHeartbeat=new $(Fe(X)),new Ke(Fe(X)),X.watchTimeTracker=new ae(Fe(X)),new fe(Fe(X)),X.adTracker=new Ie(Fe(X)),new we(Fe(X)),new Te(Fe(X)),new ke(Fe(X)),new je(Fe(X)),new Vr(Fe(X)),J.hlsjs&&X.addHLSJS(J),J.dashjs&&X.addDashJS(J),X.emit("viewinit",J.data),X}return I=V,F=[{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 Q=i()({},this.data);if(Q.video_source_is_live===void 0&&(Q.player_source_duration===1/0||Q.video_source_duration===1/0?Q.video_source_is_live=!0:(Q.player_source_duration>0||Q.video_source_duration>0)&&(Q.video_source_is_live=!1)),Q.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(ce){Q[ce]=void 0}),Q.video_source_url=Q.video_source_url||Q.player_source_url,Q.video_source_url){var J=Xr(o(Q.video_source_url),2),X=J[0],ee=J[1];Q.video_source_domain=ee,Q.video_source_hostname=X}delete Q.ad_request_id,this.playbackEventDispatcher.send(H,Q),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(Q){var J=parseInt(H.data[Q],10);H.data[Q]=isNaN(J)?void 0:J}),["player_source_url","video_source_url"].forEach(function(Q){if(H.data[Q]){var J=H.data[Q].toLowerCase();J.indexOf("data:")!==0&&J.indexOf("blob:")!==0||(H.data[Q]="MSE style URL")}})}},{key:"_resetVideoData",value:function(H,Q){var J=this;Object.keys(this.data).forEach(function(X){X.indexOf("video_")===0&&delete J.data[X]})}},{key:"_resetViewData",value:function(){var H=this;Object.keys(this.data).forEach(function(Q){Q.indexOf("view_")===0&&delete H.data[Q]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(H,Q){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var H=this,Q=this.data.view_id=y(),J=function(){Q===H.data.view_id&&t(H.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",J):J()}},{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(Q,J,X){var ee=arguments.length>4?arguments[4]:void 0,ce=Q.log,ye=Q.utils.secondsToMs,ve=function(pe){var oe,he=parseInt(ee.version);return he===1&&pe.programDateTime!==null&&(oe=pe.programDateTime),he===0&&pe.pdt!==null&&(oe=pe.pdt),oe};if(d.exists()){var se=function(pe,oe){return Q.emit(J,pe,oe)},le=function(pe,oe){var he=oe.levels,ue=oe.audioTracks,ge=oe.url,be=oe.stats,De=oe.networkDetails,tt=oe.sessionData,Je={},lt={};he.forEach(function(dt,Ct){Je[Ct]={width:dt.width,height:dt.height,bitrate:dt.bitrate,attrs:dt.attrs}}),ue.forEach(function(dt,Ct){lt[Ct]={name:dt.name,language:dt.lang,bitrate:dt.bitrate}});var ut=x(be),ft=ut.bytesLoaded,He=ut.requestStart,nr=ut.responseStart,ar=ut.responseEnd;se("requestcompleted",h(h({},a(tt)),{},{request_event_type:pe,request_bytes_loaded:ft,request_start:He,request_response_start:nr,request_response_end:ar,request_type:"manifest",request_hostname:r(ge),request_response_headers:P(De),request_rendition_lists:{media:Je,audio:lt,video:{}}}))};X.on(ee.Events.MANIFEST_LOADED,le);var xe=function(pe,oe){var he=oe.details,ue=oe.level,ge=oe.networkDetails,be=oe.stats,De=x(be),tt=De.bytesLoaded,Je=De.requestStart,lt=De.responseStart,ut=De.responseEnd,ft=he.fragments[he.fragments.length-1],He=ve(ft)+ye(ft.duration);se("requestcompleted",{request_event_type:pe,request_bytes_loaded:tt,request_start:Je,request_response_start:lt,request_response_end:ut,request_current_level:ue,request_type:"manifest",request_hostname:r(he.url),request_response_headers:P(ge),video_holdback:he.holdBack&&ye(he.holdBack),video_part_holdback:he.partHoldBack&&ye(he.partHoldBack),video_part_target_duration:he.partTarget&&ye(he.partTarget),video_target_duration:he.targetduration&&ye(he.targetduration),video_source_is_live:he.live,player_manifest_newest_program_time:isNaN(He)?void 0:He})};X.on(ee.Events.LEVEL_LOADED,xe);var Ye=function(pe,oe){var he=oe.details,ue=oe.networkDetails,ge=oe.stats,be=x(ge),De=be.bytesLoaded,tt=be.requestStart,Je=be.responseStart,lt=be.responseEnd;se("requestcompleted",{request_event_type:pe,request_bytes_loaded:De,request_start:tt,request_response_start:Je,request_response_end:lt,request_type:"manifest",request_hostname:r(he.url),request_response_headers:P(ue)})};X.on(ee.Events.AUDIO_TRACK_LOADED,Ye);var Qe=function(pe,oe){var he=oe.stats,ue=oe.networkDetails,ge=oe.frag;he=he||ge.stats;var be=x(he),De={request_event_type:pe,request_bytes_loaded:be.bytesLoaded,request_start:be.requestStart,request_response_start:be.responseStart,request_response_end:be.responseEnd,request_hostname:ue?r(ue.responseURL):void 0,request_response_headers:P(ue),request_media_duration:ge.duration};ge.type==="main"?(De.request_type="media",De.request_current_level=ge.level,De.request_video_width=(X.levels[ge.level]||{}).width,De.request_video_height=(X.levels[ge.level]||{}).height):De.request_type=ge.type,se("requestcompleted",De)};X.on(ee.Events.FRAG_LOADED,Qe);var Et=function(pe,oe){var he=oe.frag,ue=he.start,ge={currentFragmentPDT:ve(he),currentFragmentStart:ye(ue)};se("fragmentchange",ge)};X.on(ee.Events.FRAG_CHANGED,Et);var Se=function(pe,oe){var he=oe.type,ue=oe.details,ge=oe.response,be=oe.fatal,De=oe.context,tt=oe.frag;if(ue===ee.ErrorDetails.MANIFEST_LOAD_ERROR||ue===ee.ErrorDetails.MANIFEST_LOAD_TIMEOUT||ue===ee.ErrorDetails.FRAG_LOAD_ERROR||ue===ee.ErrorDetails.FRAG_LOAD_TIMEOUT||ue===ee.ErrorDetails.LEVEL_LOAD_ERROR||ue===ee.ErrorDetails.LEVEL_LOAD_TIMEOUT){var Je=tt&&tt.url||De&&De.url||"";se("requestfailed",{request_error:ue,request_url:Je,request_hostname:r(Je),request_type:ue===ee.ErrorDetails.FRAG_LOAD_ERROR||ue===ee.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:ge&&ge.code,request_error_text:ge&&ge.text})}be&&se("error",{player_error_code:he,player_error_message:ue})};X.on(ee.Events.ERROR,Se);var $e=function(pe,oe){var he=oe.frag,ue=he&&he._url||"";se("requestcanceled",{request_event_type:pe,request_url:ue,request_type:"media",request_hostname:r(ue)})};X.on(ee.Events.FRAG_LOAD_EMERGENCY_ABORTED,$e);var Ge=function(pe,oe){var he=oe.level,ue=X.levels[he];if(ue&&ue.attrs&&ue.attrs.BANDWIDTH){var ge,be=ue.attrs.BANDWIDTH,De=parseFloat(ue.attrs["FRAME-RATE"]);isNaN(De)||(ge=De),be?se("renditionchange",{video_source_fps:ge,video_source_bitrate:be,video_source_width:ue.width,video_source_height:ue.height}):ce.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};X.on(ee.Events.LEVEL_SWITCHED,Ge),X._stopMuxMonitor=function(){X.off(ee.Events.MANIFEST_LOADED,le),X.off(ee.Events.LEVEL_LOADED,xe),X.off(ee.Events.AUDIO_TRACK_LOADED,Ye),X.off(ee.Events.FRAG_LOADED,Qe),X.off(ee.Events.FRAG_CHANGED,Et),X.off(ee.Events.ERROR,Se),X.off(ee.Events.FRAG_LOAD_EMERGENCY_ABORTED,$e),X.off(ee.Events.LEVEL_SWITCHED,Ge),X.off(ee.Events.DESTROYING,X._stopMuxMonitor),delete X._stopMuxMonitor},X.on(ee.Events.DESTROYING,X._stopMuxMonitor)}else ce.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(Q,J,X){var ee=Q.log;if(X&&X.on){var ce=function(Se,$e){return Q.emit(J,Se,$e)},ye=function(Se){var $e=Se.type,Ge=(Se.data||{}).url;ce("requestcompleted",{request_event_type:$e,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:r(Ge)})};X.on("manifestLoaded",ye);var ve={},se=function(Se){var $e=Se.type,Ge=Se.fragmentModel,pe=(Se.chunk||{}).mediaInfo||{},oe=pe.type,he=pe.bitrateList,ue={};(he=he||[]).forEach(function(ft,He){ue[He]={},ue[He].width=ft.width,ue[He].height=ft.height,ue[He].bitrate=ft.bandwidth,ue[He].attrs={}}),oe==="video"?ve.video=ue:oe==="audio"?ve.audio=ue:ve.media=ue;var ge=k(Ge,X),be=ge.requestStart,De=ge.requestResponseStart,tt=ge.requestResponseEnd,Je=ge.requestResponseHeaders,lt=ge.requestMediaDuration,ut=ge.requestHostname;ce("requestcompleted",{request_event_type:$e,request_start:be,request_response_start:De,request_response_end:tt,request_bytes_loaded:-1,request_type:oe+"_init",request_response_headers:Je,request_hostname:ut,request_media_duration:lt,request_rendition_lists:ve})};X.on("initFragmentLoaded",se);var le=function(Se){var $e=Se.type,Ge=Se.fragmentModel,pe=Se.chunk||{},oe=pe.mediaInfo,he=pe.start,ue=(oe||{}).type,ge=k(Ge,X),be=ge.requestStart,De=ge.requestResponseStart,tt=ge.requestResponseEnd,Je=ge.requestBytesLoaded,lt=ge.requestResponseHeaders,ut=ge.requestMediaDuration,ft=ge.requestHostname,He=B(ue,X),nr=He.currentLevel,ar=He.renditionWidth,dt=He.renditionHeight,Ct=He.renditionBitrate;ce("requestcompleted",{request_event_type:$e,request_start:be,request_response_start:De,request_response_end:tt,request_bytes_loaded:Je,request_type:ue,request_response_headers:lt,request_hostname:ft,request_media_start_time:he,request_media_duration:ut,request_current_level:nr,request_labeled_bitrate:Ct,request_video_width:ar,request_video_height:dt})};X.on("mediaFragmentLoaded",le);var xe={video:void 0,audio:void 0,totalBitrate:void 0},Ye=function(){if(xe.video&&typeof xe.video.bitrate=="number"){if(xe.video.width&&xe.video.height){var Se=xe.video.bitrate;return xe.audio&&typeof xe.audio.bitrate=="number"&&(Se+=xe.audio.bitrate),Se!==xe.totalBitrate?(xe.totalBitrate=Se,{video_source_bitrate:Se,video_source_height:xe.video.height,video_source_width:xe.video.width}):void 0}ee.warn("have bitrate info for video but missing width/height")}},Qe=function(Se,$e,Ge){if(typeof Se.newQuality=="number"){var pe=Se.mediaType;if(pe==="audio"||pe==="video"){var oe=X.getBitrateInfoListFor(pe).find(function(ue){return ue.qualityIndex===Se.newQuality});if(oe&&typeof oe.bitrate=="number"){xe[pe]=oe;var he=Ye();he&&ce("renditionchange",he)}else ee.warn("missing bitrate info for ".concat(pe))}}else ee.warn("missing evt.newQuality in qualityChangeRendered event",Se)};X.on("qualityChangeRendered",Qe);var Et=function(Se){var $e=Se.error,Ge=Se.event,pe=(Ge=Ge||{}).request||{},oe=A().event&&A().event.currentTarget||{};ce("requestfailed",{request_error:$e+"_"+Ge.id+"_"+pe.type,request_url:Ge.url,request_hostname:r(Ge.url),request_type:pe.mediaType,request_error_code:oe.status,request_error_type:oe.statusText})};X.on("error",Et),X._stopMuxMonitor=function(){X.off("manifestLoaded",ye),X.off("initFragmentLoaded",se),X.off("mediaFragmentLoaded",le),X.off("qualityChangeRendered",Qe),X.off("error",Et),delete X._stopMuxMonitor}}else ee.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)}}],F&&pr(I.prototype,F),N&&pr(I,N),Object.defineProperty(I,"prototype",{writable:!1}),V}(z),qr=Zr,ei=b(153),It=b.n(ei);function tr(w){return tr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(I){return typeof I}:function(I){return I&&typeof Symbol=="function"&&I.constructor===Symbol&&I!==Symbol.prototype?"symbol":typeof I},tr(w)}function Er(w,I){return function(F){if(Array.isArray(F))return F}(w)||function(F,N){var K=F==null?null:typeof Symbol!="undefined"&&F[Symbol.iterator]||F["@@iterator"];if(K!=null){var V,H,Q=[],J=!0,X=!1;try{for(K=K.call(F);!(J=(V=K.next()).done)&&(Q.push(V.value),!N||Q.length!==N);J=!0);}catch(ee){X=!0,H=ee}finally{try{J||K.return==null||K.return()}finally{if(X)throw H}}return Q}}(w,I)||function(F,N){if(F){if(typeof F=="string")return yr(F,N);var K=Object.prototype.toString.call(F).slice(8,-1);return K==="Object"&&F.constructor&&(K=F.constructor.name),K==="Map"||K==="Set"?Array.from(F):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?yr(F,N):void 0}}(w,I)||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 yr(w,I){(I==null||I>w.length)&&(I=w.length);for(var F=0,N=new Array(I);F<I;F++)N[F]=w[F];return N}var Lt,ti=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],ri={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};A()&&A().WeakMap&&(Lt=new WeakMap);var ii="#EXT-X-TARGETDURATION",ni="#EXT-X-PART-INF",ai="#EXT-X-SERVER-CONTROL",si="#EXTINF",oi="#EXT-X-PROGRAM-DATE-TIME",li="#EXT-X-VERSION",ui="#EXT-X-SESSION-DATA",Wt=function(w){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(w),this.manifest};Wt.prototype.process=function(w){var I;for(this.buffer+=w,I=this.buffer.indexOf(`
5
- `);I>-1;I=this.buffer.indexOf(`
6
- `))this.processLine(this.buffer.substring(0,I)),this.buffer=this.buffer.substring(I+1)},Wt.prototype.processLine=function(w){var I=w.indexOf(":"),F=hi(w,I),N=F[0],K=F.length===2?ir(F[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 ii:if(!isFinite(K)||K<0)return;this.manifest.targetDuration=K,this.setHoldBack();break;case ni:rr(this.manifest,F),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case ai:rr(this.manifest,F),this.setHoldBack();break;case si:K===0?this.currentUri.duration=.01:K>0&&(this.currentUri.duration=K);break;case oi:var V=K,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 li:rr(this.manifest,F);break;case ui:var Q=vi(F[1]),J=a(Q);i()(this.manifest.sessionData,J)}},Wt.prototype.setHoldBack=function(){var w=this.manifest,I=w.serverControl,F=w.targetDuration,N=w.partTargetDuration;if(I){var K="holdBack",V="partHoldBack",H=F&&3*F,Q=N&&2*N;F&&!I.hasOwnProperty(K)&&(I[K]=H),H&&I[K]<H&&(I[K]=H),N&&!I.hasOwnProperty(V)&&(I[V]=3*N),N&&I[V]<Q&&(I[V]=Q)}};var rr=function(w,I){var F,N=Tr(I[0].replace("#EXT-X-",""));ci(I[1])?(F={},F=i()(di(I[1]),F)):F=ir(I[1]),w[N]=F},Tr=function(w){return w.toLowerCase().replace(/-(\w)/g,function(I){return I[1].toUpperCase()})},ir=function(w){if(w.toLowerCase()==="yes"||w.toLowerCase()==="no")return w.toLowerCase()==="yes";var I=w.indexOf(":")!==-1?w:parseFloat(w);return isNaN(I)?w:I},fi=function(w){var I={},F=w.split("=");return F.length>1&&(I[Tr(F[0])]=ir(F[1])),I},di=function(w){for(var I=w.split(","),F={},N=0;I.length>N;N++){var K=I[N],V=fi(K);F=i()(V,F)}return F},ci=function(w){return w.indexOf("=")>-1},hi=function(w,I){return I===-1?[w]:[w.substring(0,I),w.substring(I+1)]},vi=function(w){var I={};if(w){var F=w.search(",");return[w.slice(0,F),w.slice(F+1)].forEach(function(N,K){for(var V=N.replace(/['"]+/g,"").split("="),H=0;H<V.length;H++)V[H]==="DATA-ID"&&(I["DATA-ID"]=V[1-H]),V[H]==="VALUE"&&(I.VALUE=V[1-H])}),{data:I}}},gi=Wt,mi={safeCall:function(w,I,F,N){var K=N;if(w&&typeof w[I]=="function")try{K=w[I].apply(w,F)}catch(V){e.info("safeCall error",V)}return K},safeIncrement:t,getComputedStyle:function(w,I){var F;if(w&&I&&A()&&typeof A().getComputedStyle=="function")return Lt&&Lt.has(w)&&(F=Lt.get(w)),F||(F=A().getComputedStyle(w,null),Lt&&Lt.set(w,F)),F.getPropertyValue(I)},secondsToMs:function(w){return Math.floor(1e3*w)},assign:i(),headersStringToObject:l,extractHostnameAndDomain:o,extractHostname:r,manifestParser:gi,generateShortID:T,generateUUID:y,now:c.now},pi={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 Ei(w,I){return function(F){if(Array.isArray(F))return F}(w)||function(F,N){var K=F==null?null:typeof Symbol!="undefined"&&F[Symbol.iterator]||F["@@iterator"];if(K!=null){var V,H,Q=[],J=!0,X=!1;try{for(K=K.call(F);!(J=(V=K.next()).done)&&(Q.push(V.value),!N||Q.length!==N);J=!0);}catch(ee){X=!0,H=ee}finally{try{J||K.return==null||K.return()}finally{if(X)throw H}}return Q}}(w,I)||function(F,N){if(F){if(typeof F=="string")return xr(F,N);var K=Object.prototype.toString.call(F).slice(8,-1);return K==="Object"&&F.constructor&&(K=F.constructor.name),K==="Map"||K==="Set"?Array.from(F):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?xr(F,N):void 0}}(w,I)||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 xr(w,I){(I==null||I>w.length)&&(I=w.length);for(var F=0,N=new Array(I);F<I;F++)N[F]=w[F];return N}var et={},Mt=function w(I){var F=arguments;typeof I=="string"?w.hasOwnProperty(I)?A().setTimeout(function(){F=Array.prototype.splice.call(F,1),w[I].apply(null,F)},0):e.warn("`"+I+"` is an unknown task"):typeof I=="function"?A().setTimeout(function(){I(w)},0):e.warn("`"+I+"` is invalid.")},yi={loaded:c.now(),NAME:"mux-embed",VERSION:"4.14.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(w,I){return function(F,N,K){var V=Er(E(N),3),H=V[0],Q=V[1],J=V[2],X=F.log,ee=F.utils.getComputedStyle,ce=F.utils.secondsToMs;if(!H)return X.error("No element was found with the `"+Q+"` query selector.");if(J!=="video"&&J!=="audio")return X.error("The element of `"+Q+"` was not a media element.");H.mux&&(H.mux.destroy(),delete H.mux,X.warn("Already monitoring this video element, replacing existing event listeners")),(K=i()({automaticErrorTracking:!0},K)).data=i()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:F.VERSION},K.data),K.getPlayheadTime=function(){return ce(H.currentTime)},K.getStateData=function(){var ve=this.hlsjs&&this.hlsjs.url,se=this.dashjs&&tr(this.dashjs.getSource==="function")&&this.dashjs.getSource(),le={player_is_paused:H.paused,player_playhead_time:ce(H.currentTime),player_width:parseInt(ee(H,"width")),player_height:parseInt(ee(H,"height")),player_autoplay_on:H.autoplay,player_preload_on:H.preload,player_language_code:H.lang,player_is_fullscreen:It()&&!!(It().fullscreenElement||It().webkitFullscreenElement||It().mozFullScreenElement||It().msFullscreenElement),video_poster_url:H.poster,video_source_url:ve||se||H.currentSrc,video_source_duration:ce(H.duration),video_source_height:H.videoHeight,video_source_width:H.videoWidth},xe=K.getPlayheadTime();if(H.getStartDate&&xe>0){var Ye=H.getStartDate();if(Ye&&typeof Ye.getTime=="function"&&Ye.getTime()){var Qe=Ye.getTime();if(le.player_program_time=Qe+xe,H.seekable.length>0){var Et=Qe+H.seekable.end(H.seekable.length-1);le.player_live_edge_program_time=Et}}}return le},H.mux=H.mux||{},H.mux.deleted=!1,H.mux.emit=function(ve,se){F.emit(Q,ve,se)};var ye=function(){X.error("The monitor for this video element has already been destroyed.")};H.mux.destroy=function(){Object.keys(H.mux.listeners).forEach(function(ve){H.removeEventListener(ve,H.mux.listeners[ve],!1)}),delete H.mux.listeners,H.mux.destroy=ye,H.mux.swapElement=ye,H.mux.emit=ye,H.mux.addHLSJS=ye,H.mux.addDashJS=ye,H.mux.removeHLSJS=ye,H.mux.removeDashJS=ye,H.mux.deleted=!0,F.emit(Q,"destroy")},H.mux.swapElement=function(ve){var se=Er(E(ve),3),le=se[0],xe=se[1],Ye=se[2];return le?Ye!=="video"&&Ye!=="audio"?F.log.error("The element of `"+xe+"` was not a media element."):(le.muxId=H.muxId,delete H.muxId,le.mux=le.mux||{},le.mux.listeners=i()({},H.mux.listeners),delete H.mux.listeners,Object.keys(le.mux.listeners).forEach(function(Qe){H.removeEventListener(Qe,le.mux.listeners[Qe],!1),le.addEventListener(Qe,le.mux.listeners[Qe],!1)}),le.mux.swapElement=H.mux.swapElement,le.mux.destroy=H.mux.destroy,delete H.mux,void(H=le)):F.log.error("No element was found with the `"+xe+"` query selector.")},H.mux.addHLSJS=function(ve){F.addHLSJS(Q,ve)},H.mux.addDashJS=function(ve){F.addDashJS(Q,ve)},H.mux.removeHLSJS=function(){F.removeHLSJS(Q)},H.mux.removeDashJS=function(){F.removeDashJS(Q)},F.init(Q,K),F.emit(Q,"playerready"),H.paused||(F.emit(Q,"play"),H.readyState>2&&F.emit(Q,"playing")),H.mux.listeners={},ti.forEach(function(ve){(ve!=="error"||K.automaticErrorTracking)&&(H.mux.listeners[ve]=function(){var se={};if(ve==="error"){if(!H.error||H.error.code===1)return;se.player_error_code=H.error.code,se.player_error_message=ri[H.error.code]||H.error.message}F.emit(Q,ve,se)},H.addEventListener(ve,H.mux.listeners[ve],!1))})}(Mt,w,I)},destroyMonitor:function(w){var I=Ei(E(w),1)[0];I&&I.mux&&typeof I.mux.destroy=="function"?I.mux.destroy():e.error("A video element monitor for `"+w+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(w,I){var F=D(w);et[F]?et[F].addHLSJS(I):e.error("A monitor for `"+F+"` has not been initialized.")},addDashJS:function(w,I){var F=D(w);et[F]?et[F].addDashJS(I):e.error("A monitor for `"+F+"` has not been initialized.")},removeHLSJS:function(w){var I=D(w);et[I]?et[I].removeHLSJS():e.error("A monitor for `"+I+"` has not been initialized.")},removeDashJS:function(w){var I=D(w);et[I]?et[I].removeDashJS():e.error("A monitor for `"+I+"` has not been initialized.")},init:function(w,I){s()&&I&&I.respectDoNotTrack&&e.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var F=D(w);et[F]=new qr(Mt,F,I)},emit:function(w,I,F){var N=D(w);et[N]?(et[N].emit(I,F),I==="destroy"&&delete et[N]):e.error("A monitor for `"+N+"` has not been initialized.")},checkDoNotTrack:s,log:e,utils:mi,events:pi,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Mt,yi),A()!==void 0&&typeof A().addEventListener=="function"&&A().addEventListener("pagehide",function(w){w.persisted||(Mt.WINDOW_UNLOADING=!0)},!1);var Ti=Mt},655:function(L,C,b){var O,A;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((A=typeof(O=T)=="function"?O.call(C,b,C,L):O)===void 0||(L.exports=A),D=!0,y(C)==="object"&&(L.exports=T(),D=!0),!D){var E=window.Cookies,g=window.Cookies=T();g.noConflict=function(){return window.Cookies=E,g}}})(function(){var T=function(){for(var D=0,E={};D<arguments.length;D++){var g=arguments[D];for(var p in g)E[p]=g[p]}return E};return function D(E){function g(p,u,e){var s;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(e=T({path:"/"},g.defaults,e)).expires=="number"){var c=new Date;c.setMilliseconds(c.getMilliseconds()+864e5*e.expires),e.expires=c}try{s=JSON.stringify(u),/^[\{\[]/.test(s)&&(u=s)}catch{}return u=E.write?E.write(u,p):encodeURIComponent(String(u)).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,"=",u,e.expires?"; expires="+e.expires.toUTCString():"",e.path?"; path="+e.path:"",e.domain?"; domain="+e.domain:"",e.secure?"; secure":""].join("")}p||(s={});for(var v=document.cookie?document.cookie.split("; "):[],i=/(%[0-9A-Z]{2})+/g,r=0;r<v.length;r++){var o=v[r].split("="),d=o.slice(1).join("=");d.charAt(0)==='"'&&(d=d.slice(1,-1));try{var t=o[0].replace(i,decodeURIComponent);if(d=E.read?E.read(d,t):E(d,t)||d.replace(i,decodeURIComponent),this.json)try{d=JSON.parse(d)}catch{}if(p===t){s=d;break}p||(s[t]=d)}catch{}}return s}}return g.set=g,g.get=function(p){return g.call(g,p)},g.getJSON=function(){return g.apply({json:!0},[].slice.call(arguments))},g.defaults={},g.remove=function(p,u){g(p,"",T(u,{expires:-1}))},g.withConverter=D,g}(function(){})})},153:function(L,C,b){var O,A=b.g!==void 0?b.g:typeof window!="undefined"?window:{},y=b(558);typeof document!="undefined"?O=document:(O=A["__GLOBAL_DOCUMENT_CACHE@4"])||(O=A["__GLOBAL_DOCUMENT_CACHE@4"]=y),L.exports=O},48:function(L,C,b){var O;O=typeof window!="undefined"?window:b.g!==void 0?b.g:typeof self!="undefined"?self:{},L.exports=O},678:function(L){var C=9007199254740991,b="[object Arguments]",O="[object Function]",A="[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 D,E,g=Object.prototype,p=g.hasOwnProperty,u=g.toString,e=g.propertyIsEnumerable,s=(D=Object.keys,E=Object,function(S){return D(E(S))}),c=Math.max,v=!e.call({valueOf:1},"valueOf");function i(S,x){var P=n(S)||function(W){return function(G){return function(z){return!!z&&typeof z=="object"}(G)&&l(G)}(W)&&p.call(W,"callee")&&(!e.call(W,"callee")||u.call(W)==b)}(S)?function(W,G){for(var z=-1,Y=Array(W);++z<W;)Y[z]=G(z);return Y}(S.length,String):[],k=P.length,B=!!k;for(var U in S)!x&&!p.call(S,U)||B&&(U=="length"||o(U,k))||P.push(U);return P}function r(S,x,P){var k=S[x];p.call(S,x)&&t(k,P)&&(P!==void 0||x in S)||(S[x]=P)}function o(S,x){return!!(x=x==null?C:x)&&(typeof S=="number"||y.test(S))&&S>-1&&S%1==0&&S<x}function d(S){var x=S&&S.constructor;return S===(typeof x=="function"&&x.prototype||g)}function t(S,x){return S===x||S!=S&&x!=x}var n=Array.isArray;function l(S){return S!=null&&function(x){return typeof x=="number"&&x>-1&&x%1==0&&x<=C}(S.length)&&!function(x){var P=a(x)?u.call(x):"";return P==O||P==A}(S)}function a(S){var x=typeof S;return!!S&&(x=="object"||x=="function")}var f,h=(f=function(S,x){if(v||d(x)||l(x))(function(k,B,U,W){U||(U={});for(var G=-1,z=B.length;++G<z;){var Y=B[G],$=W?W(U[Y],k[Y],Y,U,k):void 0;r(U,Y,$===void 0?k[Y]:$)}})(x,function(k){return l(k)?i(k):function(B){if(!d(B))return s(B);var U=[];for(var W in Object(B))p.call(B,W)&&W!="constructor"&&U.push(W);return U}(k)}(x),S);else for(var P in x)p.call(x,P)&&r(S,P,x[P])},function(S,x){return x=c(x===void 0?S.length-1:x,0),function(){for(var P=arguments,k=-1,B=c(P.length-x,0),U=Array(B);++k<B;)U[k]=P[x+k];k=-1;for(var W=Array(x+1);++k<x;)W[k]=P[k];return W[x]=U,T(S,this,W)}}(function(S,x){var P=-1,k=x.length,B=k>1?x[k-1]:void 0,U=k>2?x[2]:void 0;for(B=f.length>3&&typeof B=="function"?(k--,B):void 0,U&&function(G,z,Y){if(!a(Y))return!1;var $=typeof z;return!!($=="number"?l(Y)&&o(z,Y.length):$=="string"&&z in Y)&&t(Y[z],G)}(x[0],x[1],U)&&(B=k<3?void 0:B,k=1),S=Object(S);++P<k;){var W=x[P];W&&f(S,W,P,B)}return S}));L.exports=h},640:function(L,C,b){var O,A;(function(y,T){"use strict";O=function(){var D=function(){},E="undefined",g=typeof window!==E&&typeof window.navigator!==E&&/Trident\/|MSIE /.test(window.navigator.userAgent),p=["trace","debug","info","warn","error"];function u(n,l){var a=n[l];if(typeof a.bind=="function")return a.bind(n);try{return Function.prototype.bind.call(a,n)}catch{return function(){return Function.prototype.apply.apply(a,[n,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 s(n){return n==="debug"&&(n="log"),typeof console!==E&&(n==="trace"&&g?e:console[n]!==void 0?u(console,n):console.log!==void 0?u(console,"log"):D)}function c(n,l){for(var a=0;a<p.length;a++){var f=p[a];this[f]=a<n?D:this.methodFactory(f,n,l)}this.log=this.debug}function v(n,l,a){return function(){typeof console!==E&&(c.call(this,l,a),this[n].apply(this,arguments))}}function i(n,l,a){return s(n)||v.apply(this,arguments)}function r(n,l,a){var f,h=this;l=l==null?"WARN":l;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 h.levels[U]===void 0&&(U=void 0),U}}function k(){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 n=="string"?S+=":"+n:typeof n=="symbol"&&(S=void 0),h.name=n,h.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},h.methodFactory=a||i,h.getLevel=function(){return f},h.setLevel=function(U,W){if(typeof U=="string"&&h.levels[U.toUpperCase()]!==void 0&&(U=h.levels[U.toUpperCase()]),!(typeof U=="number"&&U>=0&&U<=h.levels.SILENT))throw"log.setLevel() called with invalid level: "+U;if(f=U,W!==!1&&x(U),c.call(h,U,n),typeof console===E&&U<h.levels.SILENT)return"No console available for logging"},h.setDefaultLevel=function(U){l=U,P()||h.setLevel(U,!1)},h.resetLevel=function(){h.setLevel(l,!1),k()},h.enableAll=function(U){h.setLevel(h.levels.TRACE,U)},h.disableAll=function(U){h.setLevel(h.levels.SILENT,U)};var B=P();B==null&&(B=l),h.setLevel(B,!1)}var o=new r,d={};o.getLogger=function(n){if(typeof n!="symbol"&&typeof n!="string"||n==="")throw new TypeError("You must supply a name when creating a logger.");var l=d[n];return l||(l=d[n]=new r(n,o.getLevel(),o.methodFactory)),l};var t=typeof window!==E?window.log:void 0;return o.noConflict=function(){return typeof window!==E&&window.log===o&&(window.log=t),o},o.getLoggers=function(){return d},o.default=o,o},(A=typeof O=="function"?O.call(C,b,C,L):O)===void 0||(L.exports=A)})()},375:function(L,C){"use strict";var b=Object.prototype.hasOwnProperty;function O(y){try{return decodeURIComponent(y.replace(/\+/g," "))}catch{return null}}function A(y){try{return encodeURIComponent(y)}catch{return null}}C.stringify=function(y,T){T=T||"";var D,E,g=[];for(E in typeof T!="string"&&(T="?"),y)if(b.call(y,E)){if((D=y[E])||D!=null&&!isNaN(D)||(D=""),E=A(E),D=A(D),E===null||D===null)continue;g.push(E+"="+D)}return g.length?T+g.join("&"):""},C.parse=function(y){for(var T,D=/([^=?#&]+)=?([^&]*)/g,E={};T=D.exec(y);){var g=O(T[1]),p=O(T[2]);g===null||p===null||g in E||(E[g]=p)}return E}},558:function(){}},M={};function _(L){var C=M[L];if(C!==void 0)return C.exports;var b=M[L]={exports:{}};return m[L].call(b.exports,b,b.exports,_),b.exports}return _.n=function(L){var C=L&&L.__esModule?function(){return L.default}:function(){return L};return _.d(C,{a:C}),C},_.d=function(L,C){for(var b in C)_.o(C,b)&&!_.o(L,b)&&Object.defineProperty(L,b,{enumerable:!0,get:C[b]})},_.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),_.o=function(L,C){return Object.prototype.hasOwnProperty.call(L,C)},_(80)}()},typeof Gt=="object"&&typeof sr=="object"?sr.exports=R():typeof Gt=="object"?Gt.mux=R():j.mux=R()})()});var Ht=Dr((Ft,or)=>{typeof window!="undefined"&&function(R,m){typeof Ft=="object"&&typeof or=="object"?or.exports=m():typeof define=="function"&&define.amd?define([],m):typeof Ft=="object"?Ft.Hls=m():R.Hls=m()}(Ft,function(){return function(j){var R={};function m(M){if(R[M])return R[M].exports;var _=R[M]={i:M,l:!1,exports:{}};return j[M].call(_.exports,_,_.exports,m),_.l=!0,_.exports}return m.m=j,m.c=R,m.d=function(M,_,L){m.o(M,_)||Object.defineProperty(M,_,{enumerable:!0,get:L})},m.r=function(M){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(M,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(M,"__esModule",{value:!0})},m.t=function(M,_){if(_&1&&(M=m(M)),_&8||_&4&&typeof M=="object"&&M&&M.__esModule)return M;var L=Object.create(null);if(m.r(L),Object.defineProperty(L,"default",{enumerable:!0,value:M}),_&2&&typeof M!="string")for(var C in M)m.d(L,C,function(b){return M[b]}.bind(null,C));return L},m.n=function(M){var _=M&&M.__esModule?function(){return M.default}:function(){return M};return m.d(_,"a",_),_},m.o=function(M,_){return Object.prototype.hasOwnProperty.call(M,_)},m.p="/dist/",m(m.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(j,R,m){"use strict";var M=Object.prototype.hasOwnProperty,_="~";function L(){}Object.create&&(L.prototype=Object.create(null),new L().__proto__||(_=!1));function C(y,T,D){this.fn=y,this.context=T,this.once=D||!1}function b(y,T,D,E,g){if(typeof D!="function")throw new TypeError("The listener must be a function");var p=new C(D,E||y,g),u=_?_+T:T;return y._events[u]?y._events[u].fn?y._events[u]=[y._events[u],p]:y._events[u].push(p):(y._events[u]=p,y._eventsCount++),y}function O(y,T){--y._eventsCount===0?y._events=new L:delete y._events[T]}function A(){this._events=new L,this._eventsCount=0}A.prototype.eventNames=function(){var T=[],D,E;if(this._eventsCount===0)return T;for(E in D=this._events)M.call(D,E)&&T.push(_?E.slice(1):E);return Object.getOwnPropertySymbols?T.concat(Object.getOwnPropertySymbols(D)):T},A.prototype.listeners=function(T){var D=_?_+T:T,E=this._events[D];if(!E)return[];if(E.fn)return[E.fn];for(var g=0,p=E.length,u=new Array(p);g<p;g++)u[g]=E[g].fn;return u},A.prototype.listenerCount=function(T){var D=_?_+T:T,E=this._events[D];return E?E.fn?1:E.length:0},A.prototype.emit=function(T,D,E,g,p,u){var e=_?_+T:T;if(!this._events[e])return!1;var s=this._events[e],c=arguments.length,v,i;if(s.fn){switch(s.once&&this.removeListener(T,s.fn,void 0,!0),c){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,D),!0;case 3:return s.fn.call(s.context,D,E),!0;case 4:return s.fn.call(s.context,D,E,g),!0;case 5:return s.fn.call(s.context,D,E,g,p),!0;case 6:return s.fn.call(s.context,D,E,g,p,u),!0}for(i=1,v=new Array(c-1);i<c;i++)v[i-1]=arguments[i];s.fn.apply(s.context,v)}else{var r=s.length,o;for(i=0;i<r;i++)switch(s[i].once&&this.removeListener(T,s[i].fn,void 0,!0),c){case 1:s[i].fn.call(s[i].context);break;case 2:s[i].fn.call(s[i].context,D);break;case 3:s[i].fn.call(s[i].context,D,E);break;case 4:s[i].fn.call(s[i].context,D,E,g);break;default:if(!v)for(o=1,v=new Array(c-1);o<c;o++)v[o-1]=arguments[o];s[i].fn.apply(s[i].context,v)}}return!0},A.prototype.on=function(T,D,E){return b(this,T,D,E,!1)},A.prototype.once=function(T,D,E){return b(this,T,D,E,!0)},A.prototype.removeListener=function(T,D,E,g){var p=_?_+T:T;if(!this._events[p])return this;if(!D)return O(this,p),this;var u=this._events[p];if(u.fn)u.fn===D&&(!g||u.once)&&(!E||u.context===E)&&O(this,p);else{for(var e=0,s=[],c=u.length;e<c;e++)(u[e].fn!==D||g&&!u[e].once||E&&u[e].context!==E)&&s.push(u[e]);s.length?this._events[p]=s.length===1?s[0]:s:O(this,p)}return this},A.prototype.removeAllListeners=function(T){var D;return T?(D=_?_+T:T,this._events[D]&&O(this,D)):(this._events=new L,this._eventsCount=0),this},A.prototype.off=A.prototype.removeListener,A.prototype.addListener=A.prototype.on,A.prefixed=_,A.EventEmitter=A,j.exports=A},"./node_modules/url-toolkit/src/url-toolkit.js":function(j,R,m){(function(M){var _=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,L=/^(?=([^\/?#]*))\1([^]*)$/,C=/(?:\/|^)\.(?=\/)/g,b=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,O={buildAbsoluteURL:function(A,y,T){if(T=T||{},A=A.trim(),y=y.trim(),!y){if(!T.alwaysNormalize)return A;var D=O.parseURL(A);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 g=O.parseURL(A);if(!g)throw new Error("Error trying to parse base URL.");if(!g.netLoc&&g.path&&g.path[0]!=="/"){var p=L.exec(g.path);g.netLoc=p[1],g.path=p[2]}g.netLoc&&!g.path&&(g.path="/");var u={scheme:g.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc&&(u.netLoc=g.netLoc,E.path[0]!=="/"))if(!E.path)u.path=g.path,E.params||(u.params=g.params,E.query||(u.query=g.query));else{var e=g.path,s=e.substring(0,e.lastIndexOf("/")+1)+E.path;u.path=O.normalizePath(s)}return u.path===null&&(u.path=T.alwaysNormalize?O.normalizePath(E.path):E.path),O.buildURLFromParts(u)},parseURL:function(A){var y=_.exec(A);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(A){for(A=A.split("").reverse().join("").replace(C,"");A.length!==(A=A.replace(b,"")).length;);return A.split("").reverse().join("")},buildURLFromParts:function(A){return A.scheme+A.netLoc+A.path+A.params+A.query+A.fragment}};j.exports=O})(this)},"./node_modules/webworkify-webpack/index.js":function(j,R,m){function M(T){var D={};function E(p){if(D[p])return D[p].exports;var u=D[p]={i:p,l:!1,exports:{}};return T[p].call(u.exports,u,u.exports,E),u.l=!0,u.exports}E.m=T,E.c=D,E.i=function(p){return p},E.d=function(p,u,e){E.o(p,u)||Object.defineProperty(p,u,{configurable:!1,enumerable:!0,get:e})},E.r=function(p){Object.defineProperty(p,"__esModule",{value:!0})},E.n=function(p){var u=p&&p.__esModule?function(){return p.default}:function(){return p};return E.d(u,"a",u),u},E.o=function(p,u){return Object.prototype.hasOwnProperty.call(p,u)},E.p="/",E.oe=function(p){throw console.error(p),p};var g=E(E.s=ENTRY_MODULE);return g.default||g}var _="[\\.|\\-|\\+|\\w|/|@]+",L="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+_+").*?\\)";function C(T){return(T+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function b(T){return!isNaN(1*T)}function O(T,D,E){var g={};g[E]=[];var p=D.toString(),u=p.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return g;for(var e=u[1],s=new RegExp("(\\\\n|\\W)"+C(e)+L,"g"),c;c=s.exec(p);)c[3]!=="dll-reference"&&g[E].push(c[3]);for(s=new RegExp("\\("+C(e)+'\\("(dll-reference\\s('+_+'))"\\)\\)'+L,"g");c=s.exec(p);)T[c[2]]||(g[E].push(c[1]),T[c[2]]=m(c[1]).m),g[c[2]]=g[c[2]]||[],g[c[2]].push(c[4]);for(var v=Object.keys(g),i=0;i<v.length;i++)for(var r=0;r<g[v[i]].length;r++)b(g[v[i]][r])&&(g[v[i]][r]=1*g[v[i]][r]);return g}function A(T){var D=Object.keys(T);return D.reduce(function(E,g){return E||T[g].length>0},!1)}function y(T,D){for(var E={main:[D]},g={main:[]},p={main:{}};A(E);)for(var u=Object.keys(E),e=0;e<u.length;e++){var s=u[e],c=E[s],v=c.pop();if(p[s]=p[s]||{},!(p[s][v]||!T[s][v])){p[s][v]=!0,g[s]=g[s]||[],g[s].push(v);for(var i=O(T,T[s][v],s),r=Object.keys(i),o=0;o<r.length;o++)E[r[o]]=E[r[o]]||[],E[r[o]]=E[r[o]].concat(i[r[o]])}}return g}j.exports=function(T,D){D=D||{};var E={main:m.m},g=D.all?{main:Object.keys(E.main)}:y(E,T),p="";Object.keys(g).filter(function(v){return v!=="main"}).forEach(function(v){for(var i=0;g[v][i];)i++;g[v].push(i),E[v][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",p=p+"var "+v+" = ("+M.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+g[v].map(function(r){return""+JSON.stringify(r)+": "+E[v][r].toString()}).join(",")+`});
8
- `}),p=p+"new (("+M.toString().replace("ENTRY_MODULE",JSON.stringify(T))+")({"+g.main.map(function(v){return""+JSON.stringify(v)+": "+E.main[v].toString()}).join(",")+"}))(self);";var u=new window.Blob([p],{type:"text/javascript"});if(D.bare)return u;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,s=e.createObjectURL(u),c=new window.Worker(s);return c.objectURL=s,c}},"./src/config.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"hlsDefaultConfig",function(){return o}),m.d(R,"mergeConfig",function(){return t}),m.d(R,"enableStreamingMode",function(){return n});var M=m("./src/controller/abr-controller.ts"),_=m("./src/controller/audio-stream-controller.ts"),L=m("./src/controller/audio-track-controller.ts"),C=m("./src/controller/subtitle-stream-controller.ts"),b=m("./src/controller/subtitle-track-controller.ts"),O=m("./src/controller/buffer-controller.ts"),A=m("./src/controller/timeline-controller.ts"),y=m("./src/controller/cap-level-controller.ts"),T=m("./src/controller/fps-controller.ts"),D=m("./src/controller/eme-controller.ts"),E=m("./src/controller/cmcd-controller.ts"),g=m("./src/utils/xhr-loader.ts"),p=m("./src/utils/fetch-loader.ts"),u=m("./src/utils/cues.ts"),e=m("./src/utils/mediakeys-helper.ts"),s=m("./src/utils/logger.ts");function c(){return c=Object.assign?Object.assign.bind():function(l){for(var a=1;a<arguments.length;a++){var f=arguments[a];for(var h in f)Object.prototype.hasOwnProperty.call(f,h)&&(l[h]=f[h])}return l},c.apply(this,arguments)}function v(l,a){var f=Object.keys(l);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(l);a&&(h=h.filter(function(S){return Object.getOwnPropertyDescriptor(l,S).enumerable})),f.push.apply(f,h)}return f}function i(l){for(var a=1;a<arguments.length;a++){var f=arguments[a]!=null?arguments[a]:{};a%2?v(Object(f),!0).forEach(function(h){r(l,h,f[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(f)):v(Object(f)).forEach(function(h){Object.defineProperty(l,h,Object.getOwnPropertyDescriptor(f,h))})}return l}function r(l,a,f){return a in l?Object.defineProperty(l,a,{value:f,enumerable:!0,configurable:!0,writable:!0}):l[a]=f,l}var o=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:g.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:M.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},d()),{},{subtitleStreamController:C.SubtitleStreamController,subtitleTrackController:b.default,timelineController:A.TimelineController,audioStreamController:_.default,audioTrackController:L.default,emeController:D.default,cmcdController:E.default});function d(){return{cueHandler:u.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(l,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return c({},l,a)}function n(l){var a=l.loader;if(a!==p.default&&a!==g.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),l.progressive=!1;else{var f=Object(p.fetchSupported)();f&&(l.loader=p.default,l.progressive=!0,l.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/polyfills/number.ts"),_=m("./src/utils/ewma-bandwidth-estimator.ts"),L=m("./src/events.ts"),C=m("./src/utils/buffer-helper.ts"),b=m("./src/errors.ts"),O=m("./src/types/loader.ts"),A=m("./src/utils/logger.ts");function y(E,g){for(var p=0;p<g.length;p++){var u=g[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(E,u.key,u)}}function T(E,g,p){return g&&y(E.prototype,g),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 u=p.config;this.bwEstimator=new _.default(u.abrEwmaSlowVoD,u.abrEwmaFastVoD,u.abrEwmaDefaultEstimate),this.registerListeners()}var g=E.prototype;return g.registerListeners=function(){var u=this.hls;u.on(L.Events.FRAG_LOADING,this.onFragLoading,this),u.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(L.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(L.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){var u=this.hls;u.off(L.Events.FRAG_LOADING,this.onFragLoading,this),u.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(L.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(L.Events.ERROR,this.onError,this)},g.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},g.onFragLoading=function(u,e){var s=e.frag;if(s.type===O.PlaylistLevelType.MAIN&&!this.timer){var c;this.fragCurrent=s,this.partCurrent=(c=e.part)!=null?c:null,this.timer=self.setInterval(this.onCheck,100)}},g.onLevelLoaded=function(u,e){var s=this.hls.config;e.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)},g._abandonRulesCheck=function(){var u=this.fragCurrent,e=this.partCurrent,s=this.hls,c=s.autoLevelEnabled,v=s.config,i=s.media;if(!(!u||!i)){var r=e?e.stats:u.stats,o=e?e.duration:u.duration;if(r.aborted){A.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!c||i.paused||!i.playbackRate||!i.readyState)){var d=performance.now()-r.loading.start,t=Math.abs(i.playbackRate);if(!(d<=500*o/t)){var n=s.levels,l=s.minAutoLevel,a=n[u.level],f=r.total||Math.max(r.loaded,Math.round(o*a.maxBitrate/8)),h=Math.max(1,r.bwEstimate?r.bwEstimate/8:r.loaded*1e3/d),S=(f-r.loaded)/h,x=i.currentTime,P=(C.BufferHelper.bufferInfo(i,x,v.maxBufferHole).end-x)/t;if(!(P>=2*o/t||S<=P)){var k=Number.POSITIVE_INFINITY,B;for(B=u.level-1;B>l;B--){var U=n[B].maxBitrate;if(k=o*U/(8*.8*h),k<P)break}if(!(k>=S)){var W=this.bwEstimator.getEstimate();A.logger.warn("Fragment "+u.sn+(e?" part "+e.index:"")+" of level "+u.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+B+`
9
- Current BW estimate: `+(Object(M.isFiniteNumber)(W)?(W/1024).toFixed(3):"Unknown")+` Kb/s
10
- Estimated load time for current fragment: `+S.toFixed(3)+` s
11
- Estimated load time for the next fragment: `+k.toFixed(3)+` s
12
- Time to underbuffer: `+P.toFixed(3)+" s"),s.nextLoadLevel=B,this.bwEstimator.sample(d,r.loaded),this.clearTimer(),u.loader&&(this.fragCurrent=this.partCurrent=null,u.loader.abort()),s.trigger(L.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:u,part:e,stats:r})}}}}}},g.onFragLoaded=function(u,e){var s=e.frag,c=e.part;if(s.type===O.PlaylistLevelType.MAIN&&Object(M.isFiniteNumber)(s.sn)){var v=c?c.stats:s.stats,i=c?c.duration:s.duration;if(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var r=this.hls.levels[s.level],o=(r.loaded?r.loaded.bytes:0)+v.loaded,d=(r.loaded?r.loaded.duration:0)+i;r.loaded={bytes:o,duration:d},r.realBitrate=Math.round(8*o/d)}if(s.bitrateTest){var t={stats:v,frag:s,part:c,id:s.type};this.onFragBuffered(L.Events.FRAG_BUFFERED,t)}}},g.onFragBuffered=function(u,e){var s=e.frag,c=e.part,v=c?c.stats:s.stats;if(!v.aborted&&!(s.type!==O.PlaylistLevelType.MAIN||s.sn==="initSegment")){var i=v.parsing.end-v.loading.start;this.bwEstimator.sample(i,v.loaded),v.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},g.onError=function(u,e){switch(e.details){case b.ErrorDetails.FRAG_LOAD_ERROR:case b.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},g.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},g.getNextABRAutoLevel=function(){var u=this.fragCurrent,e=this.partCurrent,s=this.hls,c=s.maxAutoLevel,v=s.config,i=s.minAutoLevel,r=s.media,o=e?e.duration:u?u.duration:0,d=r?r.currentTime:0,t=r&&r.playbackRate!==0?Math.abs(r.playbackRate):1,n=this.bwEstimator?this.bwEstimator.getEstimate():v.abrEwmaDefaultEstimate,l=(C.BufferHelper.bufferInfo(r,d,v.maxBufferHole).end-d)/t,a=this.findBestLevel(n,i,c,l,v.abrBandWidthFactor,v.abrBandWidthUpFactor);if(a>=0)return a;A.logger.trace((l?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var f=o?Math.min(o,v.maxStarvationDelay):v.maxStarvationDelay,h=v.abrBandWidthFactor,S=v.abrBandWidthUpFactor;if(!l){var x=this.bitrateTestDelay;if(x){var P=o?Math.min(o,v.maxLoadingDelay):v.maxLoadingDelay;f=P-x,A.logger.trace("bitrate test took "+Math.round(1e3*x)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*f)+" ms"),h=S=1}}return a=this.findBestLevel(n,i,c,l+f,h,S),Math.max(a,0)},g.findBestLevel=function(u,e,s,c,v,i){for(var r,o=this.fragCurrent,d=this.partCurrent,t=this.lastLoadedFragLevel,n=this.hls.levels,l=n[t],a=!!(l!=null&&(r=l.details)!==null&&r!==void 0&&r.live),f=l==null?void 0:l.codecSet,h=d?d.duration:o?o.duration:0,S=s;S>=e;S--){var x=n[S];if(!(!x||f&&x.codecSet!==f)){var P=x.details,k=(d?P==null?void 0:P.partTarget:P==null?void 0:P.averagetargetduration)||h,B=void 0;S<=t?B=v*u:B=i*u;var U=n[S].maxBitrate,W=U*k/B;if(A.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+S+"/"+Math.round(B)+"/"+U+"/"+k+"/"+c+"/"+W),B>U&&(!W||a&&!this.bitrateTestDelay||W<c))return S}}return-1},T(E,[{key:"nextAutoLevel",get:function(){var u=this._nextAutoLevel,e=this.bwEstimator;if(u!==-1&&!e.canEstimate())return u;var s=this.getNextABRAutoLevel();return u!==-1&&this.hls.levels[s].loadError?u:(u!==-1&&(s=Math.min(u,s)),s)},set:function(u){this._nextAutoLevel=u}}]),E}();R.default=D},"./src/controller/audio-stream-controller.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/polyfills/number.ts"),_=m("./src/controller/base-stream-controller.ts"),L=m("./src/events.ts"),C=m("./src/utils/buffer-helper.ts"),b=m("./src/controller/fragment-tracker.ts"),O=m("./src/types/level.ts"),A=m("./src/types/loader.ts"),y=m("./src/loader/fragment.ts"),T=m("./src/demux/chunk-cache.ts"),D=m("./src/demux/transmuxer-interface.ts"),E=m("./src/types/transmuxer.ts"),g=m("./src/controller/fragment-finders.ts"),p=m("./src/utils/discontinuities.ts"),u=m("./src/errors.ts");function e(){return e=Object.assign?Object.assign.bind():function(r){for(var o=1;o<arguments.length;o++){var d=arguments[o];for(var t in d)Object.prototype.hasOwnProperty.call(d,t)&&(r[t]=d[t])}return r},e.apply(this,arguments)}function s(r,o){r.prototype=Object.create(o.prototype),r.prototype.constructor=r,c(r,o)}function c(r,o){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},c(r,o)}var v=100,i=function(r){s(o,r);function o(t,n){var l;return l=r.call(this,t,n,"[audio-stream-controller]")||this,l.videoBuffer=null,l.videoTrackCC=-1,l.waitingVideoCC=-1,l.audioSwitch=!1,l.trackId=-1,l.waitingData=null,l.mainDetails=null,l.bufferFlushed=!1,l.cachedTrackLoadedData=null,l._registerListeners(),l}var d=o.prototype;return d.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},d._registerListeners=function(){var n=this.hls;n.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(L.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.on(L.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.on(L.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.on(L.Events.ERROR,this.onError,this),n.on(L.Events.BUFFER_RESET,this.onBufferReset,this),n.on(L.Events.BUFFER_CREATED,this.onBufferCreated,this),n.on(L.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.on(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.on(L.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d._unregisterListeners=function(){var n=this.hls;n.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(L.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.off(L.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.off(L.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.off(L.Events.ERROR,this.onError,this),n.off(L.Events.BUFFER_RESET,this.onBufferReset,this),n.off(L.Events.BUFFER_CREATED,this.onBufferCreated,this),n.off(L.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.off(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(L.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d.onInitPtsFound=function(n,l){var a=l.frag,f=l.id,h=l.initPTS;if(f==="main"){var S=a.cc;this.initPTS[a.cc]=h,this.log("InitPTS for cc: "+S+" found from main: "+h),this.videoTrackCC=S,this.state===_.State.WAITING_INIT_PTS&&this.tick()}},d.startLoad=function(n){if(!this.levels){this.startPosition=n,this.state=_.State.STOPPED;return}var l=this.lastCurrentTime;this.stopLoad(),this.setInterval(v),this.fragLoadError=0,l>0&&n===-1?(this.log("Override startPosition with lastCurrentTime @"+l.toFixed(3)),n=l,this.state=_.State.IDLE):(this.loadedmetadata=!1,this.state=_.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=n,this.tick()},d.doTick=function(){switch(this.state){case _.State.IDLE:this.doTickIdle();break;case _.State.WAITING_TRACK:{var n,l=this.levels,a=this.trackId,f=l==null||(n=l[a])===null||n===void 0?void 0:n.details;if(f){if(this.waitForCdnTuneIn(f))break;this.state=_.State.WAITING_INIT_PTS}break}case _.State.FRAG_LOADING_WAITING_RETRY:{var h,S=performance.now(),x=this.retryDate;(!x||S>=x||(h=this.media)!==null&&h!==void 0&&h.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=_.State.IDLE);break}case _.State.WAITING_INIT_PTS:{var P=this.waitingData;if(P){var k=P.frag,B=P.part,U=P.cache,W=P.complete;if(this.initPTS[k.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=_.State.FRAG_LOADING;var G=U.flush(),z={frag:k,part:B,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 ("+k.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var Y=this.getLoadPosition(),$=C.BufferHelper.bufferInfo(this.mediaBuffer,Y,this.config.maxBufferHole),Z=Object(g.fragmentWithinToleranceTest)($.end,this.config.maxFragLookUpTolerance,k);Z<0&&(this.log("Waiting fragment cc ("+k.cc+") @ "+k.start+" cancelled because another fragment at "+$.end+" is needed"),this.clearWaitingFragment())}}else this.state=_.State.IDLE}}this.onTickEnd()},d.clearWaitingFragment=function(){var n=this.waitingData;n&&(this.fragmentTracker.removeFragment(n.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=_.State.IDLE)},d.resetLoadingState=function(){this.clearWaitingFragment(),r.prototype.resetLoadingState.call(this)},d.onTickEnd=function(){var n=this.media;if(!(!n||!n.readyState)){var l=this.mediaBuffer?this.mediaBuffer:n,a=l.buffered;!this.loadedmetadata&&a.length&&(this.loadedmetadata=!0),this.lastCurrentTime=n.currentTime}},d.doTickIdle=function(){var n,l,a=this.hls,f=this.levels,h=this.media,S=this.trackId,x=a.config;if(!(!f||!f[S])&&!(!h&&(this.startFragRequested||!x.startFragPrefetch))){var P=f[S],k=P.details;if(!k||k.live&&this.levelLastLoaded!==S||this.waitForCdnTuneIn(k)){this.state=_.State.WAITING_TRACK;return}var B=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&B&&(this.bufferFlushed=!1,this.afterBufferFlushed(B,y.ElementaryStreamTypes.AUDIO,A.PlaylistLevelType.AUDIO));var U=this.getFwdBufferInfo(B,A.PlaylistLevelType.AUDIO);if(U!==null){var W=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,A.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,k)){a.trigger(L.Events.BUFFER_EOS,{type:"audio"}),this.state=_.State.ENDED;return}var $=k.fragments,Z=$[0].start,q=U.end;if(Y&&h){var ie=this.getLoadPosition();q=ie,k.PTSKnown&&ie<Z&&(U.end>Z||U.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),h.currentTime=Z+.05)}if(!(W&&q>W.end+k.targetduration)&&!((!W||!W.len)&&U.len)){var ne=this.getNextFragment(q,k);if(!ne){this.bufferFlushed=!0;return}((n=ne.decryptdata)===null||n===void 0?void 0:n.keyFormat)==="identity"&&!((l=ne.decryptdata)!==null&&l!==void 0&&l.key)?this.loadKey(ne,k):this.loadFragment(ne,k,q)}}}}},d.getMaxBufferLength=function(n){var l=r.prototype.getMaxBufferLength.call(this);return n?Math.max(l,n):l},d.onMediaDetaching=function(){this.videoBuffer=null,r.prototype.onMediaDetaching.call(this)},d.onAudioTracksUpdated=function(n,l){var a=l.audioTracks;this.resetTransmuxer(),this.levels=a.map(function(f){return new O.Level(f)})},d.onAudioTrackSwitching=function(n,l){var a=!!l.url;this.trackId=l.id;var f=this.fragCurrent;f!=null&&f.loader&&f.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),a?this.setInterval(v):this.resetTransmuxer(),a?(this.audioSwitch=!0,this.state=_.State.IDLE):this.state=_.State.STOPPED,this.tick()},d.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},d.onLevelLoaded=function(n,l){this.mainDetails=l.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(L.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},d.onAudioTrackLoaded=function(n,l){var a;if(this.mainDetails==null){this.cachedTrackLoadedData=l;return}var f=this.levels,h=l.details,S=l.id;if(!f){this.warn("Audio tracks were reset while loading level "+S);return}this.log("Track "+S+" loaded ["+h.startSN+","+h.endSN+"],duration:"+h.totalduration);var x=f[S],P=0;if(h.live||(a=x.details)!==null&&a!==void 0&&a.live){var k=this.mainDetails;if(h.fragments[0]||(h.deltaUpdateFailed=!0),h.deltaUpdateFailed||!k)return;!x.details&&h.hasProgramDateTime&&k.hasProgramDateTime?(Object(p.alignMediaPlaylistByPDT)(h,k),P=h.fragments[0].start):P=this.alignPlaylists(h,x.details)}x.details=h,this.levelLastLoaded=S,!this.startFragRequested&&(this.mainDetails||!h.live)&&this.setStartPosition(x.details,P),this.state===_.State.WAITING_TRACK&&!this.waitForCdnTuneIn(h)&&(this.state=_.State.IDLE),this.tick()},d._handleFragmentLoadProgress=function(n){var l,a=n.frag,f=n.part,h=n.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 "+a.sn+" of level "+a.level+" will not be buffered");return}var k=P[x];console.assert(k,"Audio track is defined on fragment load progress");var B=k.details;console.assert(B,"Audio track details are defined on fragment load progress");var U=S.defaultAudioCodec||k.audioCodec||"mp4a.40.2",W=this.transmuxer;W||(W=this.transmuxer=new D.default(this.hls,A.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var G=this.initPTS[a.cc],z=(l=a.initSegment)===null||l===void 0?void 0:l.data;if(G!==void 0){var Y=!1,$=f?f.index:-1,Z=$!==-1,q=new E.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,h.byteLength,$,Z);W.push(h,z,U,"",a,f,B.totalduration,Y,q,G)}else{this.log("Unknown video PTS for cc "+a.cc+", waiting for video PTS before demuxing audio frag "+a.sn+" of ["+B.startSN+" ,"+B.endSN+"],track "+x);var ie=this.waitingData=this.waitingData||{frag:a,part:f,cache:new T.default,complete:!1},ne=ie.cache;ne.push(new Uint8Array(h)),this.waitingVideoCC=this.videoTrackCC,this.state=_.State.WAITING_INIT_PTS}},d._handleFragmentLoadComplete=function(n){if(this.waitingData){this.waitingData.complete=!0;return}r.prototype._handleFragmentLoadComplete.call(this,n)},d.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},d.onBufferCreated=function(n,l){var a=l.tracks.audio;a&&(this.mediaBuffer=a.buffer||null),l.tracks.video&&(this.videoBuffer=l.tracks.video.buffer||null)},d.onFragBuffered=function(n,l){var a=l.frag,f=l.part;if(a.type===A.PlaylistLevelType.AUDIO){if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(f?" p: "+f.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}a.sn!=="initSegment"&&(this.fragPrevious=a,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(L.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(a,f)}},d.onError=function(n,l){switch(l.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.AUDIO,l);break;case u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==_.State.ERROR&&this.state!==_.State.STOPPED&&(this.state=l.fatal?_.State.ERROR:_.State.IDLE,this.warn(l.details+" while loading frag, switching to "+this.state+" state"));break;case u.ErrorDetails.BUFFER_FULL_ERROR:if(l.parent==="audio"&&(this.state===_.State.PARSING||this.state===_.State.PARSED)){var a=!0,f=this.getFwdBufferInfo(this.mediaBuffer,A.PlaylistLevelType.AUDIO);f&&f.len>.5&&(a=!this.reduceMaxBufferLength(f.len)),a&&(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}},d.onBufferFlushed=function(n,l){var a=l.type;a===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},d._handleTransmuxComplete=function(n){var l,a="audio",f=this.hls,h=n.remuxResult,S=n.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,k=x.part,B=x.level.details,U=h.audio,W=h.text,G=h.id3,z=h.initSegment;if(!(this.fragContextChanged(P)||!B)){if(this.state=_.State.PARSING,this.audioSwitch&&U&&this.completeAudioSwitch(),z!=null&&z.tracks&&(this._bufferInitSegment(z.tracks,P,S),f.trigger(L.Events.FRAG_PARSING_INIT_SEGMENT,{frag:P,id:a,tracks:z.tracks})),U){var Y=U.startPTS,$=U.endPTS,Z=U.startDTS,q=U.endDTS;k&&(k.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:Y,endPTS:$,startDTS:Z,endDTS:q}),P.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,Y,$,Z,q),this.bufferFragmentData(U,P,k,S)}if(G!=null&&(l=G.samples)!==null&&l!==void 0&&l.length){var ie=e({id:a,frag:P,details:B},G);f.trigger(L.Events.FRAG_PARSING_METADATA,ie)}if(W){var ne=e({id:a,frag:P,details:B},W);f.trigger(L.Events.FRAG_PARSING_USERDATA,ne)}}},d._bufferInitSegment=function(n,l,a){if(this.state===_.State.PARSING){n.video&&delete n.video;var f=n.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(L.Events.BUFFER_CODECS,n);var h=f.initSegment;if(h!=null&&h.byteLength){var S={type:"audio",frag:l,part:null,chunkMeta:a,parent:l.type,data:h};this.hls.trigger(L.Events.BUFFER_APPENDING,S)}this.tick()}}},d.loadFragment=function(n,l,a){var f=this.fragmentTracker.getState(n);this.fragCurrent=n,(this.audioSwitch||f===b.FragmentState.NOT_LOADED||f===b.FragmentState.PARTIAL)&&(n.sn==="initSegment"?this._loadInitSegment(n):l.live&&!Object(M.isFiniteNumber)(this.initPTS[n.cc])?(this.log("Waiting for video PTS in continuity counter "+n.cc+" of live stream before loading audio fragment "+n.sn+" of level "+this.trackId),this.state=_.State.WAITING_INIT_PTS):(this.startFragRequested=!0,r.prototype.loadFragment.call(this,n,l,a)))},d.completeAudioSwitch=function(){var n=this.hls,l=this.media,a=this.trackId;l&&(this.log("Switching audio track : flushing all audio"),r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,n.trigger(L.Events.AUDIO_TRACK_SWITCHED,{id:a})},o}(_.default);R.default=i},"./src/controller/audio-track-controller.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/events.ts"),_=m("./src/errors.ts"),L=m("./src/controller/base-playlist-controller.ts"),C=m("./src/types/loader.ts");function b(D,E){for(var g=0;g<E.length;g++){var p=E[g];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(D,p.key,p)}}function O(D,E,g){return E&&b(D.prototype,E),g&&b(D,g),Object.defineProperty(D,"prototype",{writable:!1}),D}function A(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,u){return p.__proto__=u,p},y(D,E)}var T=function(D){A(E,D);function E(p){var u;return u=D.call(this,p,"[audio-track-controller]")||this,u.tracks=[],u.groupId=null,u.tracksInGroup=[],u.trackId=-1,u.trackName="",u.selectDefaultTrack=!0,u.registerListeners(),u}var g=E.prototype;return g.registerListeners=function(){var u=this.hls;u.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.on(M.Events.LEVEL_LOADING,this.onLevelLoading,this),u.on(M.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.on(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(M.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){var u=this.hls;u.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.off(M.Events.LEVEL_LOADING,this.onLevelLoading,this),u.off(M.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.off(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(M.Events.ERROR,this.onError,this)},g.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,D.prototype.destroy.call(this)},g.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},g.onManifestParsed=function(u,e){this.tracks=e.audioTracks||[]},g.onAudioTrackLoaded=function(u,e){var s=e.id,c=e.details,v=this.tracksInGroup[s];if(!v){this.warn("Invalid audio track id "+s);return}var i=v.details;v.details=e.details,this.log("audioTrack "+s+" loaded ["+c.startSN+"-"+c.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,e,i))},g.onLevelLoading=function(u,e){this.switchLevel(e.level)},g.onLevelSwitching=function(u,e){this.switchLevel(e.level)},g.switchLevel=function(u){var e=this.hls.levels[u];if(!!(e!=null&&e.audioGroupIds)){var s=e.audioGroupIds[e.urlId];if(this.groupId!==s){this.groupId=s;var c=this.tracks.filter(function(i){return!s||i.groupId===s});this.selectDefaultTrack&&!c.some(function(i){return i.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=c;var v={audioTracks:c};this.log("Updating audio tracks, "+c.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(M.Events.AUDIO_TRACKS_UPDATED,v),this.selectInitialTrack()}}},g.onError=function(u,e){D.prototype.onError.call(this,u,e),!(e.fatal||!e.context)&&e.context.type===C.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},g.setAudioTrack=function(u){var e=this.tracksInGroup;if(u<0||u>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var s=e[this.trackId];this.log("Now switching to audio-track index "+u);var c=e[u],v=c.id,i=c.groupId,r=i===void 0?"":i,o=c.name,d=c.type,t=c.url;if(this.trackId=u,this.trackName=o,this.selectDefaultTrack=!1,this.hls.trigger(M.Events.AUDIO_TRACK_SWITCHING,{id:v,groupId:r,name:o,type:d,url:t}),!(c.details&&!c.details.live)){var n=this.switchParams(c.url,s==null?void 0:s.details);this.loadPlaylist(n)}},g.selectInitialTrack=function(){var u=this.tracksInGroup;console.assert(u.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,s=this.findTrackId(e)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},g.findTrackId=function(u){for(var e=this.tracksInGroup,s=0;s<e.length;s++){var c=e[s];if((!this.selectDefaultTrack||c.default)&&(!u||u===c.name))return c.id}return-1},g.loadPlaylist=function(u){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var s=e.id,c=e.groupId,v=e.url;if(u)try{v=u.addDirectives(v)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("loading audio-track playlist for id: "+s),this.clearTimer(),this.hls.trigger(M.Events.AUDIO_TRACK_LOADING,{url:v,id:s,groupId:c,deliveryDirectives:u||null})}},O(E,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(u){this.selectDefaultTrack=!1,this.setAudioTrack(u)}}]),E}(L.default);R.default=T},"./src/controller/base-playlist-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return O});var M=m("./src/polyfills/number.ts"),_=m("./src/types/level.ts"),L=m("./src/controller/level-helper.ts"),C=m("./src/utils/logger.ts"),b=m("./src/errors.ts"),O=function(){function A(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=C.logger.log.bind(C.logger,D+":"),this.warn=C.logger.warn.bind(C.logger,D+":"),this.hls=T}var y=A.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(D,E){E.fatal&&E.type===b.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 g=E==null?void 0:E.renditionReports;if(g)for(var p=0;p<g.length;p++){var u=g[p],e=""+u.URI;if(e===D.slice(-e.length)){var s=parseInt(u["LAST-MSN"]),c=parseInt(u["LAST-PART"]);if(E&&this.hls.config.lowLatencyMode){var v=Math.min(E.age-E.partTarget,E.targetduration);c!==void 0&&v>E.partTarget&&(c+=1)}if(Object(M.isFiniteNumber)(s))return new _.HlsUrlParameters(s,Object(M.isFiniteNumber)(c)?c:void 0,_.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,g){var p=this,u=E.details,e=E.stats,s=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(u.advancedDateTime=Date.now()-s,u.live||g!=null&&g.live){if(u.reloaded(g),g&&this.log("live playlist "+D+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:"MISSED")),g&&u.fragments.length>0&&Object(L.mergeDetails)(g,u),!this.canLoad||!u.live)return;var c,v=void 0,i=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var r=this.hls.config.lowLatencyMode,o=u.lastPartSn,d=u.endSN,t=u.lastPartIndex,n=t!==-1,l=o===d,a=r?0:t;n?(v=l?d+1:o,i=l?a:t+1):v=d+1;var f=u.age,h=f+u.ageHeader,S=Math.min(h-u.partTarget,u.targetduration*1.5);if(S>0){if(g&&S>g.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+g.tuneInGoal+" to: "+S+" with playlist age: "+u.age),S=0;else{var x=Math.floor(S/u.targetduration);if(v+=x,i!==void 0){var P=Math.round(S%u.targetduration/u.partTarget);i+=P}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+f.toFixed(2)+"s goal: "+S+" skip sn "+x+" to part "+i)}u.tuneInGoal=S}if(c=this.getDeliveryDirectives(u,E.deliveryDirectives,v,i),r||!l){this.loadPlaylist(c);return}}else c=this.getDeliveryDirectives(u,E.deliveryDirectives,v,i);var k=Object(L.computeReloadInterval)(u,e);v!==void 0&&u.canBlockReload&&(k-=u.partTarget||1),this.log("reload live playlist "+D+" in "+Math.round(k)+" ms"),this.timer=self.setTimeout(function(){return p.loadPlaylist(c)},k)}else this.clearTimer()},y.getDeliveryDirectives=function(D,E,g,p){var u=Object(_.getSkipValue)(D,g);return E!=null&&E.skip&&D.deltaUpdateFailed&&(g=E.msn,p=E.part,u=_.HlsSkip.No),new _.HlsUrlParameters(g,p,u)},y.retryLoadingOrFail=function(D){var E=this,g=this.hls.config,p=this.retryCount<g.levelLoadingMaxRetry;if(p){var u;if(this.retryCount++,D.details.indexOf("LoadTimeOut")>-1&&(u=D.context)!==null&&u!==void 0&&u.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+D.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*g.levelLoadingRetryDelay,g.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},A}()},"./src/controller/base-stream-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"State",function(){return d}),m.d(R,"default",function(){return t});var M=m("./src/polyfills/number.ts"),_=m("./src/task-loop.ts"),L=m("./src/controller/fragment-tracker.ts"),C=m("./src/utils/buffer-helper.ts"),b=m("./src/utils/logger.ts"),O=m("./src/events.ts"),A=m("./src/errors.ts"),y=m("./src/types/transmuxer.ts"),T=m("./src/utils/mp4-tools.ts"),D=m("./src/utils/discontinuities.ts"),E=m("./src/controller/fragment-finders.ts"),g=m("./src/controller/level-helper.ts"),p=m("./src/loader/fragment-loader.ts"),u=m("./src/crypt/decrypter.ts"),e=m("./src/utils/time-ranges.ts"),s=m("./src/types/loader.ts");function c(n,l){for(var a=0;a<l.length;a++){var f=l[a];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(n,f.key,f)}}function v(n,l,a){return l&&c(n.prototype,l),a&&c(n,a),Object.defineProperty(n,"prototype",{writable:!1}),n}function i(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function r(n,l){n.prototype=Object.create(l.prototype),n.prototype.constructor=n,o(n,l)}function o(n,l){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,h){return f.__proto__=h,f},o(n,l)}var d={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(n){r(l,n);function l(f,h,S){var x;return x=n.call(this)||this,x.hls=void 0,x.fragPrevious=null,x.fragCurrent=null,x.fragmentTracker=void 0,x.transmuxer=null,x._state=d.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=b.logger.log.bind(b.logger,S+":"),x.warn=b.logger.warn.bind(b.logger,S+":"),x.hls=f,x.fragmentLoader=new p.default(f.config),x.fragmentTracker=h,x.config=f.config,x.decrypter=new u.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 a=l.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(h){},a.stopLoad=function(){this.fragmentLoader.abort();var h=this.fragCurrent;h&&this.fragmentTracker.removeFragment(h),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=d.STOPPED},a._streamEnded=function(h,S){var x=this.fragCurrent,P=this.fragmentTracker;if(!S.live&&x&&this.media&&x.sn>=S.endSN&&!h.nextStart){var k=S.partList;if(k!=null&&k.length){var B=k[k.length-1],U=C.BufferHelper.isBuffered(this.media,B.start+B.duration/2);return U}var W=P.getState(x);return W===L.FragmentState.PARTIAL||W===L.FragmentState.OK}return!1},a.onMediaAttached=function(h,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===d.STOPPED&&this.startLoad(P.startPosition)},a.onMediaDetaching=function(){var h=this.media;h!=null&&h.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),h&&this.onvseeking&&this.onvended&&(h.removeEventListener("seeking",this.onvseeking),h.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var h=this.config,S=this.fragCurrent,x=this.media,P=this.mediaBuffer,k=this.state,B=x?x.currentTime:0,U=C.BufferHelper.bufferInfo(P||x,B,h.maxBufferHole);if(this.log("media seeking to "+(Object(M.isFiniteNumber)(B)?B.toFixed(3):B)+", state: "+k),k===d.ENDED)this.resetLoadingState();else if(S&&!U.len){var W=h.maxFragLookUpTolerance,G=S.start-W,z=S.start+S.duration+W,Y=B>z;(B<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=B),!this.loadedmetadata&&!U.len&&(this.nextLoadPosition=this.startPosition=B),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(h,S){if(!(this.state!==d.KEY_LOADING||S.frag!==this.fragCurrent||!this.levels)){this.state=d.IDLE;var x=this.levels[S.frag.level].details;x&&this.loadFragment(S.frag,x,S.frag.start)}},a.onLevelSwitching=function(h,S){this.fragLoadError=0},a.onHandlerDestroying=function(){this.stopLoad(),n.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=d.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,n.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(h,S){this.log("Loading key for "+h.sn+" of ["+S.startSN+"-"+S.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+h.level),this.state=d.KEY_LOADING,this.fragCurrent=h,this.hls.trigger(O.Events.KEY_LOADING,{frag:h})},a.loadFragment=function(h,S,x){this._loadFragForPlayback(h,S,x)},a._loadFragForPlayback=function(h,S,x){var P=this,k=function(U){if(P.fragContextChanged(h)){P.warn("Fragment "+h.sn+(U.part?" p: "+U.part.index:"")+" of level "+h.level+" was dropped during download."),P.fragmentTracker.removeFragment(h);return}h.stats.chunkCount++,P._handleFragmentLoadProgress(U)};this._doFragLoad(h,S,x,k).then(function(B){if(!!B){P.fragLoadError=0;var U=P.state;if(P.fragContextChanged(h)){(U===d.FRAG_LOADING||!P.fragCurrent&&U===d.PARSING)&&(P.fragmentTracker.removeFragment(h),P.state=d.IDLE);return}"payload"in B&&(P.log("Loaded fragment "+h.sn+" of level "+h.level),P.hls.trigger(O.Events.FRAG_LOADED,B)),P._handleFragmentLoadComplete(B)}}).catch(function(B){P.state===d.STOPPED||P.state===d.ERROR||(P.warn(B),P.resetFragmentLoading(h))})},a.flushMainBuffer=function(h,S,x){if(x===void 0&&(x=null),!!(h-S)){var P={startOffset:h,endOffset:S,type:x};this.fragLoadError=0,this.hls.trigger(O.Events.BUFFER_FLUSHING,P)}},a._loadInitSegment=function(h){var S=this;this._doFragLoad(h).then(function(x){if(!x||S.fragContextChanged(h)||!S.levels)throw new Error("init load aborted");return x}).then(function(x){var P=S.hls,k=x.payload,B=h.decryptdata;if(k&&k.byteLength>0&&B&&B.key&&B.iv&&B.method==="AES-128"){var U=self.performance.now();return S.decrypter.webCryptoDecrypt(new Uint8Array(k),B.key.buffer,B.iv.buffer).then(function(W){var G=self.performance.now();return P.trigger(O.Events.FRAG_DECRYPTED,{frag:h,payload:W,stats:{tstart:U,tdecrypt:G}}),x.payload=W,x})}return x}).then(function(x){var P=S.fragCurrent,k=S.hls,B=S.levels;if(!B)throw new Error("init load aborted, missing levels");var U=B[h.level].details;console.assert(U,"Level details are defined when init segment is loaded");var W=h.stats;S.state=d.IDLE,S.fragLoadError=0,h.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&&k.trigger(O.Events.FRAG_BUFFERED,{stats:W,frag:P,part:null,id:h.type}),S.tick()}).catch(function(x){S.state===d.STOPPED||S.state===d.ERROR||(S.warn(x),S.resetFragmentLoading(h))})},a.fragContextChanged=function(h){var S=this.fragCurrent;return!h||!S||h.level!==S.level||h.sn!==S.sn||h.urlId!==S.urlId},a.fragBufferedComplete=function(h,S){var x=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+h.type+" sn: "+h.sn+(S?" part: "+S.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+h.level+" "+(x?e.default.toString(C.BufferHelper.getBuffered(x)):"(detached)")),this.state=d.IDLE,x&&(!this.loadedmetadata&&x.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},a.seekToStartPos=function(){},a._handleFragmentLoadComplete=function(h){var S=this.transmuxer;if(!!S){var x=h.frag,P=h.part,k=h.partsLoaded,B=!k||k.length===0||k.some(function(W){return!W}),U=new y.ChunkMetadata(x.level,x.sn,x.stats.chunkCount+1,0,P?P.index:-1,!B);S.flush(U)}},a._handleFragmentLoadProgress=function(h){},a._doFragLoad=function(h,S,x,P){var k=this;if(x===void 0&&(x=null),!this.levels)throw new Error("frag load aborted, missing levels");if(x=Math.max(h.start,x||0),this.config.lowLatencyMode&&S){var B=S.partList;if(B&&P){x>h.end&&S.fragmentHint&&(h=S.fragmentHint);var U=this.getNextPart(B,h,x);if(U>-1){var W=B[U];return this.log("Loading part sn: "+h.sn+" p: "+W.index+" cc: "+h.cc+" of playlist ["+S.startSN+"-"+S.endSN+"] parts [0-"+U+"-"+(B.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+h.level+", target: "+parseFloat(x.toFixed(3))),this.nextLoadPosition=W.start+W.duration,this.state=d.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:h,part:B[U],targetBufferTime:x}),this.doFragPartsLoad(h,B,U,P).catch(function(G){return k.handleFragLoadError(G)})}else if(!h.url||this.loadedEndOfParts(B,x))return Promise.resolve(null)}}return this.log("Loading fragment "+h.sn+" cc: "+h.cc+" "+(S?"of ["+S.startSN+"-"+S.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+h.level+", target: "+parseFloat(x.toFixed(3))),Object(M.isFiniteNumber)(h.sn)&&!this.bitrateTest&&(this.nextLoadPosition=h.start+h.duration),this.state=d.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:h,targetBufferTime:x}),this.fragmentLoader.load(h,P).catch(function(G){return k.handleFragLoadError(G)})},a.doFragPartsLoad=function(h,S,x,P){var k=this;return new Promise(function(B,U){var W=[],G=function z(Y){var $=S[Y];k.fragmentLoader.loadPart(h,$,P).then(function(Z){W[$.index]=Z;var q=Z.part;k.hls.trigger(O.Events.FRAG_LOADED,Z);var ie=S[Y+1];if(ie&&ie.fragment===h)z(Y+1);else return B({frag:h,part:q,partsLoaded:W})}).catch(U)};G(x)})},a.handleFragLoadError=function(h){var S=h.data;return S&&S.details===A.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(S.frag,S.part):this.hls.trigger(O.Events.ERROR,S),null},a._handleTransmuxerFlush=function(h){var S=this.getCurrentContext(h);if(!S||this.state!==d.PARSING){this.fragCurrent||(this.state=d.IDLE);return}var x=S.frag,P=S.part,k=S.level,B=self.performance.now();x.stats.parsing.end=B,P&&(P.stats.parsing.end=B),this.updateLevelTiming(x,P,k,h.partial)},a.getCurrentContext=function(h){var S=this.levels,x=h.level,P=h.sn,k=h.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 B=S[x],U=k>-1?Object(g.getPartWith)(B,P,k):null,W=U?U.fragment:Object(g.getFragmentWithSN)(B,P,this.fragCurrent);return W?{frag:W,part:U,level:B}:null},a.bufferFragmentData=function(h,S,x,P){if(!(!h||this.state!==d.PARSING)){var k=h.data1,B=h.data2,U=k;if(k&&B&&(U=Object(T.appendUint8Array)(k,B)),!(!U||!U.length)){var W={type:h.type,frag:S,part:x,chunkMeta:P,parent:S.type,data:U};this.hls.trigger(O.Events.BUFFER_APPENDING,W),h.dropped&&h.independent&&!x&&this.flushBufferGap(S)}}},a.flushBufferGap=function(h){var S=this.media;if(!!S){if(!C.BufferHelper.isBuffered(S,S.currentTime)){this.flushMainBuffer(0,h.start);return}var x=S.currentTime,P=C.BufferHelper.bufferInfo(S,x,0),k=h.duration,B=Math.min(this.config.maxFragLookUpTolerance*2,k*.25),U=Math.max(Math.min(h.start-B,P.end-B),x+B);h.start-U>B&&this.flushMainBuffer(U,h.start)}},a.getFwdBufferInfo=function(h,S){var x=this.config,P=this.getLoadPosition();if(!Object(M.isFiniteNumber)(P))return null;var k=C.BufferHelper.bufferInfo(h,P,x.maxBufferHole);if(k.len===0&&k.nextStart!==void 0){var B=this.fragmentTracker.getBufferedFrag(P,S);if(B&&k.nextStart<B.end)return C.BufferHelper.bufferInfo(h,P,Math.max(k.nextStart,x.maxBufferHole))}return k},a.getMaxBufferLength=function(h){var S=this.config,x;return h?x=Math.max(8*S.maxBufferSize/h,S.maxBufferLength):x=S.maxBufferLength,Math.min(x,S.maxMaxBufferLength)},a.reduceMaxBufferLength=function(h){var S=this.config,x=h||S.maxBufferLength;return S.maxMaxBufferLength>=x?(S.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+S.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(h,S){var x=S.fragments,P=x.length;if(!P)return null;var k=this.config,B=x[0].start,U;if(S.live){var W=k.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:h)}else h<=B&&(U=x[0]);if(!U){var G=k.lowLatencyMode?S.partEnd:S.fragmentEnd;U=this.getFragmentAtPosition(h,G,S)}return this.mapToInitFragWhenRequired(U)},a.mapToInitFragWhenRequired=function(h){return h!=null&&h.initSegment&&!(h!=null&&h.initSegment.data)&&!this.bitrateTest?h.initSegment:h},a.getNextPart=function(h,S,x){for(var P=-1,k=!1,B=!0,U=0,W=h.length;U<W;U++){var G=h[U];if(B=B&&!G.independent,P>-1&&x<G.start)break;var z=G.loaded;!z&&(k||G.independent||B)&&G.fragment===S&&(P=U),k=z}return P},a.loadedEndOfParts=function(h,S){var x=h[h.length-1];return x&&S>x.start&&x.loaded},a.getInitialLiveFragment=function(h,S){var x=this.fragPrevious,P=null;if(x){if(h.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 k=x.sn+1;if(k>=h.startSN&&k<=h.endSN){var B=S[k-h.startSN];x.cc===B.cc&&(P=B,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?h.fragmentEnd:h.edge,h))}return P},a.getFragmentAtPosition=function(h,S,x){var P=this.config,k=this.fragPrevious,B=x.fragments,U=x.endSN,W=x.fragmentHint,G=P.maxFragLookUpTolerance,z=!!(P.lowLatencyMode&&x.partList&&W);z&&W&&!this.bitrateTest&&(B=B.concat(W),U=W.sn);var Y;if(h<S){var $=h>S-G?0:G;Y=Object(E.findFragmentByPTS)(k,B,h,$)}else Y=B[B.length-1];if(Y){var Z=Y.sn-x.startSN;if(k&&Y.sn===k.sn&&!z){var q=k&&Y.level===k.level;if(q){var ie=B[Z+1];Y.sn<U&&this.fragmentTracker.getState(ie)!==L.FragmentState.OK?(this.log("SN "+Y.sn+" just loaded, load next one: "+ie.sn),Y=ie):Y=null}}}return Y},a.synchronizeToLiveEdge=function(h){var S=this.config,x=this.media;if(!!x){var P=this.hls.liveSyncPosition,k=x.currentTime,B=h.fragments[0].start,U=h.edge,W=k>=B-S.maxFragLookUpTolerance&&k<=U;if(P!==null&&x.duration>P&&(k<P||!W)){var G=S.liveMaxLatencyDuration!==void 0?S.liveMaxLatencyDuration:S.liveMaxLatencyDurationCount*h.targetduration;(!W&&x.readyState<4||k<U-G)&&(this.loadedmetadata||(this.nextLoadPosition=P),x.readyState&&(this.warn("Playback: "+k.toFixed(3)+" is located too far from the end of live sliding playlist: "+U+", reset currentTime to : "+P.toFixed(3)),x.currentTime=P))}}},a.alignPlaylists=function(h,S){var x=this.levels,P=this.levelLastLoaded,k=this.fragPrevious,B=P!==null?x[P]:null,U=h.fragments.length;if(!U)return this.warn("No fragments in live playlist"),0;var W=h.fragments[0].start,G=!S,z=h.alignedSliding&&Object(M.isFiniteNumber)(W);if(G||!z&&!W){Object(D.alignStream)(k,B,h);var Y=h.fragments[0].start;return this.log("Live playlist sliding: "+Y.toFixed(2)+" start-sn: "+(S?S.startSN:"na")+"->"+h.startSN+" prev-sn: "+(k?k.sn:"na")+" fragments: "+U),Y}return W},a.waitForCdnTuneIn=function(h){var S=3;return h.live&&h.canBlockReload&&h.partTarget&&h.tuneInGoal>Math.max(h.partHoldBack,h.partTarget*S)},a.setStartPosition=function(h,S){var x=this.startPosition;if(x<S&&(x=-1),x===-1||this.lastCurrentTime===-1){var P=h.startTimeOffset;Object(M.isFiniteNumber)(P)?(x=S+P,P<0&&(x+=h.totalduration),x=Math.min(Math.max(S,x),S+h.totalduration),this.log("Start time offset "+P+" found in playlist, adjust startPosition to "+x),this.startPosition=x):h.live?x=this.hls.liveSyncPosition||S:this.startPosition=x=0,this.lastCurrentTime=x}this.nextLoadPosition=x},a.getLoadPosition=function(){var h=this.media,S=0;return this.loadedmetadata&&h?S=h.currentTime:this.nextLoadPosition&&(S=this.nextLoadPosition),S},a.handleFragLoadAborted=function(h,S){this.transmuxer&&h.sn!=="initSegment"&&h.stats.aborted&&(this.warn("Fragment "+h.sn+(S?" part"+S.index:"")+" of level "+h.level+" was aborted"),this.resetFragmentLoading(h))},a.resetFragmentLoading=function(h){(!this.fragCurrent||!this.fragContextChanged(h)&&this.state!==d.FRAG_LOADING_WAITING_RETRY)&&(this.state=d.IDLE)},a.onFragmentOrKeyLoadError=function(h,S){if(!S.fatal){var x=S.frag;if(!(!x||x.type!==h)){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 k=this.config;if(this.fragLoadError+1<=k.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var B=Math.min(Math.pow(2,this.fragLoadError)*k.fragLoadingRetryDelay,k.fragLoadingMaxRetryTimeout);this.warn("Fragment "+x.sn+" of "+h+" "+x.level+" failed to load, retrying in "+B+"ms"),this.retryDate=self.performance.now()+B,this.fragLoadError++,this.state=d.FRAG_LOADING_WAITING_RETRY}else S.levelRetry?(h===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=d.IDLE):(b.logger.error(S.details+" reaches max retry, redispatch as fatal ..."),S.fatal=!0,this.hls.stopLoad(),this.state=d.ERROR)}}},a.afterBufferFlushed=function(h,S,x){if(!!h){var P=C.BufferHelper.getBuffered(h);this.fragmentTracker.detectEvictedFragments(S,P,x),this.state===d.ENDED&&this.resetLoadingState()}},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=d.IDLE},a.resetStartWhenNotLoaded=function(h){if(!this.loadedmetadata){this.startFragRequested=!1;var S=this.levels?this.levels[h].details:null;S!=null&&S.live?(this.startPosition=-1,this.setStartPosition(S,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},a.updateLevelTiming=function(h,S,x,P){var k=this,B=x.details;console.assert(!!B,"level.details must be defined");var U=Object.keys(h.elementaryStreams).reduce(function(W,G){var z=h.elementaryStreams[G];if(z){var Y=z.endPTS-z.startPTS;if(Y<=0)return k.warn("Could not parse fragment "+h.sn+" "+G+" duration reliably ("+Y+")"),W||!1;var $=P?0:Object(g.updateFragPTSDTS)(B,h,z.startPTS,z.endPTS,z.startDTS,z.endDTS);return k.hls.trigger(O.Events.LEVEL_PTS_UPDATED,{details:B,level:x,drift:$,type:G,frag:h,start:z.startPTS,end:z.endPTS}),!0}return W},!1);U||(this.warn("Found no media in fragment "+h.sn+" of level "+x.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=d.PARSED,this.hls.trigger(O.Events.FRAG_PARSED,{frag:h,part:S})},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},v(l,[{key:"state",get:function(){return this._state},set:function(h){var S=this._state;S!==h&&(this._state=h,this.log(S+"->"+h))}}]),l}(_.default)},"./src/controller/buffer-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return E});var M=m("./src/polyfills/number.ts"),_=m("./src/events.ts"),L=m("./src/utils/logger.ts"),C=m("./src/errors.ts"),b=m("./src/utils/buffer-helper.ts"),O=m("./src/utils/mediasource-helper.ts"),A=m("./src/loader/fragment.ts"),y=m("./src/controller/buffer-operation-queue.ts"),T=Object(O.getMediaSource)(),D=/([ha]vc.)(?:\.[^.,]+)+/,E=function(){function g(u){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 s=e.hls,c=e.media,v=e.mediaSource;L.logger.log("[buffer-controller]: Media source opened"),c&&(e.updateMediaElementDuration(),s.trigger(_.Events.MEDIA_ATTACHED,{media:c})),v&&v.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){L.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){L.logger.log("[buffer-controller]: Media source ended")},this.hls=u,this._initSourceBuffer(),this.registerListeners()}var p=g.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(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.Events.BUFFER_RESET,this.onBufferReset,this),e.on(_.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(_.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_.Events.BUFFER_EOS,this.onBufferEos,this),e.on(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(_.Events.FRAG_PARSED,this.onFragParsed,this),e.on(_.Events.FRAG_CHANGED,this.onFragChanged,this)},p.unregisterListeners=function(){var e=this.hls;e.off(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.Events.BUFFER_RESET,this.onBufferReset,this),e.off(_.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(_.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_.Events.BUFFER_EOS,this.onBufferEos,this),e.off(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(_.Events.FRAG_PARSED,this.onFragParsed,this),e.off(_.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,s){var c=2;(s.audio&&!s.video||!s.altAudio)&&(c=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=c,this.details=null,L.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},p.onMediaAttaching=function(e,s){var c=this.media=s.media;if(c&&T){var v=this.mediaSource=new T;v.addEventListener("sourceopen",this._onMediaSourceOpen),v.addEventListener("sourceended",this._onMediaSourceEnded),v.addEventListener("sourceclose",this._onMediaSourceClose),c.src=self.URL.createObjectURL(v),this._objectUrl=c.src}},p.onMediaDetaching=function(){var e=this.media,s=this.mediaSource,c=this._objectUrl;if(s){if(L.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(v){L.logger.warn("[buffer-controller]: onMediaDetaching: "+v.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(c&&self.URL.revokeObjectURL(c),e.src===c?(e.removeAttribute("src"),e.load()):L.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(_.Events.MEDIA_DETACHED,void 0)},p.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(s){var c=e.sourceBuffer[s];try{c&&(e.removeBufferListeners(s),e.mediaSource&&e.mediaSource.removeSourceBuffer(c),e.sourceBuffer[s]=void 0)}catch(v){L.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",v)}}),this._initSourceBuffer()},p.onBufferCodecs=function(e,s){var c=this,v=this.getSourceBufferTypes().length;Object.keys(s).forEach(function(i){if(v){var r=c.tracks[i];if(r&&typeof r.buffer.changeType=="function"){var o=s[i],d=o.id,t=o.codec,n=o.levelCodec,l=o.container,a=o.metadata,f=(r.levelCodec||r.codec).replace(D,"$1"),h=(n||t).replace(D,"$1");if(f!==h){var S=l+";codecs="+(n||t);c.appendChangeType(i,S),L.logger.log("[buffer-controller]: switching codec "+f+" to "+h),c.tracks[i]={buffer:r.buffer,codec:t,container:l,levelCodec:n,metadata:a,id:d}}}}else c.pendingTracks[i]=s[i]}),!v&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},p.appendChangeType=function(e,s){var c=this,v=this.operationQueue,i={execute:function(){var o=c.sourceBuffer[e];o&&(L.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+s),o.changeType(s)),v.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(o){L.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",o)}};v.append(i,e)},p.onBufferAppending=function(e,s){var c=this,v=this.hls,i=this.operationQueue,r=this.tracks,o=s.data,d=s.type,t=s.frag,n=s.part,l=s.chunkMeta,a=l.buffering[d],f=self.performance.now();a.start=f;var h=t.stats.buffering,S=n?n.stats.buffering:null;h.start===0&&(h.start=f),S&&S.start===0&&(S.start=f);var x=r.audio,P=d==="audio"&&l.id===1&&(x==null?void 0:x.container)==="audio/mpeg",k={execute:function(){if(a.executeStart=self.performance.now(),P){var U=c.sourceBuffer[d];if(U){var W=t.start-U.timestampOffset;Math.abs(W)>=.1&&(L.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+t.start+" (delta: "+W+") sn: "+t.sn+")"),U.timestampOffset=t.start)}}c.appendExecutor(o,d)},onStart:function(){},onComplete:function(){var U=self.performance.now();a.executeEnd=a.end=U,h.first===0&&(h.first=U),S&&S.first===0&&(S.first=U);var W=c.sourceBuffer,G={};for(var z in W)G[z]=b.BufferHelper.getBuffered(W[z]);c.appendError=0,c.hls.trigger(_.Events.BUFFER_APPENDED,{type:d,frag:t,part:n,chunkMeta:l,parent:t.type,timeRanges:G})},onError:function(U){L.logger.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",U);var W={type:C.ErrorTypes.MEDIA_ERROR,parent:t.type,details:C.ErrorDetails.BUFFER_APPEND_ERROR,err:U,fatal:!1};U.code===DOMException.QUOTA_EXCEEDED_ERR?W.details=C.ErrorDetails.BUFFER_FULL_ERROR:(c.appendError++,W.details=C.ErrorDetails.BUFFER_APPEND_ERROR,c.appendError>v.config.appendErrorMaxRetry&&(L.logger.error("[buffer-controller]: Failed "+v.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),W.fatal=!0,v.stopLoad())),v.trigger(_.Events.ERROR,W)}};i.append(k,d)},p.onBufferFlushing=function(e,s){var c=this,v=this.operationQueue,i=function(o){return{execute:c.removeExecutor.bind(c,o,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){c.hls.trigger(_.Events.BUFFER_FLUSHED,{type:o})},onError:function(t){L.logger.warn("[buffer-controller]: Failed to remove from "+o+" SourceBuffer",t)}}};s.type?v.append(i(s.type),s.type):this.getSourceBufferTypes().forEach(function(r){v.append(i(r),r)})},p.onFragParsed=function(e,s){var c=this,v=s.frag,i=s.part,r=[],o=i?i.elementaryStreams:v.elementaryStreams;o[A.ElementaryStreamTypes.AUDIOVIDEO]?r.push("audiovideo"):(o[A.ElementaryStreamTypes.AUDIO]&&r.push("audio"),o[A.ElementaryStreamTypes.VIDEO]&&r.push("video"));var d=function(){var n=self.performance.now();v.stats.buffering.end=n,i&&(i.stats.buffering.end=n);var l=i?i.stats:v.stats;c.hls.trigger(_.Events.FRAG_BUFFERED,{frag:v,part:i,stats:l,id:v.type})};r.length===0&&L.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+v.type+" level: "+v.level+" sn: "+v.sn),this.blockBuffers(d,r)},p.onFragChanged=function(e,s){this.flushBackBuffer()},p.onBufferEos=function(e,s){var c=this,v=this.getSourceBufferTypes().reduce(function(i,r){var o=c.sourceBuffer[r];return(!s.type||s.type===r)&&o&&!o.ended&&(o.ended=!0,L.logger.log("[buffer-controller]: "+r+" sourceBuffer now EOS")),i&&!!(!o||o.ended)},!0);v&&this.blockBuffers(function(){var i=c.mediaSource;!i||i.readyState!=="open"||i.endOfStream()})},p.onLevelUpdated=function(e,s){var c=s.details;!c.fragments.length||(this.details=c,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},p.flushBackBuffer=function(){var e=this.hls,s=this.details,c=this.media,v=this.sourceBuffer;if(!(!c||s===null)){var i=this.getSourceBufferTypes();if(!!i.length){var r=s.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!(!Object(M.isFiniteNumber)(r)||r<0)){var o=c.currentTime,d=s.levelTargetDuration,t=Math.max(r,d),n=Math.floor(o/d)*d-t;i.forEach(function(l){var a=v[l];if(a){var f=b.BufferHelper.getBuffered(a);f.length>0&&n>f.start(0)&&(e.trigger(_.Events.BACK_BUFFER_REACHED,{bufferEnd:n}),s.live&&e.trigger(_.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:n}),e.trigger(_.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:n,type:l}))}})}}}},p.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,s=this.hls,c=this.media,v=this.mediaSource,i=e.fragments[0].start+e.totalduration,r=c.duration,o=Object(M.isFiniteNumber)(v.duration)?v.duration:0;e.live&&s.config.liveDurationInfinity?(L.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),v.duration=1/0,this.updateSeekableRange(e)):(i>o&&i>r||!Object(M.isFiniteNumber)(r))&&(L.logger.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),v.duration=i)}},p.updateSeekableRange=function(e){var s=this.mediaSource,c=e.fragments,v=c.length;if(v&&e.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var i=Math.max(0,c[0].start),r=Math.max(i,i+e.totalduration);s.setLiveSeekableRange(i,r)}},p.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,s=this.operationQueue,c=this.pendingTracks,v=Object.keys(c).length;if(v&&!e||v===2){this.createSourceBuffers(c),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length===0){this.hls.trigger(_.Events.ERROR,{type:C.ErrorTypes.MEDIA_ERROR,details:C.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}i.forEach(function(r){s.executeNext(r)})}},p.createSourceBuffers=function(e){var s=this.sourceBuffer,c=this.mediaSource;if(!c)throw Error("createSourceBuffers called when mediaSource was null");var v=0;for(var i in e)if(!s[i]){var r=e[i];if(!r)throw Error("source buffer exists for track "+i+", however track does not");var o=r.levelCodec||r.codec,d=r.container+";codecs="+o;L.logger.log("[buffer-controller]: creating sourceBuffer("+d+")");try{var t=s[i]=c.addSourceBuffer(d),n=i;this.addBufferListener(n,"updatestart",this._onSBUpdateStart),this.addBufferListener(n,"updateend",this._onSBUpdateEnd),this.addBufferListener(n,"error",this._onSBUpdateError),this.tracks[i]={buffer:t,codec:o,container:r.container,levelCodec:r.levelCodec,metadata:r.metadata,id:r.id},v++}catch(l){L.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+l.message),this.hls.trigger(_.Events.ERROR,{type:C.ErrorTypes.MEDIA_ERROR,details:C.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:l,mimeType:d})}}v&&this.hls.trigger(_.Events.BUFFER_CREATED,{tracks:this.tracks})},p._onSBUpdateStart=function(e){var s=this.operationQueue,c=s.current(e);c.onStart()},p._onSBUpdateEnd=function(e){var s=this.operationQueue,c=s.current(e);c.onComplete(),s.shiftAndExecuteNext(e)},p._onSBUpdateError=function(e,s){L.logger.error("[buffer-controller]: "+e+" SourceBuffer error",s),this.hls.trigger(_.Events.ERROR,{type:C.ErrorTypes.MEDIA_ERROR,details:C.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var c=this.operationQueue.current(e);c&&c.onError(s)},p.removeExecutor=function(e,s,c){var v=this.media,i=this.mediaSource,r=this.operationQueue,o=this.sourceBuffer,d=o[e];if(!v||!i||!d){L.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),r.shiftAndExecuteNext(e);return}var t=Object(M.isFiniteNumber)(v.duration)?v.duration:1/0,n=Object(M.isFiniteNumber)(i.duration)?i.duration:1/0,l=Math.max(0,s),a=Math.min(c,t,n);a>l?(L.logger.log("[buffer-controller]: Removing ["+l+","+a+"] from the "+e+" SourceBuffer"),console.assert(!d.updating,e+" sourceBuffer must not be updating"),d.remove(l,a)):r.shiftAndExecuteNext(e)},p.appendExecutor=function(e,s){var c=this.operationQueue,v=this.sourceBuffer,i=v[s];if(!i){L.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),c.shiftAndExecuteNext(s);return}i.ended=!1,console.assert(!i.updating,s+" sourceBuffer must not be updating"),i.appendBuffer(e)},p.blockBuffers=function(e,s){var c=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){L.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var v=this.operationQueue,i=s.map(function(r){return v.appendBlocker(r)});Promise.all(i).then(function(){e(),s.forEach(function(r){var o=c.sourceBuffer[r];(!o||!o.updating)&&v.shiftAndExecuteNext(r)})})},p.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},p.addBufferListener=function(e,s,c){var v=this.sourceBuffer[e];if(!!v){var i=c.bind(this,e);this.listeners[e].push({event:s,listener:i}),v.addEventListener(s,i)}},p.removeBufferListeners=function(e){var s=this.sourceBuffer[e];!s||this.listeners[e].forEach(function(c){s.removeEventListener(c.event,c.listener)})},g}()},"./src/controller/buffer-operation-queue.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return _});var M=m("./src/utils/logger.ts"),_=function(){function L(b){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=b}var C=L.prototype;return C.append=function(O,A){var y=this.queues[A];y.push(O),y.length===1&&this.buffers[A]&&this.executeNext(A)},C.insertAbort=function(O,A){var y=this.queues[A];y.unshift(O),this.executeNext(A)},C.appendBlocker=function(O){var A,y=new Promise(function(D){A=D}),T={execute:A,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(T,O),y},C.executeNext=function(O){var A=this.buffers,y=this.queues,T=A[O],D=y[O];if(D.length){var E=D[0];try{E.execute()}catch(g){M.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),E.onError(g),(!T||!T.updating)&&(D.shift(),this.executeNext(O))}}},C.shiftAndExecuteNext=function(O){this.queues[O].shift(),this.executeNext(O)},C.current=function(O){return this.queues[O][0]},L}()},"./src/controller/cap-level-controller.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/events.ts");function _(b,O){for(var A=0;A<O.length;A++){var y=O[A];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(b,y.key,y)}}function L(b,O,A){return O&&_(b.prototype,O),A&&_(b,A),Object.defineProperty(b,"prototype",{writable:!1}),b}var C=function(){function b(A){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=A,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var O=b.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(M.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(M.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(M.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.unregisterListener=function(){var y=this.hls;y.off(M.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(M.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(M.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.onFpsDropLevelCapping=function(y,T){b.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(g,p){return b.isLevelAllowed(p,T.restrictedLevels)&&p<=y});return this.clientRect=null,b.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},b.isLevelAllowed=function(y,T){return T===void 0&&(T=[]),T.indexOf(y)===-1},b.getMaxLevelByMediaSize=function(y,T,D){if(!y||!y.length)return-1;for(var E=function(s,c){return c?s.width!==c.width||s.height!==c.height:!0},g=y.length-1,p=0;p<y.length;p+=1){var u=y[p];if((u.width>=T||u.height>=D)&&E(u,y[p+1])){g=p;break}}return g},L(b,[{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}}]),b}();R.default=C},"./src/controller/cmcd-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return E});var M=m("./src/events.ts"),_=m("./src/types/cmcd.ts"),L=m("./src/utils/buffer-helper.ts"),C=m("./src/utils/logger.ts");function b(g,p){for(var u=0;u<p.length;u++){var e=p[u];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(g,e.key,e)}}function O(g,p,u){return p&&b(g.prototype,p),u&&b(g,u),Object.defineProperty(g,"prototype",{writable:!1}),g}function A(g,p){var u=typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(u)return(u=u.call(g)).next.bind(u);if(Array.isArray(g)||(u=y(g))||p&&g&&typeof g.length=="number"){u&&(g=u);var e=0;return function(){return e>=g.length?{done:!0}:{done:!1,value:g[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(g,p){if(!!g){if(typeof g=="string")return T(g,p);var u=Object.prototype.toString.call(g).slice(8,-1);if(u==="Object"&&g.constructor&&(u=g.constructor.name),u==="Map"||u==="Set")return Array.from(g);if(u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))return T(g,p)}}function T(g,p){(p==null||p>g.length)&&(p=g.length);for(var u=0,e=new Array(p);u<p;u++)e[u]=g[u];return e}function D(){return D=Object.assign?Object.assign.bind():function(g){for(var p=1;p<arguments.length;p++){var u=arguments[p];for(var e in u)Object.prototype.hasOwnProperty.call(u,e)&&(g[e]=u[e])}return g},D.apply(this,arguments)}var E=function(){function g(u){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(v){try{e.apply(v,{ot:_.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(i){C.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(v){try{var i=v.frag,r=e.hls.levels[i.level],o=e.getObjectType(i),d={d:i.duration*1e3,ot:o};(o===_.CMCDObjectType.VIDEO||o===_.CMCDObjectType.AUDIO||o==_.CMCDObjectType.MUXED)&&(d.br=r.bitrate/1e3,d.tb=e.getTopBandwidth(o)/1e3,d.bl=e.getBufferLength(o)),e.apply(v,d)}catch(t){C.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=u;var s=this.config=u.config,c=s.cmcd;c!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=c.sessionId||g.uuid(),this.cid=c.contentId,this.useHeaders=c.useHeaders===!0,this.registerListeners())}var p=g.prototype;return p.registerListeners=function(){var e=this.hls;e.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(M.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(M.Events.BUFFER_CREATED,this.onBufferCreated,this)},p.unregisterListeners=function(){var e=this.hls;e.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(M.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(M.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,s){this.media=s.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,s){var c,v;this.audioBuffer=(c=s.tracks.audio)===null||c===void 0?void 0:c.buffer,this.videoBuffer=(v=s.tracks.video)===null||v===void 0?void 0:v.buffer},p.createData=function(){var e;return{v:_.CMCDVersion,sf:_.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,s){s===void 0&&(s={}),D(s,this.createData());var c=s.ot===_.CMCDObjectType.INIT||s.ot===_.CMCDObjectType.VIDEO||s.ot===_.CMCDObjectType.MUXED;if(this.starved&&c&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var v=g.toHeaders(s);if(!Object.keys(v).length)return;e.headers||(e.headers={}),D(e.headers,v)}else{var i=g.toQuery(s);if(!i)return;e.url=g.appendQueryToUri(e.url,i)}},p.getObjectType=function(e){var s=e.type;if(s==="subtitle")return _.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return _.CMCDObjectType.INIT;if(s==="audio")return _.CMCDObjectType.AUDIO;if(s==="main")return this.hls.audioTracks.length?_.CMCDObjectType.VIDEO:_.CMCDObjectType.MUXED},p.getTopBandwidth=function(e){var s=0,c,v=this.hls;if(e===_.CMCDObjectType.AUDIO)c=v.audioTracks;else{var i=v.maxAutoLevel,r=i>-1?i+1:v.levels.length;c=v.levels.slice(0,r)}for(var o=A(c),d;!(d=o()).done;){var t=d.value;t.bitrate>s&&(s=t.bitrate)}return s>0?s:NaN},p.getBufferLength=function(e){var s=this.hls.media,c=e===_.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!c||!s)return NaN;var v=L.BufferHelper.bufferInfo(c,s.currentTime,this.config.maxBufferHole);return v.len*1e3},p.createPlaylistLoader=function(){var e=this.config.pLoader,s=this.applyPlaylistData,c=e||this.config.loader;return function(){function v(r){this.loader=void 0,this.loader=new c(r)}var i=v.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(o,d,t){s(o),this.loader.load(o,d,t)},O(v,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),v}()},p.createFragmentLoader=function(){var e=this.config.fLoader,s=this.applyFragmentData,c=e||this.config.loader;return function(){function v(r){this.loader=void 0,this.loader=new c(r)}var i=v.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(o,d,t){s(o),this.loader.load(o,d,t)},O(v,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),v}()},g.uuid=function(){var e=URL.createObjectURL(new Blob),s=e.toString();return URL.revokeObjectURL(e),s.slice(s.lastIndexOf("/")+1)},g.serialize=function(e){for(var s=[],c=function(P){return!Number.isNaN(P)&&P!=null&&P!==""&&P!==!1},v=function(P){return Math.round(P)},i=function(P){return v(P/100)*100},r=function(P){return encodeURIComponent(P)},o={br:v,d:v,bl:i,dl:i,mtp:i,nor:r,rtp:i,tb:v},d=Object.keys(e||{}).sort(),t=A(d),n;!(n=t()).done;){var l=n.value,a=e[l];if(!!c(a)&&!(l==="v"&&a===1)&&!(l=="pr"&&a===1)){var f=o[l];f&&(a=f(a));var h=typeof a,S=void 0;l==="ot"||l==="sf"||l==="st"?S=l+"="+a:h==="boolean"?S=l:h==="number"?S=l+"="+a:S=l+"="+JSON.stringify(a),s.push(S)}}return s.join(",")},g.toHeaders=function(e){for(var s=Object.keys(e),c={},v=["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},o=0,d=s;o<d.length;o++){var t=d[o],n=r[t]!=null?r[t]:1;i[n][t]=e[t]}for(var l=0;l<i.length;l++){var a=g.serialize(i[l]);a&&(c["CMCD-"+v[l]]=a)}return c},g.toQuery=function(e){return"CMCD="+encodeURIComponent(g.serialize(e))},g.appendQueryToUri=function(e,s){if(!s)return e;var c=e.includes("?")?"&":"?";return""+e+c+s},g}()},"./src/controller/eme-controller.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/events.ts"),_=m("./src/errors.ts"),L=m("./src/utils/logger.ts"),C=m("./src/utils/mediakeys-helper.ts");function b(E,g){for(var p=0;p<g.length;p++){var u=g[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(E,u.key,u)}}function O(E,g,p){return g&&b(E.prototype,g),p&&b(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}var A=3,y=function(g,p,u){var e={audioCapabilities:[],videoCapabilities:[]};return g.forEach(function(s){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+s+'"',robustness:u.audioRobustness||""})}),p.forEach(function(s){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+s+'"',robustness:u.videoRobustness||""})}),[e]},T=function(g,p,u,e){switch(g){case C.KeySystems.WIDEVINE:return y(p,u,e);default:throw new Error("Unknown key-system: "+g)}},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 g=E.prototype;return g.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},g._registerListeners=function(){this.hls.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(M.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this)},g._unregisterListeners=function(){this.hls.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(M.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this)},g.getLicenseServerUrl=function(u){switch(u){case C.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+u+'"')},g._attemptKeySystemAccess=function(u,e,s){var c=this,v=T(u,e,s,this._drmSystemOptions);L.logger.log("Requesting encrypted media key-system access");var i=this.requestMediaKeySystemAccess(u,v);this.mediaKeysPromise=i.then(function(r){return c._onMediaKeySystemAccessObtained(u,r)}),i.catch(function(r){L.logger.error('Failed to obtain key-system "'+u+'" access:',r)})},g._onMediaKeySystemAccessObtained=function(u,e){var s=this;L.logger.log('Access for key-system "'+u+'" obtained');var c={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:u};this._mediaKeysList.push(c);var v=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(i){return c.mediaKeys=i,L.logger.log('Media-keys created for key-system "'+u+'"'),s._onMediaKeysCreated(),i});return v.catch(function(i){L.logger.error("Failed to create media-keys:",i)}),v},g._onMediaKeysCreated=function(){var u=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),u._onNewMediaKeySession(e.mediaKeysSession))})},g._onNewMediaKeySession=function(u){var e=this;L.logger.log("New key-system session "+u.sessionId),u.addEventListener("message",function(s){e._onKeySessionMessage(u,s.message)},!1)},g._onKeySessionMessage=function(u,e){L.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(s){L.logger.log("Received license data (length: "+(s&&s.byteLength)+"), updating key-session"),u.update(s).catch(function(c){L.logger.warn("Updating key-session failed: "+c)})})},g.onMediaEncrypted=function(u){var e=this;if(L.logger.log('Media is encrypted using "'+u.initDataType+'" init data type'),!this.mediaKeysPromise){L.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var s=function(v){!e._media||(e._attemptSetMediaKeys(v),e._generateRequestWithPreferredKeySession(u.initDataType,u.initData))};this.mediaKeysPromise.then(s).catch(s)},g._attemptSetMediaKeys=function(u){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){L.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}L.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},g._generateRequestWithPreferredKeySession=function(u,e){var s=this,c=this._mediaKeysList[0];if(!c){L.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(c.mediaKeysSessionInitialized){L.logger.warn("Key-Session already initialized but requested again");return}var v=c.mediaKeysSession;if(!v){L.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){L.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}L.logger.log('Generating key-session request for "'+u+'" init data type'),c.mediaKeysSessionInitialized=!0,v.generateRequest(u,e).then(function(){L.logger.debug("Key-session generation succeeded")}).catch(function(i){L.logger.error("Error generating key-session request:",i),s.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},g._createLicenseXhr=function(u,e,s){var c=new XMLHttpRequest;c.responseType="arraybuffer",c.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,c,u,e,s);var v=this._licenseXhrSetup;if(v)try{v.call(this.hls,c,u),v=void 0}catch(i){L.logger.error(i)}try{c.readyState||c.open("POST",u,!0),v&&v.call(this.hls,c,u)}catch(i){throw new Error("issue setting up KeySystem license XHR "+i)}return c},g._onLicenseRequestReadyStageChange=function(u,e,s,c){switch(u.readyState){case 4:if(u.status===200){this._requestLicenseFailureCount=0,L.logger.log("License request succeeded");var v=u.response,i=this._licenseResponseCallback;if(i)try{v=i.call(this.hls,u,e)}catch(o){L.logger.error(o)}c(v)}else{if(L.logger.error("License Request XHR failed ("+e+"). Status: "+u.status+" ("+u.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>A){this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var r=A-this._requestLicenseFailureCount+1;L.logger.warn("Retrying license request, "+r+" attempts left"),this._requestLicense(s,c)}break}},g._generateLicenseRequestChallenge=function(u,e){switch(u.mediaKeySystemDomain){case C.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+u.mediaKeySystemDomain)},g._requestLicense=function(u,e){L.logger.log("Requesting content license for key-system");var s=this._mediaKeysList[0];if(!s){L.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var c=this.getLicenseServerUrl(s.mediaKeySystemDomain),v=this._createLicenseXhr(c,u,e);L.logger.log("Sending license request to URL: "+c);var i=this._generateLicenseRequestChallenge(s,u);v.send(i)}catch(r){L.logger.error("Failure requesting DRM license: "+r),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},g.onMediaAttached=function(u,e){if(!!this._emeEnabled){var s=e.media;this._media=s,s.addEventListener("encrypted",this._onMediaEncrypted)}},g.onMediaDetached=function(){var u=this._media,e=this._mediaKeysList;!u||(u.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(s){if(s.mediaKeysSession)return s.mediaKeysSession.close().catch(function(){})})).then(function(){return u.setMediaKeys(null)}).catch(function(){}))},g.onManifestParsed=function(u,e){if(!!this._emeEnabled){var s=e.levels.map(function(v){return v.audioCodec}).filter(function(v){return!!v}),c=e.levels.map(function(v){return v.videoCodec}).filter(function(v){return!!v});this._attemptKeySystemAccess(C.KeySystems.WIDEVINE,s,c)}},O(E,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),E}();R.default=D},"./src/controller/fps-controller.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/events.ts"),_=m("./src/utils/logger.ts"),L=function(){function C(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 b=C.prototype;return b.setStreamController=function(A){this.streamController=A},b.registerListeners=function(){this.hls.on(M.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},b.unregisterListeners=function(){this.hls.off(M.Events.MEDIA_ATTACHING,this.onMediaAttaching)},b.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},b.onMediaAttaching=function(A,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)}},b.checkFPS=function(A,y,T){var D=performance.now();if(y){if(this.lastTime){var E=D-this.lastTime,g=T-this.lastDroppedFrames,p=y-this.lastDecodedFrames,u=1e3*g/E,e=this.hls;if(e.trigger(M.Events.FPS_DROP,{currentDropped:g,currentDecoded:p,totalDroppedFrames:T}),u>0&&g>e.config.fpsDroppedMonitoringThreshold*p){var s=e.currentLevel;_.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),s>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=s)&&(s=s-1,e.trigger(M.Events.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:e.currentLevel}),e.autoLevelCapping=s,this.streamController.nextLevelSwitch())}}this.lastTime=D,this.lastDroppedFrames=T,this.lastDecodedFrames=y}},b.checkFPSInterval=function(){var A=this.media;if(A)if(this.isVideoPlaybackQualityAvailable){var y=A.getVideoPlaybackQuality();this.checkFPS(A,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(A,A.webkitDecodedFrameCount,A.webkitDroppedFrameCount)},C}();R.default=L},"./src/controller/fragment-finders.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"findFragmentByPDT",function(){return L}),m.d(R,"findFragmentByPTS",function(){return C}),m.d(R,"fragmentWithinToleranceTest",function(){return b}),m.d(R,"pdtWithinToleranceTest",function(){return O}),m.d(R,"findFragWithCC",function(){return A});var M=m("./src/polyfills/number.ts"),_=m("./src/utils/binary-search.ts");function L(y,T,D){if(T===null||!Array.isArray(y)||!y.length||!Object(M.isFiniteNumber)(T))return null;var E=y[0].programDateTime;if(T<(E||0))return null;var g=y[y.length-1].endProgramDateTime;if(T>=(g||0))return null;D=D||0;for(var p=0;p<y.length;++p){var u=y[p];if(O(T,D,u))return u}return null}function C(y,T,D,E){D===void 0&&(D=0),E===void 0&&(E=0);var g=null;if(y?g=T[y.sn-T[0].sn+1]||null:D===0&&T[0].start===0&&(g=T[0]),g&&b(D,E,g)===0)return g;var p=_.default.search(T,b.bind(null,D,E));return p||g}function b(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,g=D.endProgramDateTime||0;return g-E>y}function A(y,T){return _.default.search(y,function(D){return D.cc<T?1:D.cc>T?-1:0})}},"./src/controller/fragment-tracker.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"FragmentState",function(){return L}),m.d(R,"FragmentTracker",function(){return C});var M=m("./src/events.ts"),_=m("./src/types/loader.ts"),L;(function(A){A.NOT_LOADED="NOT_LOADED",A.APPENDING="APPENDING",A.PARTIAL="PARTIAL",A.OK="OK"})(L||(L={}));var C=function(){function A(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=A.prototype;return y._registerListeners=function(){var D=this.hls;D.on(M.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.on(M.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var D=this.hls;D.off(M.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.off(M.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(D,E){if(E===_.PlaylistLevelType.MAIN){var g=this.activeFragment,p=this.activeParts;if(!g)return null;if(p)for(var u=p.length;u--;){var e=p[u],s=e?e.end:g.appendedPTS;if(e.start<=D&&s!==void 0&&D<=s)return u>9&&(this.activeParts=p.slice(u-9)),e}else if(g.start<=D&&g.appendedPTS!==void 0&&D<=g.appendedPTS)return g}return this.getBufferedFrag(D,E)},y.getBufferedFrag=function(D,E){for(var g=this.fragments,p=Object.keys(g),u=p.length;u--;){var e=g[p[u]];if((e==null?void 0:e.body.type)===E&&e.buffered){var s=e.body;if(s.start<=D&&D<=s.end)return s}}return null},y.detectEvictedFragments=function(D,E,g){var p=this;Object.keys(this.fragments).forEach(function(u){var e=p.fragments[u];if(!!e){if(!e.buffered){e.body.type===g&&p.removeFragment(e.body);return}var s=e.range[D];!s||s.time.some(function(c){var v=!p.isTimeBuffered(c.startPTS,c.endPTS,E);return v&&p.removeFragment(e.body),v})}})},y.detectPartialFragments=function(D){var E=this,g=this.timeRanges,p=D.frag,u=D.part;if(!(!g||p.sn==="initSegment")){var e=O(p),s=this.fragments[e];!s||(Object.keys(g).forEach(function(c){var v=p.elementaryStreams[c];if(!!v){var i=g[c],r=u!==null||v.partial===!0;s.range[c]=E.getBufferedTimes(p,u,r,i)}}),s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body))}},y.fragBuffered=function(D){var E=O(D),g=this.fragments[E];g&&(g.loaded=null,g.buffered=!0)},y.getBufferedTimes=function(D,E,g,p){for(var u={time:[],partial:g},e=E?E.start:D.start,s=E?E.end:D.end,c=D.minEndPTS||s,v=D.maxStartPTS||e,i=0;i<p.length;i++){var r=p.start(i)-this.bufferPadding,o=p.end(i)+this.bufferPadding;if(v>=r&&c<=o){u.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(s,p.end(i))});break}else if(e<o&&s>r)u.partial=!0,u.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(s,p.end(i))});else if(s<=r)break}return u},y.getPartialFragment=function(D){var E=null,g,p,u,e=0,s=this.bufferPadding,c=this.fragments;return Object.keys(c).forEach(function(v){var i=c[v];!i||b(i)&&(p=i.body.start-s,u=i.body.end+s,D>=p&&D<=u&&(g=Math.min(D-p,u-D),e<=g&&(E=i.body,e=g)))}),E},y.getState=function(D){var E=O(D),g=this.fragments[E];return g?g.buffered?b(g)?L.PARTIAL:L.OK:L.APPENDING:L.NOT_LOADED},y.isTimeBuffered=function(D,E,g){for(var p,u,e=0;e<g.length;e++){if(p=g.start(e)-this.bufferPadding,u=g.end(e)+this.bufferPadding,D>=p&&E<=u)return!0;if(E<=p)return!1}return!1},y.onFragLoaded=function(D,E){var g=E.frag,p=E.part;if(!(g.sn==="initSegment"||g.bitrateTest||p)){var u=O(g);this.fragments[u]={body:g,loaded:E,buffered:!1,range:Object.create(null)}}},y.onBufferAppended=function(D,E){var g=this,p=E.frag,u=E.part,e=E.timeRanges;if(p.type===_.PlaylistLevelType.MAIN)if(this.activeFragment=p,u){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(u)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(c){var v=e[c];if(g.detectEvictedFragments(c,v),!u)for(var i=0;i<v.length;i++)p.appendedPTS=Math.max(v.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,g){var p=this;Object.keys(this.fragments).forEach(function(u){var e=p.fragments[u];if(!!e&&e.buffered){var s=e.body;s.type===g&&s.start<E&&s.end>D&&p.removeFragment(s)}})},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},A}();function b(A){var y,T;return A.buffered&&(((y=A.range.video)===null||y===void 0?void 0:y.partial)||((T=A.range.audio)===null||T===void 0?void 0:T.partial))}function O(A){return A.type+"_"+A.level+"_"+A.urlId+"_"+A.sn}},"./src/controller/gap-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"STALL_MINIMUM_DURATION_MS",function(){return b}),m.d(R,"MAX_START_GAP_JUMP",function(){return O}),m.d(R,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return A}),m.d(R,"SKIP_BUFFER_RANGE_START",function(){return y}),m.d(R,"default",function(){return T});var M=m("./src/utils/buffer-helper.ts"),_=m("./src/errors.ts"),L=m("./src/events.ts"),C=m("./src/utils/logger.ts"),b=250,O=2,A=.1,y=.05,T=function(){function D(g,p,u,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=g,this.media=p,this.fragmentTracker=u,this.hls=e}var E=D.prototype;return E.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},E.poll=function(p,u){var e=this.config,s=this.media,c=this.stalled;if(s!==null){var v=s.currentTime,i=s.seeking,r=this.seeking&&!i,o=!this.seeking&&i;if(this.seeking=i,v!==p){if(this.moved=!0,c!==null){if(this.stallReported){var d=self.performance.now()-c;C.logger.warn("playback not stuck anymore @"+v+", after "+Math.round(d)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((o||r)&&(this.stalled=null),!(s.paused&&!i||s.ended||s.playbackRate===0||!M.BufferHelper.getBuffered(s).length)){var t=M.BufferHelper.bufferInfo(s,v,0),n=t.len>0,l=t.nextStart||0;if(!(!n&&!l)){if(i){var a=t.len>O,f=!l||u&&u.start<=v||l-v>O&&!this.fragmentTracker.getPartialFragment(v);if(a||f)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var h,S=Math.max(l,t.start||0)-v,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=x==null||(h=x.details)===null||h===void 0?void 0:h.live,k=P?x.details.targetduration*2:O;if(S>0&&S<=k){this._trySkipBufferHole(null);return}}var B=self.performance.now();if(c===null){this.stalled=B;return}var U=B-c;if(!(!i&&U>=b&&(this._reportStall(t),!this.media))){var W=M.BufferHelper.bufferInfo(s,v,e.maxBufferHole);this._tryFixBufferStall(W,U)}}}}},E._tryFixBufferStall=function(p,u){var e=this.config,s=this.fragmentTracker,c=this.media;if(c!==null){var v=c.currentTime,i=s.getPartialFragment(v);if(i){var r=this._trySkipBufferHole(i);if(r||!this.media)return}p.len>e.maxBufferHole&&u>e.highBufferWatchdogPeriod*1e3&&(C.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},E._reportStall=function(p){var u=this.hls,e=this.media,s=this.stallReported;!s&&e&&(this.stallReported=!0,C.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer ("+JSON.stringify(p)+")"),u.trigger(L.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p.len}))},E._trySkipBufferHole=function(p){var u=this.config,e=this.hls,s=this.media;if(s===null)return 0;for(var c=s.currentTime,v=0,i=M.BufferHelper.getBuffered(s),r=0;r<i.length;r++){var o=i.start(r);if(c+u.maxBufferHole>=v&&c<o){var d=Math.max(o+y,s.currentTime+A);return C.logger.warn("skipping hole, adjusting currentTime from "+c+" to "+d),this.moved=!0,this.stalled=null,s.currentTime=d,p&&e.trigger(L.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+c+" to "+d,frag:p}),d}v=i.end(r)}return 0},E._tryNudgeBuffer=function(){var p=this.config,u=this.hls,e=this.media,s=this.nudgeRetry;if(e!==null){var c=e.currentTime;if(this.nudgeRetry++,s<p.nudgeMaxRetry){var v=c+(s+1)*p.nudgeOffset;C.logger.warn("Nudging 'currentTime' from "+c+" to "+v),e.currentTime=v,u.trigger(L.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else C.logger.error("Playhead still not moving while enough data buffered @"+c+" after "+p.nudgeMaxRetry+" nudges"),u.trigger(L.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},D}()},"./src/controller/id3-track-controller.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/polyfills/number.ts"),_=m("./src/events.ts"),L=m("./src/utils/texttrack-utils.ts"),C=m("./src/demux/id3.ts"),b=m("./src/loader/date-range.ts"),O=m("./src/types/demuxer.ts"),A=.25;function y(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function T(g,p){return g.getTime()/1e3-p}function D(g){return Uint8Array.from(g.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var E=function(){function g(u){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=u,this._registerListeners()}var p=g.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(_.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p._unregisterListeners=function(){var e=this.hls;e.off(_.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p.onMediaAttached=function(e,s){this.media=s.media},p.onMediaDetaching=function(){!this.id3Track||(Object(L.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},p.onManifestLoading=function(){this.dateRangeCuesAppended={}},p.createTrack=function(e){var s=this.getID3Track(e.textTracks);return s.mode="hidden",s},p.getID3Track=function(e){if(!!this.media){for(var s=0;s<e.length;s++){var c=e[s];if(c.kind==="metadata"&&c.label==="id3")return Object(L.sendAddTrackEvent)(c,this.media),c}return this.media.addTextTrack("metadata","id3")}},p.onFragParsingMetadata=function(e,s){if(!!this.media){var c=this.hls.config,v=c.enableEmsgMetadataCues,i=c.enableID3MetadataCues;if(!(!v&&!i)){var r=s.frag,o=s.samples,d=s.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var t=d.edge||r.end,n=y(),l=!1,a={},f=0;f<o.length;f++){var h=o[f].type;if(!(h===O.MetadataSchema.emsg&&!v||!i)){var S=C.getID3Frames(o[f].data);if(S){var x=o[f].pts,P=t,k=P-x;k<=0&&(P=x+A);for(var B=0;B<S.length;B++){var U=S[B];if(!C.isTimeStampFrame(U)){var W=new n(x,P,"");W.value=U,h&&(W.type=h),this.id3Track.addCue(W),a[U.key]=null,l=!0}}}}}l&&this.updateId3CueEnds(a)}}},p.updateId3CueEnds=function(e){var s,c=(s=this.id3Track)===null||s===void 0?void 0:s.cues;if(c)for(var v=c.length;v--;){var i,r=c[v],o=(i=r.value)===null||i===void 0?void 0:i.key;if(o&&o in e){var d=e[o];d&&r.endTime!==d&&(r.endTime=d),e[o]=r.startTime}}},p.onBufferFlushing=function(e,s){var c=s.startOffset,v=s.endOffset,i=s.type,r=this.id3Track,o=this.hls;if(!!o){var d=o.config,t=d.enableEmsgMetadataCues,n=d.enableID3MetadataCues;if(r&&(t||n)){var l;i==="audio"?l=function(f){return f.type===O.MetadataSchema.audioId3&&n}:i==="video"?l=function(f){return f.type===O.MetadataSchema.emsg&&t}:l=function(f){return f.type===O.MetadataSchema.audioId3&&n||f.type===O.MetadataSchema.emsg&&t},Object(L.removeCuesInRange)(r,c,v,l)}}},p.onLevelUpdated=function(e,s){var c=this,v=s.details;if(!(!this.media||!v.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var i=this.dateRangeCuesAppended,r=this.id3Track,o=v.dateRanges,d=Object.keys(o);if(r)for(var t=Object.keys(i).filter(function(k){return!d.includes(k)}),n=function(B){var U=t[B];Object.keys(i[U].cues).forEach(function(W){r.removeCue(i[U].cues[W])}),delete i[U]},l=t.length;l--;)n(l);var a=v.fragments[v.fragments.length-1];if(!(d.length===0||!Object(M.isFiniteNumber)(a==null?void 0:a.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var f=a.programDateTime/1e3-a.start,h=v.edge||a.end,S=y(),x=function(B){var U=d[B],W=o[U],G=i[U],z=(G==null?void 0:G.cues)||{},Y=(G==null?void 0:G.durationKnown)||!1,$=T(W.startDate,f),Z=h,q=W.endDate;if(q)Z=T(q,f),Y=!0;else if(W.endOnNext&&!Y){var ie=d.reduce(function(re,Ee){var me=o[Ee];return me.class===W.class&&me.id!==Ee&&me.startDate>W.startDate&&re.push(me),re},[]).sort(function(re,Ee){return re.startDate.getTime()-Ee.startDate.getTime()})[0];ie&&(Z=T(ie.startDate,f),Y=!0)}for(var ne=Object.keys(W.attr),ae=0;ae<ne.length;ae++){var te=ne[ae];if(!(te===b.DateRangeAttribute.ID||te===b.DateRangeAttribute.CLASS||te===b.DateRangeAttribute.START_DATE||te===b.DateRangeAttribute.DURATION||te===b.DateRangeAttribute.END_DATE||te===b.DateRangeAttribute.END_ON_NEXT)){var fe=z[te];if(fe)Y&&!G.durationKnown&&(fe.endTime=Z);else{var de=W.attr[te];fe=new S($,Z,""),(te===b.DateRangeAttribute.SCTE35_OUT||te===b.DateRangeAttribute.SCTE35_IN)&&(de=D(de)),fe.value={key:te,data:de},fe.type=O.MetadataSchema.dateRange,c.id3Track.addCue(fe),z[te]=fe}}}i[U]={cues:z,dateRange:W,durationKnown:Y}},P=0;P<d.length;P++)x(P)}}},g}();R.default=E},"./src/controller/latency-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return O});var M=m("./src/errors.ts"),_=m("./src/events.ts"),L=m("./src/utils/logger.ts");function C(A,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(A,D.key,D)}}function b(A,y,T){return y&&C(A.prototype,y),T&&C(A,T),Object.defineProperty(A,"prototype",{writable:!1}),A}var O=function(){function A(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=A.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(_.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(_.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(_.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(_.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(_.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(_.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 g=E.details;this.levelDetails=g,g.advanced&&this.timeupdate(),!g.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(D,E){E.details===M.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,L.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 g=this.computeLatency();if(g!==null){this._latency=g;var p=this.config,u=p.lowLatencyMode,e=p.maxLiveSyncPlaybackRate;if(!(!u||e===1)){var s=this.targetLatency;if(s!==null){var c=g-s,v=Math.min(this.maxLatency,s+E.targetduration),i=c<v;if(E.live&&i&&c>.05&&this.forwardBufferLength>1){var r=Math.min(2,Math.max(1,e)),o=Math.round(2/(1+Math.exp(-.75*c-this.edgeStalled))*20)/20;D.playbackRate=Math.min(r,Math.max(1,o))}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},b(A,[{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,g=D.partHoldBack,p=D.targetduration,u=this.config,e=u.liveSyncDuration,s=u.liveSyncDurationCount,c=u.lowLatencyMode,v=this.hls.userConfig,i=c&&g||E;(v.liveSyncDuration||v.liveSyncDurationCount||i===0)&&(i=e!==void 0?e:s*p);var r=p,o=1;return i+Math.min(this.stallCount*o,r)}},{key:"liveSyncPosition",get:function(){var D=this.estimateLiveEdge(),E=this.targetLatency,g=this.levelDetails;if(D===null||E===null||g===null)return null;var p=g.edge,u=D-E-this.edgeStalled,e=p-g.totalduration,s=p-(this.config.lowLatencyMode&&g.partTarget||g.targetduration);return Math.min(Math.max(e,u),s)}},{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 g=D.buffered.length;return(g?D.buffered.end(g-1):E.edge)-this.currentTime}}]),A}()},"./src/controller/level-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return u});var M=m("./src/types/level.ts"),_=m("./src/events.ts"),L=m("./src/errors.ts"),C=m("./src/utils/codecs.ts"),b=m("./src/controller/level-helper.ts"),O=m("./src/controller/base-playlist-controller.ts"),A=m("./src/types/loader.ts");function y(){return y=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var c=arguments[s];for(var v in c)Object.prototype.hasOwnProperty.call(c,v)&&(e[v]=c[v])}return e},y.apply(this,arguments)}function T(e,s){for(var c=0;c<s.length;c++){var v=s[c];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(e,v.key,v)}}function D(e,s,c){return s&&T(e.prototype,s),c&&T(e,c),Object.defineProperty(e,"prototype",{writable:!1}),e}function E(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,g(e,s)}function g(e,s){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,i){return v.__proto__=i,v},g(e,s)}var p=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),u=function(e){E(s,e);function s(v){var i;return i=e.call(this,v,"[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 c=s.prototype;return c._registerListeners=function(){var i=this.hls;i.on(_.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(_.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(_.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.on(_.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(_.Events.ERROR,this.onError,this)},c._unregisterListeners=function(){var i=this.hls;i.off(_.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.off(_.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(_.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.off(_.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(_.Events.ERROR,this.onError,this)},c.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},c.startLoad=function(){var i=this._levels;i.forEach(function(r){r.loadError=0}),e.prototype.startLoad.call(this)},c.onManifestLoaded=function(i,r){var o=[],d=[],t=[],n,l={},a,f=!1,h=!1,S=!1;if(r.levels.forEach(function(B){var U=B.attrs;f=f||!!(B.width&&B.height),h=h||!!B.videoCodec,S=S||!!B.audioCodec,p&&B.audioCodec&&B.audioCodec.indexOf("mp4a.40.34")!==-1&&(B.audioCodec=void 0);var W=B.bitrate+"-"+B.attrs.RESOLUTION+"-"+B.attrs.CODECS;a=l[W],a?a.url.push(B.url):(a=new M.Level(B),l[W]=a,o.push(a)),U&&(U.AUDIO&&Object(b.addGroupId)(a,"audio",U.AUDIO),U.SUBTITLES&&Object(b.addGroupId)(a,"text",U.SUBTITLES))}),(f||h)&&S&&(o=o.filter(function(B){var U=B.videoCodec,W=B.width,G=B.height;return!!U||!!(W&&G)})),o=o.filter(function(B){var U=B.audioCodec,W=B.videoCodec;return(!U||Object(C.isCodecSupportedInMp4)(U,"audio"))&&(!W||Object(C.isCodecSupportedInMp4)(W,"video"))}),r.audioTracks&&(d=r.audioTracks.filter(function(B){return!B.audioCodec||Object(C.isCodecSupportedInMp4)(B.audioCodec,"audio")}),Object(b.assignTrackIdsByGroup)(d)),r.subtitles&&(t=r.subtitles,Object(b.assignTrackIdsByGroup)(t)),o.length>0){n=o[0].bitrate,o.sort(function(B,U){return B.bitrate-U.bitrate}),this._levels=o;for(var x=0;x<o.length;x++)if(o[x].bitrate===n){this._firstLevel=x,this.log("manifest loaded, "+o.length+" level(s) found, first bitrate: "+n);break}var P=S&&!h,k={levels:o,audioTracks:d,subtitleTracks:t,firstLevel:this._firstLevel,stats:r.stats,audio:S,video:h,altAudio:!P&&d.some(function(B){return!!B.url})};this.hls.trigger(_.Events.MANIFEST_PARSED,k),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(_.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,reason:"no level with compatible codecs found in manifest"})},c.onError=function(i,r){var o;if(e.prototype.onError.call(this,i,r),!r.fatal){var d=r.context,t=this._levels[this.currentLevelIndex];if(d&&(d.type===A.PlaylistContextType.AUDIO_TRACK&&t.audioGroupIds&&d.groupId===t.audioGroupIds[t.urlId]||d.type===A.PlaylistContextType.SUBTITLE_TRACK&&t.textGroupIds&&d.groupId===t.textGroupIds[t.urlId])){this.redundantFailover(this.currentLevelIndex);return}var n=!1,l=!0,a;switch(r.details){case L.ErrorDetails.FRAG_LOAD_ERROR:case L.ErrorDetails.FRAG_LOAD_TIMEOUT:case L.ErrorDetails.KEY_LOAD_ERROR:case L.ErrorDetails.KEY_LOAD_TIMEOUT:if(r.frag){var f=r.frag.type===A.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,h=this._levels[f];h?(h.fragmentError++,h.fragmentError>this.hls.config.fragLoadingMaxRetry&&(a=f)):a=f}break;case L.ErrorDetails.LEVEL_LOAD_ERROR:case L.ErrorDetails.LEVEL_LOAD_TIMEOUT:d&&(d.deliveryDirectives&&(l=!1),a=d.level),n=!0;break;case L.ErrorDetails.REMUX_ALLOC_ERROR:a=(o=r.level)!=null?o:this.currentLevelIndex,n=!0;break}a!==void 0&&this.recoverLevel(r,a,n,l)}},c.recoverLevel=function(i,r,o,d){var t=i.details,n=this._levels[r];if(n.loadError++,o){var l=this.retryLoadingOrFail(i);if(l)i.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(d){var a=n.url.length;if(a>1&&n.loadError<a)i.levelRetry=!0,this.redundantFailover(r);else if(this.manualLevelIndex===-1){for(var f=-1,h=this._levels,S=h.length;S--;){var x=(S+this.currentLevelIndex)%h.length;if(x!==this.currentLevelIndex&&h[x].loadError===0){f=x;break}}f>-1&&this.currentLevelIndex!==f&&(this.warn(t+": switch to "+f),i.levelRetry=!0,this.hls.nextAutoLevel=f)}}},c.redundantFailover=function(i){var r=this._levels[i],o=r.url.length;if(o>1){var d=(r.urlId+1)%o;this.warn("Switching to redundant URL-id "+d),this._levels.forEach(function(t){t.urlId=d}),this.level=i}},c.onFragLoaded=function(i,r){var o=r.frag;if(o!==void 0&&o.type===A.PlaylistLevelType.MAIN){var d=this._levels[o.level];d!==void 0&&(d.fragmentError=0,d.loadError=0)}},c.onLevelLoaded=function(i,r){var o,d=r.level,t=r.details,n=this._levels[d];if(!n){var l;this.warn("Invalid level index "+d),(l=r.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(t.deltaUpdateFailed=!0);return}d===this.currentLevelIndex?(n.fragmentError===0&&(n.loadError=0,this.retryCount=0),this.playlistLoaded(d,r,n.details)):(o=r.deliveryDirectives)!==null&&o!==void 0&&o.skip&&(t.deltaUpdateFailed=!0)},c.onAudioTrackSwitched=function(i,r){var o=this.hls.levels[this.currentLevelIndex];if(!!o&&o.audioGroupIds){for(var d=-1,t=this.hls.audioTracks[r.id].groupId,n=0;n<o.audioGroupIds.length;n++)if(o.audioGroupIds[n]===t){d=n;break}d!==o.urlId&&(o.urlId=d,this.startLoad())}},c.loadPlaylist=function(i){var r=this.currentLevelIndex,o=this._levels[r];if(this.canLoad&&o&&o.url.length>0){var d=o.urlId,t=o.url[d];if(i)try{t=i.addDirectives(t)}catch(n){this.warn("Could not construct new URL with HLS Delivery Directives: "+n)}this.log("Attempt loading level index "+r+(i?" at sn "+i.msn+" part "+i.part:"")+" with URL-id "+d+" "+t),this.clearTimer(),this.hls.trigger(_.Events.LEVEL_LOADING,{url:t,level:r,id:d,deliveryDirectives:i||null})}},c.removeLevel=function(i,r){var o=function(n,l){return l!==r},d=this._levels.filter(function(t,n){return n!==i?!0:t.url.length>1&&r!==void 0?(t.url=t.url.filter(o),t.audioGroupIds&&(t.audioGroupIds=t.audioGroupIds.filter(o)),t.textGroupIds&&(t.textGroupIds=t.textGroupIds.filter(o)),t.urlId=0,!0):!1}).map(function(t,n){var l=t.details;return l!=null&&l.fragments&&l.fragments.forEach(function(a){a.level=n}),t});this._levels=d,this.hls.trigger(_.Events.LEVELS_UPDATED,{levels:d})},D(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(i){var r,o=this._levels;if(o.length!==0&&!(this.currentLevelIndex===i&&(r=o[i])!==null&&r!==void 0&&r.details)){if(i<0||i>=o.length){var d=i<0;if(this.hls.trigger(_.Events.ERROR,{type:L.ErrorTypes.OTHER_ERROR,details:L.ErrorDetails.LEVEL_SWITCH_ERROR,level:i,fatal:d,reason:"invalid level idx"}),d)return;i=Math.min(i,o.length-1)}this.clearTimer();var t=this.currentLevelIndex,n=o[t],l=o[i];this.log("switching to level "+i+" from "+t),this.currentLevelIndex=i;var a=y({},l,{level:i,maxBitrate:l.maxBitrate,uri:l.uri,urlId:l.urlId});delete a._urlId,this.hls.trigger(_.Events.LEVEL_SWITCHING,a);var f=l.details;if(!f||f.live){var h=this.switchParams(l.uri,n==null?void 0:n.details);this.loadPlaylist(h)}}}},{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)}}]),s}(O.default)},"./src/controller/level-helper.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"addGroupId",function(){return b}),m.d(R,"assignTrackIdsByGroup",function(){return O}),m.d(R,"updatePTS",function(){return A}),m.d(R,"updateFragPTSDTS",function(){return T}),m.d(R,"mergeDetails",function(){return D}),m.d(R,"mapPartIntersection",function(){return g}),m.d(R,"mapFragmentIntersection",function(){return p}),m.d(R,"adjustSliding",function(){return u}),m.d(R,"addSliding",function(){return e}),m.d(R,"computeReloadInterval",function(){return s}),m.d(R,"getFragmentWithSN",function(){return c}),m.d(R,"getPartWith",function(){return v});var M=m("./src/polyfills/number.ts"),_=m("./src/utils/logger.ts"),L=m("./src/loader/date-range.ts");function C(){return C=Object.assign?Object.assign.bind():function(i){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var d in o)Object.prototype.hasOwnProperty.call(o,d)&&(i[d]=o[d])}return i},C.apply(this,arguments)}function b(i,r,o){switch(r){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(o);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(o);break}}function O(i){var r={};i.forEach(function(o){var d=o.groupId||"";o.id=r[d]=r[d]||0,r[d]++})}function A(i,r,o){var d=i[r],t=i[o];y(d,t)}function y(i,r){var o=r.startPTS;if(Object(M.isFiniteNumber)(o)){var d=0,t;r.sn>i.sn?(d=o-i.start,t=i):(d=i.start-o,t=r),t.duration!==d&&(t.duration=d)}else if(r.sn>i.sn){var n=i.cc===r.cc;n&&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,o,d,t,n){var l=d-o;l<=0&&(_.logger.warn("Fragment should have a positive duration",r),d=o+r.duration,n=t+r.duration);var a=o,f=d,h=r.startPTS,S=r.endPTS;if(Object(M.isFiniteNumber)(h)){var x=Math.abs(h-o);Object(M.isFiniteNumber)(r.deltaPTS)?r.deltaPTS=Math.max(x,r.deltaPTS):r.deltaPTS=x,a=Math.max(o,h),o=Math.min(o,h),t=Math.min(t,r.startDTS),f=Math.min(d,S),d=Math.max(d,S),n=Math.max(n,r.endDTS)}r.duration=d-o;var P=o-r.start;r.appendedPTS=d,r.start=r.startPTS=o,r.maxStartPTS=a,r.startDTS=t,r.endPTS=d,r.minEndPTS=f,r.endDTS=n;var k=r.sn;if(!i||k<i.startSN||k>i.endSN)return 0;var B,U=k-i.startSN,W=i.fragments;for(W[U]=r,B=U;B>0;B--)y(W[B],W[B-1]);for(B=U;B<W.length-1;B++)y(W[B],W[B+1]);return i.fragmentHint&&y(W[W.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,P}function D(i,r){for(var o=null,d=i.fragments,t=d.length-1;t>=0;t--){var n=d[t].initSegment;if(n){o=n;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var l=0,a;if(p(i,r,function(B,U){B.relurl&&(l=B.cc-U.cc),Object(M.isFiniteNumber)(B.startPTS)&&Object(M.isFiniteNumber)(B.endPTS)&&(U.start=U.startPTS=B.startPTS,U.startDTS=B.startDTS,U.appendedPTS=B.appendedPTS,U.maxStartPTS=B.maxStartPTS,U.endPTS=B.endPTS,U.endDTS=B.endDTS,U.minEndPTS=B.minEndPTS,U.duration=B.endPTS-B.startPTS,U.duration&&(a=U),r.PTSKnown=r.alignedSliding=!0),U.elementaryStreams=B.elementaryStreams,U.loader=B.loader,U.stats=B.stats,U.urlId=B.urlId,B.initSegment&&(U.initSegment=B.initSegment,o=B.initSegment)}),o){var f=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments;f.forEach(function(B){var U;(!B.initSegment||B.initSegment.relurl===((U=o)===null||U===void 0?void 0:U.relurl))&&(B.initSegment=o)})}if(r.skippedSegments)if(r.deltaUpdateFailed=r.fragments.some(function(B){return!B}),r.deltaUpdateFailed){_.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var h=r.skippedSegments;h--;)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(l){_.logger.warn("discontinuity sliding from playlist, take drift into account");for(var x=0;x<S.length;x++)S[x].cc+=l}r.skippedSegments&&(r.startCC=r.fragments[0].cc),g(i.partList,r.partList,function(B,U){U.elementaryStreams=B.elementaryStreams,U.stats=B.stats}),a?T(r,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):u(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 k=r.edge;r.driftStart||(r.driftStartTime=P,r.driftStart=k),r.driftEndTime=P,r.driftEnd=k}else r.driftEndTime=i.driftEndTime,r.driftEnd=i.driftEnd,r.advancedDateTime=i.advancedDateTime}function E(i,r,o){var d=C({},i);return o&&o.forEach(function(t){delete d[t]}),Object.keys(r).forEach(function(t){var n=new L.DateRange(r[t].attr,d[t]);n.isValid?d[t]=n:_.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(r[t].attr)+'"')}),d}function g(i,r,o){if(i&&r)for(var d=0,t=0,n=i.length;t<=n;t++){var l=i[t],a=r[t+d];l&&a&&l.index===a.index&&l.fragment.sn===a.fragment.sn?o(l,a):d--}}function p(i,r,o){for(var d=r.skippedSegments,t=Math.max(i.startSN,r.startSN)-r.startSN,n=(i.fragmentHint?1:0)+(d?r.endSN:Math.min(i.endSN,r.endSN))-r.startSN,l=r.startSN-i.startSN,a=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments,f=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,h=t;h<=n;h++){var S=f[l+h],x=a[h];d&&!x&&h<d&&(x=r.fragments[h]=S),S&&x&&o(S,x)}}function u(i,r){var o=r.startSN+r.skippedSegments-i.startSN,d=i.fragments;o<0||o>=d.length||e(r,d[o].start)}function e(i,r){if(r){for(var o=i.fragments,d=i.skippedSegments;d<o.length;d++)o[d].start+=r;i.fragmentHint&&(i.fragmentHint.start+=r)}}function s(i,r){var o=1e3*i.levelTargetDuration,d=o/2,t=i.age,n=t>0&&t<o*3,l=r.loading.end-r.loading.start,a,f=i.availabilityDelay;if(i.updated===!1)if(n){var h=333*i.misses;a=Math.max(Math.min(d,l*2),h),i.availabilityDelay=(i.availabilityDelay||0)+a}else a=d;else n?(f=Math.min(f||o/2,t),i.availabilityDelay=f,a=f+o-t):a=o-l;return Math.round(a)}function c(i,r,o){if(!i||!i.details)return null;var d=i.details,t=d.fragments[r-d.startSN];return t||(t=d.fragmentHint,t&&t.sn===r)?t:r<d.startSN&&o&&o.sn===r?o:null}function v(i,r,o){if(!i||!i.details)return null;var d=i.details.partList;if(d)for(var t=d.length;t--;){var n=d[t];if(n.index===o&&n.fragment.sn===r)return n}return null}},"./src/controller/stream-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return v});var M=m("./src/polyfills/number.ts"),_=m("./src/controller/base-stream-controller.ts"),L=m("./src/is-supported.ts"),C=m("./src/events.ts"),b=m("./src/utils/buffer-helper.ts"),O=m("./src/controller/fragment-tracker.ts"),A=m("./src/types/loader.ts"),y=m("./src/loader/fragment.ts"),T=m("./src/demux/transmuxer-interface.ts"),D=m("./src/types/transmuxer.ts"),E=m("./src/controller/gap-controller.ts"),g=m("./src/errors.ts");function p(i,r){for(var o=0;o<r.length;o++){var d=r[o];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(i,d.key,d)}}function u(i,r,o){return r&&p(i.prototype,r),o&&p(i,o),Object.defineProperty(i,"prototype",{writable:!1}),i}function e(i,r){i.prototype=Object.create(r.prototype),i.prototype.constructor=i,s(i,r)}function s(i,r){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(d,t){return d.__proto__=t,d},s(i,r)}var c=100,v=function(i){e(r,i);function r(d,t){var n;return n=i.call(this,d,t,"[stream-controller]")||this,n.audioCodecSwap=!1,n.gapController=null,n.level=-1,n._forceStartLoad=!1,n.altAudio=!1,n.audioOnly=!1,n.fragPlaying=null,n.onvplaying=null,n.onvseeked=null,n.fragLastKbps=0,n.couldBacktrack=!1,n.backtrackFragment=null,n.audioCodecSwitch=!1,n.videoBuffer=null,n._registerListeners(),n}var o=r.prototype;return o._registerListeners=function(){var t=this.hls;t.on(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(C.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(C.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(C.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(C.Events.ERROR,this.onError,this),t.on(C.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(C.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(C.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(C.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(C.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(C.Events.FRAG_BUFFERED,this.onFragBuffered,this)},o._unregisterListeners=function(){var t=this.hls;t.off(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(C.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(C.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(C.Events.ERROR,this.onError,this),t.off(C.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(C.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(C.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(C.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(C.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(C.Events.FRAG_BUFFERED,this.onFragBuffered,this)},o.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},o.startLoad=function(t){if(this.levels){var n=this.lastCurrentTime,l=this.hls;if(this.stopLoad(),this.setInterval(c),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var a=l.startLevel;a===-1&&(l.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=l.nextAutoLevel),this.level=l.nextLoadLevel=a,this.loadedmetadata=!1}n>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+n.toFixed(3)),t=n),this.state=_.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=_.State.STOPPED},o.stopLoad=function(){this._forceStartLoad=!1,i.prototype.stopLoad.call(this)},o.doTick=function(){switch(this.state){case _.State.IDLE:this.doTickIdle();break;case _.State.WAITING_LEVEL:{var t,n=this.levels,l=this.level,a=n==null||(t=n[l])===null||t===void 0?void 0:t.details;if(a&&(!a.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(a))break;this.state=_.State.IDLE;break}break}case _.State.FRAG_LOADING_WAITING_RETRY:{var f,h=self.performance.now(),S=this.retryDate;(!S||h>=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=_.State.IDLE)}break;default:break}this.onTickEnd()},o.onTickEnd=function(){i.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},o.doTickIdle=function(){var t,n,l=this.hls,a=this.levelLastLoaded,f=this.levels,h=this.media,S=l.config,x=l.nextLoadLevel;if(!(a===null||!h&&(this.startFragRequested||!S.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!f||!f[x])){var P=f[x];this.level=l.nextLoadLevel=x;var k=P.details;if(!k||this.state===_.State.WAITING_LEVEL||k.live&&this.levelLastLoaded!==x){this.state=_.State.WAITING_LEVEL;return}var B=this.getMainFwdBufferInfo();if(B!==null){var U=B.len,W=this.getMaxBufferLength(P.maxBitrate);if(!(U>=W)){if(this._streamEnded(B,k)){var G={};this.altAudio&&(G.type="video"),this.hls.trigger(C.Events.BUFFER_EOS,G),this.state=_.State.ENDED;return}this.backtrackFragment&&this.backtrackFragment.start>B.end&&(this.backtrackFragment=null);var z=this.backtrackFragment?this.backtrackFragment.start:B.end,Y=this.getNextFragment(z,k);if(this.couldBacktrack&&!this.fragPrevious&&Y&&Y.sn!=="initSegment"&&this.fragmentTracker.getState(Y)!==O.FragmentState.OK){var $,Z=(($=this.backtrackFragment)!=null?$:Y).sn,q=Z-k.startSN,ie=k.fragments[q-1];ie&&Y.cc===ie.cc&&(Y=ie,this.fragmentTracker.removeFragment(ie))}else this.backtrackFragment&&B.len&&(this.backtrackFragment=null);if(Y&&this.fragmentTracker.getState(Y)===O.FragmentState.OK&&this.nextLoadPosition>z){var ne=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;h&&this.afterBufferFlushed(h,ne,A.PlaylistLevelType.MAIN),Y=this.getNextFragment(this.nextLoadPosition,k)}!Y||(Y.initSegment&&!Y.initSegment.data&&!this.bitrateTest&&(Y=Y.initSegment),((t=Y.decryptdata)===null||t===void 0?void 0:t.keyFormat)==="identity"&&!((n=Y.decryptdata)!==null&&n!==void 0&&n.key)?this.loadKey(Y,k):this.loadFragment(Y,k,z))}}}},o.loadFragment=function(t,n,l){var a,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,n,l)):f===O.FragmentState.APPENDING?this.reduceMaxBufferLength(t.duration)&&this.fragmentTracker.removeFragment(t):((a=this.media)===null||a===void 0?void 0:a.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},o.getAppendedFrag=function(t){var n=this.fragmentTracker.getAppendedFrag(t,A.PlaylistLevelType.MAIN);return n&&"fragment"in n?n.fragment:n},o.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,A.PlaylistLevelType.MAIN)},o.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},o.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},o.nextLevelSwitch=function(){var t=this.levels,n=this.media;if(n!=null&&n.readyState){var l,a=this.getAppendedFrag(n.currentTime);if(a&&a.start>1&&this.flushMainBuffer(0,a.start-1),!n.paused&&t){var f=this.hls.nextLoadLevel,h=t[f],S=this.fragLastKbps;S&&this.fragCurrent?l=this.fragCurrent.duration*h.maxBitrate/(1e3*S)+1:l=0}else l=0;var x=this.getBufferedFrag(n.currentTime+l);if(x){var P=this.followingBufferedFrag(x);if(P){this.abortCurrentFrag();var k=P.maxStartPTS?P.maxStartPTS:P.start,B=P.duration,U=Math.max(x.end,k+Math.min(Math.max(B-this.config.maxFragLookUpTolerance,B*.5),B*.75));this.flushMainBuffer(U,Number.POSITIVE_INFINITY)}}}},o.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t!=null&&t.loader&&t.loader.abort(),this.state){case _.State.KEY_LOADING:case _.State.FRAG_LOADING:case _.State.FRAG_LOADING_WAITING_RETRY:case _.State.PARSING:case _.State.PARSED:this.state=_.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},o.flushMainBuffer=function(t,n){i.prototype.flushMainBuffer.call(this,t,n,this.altAudio?"video":null)},o.onMediaAttached=function(t,n){i.prototype.onMediaAttached.call(this,t,n);var l=n.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),l.addEventListener("playing",this.onvplaying),l.addEventListener("seeked",this.onvseeked),this.gapController=new E.default(this.config,l,this.fragmentTracker,this.hls)},o.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)},o.onMediaPlaying=function(){this.tick()},o.onMediaSeeked=function(){var t=this.media,n=t?t.currentTime:null;Object(M.isFiniteNumber)(n)&&this.log("Media seeked to "+n.toFixed(3)),this.tick()},o.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(C.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},o.onManifestParsed=function(t,n){var l=!1,a=!1,f;n.levels.forEach(function(h){f=h.audioCodec,f&&(f.indexOf("mp4a.40.2")!==-1&&(l=!0),f.indexOf("mp4a.40.5")!==-1&&(a=!0))}),this.audioCodecSwitch=l&&a&&!Object(L.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=n.levels,this.startFragRequested=!1},o.onLevelLoading=function(t,n){var l=this.levels;if(!(!l||this.state!==_.State.IDLE)){var a=l[n.level];(!a.details||a.details.live&&this.levelLastLoaded!==n.level||this.waitForCdnTuneIn(a.details))&&(this.state=_.State.WAITING_LEVEL)}},o.onLevelLoaded=function(t,n){var l,a=this.levels,f=n.level,h=n.details,S=h.totalduration;if(!a){this.warn("Levels were reset while loading level "+f);return}this.log("Level "+f+" loaded ["+h.startSN+","+h.endSN+"], cc ["+h.startCC+", "+h.endCC+"] duration:"+S);var x=this.fragCurrent;x&&(this.state===_.State.FRAG_LOADING||this.state===_.State.FRAG_LOADING_WAITING_RETRY)&&x.level!==n.level&&x.loader&&(this.state=_.State.IDLE,this.backtrackFragment=null,x.loader.abort());var P=a[f],k=0;if(h.live||(l=P.details)!==null&&l!==void 0&&l.live){if(h.fragments[0]||(h.deltaUpdateFailed=!0),h.deltaUpdateFailed)return;k=this.alignPlaylists(h,P.details)}if(P.details=h,this.levelLastLoaded=f,this.hls.trigger(C.Events.LEVEL_UPDATED,{details:h,level:f}),this.state===_.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(h))return;this.state=_.State.IDLE}this.startFragRequested?h.live&&this.synchronizeToLiveEdge(h):this.setStartPosition(h,k),this.tick()},o._handleFragmentLoadProgress=function(t){var n,l=t.frag,a=t.part,f=t.payload,h=this.levels;if(!h){this.warn("Levels were reset while fragment load was in progress. Fragment "+l.sn+" of level "+l.level+" will not be buffered");return}var S=h[l.level],x=S.details;if(!x){this.warn("Dropping fragment "+l.sn+" of level "+l.level+" after level details were reset");return}var P=S.videoCodec,k=x.PTSKnown||!x.live,B=(n=l.initSegment)===null||n===void 0?void 0:n.data,U=this._getAudioCodec(S),W=this.transmuxer=this.transmuxer||new T.default(this.hls,A.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),G=a?a.index:-1,z=G!==-1,Y=new D.ChunkMetadata(l.level,l.sn,l.stats.chunkCount,f.byteLength,G,z),$=this.initPTS[l.cc];W.push(f,B,U,P,l,a,x.totalduration,k,Y,$)},o.onAudioTrackSwitching=function(t,n){var l=this.altAudio,a=!!n.url,f=n.id;if(!a){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var h=this.fragCurrent;h!=null&&h.loader&&(this.log("Switching to main audio track, cancel main fragment load"),h.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var S=this.hls;l&&S.trigger(C.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),S.trigger(C.Events.AUDIO_TRACK_SWITCHED,{id:f})}},o.onAudioTrackSwitched=function(t,n){var l=n.id,a=!!this.hls.audioTracks[l].url;if(a){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=a,this.tick()},o.onBufferCreated=function(t,n){var l=n.tracks,a,f,h=!1;for(var S in l){var x=l[S];if(x.id==="main"){if(f=S,a=x,S==="video"){var P=l[S];P&&(this.videoBuffer=P.buffer)}}else h=!0}h&&a?(this.log("Alternate track found, use "+f+".buffered to schedule main fragment loading"),this.mediaBuffer=a.buffer):this.mediaBuffer=this.media},o.onFragBuffered=function(t,n){var l=n.frag,a=n.part;if(!(l&&l.type!==A.PlaylistLevelType.MAIN)){if(this.fragContextChanged(l)){this.warn("Fragment "+l.sn+(a?" p: "+a.index:"")+" of level "+l.level+" finished buffering, but was aborted. state: "+this.state),this.state===_.State.PARSED&&(this.state=_.State.IDLE);return}var f=a?a.stats:l.stats;this.fragLastKbps=Math.round(8*f.total/(f.buffering.end-f.loading.first)),l.sn!=="initSegment"&&(this.fragPrevious=l),this.fragBufferedComplete(l,a)}},o.onError=function(t,n){switch(n.details){case g.ErrorDetails.FRAG_LOAD_ERROR:case g.ErrorDetails.FRAG_LOAD_TIMEOUT:case g.ErrorDetails.KEY_LOAD_ERROR:case g.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.MAIN,n);break;case g.ErrorDetails.LEVEL_LOAD_ERROR:case g.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==_.State.ERROR&&(n.fatal?(this.warn(""+n.details),this.state=_.State.ERROR):!n.levelRetry&&this.state===_.State.WAITING_LEVEL&&(this.state=_.State.IDLE));break;case g.ErrorDetails.BUFFER_FULL_ERROR:if(n.parent==="main"&&(this.state===_.State.PARSING||this.state===_.State.PARSED)){var l=!0,a=this.getFwdBufferInfo(this.media,A.PlaylistLevelType.MAIN);a&&a.len>.5&&(l=!this.reduceMaxBufferLength(a.len)),l&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},o.checkBuffer=function(){var t=this.media,n=this.gapController;if(!(!t||!n||!t.readyState)){if(this.loadedmetadata||!b.BufferHelper.getBuffered(t).length){var l=this.state!==_.State.IDLE?this.fragCurrent:null;n.poll(this.lastCurrentTime,l)}this.lastCurrentTime=t.currentTime}},o.onFragLoadEmergencyAborted=function(){this.state=_.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},o.onBufferFlushed=function(t,n){var l=n.type;if(l!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var a=(l===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(a,l,A.PlaylistLevelType.MAIN)}},o.onLevelsUpdated=function(t,n){this.levels=n.levels},o.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},o.seekToStartPos=function(){var t=this.media;if(!!t){var n=t.currentTime,l=this.startPosition;if(l>=0&&n<l){if(t.seeking){this.log("could not seek to "+l+", already seeking at "+n);return}var a=b.BufferHelper.getBuffered(t),f=a.length?a.start(0):0,h=f-l;h>0&&(h<this.config.maxBufferHole||h<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+h+" to match buffer start"),l+=h,this.startPosition=l),this.log("seek to target start position "+l+" from current time "+n),t.currentTime=l}}},o._getAudioCodec=function(t){var n=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&n&&(this.log("Swapping audio codec"),n.indexOf("mp4a.40.5")!==-1?n="mp4a.40.2":n="mp4a.40.5"),n},o._loadBitrateTestFrag=function(t){var n=this;t.bitrateTest=!0,this._doFragLoad(t).then(function(l){var a=n.hls;if(!(!l||a.nextLoadLevel||n.fragContextChanged(t))){n.fragLoadError=0,n.state=_.State.IDLE,n.startFragRequested=!1,n.bitrateTest=!1;var f=t.stats;f.parsing.start=f.parsing.end=f.buffering.start=f.buffering.end=self.performance.now(),a.trigger(C.Events.FRAG_LOADED,l),t.bitrateTest=!1}})},o._handleTransmuxComplete=function(t){var n,l="main",a=this.hls,f=t.remuxResult,h=t.chunkMeta,S=this.getCurrentContext(h);if(!S){this.warn("The loading context changed while buffering fragment "+h.sn+" of level "+h.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(h.level);return}var x=S.frag,P=S.part,k=S.level,B=f.video,U=f.text,W=f.id3,G=f.initSegment,z=k.details,Y=this.altAudio?void 0:f.audio;if(!this.fragContextChanged(x)){if(this.state=_.State.PARSING,G){G.tracks&&(this._bufferInitSegment(k,G.tracks,x,h),a.trigger(C.Events.FRAG_PARSING_INIT_SEGMENT,{frag:x,id:l,tracks:G.tracks}));var $=G.initPTS,Z=G.timescale;Object(M.isFiniteNumber)($)&&(this.initPTS[x.cc]=$,a.trigger(C.Events.INIT_PTS_FOUND,{frag:x,id:l,initPTS:$,timescale:Z}))}if(B&&f.independent!==!1){if(z){var q=B.startPTS,ie=B.endPTS,ne=B.startDTS,ae=B.endDTS;if(P)P.elementaryStreams[B.type]={startPTS:q,endPTS:ie,startDTS:ne,endDTS:ae};else if(B.firstKeyFrame&&B.independent&&(this.couldBacktrack=!0),B.dropped&&B.independent){var te=this.getMainFwdBufferInfo(),fe=(te?te.end:this.getLoadPosition())+this.config.maxBufferHole,de=B.firstKeyFramePTS?B.firstKeyFramePTS:q;if(fe<de-this.config.maxBufferHole){this.backtrack(x);return}x.setElementaryStreamInfo(B.type,x.start,ie,x.start,ae,!0)}x.setElementaryStreamInfo(B.type,q,ie,ne,ae),this.backtrackFragment&&(this.backtrackFragment=x),this.bufferFragmentData(B,x,P,h)}}else if(f.independent===!1){this.backtrack(x);return}if(Y){var re=Y.startPTS,Ee=Y.endPTS,me=Y.startDTS,Te=Y.endDTS;P&&(P.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:re,endPTS:Ee,startDTS:me,endDTS:Te}),x.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,re,Ee,me,Te),this.bufferFragmentData(Y,x,P,h)}if(z&&W!==null&&W!==void 0&&(n=W.samples)!==null&&n!==void 0&&n.length){var Me={id:l,frag:x,details:z,samples:W.samples};a.trigger(C.Events.FRAG_PARSING_METADATA,Me)}if(z&&U){var Ae={id:l,frag:x,details:z,samples:U.samples};a.trigger(C.Events.FRAG_PARSING_USERDATA,Ae)}}},o._bufferInitSegment=function(t,n,l,a){var f=this;if(this.state===_.State.PARSING){this.audioOnly=!!n.audio&&!n.video,this.altAudio&&!this.audioOnly&&delete n.audio;var h=n.audio,S=n.video,x=n.audiovideo;if(h){var P=t.audioCodec,k=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(P&&(P.indexOf("mp4a.40.5")!==-1?P="mp4a.40.2":P="mp4a.40.5"),h.metadata.channelCount!==1&&k.indexOf("firefox")===-1&&(P="mp4a.40.5")),k.indexOf("android")!==-1&&h.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+'"'),h.levelCodec=P,h.id="main",this.log("Init audio buffer, container:"+h.container+", codecs[selected/level/parsed]=["+(P||"")+"/"+(t.audioCodec||"")+"/"+h.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(C.Events.BUFFER_CODECS,n),Object.keys(n).forEach(function(B){var U=n[B],W=U.initSegment;W!=null&&W.byteLength&&f.hls.trigger(C.Events.BUFFER_APPENDING,{type:B,data:W,frag:l,part:null,chunkMeta:a,parent:l.type})}),this.tick()}},o.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,A.PlaylistLevelType.MAIN)},o.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=_.State.IDLE},o.checkFragmentChanged=function(){var t=this.media,n=null;if(t&&t.readyState>1&&t.seeking===!1){var l=t.currentTime;if(b.BufferHelper.isBuffered(t,l)?n=this.getAppendedFrag(l):b.BufferHelper.isBuffered(t,l+.1)&&(n=this.getAppendedFrag(l+.1)),n){this.backtrackFragment=null;var a=this.fragPlaying,f=n.level;(!a||n.sn!==a.sn||a.level!==f||n.urlId!==a.urlId)&&(this.hls.trigger(C.Events.FRAG_CHANGED,{frag:n}),(!a||a.level!==f)&&this.hls.trigger(C.Events.LEVEL_SWITCHED,{level:f}),this.fragPlaying=n)}}},u(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 n=t.currentTime,l=this.currentFrag;if(l&&Object(M.isFiniteNumber)(n)&&Object(M.isFiniteNumber)(l.programDateTime)){var a=l.programDateTime+(n-l.start)*1e3;return new Date(a)}}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}(_.default)},"./src/controller/subtitle-stream-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"SubtitleStreamController",function(){return e});var M=m("./src/events.ts"),_=m("./src/utils/buffer-helper.ts"),L=m("./src/controller/fragment-finders.ts"),C=m("./src/utils/discontinuities.ts"),b=m("./src/controller/level-helper.ts"),O=m("./src/controller/fragment-tracker.ts"),A=m("./src/controller/base-stream-controller.ts"),y=m("./src/types/loader.ts"),T=m("./src/types/level.ts");function D(c,v){for(var i=0;i<v.length;i++){var r=v[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(c,r.key,r)}}function E(c,v,i){return v&&D(c.prototype,v),i&&D(c,i),Object.defineProperty(c,"prototype",{writable:!1}),c}function g(c,v){c.prototype=Object.create(v.prototype),c.prototype.constructor=c,p(c,v)}function p(c,v){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},p(c,v)}var u=500,e=function(c){g(v,c);function v(r,o){var d;return d=c.call(this,r,o,"[subtitle-stream-controller]")||this,d.levels=[],d.currentTrackId=-1,d.tracksBuffered=[],d.mainDetails=null,d._registerListeners(),d}var i=v.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var o=this.hls;o.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.on(M.Events.ERROR,this.onError,this),o.on(M.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.on(M.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),o.on(M.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on(M.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),o.on(M.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var o=this.hls;o.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.off(M.Events.ERROR,this.onError,this),o.off(M.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.off(M.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),o.off(M.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off(M.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),o.off(M.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.startLoad=function(){this.stopLoad(),this.state=A.State.IDLE,this.setInterval(u),this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onLevelLoaded=function(o,d){this.mainDetails=d.details},i.onSubtitleFragProcessed=function(o,d){var t=d.frag,n=d.success;if(this.fragPrevious=t,this.state=A.State.IDLE,!!n){var l=this.tracksBuffered[this.currentTrackId];if(!!l){for(var a,f=t.start,h=0;h<l.length;h++)if(f>=l[h].start&&f<=l[h].end){a=l[h];break}var S=t.start+t.duration;a?a.end=S:(a={start:f,end:S},l.push(a)),this.fragmentTracker.fragBuffered(t)}}},i.onBufferFlushing=function(o,d){var t=d.startOffset,n=d.endOffset;if(t===0&&n!==Number.POSITIVE_INFINITY){var l=this.currentTrackId,a=this.levels;if(!a.length||!a[l]||!a[l].details)return;var f=a[l].details,h=f.targetduration,S=n-h;if(S<=0)return;d.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(o,d){var t,n=d.frag;!n||n.type!==y.PlaylistLevelType.SUBTITLE||((t=this.fragCurrent)!==null&&t!==void 0&&t.loader&&this.fragCurrent.loader.abort(),this.state=A.State.IDLE)},i.onSubtitleTracksUpdated=function(o,d){var t=this,n=d.subtitleTracks;this.tracksBuffered=[],this.levels=n.map(function(l){return new T.Level(l)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(l){t.tracksBuffered[l.id]=[]}),this.mediaBuffer=null},i.onSubtitleTrackSwitch=function(o,d){if(this.currentTrackId=d.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(u)},i.onSubtitleTrackLoaded=function(o,d){var t,n=d.details,l=d.id,a=this.currentTrackId,f=this.levels;if(!!f.length){var h=f[a];if(!(l>=f.length||l!==a||!h)){if(this.mediaBuffer=this.mediaBufferTimeRanges,n.live||(t=h.details)!==null&&t!==void 0&&t.live){var S=this.mainDetails;if(n.deltaUpdateFailed||!S)return;var x=S.fragments[0];if(!h.details)n.hasProgramDateTime&&S.hasProgramDateTime?Object(C.alignMediaPlaylistByPDT)(n,S):x&&Object(b.addSliding)(n,x.start);else{var P=this.alignPlaylists(n,h.details);P===0&&x&&Object(b.addSliding)(n,x.start)}}if(h.details=n,this.levelLastLoaded=l,this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===A.State.IDLE){var k=Object(L.findFragmentByPTS)(null,n.fragments,this.media.currentTime,0);k||(this.warn("Subtitle playlist not aligned with playback"),h.details=void 0)}}}},i._handleFragmentLoadComplete=function(o){var d=o.frag,t=o.payload,n=d.decryptdata,l=this.hls;if(!this.fragContextChanged(d)&&t&&t.byteLength>0&&n&&n.key&&n.iv&&n.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(t),n.key.buffer,n.iv.buffer).then(function(f){var h=performance.now();l.trigger(M.Events.FRAG_DECRYPTED,{frag:d,payload:f,stats:{tstart:a,tdecrypt:h}})})}},i.doTick=function(){if(!this.media){this.state=A.State.IDLE;return}if(this.state===A.State.IDLE){var o=this.currentTrackId,d=this.levels;if(!d.length||!d[o]||!d[o].details)return;var t=d[o].details,n=t.targetduration,l=this.config,a=this.media,f=_.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a.currentTime-n,l.maxBufferHole),h=f.end,S=f.len,x=this.getMaxBufferLength()+n;if(S>x)return;console.assert(t,"Subtitle track details are defined on idle subtitle stream controller tick");var P=t.fragments,k=P.length,B=t.edge,U,W=this.fragPrevious;if(h<B){var G=l.maxFragLookUpTolerance;U=Object(L.findFragmentByPTS)(W,P,Math.max(P[0].start,h),G),!U&&W&&W.start<P[0].start&&(U=P[0])}else U=P[k-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,h)}},i.loadFragment=function(o,d,t){this.fragCurrent=o,o.sn==="initSegment"?this._loadInitSegment(o):c.prototype.loadFragment.call(this,o,d,t)},E(v,[{key:"mediaBufferTimeRanges",get:function(){return new s(this.tracksBuffered[this.currentTrackId]||[])}}]),v}(A.default),s=function(v){this.buffered=void 0;var i=function(o,d,t){if(d=d>>>0,d>t-1)throw new DOMException("Failed to execute '"+o+"' on 'TimeRanges': The index provided ("+d+") is greater than the maximum bound ("+t+")");return v[d][o]};this.buffered={get length(){return v.length},end:function(o){return i("end",o,v.length)},start:function(o){return i("start",o,v.length)}}}},"./src/controller/subtitle-track-controller.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/events.ts"),_=m("./src/utils/texttrack-utils.ts"),L=m("./src/controller/base-playlist-controller.ts"),C=m("./src/types/loader.ts");function b(E,g){for(var p=0;p<g.length;p++){var u=g[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(E,u.key,u)}}function O(E,g,p){return g&&b(E.prototype,g),p&&b(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}function A(E,g){E.prototype=Object.create(g.prototype),E.prototype.constructor=E,y(E,g)}function y(E,g){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,e){return u.__proto__=e,u},y(E,g)}var T=function(E){A(g,E);function g(u){var e;return e=E.call(this,u,"[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=g.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(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(M.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(M.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(M.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(M.Events.ERROR,this.onError,this)},p.unregisterListeners=function(){var e=this.hls;e.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(M.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(M.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(M.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(M.Events.ERROR,this.onError,this)},p.onMediaAttached=function(e,s){this.media=s.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(s){Object(_.clearCurrentCues)(s)}),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,s){this.tracks=s.subtitleTracks},p.onSubtitleTrackLoaded=function(e,s){var c=s.id,v=s.details,i=this.trackId,r=this.tracksInGroup[i];if(!r){this.warn("Invalid subtitle track id "+c);return}var o=r.details;r.details=s.details,this.log("subtitle track "+c+" loaded ["+v.startSN+"-"+v.endSN+"]"),c===this.trackId&&(this.retryCount=0,this.playlistLoaded(c,s,o))},p.onLevelLoading=function(e,s){this.switchLevel(s.level)},p.onLevelSwitching=function(e,s){this.switchLevel(s.level)},p.switchLevel=function(e){var s=this.hls.levels[e];if(!!(s!=null&&s.textGroupIds)){var c=s.textGroupIds[s.urlId];if(this.groupId!==c){var v=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,i=this.tracks.filter(function(d){return!c||d.groupId===c});this.tracksInGroup=i;var r=this.findTrackId(v==null?void 0:v.name)||this.findTrackId();this.groupId=c;var o={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+c+'" group-id'),this.hls.trigger(M.Events.SUBTITLE_TRACKS_UPDATED,o),r!==-1&&this.setSubtitleTrack(r,v)}}},p.findTrackId=function(e){for(var s=this.tracksInGroup,c=0;c<s.length;c++){var v=s[c];if((!this.selectDefaultTrack||v.default)&&(!e||e===v.name))return v.id}return-1},p.onError=function(e,s){E.prototype.onError.call(this,e,s),!(s.fatal||!s.context)&&s.context.type===C.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},p.loadPlaylist=function(e){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var c=s.id,v=s.groupId,i=s.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 "+c),this.hls.trigger(M.Events.SUBTITLE_TRACK_LOADING,{url:i,id:c,groupId:v,deliveryDirectives:e||null})}},p.toggleTrackModes=function(e){var s=this,c=this.media,v=this.trackId;if(!!c){var i=D(c.textTracks),r=i.filter(function(t){return t.groupId===s.groupId});if(e===-1)[].slice.call(i).forEach(function(t){t.mode="disabled"});else{var o=r[v];o&&(o.mode="disabled")}var d=r[e];d&&(d.mode=this.subtitleDisplay?"showing":"hidden")}},p.setSubtitleTrack=function(e,s){var c,v=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(c=v[e])!==null&&c!==void 0&&c.details)||e<-1||e>=v.length)){this.clearTimer();var i=v[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,i){var r=i.id,o=i.groupId,d=o===void 0?"":o,t=i.name,n=i.type,l=i.url;this.hls.trigger(M.Events.SUBTITLE_TRACK_SWITCH,{id:r,groupId:d,name:t,type:n,url:l});var a=this.switchParams(i.url,s==null?void 0:s.details);this.loadPlaylist(a)}else this.hls.trigger(M.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,s=D(this.media.textTracks),c=0;c<s.length;c++)if(s[c].mode==="hidden")e=c;else if(s[c].mode==="showing"){e=c;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},O(g,[{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 s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,s)}}]),g}(L.default);function D(E){for(var g=[],p=0;p<E.length;p++){var u=E[p];u.kind==="subtitles"&&u.label&&g.push(E[p])}return g}R.default=T},"./src/controller/timeline-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"TimelineController",function(){return E});var M=m("./src/polyfills/number.ts"),_=m("./src/events.ts"),L=m("./src/utils/cea-608-parser.ts"),C=m("./src/utils/output-filter.ts"),b=m("./src/utils/webvtt-parser.ts"),O=m("./src/utils/texttrack-utils.ts"),A=m("./src/utils/imsc1-ttml-parser.ts"),y=m("./src/utils/mp4-tools.ts"),T=m("./src/types/loader.ts"),D=m("./src/utils/logger.ts"),E=function(){function e(c){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=u(),this.captionsProperties=void 0,this.hls=c,this.config=c.config,this.Cues=c.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 v=new C.default(this,"textTrack1"),i=new C.default(this,"textTrack2"),r=new C.default(this,"textTrack3"),o=new C.default(this,"textTrack4");this.cea608Parser1=new L.default(1,v,i),this.cea608Parser2=new L.default(3,r,o)}c.on(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),c.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(_.Events.MANIFEST_LOADED,this.onManifestLoaded,this),c.on(_.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),c.on(_.Events.FRAG_LOADING,this.onFragLoading,this),c.on(_.Events.FRAG_LOADED,this.onFragLoaded,this),c.on(_.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),c.on(_.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),c.on(_.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),c.on(_.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),c.on(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var s=e.prototype;return s.destroy=function(){var v=this.hls;v.off(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),v.off(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.off(_.Events.MANIFEST_LOADED,this.onManifestLoaded,this),v.off(_.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),v.off(_.Events.FRAG_LOADING,this.onFragLoading,this),v.off(_.Events.FRAG_LOADED,this.onFragLoaded,this),v.off(_.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),v.off(_.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),v.off(_.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),v.off(_.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),v.off(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},s.addCues=function(v,i,r,o,d){for(var t=!1,n=d.length;n--;){var l=d[n],a=p(l[0],l[1],i,r);if(a>=0&&(l[0]=Math.min(l[0],i),l[1]=Math.max(l[1],r),t=!0,a/(r-i)>.5))return}if(t||d.push([i,r]),this.config.renderTextTracksNatively){var f=this.captionsTracks[v];this.Cues.newCue(f,i,r,o)}else{var h=this.Cues.newCue(null,i,r,o);this.hls.trigger(_.Events.CUES_PARSED,{type:"captions",cues:h,track:v})}},s.onInitPtsFound=function(v,i){var r=this,o=i.frag,d=i.id,t=i.initPTS,n=i.timescale,l=this.unparsedVttFrags;d==="main"&&(this.initPTS[o.cc]=t,this.timescale[o.cc]=n),l.length&&(this.unparsedVttFrags=[],l.forEach(function(a){r.onFragLoaded(_.Events.FRAG_LOADED,a)}))},s.getExistingTrack=function(v){var i=this.media;if(i)for(var r=0;r<i.textTracks.length;r++){var o=i.textTracks[r];if(o[v])return o}return null},s.createCaptionsTrack=function(v){this.config.renderTextTracksNatively?this.createNativeTrack(v):this.createNonNativeTrack(v)},s.createNativeTrack=function(v){if(!this.captionsTracks[v]){var i=this.captionsProperties,r=this.captionsTracks,o=this.media,d=i[v],t=d.label,n=d.languageCode,l=this.getExistingTrack(v);if(l)r[v]=l,Object(O.clearCurrentCues)(r[v]),Object(O.sendAddTrackEvent)(r[v],o);else{var a=this.createTextTrack("captions",t,n);a&&(a[v]=!0,r[v]=a)}}},s.createNonNativeTrack=function(v){if(!this.nonNativeCaptionsTracks[v]){var i=this.captionsProperties[v];if(!!i){var r=i.label,o={_id:v,label:r,kind:"captions",default:i.media?!!i.media.default:!1,closedCaptions:i.media};this.nonNativeCaptionsTracks[v]=o,this.hls.trigger(_.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[o]})}}},s.createTextTrack=function(v,i,r){var o=this.media;if(!!o)return o.addTextTrack(v,i,r)},s.onMediaAttaching=function(v,i){this.media=i.media,this._cleanTracks()},s.onMediaDetaching=function(){var v=this.captionsTracks;Object.keys(v).forEach(function(i){Object(O.clearCurrentCues)(v[i]),delete v[i]}),this.nonNativeCaptionsTracks={}},s.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=u(),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())},s._cleanTracks=function(){var v=this.media;if(!!v){var i=v.textTracks;if(i)for(var r=0;r<i.length;r++)Object(O.clearCurrentCues)(i[r])}},s.onSubtitleTracksUpdated=function(v,i){var r=this;this.textTracks=[];var o=i.subtitleTracks||[],d=o.some(function(a){return a.textCodec===A.IMSC1_CODEC});if(this.config.enableWebVTT||d&&this.config.enableIMSC1){var t=this.tracks&&o&&this.tracks.length===o.length;if(this.tracks=o||[],this.config.renderTextTracksNatively){var n=this.media?this.media.textTracks:[];this.tracks.forEach(function(a,f){var h;if(f<n.length){for(var S=null,x=0;x<n.length;x++)if(g(n[x],a)){S=n[x];break}S&&(h=S)}if(h)Object(O.clearCurrentCues)(h);else{var P=r._captionsOrSubtitlesFromCharacteristics(a);h=r.createTextTrack(P,a.name,a.lang),h&&(h.mode="disabled")}h&&(h.groupId=a.groupId,r.textTracks.push(h))})}else if(!t&&this.tracks&&this.tracks.length){var l=this.tracks.map(function(a){return{label:a.name,kind:a.type.toLowerCase(),default:a.default,subtitleTrack:a}});this.hls.trigger(_.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:l})}}},s._captionsOrSubtitlesFromCharacteristics=function(v){var i;if((i=v.attrs)!==null&&i!==void 0&&i.CHARACTERISTICS){var r=/transcribes-spoken-dialog/gi.test(v.attrs.CHARACTERISTICS),o=/describes-music-and-sound/gi.test(v.attrs.CHARACTERISTICS);if(r&&o)return"captions"}return"subtitles"},s.onManifestLoaded=function(v,i){var r=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach(function(o){var d=/(?:CC|SERVICE)([1-4])/.exec(o.instreamId);if(!!d){var t="textTrack"+d[1],n=r.captionsProperties[t];!n||(n.label=o.name,o.lang&&(n.languageCode=o.lang),n.media=o)}})},s.onFragLoading=function(v,i){var r=this.cea608Parser1,o=this.cea608Parser2,d=this.lastSn,t=this.lastPartIndex;if(!(!this.enabled||!(r&&o))&&i.frag.type===T.PlaylistLevelType.MAIN){var n,l,a=i.frag.sn,f=(n=i==null||(l=i.part)===null||l===void 0?void 0:l.index)!=null?n:-1;a===d+1||a===d&&f===t+1||(r.reset(),o.reset()),this.lastSn=a,this.lastPartIndex=f}},s.onFragLoaded=function(v,i){var r=i.frag,o=i.payload,d=this.initPTS,t=this.unparsedVttFrags;if(r.type===T.PlaylistLevelType.SUBTITLE)if(o.byteLength){if(!Object(M.isFiniteNumber)(d[r.cc])){t.push(i),d.length&&this.hls.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")});return}var n=r.decryptdata,l="stats"in i;if(n==null||n.key==null||n.method!=="AES-128"||l){var a=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),a&&a.textCodec===A.IMSC1_CODEC?this._parseIMSC1(r,o):this._parseVTTs(r,o,f)}}else this.hls.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},s._parseIMSC1=function(v,i){var r=this,o=this.hls;Object(A.parseIMSC1)(i,this.initPTS[v.cc],this.timescale[v.cc],function(d){r._appendCues(d,v.level),o.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:v})},function(d){D.logger.log("Failed to parse IMSC1: "+d),o.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:v,error:d})})},s._parseVTTs=function(v,i,r){var o,d=this,t=this.hls,n=(o=v.initSegment)!==null&&o!==void 0&&o.data?Object(y.appendUint8Array)(v.initSegment.data,new Uint8Array(i)):i;Object(b.parseWebVTT)(n,this.initPTS[v.cc],this.timescale[v.cc],r,v.cc,v.start,function(l){d._appendCues(l,v.level),t.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:v})},function(l){d._fallbackToIMSC1(v,i),D.logger.log("Failed to parse VTT cue: "+l),t.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:v,error:l})})},s._fallbackToIMSC1=function(v,i){var r=this,o=this.tracks[v.level];o.textCodec||Object(A.parseIMSC1)(i,this.initPTS[v.cc],this.timescale[v.cc],function(){o.textCodec=A.IMSC1_CODEC,r._parseIMSC1(v,i)},function(){o.textCodec="wvtt"})},s._appendCues=function(v,i){var r=this.hls;if(this.config.renderTextTracksNatively){var o=this.textTracks[i];if(!o||o.mode==="disabled")return;v.forEach(function(n){return Object(O.addCueToTrack)(o,n)})}else{var d=this.tracks[i];if(!d)return;var t=d.default?"default":"subtitles"+i;r.trigger(_.Events.CUES_PARSED,{type:"subtitles",cues:v,track:t})}},s.onFragDecrypted=function(v,i){var r=i.frag;if(r.type===T.PlaylistLevelType.SUBTITLE){if(!Object(M.isFiniteNumber)(this.initPTS[r.cc])){this.unparsedVttFrags.push(i);return}this.onFragLoaded(_.Events.FRAG_LOADED,i)}},s.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},s.onFragParsingUserdata=function(v,i){var r=this.cea608Parser1,o=this.cea608Parser2;if(!(!this.enabled||!(r&&o)))for(var d=0;d<i.samples.length;d++){var t=i.samples[d].bytes;if(t){var n=this.extractCea608Data(t);r.addData(i.samples[d].pts,n[0]),o.addData(i.samples[d].pts,n[1])}}},s.onBufferFlushing=function(v,i){var r=i.startOffset,o=i.endOffset,d=i.endOffsetSubtitles,t=i.type,n=this.media;if(!(!n||n.currentTime<o)){if(!t||t==="video"){var l=this.captionsTracks;Object.keys(l).forEach(function(f){return Object(O.removeCuesInRange)(l[f],r,o)})}if(this.config.renderTextTracksNatively&&r===0&&d!==void 0){var a=this.textTracks;Object.keys(a).forEach(function(f){return Object(O.removeCuesInRange)(a[f],r,d)})}}},s.extractCea608Data=function(v){for(var i=[[],[]],r=v[0]&31,o=2,d=0;d<r;d++){var t=v[o++],n=127&v[o++],l=127&v[o++];if(!(n===0&&l===0)){var a=(4&t)!==0;if(a){var f=3&t;(f===0||f===1)&&(i[f].push(n),i[f].push(l))}}}return i},e}();function g(e,s){return e&&e.label===s.name&&!(e.textTrack1||e.textTrack2)}function p(e,s,c,v){return Math.min(s,v)-Math.max(e,c)}function u(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return M});var M=function(){function _(C,b){this.subtle=void 0,this.aesIV=void 0,this.subtle=C,this.aesIV=b}var L=_.prototype;return L.decrypt=function(b,O){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},O,b)},_}()},"./src/crypt/aes-decryptor.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"removePadding",function(){return _}),m.d(R,"default",function(){return L});var M=m("./src/utils/typed-array.ts");function _(C){var b=C.byteLength,O=b&&new DataView(C.buffer).getUint8(b-1);return O?Object(M.sliceUint8)(C,0,b-O):C}var L=function(){function C(){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 b=C.prototype;return b.uint8ArrayToUint32Array_=function(A){for(var y=new DataView(A),T=new Uint32Array(4),D=0;D<4;D++)T[D]=y.getUint32(D*4);return T},b.initTable=function(){var A=this.sBox,y=this.invSBox,T=this.subMix,D=T[0],E=T[1],g=T[2],p=T[3],u=this.invSubMix,e=u[0],s=u[1],c=u[2],v=u[3],i=new Uint32Array(256),r=0,o=0,d=0;for(d=0;d<256;d++)d<128?i[d]=d<<1:i[d]=d<<1^283;for(d=0;d<256;d++){var t=o^o<<1^o<<2^o<<3^o<<4;t=t>>>8^t&255^99,A[r]=t,y[t]=r;var n=i[r],l=i[n],a=i[l],f=i[t]*257^t*16843008;D[r]=f<<24|f>>>8,E[r]=f<<16|f>>>16,g[r]=f<<8|f>>>24,p[r]=f,f=a*16843009^l*65537^n*257^r*16843008,e[t]=f<<24|f>>>8,s[t]=f<<16|f>>>16,c[t]=f<<8|f>>>24,v[t]=f,r?(r=n^i[i[i[a^n]]],o^=i[i[o]]):r=o=1}},b.expandKey=function(A){for(var y=this.uint8ArrayToUint32Array_(A),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 g=this.ksRows=(E+6+1)*4,p,u,e=this.keySchedule=new Uint32Array(g),s=this.invKeySchedule=new Uint32Array(g),c=this.sBox,v=this.rcon,i=this.invSubMix,r=i[0],o=i[1],d=i[2],t=i[3],n,l;for(p=0;p<g;p++){if(p<E){n=e[p]=y[p];continue}l=n,p%E===0?(l=l<<8|l>>>24,l=c[l>>>24]<<24|c[l>>>16&255]<<16|c[l>>>8&255]<<8|c[l&255],l^=v[p/E|0]<<24):E>6&&p%E===4&&(l=c[l>>>24]<<24|c[l>>>16&255]<<16|c[l>>>8&255]<<8|c[l&255]),e[p]=n=(e[p-E]^l)>>>0}for(u=0;u<g;u++)p=g-u,u&3?l=e[p]:l=e[p-4],u<4||p<=4?s[u]=l:s[u]=r[c[l>>>24]]^o[c[l>>>16&255]]^d[c[l>>>8&255]]^t[c[l&255]],s[u]=s[u]>>>0}},b.networkToHostOrderSwap=function(A){return A<<24|(A&65280)<<8|(A&16711680)>>8|A>>>24},b.decrypt=function(A,y,T){for(var D=this.keySize+6,E=this.invKeySchedule,g=this.invSBox,p=this.invSubMix,u=p[0],e=p[1],s=p[2],c=p[3],v=this.uint8ArrayToUint32Array_(T),i=v[0],r=v[1],o=v[2],d=v[3],t=new Int32Array(A),n=new Int32Array(t.length),l,a,f,h,S,x,P,k,B,U,W,G,z,Y,$=this.networkToHostOrderSwap;y<t.length;){for(B=$(t[y]),U=$(t[y+1]),W=$(t[y+2]),G=$(t[y+3]),S=B^E[0],x=G^E[1],P=W^E[2],k=U^E[3],z=4,Y=1;Y<D;Y++)l=u[S>>>24]^e[x>>16&255]^s[P>>8&255]^c[k&255]^E[z],a=u[x>>>24]^e[P>>16&255]^s[k>>8&255]^c[S&255]^E[z+1],f=u[P>>>24]^e[k>>16&255]^s[S>>8&255]^c[x&255]^E[z+2],h=u[k>>>24]^e[S>>16&255]^s[x>>8&255]^c[P&255]^E[z+3],S=l,x=a,P=f,k=h,z=z+4;l=g[S>>>24]<<24^g[x>>16&255]<<16^g[P>>8&255]<<8^g[k&255]^E[z],a=g[x>>>24]<<24^g[P>>16&255]<<16^g[k>>8&255]<<8^g[S&255]^E[z+1],f=g[P>>>24]<<24^g[k>>16&255]<<16^g[S>>8&255]<<8^g[x&255]^E[z+2],h=g[k>>>24]<<24^g[S>>16&255]<<16^g[x>>8&255]<<8^g[P&255]^E[z+3],n[y]=$(l^i),n[y+1]=$(h^r),n[y+2]=$(f^o),n[y+3]=$(a^d),i=B,r=U,o=W,d=G,y=y+4}return n.buffer},C}()},"./src/crypt/decrypter.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return y});var M=m("./src/crypt/aes-crypto.ts"),_=m("./src/crypt/fast-aes-key.ts"),L=m("./src/crypt/aes-decryptor.ts"),C=m("./src/utils/logger.ts"),b=m("./src/utils/mp4-tools.ts"),O=m("./src/utils/typed-array.ts"),A=16,y=function(){function T(E,g,p){var u=p===void 0?{}:p,e=u.removePKCS7Padding,s=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=g,this.removePKCS7Padding=s,s)try{var c=self.crypto;c&&(this.subtle=c.subtle||c.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 g=this.currentResult;if(!g){this.reset();return}var p=new Uint8Array(g);return this.reset(),this.removePKCS7Padding?Object(L.removePadding)(p):p},D.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},D.decrypt=function(g,p,u,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(g),p,u);var s=this.flush();s&&e(s.buffer)}else this.webCryptoDecrypt(new Uint8Array(g),p,u).then(e)},D.softwareDecrypt=function(g,p,u){var e=this.currentIV,s=this.currentResult,c=this.remainderData;this.logOnce("JS AES decrypt"),c&&(g=Object(b.appendUint8Array)(c,g),this.remainderData=null);var v=this.getValidChunk(g);if(!v.length)return null;e&&(u=e);var i=this.softwareDecrypter;i||(i=this.softwareDecrypter=new L.default),i.expandKey(p);var r=s;return this.currentResult=i.decrypt(v.buffer,0,u),this.currentIV=Object(O.sliceUint8)(v,-16).buffer,r||null},D.webCryptoDecrypt=function(g,p,u){var e=this,s=this.subtle;return(this.key!==p||!this.fastAesKey)&&(this.key=p,this.fastAesKey=new _.default(s,p)),this.fastAesKey.expandKey().then(function(c){if(!s)return Promise.reject(new Error("web crypto not initialized"));var v=new M.default(s,u);return v.decrypt(g.buffer,c)}).catch(function(c){return e.onWebCryptoError(c,g,p,u)})},D.onWebCryptoError=function(g,p,u,e){return C.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",g),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(p,u,e)},D.getValidChunk=function(g){var p=g,u=g.length-g.length%A;return u!==g.length&&(p=Object(O.sliceUint8)(g,0,u),this.remainderData=Object(O.sliceUint8)(g,u)),p},D.logOnce=function(g){!this.logEnabled||(C.logger.log("[decrypter.ts]: "+g),this.logEnabled=!1)},T}()},"./src/crypt/fast-aes-key.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return M});var M=function(){function _(C,b){this.subtle=void 0,this.key=void 0,this.subtle=C,this.key=b}var L=_.prototype;return L.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},_}()},"./src/demux/aacdemuxer.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/demux/base-audio-demuxer.ts"),_=m("./src/demux/adts.ts"),L=m("./src/utils/logger.ts"),C=m("./src/demux/id3.ts");function b(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,g){return E.__proto__=g,E},O(y,T)}var A=function(y){b(T,y);function T(E,g){var p;return p=y.call(this)||this,p.observer=void 0,p.config=void 0,p.observer=E,p.config=g,p}var D=T.prototype;return D.resetInitSegment=function(g,p,u,e){y.prototype.resetInitSegment.call(this,g,p,u,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(g){if(!g)return!1;for(var p=C.getID3Data(g,0)||[],u=p.length,e=g.length;u<e;u++)if(_.probe(g,u))return L.logger.log("ADTS sync word found !"),!0;return!1},D.canParse=function(g,p){return _.canParse(g,p)},D.appendFrame=function(g,p,u){_.initTrackConfig(g,this.observer,p,u,g.manifestCodec);var e=_.appendFrame(g,p,u,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},T}(M.default);R.default=A},"./src/demux/adts.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"getAudioConfig",function(){return C}),m.d(R,"isHeaderPattern",function(){return b}),m.d(R,"getHeaderLength",function(){return O}),m.d(R,"getFullFrameLength",function(){return A}),m.d(R,"canGetFrameLength",function(){return y}),m.d(R,"isHeader",function(){return T}),m.d(R,"canParse",function(){return D}),m.d(R,"probe",function(){return E}),m.d(R,"initTrackConfig",function(){return g}),m.d(R,"getFrameDuration",function(){return p}),m.d(R,"parseFrameHeader",function(){return u}),m.d(R,"appendFrame",function(){return e});var M=m("./src/utils/logger.ts"),_=m("./src/errors.ts"),L=m("./src/events.ts");function C(s,c,v,i){var r,o,d,t,n=navigator.userAgent.toLowerCase(),l=i,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=((c[v+2]&192)>>>6)+1;var f=(c[v+2]&60)>>>2;if(f>a.length-1){s.trigger(L.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+f});return}return d=(c[v+2]&1)<<2,d|=(c[v+3]&192)>>>6,M.logger.log("manifest codec:"+i+", ADTS type:"+r+", samplingIndex:"+f),/firefox/i.test(n)?f>=6?(r=5,t=new Array(4),o=f-3):(r=2,t=new Array(2),o=f):n.indexOf("android")!==-1?(r=2,t=new Array(2),o=f):(r=5,t=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&f>=6?o=f-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(f>=6&&d===1||/vivaldi/i.test(n))||!i&&d===1)&&(r=2,t=new Array(2)),o=f)),t[0]=r<<3,t[0]|=(f&14)>>1,t[1]|=(f&1)<<7,t[1]|=d<<3,r===5&&(t[1]|=(o&14)>>1,t[2]=(o&1)<<7,t[2]|=2<<2,t[3]=0),{config:t,samplerate:a[f],channelCount:d,codec:"mp4a.40."+r,manifestCodec:l}}function b(s,c){return s[c]===255&&(s[c+1]&246)===240}function O(s,c){return s[c+1]&1?7:9}function A(s,c){return(s[c+3]&3)<<11|s[c+4]<<3|(s[c+5]&224)>>>5}function y(s,c){return c+5<s.length}function T(s,c){return c+1<s.length&&b(s,c)}function D(s,c){return y(s,c)&&b(s,c)&&A(s,c)<=s.length-c}function E(s,c){if(T(s,c)){var v=O(s,c);if(c+v>=s.length)return!1;var i=A(s,c);if(i<=v)return!1;var r=c+i;return r===s.length||T(s,r)}return!1}function g(s,c,v,i,r){if(!s.samplerate){var o=C(c,v,i,r);if(!o)return;s.config=o.config,s.samplerate=o.samplerate,s.channelCount=o.channelCount,s.codec=o.codec,s.manifestCodec=o.manifestCodec,M.logger.log("parsed codec:"+s.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function p(s){return 1024*9e4/s}function u(s,c){var v=O(s,c);if(c+v<=s.length){var i=A(s,c)-v;if(i>0)return{headerLength:v,frameLength:i}}}function e(s,c,v,i,r){var o=p(s.samplerate),d=i+r*o,t=u(c,v),n;if(t){var l=t.frameLength,a=t.headerLength,f=a+l,h=Math.max(0,v+f-c.length);h?(n=new Uint8Array(f-a),n.set(c.subarray(v+a,c.length),0)):n=c.subarray(v+a,v+f);var S={unit:n,pts:d};return h||s.samples.push(S),{sample:S,length:f,missing:h}}var x=c.length-v;n=new Uint8Array(x),n.set(c.subarray(v,c.length),0);var P={unit:n,pts:d};return{sample:P,length:x,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"initPTSFn",function(){return y});var M=m("./src/polyfills/number.ts"),_=m("./src/demux/id3.ts"),L=m("./src/types/demuxer.ts"),C=m("./src/demux/dummy-demuxed-track.ts"),b=m("./src/utils/mp4-tools.ts"),O=m("./src/utils/typed-array.ts"),A=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(g,p,u,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},D.resetTimeStamp=function(g){this.initPTS=g,this.resetContiguity()},D.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},D.canParse=function(g,p){return!1},D.appendFrame=function(g,p,u){},D.demux=function(g,p){this.cachedData&&(g=Object(b.appendUint8Array)(this.cachedData,g),this.cachedData=null);var u=_.getID3Data(g,0),e=u?u.length:0,s,c,v=this._audioTrack,i=this._id3Track,r=u?_.getTimeStamp(u):void 0,o=g.length;for((this.basePTS===null||this.frameIndex===0&&Object(M.isFiniteNumber)(r))&&(this.basePTS=y(r,p,this.initPTS)),u&&u.length>0&&i.samples.push({pts:this.basePTS,dts:this.basePTS,data:u,type:L.MetadataSchema.audioId3}),c=this.basePTS;e<o;){if(this.canParse(g,e)){var d=this.appendFrame(v,g,e);d?(this.frameIndex++,c=d.sample.pts,e+=d.length,s=e):e=o}else _.canParse(g,e)?(u=_.getID3Data(g,e),i.samples.push({pts:c,dts:c,data:u,type:L.MetadataSchema.audioId3}),e+=u.length,s=e):e++;if(e===o&&s!==o){var t=Object(O.sliceUint8)(g,s);this.cachedData?this.cachedData=Object(b.appendUint8Array)(this.cachedData,t):this.cachedData=t}}return{audioTrack:v,videoTrack:Object(C.dummyTrack)(),id3Track:i,textTrack:Object(C.dummyTrack)()}},D.demuxSampleAes=function(g,p,u){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},D.flush=function(g){var p=this.cachedData;return p&&(this.cachedData=null,this.demux(p,0)),{audioTrack:this._audioTrack,videoTrack:Object(C.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(C.dummyTrack)()}},D.destroy=function(){},T}(),y=function(D,E,g){return Object(M.isFiniteNumber)(D)?D*90:E*9e4+(g||0)};R.default=A},"./src/demux/chunk-cache.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return M});var M=function(){function L(){this.chunks=[],this.dataLength=0}var C=L.prototype;return C.push=function(O){this.chunks.push(O),this.dataLength+=O.length},C.flush=function(){var O=this.chunks,A=this.dataLength,y;if(O.length)O.length===1?y=O[0]:y=_(O,A);else return new Uint8Array(0);return this.reset(),y},C.reset=function(){this.chunks.length=0,this.dataLength=0},L}();function _(L,C){for(var b=new Uint8Array(C),O=0,A=0;A<L.length;A++){var y=L[A];b.set(y,O),O+=y.length}return b}},"./src/demux/dummy-demuxed-track.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"dummyTrack",function(){return M});function M(_,L){return _===void 0&&(_=""),L===void 0&&(L=9e4),{type:_,id:-1,pid:-1,inputTimeScale:L,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/utils/logger.ts"),_=function(){function L(b){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=b,this.bytesAvailable=b.byteLength,this.word=0,this.bitsAvailable=0}var C=L.prototype;return C.loadWord=function(){var O=this.data,A=this.bytesAvailable,y=O.byteLength-A,T=new Uint8Array(4),D=Math.min(4,A);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},C.skipBits=function(O){var A;this.bitsAvailable>O?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,A=O>>3,O-=A>>3,this.bytesAvailable-=A,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},C.readBits=function(O){var A=Math.min(this.bitsAvailable,O),y=this.word>>>32-A;return O>32&&M.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=A,this.bitsAvailable>0?this.word<<=A:this.bytesAvailable>0&&this.loadWord(),A=O-A,A>0&&this.bitsAvailable?y<<A|this.readBits(A):y},C.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()},C.skipUEG=function(){this.skipBits(1+this.skipLZ())},C.skipEG=function(){this.skipBits(1+this.skipLZ())},C.readUEG=function(){var O=this.skipLZ();return this.readBits(O+1)-1},C.readEG=function(){var O=this.readUEG();return 1&O?1+O>>>1:-1*(O>>>1)},C.readBoolean=function(){return this.readBits(1)===1},C.readUByte=function(){return this.readBits(8)},C.readUShort=function(){return this.readBits(16)},C.readUInt=function(){return this.readBits(32)},C.skipScalingList=function(O){for(var A=8,y=8,T,D=0;D<O;D++)y!==0&&(T=this.readEG(),y=(A+T+256)%256),A=y===0?A:y},C.readSPS=function(){var O=0,A=0,y=0,T=0,D,E,g,p=this.readUByte.bind(this),u=this.readBits.bind(this),e=this.readUEG.bind(this),s=this.readBoolean.bind(this),c=this.skipBits.bind(this),v=this.skipEG.bind(this),i=this.skipUEG.bind(this),r=this.skipScalingList.bind(this);p();var o=p();if(u(5),c(3),p(),i(),o===100||o===110||o===122||o===244||o===44||o===83||o===86||o===118||o===128){var d=e();if(d===3&&c(1),i(),i(),c(1),s())for(E=d!==3?8:12,g=0;g<E;g++)s()&&(g<6?r(16):r(64))}i();var t=e();if(t===0)e();else if(t===1)for(c(1),v(),v(),D=e(),g=0;g<D;g++)v();i(),c(1);var n=e(),l=e(),a=u(1);a===0&&c(1),c(1),s()&&(O=e(),A=e(),y=e(),T=e());var f=[1,1];if(s()&&s()){var h=p();switch(h){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((n+1)*16-O*2-A*2),height:(2-a)*(l+1)*16-(a?2:4)*(y+T),pixelRatio:f}},C.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},L}();R.default=_},"./src/demux/id3.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"isHeader",function(){return M}),m.d(R,"isFooter",function(){return _}),m.d(R,"getID3Data",function(){return L}),m.d(R,"canParse",function(){return b}),m.d(R,"getTimeStamp",function(){return O}),m.d(R,"isTimeStampFrame",function(){return A}),m.d(R,"getID3Frames",function(){return T}),m.d(R,"decodeFrame",function(){return D}),m.d(R,"utf8ArrayToStr",function(){return e}),m.d(R,"testables",function(){return s});var M=function(r,o){return o+10<=r.length&&r[o]===73&&r[o+1]===68&&r[o+2]===51&&r[o+3]<255&&r[o+4]<255&&r[o+6]<128&&r[o+7]<128&&r[o+8]<128&&r[o+9]<128},_=function(r,o){return o+10<=r.length&&r[o]===51&&r[o+1]===68&&r[o+2]===73&&r[o+3]<255&&r[o+4]<255&&r[o+6]<128&&r[o+7]<128&&r[o+8]<128&&r[o+9]<128},L=function(r,o){for(var d=o,t=0;M(r,o);){t+=10;var n=C(r,o+6);t+=n,_(r,o+10)&&(t+=10),o+=t}if(t>0)return r.subarray(d,d+t)},C=function(r,o){var d=0;return d=(r[o]&127)<<21,d|=(r[o+1]&127)<<14,d|=(r[o+2]&127)<<7,d|=r[o+3]&127,d},b=function(r,o){return M(r,o)&&C(r,o+6)+10<=r.length-o},O=function(r){for(var o=T(r),d=0;d<o.length;d++){var t=o[d];if(A(t))return u(t)}},A=function(r){return r&&r.key==="PRIV"&&r.info==="com.apple.streaming.transportStreamTimestamp"},y=function(r){var o=String.fromCharCode(r[0],r[1],r[2],r[3]),d=C(r,4),t=10;return{type:o,size:d,data:r.subarray(t,t+d)}},T=function(r){for(var o=0,d=[];M(r,o);){var t=C(r,o+6);o+=10;for(var n=o+t;o+8<n;){var l=y(r.subarray(o)),a=D(l);a&&d.push(a),o+=l.size+10}_(r,o)&&(o+=10)}return d},D=function(r){return r.type==="PRIV"?E(r):r.type[0]==="W"?p(r):g(r)},E=function(r){if(!(r.size<2)){var o=e(r.data,!0),d=new Uint8Array(r.data.subarray(o.length+1));return{key:r.type,info:o,data:d.buffer}}},g=function(r){if(!(r.size<2)){if(r.type==="TXXX"){var o=1,d=e(r.data.subarray(o),!0);o+=d.length+1;var t=e(r.data.subarray(o));return{key:r.type,info:d,data:t}}var n=e(r.data.subarray(1));return{key:r.type,data:n}}},p=function(r){if(r.type==="WXXX"){if(r.size<2)return;var o=1,d=e(r.data.subarray(o),!0);o+=d.length+1;var t=e(r.data.subarray(o));return{key:r.type,info:d,data:t}}var n=e(r.data);return{key:r.type,data:n}},u=function(r){if(r.data.byteLength===8){var o=new Uint8Array(r.data),d=o[3]&1,t=(o[4]<<23)+(o[5]<<15)+(o[6]<<7)+o[7];return t/=45,d&&(t+=4772185884e-2),Math.round(t)}},e=function(r,o){o===void 0&&(o=!1);var d=v();if(d){var t=d.decode(r);if(o){var n=t.indexOf("\0");return n!==-1?t.substring(0,n):t}return t.replace(/\0/g,"")}for(var l=r.length,a,f,h,S="",x=0;x<l;){if(a=r[x++],a===0&&o)return S;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:S+=String.fromCharCode(a);break;case 12:case 13:f=r[x++],S+=String.fromCharCode((a&31)<<6|f&63);break;case 14:f=r[x++],h=r[x++],S+=String.fromCharCode((a&15)<<12|(f&63)<<6|(h&63)<<0);break;default:}}return S},s={decodeTextFrame:g},c;function v(){return!c&&typeof self.TextDecoder!="undefined"&&(c=new self.TextDecoder("utf-8")),c}},"./src/demux/mp3demuxer.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/demux/base-audio-demuxer.ts"),_=m("./src/demux/id3.ts"),L=m("./src/utils/logger.ts"),C=m("./src/demux/mpegaudio.ts");function b(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,g){return E.__proto__=g,E},O(y,T)}var A=function(y){b(T,y);function T(){return y.apply(this,arguments)||this}var D=T.prototype;return D.resetInitSegment=function(g,p,u,e){y.prototype.resetInitSegment.call(this,g,p,u,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(g){if(!g)return!1;for(var p=_.getID3Data(g,0)||[],u=p.length,e=g.length;u<e;u++)if(C.probe(g,u))return L.logger.log("MPEG Audio sync word found !"),!0;return!1},D.canParse=function(g,p){return C.canParse(g,p)},D.appendFrame=function(g,p,u){if(this.basePTS!==null)return C.appendFrame(g,p,u,this.basePTS,this.frameIndex)},T}(M.default);R.default=A},"./src/demux/mp4demuxer.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/polyfills/number.ts"),_=m("./src/types/demuxer.ts"),L=m("./src/utils/mp4-tools.ts"),C=m("./src/demux/dummy-demuxed-track.ts"),b=/\/emsg[-/]ID3/i,O=function(){function A(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=A.prototype;return y.resetTimeStamp=function(){},y.resetInitSegment=function(D,E,g,p){var u=Object(L.parseInitSegment)(D),e=this.videoTrack=Object(C.dummyTrack)("video",1),s=this.audioTrack=Object(C.dummyTrack)("audio",1),c=this.txtTrack=Object(C.dummyTrack)("text",1);if(this.id3Track=Object(C.dummyTrack)("id3",1),this.timeOffset=0,u.video){var v=u.video,i=v.id,r=v.timescale,o=v.codec;e.id=i,e.timescale=c.timescale=r,e.codec=o}if(u.audio){var d=u.audio,t=d.id,n=d.timescale,l=d.codec;s.id=t,s.timescale=n,s.codec=l}c.id=L.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=s.duration=p},y.resetContiguity=function(){},A.probe=function(D){return D=D.length>16384?D.subarray(0,16384):D,Object(L.findBox)(D,["moof"]).length>0},y.demux=function(D,E){this.timeOffset=E;var g=D,p=this.videoTrack,u=this.txtTrack;if(this.config.progressive){this.remainderData&&(g=Object(L.appendUint8Array)(this.remainderData,D));var e=Object(L.segmentValidRange)(g);this.remainderData=e.remainder,p.samples=e.valid||new Uint8Array}else p.samples=g;var s=this.extractID3Track(p,E);return u.samples=Object(L.parseSamples)(E,p),{videoTrack:p,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},y.flush=function(){var D=this.timeOffset,E=this.videoTrack,g=this.txtTrack;E.samples=this.remainderData||new Uint8Array,this.remainderData=null;var p=this.extractID3Track(E,this.timeOffset);return g.samples=Object(L.parseSamples)(D,E),{videoTrack:E,audioTrack:Object(C.dummyTrack)(),id3Track:p,textTrack:Object(C.dummyTrack)()}},y.extractID3Track=function(D,E){var g=this.id3Track;if(D.samples.length){var p=Object(L.findBox)(D.samples,["emsg"]);p&&p.forEach(function(u){var e=Object(L.parseEmsg)(u);if(b.test(e.schemeIdUri)){var s=Object(M.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:E+e.presentationTimeDelta/e.timeScale,c=e.payload;g.samples.push({data:c,len:c.byteLength,dts:s,pts:s,type:_.MetadataSchema.emsg})}})}return g},y.demuxSampleAes=function(D,E,g){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},y.destroy=function(){},A}();R.default=O},"./src/demux/mpegaudio.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"appendFrame",function(){return O}),m.d(R,"parseHeader",function(){return A}),m.d(R,"isHeaderPattern",function(){return y}),m.d(R,"isHeader",function(){return T}),m.d(R,"canParse",function(){return D}),m.d(R,"probe",function(){return E});var M=null,_=[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],L=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],C=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],b=[0,1,1,4];function O(g,p,u,e,s){if(!(u+24>p.length)){var c=A(p,u);if(c&&u+c.frameLength<=p.length){var v=c.samplesPerFrame*9e4/c.sampleRate,i=e+s*v,r={unit:p.subarray(u,u+c.frameLength),pts:i,dts:i};return g.config=[],g.channelCount=c.channelCount,g.samplerate=c.sampleRate,g.samples.push(r),{sample:r,length:c.frameLength,missing:0}}}}function A(g,p){var u=g[p+1]>>3&3,e=g[p+1]>>1&3,s=g[p+2]>>4&15,c=g[p+2]>>2&3;if(u!==1&&s!==0&&s!==15&&c!==3){var v=g[p+2]>>1&1,i=g[p+3]>>6,r=u===3?3-e:e===3?3:4,o=_[r*14+s-1]*1e3,d=u===3?0:u===2?1:2,t=L[d*3+c],n=i===3?1:2,l=C[u][e],a=b[e],f=l*8*a,h=Math.floor(l*o/t+v)*a;if(M===null){var S=navigator.userAgent||"",x=S.match(/Chrome\/(\d+)/i);M=x?parseInt(x[1]):0}var P=!!M&&M<=87;return P&&e===2&&o>=224e3&&i===0&&(g[p+3]=g[p+3]|128),{sampleRate:t,channelCount:n,frameLength:h,samplesPerFrame:f}}}function y(g,p){return g[p]===255&&(g[p+1]&224)===224&&(g[p+1]&6)!==0}function T(g,p){return p+1<g.length&&y(g,p)}function D(g,p){var u=4;return y(g,p)&&u<=g.length-p}function E(g,p){if(p+1<g.length&&y(g,p)){var u=4,e=A(g,p),s=u;e!=null&&e.frameLength&&(s=e.frameLength);var c=p+s;return c===g.length||T(g,c)}return!1}},"./src/demux/sample-aes.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/crypt/decrypter.ts"),_=m("./src/demux/tsdemuxer.ts"),L=function(){function C(O,A,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new M.default(O,A,{removePKCS7Padding:!1})}var b=C.prototype;return b.decryptBuffer=function(A,y){this.decrypter.decrypt(A,this.keyData.key.buffer,this.keyData.iv.buffer,y)},b.decryptAacSample=function(A,y,T,D){var E=A[y].unit;if(!(E.length<=16)){var g=E.subarray(16,E.length-E.length%16),p=g.buffer.slice(g.byteOffset,g.byteOffset+g.length),u=this;this.decryptBuffer(p,function(e){var s=new Uint8Array(e);E.set(s,16),D||u.decryptAacSamples(A,y+1,T)})}},b.decryptAacSamples=function(A,y,T){for(;;y++){if(y>=A.length){T();return}if(!(A[y].unit.length<32)){var D=this.decrypter.isSync();if(this.decryptAacSample(A,y,T,D),!D)return}}},b.getAvcEncryptedData=function(A){for(var y=Math.floor((A.length-48)/160)*16+16,T=new Int8Array(y),D=0,E=32;E<A.length-16;E+=160,D+=16)T.set(A.subarray(E,E+16),D);return T},b.getAvcDecryptedUnit=function(A,y){for(var T=new Uint8Array(y),D=0,E=32;E<A.length-16;E+=160,D+=16)A.set(T.subarray(D,D+16),E);return A},b.decryptAvcSample=function(A,y,T,D,E,g){var p=Object(_.discardEPB)(E.data),u=this.getAvcEncryptedData(p),e=this;this.decryptBuffer(u.buffer,function(s){E.data=e.getAvcDecryptedUnit(p,s),g||e.decryptAvcSamples(A,y,T+1,D)})},b.decryptAvcSamples=function(A,y,T,D){if(A instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,T=0){if(y>=A.length){D();return}for(var E=A[y].units;!(T>=E.length);T++){var g=E[T];if(!(g.data.length<=48||g.type!==1&&g.type!==5)){var p=this.decrypter.isSync();if(this.decryptAvcSample(A,y,T,D,g,p),!p)return}}}},C}();R.default=L},"./src/demux/transmuxer-interface.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return E});var M=m("./node_modules/webworkify-webpack/index.js"),_=m.n(M),L=m("./src/events.ts"),C=m("./src/demux/transmuxer.ts"),b=m("./src/utils/logger.ts"),O=m("./src/errors.ts"),A=m("./src/utils/mediasource-helper.ts"),y=m("./node_modules/eventemitter3/index.js"),T=m.n(y),D=Object(A.getMediaSource)()||{isTypeSupported:function(){return!1}},E=function(){function g(u,e,s,c){var v=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=u,this.id=e,this.onTransmuxComplete=s,this.onFlush=c;var i=u.config,r=function(l,a){a=a||{},a.frag=v.frag,a.id=v.id,u.trigger(l,a)};this.observer=new y.EventEmitter,this.observer.on(L.Events.FRAG_DECRYPTED,r),this.observer.on(L.Events.ERROR,r);var o={mp4:D.isTypeSupported("video/mp4"),mpeg:D.isTypeSupported("audio/mpeg"),mp3:D.isTypeSupported('audio/mp4; codecs="mp3"')},d=navigator.vendor;if(i.enableWorker&&typeof Worker!="undefined"){b.logger.log("demuxing in webworker");var t;try{t=this.worker=M("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),t.addEventListener("message",this.onwmsg),t.onerror=function(n){u.trigger(L.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(n.message+" ("+n.filename+":"+n.lineno+")")})},t.postMessage({cmd:"init",typeSupported:o,vendor:d,id:e,config:JSON.stringify(i)})}catch(n){b.logger.warn("Error in worker:",n),b.logger.error("Error while initializing DemuxerWorker, fallback to inline"),t&&self.URL.revokeObjectURL(t.objectURL),this.transmuxer=new C.default(this.observer,o,i,d,e),this.worker=null}}else this.transmuxer=new C.default(this.observer,o,i,d,e)}var p=g.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 s=this.transmuxer;s&&(s.destroy(),this.transmuxer=null)}var c=this.observer;c&&c.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},p.push=function(e,s,c,v,i,r,o,d,t,n){var l,a,f=this;t.transmuxing.start=self.performance.now();var h=this.transmuxer,S=this.worker,x=r?r.start:i.start,P=i.decryptdata,k=this.frag,B=!(k&&i.cc===k.cc),U=!(k&&t.level===k.level),W=k?t.sn-k.sn:-1,G=this.part?t.part-this.part.index:-1,z=W===0&&t.id>1&&t.id===(k==null?void 0:k.stats.chunkCount),Y=!U&&(W===1||W===0&&(G===1||z&&G<=0)),$=self.performance.now();(U||W||i.stats.parsing.start===0)&&(i.stats.parsing.start=$),r&&(G||!Y)&&(r.stats.parsing.start=$);var Z=!(k&&((l=i.initSegment)===null||l===void 0?void 0:l.url)===((a=k.initSegment)===null||a===void 0?void 0:a.url)),q=new C.TransmuxState(B,Y,d,U,x,Z);if(!Y||B||Z){b.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+t.sn+" p: "+t.part+" level: "+t.level+" id: "+t.id+`
14
- discontinuity: `+B+`
15
- trackSwitch: `+U+`
16
- contiguous: `+Y+`
17
- accurateTimeOffset: `+d+`
18
- timeOffset: `+x+`
19
- initSegmentChange: `+Z);var ie=new C.TransmuxConfig(c,v,s,o,n);this.configureTransmuxer(ie)}if(this.frag=i,this.part=r,S)S.postMessage({cmd:"demux",data:e,decryptdata:P,chunkMeta:t,state:q},e instanceof ArrayBuffer?[e]:[]);else if(h){var ne=h.push(e,P,t,q);Object(C.isPromise)(ne)?ne.then(function(ae){f.handleTransmuxComplete(ae)}):this.handleTransmuxComplete(ne)}},p.flush=function(e){var s=this;e.transmuxing.start=self.performance.now();var c=this.transmuxer,v=this.worker;if(v)v.postMessage({cmd:"flush",chunkMeta:e});else if(c){var i=c.flush(e);Object(C.isPromise)(i)?i.then(function(r){s.handleFlushResult(r,e)}):this.handleFlushResult(i,e)}},p.handleFlushResult=function(e,s){var c=this;e.forEach(function(v){c.handleTransmuxComplete(v)}),this.onFlush(s)},p.onWorkerMessage=function(e){var s=e.data,c=this.hls;switch(s.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(s.data);break}case"flush":{this.onFlush(s.data);break}case"workerLog":b.logger[s.data.logType]&&b.logger[s.data.logType](s.data.message);break;default:{s.data=s.data||{},s.data.frag=this.frag,s.data.id=this.id,c.trigger(s.event,s.data);break}}},p.configureTransmuxer=function(e){var s=this.worker,c=this.transmuxer;s?s.postMessage({cmd:"configure",config:e}):c&&c.configure(e)},p.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},g}()},"./src/demux/transmuxer-worker.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return O});var M=m("./src/demux/transmuxer.ts"),_=m("./src/events.ts"),L=m("./src/utils/logger.ts"),C=m("./node_modules/eventemitter3/index.js"),b=m.n(C);function O(E){var g=new C.EventEmitter,p=function(s,c){E.postMessage({event:s,data:c})};g.on(_.Events.FRAG_DECRYPTED,p),g.on(_.Events.ERROR,p);var u=function(){var s=function(i){var r=function(d){p("workerLog",{logType:i,message:d})};L.logger[i]=r};for(var c in L.logger)s(c)};E.addEventListener("message",function(e){var s=e.data;switch(s.cmd){case"init":{var c=JSON.parse(s.config);E.transmuxer=new M.default(g,s.typeSupported,c,s.vendor,s.id),Object(L.enableLogs)(c.debug),u(),p("init",null);break}case"configure":{E.transmuxer.configure(s.config);break}case"demux":{var v=E.transmuxer.push(s.data,s.decryptdata,s.chunkMeta,s.state);Object(M.isPromise)(v)?v.then(function(o){A(E,o)}):A(E,v);break}case"flush":{var i=s.chunkMeta,r=E.transmuxer.flush(i);Object(M.isPromise)(r)?r.then(function(o){T(E,o,i)}):T(E,r,i);break}default:break}})}function A(E,g){if(D(g.remuxResult))return!1;var p=[],u=g.remuxResult,e=u.audio,s=u.video;return e&&y(p,e),s&&y(p,s),E.postMessage({event:"transmuxComplete",data:g},p),!0}function y(E,g){g.data1&&E.push(g.data1.buffer),g.data2&&E.push(g.data2.buffer)}function T(E,g,p){var u=g.reduce(function(e,s){return A(E,s)||e},!1);u||E.postMessage({event:"transmuxComplete",data:g[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(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return p}),m.d(R,"isPromise",function(){return s}),m.d(R,"TransmuxConfig",function(){return c}),m.d(R,"TransmuxState",function(){return v});var M=m("./src/events.ts"),_=m("./src/errors.ts"),L=m("./src/crypt/decrypter.ts"),C=m("./src/demux/aacdemuxer.ts"),b=m("./src/demux/mp4demuxer.ts"),O=m("./src/demux/tsdemuxer.ts"),A=m("./src/demux/mp3demuxer.ts"),y=m("./src/remux/mp4-remuxer.ts"),T=m("./src/remux/passthrough-remuxer.ts"),D=m("./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 g=[{demux:O.default,remux:y.default},{demux:b.default,remux:T.default},{demux:C.default,remux:y.default},{demux:A.default,remux:y.default}],p=function(){function i(o,d,t,n,l){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=o,this.typeSupported=d,this.config=t,this.vendor=n,this.id=l}var r=i.prototype;return r.configure=function(d){this.transmuxConfig=d,this.decrypter&&this.decrypter.reset()},r.push=function(d,t,n,l){var a=this,f=n.transmuxing;f.executeStart=E();var h=new Uint8Array(d),S=this.config,x=this.currentTransmuxState,P=this.transmuxConfig;l&&(this.currentTransmuxState=l);var k=l||x,B=k.contiguous,U=k.discontinuity,W=k.trackSwitch,G=k.accurateTimeOffset,z=k.timeOffset,Y=k.initSegmentChange,$=P.audioCodec,Z=P.videoCodec,q=P.defaultInitPts,ie=P.duration,ne=P.initSegmentData;(U||W||Y)&&this.resetInitSegment(ne,$,Z,ie),(U||Y)&&this.resetInitialTimestamp(q),B||this.resetContiguity();var ae=u(h,t);if(ae&&ae.method==="AES-128"){var te=this.getDecrypter();if(S.enableSoftwareAES){var fe=te.softwareDecrypt(h,ae.key.buffer,ae.iv.buffer);if(!fe)return f.executeEnd=E(),e(n);h=new Uint8Array(fe)}else return this.decryptionPromise=te.webCryptoDecrypt(h,ae.key.buffer,ae.iv.buffer).then(function(Ee){var me=a.push(Ee,null,n);return a.decryptionPromise=null,me}),this.decryptionPromise}this.needsProbing(h,U,W)&&this.configureTransmuxer(h,P);var de=this.transmux(h,ae,z,G,n),re=this.currentTransmuxState;return re.contiguous=!0,re.discontinuity=!1,re.trackSwitch=!1,f.executeEnd=E(),de},r.flush=function(d){var t=this,n=d.transmuxing;n.executeStart=E();var l=this.decrypter,a=this.currentTransmuxState,f=this.decryptionPromise;if(f)return f.then(function(){return t.flush(d)});var h=[],S=a.timeOffset;if(l){var x=l.flush();x&&h.push(this.push(x,null,d))}var P=this.demuxer,k=this.remuxer;if(!P||!k)return this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),n.executeEnd=E(),[e(d)];var B=P.flush(S);return s(B)?B.then(function(U){return t.flushRemux(h,U,d),h}):(this.flushRemux(h,B,d),h)},r.flushRemux=function(d,t,n){var l=t.audioTrack,a=t.videoTrack,f=t.id3Track,h=t.textTrack,S=this.currentTransmuxState,x=S.accurateTimeOffset,P=S.timeOffset;D.logger.log("[transmuxer.ts]: Flushed fragment "+n.sn+(n.part>-1?" p: "+n.part:"")+" of level "+n.level);var k=this.remuxer.remux(l,a,f,h,P,x,!0,this.id);d.push({remuxResult:k,chunkMeta:n}),n.transmuxing.executeEnd=E()},r.resetInitialTimestamp=function(d){var t=this.demuxer,n=this.remuxer;!t||!n||(t.resetTimeStamp(d),n.resetTimeStamp(d))},r.resetContiguity=function(){var d=this.demuxer,t=this.remuxer;!d||!t||(d.resetContiguity(),t.resetNextTimestamp())},r.resetInitSegment=function(d,t,n,l){var a=this.demuxer,f=this.remuxer;!a||!f||(a.resetInitSegment(d,t,n,l),f.resetInitSegment(d,t,n))},r.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},r.transmux=function(d,t,n,l,a){var f;return t&&t.method==="SAMPLE-AES"?f=this.transmuxSampleAes(d,t,n,l,a):f=this.transmuxUnencrypted(d,n,l,a),f},r.transmuxUnencrypted=function(d,t,n,l){var a=this.demuxer.demux(d,t,!1,!this.config.progressive),f=a.audioTrack,h=a.videoTrack,S=a.id3Track,x=a.textTrack,P=this.remuxer.remux(f,h,S,x,t,n,!1,this.id);return{remuxResult:P,chunkMeta:l}},r.transmuxSampleAes=function(d,t,n,l,a){var f=this;return this.demuxer.demuxSampleAes(d,t,n).then(function(h){var S=f.remuxer.remux(h.audioTrack,h.videoTrack,h.id3Track,h.textTrack,n,l,!1,f.id);return{remuxResult:S,chunkMeta:a}})},r.configureTransmuxer=function(d,t){for(var n=this.config,l=this.observer,a=this.typeSupported,f=this.vendor,h=t.audioCodec,S=t.defaultInitPts,x=t.duration,P=t.initSegmentData,k=t.videoCodec,B,U=0,W=g.length;U<W;U++)if(g[U].demux.probe(d)){B=g[U];break}B||(D.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),B={demux:b.default,remux:T.default});var G=this.demuxer,z=this.remuxer,Y=B.remux,$=B.demux;(!z||!(z instanceof Y))&&(this.remuxer=new Y(l,n,a,f)),(!G||!(G instanceof $))&&(this.demuxer=new $(l,n,a),this.probe=$.probe),this.resetInitSegment(P,h,k,x),this.resetInitialTimestamp(S)},r.needsProbing=function(d,t,n){return!this.demuxer||!this.remuxer||t||n},r.getDecrypter=function(){var d=this.decrypter;return d||(d=this.decrypter=new L.default(this.observer,this.config)),d},i}();function u(i,r){var o=null;return i.byteLength>0&&r!=null&&r.key!=null&&r.iv!==null&&r.method!=null&&(o=r),o}var e=function(r){return{remuxResult:{},chunkMeta:r}};function s(i){return"then"in i&&i.then instanceof Function}var c=function(r,o,d,t,n){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=o,this.initSegmentData=d,this.duration=t,this.defaultInitPts=n},v=function(r,o,d,t,n,l){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=o,this.accurateTimeOffset=d,this.trackSwitch=t,this.timeOffset=n,this.initSegmentChange=l}},"./src/demux/tsdemuxer.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"discardEPB",function(){return c});var M=m("./src/demux/adts.ts"),_=m("./src/demux/mpegaudio.ts"),L=m("./src/demux/exp-golomb.ts"),C=m("./src/demux/sample-aes.ts"),b=m("./src/events.ts"),O=m("./src/utils/mp4-tools.ts"),A=m("./src/utils/logger.ts"),y=m("./src/errors.ts"),T=m("./src/types/demuxer.ts");function D(){return D=Object.assign?Object.assign.bind():function(v){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(v[o]=r[o])}return v},D.apply(this,arguments)}var E=function(){function v(r,o,d){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=o,this.typeSupported=d}v.probe=function(o){return o[0]===71&&o[188]===71},v.createTrack=function(o,d){return{container:o==="video"||o==="audio"?"video/mp2t":void 0,type:o,id:O.RemuxerTrackIdConfig[o],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:o==="audio"?d:void 0}};var i=v.prototype;return i.resetInitSegment=function(o,d,t,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=v.createTrack("video"),this._audioTrack=v.createTrack("audio",n),this._id3Track=v.createTrack("id3"),this._txtTrack=v.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=d,this.videoCodec=t,this._duration=n},i.resetTimeStamp=function(){},i.resetContiguity=function(){var o=this._audioTrack,d=this._avcTrack,t=this._id3Track;o&&(o.pesData=null),d&&(d.pesData=null),t&&(t.pesData=null),this.aacOverFlow=null},i.demux=function(o,d,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1),t||(this.sampleAes=null);var l,a=this._avcTrack,f=this._audioTrack,h=this._id3Track,S=this._txtTrack,x=a.pid,P=a.pesData,k=f.pid,B=h.pid,U=f.pesData,W=h.pesData,G=null,z=this.pmtParsed,Y=this._pmtId,$=o.length;if(this.remainderData&&(o=Object(O.appendUint8Array)(this.remainderData,o),$=o.length,this.remainderData=null),$<188&&!n)return this.remainderData=o,{audioTrack:f,videoTrack:a,id3Track:h,textTrack:S};$-=$%188,$<o.byteLength&&!n&&(this.remainderData=new Uint8Array(o.buffer,$,o.buffer.byteLength-$));for(var Z=0,q=0;q<$;q+=188)if(o[q]===71){var ie=!!(o[q+1]&64),ne=((o[q+1]&31)<<8)+o[q+2],ae=(o[q+3]&48)>>4,te=void 0;if(ae>1){if(te=q+5+o[q+4],te===q+188)continue}else te=q+4;switch(ne){case x:ie&&(P&&(l=e(P))&&this.parseAVCPES(a,S,l,!1),P={data:[],size:0}),P&&(P.data.push(o.subarray(te,q+188)),P.size+=q+188-te);break;case k:if(ie){if(U&&(l=e(U)))switch(f.segmentCodec){case"aac":this.parseAACPES(f,l);break;case"mp3":this.parseMPEGPES(f,l);break}U={data:[],size:0}}U&&(U.data.push(o.subarray(te,q+188)),U.size+=q+188-te);break;case B:ie&&(W&&(l=e(W))&&this.parseID3PES(h,l),W={data:[],size:0}),W&&(W.data.push(o.subarray(te,q+188)),W.size+=q+188-te);break;case 0:ie&&(te+=o[te]+1),Y=this._pmtId=p(o,te);break;case Y:{ie&&(te+=o[te]+1);var fe=u(o,te,this.typeSupported,t);x=fe.avc,x>0&&(a.pid=x),k=fe.audio,k>0&&(f.pid=k,f.segmentCodec=fe.segmentCodec),B=fe.id3,B>0&&(h.pid=B),G!==null&&!z&&(A.logger.log("unknown PID '"+G+"' in TS found"),G=null),z=this.pmtParsed=!0;break}case 17:case 8191:break;default:G=ne;break}}else Z++;Z>0&&this.observer.emit(b.Events.ERROR,b.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+Z+" TS packet/s that do not start with 0x47"}),a.pesData=P,f.pesData=U,h.pesData=W;var de={audioTrack:f,videoTrack:a,id3Track:h,textTrack:S};return n&&this.extractRemainingSamples(de),de},i.flush=function(){var o=this.remainderData;this.remainderData=null;var d;return o?d=this.demux(o,-1,!1,!0):d={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(d),this.sampleAes?this.decrypt(d,this.sampleAes):d},i.extractRemainingSamples=function(o){var d=o.audioTrack,t=o.videoTrack,n=o.id3Track,l=o.textTrack,a=t.pesData,f=d.pesData,h=n.pesData,S;if(a&&(S=e(a))?(this.parseAVCPES(t,l,S,!0),t.pesData=null):t.pesData=a,f&&(S=e(f))){switch(d.segmentCodec){case"aac":this.parseAACPES(d,S);break;case"mp3":this.parseMPEGPES(d,S);break}d.pesData=null}else f!=null&&f.size&&A.logger.log("last AAC PES packet truncated,might overlap between fragments"),d.pesData=f;h&&(S=e(h))?(this.parseID3PES(n,S),n.pesData=null):n.pesData=h},i.demuxSampleAes=function(o,d,t){var n=this.demux(o,t,!0,!this.config.progressive),l=this.sampleAes=new C.default(this.observer,this.config,d);return this.decrypt(n,l)},i.decrypt=function(o,d){return new Promise(function(t){var n=o.audioTrack,l=o.videoTrack;n.samples&&n.segmentCodec==="aac"?d.decryptAacSamples(n.samples,0,function(){l.samples?d.decryptAvcSamples(l.samples,0,0,function(){t(o)}):t(o)}):l.samples&&d.decryptAvcSamples(l.samples,0,0,function(){t(o)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(o,d,t,n){var l=this,a=this.parseAVCNALu(o,t.data),f=!1,h=this.avcSample,S,x=!1;t.data=null,h&&a.length&&!o.audFound&&(s(h,o),h=this.avcSample=g(!1,t.pts,t.dts,"")),a.forEach(function(P){switch(P.type){case 1:{S=!0,h||(h=l.avcSample=g(!0,t.pts,t.dts,"")),f&&(h.debug+="NDR "),h.frame=!0;var k=P.data;if(x&&k.length>4){var B=new L.default(k).readSliceType();(B===2||B===4||B===7||B===9)&&(h.key=!0)}break}case 5:S=!0,h||(h=l.avcSample=g(!0,t.pts,t.dts,"")),f&&(h.debug+="IDR "),h.key=!0,h.frame=!0;break;case 6:{S=!0,f&&h&&(h.debug+="SEI "),Object(O.parseSEIMessageFromNALu)(c(P.data),t.pts,d.samples);break}case 7:if(S=!0,x=!0,f&&h&&(h.debug+="SPS "),!o.sps){var U=new L.default(P.data),W=U.readSPS();o.width=W.width,o.height=W.height,o.pixelRatio=W.pixelRatio,o.sps=[P.data],o.duration=l._duration;for(var G=P.data.subarray(1,4),z="avc1.",Y=0;Y<3;Y++){var $=G[Y].toString(16);$.length<2&&($="0"+$),z+=$}o.codec=z}break;case 8:S=!0,f&&h&&(h.debug+="PPS "),o.pps||(o.pps=[P.data]);break;case 9:S=!1,o.audFound=!0,h&&s(h,o),h=l.avcSample=g(!1,t.pts,t.dts,f?"AUD ":"");break;case 12:S=!0;break;default:S=!1,h&&(h.debug+="unknown NAL "+P.type+" ");break}if(h&&S){var Z=h.units;Z.push(P)}}),n&&h&&(s(h,o),this.avcSample=null)},i.getLastNalUnit=function(o){var d,t=this.avcSample,n;if((!t||t.units.length===0)&&(t=o[o.length-1]),(d=t)!==null&&d!==void 0&&d.units){var l=t.units;n=l[l.length-1]}return n},i.parseAVCNALu=function(o,d){var t=d.byteLength,n=o.naluState||0,l=n,a=[],f=0,h,S,x,P=-1,k=0;for(n===-1&&(P=0,k=d[0]&31,n=0,f=1);f<t;){if(h=d[f++],!n){n=h?0:1;continue}if(n===1){n=h?0:2;continue}if(!h)n=3;else if(h===1){if(P>=0){var B={data:d.subarray(P,f-n-1),type:k};a.push(B)}else{var U=this.getLastNalUnit(o.samples);if(U&&(l&&f<=4-l&&U.state&&(U.data=U.data.subarray(0,U.data.byteLength-l)),S=f-n-1,S>0)){var W=new Uint8Array(U.data.byteLength+S);W.set(U.data,0),W.set(d.subarray(0,S),U.data.byteLength),U.data=W,U.state=0}}f<t?(x=d[f]&31,P=f,k=x,n=0):n=-1}else n=0}if(P>=0&&n>=0){var G={data:d.subarray(P,t),type:k,state:n};a.push(G)}if(a.length===0){var z=this.getLastNalUnit(o.samples);if(z){var Y=new Uint8Array(z.data.byteLength+d.byteLength);Y.set(z.data,0),Y.set(d,z.data.byteLength),z.data=Y}}return o.naluState=n,a},i.parseAACPES=function(o,d){var t=0,n=this.aacOverFlow,l=d.data;if(n){this.aacOverFlow=null;var a=n.missing,f=n.sample.unit.byteLength;if(a===-1){var h=new Uint8Array(f+l.byteLength);h.set(n.sample.unit,0),h.set(l,f),l=h}else{var S=f-a;n.sample.unit.set(l.subarray(0,a),S),o.samples.push(n.sample),t=n.missing}}var x,P;for(x=t,P=l.length;x<P-1&&!M.isHeader(l,x);x++);if(x!==t){var k,B;if(x<P-1?(k="AAC PES did not start with ADTS header,offset:"+x,B=!1):(k="no ADTS header found in AAC PES",B=!0),A.logger.warn("parsing error:"+k),this.observer.emit(b.Events.ERROR,b.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:B,reason:k}),B)return}M.initTrackConfig(o,this.observer,l,x,this.audioCodec);var U;if(d.pts!==void 0)U=d.pts;else if(n){var W=M.getFrameDuration(o.samplerate);U=n.sample.pts+W}else{A.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var G=0,z;x<P;)if(z=M.appendFrame(o,l,x,U,G),x+=z.length,z.missing){this.aacOverFlow=z;break}else for(G++;x<P-1&&!M.isHeader(l,x);x++);},i.parseMPEGPES=function(o,d){var t=d.data,n=t.length,l=0,a=0,f=d.pts;if(f===void 0){A.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<n;)if(_.isHeader(t,a)){var h=_.appendFrame(o,t,a,f,l);if(h)a+=h.length,l++;else break}else a++},i.parseID3PES=function(o,d){if(d.pts===void 0){A.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var t=D({},d,{type:this._avcTrack?T.MetadataSchema.emsg:T.MetadataSchema.audioId3});o.samples.push(t)},v}();function g(v,i,r,o){return{key:v,frame:!1,pts:i,dts:r,units:[],debug:o,length:0}}function p(v,i){return(v[i+10]&31)<<8|v[i+11]}function u(v,i,r,o){var d={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},t=(v[i+1]&15)<<8|v[i+2],n=i+3+t-4,l=(v[i+10]&15)<<8|v[i+11];for(i+=12+l;i<n;){var a=(v[i+1]&31)<<8|v[i+2];switch(v[i]){case 207:if(!o){A.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:d.audio===-1&&(d.audio=a);break;case 21:d.id3===-1&&(d.id3=a);break;case 219:if(!o){A.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:d.avc===-1&&(d.avc=a);break;case 3:case 4:r.mpeg!==!0&&r.mp3!==!0?A.logger.log("MPEG audio found, not supported in this browser"):d.audio===-1&&(d.audio=a,d.segmentCodec="mp3");break;case 36:A.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((v[i+3]&15)<<8|v[i+4])+5}return d}function e(v){var i=0,r,o,d,t,n,l=v.data;if(!v||v.size===0)return null;for(;l[0].length<19&&l.length>1;){var a=new Uint8Array(l[0].length+l[1].length);a.set(l[0]),a.set(l[1],l[0].length),l[0]=a,l.splice(1,1)}r=l[0];var f=(r[0]<<16)+(r[1]<<8)+r[2];if(f===1){if(o=(r[4]<<8)+r[5],o&&o>v.size-6)return null;var h=r[7];h&192&&(t=(r[9]&14)*536870912+(r[10]&255)*4194304+(r[11]&254)*16384+(r[12]&255)*128+(r[13]&254)/2,h&64?(n=(r[14]&14)*536870912+(r[15]&255)*4194304+(r[16]&254)*16384+(r[17]&255)*128+(r[18]&254)/2,t-n>60*9e4&&(A.logger.warn(Math.round((t-n)/9e4)+"s delta between PTS and DTS, align them"),t=n)):n=t),d=r[8];var S=d+9;if(v.size<=S)return null;v.size-=S;for(var x=new Uint8Array(v.size),P=0,k=l.length;P<k;P++){r=l[P];var B=r.byteLength;if(S)if(S>B){S-=B;continue}else r=r.subarray(S),B-=S,S=0;x.set(r,i),i+=B}return o&&(o-=d+3),{data:x,pts:t,dts:n,len:o}}return null}function s(v,i){if(v.units.length&&v.frame){if(v.pts===void 0){var r=i.samples,o=r.length;if(o){var d=r[o-1];v.pts=d.pts,v.dts=d.dts}else{i.dropped++;return}}i.samples.push(v)}v.debug.length&&A.logger.log(v.pts+"/"+v.dts+":"+v.debug)}function c(v){for(var i=v.byteLength,r=[],o=1;o<i-2;)v[o]===0&&v[o+1]===0&&v[o+2]===3?(r.push(o+2),o+=2):o++;if(r.length===0)return v;var d=i-r.length,t=new Uint8Array(d),n=0;for(o=0;o<d;n++,o++)n===r[0]&&(n++,r.shift()),t[o]=v[n];return t}R.default=E},"./src/errors.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"ErrorTypes",function(){return M}),m.d(R,"ErrorDetails",function(){return _});var M;(function(L){L.NETWORK_ERROR="networkError",L.MEDIA_ERROR="mediaError",L.KEY_SYSTEM_ERROR="keySystemError",L.MUX_ERROR="muxError",L.OTHER_ERROR="otherError"})(M||(M={}));var _;(function(L){L.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",L.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",L.KEY_SYSTEM_NO_SESSION="keySystemNoSession",L.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",L.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",L.MANIFEST_LOAD_ERROR="manifestLoadError",L.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",L.MANIFEST_PARSING_ERROR="manifestParsingError",L.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",L.LEVEL_EMPTY_ERROR="levelEmptyError",L.LEVEL_LOAD_ERROR="levelLoadError",L.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",L.LEVEL_SWITCH_ERROR="levelSwitchError",L.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",L.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",L.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",L.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",L.FRAG_LOAD_ERROR="fragLoadError",L.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",L.FRAG_DECRYPT_ERROR="fragDecryptError",L.FRAG_PARSING_ERROR="fragParsingError",L.REMUX_ALLOC_ERROR="remuxAllocError",L.KEY_LOAD_ERROR="keyLoadError",L.KEY_LOAD_TIMEOUT="keyLoadTimeOut",L.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",L.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",L.BUFFER_APPEND_ERROR="bufferAppendError",L.BUFFER_APPENDING_ERROR="bufferAppendingError",L.BUFFER_STALLED_ERROR="bufferStalledError",L.BUFFER_FULL_ERROR="bufferFullError",L.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",L.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",L.INTERNAL_EXCEPTION="internalException",L.INTERNAL_ABORTED="aborted",L.UNKNOWN="unknown"})(_||(_={}))},"./src/events.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"Events",function(){return M});var M;(function(_){_.MEDIA_ATTACHING="hlsMediaAttaching",_.MEDIA_ATTACHED="hlsMediaAttached",_.MEDIA_DETACHING="hlsMediaDetaching",_.MEDIA_DETACHED="hlsMediaDetached",_.BUFFER_RESET="hlsBufferReset",_.BUFFER_CODECS="hlsBufferCodecs",_.BUFFER_CREATED="hlsBufferCreated",_.BUFFER_APPENDING="hlsBufferAppending",_.BUFFER_APPENDED="hlsBufferAppended",_.BUFFER_EOS="hlsBufferEos",_.BUFFER_FLUSHING="hlsBufferFlushing",_.BUFFER_FLUSHED="hlsBufferFlushed",_.MANIFEST_LOADING="hlsManifestLoading",_.MANIFEST_LOADED="hlsManifestLoaded",_.MANIFEST_PARSED="hlsManifestParsed",_.LEVEL_SWITCHING="hlsLevelSwitching",_.LEVEL_SWITCHED="hlsLevelSwitched",_.LEVEL_LOADING="hlsLevelLoading",_.LEVEL_LOADED="hlsLevelLoaded",_.LEVEL_UPDATED="hlsLevelUpdated",_.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",_.LEVELS_UPDATED="hlsLevelsUpdated",_.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",_.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",_.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",_.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",_.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",_.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",_.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",_.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",_.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",_.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",_.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",_.CUES_PARSED="hlsCuesParsed",_.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",_.INIT_PTS_FOUND="hlsInitPtsFound",_.FRAG_LOADING="hlsFragLoading",_.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",_.FRAG_LOADED="hlsFragLoaded",_.FRAG_DECRYPTED="hlsFragDecrypted",_.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",_.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",_.FRAG_PARSING_METADATA="hlsFragParsingMetadata",_.FRAG_PARSED="hlsFragParsed",_.FRAG_BUFFERED="hlsFragBuffered",_.FRAG_CHANGED="hlsFragChanged",_.FPS_DROP="hlsFpsDrop",_.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",_.ERROR="hlsError",_.DESTROYING="hlsDestroying",_.KEY_LOADING="hlsKeyLoading",_.KEY_LOADED="hlsKeyLoaded",_.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",_.BACK_BUFFER_REACHED="hlsBackBufferReached"})(M||(M={}))},"./src/hls.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return i});var M=m("./node_modules/url-toolkit/src/url-toolkit.js"),_=m.n(M),L=m("./src/loader/playlist-loader.ts"),C=m("./src/loader/key-loader.ts"),b=m("./src/controller/id3-track-controller.ts"),O=m("./src/controller/latency-controller.ts"),A=m("./src/controller/level-controller.ts"),y=m("./src/controller/fragment-tracker.ts"),T=m("./src/controller/stream-controller.ts"),D=m("./src/is-supported.ts"),E=m("./src/utils/logger.ts"),g=m("./src/config.ts"),p=m("./node_modules/eventemitter3/index.js"),u=m.n(p),e=m("./src/events.ts"),s=m("./src/errors.ts");function c(r,o){for(var d=0;d<o.length;d++){var t=o[d];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,t.key,t)}}function v(r,o,d){return o&&c(r.prototype,o),d&&c(r,d),Object.defineProperty(r,"prototype",{writable:!1}),r}var i=function(){r.isSupported=function(){return Object(D.isSupported)()};function r(d){d===void 0&&(d={}),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(g.mergeConfig)(r.DefaultConfig,d);this.userConfig=d,Object(E.enableLogs)(t.debug),this._autoLevelCapping=-1,t.progressive&&Object(g.enableStreamingMode)(t);var n=t.abrController,l=t.bufferController,a=t.capLevelController,f=t.fpsController,h=this.abrController=new n(this),S=this.bufferController=new l(this),x=this.capLevelController=new a(this),P=new f(this),k=new L.default(this),B=new C.default(this),U=new b.default(this),W=this.levelController=new A.default(this),G=new y.FragmentTracker(this),z=this.streamController=new T.default(this,G);x.setStreamController(z),P.setStreamController(z);var Y=[k,B,W,z];this.networkControllers=Y;var $=[h,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,$),this.emeController=this.createController(t.emeController,null,$),this.cmcdController=this.createController(t.cmcdController,null,$),this.latencyController=this.createController(O.default,null,$),this.coreComponents=$}var o=r.prototype;return o.createController=function(t,n,l){if(t){var a=n?new t(this,n):new t(this);return l&&l.push(a),a}return null},o.on=function(t,n,l){l===void 0&&(l=this),this._emitter.on(t,n,l)},o.once=function(t,n,l){l===void 0&&(l=this),this._emitter.once(t,n,l)},o.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},o.off=function(t,n,l,a){l===void 0&&(l=this),this._emitter.off(t,n,l,a)},o.listeners=function(t){return this._emitter.listeners(t)},o.emit=function(t,n,l){return this._emitter.emit(t,n,l)},o.trigger=function(t,n){if(this.config.debug)return this.emit(t,t,n);try{return this.emit(t,t,n)}catch(l){E.logger.error("An internal error happened while handling event "+t+'. Error message: "'+l.message+'". Here is a stacktrace:',l),this.trigger(e.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:l})}return!1},o.listenerCount=function(t){return this._emitter.listenerCount(t)},o.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},o.attachMedia=function(t){E.logger.log("attachMedia"),this._media=t,this.trigger(e.Events.MEDIA_ATTACHING,{media:t})},o.detachMedia=function(){E.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},o.loadSource=function(t){this.stopLoad();var n=this.media,l=this.url,a=this.url=M.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});E.logger.log("loadSource:"+a),n&&l&&l!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(n)),this.trigger(e.Events.MANIFEST_LOADING,{url:t})},o.startLoad=function(t){t===void 0&&(t=-1),E.logger.log("startLoad("+t+")"),this.networkControllers.forEach(function(n){n.startLoad(t)})},o.stopLoad=function(){E.logger.log("stopLoad"),this.networkControllers.forEach(function(t){t.stopLoad()})},o.swapAudioCodec=function(){E.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},o.recoverMediaError=function(){E.logger.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},o.removeLevel=function(t,n){n===void 0&&(n=0),this.levelController.removeLevel(t,n)},v(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 n=!!t;n!==this.config.capLevelToPlayerSize&&(n?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=n)}},{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,n=this.config.minAutoBitrate;if(!t)return 0;for(var l=t.length,a=0;a<l;a++)if(t[a].maxBitrate>=n)return a;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,n=this.autoLevelCapping,l;return n===-1&&t&&t.length?l=t.length-1:l=n,l}},{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 n=this.audioTrackController;n&&(n.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 n=this.subtitleTrackController;n&&(n.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 n=this.subtitleTrackController;n&&(n.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 s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return r.defaultConfig?r.defaultConfig:g.hlsDefaultConfig},set:function(t){r.defaultConfig=t}}]),r}();i.defaultConfig=void 0},"./src/is-supported.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"isSupported",function(){return L}),m.d(R,"changeTypeSupported",function(){return C});var M=m("./src/utils/mediasource-helper.ts");function _(){return self.SourceBuffer||self.WebKitSourceBuffer}function L(){var b=Object(M.getMediaSource)();if(!b)return!1;var O=_(),A=b&&typeof b.isTypeSupported=="function"&&b.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!A&&!!y}function C(){var b,O=_();return typeof(O==null||(b=O.prototype)===null||b===void 0?void 0:b.changeType)=="function"}},"./src/loader/date-range.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"DateRangeAttribute",function(){return A}),m.d(R,"DateRange",function(){return y});var M=m("./src/polyfills/number.ts"),_=m("./src/utils/attr-list.ts"),L=m("./src/utils/logger.ts");function C(){return C=Object.assign?Object.assign.bind():function(T){for(var D=1;D<arguments.length;D++){var E=arguments[D];for(var g in E)Object.prototype.hasOwnProperty.call(E,g)&&(T[g]=E[g])}return T},C.apply(this,arguments)}function b(T,D){for(var E=0;E<D.length;E++){var g=D[E];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(T,g.key,g)}}function O(T,D,E){return D&&b(T.prototype,D),E&&b(T,E),Object.defineProperty(T,"prototype",{writable:!1}),T}var A;(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"})(A||(A={}));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 g=E.attr;for(var p in g)if(Object.prototype.hasOwnProperty.call(D,p)&&D[p]!==g[p]){L.logger.warn('DATERANGE tag attribute: "'+p+'" does not match for tags with ID: "'+D.ID+'"'),this._badValueForSameId=p;break}D=C(new _.AttrList({}),g,D)}if(this.attr=D,this._startDate=new Date(D[A.START_DATE]),A.END_DATE in this.attr){var u=new Date(this.attr[A.END_DATE]);Object(M.isFiniteNumber)(u.getTime())&&(this._endDate=u)}}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(A.DURATION in this.attr){var E=this.attr.decimalFloatingPoint(A.DURATION);if(Object(M.isFiniteNumber)(E))return E}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return A.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(A.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(A.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&Object(M.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),T}()},"./src/loader/fragment-loader.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return E}),m.d(R,"LoadError",function(){return p});var M=m("./src/polyfills/number.ts"),_=m("./src/errors.ts");function L(u,e){u.prototype=Object.create(e.prototype),u.prototype.constructor=u,y(u,e)}function C(u){var e=typeof Map=="function"?new Map:void 0;return C=function(c){if(c===null||!A(c))return c;if(typeof c!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(c))return e.get(c);e.set(c,v)}function v(){return b(c,arguments,T(this).constructor)}return v.prototype=Object.create(c.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),y(v,c)},C(u)}function b(u,e,s){return O()?b=Reflect.construct.bind():b=function(v,i,r){var o=[null];o.push.apply(o,i);var d=Function.bind.apply(v,o),t=new d;return r&&y(t,r.prototype),t},b.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 A(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function y(u,e){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,v){return c.__proto__=v,c},y(u,e)}function T(u){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},T(u)}var D=Math.pow(2,17),E=function(){function u(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var e=u.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(c,v){var i=this,r=c.url;if(!r)return Promise.reject(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:c,networkDetails:null},"Fragment does not have a "+(r?"part list":"url")));this.abort();var o=this.config,d=o.fLoader,t=o.loader;return new Promise(function(n,l){i.loader&&i.loader.destroy();var a=i.loader=c.loader=d?new d(o):new t(o),f=g(c),h={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:c.sn==="initSegment"?1/0:D};c.stats=a.stats,a.load(f,h,{onSuccess:function(x,P,k,B){i.resetLoader(c,a),n({frag:c,part:null,payload:x.data,networkDetails:B})},onError:function(x,P,k){i.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:c,response:x,networkDetails:k}))},onAbort:function(x,P,k){i.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:c,networkDetails:k}))},onTimeout:function(x,P,k){i.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:c,networkDetails:k}))},onProgress:function(x,P,k,B){v&&v({frag:c,part:null,payload:k,networkDetails:B})}})})},e.loadPart=function(c,v,i){var r=this;this.abort();var o=this.config,d=o.fLoader,t=o.loader;return new Promise(function(n,l){r.loader&&r.loader.destroy();var a=r.loader=c.loader=d?new d(o):new t(o),f=g(c,v),h={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:D};v.stats=a.stats,a.load(f,h,{onSuccess:function(x,P,k,B){r.resetLoader(c,a),r.updateStatsFromPart(c,v);var U={frag:c,part:v,payload:x.data,networkDetails:B};i(U),n(U)},onError:function(x,P,k){r.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:c,part:v,response:x,networkDetails:k}))},onAbort:function(x,P,k){c.stats.aborted=v.stats.aborted,r.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:c,part:v,networkDetails:k}))},onTimeout:function(x,P,k){r.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:c,part:v,networkDetails:k}))}})})},e.updateStatsFromPart=function(c,v){var i=c.stats,r=v.stats,o=r.total;if(i.loaded+=r.loaded,o){var d=Math.round(c.duration/v.duration),t=Math.min(Math.round(i.loaded/o),d),n=d-t,l=n*Math.round(i.loaded/t);i.total=i.loaded+l}else i.total=Math.max(i.loaded,i.total);var a=i.loading,f=r.loading;a.start?a.first+=f.first-f.start:(a.start=f.start,a.first=f.first),a.end=f.end},e.resetLoader=function(c,v){c.loader=null,this.loader===v&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),v.destroy()},u}();function g(u,e){e===void 0&&(e=null);var s=e||u,c={frag:u,part:e,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},v=s.byteRangeStartOffset,i=s.byteRangeEndOffset;return Object(M.isFiniteNumber)(v)&&Object(M.isFiniteNumber)(i)&&(c.rangeStart=v,c.rangeEnd=i),c}var p=function(u){L(e,u);function e(s){for(var c,v=arguments.length,i=new Array(v>1?v-1:0),r=1;r<v;r++)i[r-1]=arguments[r];return c=u.call.apply(u,[this].concat(i))||this,c.data=void 0,c.data=s,c}return e}(C(Error))},"./src/loader/fragment.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"ElementaryStreamTypes",function(){return E}),m.d(R,"BaseSegment",function(){return g}),m.d(R,"Fragment",function(){return p}),m.d(R,"Part",function(){return u});var M=m("./src/polyfills/number.ts"),_=m("./node_modules/url-toolkit/src/url-toolkit.js"),L=m.n(_),C=m("./src/utils/logger.ts"),b=m("./src/loader/level-key.ts"),O=m("./src/loader/load-stats.ts");function A(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,y(e,s)}function y(e,s){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,i){return v.__proto__=i,v},y(e,s)}function T(e,s){for(var c=0;c<s.length;c++){var v=s[c];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(e,v.key,v)}}function D(e,s,c){return s&&T(e.prototype,s),c&&T(e,c),Object.defineProperty(e,"prototype",{writable:!1}),e}var E;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(E||(E={}));var g=function(){function e(c){var v;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(v={},v[E.AUDIO]=null,v[E.VIDEO]=null,v[E.AUDIOVIDEO]=null,v),this.baseurl=c}var s=e.prototype;return s.setByteRange=function(v,i){var r=v.split("@",2),o=[];r.length===1?o[0]=i?i.byteRangeEndOffset:0:o[0]=parseInt(r[1]),o[1]=parseInt(r[0])+o[0],this._byteRange=o},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(_.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(v){this._url=v}}]),e}(),p=function(e){A(s,e);function s(v,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=v,r}var c=s.prototype;return c.createInitializationVector=function(i){for(var r=new Uint8Array(16),o=12;o<16;o++)r[o]=i>>8*(15-o)&255;return r},c.setDecryptDataFromLevelKey=function(i,r){var o=i;return(i==null?void 0:i.method)==="AES-128"&&i.uri&&!i.iv&&(o=b.LevelKey.fromURI(i.uri),o.method=i.method,o.iv=this.createInitializationVector(r),o.keyFormat="identity"),o},c.setElementaryStreamInfo=function(i,r,o,d,t,n){n===void 0&&(n=!1);var l=this.elementaryStreams,a=l[i];if(!a){l[i]={startPTS:r,endPTS:o,startDTS:d,endDTS:t,partial:n};return}a.startPTS=Math.min(a.startPTS,r),a.endPTS=Math.max(a.endPTS,o),a.startDTS=Math.min(a.startDTS,d),a.endDTS=Math.max(a.endDTS,t)},c.clearElementaryStreamInfo=function(){var i=this.elementaryStreams;i[E.AUDIO]=null,i[E.VIDEO]=null,i[E.AUDIOVIDEO]=null},D(s,[{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&&C.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(M.isFiniteNumber)(this.programDateTime))return null;var i=Object(M.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)}}]),s}(g),u=function(e){A(s,e);function s(c,v,i,r,o){var d;d=e.call(this,i)||this,d.fragOffset=0,d.duration=0,d.gap=!1,d.independent=!1,d.relurl=void 0,d.fragment=void 0,d.index=void 0,d.stats=new O.LoadStats,d.duration=c.decimalFloatingPoint("DURATION"),d.gap=c.bool("GAP"),d.independent=c.bool("INDEPENDENT"),d.relurl=c.enumeratedString("URI"),d.fragment=v,d.index=r;var t=c.enumeratedString("BYTERANGE");return t&&d.setByteRange(t,o),o&&(d.fragOffset=o.fragOffset+o.duration),d}return D(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var v=this.elementaryStreams;return!!(v.audio||v.video||v.audiovideo)}}]),s}(g)},"./src/loader/key-loader.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return C});var M=m("./src/events.ts"),_=m("./src/errors.ts"),L=m("./src/utils/logger.ts"),C=function(){function b(A){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=A,this.registerListeners()}var O=b.prototype;return O.startLoad=function(y){},O.stopLoad=function(){this.destroyInternalLoaders()},O.registerListeners=function(){this.hls.on(M.Events.KEY_LOADING,this.onKeyLoading,this)},O.unregisterListeners=function(){this.hls.off(M.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,g=this.loaders[E];if(!D.decryptdata){L.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var p=D.decryptdata.uri;if(p!==this.decrypturl||this.decryptkey===null){var u=this.hls.config;if(g&&(L.logger.warn("abort previous key loader for type:"+E),g.abort()),!p){L.logger.warn("key uri is falsy");return}var e=u.loader,s=D.loader=this.loaders[E]=new e(u);this.decrypturl=p,this.decryptkey=null;var c={url:p,frag:D,responseType:"arraybuffer"},v={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:u.fragLoadingRetryDelay,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(c,v,i)}else this.decryptkey&&(D.decryptdata.key=this.decryptkey,this.hls.trigger(M.Events.KEY_LOADED,{frag:D}))},O.loadsuccess=function(y,T,D){var E=D.frag;if(!E.decryptdata){L.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(M.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(M.Events.ERROR,{type:_.ErrorTypes.NETWORK_ERROR,details:_.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(M.Events.ERROR,{type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:D})},b}()},"./src/loader/level-details.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"LevelDetails",function(){return b});var M=m("./src/polyfills/number.ts");function _(O,A){for(var y=0;y<A.length;y++){var T=A[y];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function L(O,A,y){return A&&_(O.prototype,A),y&&_(O,y),Object.defineProperty(O,"prototype",{writable:!1}),O}var C=10,b=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 A=O.prototype;return A.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},L(O,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(M.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||C}},{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(j,R,m){"use strict";m.r(R),m.d(R,"LevelKey",function(){return b});var M=m("./node_modules/url-toolkit/src/url-toolkit.js"),_=m.n(M);function L(O,A){for(var y=0;y<A.length;y++){var T=A[y];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function C(O,A,y){return A&&L(O.prototype,A),y&&L(O,y),Object.defineProperty(O,"prototype",{writable:!1}),O}var b=function(){O.fromURL=function(y,T){return new O(y,T)},O.fromURI=function(y){return new O(y)};function O(A,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(M.buildAbsoluteURL)(A,y,{alwaysNormalize:!0}):this._uri=A}return C(O,[{key:"uri",get:function(){return this._uri}}]),O}()},"./src/loader/load-stats.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"LoadStats",function(){return M});var M=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(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return c});var M=m("./src/polyfills/number.ts"),_=m("./node_modules/url-toolkit/src/url-toolkit.js"),L=m.n(_),C=m("./src/loader/date-range.ts"),b=m("./src/loader/fragment.ts"),O=m("./src/loader/level-details.ts"),A=m("./src/loader/level-key.ts"),y=m("./src/utils/attr-list.ts"),T=m("./src/utils/logger.ts"),D=m("./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,g=/#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"),u=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 s(t){var n,l;return e.test((n=(l=_.parseURL(t))===null||l===void 0?void 0:l.path)!=null?n:"")}var c=function(){function t(){}return t.findGroup=function(l,a){for(var f=0;f<l.length;f++){var h=l[f];if(h.id===a)return h}},t.convertAVC1ToAVCOTI=function(l){var a=l.split(".");if(a.length>2){var f=a.shift()+".";return f+=parseInt(a.shift()).toString(16),f+=("000"+parseInt(a.shift()).toString(16)).slice(-4),f}return l},t.resolve=function(l,a){return _.buildAbsoluteURL(a,l,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(l,a){var f=[],h={},S=!1;E.lastIndex=0;for(var x;(x=E.exec(l))!=null;)if(x[1]){var P=new y.AttrList(x[1]),k={attrs:P,bitrate:P.decimalInteger("AVERAGE-BANDWIDTH")||P.decimalInteger("BANDWIDTH"),name:P.NAME,url:t.resolve(x[2],a)},B=P.decimalResolution("RESOLUTION");B&&(k.width=B.width,k.height=B.height),v((P.CODECS||"").split(/[ ,]+/).filter(function(W){return W}),k),k.videoCodec&&k.videoCodec.indexOf("avc1")!==-1&&(k.videoCodec=t.convertAVC1ToAVCOTI(k.videoCodec)),f.push(k)}else if(x[3]){var U=new y.AttrList(x[3]);U["DATA-ID"]&&(S=!0,h[U["DATA-ID"]]=U)}return{levels:f,sessionData:S?h:null}},t.parseMasterPlaylistMedia=function(l,a,f,h){h===void 0&&(h=[]);var S,x=[],P=0;for(g.lastIndex=0;(S=g.exec(l))!==null;){var k=new y.AttrList(S[1]);if(k.TYPE===f){var B={attrs:k,bitrate:0,id:P++,groupId:k["GROUP-ID"],instreamId:k["INSTREAM-ID"],name:k.NAME||k.LANGUAGE||"",type:f,default:k.bool("DEFAULT"),autoselect:k.bool("AUTOSELECT"),forced:k.bool("FORCED"),lang:k.LANGUAGE,url:k.URI?t.resolve(k.URI,a):""};if(h.length){var U=t.findGroup(h,B.groupId)||h[0];i(B,U,"audioCodec"),i(B,U,"textCodec")}x.push(B)}}return x},t.parseLevelPlaylist=function(l,a,f,h,S){var x=new O.LevelDetails(a),P=x.fragments,k=null,B=0,U=0,W=0,G=0,z=null,Y=new b.Fragment(h,a),$,Z,q,ie=-1,ne=!1;for(p.lastIndex=0,x.m3u8=l;($=p.exec(l))!==null;){ne&&(ne=!1,Y=new b.Fragment(h,a),Y.start=W,Y.sn=B,Y.cc=G,Y.level=f,k&&(Y.initSegment=k,Y.rawProgramDateTime=k.rawProgramDateTime,k.rawProgramDateTime=null));var ae=$[1];if(ae){Y.duration=parseFloat(ae);var te=(" "+$[2]).slice(1);Y.title=te||null,Y.tagList.push(te?["INF",ae,te]:["INF",ae])}else if($[3])Object(M.isFiniteNumber)(Y.duration)&&(Y.start=W,q&&(Y.levelkey=q),Y.sn=B,Y.level=f,Y.cc=G,Y.urlId=S,P.push(Y),Y.relurl=(" "+$[3]).slice(1),o(Y,z),z=Y,W+=Y.duration,B++,U=0,ne=!0);else if($[4]){var fe=(" "+$[4]).slice(1);z?Y.setByteRange(fe,z):Y.setByteRange(fe)}else if($[5])Y.rawProgramDateTime=(" "+$[5]).slice(1),Y.tagList.push(["PROGRAM-DATE-TIME",Y.rawProgramDateTime]),ie===-1&&(ie=P.length);else{if($=$[0].match(u),!$){T.logger.warn("No matches on slow regex match for level playlist!");continue}for(Z=1;Z<$.length&&typeof $[Z]=="undefined";Z++);var de=(" "+$[Z]).slice(1),re=(" "+$[Z+1]).slice(1),Ee=$[Z+2]?(" "+$[Z+2]).slice(1):"";switch(de){case"PLAYLIST-TYPE":x.type=re.toUpperCase();break;case"MEDIA-SEQUENCE":B=x.startSN=parseInt(re);break;case"SKIP":{var me=new y.AttrList(re),Te=me.decimalInteger("SKIPPED-SEGMENTS");if(Object(M.isFiniteNumber)(Te)){x.skippedSegments=Te;for(var Me=Te;Me--;)P.unshift(null);B+=Te}var Ae=me.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ae&&(x.recentlyRemovedDateranges=Ae.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||Ee)&&Y.tagList.push(Ee?[re,Ee]:[re]);break;case"DISCONTINUITY":G++,Y.tagList.push(["DIS"]);break;case"GAP":Y.tagList.push([de]);break;case"BITRATE":Y.tagList.push([de,re]);break;case"DATERANGE":{var we=new y.AttrList(re),Re=new C.DateRange(we,x.dateRanges[we.ID]);Re.isValid||x.skippedSegments?x.dateRanges[Re.id]=Re: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,_e=new y.AttrList(re),Be=_e.enumeratedString("METHOD"),Ke=_e.URI,We=_e.hexadecimalInteger("IV"),Ue=_e.enumeratedString("KEYFORMATVERSIONS"),Ze=_e.enumeratedString("KEYID"),Ce=(ke=_e.enumeratedString("KEYFORMAT"))!=null?ke:"identity",qe=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(qe.indexOf(Ce)>-1){T.logger.warn("Keyformat "+Ce+" is not supported from the manifest");continue}else if(Ce!=="identity")continue;Be&&(q=A.LevelKey.fromURL(a,Ke),Ke&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Be)>=0&&(q.method=Be,q.keyFormat=Ce,Ze&&(q.keyID=Ze),Ue&&(q.keyFormatVersions=Ue),q.iv=We));break}case"START":{var Oe=new y.AttrList(re),Pe=Oe.decimalFloatingPoint("TIME-OFFSET");Object(M.isFiniteNumber)(Pe)&&(x.startTimeOffset=Pe);break}case"MAP":{var Ve=new y.AttrList(re);if(Y.duration){var Ie=new b.Fragment(h,a);d(Ie,Ve,f,q),k=Ie,Y.initSegment=k,k.rawProgramDateTime&&!Y.rawProgramDateTime&&(Y.rawProgramDateTime=k.rawProgramDateTime)}else d(Y,Ve,f,q),k=Y,ne=!0;break}case"SERVER-CONTROL":{var Le=new y.AttrList(re);x.canBlockReload=Le.bool("CAN-BLOCK-RELOAD"),x.canSkipUntil=Le.optionalFloat("CAN-SKIP-UNTIL",0),x.canSkipDateRanges=x.canSkipUntil>0&&Le.bool("CAN-SKIP-DATERANGES"),x.partHoldBack=Le.optionalFloat("PART-HOLD-BACK",0),x.holdBack=Le.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var rt=new y.AttrList(re);x.partTarget=rt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var je=x.partList;je||(je=x.partList=[]);var st=U>0?je[je.length-1]:void 0,vt=U++,ze=new b.Part(new y.AttrList(re),Y,a,vt,st);je.push(ze),Y.duration+=ze.duration;break}case"PRELOAD-HINT":{var xt=new y.AttrList(re);x.preloadHint=xt;break}case"RENDITION-REPORT":{var gt=new y.AttrList(re);x.renditionReports=x.renditionReports||[],x.renditionReports.push(gt);break}default:T.logger.warn("line parsed but not handled: "+$);break}}}z&&!z.relurl?(P.pop(),W-=z.duration,x.partList&&(x.fragmentHint=z)):x.partList&&(o(Y,z),Y.cc=G,x.fragmentHint=Y);var it=P.length,ot=P[0],nt=P[it-1];if(W+=x.skippedSegments*x.targetduration,W>0&&it&&nt){x.averagetargetduration=W/it;var mt=nt.sn;x.endSN=mt!=="initSegment"?mt:0,ot&&(x.startCC=ot.cc,ot.initSegment||x.fragments.every(function(ct){return ct.relurl&&s(ct.relurl)})&&(T.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),Y=new b.Fragment(h,a),Y.relurl=nt.relurl,Y.level=f,Y.sn="initSegment",ot.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,ie>0&&r(P,ie),x},t}();function v(t,n){["video","audio","text"].forEach(function(l){var a=t.filter(function(h){return Object(D.isCodecType)(h,l)});if(a.length){var f=a.filter(function(h){return h.lastIndexOf("avc1",0)===0||h.lastIndexOf("mp4a",0)===0});n[l+"Codec"]=f.length>0?f[0]:a[0],t=t.filter(function(h){return a.indexOf(h)===-1})}}),n.unknownCodecs=t}function i(t,n,l){var a=n[l];a&&(t[l]=a)}function r(t,n){for(var l=t[n],a=n;a--;){var f=t[a];if(!f)return;f.programDateTime=l.programDateTime-f.duration*1e3,l=f}}function o(t,n){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):n!=null&&n.programDateTime&&(t.programDateTime=n.endProgramDateTime),Object(M.isFiniteNumber)(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function d(t,n,l,a){t.relurl=n.URI,n.BYTERANGE&&t.setByteRange(n.BYTERANGE),t.level=l,t.sn="initSegment",a&&(t.levelkey=a),t.initSegment=null}},"./src/loader/playlist-loader.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/polyfills/number.ts"),_=m("./src/events.ts"),L=m("./src/errors.ts"),C=m("./src/utils/logger.ts"),b=m("./src/utils/mp4-tools.ts"),O=m("./src/loader/m3u8-parser.ts"),A=m("./src/types/loader.ts"),y=m("./src/utils/attr-list.ts");function T(g){var p=g.type;switch(p){case A.PlaylistContextType.AUDIO_TRACK:return A.PlaylistLevelType.AUDIO;case A.PlaylistContextType.SUBTITLE_TRACK:return A.PlaylistLevelType.SUBTITLE;default:return A.PlaylistLevelType.MAIN}}function D(g,p){var u=g.url;return(u===void 0||u.indexOf("data:")===0)&&(u=p.url),u}var E=function(){function g(u){this.hls=void 0,this.loaders=Object.create(null),this.hls=u,this.registerListeners()}var p=g.prototype;return p.startLoad=function(e){},p.stopLoad=function(){this.destroyInternalLoaders()},p.registerListeners=function(){var e=this.hls;e.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(_.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.unregisterListeners=function(){var e=this.hls;e.off(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(_.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(_.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.createInternalLoader=function(e){var s=this.hls.config,c=s.pLoader,v=s.loader,i=c||v,r=new i(s);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 s=this.loaders[e];s&&s.destroy(),this.resetInternalLoader(e)}},p.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},p.onManifestLoading=function(e,s){var c=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:A.PlaylistContextType.MANIFEST,url:c,deliveryDirectives:null})},p.onLevelLoading=function(e,s){var c=s.id,v=s.level,i=s.url,r=s.deliveryDirectives;this.load({id:c,groupId:null,level:v,responseType:"text",type:A.PlaylistContextType.LEVEL,url:i,deliveryDirectives:r})},p.onAudioTrackLoading=function(e,s){var c=s.id,v=s.groupId,i=s.url,r=s.deliveryDirectives;this.load({id:c,groupId:v,level:null,responseType:"text",type:A.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:r})},p.onSubtitleTrackLoading=function(e,s){var c=s.id,v=s.groupId,i=s.url,r=s.deliveryDirectives;this.load({id:c,groupId:v,level:null,responseType:"text",type:A.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:r})},p.load=function(e){var s,c=this.hls.config,v=this.getInternalLoader(e);if(v){var i=v.context;if(i&&i.url===e.url){C.logger.trace("[playlist-loader]: playlist request ongoing");return}C.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),v.abort()}var r,o,d,t;switch(e.type){case A.PlaylistContextType.MANIFEST:r=c.manifestLoadingMaxRetry,o=c.manifestLoadingTimeOut,d=c.manifestLoadingRetryDelay,t=c.manifestLoadingMaxRetryTimeout;break;case A.PlaylistContextType.LEVEL:case A.PlaylistContextType.AUDIO_TRACK:case A.PlaylistContextType.SUBTITLE_TRACK:r=0,o=c.levelLoadingTimeOut;break;default:r=c.levelLoadingMaxRetry,o=c.levelLoadingTimeOut,d=c.levelLoadingRetryDelay,t=c.levelLoadingMaxRetryTimeout;break}if(v=this.createInternalLoader(e),(s=e.deliveryDirectives)!==null&&s!==void 0&&s.part){var n;if(e.type===A.PlaylistContextType.LEVEL&&e.level!==null?n=this.hls.levels[e.level].details:e.type===A.PlaylistContextType.AUDIO_TRACK&&e.id!==null?n=this.hls.audioTracks[e.id].details:e.type===A.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(n=this.hls.subtitleTracks[e.id].details),n){var l=n.partTarget,a=n.targetduration;l&&a&&(o=Math.min(Math.max(l*3,a*.8)*1e3,o))}}var f={timeout:o,maxRetry:r,retryDelay:d,maxRetryDelay:t,highWaterMark:0},h={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};v.load(e,f,h)},p.loadsuccess=function(e,s,c,v){if(v===void 0&&(v=null),c.isSidxRequest){this.handleSidxRequest(e,c),this.handlePlaylistLoaded(e,s,c,v);return}this.resetInternalLoader(c.type);var i=e.data;if(i.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,c,"no EXTM3U delimiter",v);return}s.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,s,c,v):this.handleMasterPlaylist(e,s,c,v)},p.loaderror=function(e,s,c){c===void 0&&(c=null),this.handleNetworkError(s,c,!1,e)},p.loadtimeout=function(e,s,c){c===void 0&&(c=null),this.handleNetworkError(s,c,!0)},p.handleMasterPlaylist=function(e,s,c,v){var i=this.hls,r=e.data,o=D(e,c),d=O.default.parseMasterPlaylist(r,o),t=d.levels,n=d.sessionData;if(!t.length){this.handleManifestParsingError(e,c,"no level found in manifest",v);return}var l=t.map(function(P){return{id:P.attrs.AUDIO,audioCodec:P.audioCodec}}),a=t.map(function(P){return{id:P.attrs.SUBTITLES,textCodec:P.textCodec}}),f=O.default.parseMasterPlaylistMedia(r,o,"AUDIO",l),h=O.default.parseMasterPlaylistMedia(r,o,"SUBTITLES",a),S=O.default.parseMasterPlaylistMedia(r,o,"CLOSED-CAPTIONS");if(f.length){var x=f.some(function(P){return!P.url});!x&&t[0].audioCodec&&!t[0].attrs.AUDIO&&(C.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(_.Events.MANIFEST_LOADED,{levels:t,audioTracks:f,subtitles:h,captions:S,url:o,stats:s,networkDetails:v,sessionData:n})},p.handleTrackOrLevelPlaylist=function(e,s,c,v){var i=this.hls,r=c.id,o=c.level,d=c.type,t=D(e,c),n=Object(M.isFiniteNumber)(r)?r:0,l=Object(M.isFiniteNumber)(o)?o:n,a=T(c),f=O.default.parseLevelPlaylist(e.data,t,l,a,n);if(!f.fragments.length){i.trigger(_.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:t,reason:"no fragments found in level",level:typeof c.level=="number"?c.level:void 0});return}if(d===A.PlaylistContextType.MANIFEST){var h={attrs:new y.AttrList({}),bitrate:0,details:f,name:"",url:t};i.trigger(_.Events.MANIFEST_LOADED,{levels:[h],audioTracks:[],url:t,stats:s,networkDetails:v,sessionData:null})}if(s.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:d,level:o,levelDetails:f,id:r,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}c.levelDetails=f,this.handlePlaylistLoaded(e,s,c,v)},p.handleSidxRequest=function(e,s){var c=new Uint8Array(e.data),v=Object(b.findBox)(c,["sidx"])[0];if(!!v){var i=Object(b.parseSegmentIndex)(v);if(!!i){var r=i.references,o=s.levelDetails;r.forEach(function(d,t){var n=d.info,l=o.fragments[t];if(l.byteRange.length===0&&l.setByteRange(String(1+n.end-n.start)+"@"+String(n.start)),l.initSegment){var a=Object(b.findBox)(c,["moov"])[0],f=a?a.length:null;l.initSegment.setByteRange(String(f)+"@0")}})}}},p.handleManifestParsingError=function(e,s,c,v){this.hls.trigger(_.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===A.PlaylistContextType.MANIFEST,url:e.url,reason:c,response:e,context:s,networkDetails:v})},p.handleNetworkError=function(e,s,c,v){c===void 0&&(c=!1),C.logger.warn("[playlist-loader]: A network "+(c?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var i=L.ErrorDetails.UNKNOWN,r=!1,o=this.getInternalLoader(e);switch(e.type){case A.PlaylistContextType.MANIFEST:i=c?L.ErrorDetails.MANIFEST_LOAD_TIMEOUT:L.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0;break;case A.PlaylistContextType.LEVEL:i=c?L.ErrorDetails.LEVEL_LOAD_TIMEOUT:L.ErrorDetails.LEVEL_LOAD_ERROR,r=!1;break;case A.PlaylistContextType.AUDIO_TRACK:i=c?L.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:L.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,r=!1;break;case A.PlaylistContextType.SUBTITLE_TRACK:i=c?L.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:L.ErrorDetails.SUBTITLE_LOAD_ERROR,r=!1;break}o&&this.resetInternalLoader(e.type);var d={type:L.ErrorTypes.NETWORK_ERROR,details:i,fatal:r,url:e.url,loader:o,context:e,networkDetails:s};v&&(d.response=v),this.hls.trigger(_.Events.ERROR,d)},p.handlePlaylistLoaded=function(e,s,c,v){var i=c.type,r=c.level,o=c.id,d=c.groupId,t=c.loader,n=c.levelDetails,l=c.deliveryDirectives;if(!(n!=null&&n.targetduration)){this.handleManifestParsingError(e,c,"invalid target duration",v);return}if(!!t)switch(n.live&&(t.getCacheAge&&(n.ageHeader=t.getCacheAge()||0),(!t.getCacheAge||isNaN(n.ageHeader))&&(n.ageHeader=0)),i){case A.PlaylistContextType.MANIFEST:case A.PlaylistContextType.LEVEL:this.hls.trigger(_.Events.LEVEL_LOADED,{details:n,level:r||0,id:o||0,stats:s,networkDetails:v,deliveryDirectives:l});break;case A.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(_.Events.AUDIO_TRACK_LOADED,{details:n,id:o||0,groupId:d||"",stats:s,networkDetails:v,deliveryDirectives:l});break;case A.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(_.Events.SUBTITLE_TRACK_LOADED,{details:n,id:o||0,groupId:d||"",stats:s,networkDetails:v,deliveryDirectives:l});break}},g}();R.default=E},"./src/polyfills/number.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"isFiniteNumber",function(){return M}),m.d(R,"MAX_SAFE_INTEGER",function(){return _});var M=Number.isFinite||function(L){return typeof L=="number"&&isFinite(L)},_=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(j,R,m){"use strict";m.r(R);var M=function(){function _(){}return _.getSilentFrame=function(C,b){switch(C){case"mp4a.40.2":if(b===1)return new Uint8Array([0,200,0,128,35,128]);if(b===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(b===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(b===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(b===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(b===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(b===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(b===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(b===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}},_}();R.default=M},"./src/remux/mp4-generator.ts":function(j,R,m){"use strict";m.r(R);var M=Math.pow(2,32)-1,_=function(){function L(){}return L.init=function(){L.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 b;for(b in L.types)L.types.hasOwnProperty(b)&&(L.types[b]=[b.charCodeAt(0),b.charCodeAt(1),b.charCodeAt(2),b.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]),A=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);L.HDLR_TYPES={video:O,audio:A};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]);L.STTS=L.STSC=L.STCO=T,L.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),L.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),L.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),L.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]),g=new Uint8Array([0,0,0,1]);L.FTYP=L.box(L.types.ftyp,D,g,D,E),L.DINF=L.box(L.types.dinf,L.box(L.types.dref,y))},L.box=function(b){for(var O=8,A=arguments.length,y=new Array(A>1?A-1:0),T=1;T<A;T++)y[T-1]=arguments[T];for(var D=y.length,E=D;D--;)O+=y[D].byteLength;var g=new Uint8Array(O);for(g[0]=O>>24&255,g[1]=O>>16&255,g[2]=O>>8&255,g[3]=O&255,g.set(b,4),D=0,O=8;D<E;D++)g.set(y[D],O),O+=y[D].byteLength;return g},L.hdlr=function(b){return L.box(L.types.hdlr,L.HDLR_TYPES[b])},L.mdat=function(b){return L.box(L.types.mdat,b)},L.mdhd=function(b,O){O*=b;var A=Math.floor(O/(M+1)),y=Math.floor(O%(M+1));return L.box(L.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,b>>24&255,b>>16&255,b>>8&255,b&255,A>>24,A>>16&255,A>>8&255,A&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},L.mdia=function(b){return L.box(L.types.mdia,L.mdhd(b.timescale,b.duration),L.hdlr(b.type),L.minf(b))},L.mfhd=function(b){return L.box(L.types.mfhd,new Uint8Array([0,0,0,0,b>>24,b>>16&255,b>>8&255,b&255]))},L.minf=function(b){return b.type==="audio"?L.box(L.types.minf,L.box(L.types.smhd,L.SMHD),L.DINF,L.stbl(b)):L.box(L.types.minf,L.box(L.types.vmhd,L.VMHD),L.DINF,L.stbl(b))},L.moof=function(b,O,A){return L.box(L.types.moof,L.mfhd(b),L.traf(A,O))},L.moov=function(b){for(var O=b.length,A=[];O--;)A[O]=L.trak(b[O]);return L.box.apply(null,[L.types.moov,L.mvhd(b[0].timescale,b[0].duration)].concat(A).concat(L.mvex(b)))},L.mvex=function(b){for(var O=b.length,A=[];O--;)A[O]=L.trex(b[O]);return L.box.apply(null,[L.types.mvex].concat(A))},L.mvhd=function(b,O){O*=b;var A=Math.floor(O/(M+1)),y=Math.floor(O%(M+1)),T=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,b>>24&255,b>>16&255,b>>8&255,b&255,A>>24,A>>16&255,A>>8&255,A&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 L.box(L.types.mvhd,T)},L.sdtp=function(b){var O=b.samples||[],A=new Uint8Array(4+O.length),y,T;for(y=0;y<O.length;y++)T=O[y].flags,A[y+4]=T.dependsOn<<4|T.isDependedOn<<2|T.hasRedundancy;return L.box(L.types.sdtp,A)},L.stbl=function(b){return L.box(L.types.stbl,L.stsd(b),L.box(L.types.stts,L.STTS),L.box(L.types.stsc,L.STSC),L.box(L.types.stsz,L.STSZ),L.box(L.types.stco,L.STCO))},L.avc1=function(b){var O=[],A=[],y,T,D;for(y=0;y<b.sps.length;y++)T=b.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<b.pps.length;y++)T=b.pps[y],D=T.byteLength,A.push(D>>>8&255),A.push(D&255),A=A.concat(Array.prototype.slice.call(T));var E=L.box(L.types.avcC,new Uint8Array([1,O[3],O[4],O[5],255,224|b.sps.length].concat(O).concat([b.pps.length]).concat(A))),g=b.width,p=b.height,u=b.pixelRatio[0],e=b.pixelRatio[1];return L.box(L.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,g>>8&255,g&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,L.box(L.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),L.box(L.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,e>>24,e>>16&255,e>>8&255,e&255])))},L.esds=function(b){var O=b.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(b.config).concat([6,1,2]))},L.mp4a=function(b){var O=b.samplerate;return L.box(L.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,b.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]),L.box(L.types.esds,L.esds(b)))},L.mp3=function(b){var O=b.samplerate;return L.box(L.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,b.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]))},L.stsd=function(b){return b.type==="audio"?b.segmentCodec==="mp3"&&b.codec==="mp3"?L.box(L.types.stsd,L.STSD,L.mp3(b)):L.box(L.types.stsd,L.STSD,L.mp4a(b)):L.box(L.types.stsd,L.STSD,L.avc1(b))},L.tkhd=function(b){var O=b.id,A=b.duration*b.timescale,y=b.width,T=b.height,D=Math.floor(A/(M+1)),E=Math.floor(A%(M+1));return L.box(L.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]))},L.traf=function(b,O){var A=L.sdtp(b),y=b.id,T=Math.floor(O/(M+1)),D=Math.floor(O%(M+1));return L.box(L.types.traf,L.box(L.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),L.box(L.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])),L.trun(b,A.length+16+20+8+16+8+8),A)},L.trak=function(b){return b.duration=b.duration||4294967295,L.box(L.types.trak,L.tkhd(b),L.mdia(b))},L.trex=function(b){var O=b.id;return L.box(L.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]))},L.trun=function(b,O){var A=b.samples||[],y=A.length,T=12+16*y,D=new Uint8Array(T),E,g,p,u,e,s;for(O+=8+T,D.set([b.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++)g=A[E],p=g.duration,u=g.size,e=g.flags,s=g.cts,D.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,s>>>24&255,s>>>16&255,s>>>8&255,s&255],12+16*E);return L.box(L.types.trun,D)},L.initSegment=function(b){L.types||L.init();var O=L.moov(b),A=new Uint8Array(L.FTYP.byteLength+O.byteLength);return A.set(L.FTYP),A.set(O,L.FTYP.byteLength),A},L}();_.types=void 0,_.HDLR_TYPES=void 0,_.STTS=void 0,_.STSC=void 0,_.STCO=void 0,_.STSZ=void 0,_.VMHD=void 0,_.SMHD=void 0,_.STSD=void 0,_.FTYP=void 0,_.DINF=void 0,R.default=_},"./src/remux/mp4-remuxer.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return e}),m.d(R,"normalizePts",function(){return s}),m.d(R,"flushTextTrackMetadataCueSamples",function(){return v}),m.d(R,"flushTextTrackUserdataCueSamples",function(){return i});var M=m("./src/polyfills/number.ts"),_=m("./src/remux/aac-helper.ts"),L=m("./src/remux/mp4-generator.ts"),C=m("./src/events.ts"),b=m("./src/errors.ts"),O=m("./src/utils/logger.ts"),A=m("./src/types/loader.ts"),y=m("./src/utils/timescale-conversion.ts");function T(){return T=Object.assign?Object.assign.bind():function(d){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(d[l]=n[l])}return d},T.apply(this,arguments)}var D=10*1e3,E=1024,g=1152,p=null,u=null,e=function(){function d(n,l,a,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=n,this.config=l,this.typeSupported=a,this.ISGenerated=!1,p===null){var h=navigator.userAgent||"",S=h.match(/Chrome\/(\d+)/i);p=S?parseInt(S[1]):0}if(u===null){var x=navigator.userAgent.match(/Safari\/(\d+)/i);u=x?parseInt(x[1]):0}}var t=d.prototype;return t.destroy=function(){},t.resetTimeStamp=function(l){O.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=l},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(l){var a=!1,f=l.reduce(function(h,S){var x=S.pts-h;return x<-4294967296?(a=!0,s(h,S.pts)):x>0?h:S.pts},l[0].pts);return a&&O.logger.debug("PTS rollover detected"),f},t.remux=function(l,a,f,h,S,x,P,k){var B,U,W,G,z,Y,$=S,Z=S,q=l.pid>-1,ie=a.pid>-1,ne=a.samples.length,ae=l.samples.length>0,te=P&&ne>0||ne>1,fe=(!q||ae)&&(!ie||te)||this.ISGenerated||P;if(fe){this.ISGenerated||(W=this.generateIS(l,a,S));var de=this.isVideoContiguous,re=-1,Ee;if(te&&(re=c(a.samples),!de&&this.config.forceKeyFrameOnDiscontinuity))if(Y=!0,re>0){O.logger.warn("[mp4-remuxer]: Dropped "+re+" out of "+ne+" video samples due to a missing keyframe");var me=this.getVideoStartPts(a.samples);a.samples=a.samples.slice(re),a.dropped+=re,Z+=(a.samples[0].pts-me)/a.inputTimeScale,Ee=Z}else re===-1&&(O.logger.warn("[mp4-remuxer]: No keyframe found out of "+ne+" video samples"),Y=!1);if(this.ISGenerated){if(ae&&te){var Te=this.getVideoStartPts(a.samples),Me=s(l.samples[0].pts,Te)-Te,Ae=Me/a.inputTimeScale;$+=Math.max(0,Ae),Z+=Math.max(0,-Ae)}if(ae){if(l.samplerate||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),W=this.generateIS(l,a,S)),U=this.remuxAudio(l,$,this.isAudioContiguous,x,ie||te||k===A.PlaylistLevelType.AUDIO?Z:void 0),te){var we=U?U.endPTS-U.startPTS:0;a.inputTimeScale||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),W=this.generateIS(l,a,S)),B=this.remuxVideo(a,Z,de,we)}}else te&&(B=this.remuxVideo(a,Z,de,0));B&&(B.firstKeyFrame=re,B.independent=re!==-1,B.firstKeyFramePTS=Ee)}}return this.ISGenerated&&(f.samples.length&&(z=v(f,S,this._initPTS,this._initDTS)),h.samples.length&&(G=i(h,S,this._initPTS))),{audio:U,video:B,initSegment:W,independent:Y,text:G,id3:z}},t.generateIS=function(l,a,f){var h=l.samples,S=a.samples,x=this.typeSupported,P={},k=!Object(M.isFiniteNumber)(this._initPTS),B="audio/mp4",U,W,G;if(k&&(U=W=1/0),l.config&&h.length){switch(l.timescale=l.samplerate,l.segmentCodec){case"mp3":x.mpeg?(B="audio/mpeg",l.codec=""):x.mp3&&(l.codec="mp3");break}P.audio={id:"audio",container:B,codec:l.codec,initSegment:l.segmentCodec==="mp3"&&x.mpeg?new Uint8Array(0):L.default.initSegment([l]),metadata:{channelCount:l.channelCount}},k&&(G=l.inputTimeScale,U=W=h[0].pts-Math.round(G*f))}if(a.sps&&a.pps&&S.length&&(a.timescale=a.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:a.codec,initSegment:L.default.initSegment([a]),metadata:{width:a.width,height:a.height}},k)){G=a.inputTimeScale;var z=this.getVideoStartPts(S),Y=Math.round(G*f);W=Math.min(W,s(S[0].dts,z)-Y),U=Math.min(U,z-Y)}if(Object.keys(P).length)return this.ISGenerated=!0,k&&(this._initPTS=U,this._initDTS=W),{tracks:P,initPTS:U,timescale:G}},t.remuxVideo=function(l,a,f,h){var S=l.inputTimeScale,x=l.samples,P=[],k=x.length,B=this._initPTS,U=this.nextAvcDts,W=8,G=this.videoSampleDuration,z,Y,$=Number.POSITIVE_INFINITY,Z=Number.NEGATIVE_INFINITY,q=!1;if(!f||U===null){var ie=a*S,ne=x[0].pts-s(x[0].dts,x[0].pts);U=ie-ne}for(var ae=0;ae<k;ae++){var te=x[ae];te.pts=s(te.pts-B,U),te.dts=s(te.dts-B,U),te.dts<x[ae>0?ae-1:ae].dts&&(q=!0)}q&&x.sort(function(Dt,Ut){var pt=Dt.dts-Ut.dts,Zt=Dt.pts-Ut.pts;return pt||Zt}),z=x[0].dts,Y=x[x.length-1].dts;var fe=Y-z,de=fe?Math.round(fe/(k-1)):G||l.inputTimeScale/30;if(f){var re=z-U,Ee=re>de,me=re<-1;if(Ee||me){Ee?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 Te=x[0].pts-re;x[0].dts=z,x[0].pts=Te,O.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(Te,!0)+"/"+Object(y.toMsFromMpegTsClock)(z,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(re,!0)+" ms")}}z=Math.max(0,z);for(var Me=0,Ae=0,we=0;we<k;we++){for(var Re=x[we],ke=Re.units,_e=ke.length,Be=0,Ke=0;Ke<_e;Ke++)Be+=ke[Ke].data.length;Ae+=Be,Me+=_e,Re.length=Be,Re.dts=Math.max(Re.dts,z),$=Math.min(Re.pts,$),Z=Math.max(Re.pts,Z)}Y=x[k-1].dts;var We=Ae+4*Me+8,Ue;try{Ue=new Uint8Array(We)}catch{this.observer.emit(C.Events.ERROR,C.Events.ERROR,{type:b.ErrorTypes.MUX_ERROR,details:b.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:We,reason:"fail allocating video mdat "+We});return}var Ze=new DataView(Ue.buffer);Ze.setUint32(0,We),Ue.set(L.default.types.mdat,4);for(var Ce=!1,qe=Number.POSITIVE_INFINITY,Oe=Number.POSITIVE_INFINITY,Pe=Number.NEGATIVE_INFINITY,Ve=Number.NEGATIVE_INFINITY,Ie=0;Ie<k;Ie++){for(var Le=x[Ie],rt=Le.units,je=0,st=0,vt=rt.length;st<vt;st++){var ze=rt[st],xt=ze.data,gt=ze.data.byteLength;Ze.setUint32(W,gt),W+=4,Ue.set(xt,W),W+=gt,je+=4+gt}var it=void 0;if(Ie<k-1)G=x[Ie+1].dts-Le.dts,it=x[Ie+1].pts-Le.pts;else{var ot=this.config,nt=Ie>0?Le.dts-x[Ie-1].dts:de;if(it=Ie>0?Le.pts-x[Ie-1].pts:de,ot.stretchShortVideoTrack&&this.nextAudioPts!==null){var mt=Math.floor(ot.maxBufferHole*S),ct=(h?$+h*S:this.nextAudioPts)-Le.pts;ct>mt?(G=ct-nt,G<0?G=nt:Ce=!0,O.logger.log("[mp4-remuxer]: It is approximately "+ct/90+" ms to the next segment; using duration "+G/90+" ms for the last video frame.")):G=nt}else G=nt}var Qt=Math.round(Le.pts-Le.dts);qe=Math.min(qe,G),Pe=Math.max(Pe,G),Oe=Math.min(Oe,it),Ve=Math.max(Ve,it),P.push(new r(Le.key,G,je,Qt))}if(P.length){if(p){if(p<70){var bt=P[0].flags;bt.dependsOn=2,bt.isNonSync=0}}else if(u&&Ve-Oe<Pe-qe&&de/Pe<.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 St=z,Xe=0,kt=P.length;Xe<kt;Xe++){var Rt=St+P[Xe].duration,Bt=St+P[Xe].cts;if(Xe<kt-1){var Pt=Rt+P[Xe+1].cts;P[Xe].duration=Pt-Bt}else P[Xe].duration=Xe?P[Xe-1].duration:de;P[Xe].cts=0,St=Rt}}}console.assert(G!==null,"mp4SampleDuration must be computed"),G=Ce||!G?de:G,this.nextAvcDts=U=Y+G,this.videoSampleDuration=G,this.isVideoContiguous=!0;var $t=L.default.moof(l.sequenceNumber++,z,T({},l,{samples:P})),Jt="video",at={data1:$t,data2:Ue,startPTS:$/S,endPTS:(Z+G)/S,startDTS:z/S,endDTS:U/S,type:Jt,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:l.dropped};return l.samples=[],l.dropped=0,console.assert(Ue.length,"MDAT length must not be zero"),at},t.remuxAudio=function(l,a,f,h,S){var x=l.inputTimeScale,P=l.samplerate?l.samplerate:x,k=x/P,B=l.segmentCodec==="aac"?E:g,U=B*k,W=this._initPTS,G=l.segmentCodec==="mp3"&&this.typeSupported.mpeg,z=[],Y=S!==void 0,$=l.samples,Z=G?0:8,q=this.nextAudioPts||-1,ie=a*x;if(this.isAudioContiguous=f=f||$.length&&q>0&&(h&&Math.abs(ie-q)<9e3||Math.abs(s($[0].pts-W,ie)-q)<20*U),$.forEach(function(ze){ze.pts=s(ze.pts-W,ie)}),!f||q<0){if($=$.filter(function(ze){return ze.pts>=0}),!$.length)return;S===0?q=0:h&&!Y?q=Math.max(0,ie):q=$[0].pts}if(l.segmentCodec==="aac")for(var ne=this.config.maxAudioFramesDrift,ae=0,te=q;ae<$.length;ae++){var fe=$[ae],de=fe.pts,re=de-te,Ee=Math.abs(1e3*re/x);if(re<=-ne*U&&Y)ae===0&&(O.logger.warn("Audio frame @ "+(de/x).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*re/x)+" ms."),this.nextAudioPts=q=te=de);else if(re>=ne*U&&Ee<D&&Y){var me=Math.round(re/U);te=de-me*U,te<0&&(me--,te+=U),ae===0&&(this.nextAudioPts=q=te),O.logger.warn("[mp4-remuxer]: Injecting "+me+" audio frame @ "+(te/x).toFixed(3)+"s due to "+Math.round(1e3*re/x)+" ms gap.");for(var Te=0;Te<me;Te++){var Me=Math.max(te,0),Ae=_.default.getSilentFrame(l.manifestCodec||l.codec,l.channelCount);Ae||(O.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Ae=fe.unit.subarray()),$.splice(ae,0,{unit:Ae,pts:Me}),te+=U,ae++}}fe.pts=te,te+=U}for(var we=null,Re=null,ke,_e=0,Be=$.length;Be--;)_e+=$[Be].unit.byteLength;for(var Ke=0,We=$.length;Ke<We;Ke++){var Ue=$[Ke],Ze=Ue.unit,Ce=Ue.pts;if(Re!==null){var qe=z[Ke-1];qe.duration=Math.round((Ce-Re)/k)}else if(f&&l.segmentCodec==="aac"&&(Ce=q),we=Ce,_e>0){_e+=Z;try{ke=new Uint8Array(_e)}catch{this.observer.emit(C.Events.ERROR,C.Events.ERROR,{type:b.ErrorTypes.MUX_ERROR,details:b.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:_e,reason:"fail allocating audio mdat "+_e});return}if(!G){var Oe=new DataView(ke.buffer);Oe.setUint32(0,_e),ke.set(L.default.types.mdat,4)}}else return;ke.set(Ze,Z);var Pe=Ze.byteLength;Z+=Pe,z.push(new r(!0,B,Pe,0)),Re=Ce}var Ve=z.length;if(!!Ve){var Ie=z[z.length-1];this.nextAudioPts=q=Re+k*Ie.duration;var Le=G?new Uint8Array(0):L.default.moof(l.sequenceNumber++,we/k,T({},l,{samples:z}));l.samples=[];var rt=we/x,je=q/x,st="audio",vt={data1:Le,data2:ke,startPTS:rt,endPTS:je,startDTS:rt,endDTS:je,type:st,hasAudio:!0,hasVideo:!1,nb:Ve};return this.isAudioContiguous=!0,console.assert(ke.length,"MDAT length must not be zero"),vt}},t.remuxEmptyAudio=function(l,a,f,h){var S=l.inputTimeScale,x=l.samplerate?l.samplerate:S,P=S/x,k=this.nextAudioPts,B=(k!==null?k:h.startDTS*S)+this._initDTS,U=h.endDTS*S+this._initDTS,W=P*E,G=Math.ceil((U-B)/W),z=_.default.getSilentFrame(l.manifestCodec||l.codec,l.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=[],$=0;$<G;$++){var Z=B+$*W;Y.push({unit:z,pts:Z,dts:Z})}return l.samples=Y,this.remuxAudio(l,a,f,!1)},d}();function s(d,t){var n;if(t===null)return d;for(t<d?n=-8589934592:n=8589934592;Math.abs(d-t)>4294967296;)d+=n;return d}function c(d){for(var t=0;t<d.length;t++)if(d[t].key)return t;return-1}function v(d,t,n,l){var a=d.samples.length;if(!!a){for(var f=d.inputTimeScale,h=0;h<a;h++){var S=d.samples[h];S.pts=s(S.pts-n,t*f)/f,S.dts=s(S.dts-l,t*f)/f}var x=d.samples;return d.samples=[],{samples:x}}}function i(d,t,n){var l=d.samples.length;if(!!l){for(var a=d.inputTimeScale,f=0;f<l;f++){var h=d.samples[f];h.pts=s(h.pts-n,t*a)/a}d.samples.sort(function(x,P){return x.pts-P.pts});var S=d.samples;return d.samples=[],{samples:S}}}var r=function(t,n,l,a){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=n,this.size=l,this.cts=a,this.flags=new o(t)},o=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(j,R,m){"use strict";m.r(R);var M=m("./src/polyfills/number.ts"),_=m("./src/remux/mp4-remuxer.ts"),L=m("./src/utils/mp4-tools.ts"),C=m("./src/loader/fragment.ts"),b=m("./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,g,p){this.audioCodec=g,this.videoCodec=p,this.generateInitSegment(E),this.emitInitSegment=!0},T.generateInitSegment=function(E){var g=this.audioCodec,p=this.videoCodec;if(!E||!E.byteLength){this.initTracks=void 0,this.initData=void 0;return}var u=this.initData=Object(L.parseInitSegment)(E);g||(g=A(u.audio,C.ElementaryStreamTypes.AUDIO)),p||(p=A(u.video,C.ElementaryStreamTypes.VIDEO));var e={};u.audio&&u.video?e.audiovideo={container:"video/mp4",codec:g+","+p,initSegment:E,id:"main"}:u.audio?e.audio={container:"audio/mp4",codec:g,initSegment:E,id:"audio"}:u.video?e.video={container:"video/mp4",codec:p,initSegment:E,id:"main"}:b.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},T.remux=function(E,g,p,u,e){var s,c=this.initPTS,v=this.lastEndTime,i={audio:void 0,video:void 0,text:u,id3:p,initSegment:void 0};Object(M.isFiniteNumber)(v)||(v=this.lastEndTime=e||0);var r=g.samples;if(!r||!r.length)return i;var o={initPTS:void 0,timescale:1},d=this.initData;if((!d||!d.length)&&(this.generateInitSegment(r),d=this.initData),!d||!d.length)return b.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(o.tracks=this.initTracks,this.emitInitSegment=!1);var t=Object(L.getStartDTS)(d,r);Object(M.isFiniteNumber)(c)||(this.initPTS=o.initPTS=c=t-e);var n=Object(L.getDuration)(r,d),l=E?t-c:v,a=l+n;Object(L.offsetStartDTS)(d,r,c),n>0?this.lastEndTime=a:(b.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var f=!!d.audio,h=!!d.video,S="";f&&(S+="audio"),h&&(S+="video");var x={data1:r,startPTS:l,startDTS:l,endPTS:a,endDTS:a,type:S,hasAudio:f,hasVideo:h,nb:1,dropped:0};i.audio=x.type==="audio"?x:void 0,i.video=x.type!=="audio"?x:void 0,i.initSegment=o;var P=(s=this.initPTS)!=null?s:0;return i.id3=Object(_.flushTextTrackMetadataCueSamples)(p,e,P,P),u.samples.length&&(i.text=Object(_.flushTextTrackUserdataCueSamples)(u,e,P)),i},y}();function A(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===C.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}R.default=O},"./src/task-loop.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return M});var M=function(){function _(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var L=_.prototype;return L.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},L.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},L.onHandlerDestroyed=function(){},L.hasInterval=function(){return!!this._tickInterval},L.hasNextTick=function(){return!!this._tickTimer},L.setInterval=function(b){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,b),!0)},L.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},L.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},L.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},L.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},L.doTick=function(){},_}()},"./src/types/cmcd.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"CMCDVersion",function(){return M}),m.d(R,"CMCDObjectType",function(){return _}),m.d(R,"CMCDStreamingFormat",function(){return L}),m.d(R,"CMCDStreamType",function(){return C});var M=1,_;(function(b){b.MANIFEST="m",b.AUDIO="a",b.VIDEO="v",b.MUXED="av",b.INIT="i",b.CAPTION="c",b.TIMED_TEXT="tt",b.KEY="k",b.OTHER="o"})(_||(_={}));var L;(function(b){b.DASH="d",b.HLS="h",b.SMOOTH="s",b.OTHER="o"})(L||(L={}));var C;(function(b){b.VOD="v",b.LIVE="l"})(C||(C={}))},"./src/types/demuxer.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"MetadataSchema",function(){return M});var M;(function(_){_.audioId3="org.id3",_.dateRange="com.apple.quicktime.HLS",_.emsg="https://aomedia.org/emsg/ID3"})(M||(M={}))},"./src/types/level.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"HlsSkip",function(){return L}),m.d(R,"getSkipValue",function(){return C}),m.d(R,"HlsUrlParameters",function(){return b}),m.d(R,"Level",function(){return O});function M(A,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(A,D.key,D)}}function _(A,y,T){return y&&M(A.prototype,y),T&&M(A,T),Object.defineProperty(A,"prototype",{writable:!1}),A}var L;(function(A){A.No="",A.Yes="YES",A.v2="v2"})(L||(L={}));function C(A,y){var T=A.canSkipUntil,D=A.canSkipDateRanges,E=A.endSN,g=y!==void 0?y-E:0;return T&&g<T?D?L.v2:L.Yes:L.No}var b=function(){function A(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=A.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()},A}(),O=function(){function A(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 _(A,[{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)}}]),A}()},"./src/types/loader.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"PlaylistContextType",function(){return M}),m.d(R,"PlaylistLevelType",function(){return _});var M;(function(L){L.MANIFEST="manifest",L.LEVEL="level",L.AUDIO_TRACK="audioTrack",L.SUBTITLE_TRACK="subtitleTrack"})(M||(M={}));var _;(function(L){L.MAIN="main",L.AUDIO="audio",L.SUBTITLE="subtitle"})(_||(_={}))},"./src/types/transmuxer.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"ChunkMetadata",function(){return M});var M=function(C,b,O,A,y,T){A===void 0&&(A=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=_(),this.buffering={audio:_(),video:_(),audiovideo:_()},this.level=C,this.sn=b,this.id=O,this.size=A,this.part=y,this.partial=T};function _(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"AttrList",function(){return L});var M=/^(\d+)x(\d+)$/,_=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,L=function(){function C(O){typeof O=="string"&&(O=C.parseAttrList(O));for(var A in O)O.hasOwnProperty(A)&&(this[A]=O[A])}var b=C.prototype;return b.decimalInteger=function(A){var y=parseInt(this[A],10);return y>Number.MAX_SAFE_INTEGER?1/0:y},b.hexadecimalInteger=function(A){if(this[A]){var y=(this[A]||"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},b.hexadecimalIntegerAsNumber=function(A){var y=parseInt(this[A],16);return y>Number.MAX_SAFE_INTEGER?1/0:y},b.decimalFloatingPoint=function(A){return parseFloat(this[A])},b.optionalFloat=function(A,y){var T=this[A];return T?parseFloat(T):y},b.enumeratedString=function(A){return this[A]},b.bool=function(A){return this[A]==="YES"},b.decimalResolution=function(A){var y=M.exec(this[A]);if(y!==null)return{width:parseInt(y[1],10),height:parseInt(y[2],10)}},C.parseAttrList=function(A){var y,T={},D='"';for(_.lastIndex=0;(y=_.exec(A))!==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},C}()},"./src/utils/binary-search.ts":function(j,R,m){"use strict";m.r(R);var M={search:function(L,C){for(var b=0,O=L.length-1,A=null,y=null;b<=O;){A=(b+O)/2|0,y=L[A];var T=C(y);if(T>0)b=A+1;else if(T<0)O=A-1;else return y}return null}};R.default=M},"./src/utils/buffer-helper.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"BufferHelper",function(){return L});var M=m("./src/utils/logger.ts"),_={length:0,start:function(){return 0},end:function(){return 0}},L=function(){function C(){}return C.isBuffered=function(O,A){try{if(O){for(var y=C.getBuffered(O),T=0;T<y.length;T++)if(A>=y.start(T)&&A<=y.end(T))return!0}}catch{}return!1},C.bufferInfo=function(O,A,y){try{if(O){var T=C.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,A,y)}}catch{}return{len:0,start:A,end:A,nextStart:void 0}},C.bufferedInfo=function(O,A,y){A=Math.max(0,A),O.sort(function(r,o){var d=r.start-o.start;return d||o.end-r.end});var T=[];if(y)for(var D=0;D<O.length;D++){var E=T.length;if(E){var g=T[E-1].end;O[D].start-g<y?O[D].end>g&&(T[E-1].end=O[D].end):T.push(O[D])}else T.push(O[D])}else T=O;for(var p=0,u,e=A,s=A,c=0;c<T.length;c++){var v=T[c].start,i=T[c].end;if(A+y>=v&&A<i)e=v,s=i,p=s-A;else if(A+y<v){u=v;break}}return{len:p,start:e||0,end:s||0,nextStart:u}},C.getBuffered=function(O){try{return O.buffered}catch(A){return M.logger.log("failed to get media.buffered",A),_}},C}()},"./src/utils/cea-608-parser.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"Row",function(){return s}),m.d(R,"CaptionScreen",function(){return c});var M=m("./src/utils/logger.ts"),_={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},L=function(n){var l=n;return _.hasOwnProperty(n)&&(l=_[n]),String.fromCharCode(l)},C=15,b=100,O={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},A={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 g=function(){function t(){this.time=null,this.verboseLevel=E.ERROR}var n=t.prototype;return n.log=function(a,f){this.verboseLevel>=a&&M.logger.log(this.time+" ["+a+"] "+f)},t}(),p=function(n){for(var l=[],a=0;a<n.length;a++)l.push(n[a].toString(16));return l},u=function(){function t(l,a,f,h,S){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=l||"white",this.underline=a||!1,this.italics=f||!1,this.background=h||"black",this.flash=S||!1}var n=t.prototype;return n.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},n.setStyles=function(a){for(var f=["foreground","underline","italics","background","flash"],h=0;h<f.length;h++){var S=f[h];a.hasOwnProperty(S)&&(this[S]=a[S])}},n.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},n.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},n.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},n.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},t}(),e=function(){function t(l,a,f,h,S,x){this.uchar=void 0,this.penState=void 0,this.uchar=l||" ",this.penState=new u(a,f,h,S,x)}var n=t.prototype;return n.reset=function(){this.uchar=" ",this.penState.reset()},n.setChar=function(a,f){this.uchar=a,this.penState.copy(f)},n.setPenState=function(a){this.penState.copy(a)},n.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},n.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},n.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},t}(),s=function(){function t(l){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var a=0;a<b;a++)this.chars.push(new e);this.logger=l,this.pos=0,this.currPenState=new u}var n=t.prototype;return n.equals=function(a){for(var f=!0,h=0;h<b;h++)if(!this.chars[h].equals(a.chars[h])){f=!1;break}return f},n.copy=function(a){for(var f=0;f<b;f++)this.chars[f].copy(a.chars[f])},n.isEmpty=function(){for(var a=!0,f=0;f<b;f++)if(!this.chars[f].isEmpty()){a=!1;break}return a},n.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(E.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>b&&(this.logger.log(E.DEBUG,"Too large cursor position "+this.pos),this.pos=b)},n.moveCursor=function(a){var f=this.pos+a;if(a>1)for(var h=this.pos+1;h<f+1;h++)this.chars[h].setPenState(this.currPenState);this.setCursor(f)},n.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},n.insertChar=function(a){a>=144&&this.backSpace();var f=L(a);if(this.pos>=b){this.logger.log(E.ERROR,"Cannot insert "+a.toString(16)+" ("+f+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(f,this.currPenState),this.moveCursor(1)},n.clearFromPos=function(a){var f;for(f=a;f<b;f++)this.chars[f].reset()},n.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},n.clearToEndOfRow=function(){this.clearFromPos(this.pos)},n.getTextString=function(){for(var a=[],f=!0,h=0;h<b;h++){var S=this.chars[h].uchar;S!==" "&&(f=!1),a.push(S)}return f?"":a.join("")},n.setPenStyles=function(a){this.currPenState.setStyles(a);var f=this.chars[this.pos];f.setPenState(this.currPenState)},t}(),c=function(){function t(l){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var a=0;a<C;a++)this.rows.push(new s(l));this.logger=l,this.currRow=C-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var n=t.prototype;return n.reset=function(){for(var a=0;a<C;a++)this.rows[a].clear();this.currRow=C-1},n.equals=function(a){for(var f=!0,h=0;h<C;h++)if(!this.rows[h].equals(a.rows[h])){f=!1;break}return f},n.copy=function(a){for(var f=0;f<C;f++)this.rows[f].copy(a.rows[f])},n.isEmpty=function(){for(var a=!0,f=0;f<C;f++)if(!this.rows[f].isEmpty()){a=!1;break}return a},n.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},n.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},n.insertChar=function(a){var f=this.rows[this.currRow];f.insertChar(a)},n.setPen=function(a){var f=this.rows[this.currRow];f.setPenStyles(a)},n.moveCursor=function(a){var f=this.rows[this.currRow];f.moveCursor(a)},n.setCursor=function(a){this.logger.log(E.INFO,"setCursor: "+a);var f=this.rows[this.currRow];f.setCursor(a)},n.setPAC=function(a){this.logger.log(E.INFO,"pacData = "+JSON.stringify(a));var f=a.row-1;if(this.nrRollUpRows&&f<this.nrRollUpRows-1&&(f=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==f){for(var h=0;h<C;h++)this.rows[h].clear();var S=this.currRow+1-this.nrRollUpRows,x=this.lastOutputScreen;if(x){var P=x.rows[S].cueStartTime,k=this.logger.time;if(P&&k!==null&&P<k)for(var B=0;B<this.nrRollUpRows;B++)this.rows[f-this.nrRollUpRows+B+1].copy(x.rows[S+B])}}this.currRow=f;var U=this.rows[this.currRow];if(a.indent!==null){var W=a.indent,G=Math.max(W-1,0);U.setCursor(a.indent),a.color=U.chars[G].penState.foreground}var z={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(z)},n.setBkgData=function(a){this.logger.log(E.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},n.setRollUpRows=function(a){this.nrRollUpRows=a},n.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 a=this.currRow+1-this.nrRollUpRows,f=this.rows.splice(a,1)[0];f.clear(),this.rows.splice(this.currRow,0,f),this.logger.log(E.INFO,"Rolling up")},n.getDisplayText=function(a){a=a||!1;for(var f=[],h="",S=-1,x=0;x<C;x++){var P=this.rows[x].getTextString();P&&(S=x+1,a?f.push("Row "+S+": '"+P+"'"):f.push(P.trim()))}return f.length>0&&(a?h="["+f.join(" | ")+"]":h=f.join(`
20
- `)),h},n.getTextAndFormat=function(){return this.rows},t}(),v=function(){function t(l,a,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=l,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new c(f),this.nonDisplayedMemory=new c(f),this.lastOutputScreen=new c(f),this.currRollUpRow=this.displayedMemory.rows[C-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=f}var n=t.prototype;return n.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[C-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},n.getHandler=function(){return this.outputFilter},n.setHandler=function(a){this.outputFilter=a},n.setPAC=function(a){this.writeScreen.setPAC(a)},n.setBkgData=function(a){this.writeScreen.setBkgData(a)},n.setMode=function(a){a!==this.mode&&(this.mode=a,this.logger.log(E.INFO,"MODE="+a),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=a)},n.insertChars=function(a){for(var f=0;f<a.length;f++)this.writeScreen.insertChar(a[f]);var h=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(E.INFO,h+": "+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())},n.ccRCL=function(){this.logger.log(E.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},n.ccBS=function(){this.logger.log(E.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},n.ccAOF=function(){},n.ccAON=function(){},n.ccDER=function(){this.logger.log(E.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},n.ccRU=function(a){this.logger.log(E.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},n.ccFON=function(){this.logger.log(E.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},n.ccRDC=function(){this.logger.log(E.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},n.ccTR=function(){this.logger.log(E.INFO,"TR"),this.setMode("MODE_TEXT")},n.ccRTD=function(){this.logger.log(E.INFO,"RTD"),this.setMode("MODE_TEXT")},n.ccEDM=function(){this.logger.log(E.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},n.ccCR=function(){this.logger.log(E.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},n.ccENM=function(){this.logger.log(E.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},n.ccEOC=function(){if(this.logger.log(E.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var a=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=a,this.writeScreen=this.nonDisplayedMemory,this.logger.log(E.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},n.ccTO=function(a){this.logger.log(E.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},n.ccMIDROW=function(a){var f={flash:!1};if(f.underline=a%2===1,f.italics=a>=46,f.italics)f.foreground="white";else{var h=Math.floor(a/2)-16,S=["white","green","blue","cyan","red","yellow","magenta"];f.foreground=S[h]}this.logger.log(E.INFO,"MIDROW: "+JSON.stringify(f)),this.writeScreen.setPen(f)},n.outputDataUpdate=function(a){a===void 0&&(a=!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),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:f),this.lastOutputScreen.copy(this.displayedMemory))},n.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},t}(),i=function(){function t(l,a,f){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var h=new g;this.channels=[null,new v(l,a,h),new v(l+1,f,h)],this.cmdHistory=d(),this.logger=h}var n=t.prototype;return n.getHandler=function(a){return this.channels[a].getHandler()},n.setHandler=function(a,f){this.channels[a].setHandler(f)},n.addData=function(a,f){var h,S,x,P=!1;this.logger.time=a;for(var k=0;k<f.length;k+=2)if(S=f[k]&127,x=f[k+1]&127,!(S===0&&x===0)){if(this.logger.log(E.DATA,"["+p([f[k],f[k+1]])+"] -> ("+p([S,x])+")"),h=this.parseCmd(S,x),h||(h=this.parseMidrow(S,x)),h||(h=this.parsePAC(S,x)),h||(h=this.parseBackgroundAttributes(S,x)),!h&&(P=this.parseChars(S,x),P)){var B=this.currentChannel;if(B&&B>0){var U=this.channels[B];U.insertChars(P)}else this.logger.log(E.WARNING,"No channel found yet. TEXT-MODE?")}!h&&!P&&this.logger.log(E.WARNING,"Couldn't parse cleaned data "+p([S,x])+" orig: "+p([f[k],f[k+1]]))}},n.parseCmd=function(a,f){var h=this.cmdHistory,S=(a===20||a===28||a===21||a===29)&&f>=32&&f<=47,x=(a===23||a===31)&&f>=33&&f<=35;if(!(S||x))return!1;if(o(a,f,h))return r(null,null,h),this.logger.log(E.DEBUG,"Repeated command ("+p([a,f])+") is dropped"),!0;var P=a===20||a===21||a===23?1:2,k=this.channels[P];return a===20||a===21||a===28||a===29?f===32?k.ccRCL():f===33?k.ccBS():f===34?k.ccAOF():f===35?k.ccAON():f===36?k.ccDER():f===37?k.ccRU(2):f===38?k.ccRU(3):f===39?k.ccRU(4):f===40?k.ccFON():f===41?k.ccRDC():f===42?k.ccTR():f===43?k.ccRTD():f===44?k.ccEDM():f===45?k.ccCR():f===46?k.ccENM():f===47&&k.ccEOC():k.ccTO(f-32),r(a,f,h),this.currentChannel=P,!0},n.parseMidrow=function(a,f){var h=0;if((a===17||a===25)&&f>=32&&f<=47){if(a===17?h=1:h=2,h!==this.currentChannel)return this.logger.log(E.ERROR,"Mismatch channel in midrow parsing"),!1;var S=this.channels[h];return S?(S.ccMIDROW(f),this.logger.log(E.DEBUG,"MIDROW ("+p([a,f])+")"),!0):!1}return!1},n.parsePAC=function(a,f){var h,S=this.cmdHistory,x=(a>=17&&a<=23||a>=25&&a<=31)&&f>=64&&f<=127,P=(a===16||a===24)&&f>=64&&f<=95;if(!(x||P))return!1;if(o(a,f,S))return r(null,null,S),!0;var k=a<=23?1:2;f>=64&&f<=95?h=k===1?O[a]:y[a]:h=k===1?A[a]:T[a];var B=this.channels[k];return B?(B.setPAC(this.interpretPAC(h,f)),r(a,f,S),this.currentChannel=k,!0):!1},n.interpretPAC=function(a,f){var h,S={color:null,italics:!1,indent:null,underline:!1,row:a};return f>95?h=f-96:h=f-64,S.underline=(h&1)===1,h<=13?S.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(h/2)]:h<=15?(S.italics=!0,S.color="white"):S.indent=Math.floor((h-16)/2)*4,S},n.parseChars=function(a,f){var h,S=null,x=null;if(a>=25?(h=2,x=a-8):(h=1,x=a),x>=17&&x<=19){var P;x===17?P=f+80:x===18?P=f+112:P=f+144,this.logger.log(E.INFO,"Special char '"+L(P)+"' in channel "+h),S=[P]}else a>=32&&a<=127&&(S=f===0?[a]:[a,f]);if(S){var k=p(S);this.logger.log(E.DEBUG,"Char codes = "+k.join(",")),r(a,f,this.cmdHistory)}return S},n.parseBackgroundAttributes=function(a,f){var h=(a===16||a===24)&&f>=32&&f<=47,S=(a===23||a===31)&&f>=45&&f<=47;if(!(h||S))return!1;var x,P={};a===16||a===24?(x=Math.floor((f-32)/2),P.background=D[x],f%2===1&&(P.background=P.background+"_semi")):f===45?P.background="transparent":(P.foreground="black",f===47&&(P.underline=!0));var k=a<=23?1:2,B=this.channels[k];return B.setBkgData(P),r(a,f,this.cmdHistory),!0},n.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var f=this.channels[a];f&&f.reset()}this.cmdHistory=d()},n.cueSplitAtTime=function(a){for(var f=0;f<this.channels.length;f++){var h=this.channels[f];h&&h.cueSplitAtTime(a)}},t}();function r(t,n,l){l.a=t,l.b=n}function o(t,n,l){return l.a===t&&l.b===n}function d(){return{a:null,b:null}}R.default=i},"./src/utils/codecs.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"isCodecType",function(){return _}),m.d(R,"isCodecSupportedInMp4",function(){return L});var M={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 _(C,b){var O=M[b];return!!O&&O[C.slice(0,4)]===!0}function L(C,b){return MediaSource.isTypeSupported((b||"video")+'/mp4;codecs="'+C+'"')}},"./src/utils/cues.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/utils/vttparser.ts"),_=m("./src/utils/webvtt-parser.ts"),L=m("./src/utils/texttrack-utils.ts"),C=/\s/,b={newCue:function(A,y,T,D){for(var E=[],g,p,u,e,s,c=self.VTTCue||self.TextTrackCue,v=0;v<D.rows.length;v++)if(g=D.rows[v],u=!0,e=0,s="",!g.isEmpty()){for(var i=0;i<g.chars.length;i++)C.test(g.chars[i].uchar)&&u?e++:(s+=g.chars[i].uchar,u=!1);g.cueStartTime=y,y===T&&(T+=1e-4),e>=16?e--:e++;var r=Object(M.fixLineBreaks)(s.trim()),o=Object(_.generateCueId)(y,T,r);(!A||!A.cues||!A.cues.getCueById(o))&&(p=new c(y,T,r),p.id=o,p.line=v+1,p.align="left",p.position=10+Math.min(80,Math.floor(e*8/32)*10),E.push(p))}return A&&E.length&&(E.sort(function(d,t){return d.line==="auto"||t.line==="auto"?0:d.line>8&&t.line>8?t.line-d.line:d.line-t.line}),E.forEach(function(d){return Object(L.addCueToTrack)(A,d)})),E}};R.default=b},"./src/utils/discontinuities.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"findFirstFragWithCC",function(){return C}),m.d(R,"shouldAlignOnDiscontinuities",function(){return b}),m.d(R,"findDiscontinuousReferenceFrag",function(){return O}),m.d(R,"adjustSlidingStart",function(){return y}),m.d(R,"alignStream",function(){return T}),m.d(R,"alignPDT",function(){return E}),m.d(R,"alignFragmentByPDTDelta",function(){return g}),m.d(R,"alignMediaPlaylistByPDT",function(){return p});var M=m("./src/polyfills/number.ts"),_=m("./src/utils/logger.ts"),L=m("./src/controller/level-helper.ts");function C(u,e){for(var s=null,c=0,v=u.length;c<v;c++){var i=u[c];if(i&&i.cc===e){s=i;break}}return s}function b(u,e,s){return!!(e.details&&(s.endCC>s.startCC||u&&u.cc<s.startCC))}function O(u,e){var s=u.fragments,c=e.fragments;if(!c.length||!s.length){_.logger.log("No fragments to align");return}var v=C(s,c[0].cc);if(!v||v&&!v.startPTS){_.logger.log("No frag in previous level to align on");return}return v}function A(u,e){if(u){var s=u.start+e;u.start=u.startPTS=s,u.endPTS=s+u.duration}}function y(u,e){for(var s=e.fragments,c=0,v=s.length;c<v;c++)A(s[c],u);e.fragmentHint&&A(e.fragmentHint,u),e.alignedSliding=!0}function T(u,e,s){!e||(D(u,s,e),!s.alignedSliding&&e.details&&E(s,e.details),!s.alignedSliding&&e.details&&!s.skippedSegments&&Object(L.adjustSliding)(e.details,s))}function D(u,e,s){if(b(u,s,e)){var c=O(s.details,e);c&&Object(M.isFiniteNumber)(c.start)&&(_.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),y(c.start,e))}}function E(u,e){if(!(!e.fragments.length||!u.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,c=u.fragments[0].programDateTime,v=(c-s)/1e3+e.fragments[0].start;v&&Object(M.isFiniteNumber)(v)&&(_.logger.log("Adjusting PTS using programDateTime delta "+(c-s)+"ms, sliding:"+v.toFixed(3)+" "+u.url+" "),y(v,u))}}function g(u,e){var s=u.programDateTime;if(!!s){var c=(s-e)/1e3;u.start=u.startPTS=c,u.endPTS=c+u.duration}}function p(u,e){if(!(!e.fragments.length||!u.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,c=e.fragments[0].start,v=s-c*1e3;u.fragments.forEach(function(i){g(i,v)}),u.fragmentHint&&g(u.fragmentHint,v),u.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/utils/ewma.ts"),_=function(){function L(b,O,A){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=A,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new M.default(b),this.fast_=new M.default(O)}var C=L.prototype;return C.update=function(O,A){var y=this.slow_,T=this.fast_;this.slow_.halfLife!==O&&(this.slow_=new M.default(O,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==A&&(this.fast_=new M.default(A,T.getEstimate(),T.getTotalWeight()))},C.sample=function(O,A){O=Math.max(O,this.minDelayMs_);var y=8*A,T=O/1e3,D=y/T;this.fast_.sample(T,D),this.slow_.sample(T,D)},C.canEstimate=function(){var O=this.fast_;return O&&O.getTotalWeight()>=this.minWeight_},C.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},C.destroy=function(){},L}();R.default=_},"./src/utils/ewma.ts":function(j,R,m){"use strict";m.r(R);var M=function(){function _(C,b,O){b===void 0&&(b=0),O===void 0&&(O=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=C,this.alpha_=C?Math.exp(Math.log(.5)/C):0,this.estimate_=b,this.totalWeight_=O}var L=_.prototype;return L.sample=function(b,O){var A=Math.pow(this.alpha_,b);this.estimate_=O*(1-A)+A*this.estimate_,this.totalWeight_+=b},L.getTotalWeight=function(){return this.totalWeight_},L.getEstimate=function(){if(this.alpha_){var b=1-Math.pow(this.alpha_,this.totalWeight_);if(b)return this.estimate_/b}return this.estimate_},_}();R.default=M},"./src/utils/fetch-loader.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"fetchSupported",function(){return g});var M=m("./src/polyfills/number.ts"),_=m("./src/loader/load-stats.ts"),L=m("./src/demux/chunk-cache.ts");function C(c,v){c.prototype=Object.create(v.prototype),c.prototype.constructor=c,T(c,v)}function b(c){var v=typeof Map=="function"?new Map:void 0;return b=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 v!="undefined"){if(v.has(r))return v.get(r);v.set(r,o)}function o(){return O(r,arguments,D(this).constructor)}return o.prototype=Object.create(r.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),T(o,r)},b(c)}function O(c,v,i){return A()?O=Reflect.construct.bind():O=function(o,d,t){var n=[null];n.push.apply(n,d);var l=Function.bind.apply(o,n),a=new l;return t&&T(a,t.prototype),a},O.apply(null,arguments)}function A(){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(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function T(c,v){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},T(c,v)}function D(c){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},D(c)}function E(){return E=Object.assign?Object.assign.bind():function(c){for(var v=1;v<arguments.length;v++){var i=arguments[v];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(c[r]=i[r])}return c},E.apply(this,arguments)}function g(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var p=function(){function c(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 _.LoadStats}var v=c.prototype;return v.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},v.abortInternal=function(){var r=this.response;(!r||!r.ok)&&(this.stats.aborted=!0,this.controller.abort())},v.abort=function(){var r;this.abortInternal(),(r=this.callbacks)!==null&&r!==void 0&&r.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},v.load=function(r,o,d){var t=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var l=u(r,this.controller.signal),a=d.onProgress,f=r.responseType==="arraybuffer",h=f?"byteLength":"length";this.context=r,this.config=o,this.callbacks=d,this.request=this.fetchSetup(r,l),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){t.abortInternal(),d.onTimeout(n,r,t.response)},o.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 s(P||"fetch, bad network response",x,S)}return n.loading.first=Math.max(self.performance.now(),n.loading.start),n.total=parseInt(S.headers.get("Content-Length")||"0"),a&&Object(M.isFiniteNumber)(o.highWaterMark)?t.loadProgressively(S,n,r,o.highWaterMark,a):f?S.arrayBuffer():S.text()}).then(function(S){var x=t.response;self.clearTimeout(t.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first),n.loaded=n.total=S[h];var P={url:x.url,data:S};a&&!Object(M.isFiniteNumber)(o.highWaterMark)&&a(n,r,S,x),d.onSuccess(P,n,r,x)}).catch(function(S){if(self.clearTimeout(t.requestTimeout),!n.aborted){var x=S&&S.code||0,P=S?S.message:null;d.onError({code:x,text:P},r,S?S.details:null)}})},v.getCacheAge=function(){var r=null;if(this.response){var o=this.response.headers.get("age");r=o?parseFloat(o):null}return r},v.loadProgressively=function(r,o,d,t,n){t===void 0&&(t=0);var l=new L.default,a=r.body.getReader(),f=function h(){return a.read().then(function(S){if(S.done)return l.dataLength&&n(o,d,l.flush(),r),Promise.resolve(new ArrayBuffer(0));var x=S.value,P=x.length;return o.loaded+=P,P<t||l.dataLength?(l.push(x),l.dataLength>=t&&n(o,d,l.flush(),r)):n(o,d,x,r),h()}).catch(function(){return Promise.reject()})};return f()},c}();function u(c,v){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:v,headers:new self.Headers(E({},c.headers))};return c.rangeEnd&&i.headers.set("Range","bytes="+c.rangeStart+"-"+String(c.rangeEnd-1)),i}function e(c,v){return new self.Request(c.url,v)}var s=function(c){C(v,c);function v(i,r,o){var d;return d=c.call(this,i)||this,d.code=void 0,d.details=void 0,d.code=r,d.details=o,d}return v}(b(Error));R.default=p},"./src/utils/imsc1-ttml-parser.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"IMSC1_CODEC",function(){return y}),m.d(R,"parseIMSC1",function(){return g});var M=m("./src/utils/mp4-tools.ts"),_=m("./src/utils/vttparser.ts"),L=m("./src/utils/vttcue.ts"),C=m("./src/demux/id3.ts"),b=m("./src/utils/timescale-conversion.ts"),O=m("./src/utils/webvtt-parser.ts");function A(){return A=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var l=arguments[n];for(var a in l)Object.prototype.hasOwnProperty.call(l,a)&&(t[a]=l[a])}return t},A.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 g(t,n,l,a,f){var h=Object(M.findBox)(new Uint8Array(t),["mdat"]);if(h.length===0){f(new Error("Could not parse IMSC1 mdat"));return}var S=h.map(function(P){return Object(C.utf8ArrayToStr)(P)}),x=Object(b.toTimescaleFromScale)(n,1,l);try{S.forEach(function(P){return a(p(P,x))})}catch(P){f(P)}}function p(t,n){var l=new DOMParser,a=l.parseFromString(t,"text/xml"),f=a.getElementsByTagName("tt")[0];if(!f)throw new Error("Invalid ttml");var h={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},S=Object.keys(h).reduce(function(U,W){return U[W]=f.getAttribute("ttp:"+W)||h[W],U},{}),x=f.getAttribute("xml:space")!=="preserve",P=e(u(f,"styling","style")),k=e(u(f,"layout","region")),B=u(f,"body","[begin]");return[].map.call(B,function(U){var W=s(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 $=new L.default(G-n,Y-n,W);$.id=Object(O.generateCueId)($.startTime,$.endTime,$.text);var Z=k[U.getAttribute("region")],q=P[U.getAttribute("style")];$.position=10,$.size=80;var ie=c(Z,q,P),ne=ie.textAlign;if(ne){var ae=E[ne];ae&&($.lineAlign=ae),$.align=ne}return A($,ie),$}).filter(function(U){return U!==null})}function u(t,n,l){var a=t.getElementsByTagName(n)[0];return a?[].slice.call(a.querySelectorAll(l)):[]}function e(t){return t.reduce(function(n,l){var a=l.getAttribute("xml:id");return a&&(n[a]=l),n},{})}function s(t,n){return[].slice.call(t.childNodes).reduce(function(l,a,f){var h;return a.nodeName==="br"&&f?l+`
21
- `:(h=a.childNodes)!==null&&h!==void 0&&h.length?s(a,n):n?l+a.textContent.trim().replace(/\s+/g," "):l+a.textContent},"")}function c(t,n,l){var a="http://www.w3.org/ns/ttml#styling",f=null,h=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],S=t!=null&&t.hasAttribute("style")?t.getAttribute("style"):null;return S&&l.hasOwnProperty(S)&&(f=l[S]),h.reduce(function(x,P){var k=v(n,a,P)||v(t,a,P)||v(f,a,P);return k&&(x[P]=k),x},{})}function v(t,n,l){return t&&t.hasAttributeNS(n,l)?t.getAttributeNS(n,l):null}function i(t){return new Error("Could not parse ttml timestamp "+t)}function r(t,n){if(!t)return null;var l=Object(_.parseTimeStamp)(t);return l===null&&(T.test(t)?l=o(t,n):D.test(t)&&(l=d(t,n))),l}function o(t,n){var l=T.exec(t),a=(l[4]|0)+(l[5]|0)/n.subFrameRate;return(l[1]|0)*3600+(l[2]|0)*60+(l[3]|0)+a/n.frameRate}function d(t,n){var l=D.exec(t),a=Number(l[1]),f=l[2];switch(f){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/n.frameRate;case"t":return a/n.tickRate}return a}},"./src/utils/logger.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"enableLogs",function(){return O}),m.d(R,"logger",function(){return A});var M=function(){},_={trace:M,debug:M,log:M,warn:M,info:M,error:M},L=_;function C(y){var T=self.console[y];return T?T.bind(self.console,"["+y+"] >"):M}function b(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(g){L[g]=y[g]?y[g].bind(y):C(g)})}function O(y){if(self.console&&y===!0||typeof y=="object"){b(y,"debug","log","info","warn","error");try{L.log()}catch{L=_}}else L=_}var A=L},"./src/utils/mediakeys-helper.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"KeySystems",function(){return M}),m.d(R,"requestMediaKeySystemAccess",function(){return _});var M;(function(L){L.WIDEVINE="com.widevine.alpha",L.PLAYREADY="com.microsoft.playready"})(M||(M={}));var _=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"getMediaSource",function(){return M});function M(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"RemuxerTrackIdConfig",function(){return O}),m.d(R,"bin2str",function(){return A}),m.d(R,"readUint16",function(){return y}),m.d(R,"readUint32",function(){return T}),m.d(R,"readSint32",function(){return D}),m.d(R,"writeUint32",function(){return E}),m.d(R,"findBox",function(){return g}),m.d(R,"parseSegmentIndex",function(){return p}),m.d(R,"parseInitSegment",function(){return u}),m.d(R,"getStartDTS",function(){return e}),m.d(R,"getDuration",function(){return s}),m.d(R,"computeRawDurationFromSamples",function(){return c}),m.d(R,"offsetStartDTS",function(){return v}),m.d(R,"segmentValidRange",function(){return i}),m.d(R,"appendUint8Array",function(){return r}),m.d(R,"parseSamples",function(){return o}),m.d(R,"parseSEIMessageFromNALu",function(){return n}),m.d(R,"parseEmsg",function(){return a});var M=m("./src/utils/typed-array.ts"),_=m("./src/loader/fragment.ts"),L=m("./src/demux/id3.ts"),C=Math.pow(2,32)-1,b=[].push,O={video:1,audio:2,id3:3,text:4};function A(f){return String.fromCharCode.apply(null,f)}function y(f,h){var S=f[h]<<8|f[h+1];return S<0?65536+S:S}function T(f,h){var S=D(f,h);return S<0?4294967296+S:S}function D(f,h){return f[h]<<24|f[h+1]<<16|f[h+2]<<8|f[h+3]}function E(f,h,S){f[h]=S>>24,f[h+1]=S>>16&255,f[h+2]=S>>8&255,f[h+3]=S&255}function g(f,h){var S=[];if(!h.length)return S;for(var x=f.byteLength,P=0;P<x;){var k=T(f,P),B=A(f.subarray(P+4,P+8)),U=k>1?P+k:x;if(B===h[0])if(h.length===1)S.push(f.subarray(P+8,U));else{var W=g(f.subarray(P+8,U),h.slice(1));W.length&&b.apply(S,W)}P=U}return S}function p(f){var h=[],S=f[0],x=8,P=T(f,x);x+=4;var k=0,B=0;S===0?x+=8:x+=16,x+=2;var U=f.length+B,W=y(f,x);x+=2;for(var G=0;G<W;G++){var z=x,Y=T(f,z);z+=4;var $=Y&2147483647,Z=(Y&2147483648)>>>31;if(Z===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var q=T(f,z);z+=4,h.push({referenceSize:$,subsegmentDuration:q,info:{duration:q/P,start:U,end:U+$-1}}),U+=$,z+=4,x=z}return{earliestPresentationTime:k,timescale:P,version:S,referencesCount:W,references:h}}function u(f){for(var h=[],S=g(f,["moov","trak"]),x=0;x<S.length;x++){var P=S[x],k=g(P,["tkhd"])[0];if(k){var B=k[0],U=B===0?12:20,W=T(k,U),G=g(P,["mdia","mdhd"])[0];if(G){B=G[0],U=B===0?12:20;var z=T(G,U),Y=g(P,["mdia","hdlr"])[0];if(Y){var $=A(Y.subarray(8,12)),Z={soun:_.ElementaryStreamTypes.AUDIO,vide:_.ElementaryStreamTypes.VIDEO}[$];if(Z){var q=g(P,["mdia","minf","stbl","stsd"])[0],ie=void 0;q&&(ie=A(q.subarray(12,16))),h[W]={timescale:z,type:Z},h[Z]={timescale:z,id:W,codec:ie}}}}}}var ne=g(f,["moov","mvex","trex"]);return ne.forEach(function(ae){var te=T(ae,4),fe=h[te];fe&&(fe.default={duration:T(ae,12),flags:T(ae,20)})}),h}function e(f,h){return g(h,["moof","traf"]).reduce(function(S,x){var P=g(x,["tfdt"])[0],k=P[0],B=g(x,["tfhd"]).reduce(function(U,W){var G=T(W,4),z=f[G];if(z){var Y=T(P,4);k===1&&(Y*=Math.pow(2,32),Y+=T(P,8));var $=z.timescale||9e4,Z=Y/$;if(isFinite(Z)&&(U===null||Z<U))return Z}return U},null);return B!==null&&isFinite(B)&&(S===null||B<S)?B:S},null)||0}function s(f,h){for(var S=0,x=0,P=0,k=g(f,["moof","traf"]),B=0;B<k.length;B++){var U=k[B],W=g(U,["tfhd"])[0],G=T(W,4),z=h[G];if(!!z){var Y=z.default,$=T(W,0)|(Y==null?void 0:Y.flags),Z=Y==null?void 0:Y.duration;$&8&&($&2?Z=T(W,12):Z=T(W,8));for(var q=z.timescale||9e4,ie=g(U,["trun"]),ne=0;ne<ie.length;ne++){if(S=c(ie[ne]),!S&&Z){var ae=T(ie[ne],4);S=Z*ae}z.type===_.ElementaryStreamTypes.VIDEO?x+=S/q:z.type===_.ElementaryStreamTypes.AUDIO&&(P+=S/q)}}}if(x===0&&P===0){for(var te=0,fe=g(f,["sidx"]),de=0;de<fe.length;de++){var re=p(fe[de]);re!=null&&re.references&&(te+=re.references.reduce(function(Ee,me){return Ee+me.info.duration||0},0))}return te}return x||P}function c(f){var h=T(f,0),S=8;h&1&&(S+=4),h&4&&(S+=4);for(var x=0,P=T(f,4),k=0;k<P;k++){if(h&256){var B=T(f,S);x+=B,S+=4}h&512&&(S+=4),h&1024&&(S+=4),h&2048&&(S+=4)}return x}function v(f,h,S){g(h,["moof","traf"]).forEach(function(x){g(x,["tfhd"]).forEach(function(P){var k=T(P,4),B=f[k];if(!!B){var U=B.timescale||9e4;g(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/(C+1)),$=Math.floor(z%(C+1));E(W,4,Y),E(W,8,$)}})}})})}function i(f){var h={valid:null,remainder:null},S=g(f,["moof"]);if(S){if(S.length<2)return h.remainder=f,h}else return h;var x=S[S.length-1];return h.valid=Object(M.sliceUint8)(f,0,x.byteOffset-8),h.remainder=Object(M.sliceUint8)(f,x.byteOffset-8),h}function r(f,h){var S=new Uint8Array(f.length+h.length);return S.set(f),S.set(h,f.length),S}function o(f,h){var S=[],x=h.samples,P=h.timescale,k=h.id,B=!1,U=g(x,["moof"]);return U.map(function(W){var G=W.byteOffset-8,z=g(W,["traf"]);z.map(function(Y){var $=g(Y,["tfdt"]).map(function(Z){var q=Z[0],ie=T(Z,4);return q===1&&(ie*=Math.pow(2,32),ie+=T(Z,8)),ie/P})[0];return $!==void 0&&(f=$),g(Y,["tfhd"]).map(function(Z){var q=T(Z,4),ie=T(Z,0)&16777215,ne=(ie&1)!==0,ae=(ie&2)!==0,te=(ie&8)!==0,fe=0,de=(ie&16)!==0,re=0,Ee=(ie&32)!==0,me=8;q===k&&(ne&&(me+=8),ae&&(me+=4),te&&(fe=T(Z,me),me+=4),de&&(re=T(Z,me),me+=4),Ee&&(me+=4),h.type==="video"&&(B=d(h.codec)),g(Y,["trun"]).map(function(Te){var Me=Te[0],Ae=T(Te,0)&16777215,we=(Ae&1)!==0,Re=0,ke=(Ae&4)!==0,_e=(Ae&256)!==0,Be=0,Ke=(Ae&512)!==0,We=0,Ue=(Ae&1024)!==0,Ze=(Ae&2048)!==0,Ce=0,qe=T(Te,4),Oe=8;we&&(Re=T(Te,Oe),Oe+=4),ke&&(Oe+=4);for(var Pe=Re+G,Ve=0;Ve<qe;Ve++){if(_e?(Be=T(Te,Oe),Oe+=4):Be=fe,Ke?(We=T(Te,Oe),Oe+=4):We=re,Ue&&(Oe+=4),Ze&&(Me===0?Ce=T(Te,Oe):Ce=D(Te,Oe),Oe+=4),h.type===_.ElementaryStreamTypes.VIDEO)for(var Ie=0;Ie<We;){var Le=T(x,Pe);Pe+=4;var rt=x[Pe]&31;if(t(B,rt)){var je=x.subarray(Pe,Pe+Le);n(je,f+Ce/P,S)}Pe+=Le,Ie+=Le+4}f+=Be/P}}))})})}),S}function d(f){if(!f)return!1;var h=f.indexOf("."),S=h<0?f:f.substring(0,h);return S==="hvc1"||S==="hev1"||S==="dvh1"||S==="dvhe"}function t(f,h){return f?h===39||h===40:h===6}function n(f,h,S){var x=l(f),P=0;P++;for(var k=0,B=0,U=!1,W=0;P<x.length;){k=0;do{if(P>=x.length)break;W=x[P++],k+=W}while(W===255);B=0;do{if(P>=x.length)break;W=x[P++],B+=W}while(W===255);var G=x.length-P;if(!U&&k===4&&P<x.length){U=!0;var z=x[P++];if(z===181){var Y=y(x,P);if(P+=2,Y===49){var $=T(x,P);if(P+=4,$===1195456820){var Z=x[P++];if(Z===3){var q=x[P++],ie=31&q,ne=64&q,ae=ne?2+ie*3:0,te=new Uint8Array(ae);if(ne){te[0]=q;for(var fe=1;fe<ae;fe++)te[fe]=x[P++]}S.push({type:Z,payloadType:k,pts:h,bytes:te})}}}}}else if(k===5&&B<G){if(U=!0,B>16){for(var de=[],re=0;re<16;re++){var Ee=x[P++].toString(16);de.push(Ee.length==1?"0"+Ee:Ee),(re===3||re===5||re===7||re===9)&&de.push("-")}for(var me=B-16,Te=new Uint8Array(me),Me=0;Me<me;Me++)Te[Me]=x[P++];S.push({payloadType:k,pts:h,uuid:de.join(""),userData:Object(L.utf8ArrayToStr)(Te),userDataBytes:Te})}}else if(B<G)P+=B;else if(B>G)break}}function l(f){for(var h=f.byteLength,S=[],x=1;x<h-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 P=h-S.length,k=new Uint8Array(P),B=0;for(x=0;x<P;B++,x++)B===S[0]&&(B++,S.shift()),k[x]=f[B];return k}function a(f){var h=f[0],S="",x="",P=0,k=0,B=0,U=0,W=0,G=0;if(h===0){for(;A(f.subarray(G,G+1))!=="\0";)S+=A(f.subarray(G,G+1)),G+=1;for(S+=A(f.subarray(G,G+1)),G+=1;A(f.subarray(G,G+1))!=="\0";)x+=A(f.subarray(G,G+1)),G+=1;x+=A(f.subarray(G,G+1)),G+=1,P=T(f,12),k=T(f,16),U=T(f,20),W=T(f,24),G=28}else if(h===1){G+=4,P=T(f,G),G+=4;var z=T(f,G);G+=4;var Y=T(f,G);for(G+=4,B=Math.pow(2,32)*z+Y,Number.isSafeInteger(B)||(B=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;A(f.subarray(G,G+1))!=="\0";)S+=A(f.subarray(G,G+1)),G+=1;for(S+=A(f.subarray(G,G+1)),G+=1;A(f.subarray(G,G+1))!=="\0";)x+=A(f.subarray(G,G+1)),G+=1;x+=A(f.subarray(G,G+1)),G+=1}var $=f.subarray(G,f.byteLength);return{schemeIdUri:S,value:x,timeScale:P,presentationTime:B,presentationTimeDelta:k,eventDuration:U,id:W,payload:$}}},"./src/utils/output-filter.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return M});var M=function(){function _(C,b){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=C,this.trackName=b}var L=_.prototype;return L.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},L.newCue=function(b,O,A){(this.startTime===null||this.startTime>b)&&(this.startTime=b),this.endTime=O,this.screen=A,this.timelineController.createCaptionsTrack(this.trackName)},L.reset=function(){this.cueRanges=[],this.startTime=null},_}()},"./src/utils/texttrack-utils.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"sendAddTrackEvent",function(){return _}),m.d(R,"addCueToTrack",function(){return L}),m.d(R,"clearCurrentCues",function(){return C}),m.d(R,"removeCuesInRange",function(){return b}),m.d(R,"getCuesInRange",function(){return A});var M=m("./src/utils/logger.ts");function _(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 L(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(g){M.logger.debug("[texttrack-utils]: "+g);var E=new self.TextTrackCue(T.startTime,T.endTime,T.text);E.id=T.id,y.addCue(E)}D==="disabled"&&(y.mode=D)}function C(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 b(y,T,D,E){var g=y.mode;if(g==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var p=A(y.cues,T,D),u=0;u<p.length;u++)(!E||E(p[u]))&&y.removeCue(p[u]);g==="disabled"&&(y.mode=g)}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,g=D;E<=g;){var p=Math.floor((g+E)/2);if(T<y[p].startTime)g=p-1;else if(T>y[p].startTime&&E<D)E=p+1;else return p}return y[E].startTime-T<T-y[g].startTime?E:g}function A(y,T,D){var E=[],g=O(y,T);if(g>-1)for(var p=g,u=y.length;p<u;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(j,R,m){"use strict";m.r(R);var M={toString:function(L){for(var C="",b=L.length,O=0;O<b;O++)C+="["+L.start(O).toFixed(3)+","+L.end(O).toFixed(3)+"]";return C}};R.default=M},"./src/utils/timescale-conversion.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"toTimescaleFromBase",function(){return _}),m.d(R,"toTimescaleFromScale",function(){return L}),m.d(R,"toMsFromMpegTsClock",function(){return C}),m.d(R,"toMpegTsClockFromTimescale",function(){return b});var M=9e4;function _(O,A,y,T){y===void 0&&(y=1),T===void 0&&(T=!1);var D=O*A*y;return T?Math.round(D):D}function L(O,A,y,T){return y===void 0&&(y=1),T===void 0&&(T=!1),_(O,A,1/y,T)}function C(O,A){return A===void 0&&(A=!1),_(O,1e3,1/M,A)}function b(O,A){return A===void 0&&(A=1),_(O,M,1/A)}},"./src/utils/typed-array.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"sliceUint8",function(){return M});function M(_,L,C){return Uint8Array.prototype.slice?_.slice(L,C):new Uint8Array(Array.prototype.slice.call(_,L,C))}},"./src/utils/vttcue.ts":function(j,R,m){"use strict";m.r(R),R.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var M=["","lr","rl"],_=["start","middle","end","left","right"];function L(y,T){if(typeof T!="string"||!Array.isArray(y))return!1;var D=T.toLowerCase();return~y.indexOf(D)?D:!1}function C(y){return L(M,y)}function b(y){return 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 g=1;g<arguments.length;g++){var p=arguments[g];for(var u in p)y[u]=p[u]}return y}function A(y,T,D){var E=this,g={enumerable:!0};E.hasBeenReset=!1;var p="",u=!1,e=y,s=T,c=D,v=null,i="",r=!0,o="auto",d="start",t=50,n="middle",l=50,a="middle";Object.defineProperty(E,"id",O({},g,{get:function(){return p},set:function(h){p=""+h}})),Object.defineProperty(E,"pauseOnExit",O({},g,{get:function(){return u},set:function(h){u=!!h}})),Object.defineProperty(E,"startTime",O({},g,{get:function(){return e},set:function(h){if(typeof h!="number")throw new TypeError("Start time must be set to a number.");e=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"endTime",O({},g,{get:function(){return s},set:function(h){if(typeof h!="number")throw new TypeError("End time must be set to a number.");s=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"text",O({},g,{get:function(){return c},set:function(h){c=""+h,this.hasBeenReset=!0}})),Object.defineProperty(E,"region",O({},g,{get:function(){return v},set:function(h){v=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"vertical",O({},g,{get:function(){return i},set:function(h){var S=C(h);if(S===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"snapToLines",O({},g,{get:function(){return r},set:function(h){r=!!h,this.hasBeenReset=!0}})),Object.defineProperty(E,"line",O({},g,{get:function(){return o},set:function(h){if(typeof h!="number"&&h!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");o=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"lineAlign",O({},g,{get:function(){return d},set:function(h){var S=b(h);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");d=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"position",O({},g,{get:function(){return t},set:function(h){if(h<0||h>100)throw new Error("Position must be between 0 and 100.");t=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"positionAlign",O({},g,{get:function(){return n},set:function(h){var S=b(h);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");n=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"size",O({},g,{get:function(){return l},set:function(h){if(h<0||h>100)throw new Error("Size must be between 0 and 100.");l=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"align",O({},g,{get:function(){return a},set:function(h){var S=b(h);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");a=S,this.hasBeenReset=!0}})),E.displayState=void 0}return A.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},A}()},"./src/utils/vttparser.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"parseTimeStamp",function(){return L}),m.d(R,"fixLineBreaks",function(){return T}),m.d(R,"VTTParser",function(){return D});var M=m("./src/utils/vttcue.ts"),_=function(){function E(){}var g=E.prototype;return g.decode=function(u,e){if(!u)return"";if(typeof u!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(u))},E}();function L(E){function g(u,e,s,c){return(u|0)*3600+(e|0)*60+(s|0)+parseFloat(c||0)}var p=E.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return p?parseFloat(p[2])>59?g(p[2],p[3],0,p[4]):g(p[1],p[2],p[3],p[4]):null}var C=function(){function E(){this.values=Object.create(null)}var g=E.prototype;return g.set=function(u,e){!this.get(u)&&e!==""&&(this.values[u]=e)},g.get=function(u,e,s){return s?this.has(u)?this.values[u]:e[s]:this.has(u)?this.values[u]:e},g.has=function(u){return u in this.values},g.alt=function(u,e,s){for(var c=0;c<s.length;++c)if(e===s[c]){this.set(u,e);break}},g.integer=function(u,e){/^-?\d+$/.test(e)&&this.set(u,parseInt(e,10))},g.percent=function(u,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var s=parseFloat(e);if(s>=0&&s<=100)return this.set(u,s),!0}return!1},E}();function b(E,g,p,u){var e=u?E.split(u):[E];for(var s in e)if(typeof e[s]=="string"){var c=e[s].split(p);if(c.length===2){var v=c[0],i=c[1];g(v,i)}}}var O=new M.default(0,0,""),A=O.align==="middle"?"middle":"center";function y(E,g,p){var u=E;function e(){var v=L(E);if(v===null)throw new Error("Malformed timestamp: "+u);return E=E.replace(/^[^\sa-zA-Z-]+/,""),v}function s(v,i){var r=new C;b(v,function(t,n){var l;switch(t){case"region":for(var a=p.length-1;a>=0;a--)if(p[a].id===n){r.set(t,p[a].region);break}break;case"vertical":r.alt(t,n,["rl","lr"]);break;case"line":l=n.split(","),r.integer(t,l[0]),r.percent(t,l[0])&&r.set("snapToLines",!1),r.alt(t,l[0],["auto"]),l.length===2&&r.alt("lineAlign",l[1],["start",A,"end"]);break;case"position":l=n.split(","),r.percent(t,l[0]),l.length===2&&r.alt("positionAlign",l[1],["start",A,"end","line-left","line-right","auto"]);break;case"size":r.percent(t,n);break;case"align":r.alt(t,n,["start",A,"end","left","right"]);break}},/:/,/\s/),i.region=r.get("region",null),i.vertical=r.get("vertical","");var o=r.get("line","auto");o==="auto"&&O.line===-1&&(o=-1),i.line=o,i.lineAlign=r.get("lineAlign","start"),i.snapToLines=r.get("snapToLines",!0),i.size=r.get("size",100),i.align=r.get("align",A);var d=r.get("position","auto");d==="auto"&&O.position===50&&(d=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50),i.position=d}function c(){E=E.replace(/^\s+/,"")}if(c(),g.startTime=e(),c(),E.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+u);E=E.slice(3),c(),g.endTime=e(),c(),s(E,g)}function T(E){return E.replace(/<br(?: \/)?>/gi,`
22
- `)}var D=function(){function E(){this.state="INITIAL",this.buffer="",this.decoder=new _,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var g=E.prototype;return g.parse=function(u){var e=this;u&&(e.buffer+=e.decoder.decode(u,{stream:!0}));function s(){var d=e.buffer,t=0;for(d=T(d);t<d.length&&d[t]!=="\r"&&d[t]!==`
23
- `;)++t;var n=d.slice(0,t);return d[t]==="\r"&&++t,d[t]===`
24
- `&&++t,e.buffer=d.slice(t),n}function c(d){b(d,function(t,n){},/:/)}try{var v="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;v=s();var i=v.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:v=s(),e.state){case"HEADER":/:/.test(v)?c(v):v||(e.state="ID");continue;case"NOTE":v||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(v)){e.state="NOTE";break}if(!v)continue;if(e.cue=new M.default(0,0,""),e.state="CUE",v.indexOf("-->")===-1){e.cue.id=v;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{y(v,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{var o=v.indexOf("-->")!==-1;if(!v||o&&(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+=v}continue;case"BADCUE":v||(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},g.flush=function(){var u=this;try{if((u.cue||u.state==="HEADER")&&(u.buffer+=`
1
+ "use strict";(()=>{var Wi=Object.create;var kr=Object.defineProperty;var Gi=Object.getOwnPropertyDescriptor;var Hi=Object.getOwnPropertyNames;var ji=Object.getPrototypeOf,Vi=Object.prototype.hasOwnProperty;var Fr=(J,ee)=>()=>(ee||J((ee={exports:{}}).exports,ee),ee.exports);var Yi=(J,ee,ie,se)=>{if(ee&&typeof ee=="object"||typeof ee=="function")for(let z of Hi(ee))!Vi.call(J,z)&&z!==ie&&kr(J,z,{get:()=>ee[z],enumerable:!(se=Gi(ee,z))||se.enumerable});return J};var zt=(J,ee,ie)=>(ie=J!=null?Wi(ji(J)):{},Yi(ee||!J||!J.__esModule?kr(ie,"default",{value:J,enumerable:!0}):ie,J));var Ur=Fr((Qt,hr)=>{(function(){var J,ee;J=this,ee=function(){return function(){var ie={80:function(N,T,C){N.exports=C(728).default},728:function(N,T,C){"use strict";C.d(T,{default:function(){return Ni}});var L=C(48),M=C.n(L),P=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(U){var O=16*Math.random()|0;return(U==="x"?O:3&O|8).toString(16)})},B=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},A=function(U){return U&&U.nodeName!==void 0?(U.muxId||(U.muxId=U.id||B()),U.muxId):U},D=function(U){var O;U&&U.nodeName!==void 0?U=A(O=U):O=document.querySelector(U);var w=O&&O.nodeName?O.nodeName.toLowerCase():"";return[O,U,w]},x=C(640),_=C.n(x),S=_().methodFactory;_().methodFactory=function(U,O,w){var W=S(U,O,w);return function(){for(var G=["[mux]"],X=0;X<arguments.length;X++)G.push(arguments[X]);W.apply(void 0,G)}},_().setLevel(_().getLevel());var d=_();function E(){return(M().doNotTrack||M().navigator&&M().navigator.doNotTrack)==="1"}var p={now:function(){var U=M().performance,O=U&&U.timing,w=O&&O.navigationStart,W=typeof w=="number"&&typeof U.now=="function"?w+U.now():Date.now();return Math.round(W)}},h=C(678),a=C.n(h),o=function(U){return n(U)[0]},n=function(U){if(typeof U!="string"||U==="")return["localhost"];var O,w=(U.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return w&&(O=(w.match(/[^\.]+\.[^\.]+$/)||[])[0]),[w,O]},v={exists:function(){var U=M().performance;return(U&&U.timing)!==void 0},domContentLoadedEventEnd:function(){var U=M().performance,O=U&&U.timing;return O&&O.domContentLoadedEventEnd},navigationStart:function(){var U=M().performance,O=U&&U.timing;return O&&O.navigationStart}};function l(U,O,w){w=w===void 0?1:w,U[O]=U[O]||0,U[O]+=w}var i=["x-cdn","content-type","x-request-id"];function u(U){var O={};return(U=U||"").trim().split(/[\r\n]+/).forEach(function(w){if(w){var W=w.split(": "),G=W.shift();G&&(i.indexOf(G.toLowerCase())>=0||G.toLowerCase().indexOf("x-litix-")===0)&&(O[G]=W.join(": "))}}),O}var g=function(U){var O={};for(var w in U){var W=U[w];W["DATA-ID"].search("io.litix.data.")!==-1&&(O[W["DATA-ID"].replace("io.litix.data.","")]=W.VALUE)}return O};function c(U,O){var w=Object.keys(U);if(Object.getOwnPropertySymbols){var W=Object.getOwnPropertySymbols(U);O&&(W=W.filter(function(G){return Object.getOwnPropertyDescriptor(U,G).enumerable})),w.push.apply(w,W)}return w}function m(U){for(var O=1;O<arguments.length;O++){var w=arguments[O]!=null?arguments[O]:{};O%2?c(Object(w),!0).forEach(function(W){e(U,W,w[W])}):Object.getOwnPropertyDescriptors?Object.defineProperties(U,Object.getOwnPropertyDescriptors(w)):c(Object(w)).forEach(function(W){Object.defineProperty(U,W,Object.getOwnPropertyDescriptor(w,W))})}return U}function e(U,O,w){return O in U?Object.defineProperty(U,O,{value:w,enumerable:!0,configurable:!0,writable:!0}):U[O]=w,U}var r=function(U){if(!U)return{};var O=v.navigationStart(),w=U.loading,W=w?w.start:U.trequest,G=w?w.first:U.tfirst,X=w?w.end:U.tload;return{bytesLoaded:U.total,requestStart:Math.round(O+W),responseStart:Math.round(O+G),responseEnd:Math.round(O+X)}},t=function(U){if(U&&typeof U.getAllResponseHeaders=="function")return u(U.getAllResponseHeaders())};function s(U,O){var w=Object.keys(U);if(Object.getOwnPropertySymbols){var W=Object.getOwnPropertySymbols(U);O&&(W=W.filter(function(G){return Object.getOwnPropertyDescriptor(U,G).enumerable})),w.push.apply(w,W)}return w}function y(U){for(var O=1;O<arguments.length;O++){var w=arguments[O]!=null?arguments[O]:{};O%2?s(Object(w),!0).forEach(function(W){f(U,W,w[W])}):Object.getOwnPropertyDescriptors?Object.defineProperties(U,Object.getOwnPropertyDescriptors(w)):s(Object(w)).forEach(function(W){Object.defineProperty(U,W,Object.getOwnPropertyDescriptor(w,W))})}return U}function f(U,O,w){return O in U?Object.defineProperty(U,O,{value:w,enumerable:!0,configurable:!0,writable:!0}):U[O]=w,U}var b=function(U,O){if(!U||typeof U.getRequests!="function")return{};var w=U.getRequests({state:"executed"});if(w.length===0)return{};var W,G=w[w.length-1],X=o(G.url),V=G.url,$=G.bytesLoaded,re=new Date(G.requestStartDate).getTime(),Z=new Date(G.firstByteDate).getTime(),oe=new Date(G.requestEndDate).getTime(),Ee=isNaN(G.duration)?0:G.duration,ve=typeof O.getMetricsFor=="function"?O.getMetricsFor(G.mediaType).HttpList:O.getDashMetrics().getHttpRequests(G.mediaType);return ve.length>0&&(W=u(ve[ve.length-1]._responseHeaders||"")),{requestStart:re,requestResponseStart:Z,requestResponseEnd:oe,requestBytesLoaded:$,requestResponseHeaders:W,requestMediaDuration:Ee,requestHostname:X,requestUrl:V}},R=function(U,O){var w=O.getQualityFor(U),W=O.getCurrentTrackFor(U).bitrateList;return W?{currentLevel:w,renditionWidth:W[w].width||null,renditionHeight:W[w].height||null,renditionBitrate:W[w].bandwidth}:{}},I=function(U){var O;return(O=U.match(/.*codecs\*?="(.*)"/))===null||O===void 0?void 0:O[1]};function k(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var F=0,K=function(){function U(){(function(G,X){if(!(G instanceof X))throw new TypeError("Cannot call a class as a function")})(this,U)}var O,w,W;return O=U,w=[{key:"on",value:function(G,X,V){return X._eventEmitterGuid=X._eventEmitterGuid||++F,this._listeners=this._listeners||{},this._listeners[G]=this._listeners[G]||[],V&&(X=X.bind(V)),this._listeners[G].push(X),X}},{key:"off",value:function(G,X){var V=this._listeners&&this._listeners[G];V&&V.forEach(function($,re){$._eventEmitterGuid===X._eventEmitterGuid&&V.splice(re,1)})}},{key:"one",value:function(G,X,V){var $=this;X._eventEmitterGuid=X._eventEmitterGuid||++F;var re=function Z(){$.off(G,Z),X.apply(V||this,arguments)};re._eventEmitterGuid=X._eventEmitterGuid,this.on(G,re)}},{key:"emit",value:function(G,X){var V=this;if(this._listeners){X=X||{};var $=this._listeners["before*"]||[],re=this._listeners[G]||[],Z=this._listeners["after"+G]||[],oe=function(Ee,ve){(Ee=Ee.slice()).forEach(function(pe){pe.call(V,{type:G},ve)})};oe($,X),oe(re,X),oe(Z,X)}}}],w&&k(O.prototype,w),W&&k(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}(),H=K;function j(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var Y=function(){function U(G){var X=this;(function(V,$){if(!(V instanceof $))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,G.on("playing",function(){X._playheadShouldBeProgressing=!0}),G.on("play",this._startPlaybackHeartbeatInterval.bind(this)),G.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),G.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),G.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),G.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),G.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),G.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),G.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),G.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),G.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("seeked",function(){G.data.player_is_paused?X._stopPlaybackHeartbeatInterval():X._startPlaybackHeartbeatInterval()}),G.on("timeupdate",function(){X._playbackHeartbeatInterval!==null&&G.emit("playbackheartbeat")}),G.on("devicesleep",function(V,$){X._playbackHeartbeatInterval!==null&&(M().clearInterval(X._playbackHeartbeatInterval),G.emit("playbackheartbeatend",{viewer_time:$.viewer_time}),X._playbackHeartbeatInterval=null)})}var O,w,W;return O=U,(w=[{key:"_startPlaybackHeartbeatInterval",value:function(){var G=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=M().setInterval(function(){G.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(M().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&j(O.prototype,w),W&&j(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function Q(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function q(U,O,w){return O&&Q(U.prototype,O),w&&Q(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var ne=q(function U(O){var w=this;(function(W,G){if(!(W instanceof G))throw new TypeError("Cannot call a class as a function")})(this,U),O.on("viewinit",function(){w.viewErrored=!1}),O.on("error",function(W,G){try{var X=O.errorTranslator({player_error_code:G.player_error_code,player_error_message:G.player_error_message,player_error_context:G.player_error_context});X?(O.data.player_error_code=X.player_error_code||G.player_error_code,O.data.player_error_message=X.player_error_message||G.player_error_message,O.data.player_error_context=X.player_error_context||G.player_error_context,w.viewErrored=!0):(delete O.data.player_error_code,delete O.data.player_error_message,delete O.data.player_error_context)}catch(V){O.mux.log.warn("Exception in error translator callback.",V),w.viewErrored=!0}})});function te(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var ae=function(){function U(G){(function(X,V){if(!(X instanceof V))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,this._watchTimeTrackerLastCheckedTime=null,G.on("playbackheartbeat",this._updateWatchTime.bind(this)),G.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var O,w,W;return O=U,(w=[{key:"_updateWatchTime",value:function(G,X){var V=X.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=V),l(this.pm.data,"view_watch_time",V-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=V}},{key:"_clearWatchTimeState",value:function(G,X){this._updateWatchTime(G,X),this._watchTimeTrackerLastCheckedTime=null}}])&&te(O.prototype,w),W&&te(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function ue(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var ce=function(){function U(G){(function(X,V){if(!(X instanceof V))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,this._playbackTimeTrackerLastPlayheadPosition=-1,G.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),G.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),G.on("seeking",this._clearPlaybackTimeState.bind(this))}var O,w,W;return O=U,(w=[{key:"_updatePlaybackTime",value:function(){var G=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&G>this._playbackTimeTrackerLastPlayheadPosition){var X=G-this._playbackTimeTrackerLastPlayheadPosition;X<=1e3&&l(this.pm.data,"view_content_playback_time",X)}this._playbackTimeTrackerLastPlayheadPosition=G}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&ue(O.prototype,w),W&&ue(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function le(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var fe=function(){function U(G){(function(V,$){if(!(V instanceof $))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G;var X=this._updatePlayheadTime.bind(this);G.on("playbackheartbeat",X),G.on("playbackheartbeatend",X),G.on("timeupdate",X),G.on("destroy",function(){G.off("timeupdate",X)})}var O,w,W;return O=U,(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(G,X){var V=this,$=function(){V.pm.currentFragmentPDT&&V.pm.currentFragmentStart&&(V.pm.data.player_program_time=V.pm.currentFragmentPDT+V.pm.data.player_playhead_time-V.pm.currentFragmentStart)};if(X&&X.player_playhead_time)this.pm.data.player_playhead_time=X.player_playhead_time,$(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var re=this.pm.getPlayheadTime();re!==void 0&&(this.pm.data.player_playhead_time=re,$(),this._updateMaxPlayheadPosition())}}}])&&le(O.prototype,w),W&&le(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function de(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function xe(U,O,w){return O&&de(U.prototype,O),w&&de(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var Ae=xe(function U(O){if(function(X,V){if(!(X instanceof V))throw new TypeError("Cannot call a class as a function")}(this,U),!O.disableRebufferTracking){var w,W=function(X,V){G(V),w=void 0},G=function(X){if(w){var V=X.viewer_time-w;l(O.data,"view_rebuffer_duration",V),w=X.viewer_time}O.data.view_watch_time>=0&&O.data.view_rebuffer_count>0&&(O.data.view_rebuffer_frequency=O.data.view_rebuffer_count/O.data.view_watch_time,O.data.view_rebuffer_percentage=O.data.view_rebuffer_duration/O.data.view_watch_time)};O.on("playbackheartbeat",function(X,V){return G(V)}),O.on("rebufferstart",function(X,V){w||(l(O.data,"view_rebuffer_count",1),w=V.viewer_time,O.one("rebufferend",W))}),O.on("viewinit",function(){w=void 0,O.off("rebufferend",W)})}});function Ie(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var Re=function(){function U(G){var X=this;(function(V,$){if(!(V instanceof $))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,G.disableRebufferTracking||G.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,G.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),G.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),G.on("seeking",function(){X._cleanupRebufferTracker(null,{viewer_time:p.now()})}))}var O,w,W;return O=U,w=[{key:"_checkIfRebuffering",value:function(G,X){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(G,X);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var V=X.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&V>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=X.viewer_time}else this._cleanupRebufferTracker(G,X,!0);else this._prepareRebufferTrackerState(X.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(G){this._lastCheckedTime=G,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=G}},{key:"_cleanupRebufferTracker",value:function(G,X){var V=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:X.viewer_time});else{if(this._lastCheckedTime===null)return;var $=this.pm.data.player_playhead_time-this._lastPlayheadTime,re=X.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&$>0&&re-$>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+re-$}))}V?this._prepareRebufferTrackerState(X.viewer_time):this._clearRebufferTrackerState()}}],w&&Ie(O.prototype,w),W&&Ie(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}(),Oe=Re;function Pe(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var Ce=function(){function U(G){var X=this;(function(V,$){if(!(V instanceof $))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,G.on("viewinit",function(){var V=G.data,$=V.view_id;if(!V.view_program_changed){var re=function(Z,oe){var Ee=oe.viewer_time;Z.type==="playing"&&G.data.view_time_to_first_frame===void 0?X.calculateTimeToFirstFrame(Ee||p.now(),$):Z.type!=="adplaying"||G.data.view_time_to_first_frame!==void 0&&!X._inPrerollPosition()||X.calculateTimeToFirstFrame(Ee||p.now(),$)};G.one("playing",re),G.one("adplaying",re),G.one("viewend",function(){G.off("playing",re),G.off("adplaying",re)})}})}var O,w,W;return O=U,(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(G,X){X===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:G}),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(O.prototype,w),W&&Pe(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function Le(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function ke(U,O,w){return O&&Le(U.prototype,O),w&&Le(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var Be=ke(function U(O){var w=this;(function(W,G){if(!(W instanceof G))throw new TypeError("Cannot call a class as a function")})(this,U),O.on("viewinit",function(){w._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(W){O.on(W,function(){if(w._lastPlayheadPosition>=0&&O.data.player_playhead_time>=0&&w._lastPlayerWidth>=0&&w._lastSourceWidth>0&&w._lastPlayerHeight>=0&&w._lastSourceHeight>0){var G=O.data.player_playhead_time-w._lastPlayheadPosition;if(G<0)return void(w._lastPlayheadPosition=-1);var X=Math.min(w._lastPlayerWidth/w._lastSourceWidth,w._lastPlayerHeight/w._lastSourceHeight),V=Math.max(0,X-1),$=Math.max(0,1-X);O.data.view_max_upscale_percentage=Math.max(O.data.view_max_upscale_percentage||0,V),O.data.view_max_downscale_percentage=Math.max(O.data.view_max_downscale_percentage||0,$),l(O.data,"view_total_content_playback_time",G),l(O.data,"view_total_upscaling",V*G),l(O.data,"view_total_downscaling",$*G)}w._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(W){O.on(W,function(){w._lastPlayheadPosition=O.data.player_playhead_time,w._lastPlayerWidth=O.data.player_width,w._lastPlayerHeight=O.data.player_height,w._lastSourceWidth=O.data.video_source_width,w._lastSourceHeight=O.data.video_source_height})})});function we(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function Ye(U,O,w){return O&&we(U.prototype,O),w&&we(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var Xe=Ye(function U(O){var w=this;(function(W,G){if(!(W instanceof G))throw new TypeError("Cannot call a class as a function")})(this,U),this.isSeeking=!1,O.on("seeking",function(W,G){a()(O.data,G),w._lastSeekingTime=p.now(),w.isSeeking===!1&&(w.isSeeking=!0,O.send("seeking"))}),O.on("seeked",function(){w.isSeeking=!1;var W=w._lastSeekingTime||p.now(),G=p.now()-W;l(O.data,"view_seek_count",1),l(O.data,"view_seek_duration",G);var X=O.data.view_max_seek_time||0;O.data.view_max_seek_time=Math.max(X,G)}),O.on("viewend",function(){w.isSeeking=!1})});function rt(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var X,V,$=[],re=!0,Z=!1;try{for(G=G.call(w);!(re=(X=G.next()).done)&&($.push(X.value),!W||$.length!==W);re=!0);}catch(oe){Z=!0,V=oe}finally{try{re||G.return==null||G.return()}finally{if(Z)throw V}}return $}}(U,O)||function(w,W){if(w){if(typeof w=="string")return ze(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?ze(w,W):void 0}}(U,O)||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 ze(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}function it(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var nt=function(U,O){U.push(O),U.sort(function(w,W){return w.viewer_time-W.viewer_time})},Je=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Ne=function(){function U(G){var X=this;(function($,re){if(!($ instanceof re))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,G.on("viewinit",function(){X.isAdBreak=!1,X._currentAdRequestNumber=0,X._currentAdResponseNumber=0,X._adRequests=[],X._adResponses=[],X._adHasPlayed=!1,X._wouldBeNewAdPlay=!0,X._prerollPlayTime=void 0}),Je.forEach(function($){return G.on($,X._updateAdData.bind(X))});var V=function(){X.isAdBreak=!1};G.on("adbreakstart",function(){X.isAdBreak=!0}),G.on("play",V),G.on("playing",V),G.on("viewend",V),G.on("adrequest",function($,re){re=a()({ad_request_id:"generatedAdRequestId"+X._currentAdRequestNumber++},re),nt(X._adRequests,re),l(G.data,"view_ad_request_count"),X.inPrerollPosition()&&(G.data.view_preroll_requested=!0,X._adHasPlayed||l(G.data,"view_preroll_request_count"))}),G.on("adresponse",function($,re){re=a()({ad_request_id:"generatedAdRequestId"+X._currentAdResponseNumber++},re),nt(X._adResponses,re);var Z=X.findAdRequest(re.ad_request_id);Z&&l(G.data,"view_ad_request_time",Math.max(0,re.viewer_time-Z.viewer_time))}),G.on("adplay",function($,re){X._adHasPlayed=!0,X._wouldBeNewAdPlay&&(X._wouldBeNewAdPlay=!1,l(G.data,"view_ad_played_count")),X.inPrerollPosition()&&!G.data.view_preroll_played&&(G.data.view_preroll_played=!0,X._adRequests.length>0&&(G.data.view_preroll_request_time=Math.max(0,re.viewer_time-X._adRequests[0].viewer_time)),G.data.view_start&&(G.data.view_startup_preroll_request_time=Math.max(0,re.viewer_time-G.data.view_start)),X._prerollPlayTime=re.viewer_time)}),G.on("adplaying",function($,re){X.inPrerollPosition()&&G.data.view_preroll_load_time===void 0&&X._prerollPlayTime!==void 0&&(G.data.view_preroll_load_time=re.viewer_time-X._prerollPlayTime,G.data.view_startup_preroll_load_time=re.viewer_time-X._prerollPlayTime)}),G.on("adended",function(){X._wouldBeNewAdPlay=!0}),G.on("aderror",function(){X._wouldBeNewAdPlay=!0})}var O,w,W;return O=U,(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(G){for(var X=0;X<this._adRequests.length;X++)if(this._adRequests[X].ad_request_id===G)return this._adRequests[X]}},{key:"_updateAdData",value:function(G,X){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&X.ad_tag_url){var V=rt(n(X.ad_tag_url),2),$=V[0],re=V[1];this.pm.data.view_preroll_ad_tag_domain=re,this.pm.data.view_preroll_ad_tag_hostname=$}if(!this.pm.data.view_preroll_ad_asset_hostname&&X.ad_asset_url){var Z=rt(n(X.ad_asset_url),2),oe=Z[0],Ee=Z[1];this.pm.data.view_preroll_ad_asset_domain=Ee,this.pm.data.view_preroll_ad_asset_hostname=oe}}}}])&&it(O.prototype,w),W&&it(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function Ke(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function Ze(U,O,w){return O&&Ke(U.prototype,O),w&&Ke(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var ft=Ze(function U(O){var w,W;(function($,re){if(!($ instanceof re))throw new TypeError("Cannot call a class as a function")})(this,U);var G=function(){O.disableRebufferTracking||w&&(l(O.data,"view_waiting_rebuffer_duration",p.now()-w),w=!1,M().clearInterval(W))},X=!1,V=function(){X=!1,G()};O.on("waiting",function(){X&&(O.disableRebufferTracking||(l(O.data,"view_waiting_rebuffer_count",1),w=p.now(),W=M().setInterval(function(){if(w){var $=p.now();l(O.data,"view_waiting_rebuffer_duration",$-w),w=$}},250)))}),O.on("playing",function(){G(),X=!0}),O.on("pause",V),O.on("seeking",V)});function Me(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function qe(U,O,w){return O&&Me(U.prototype,O),w&&Me(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var et=qe(function U(O){var w=this;(function(X,V){if(!(X instanceof V))throw new TypeError("Cannot call a class as a function")})(this,U);var W=function(){w.lastWallClockTime=p.now(),O.on("before*",G)},G=function(X){var V=p.now(),$=w.lastWallClockTime;w.lastWallClockTime=V,V-$>3e4&&(O.emit("devicesleep",{viewer_time:$}),a()(O.data,{viewer_time:$}),O.send("devicesleep"),O.emit("devicewake",{viewer_time:V}),a()(O.data,{viewer_time:V}),O.send("devicewake"))};O.one("playbackheartbeat",W),O.on("playbackheartbeatend",function(){O.off("before*",G),O.one("playbackheartbeat",W)})}),_t=C(375),mt=C(655),pt=C.n(mt),Rt="muxData",Tt=function(){var U;try{U=_t.parse(pt().get(Rt)||"")}catch{U={}}return U},Gt=function(U){try{pt().set(Rt,_t.stringify(U),{expires:7300})}catch{}},It=function(){var U=Tt();return U.mux_viewer_id=U.mux_viewer_id||P(),U.msn=U.msn||Math.random(),Gt(U),{mux_viewer_id:U.mux_viewer_id,mux_sample_number:U.msn}};function tr(U,O){var w=O.beaconCollectionDomain,W=O.beaconDomain;if(w)return"https://"+w;var G=W||"litix.io";return(U=U||"inferred").match(/^[a-z0-9]+$/)?"https://"+U+"."+G:"https://img.litix.io/a.gif"}var Ot=function(){var U;switch(St()){case"cellular":U="cellular";break;case"ethernet":U="wired";break;case"wifi":U="wifi";break;case void 0:break;default:U="other"}return U},St=function(){var U=M().navigator,O=U&&(U.connection||U.mozConnection||U.webkitConnection);return O&&O.type};Ot.getConnectionFromAPI=St;var lt=Ot,Ht=jt({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"}),Ct=jt({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",cc:"codec",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",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",un:"universal",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 jt(U){var O={};for(var w in U)U.hasOwnProperty(w)&&(O[U[w]]=w);return O}function Mt(U){var O={},w={};return Object.keys(U).forEach(function(W){var G=!1;if(U.hasOwnProperty(W)&&U[W]!==void 0){var X=W.split("_"),V=X[0],$=Ht[V];$||(d.info("Data key word `"+X[0]+"` not expected in "+W),$=V+"_"),X.splice(1).forEach(function(re){re==="url"&&(G=!0),Ct[re]?$+=Ct[re]:Number(re)&&Math.floor(Number(re))===Number(re)?$+=re:(d.info("Data key word `"+re+"` not expected in "+W),$+="_"+re+"_")}),G?w[$]=U[W]:O[$]=U[W]}}),a()(O,w)}var rr={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},ir=["hb","requestcompleted","requestfailed","requestcanceled"],nr="https://img.litix.io",ut=function(U){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=U||nr,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=a()({},rr,O)};ut.prototype.queueEvent=function(U,O){var w=a()({},O);return(this._eventQueue.length<=this._options.maxQueueLength||U==="eventrateexceeded")&&(this._eventQueue.push(w),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},ut.prototype.flushEvents=function(){var U=arguments.length>0&&arguments[0]!==void 0&&arguments[0];U&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},ut.prototype.destroy=function(){var U=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,U?this._clearBeaconQueue():this.flushEvents(),M().clearTimeout(this._sendTimeout)},ut.prototype._clearBeaconQueue=function(){var U=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,O=this._eventQueue.slice(U);U>0&&a()(O[O.length-1],Mt({mux_view_message:"event queue truncated"}));var w=this._createPayload(O);wt(this._beaconUrl,w,!0,function(){})},ut.prototype._sendBeaconQueue=function(){var U=this;if(!this._postInFlight){var O=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var w=this._createPayload(O),W=p.now();wt(this._beaconUrl,w,!1,function(G,X){X?(U._eventQueue=O.concat(U._eventQueue),U._failureCount+=1,d.info("Error sending beacon: "+X)):U._failureCount=0,U._roundTripTime=p.now()-W,U._postInFlight=!1})}},ut.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var U=Math.pow(2,this._failureCount-1);return(1+(U*=Math.random()))*this._options.baseTimeBetweenBeacons},ut.prototype._startBeaconSending=function(){var U=this;M().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=M().setTimeout(function(){U._eventQueue.length&&U._sendBeaconQueue(),U._startBeaconSending()},this._getNextBeaconTime()))},ut.prototype._createPayload=function(U){var O,w,W,G=this,X={transmission_timestamp:Math.round(p.now())};this._roundTripTime&&(X.rtt_ms=Math.round(this._roundTripTime));var V=function(){O=JSON.stringify({metadata:X,events:w||U}),W=O.length/1024},$=function(){return W<=G._options.maxPayloadKBSize};return V(),$()||(d.info("Payload size is too big ("+W+" kb). Removing unnecessary events."),w=U.filter(function(re){return ir.indexOf(re.e)===-1}),V()),$()||(d.info("Payload size still too big ("+W+" kb). Cropping fields.."),w.forEach(function(re){for(var Z in re){var oe=re[Z];typeof oe=="string"&&oe.length>51200&&(re[Z]=oe.substring(0,51200))}}),V()),O};var wt=function(U,O,w,W){if(w&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(U,O))W();else if(M().fetch)M().fetch(U,{method:"POST",body:O,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(X){return W(null,X.ok?null:"Error")}).catch(function(X){return W(null,X)});else{if(M().XMLHttpRequest){var G=new(M()).XMLHttpRequest;return G.onreadystatechange=function(){if(G.readyState===4)return W(null,G.status!==200?"error":void 0)},G.open("POST",U),G.setRequestHeader("Content-Type","text/plain"),void G.send(O)}W()}},ar=ut;function sr(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var X,V,$=[],re=!0,Z=!1;try{for(G=G.call(w);!(re=(X=G.next()).done)&&($.push(X.value),!W||$.length!==W);re=!0);}catch(oe){Z=!0,V=oe}finally{try{re||G.return==null||G.return()}finally{if(Z)throw V}}return $}}(U,O)||function(w,W){if(w){if(typeof w=="string")return Dr(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?Dr(w,W):void 0}}(U,O)||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 Dr(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}function Lr(U,O){var w=Object.keys(U);if(Object.getOwnPropertySymbols){var W=Object.getOwnPropertySymbols(U);O&&(W=W.filter(function(G){return Object.getOwnPropertyDescriptor(U,G).enumerable})),w.push.apply(w,W)}return w}function Dt(U){for(var O=1;O<arguments.length;O++){var w=arguments[O]!=null?arguments[O]:{};O%2?Lr(Object(w),!0).forEach(function(W){Vt(U,W,w[W])}):Object.getOwnPropertyDescriptors?Object.defineProperties(U,Object.getOwnPropertyDescriptors(w)):Lr(Object(w)).forEach(function(W){Object.defineProperty(U,W,Object.getOwnPropertyDescriptor(w,W))})}return U}function kt(U){return kt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(O){return typeof O}:function(O){return O&&typeof Symbol=="function"&&O.constructor===Symbol&&O!==Symbol.prototype?"symbol":typeof O},kt(U)}function ni(U,O){if(!(U instanceof O))throw new TypeError("Cannot call a class as a function")}function Ar(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function Vt(U,O,w){return O in U?Object.defineProperty(U,O,{value:w,enumerable:!0,configurable:!0,writable:!0}):U[O]=w,U}var ai=["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"],si=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended"],oi=["viewstart","error","ended","viewend"],li=function(){function U(G,X){var V,$,re,Z,oe,Ee,ve,pe,he,ye,be,He,je,at,Se,Ve=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};ni(this,U),Vt(this,"previousBeaconData",null),Vt(this,"lastEventTime",0),Vt(this,"rateLimited",!1),this.mux=G,this.envKey=X,this.options=Ve,this.eventQueue=new ar(tr(this.envKey,this.options)),this.sampleRate=(V=this.options.sampleRate)!==null&&V!==void 0?V:1,this.disableCookies=($=this.options.disableCookies)!==null&&$!==void 0&&$,this.respectDoNotTrack=(re=this.options.respectDoNotTrack)!==null&&re!==void 0&&re,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(Z=this.options.platform)===null||Z===void 0?void 0:Z.name,viewer_application_version:(oe=this.options.platform)===null||oe===void 0?void 0:oe.version,viewer_application_engine:(Ee=this.options.platform)===null||Ee===void 0?void 0:Ee.layout,viewer_device_name:(ve=this.options.platform)===null||ve===void 0?void 0:ve.product,viewer_device_category:"",viewer_device_manufacturer:(pe=this.options.platform)===null||pe===void 0?void 0:pe.manufacturer,viewer_os_family:(he=this.options.platform)===null||he===void 0||(ye=he.os)===null||ye===void 0?void 0:ye.family,viewer_os_architecture:(be=this.options.platform)===null||be===void 0||(He=be.os)===null||He===void 0?void 0:He.architecture,viewer_os_version:(je=this.options.platform)===null||je===void 0||(at=je.os)===null||at===void 0?void 0:at.version,viewer_connection_type:lt(),page_url:M()===null||M()===void 0||(Se=M().location)===null||Se===void 0?void 0:Se.href},this.viewerData=this.disableCookies?{}:It()}var O,w,W;return O=U,(w=[{key:"send",value:function(G,X){var V;if(G){if(this.respectDoNotTrack&&E())return d.info("Not sending `"+G+"` because Do Not Track is enabled");if(!X||kt(X)!=="object")return d.error("A data object was expected in send() but was not provided");var $,re,Z=this.disableCookies?{}:($=Tt(),re=p.now(),$.session_start&&($.sst=$.session_start,delete $.session_start),$.session_id&&($.sid=$.session_id,delete $.session_id),$.session_expires&&($.sex=$.session_expires,delete $.session_expires),(!$.sex||$.sex<re)&&($.sid=P(),$.sst=re),$.sex=re+15e5,Gt($),{session_id:$.sid,session_start:$.sst,session_expires:$.sex}),oe=Dt(Dt(Dt(Dt(Dt({},this.pageLevelData),X),Z),this.viewerData),{},{event:G,env_key:this.envKey});oe.user_id&&(oe.viewer_user_id=oe.user_id,delete oe.user_id);var Ee=((V=oe.mux_sample_number)!==null&&V!==void 0?V:0)>=this.sampleRate,ve=Mt(this._deduplicateBeaconData(G,oe));if(this.lastEventTime=this.mux.utils.now(),Ee)return d.info("Not sending event due to sample rate restriction",G,oe,ve);if(this.envKey||d.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",G,oe,ve),!this.rateLimited){if(d.info("Sending event",G,oe,ve),this.rateLimited=!this.eventQueue.queueEvent(G,ve),this.mux.WINDOW_UNLOADING&&G==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&G==="hb"?this.eventQueue.flushEvents(!0):oi.indexOf(G)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return oe.event="eventrateexceeded",ve=Mt(oe),this.eventQueue.queueEvent(oe.event,ve),d.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(G,X){var V=this,$={},re=X.view_id;if(!re||G==="viewstart"||G==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)$=Dt({},X),re&&(this.previousBeaconData=$),re&&G==="viewend"&&(this.previousBeaconData=null);else{var Z=G.indexOf("request")===0;Object.entries(X).forEach(function(oe){var Ee=sr(oe,2),ve=Ee[0],pe=Ee[1];V.previousBeaconData&&(pe!==V.previousBeaconData[ve]||ai.indexOf(ve)>-1||V.objectHasChanged(Z,ve,pe,V.previousBeaconData[ve])||V.eventRequiresKey(G,ve))&&($[ve]=pe,V.previousBeaconData[ve]=pe)})}return $}},{key:"objectHasChanged",value:function(G,X,V,$){return!(!G||X.indexOf("request_")!==0||X!=="request_response_headers"&&kt(V)==="object"&&kt($)==="object"&&Object.keys(V||{}).length===Object.keys($||{}).length)}},{key:"eventRequiresKey",value:function(G,X){return G==="renditionchange"&&X.indexOf("video_source_")===0||!(X.indexOf("ad_")!==0||!si.includes(G))}}])&&Ar(O.prototype,w),W&&Ar(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function br(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function ui(U,O,w){return O&&br(U.prototype,O),w&&br(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var fi=ui(function U(O){(function(Z,oe){if(!(Z instanceof oe))throw new TypeError("Cannot call a class as a function")})(this,U);var w=0,W=0,G=0,X=0,V=0,$=0,re=0;O.on("requestcompleted",function(Z,oe){var Ee,ve,pe=oe.request_start,he=oe.request_response_start,ye=oe.request_response_end,be=oe.request_bytes_loaded;if(X++,he?(Ee=he-pe,ve=ye-he):ve=ye-pe,ve>0&&be>0){var He=be/ve*8e3;V++,W+=be,G+=ve,O.data.view_min_request_throughput=Math.min(O.data.view_min_request_throughput||1/0,He),O.data.view_average_request_throughput=W/G*8e3,O.data.view_request_count=X,Ee>0&&(w+=Ee,O.data.view_max_request_latency=Math.max(O.data.view_max_request_latency||0,Ee),O.data.view_average_request_latency=w/V)}}),O.on("requestfailed",function(Z,oe){X++,$++,O.data.view_request_count=X,O.data.view_request_failed_count=$}),O.on("requestcanceled",function(Z,oe){X++,re++,O.data.view_request_count=X,O.data.view_request_canceled_count=re})});function Pr(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function di(U,O,w){return O&&Pr(U.prototype,O),w&&Pr(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var ci=di(function U(O){var w=this;(function(W,G){if(!(W instanceof G))throw new TypeError("Cannot call a class as a function")})(this,U),O.on("before*",function(W,G){var X=G.viewer_time,V=p.now(),$=w._lastEventTime;if(w._lastEventTime=V,$&&V-$>36e5){var re=Object.keys(O.data).reduce(function(Z,oe){return oe.indexOf("video_")===0?a()(Z,function(Ee,ve,pe){return ve in Ee?Object.defineProperty(Ee,ve,{value:pe,enumerable:!0,configurable:!0,writable:!0}):Ee[ve]=pe,Ee}({},oe,O.data[oe])):Z},{});O.mux.log.info("Received event after at least an hour inactivity, creating a new view"),O.emit("viewinit",a()({viewer_time:X},re)),O.playbackHeartbeat._playheadShouldBeProgressing&&W.type!=="play"&&W.type!=="adbreakstart"&&(O.emit("play",{viewer_time:X}),W.type!=="playing"&&O.emit("playing",{viewer_time:X}))}})});function or(U){return or=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(O){return typeof O}:function(O){return O&&typeof Symbol=="function"&&O.constructor===Symbol&&O!==Symbol.prototype?"symbol":typeof O},or(U)}function hi(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var X,V,$=[],re=!0,Z=!1;try{for(G=G.call(w);!(re=(X=G.next()).done)&&($.push(X.value),!W||$.length!==W);re=!0);}catch(oe){Z=!0,V=oe}finally{try{re||G.return==null||G.return()}finally{if(Z)throw V}}return $}}(U,O)||function(w,W){if(w){if(typeof w=="string")return Rr(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?Rr(w,W):void 0}}(U,O)||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 Rr(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}function Ir(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function lr(U,O){return lr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(w,W){return w.__proto__=W,w},lr(U,O)}function vi(U){var O=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,W=Yt(U);if(O){var G=Yt(this).constructor;w=Reflect.construct(W,arguments,G)}else w=W.apply(this,arguments);return gi(this,w)}}function gi(U,O){if(O&&(or(O)==="object"||typeof O=="function"))return O;if(O!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return We(U)}function We(U){if(U===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return U}function Yt(U){return Yt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(O){return O.__proto__||Object.getPrototypeOf(O)},Yt(U)}var mi=["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"],pi=function(U){(function(V,$){if(typeof $!="function"&&$!==null)throw new TypeError("Super expression must either be null or a function");V.prototype=Object.create($&&$.prototype,{constructor:{value:V,writable:!0,configurable:!0}}),Object.defineProperty(V,"prototype",{writable:!1}),$&&lr(V,$)})(X,U);var O,w,W,G=vi(X);function X(V,$,re){var Z;(function(he,ye){if(!(he instanceof ye))throw new TypeError("Cannot call a class as a function")})(this,X),(Z=G.call(this)).DOM_CONTENT_LOADED_EVENT_END=v.domContentLoadedEventEnd(),Z.NAVIGATION_START=v.navigationStart(),Z.mux=V,Z.id=$,(re=a()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(he){return he}},re)).data=re.data||{},re.data.property_key&&(re.data.env_key=re.data.property_key,delete re.data.property_key),d.setLevel(re.debug?"debug":"warn"),Z.getPlayheadTime=re.getPlayheadTime,Z.getStateData=re.getStateData||function(){return{}},Z.getAdData=re.getAdData||function(){},Z.minimumRebufferDuration=re.minimumRebufferDuration,Z.sustainedRebufferThreshold=re.sustainedRebufferThreshold,Z.playbackHeartbeatTime=re.playbackHeartbeatTime,Z.disableRebufferTracking=re.disableRebufferTracking,Z.disableRebufferTracking&&Z.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."),Z.disablePlayheadRebufferTracking=re.disablePlayheadRebufferTracking,Z.errorTranslator=re.errorTranslator,Z.playbackEventDispatcher=new li(V,re.data.env_key,re),Z.data={player_instance_id:P(),mux_sample_rate:re.sampleRate,beacon_domain:re.beaconCollectionDomain?re.beaconCollectionDomain:re.beaconDomain},Z.data.view_sequence_number=1,Z.data.player_sequence_number=1,Z.oldEmit=Z.emit,Z.emit=function(he,ye){ye=a()({viewer_time:this.mux.utils.now()},ye),this.oldEmit(he,ye)};var oe=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(We(Z));Z.on("viewinit",function(he,ye){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),a()(this.data,ye),this._initializeViewData(),this.one("play",oe),this.one("adbreakstart",oe)});var Ee=function(he){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",he)}.bind(We(Z));if(Z.on("videochange",function(he,ye){Ee(ye)}),Z.on("programchange",function(he,ye){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."),Ee(a()(ye,{view_program_changed:!0})),oe(),this.emit("play"),this.emit("playing")}),Z.on("fragmentchange",function(he,ye){this.currentFragmentPDT=ye.currentFragmentPDT,this.currentFragmentStart=ye.currentFragmentStart}),Z.on("destroy",Z.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ve=function(){var he=Z.data.view_start!==void 0;Z.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",he&&Z.mux.WINDOW_HIDDEN&&(Z.data.player_is_paused||Z.emit("hb"))};window.addEventListener("visibilitychange",ve,!1);var pe=function(he){he.persisted||Z.destroy()};window.addEventListener("pagehide",pe,!1),Z.on("destroy",function(){window.removeEventListener("visibilitychange",ve),window.removeEventListener("pagehide",pe)})}return Z.on("playerready",function(he,ye){a()(this.data,ye)}),mi.forEach(function(he){Z.on(he,function(ye,be){he.indexOf("ad")!==0&&this._updateStateData(),a()(this.data,be),this._sanitizeData()}),Z.on("after"+he,function(){(he!=="error"||this.errorTracker.viewErrored)&&this.send(he)})}),Z.on("viewend",function(he,ye){a()(Z.data,ye)}),Z.one("playerready",function(he){var ye=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=ye-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}),Z.longResumeTracker=new ci(We(Z)),Z.errorTracker=new ne(We(Z)),new et(We(Z)),Z.seekingTracker=new Xe(We(Z)),Z.playheadTime=new fe(We(Z)),Z.playbackHeartbeat=new Y(We(Z)),new Be(We(Z)),Z.watchTimeTracker=new ae(We(Z)),new ce(We(Z)),Z.adTracker=new Ne(We(Z)),new Oe(We(Z)),new Ae(We(Z)),new Ce(We(Z)),new ft(We(Z)),new fi(We(Z)),re.hlsjs&&Z.addHLSJS(re),re.dashjs&&Z.addDashJS(re),Z.emit("viewinit",re.data),Z}return O=X,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(V){var $=a()({},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(Ee){$[Ee]=void 0}),$.video_source_url=$.video_source_url||$.player_source_url,$.video_source_url){var re=hi(n($.video_source_url),2),Z=re[0],oe=re[1];$.video_source_domain=oe,$.video_source_hostname=Z}delete $.ad_request_id,this.playbackEventDispatcher.send(V,$),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){a()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var V=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function($){var re=parseInt(V.data[$],10);V.data[$]=isNaN(re)?void 0:re}),["player_source_url","video_source_url"].forEach(function($){if(V.data[$]){var re=V.data[$].toLowerCase();re.indexOf("data:")!==0&&re.indexOf("blob:")!==0||(V.data[$]="MSE style URL")}})}},{key:"_resetVideoData",value:function(V,$){var re=this;Object.keys(this.data).forEach(function(Z){Z.indexOf("video_")===0&&delete re.data[Z]})}},{key:"_resetViewData",value:function(){var V=this;Object.keys(this.data).forEach(function($){$.indexOf("view_")===0&&delete V.data[$]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(V,$){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var V=this,$=this.data.view_id=P(),re=function(){$===V.data.view_id&&l(V.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",re):re()}},{key:"_restartHeartBeat",value:function(){var V=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){V.data.player_is_paused||V.emit("hb")},1e4))}},{key:"addHLSJS",value:function(V){V.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=V.hlsjs,function($,re,Z){var oe=arguments.length>4?arguments[4]:void 0,Ee=$.log,ve=$.utils.secondsToMs,pe=function(De){var me,_e=parseInt(oe.version);return _e===1&&De.programDateTime!==null&&(me=De.programDateTime),_e===0&&De.pdt!==null&&(me=De.pdt),me};if(v.exists()){var he=function(De,me){return $.emit(re,De,me)},ye=function(De,me){var _e=me.levels,ge=me.audioTracks,Te=me.url,Fe=me.stats,Ue=me.networkDetails,st=me.sessionData,tt={},ct={};_e.forEach(function(gt,Bt){tt[Bt]={width:gt.width,height:gt.height,bitrate:gt.bitrate,attrs:gt.attrs}}),ge.forEach(function(gt,Bt){ct[Bt]={name:gt.name,language:gt.lang,bitrate:gt.bitrate}});var ot=r(Fe),vt=ot.bytesLoaded,Ge=ot.requestStart,ht=ot.responseStart,cr=ot.responseEnd;he("requestcompleted",m(m({},g(st)),{},{request_event_type:De,request_bytes_loaded:vt,request_start:Ge,request_response_start:ht,request_response_end:cr,request_type:"manifest",request_hostname:o(Te),request_response_headers:t(Ue),request_rendition_lists:{media:tt,audio:ct,video:{}}}))};Z.on(oe.Events.MANIFEST_LOADED,ye);var be=function(De,me){var _e=me.details,ge=me.level,Te=me.networkDetails,Fe=me.stats,Ue=r(Fe),st=Ue.bytesLoaded,tt=Ue.requestStart,ct=Ue.responseStart,ot=Ue.responseEnd,vt=_e.fragments[_e.fragments.length-1],Ge=pe(vt)+ve(vt.duration);he("requestcompleted",{request_event_type:De,request_bytes_loaded:st,request_start:tt,request_response_start:ct,request_response_end:ot,request_current_level:ge,request_type:"manifest",request_hostname:o(_e.url),request_response_headers:t(Te),video_holdback:_e.holdBack&&ve(_e.holdBack),video_part_holdback:_e.partHoldBack&&ve(_e.partHoldBack),video_part_target_duration:_e.partTarget&&ve(_e.partTarget),video_target_duration:_e.targetduration&&ve(_e.targetduration),video_source_is_live:_e.live,player_manifest_newest_program_time:isNaN(Ge)?void 0:Ge})};Z.on(oe.Events.LEVEL_LOADED,be);var He=function(De,me){var _e=me.details,ge=me.networkDetails,Te=me.stats,Fe=r(Te),Ue=Fe.bytesLoaded,st=Fe.requestStart,tt=Fe.responseStart,ct=Fe.responseEnd;he("requestcompleted",{request_event_type:De,request_bytes_loaded:Ue,request_start:st,request_response_start:tt,request_response_end:ct,request_type:"manifest",request_hostname:o(_e.url),request_response_headers:t(ge)})};Z.on(oe.Events.AUDIO_TRACK_LOADED,He);var je=function(De,me){var _e=me.stats,ge=me.networkDetails,Te=me.frag;_e=_e||Te.stats;var Fe=r(_e),Ue=Fe.bytesLoaded,st=Fe.requestStart,tt=Fe.responseStart,ct=Fe.responseEnd,ot=t(ge),vt=ot==null?void 0:ot["x-request-id"],Ge={request_event_type:De,request_bytes_loaded:Ue,request_start:st,request_response_start:tt,request_response_end:ct,request_hostname:ge?o(ge.responseURL):void 0,request_id:vt,request_response_headers:ot,request_media_duration:Te.duration,request_url:ge==null?void 0:ge.responseURL};Te.type==="main"?(Ge.request_type="media",Ge.request_current_level=Te.level,Ge.request_video_width=(Z.levels[Te.level]||{}).width,Ge.request_video_height=(Z.levels[Te.level]||{}).height,Ge.request_labeled_bitrate=(Z.levels[Te.level]||{}).bitrate):Ge.request_type=Te.type,he("requestcompleted",Ge)};Z.on(oe.Events.FRAG_LOADED,je);var at=function(De,me){var _e=me.frag,ge=_e.start,Te={currentFragmentPDT:pe(_e),currentFragmentStart:ve(ge)};he("fragmentchange",Te)};Z.on(oe.Events.FRAG_CHANGED,at);var Se=function(De,me){var _e=me.type,ge=me.details,Te=me.response,Fe=me.fatal,Ue=me.context,st=me.frag;if(ge===oe.ErrorDetails.MANIFEST_LOAD_ERROR||ge===oe.ErrorDetails.MANIFEST_LOAD_TIMEOUT||ge===oe.ErrorDetails.FRAG_LOAD_ERROR||ge===oe.ErrorDetails.FRAG_LOAD_TIMEOUT||ge===oe.ErrorDetails.LEVEL_LOAD_ERROR||ge===oe.ErrorDetails.LEVEL_LOAD_TIMEOUT){var tt=st&&st.url||Ue&&Ue.url||"";he("requestfailed",{request_error:ge,request_url:tt,request_hostname:o(tt),request_type:ge===oe.ErrorDetails.FRAG_LOAD_ERROR||ge===oe.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:Te&&Te.code,request_error_text:Te&&Te.text})}Fe&&he("error",{player_error_code:_e,player_error_message:ge})};Z.on(oe.Events.ERROR,Se);var Ve=function(De,me){var _e=me.frag,ge=_e&&_e._url||"";he("requestcanceled",{request_event_type:De,request_url:ge,request_type:"media",request_hostname:o(ge)})};Z.on(oe.Events.FRAG_LOAD_EMERGENCY_ABORTED,Ve);var Qe=function(De,me){var _e=me.level,ge=Z.levels[_e];if(ge&&ge.attrs&&ge.attrs.BANDWIDTH){var Te,Fe=ge.attrs.BANDWIDTH,Ue=parseFloat(ge.attrs["FRAME-RATE"]);isNaN(Ue)||(Te=Ue),Fe?he("renditionchange",{video_source_fps:Te,video_source_bitrate:Fe,video_source_width:ge.width,video_source_height:ge.height,video_source_rendition_name:ge.name,video_source_codec:ge==null?void 0:ge.videoCodec}):Ee.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};Z.on(oe.Events.LEVEL_SWITCHED,Qe),Z._stopMuxMonitor=function(){Z.off(oe.Events.MANIFEST_LOADED,ye),Z.off(oe.Events.LEVEL_LOADED,be),Z.off(oe.Events.AUDIO_TRACK_LOADED,He),Z.off(oe.Events.FRAG_LOADED,je),Z.off(oe.Events.FRAG_CHANGED,at),Z.off(oe.Events.ERROR,Se),Z.off(oe.Events.FRAG_LOAD_EMERGENCY_ABORTED,Ve),Z.off(oe.Events.LEVEL_SWITCHED,Qe),Z.off(oe.Events.DESTROYING,Z._stopMuxMonitor),delete Z._stopMuxMonitor},Z.on(oe.Events.DESTROYING,Z._stopMuxMonitor)}else Ee.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,V.hlsjs,{},V.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var V;this.hlsjs&&((V=this.hlsjs)&&typeof V._stopMuxMonitor=="function"&&V._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(V){V.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=V.dashjs,function($,re,Z){var oe=$.log;if(Z&&Z.on){var Ee=function(Se,Ve){return $.emit(re,Se,Ve)},ve=function(Se){var Ve=Se.type,Qe=(Se.data||{}).url;Ee("requestcompleted",{request_event_type:Ve,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:o(Qe),request_url:Qe})};Z.on("manifestLoaded",ve);var pe={},he=function(Se){var Ve=Se.type,Qe=Se.fragmentModel,De=(Se.chunk||{}).mediaInfo||{},me=De.type,_e=De.bitrateList,ge={};(_e=_e||[]).forEach(function(Ge,ht){ge[ht]={},ge[ht].width=Ge.width,ge[ht].height=Ge.height,ge[ht].bitrate=Ge.bandwidth,ge[ht].attrs={}}),me==="video"?pe.video=ge:me==="audio"?pe.audio=ge:pe.media=ge;var Te=b(Qe,Z),Fe=Te.requestStart,Ue=Te.requestResponseStart,st=Te.requestResponseEnd,tt=Te.requestResponseHeaders,ct=Te.requestMediaDuration,ot=Te.requestHostname,vt=Te.requestUrl;Ee("requestcompleted",{request_event_type:Ve,request_start:Fe,request_response_start:Ue,request_response_end:st,request_bytes_loaded:-1,request_type:me+"_init",request_response_headers:tt,request_hostname:ot,request_url:vt,request_media_duration:ct,request_rendition_lists:pe})};Z.on("initFragmentLoaded",he);var ye=function(Se){var Ve=Se.type,Qe=Se.fragmentModel,De=Se.chunk||{},me=De.mediaInfo,_e=De.start,ge=(me||{}).type,Te=b(Qe,Z),Fe=Te.requestStart,Ue=Te.requestResponseStart,st=Te.requestResponseEnd,tt=Te.requestBytesLoaded,ct=Te.requestResponseHeaders,ot=Te.requestMediaDuration,vt=Te.requestHostname,Ge=Te.requestUrl,ht=R(ge,Z),cr=ht.currentLevel,gt=ht.renditionWidth,Bt=ht.renditionHeight,Ki=ht.renditionBitrate;Ee("requestcompleted",{request_event_type:Ve,request_start:Fe,request_response_start:Ue,request_response_end:st,request_bytes_loaded:tt,request_type:ge,request_response_headers:ct,request_hostname:vt,request_url:Ge,request_media_start_time:_e,request_media_duration:ot,request_current_level:cr,request_labeled_bitrate:Ki,request_video_width:gt,request_video_height:Bt})};Z.on("mediaFragmentLoaded",ye);var be={video:void 0,audio:void 0,totalBitrate:void 0},He=function(){if(be.video&&typeof be.video.bitrate=="number"){if(be.video.width&&be.video.height){var Se=be.video.bitrate;return be.audio&&typeof be.audio.bitrate=="number"&&(Se+=be.audio.bitrate),Se!==be.totalBitrate?(be.totalBitrate=Se,{video_source_bitrate:Se,video_source_height:be.video.height,video_source_width:be.video.width,video_source_codec:I(be.video.codec)}):void 0}oe.warn("have bitrate info for video but missing width/height")}},je=function(Se,Ve,Qe){if(typeof Se.newQuality=="number"){var De=Se.mediaType;if(De==="audio"||De==="video"){var me=Z.getBitrateInfoListFor(De).find(function(ge){return ge.qualityIndex===Se.newQuality});if(me&&typeof me.bitrate=="number"){be[De]=y(y({},me),{},{codec:Z.getCurrentTrackFor(De).codec});var _e=He();_e&&Ee("renditionchange",_e)}else oe.warn("missing bitrate info for ".concat(De))}}else oe.warn("missing evt.newQuality in qualityChangeRendered event",Se)};Z.on("qualityChangeRendered",je);var at=function(Se){var Ve=Se.error,Qe=Se.event,De=(Qe=Qe||{}).request||{},me=M().event&&M().event.currentTarget||{};Ee("requestfailed",{request_error:Ve+"_"+Qe.id+"_"+De.type,request_url:Qe.url,request_hostname:o(Qe.url),request_type:De.mediaType,request_error_code:me.status,request_error_type:me.statusText})};Z.on("error",at),Z._stopMuxMonitor=function(){Z.off("manifestLoaded",ve),Z.off("initFragmentLoaded",he),Z.off("mediaFragmentLoaded",ye),Z.off("qualityChangeRendered",je),Z.off("error",at),delete Z._stopMuxMonitor}}else oe.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,V.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var V;this.dashjs&&((V=this.dashjs)&&typeof V._stopMuxMonitor=="function"&&V._stopMuxMonitor(),this.dashjs=void 0)}}],w&&Ir(O.prototype,w),W&&Ir(O,W),Object.defineProperty(O,"prototype",{writable:!1}),X}(H),yi=pi,Ei=C(153),Ft=C.n(Ei);function ur(U){return ur=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(O){return typeof O}:function(O){return O&&typeof Symbol=="function"&&O.constructor===Symbol&&O!==Symbol.prototype?"symbol":typeof O},ur(U)}function Or(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var X,V,$=[],re=!0,Z=!1;try{for(G=G.call(w);!(re=(X=G.next()).done)&&($.push(X.value),!W||$.length!==W);re=!0);}catch(oe){Z=!0,V=oe}finally{try{re||G.return==null||G.return()}finally{if(Z)throw V}}return $}}(U,O)||function(w,W){if(w){if(typeof w=="string")return Cr(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?Cr(w,W):void 0}}(U,O)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
5
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Cr(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}var Lt,_i=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],Ti={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};M()&&M().WeakMap&&(Lt=new WeakMap);var xi="#EXT-X-TARGETDURATION",Si="#EXT-X-PART-INF",Di="#EXT-X-SERVER-CONTROL",Li="#EXTINF",Ai="#EXT-X-PROGRAM-DATE-TIME",bi="#EXT-X-VERSION",Pi="#EXT-X-SESSION-DATA",Xt=function(U){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(U),this.manifest};Xt.prototype.process=function(U){var O;for(this.buffer+=U,O=this.buffer.indexOf(`
6
+ `);O>-1;O=this.buffer.indexOf(`
7
+ `))this.processLine(this.buffer.substring(0,O)),this.buffer=this.buffer.substring(O+1)},Xt.prototype.processLine=function(U){var O=U.indexOf(":"),w=Ci(U,O),W=w[0],G=w.length===2?dr(w[1]):void 0;if(W[0]!=="#")this.currentUri.uri=W,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(W){case xi:if(!isFinite(G)||G<0)return;this.manifest.targetDuration=G,this.setHoldBack();break;case Si:fr(this.manifest,w),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case Di:fr(this.manifest,w),this.setHoldBack();break;case Li:G===0?this.currentUri.duration=.01:G>0&&(this.currentUri.duration=G);break;case Ai:var X=G,V=new Date(X);this.manifest.dateTimeString||(this.manifest.dateTimeString=X,this.manifest.dateTimeObject=V),this.currentUri.dateTimeString=X,this.currentUri.dateTimeObject=V;break;case bi:fr(this.manifest,w);break;case Pi:var $=Mi(w[1]),re=g($);a()(this.manifest.sessionData,re)}},Xt.prototype.setHoldBack=function(){var U=this.manifest,O=U.serverControl,w=U.targetDuration,W=U.partTargetDuration;if(O){var G="holdBack",X="partHoldBack",V=w&&3*w,$=W&&2*W;w&&!O.hasOwnProperty(G)&&(O[G]=V),V&&O[G]<V&&(O[G]=V),W&&!O.hasOwnProperty(X)&&(O[X]=3*W),W&&O[X]<$&&(O[X]=$)}};var fr=function(U,O){var w,W=Mr(O[0].replace("#EXT-X-",""));Oi(O[1])?(w={},w=a()(Ii(O[1]),w)):w=dr(O[1]),U[W]=w},Mr=function(U){return U.toLowerCase().replace(/-(\w)/g,function(O){return O[1].toUpperCase()})},dr=function(U){if(U.toLowerCase()==="yes"||U.toLowerCase()==="no")return U.toLowerCase()==="yes";var O=U.indexOf(":")!==-1?U:parseFloat(U);return isNaN(O)?U:O},Ri=function(U){var O={},w=U.split("=");return w.length>1&&(O[Mr(w[0])]=dr(w[1])),O},Ii=function(U){for(var O=U.split(","),w={},W=0;O.length>W;W++){var G=O[W],X=Ri(G);w=a()(X,w)}return w},Oi=function(U){return U.indexOf("=")>-1},Ci=function(U,O){return O===-1?[U]:[U.substring(0,O),U.substring(O+1)]},Mi=function(U){var O={};if(U){var w=U.search(",");return[U.slice(0,w),U.slice(w+1)].forEach(function(W,G){for(var X=W.replace(/['"]+/g,"").split("="),V=0;V<X.length;V++)X[V]==="DATA-ID"&&(O["DATA-ID"]=X[1-V]),X[V]==="VALUE"&&(O.VALUE=X[1-V])}),{data:O}}},wi=Xt,ki={safeCall:function(U,O,w,W){var G=W;if(U&&typeof U[O]=="function")try{G=U[O].apply(U,w)}catch(X){d.info("safeCall error",X)}return G},safeIncrement:l,getComputedStyle:function(U,O){var w;if(U&&O&&M()&&typeof M().getComputedStyle=="function")return Lt&&Lt.has(U)&&(w=Lt.get(U)),w||(w=M().getComputedStyle(U,null),Lt&&Lt.set(U,w)),w.getPropertyValue(O)},secondsToMs:function(U){return Math.floor(1e3*U)},assign:a(),headersStringToObject:u,extractHostnameAndDomain:n,extractHostname:o,manifestParser:wi,generateShortID:B,generateUUID:P,now:p.now},Fi={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 Ui(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var X,V,$=[],re=!0,Z=!1;try{for(G=G.call(w);!(re=(X=G.next()).done)&&($.push(X.value),!W||$.length!==W);re=!0);}catch(oe){Z=!0,V=oe}finally{try{re||G.return==null||G.return()}finally{if(Z)throw V}}return $}}(U,O)||function(w,W){if(w){if(typeof w=="string")return wr(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?wr(w,W):void 0}}(U,O)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
8
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function wr(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}var dt={},Ut=function U(O){var w=arguments;typeof O=="string"?U.hasOwnProperty(O)?M().setTimeout(function(){w=Array.prototype.splice.call(w,1),U[O].apply(null,w)},0):d.warn("`"+O+"` is an unknown task"):typeof O=="function"?M().setTimeout(function(){O(U)},0):d.warn("`"+O+"` is invalid.")},Bi={loaded:p.now(),NAME:"mux-embed",VERSION:"4.17.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(U,O){return function(w,W,G){var X=Or(D(W),3),V=X[0],$=X[1],re=X[2],Z=w.log,oe=w.utils.getComputedStyle,Ee=w.utils.secondsToMs;if(!V)return Z.error("No element was found with the `"+$+"` query selector.");if(re!=="video"&&re!=="audio")return Z.error("The element of `"+$+"` was not a media element.");V.mux&&(V.mux.destroy(),delete V.mux,Z.warn("Already monitoring this video element, replacing existing event listeners")),(G=a()({automaticErrorTracking:!0},G)).data=a()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:w.VERSION},G.data),G.getPlayheadTime=function(){return Ee(V.currentTime)},G.getStateData=function(){var pe,he,ye=this.hlsjs&&this.hlsjs.url,be=this.dashjs&&ur(this.dashjs.getSource==="function")&&this.dashjs.getSource(),He={player_is_paused:V.paused,player_playhead_time:Ee(V.currentTime),player_width:parseInt(oe(V,"width")),player_height:parseInt(oe(V,"height")),player_autoplay_on:V.autoplay,player_preload_on:V.preload,player_language_code:V.lang,player_is_fullscreen:Ft()&&!!(Ft().fullscreenElement||Ft().webkitFullscreenElement||Ft().mozFullScreenElement||Ft().msFullscreenElement),video_poster_url:V.poster,video_source_url:ye||be||V.currentSrc,video_source_duration:Ee(V.duration),video_source_height:V.videoHeight,video_source_width:V.videoWidth,view_dropped_frame_count:(pe=V)===null||pe===void 0||(he=pe.getVideoPlaybackQuality)===null||he===void 0?void 0:he.call(pe).droppedVideoFrames},je=G.getPlayheadTime();if(V.getStartDate&&je>0){var at=V.getStartDate();if(at&&typeof at.getTime=="function"&&at.getTime()){var Se=at.getTime();if(He.player_program_time=Se+je,V.seekable.length>0){var Ve=Se+V.seekable.end(V.seekable.length-1);He.player_live_edge_program_time=Ve}}}return He},V.mux=V.mux||{},V.mux.deleted=!1,V.mux.emit=function(pe,he){w.emit($,pe,he)};var ve=function(){Z.error("The monitor for this video element has already been destroyed.")};V.mux.destroy=function(){Object.keys(V.mux.listeners).forEach(function(pe){V.removeEventListener(pe,V.mux.listeners[pe],!1)}),delete V.mux.listeners,V.mux.destroy=ve,V.mux.swapElement=ve,V.mux.emit=ve,V.mux.addHLSJS=ve,V.mux.addDashJS=ve,V.mux.removeHLSJS=ve,V.mux.removeDashJS=ve,V.mux.deleted=!0,w.emit($,"destroy")},V.mux.swapElement=function(pe){var he=Or(D(pe),3),ye=he[0],be=he[1],He=he[2];return ye?He!=="video"&&He!=="audio"?w.log.error("The element of `"+be+"` was not a media element."):(ye.muxId=V.muxId,delete V.muxId,ye.mux=ye.mux||{},ye.mux.listeners=a()({},V.mux.listeners),delete V.mux.listeners,Object.keys(ye.mux.listeners).forEach(function(je){V.removeEventListener(je,ye.mux.listeners[je],!1),ye.addEventListener(je,ye.mux.listeners[je],!1)}),ye.mux.swapElement=V.mux.swapElement,ye.mux.destroy=V.mux.destroy,delete V.mux,void(V=ye)):w.log.error("No element was found with the `"+be+"` query selector.")},V.mux.addHLSJS=function(pe){w.addHLSJS($,pe)},V.mux.addDashJS=function(pe){w.addDashJS($,pe)},V.mux.removeHLSJS=function(){w.removeHLSJS($)},V.mux.removeDashJS=function(){w.removeDashJS($)},w.init($,G),w.emit($,"playerready"),V.paused||(w.emit($,"play"),V.readyState>2&&w.emit($,"playing")),V.mux.listeners={},_i.forEach(function(pe){(pe!=="error"||G.automaticErrorTracking)&&(V.mux.listeners[pe]=function(){var he={};if(pe==="error"){if(!V.error||V.error.code===1)return;he.player_error_code=V.error.code,he.player_error_message=Ti[V.error.code]||V.error.message}w.emit($,pe,he)},V.addEventListener(pe,V.mux.listeners[pe],!1))})}(Ut,U,O)},destroyMonitor:function(U){var O=Ui(D(U),1)[0];O&&O.mux&&typeof O.mux.destroy=="function"?O.mux.destroy():d.error("A video element monitor for `"+U+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(U,O){var w=A(U);dt[w]?dt[w].addHLSJS(O):d.error("A monitor for `"+w+"` has not been initialized.")},addDashJS:function(U,O){var w=A(U);dt[w]?dt[w].addDashJS(O):d.error("A monitor for `"+w+"` has not been initialized.")},removeHLSJS:function(U){var O=A(U);dt[O]?dt[O].removeHLSJS():d.error("A monitor for `"+O+"` has not been initialized.")},removeDashJS:function(U){var O=A(U);dt[O]?dt[O].removeDashJS():d.error("A monitor for `"+O+"` has not been initialized.")},init:function(U,O){E()&&O&&O.respectDoNotTrack&&d.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var w=A(U);dt[w]=new yi(Ut,w,O)},emit:function(U,O,w){var W=A(U);dt[W]?(dt[W].emit(O,w),O==="destroy"&&delete dt[W]):d.error("A monitor for `"+W+"` has not been initialized.")},checkDoNotTrack:E,log:d,utils:ki,events:Fi,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Ut,Bi),M()!==void 0&&typeof M().addEventListener=="function"&&M().addEventListener("pagehide",function(U){U.persisted||(Ut.WINDOW_UNLOADING=!0)},!1);var Ni=Ut},655:function(N,T,C){var L,M;function P(B){return P=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},P(B);}(function(B){var A=!1;if((M=typeof(L=B)=="function"?L.call(T,C,T,N):L)===void 0||(N.exports=M),A=!0,P(T)==="object"&&(N.exports=B(),A=!0),!A){var D=window.Cookies,x=window.Cookies=B();x.noConflict=function(){return window.Cookies=D,x}}})(function(){var B=function(){for(var A=0,D={};A<arguments.length;A++){var x=arguments[A];for(var _ in x)D[_]=x[_]}return D};return function A(D){function x(_,S,d){var E;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(d=B({path:"/"},x.defaults,d)).expires=="number"){var p=new Date;p.setMilliseconds(p.getMilliseconds()+864e5*d.expires),d.expires=p}try{E=JSON.stringify(S),/^[\{\[]/.test(E)&&(S=E)}catch{}return S=D.write?D.write(S,_):encodeURIComponent(String(S)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),_=(_=(_=encodeURIComponent(String(_))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[_,"=",S,d.expires?"; expires="+d.expires.toUTCString():"",d.path?"; path="+d.path:"",d.domain?"; domain="+d.domain:"",d.secure?"; secure":""].join("")}_||(E={});for(var h=document.cookie?document.cookie.split("; "):[],a=/(%[0-9A-Z]{2})+/g,o=0;o<h.length;o++){var n=h[o].split("="),v=n.slice(1).join("=");v.charAt(0)==='"'&&(v=v.slice(1,-1));try{var l=n[0].replace(a,decodeURIComponent);if(v=D.read?D.read(v,l):D(v,l)||v.replace(a,decodeURIComponent),this.json)try{v=JSON.parse(v)}catch{}if(_===l){E=v;break}_||(E[l]=v)}catch{}}return E}}return x.set=x,x.get=function(_){return x.call(x,_)},x.getJSON=function(){return x.apply({json:!0},[].slice.call(arguments))},x.defaults={},x.remove=function(_,S){x(_,"",B(S,{expires:-1}))},x.withConverter=A,x}(function(){})})},153:function(N,T,C){var L,M=C.g!==void 0?C.g:typeof window!="undefined"?window:{},P=C(558);typeof document!="undefined"?L=document:(L=M["__GLOBAL_DOCUMENT_CACHE@4"])||(L=M["__GLOBAL_DOCUMENT_CACHE@4"]=P),N.exports=L},48:function(N,T,C){var L;L=typeof window!="undefined"?window:C.g!==void 0?C.g:typeof self!="undefined"?self:{},N.exports=L},678:function(N){var T=9007199254740991,C="[object Arguments]",L="[object Function]",M="[object GeneratorFunction]",P=/^(?:0|[1-9]\d*)$/;function B(e,r,t){switch(t.length){case 0:return e.call(r);case 1:return e.call(r,t[0]);case 2:return e.call(r,t[0],t[1]);case 3:return e.call(r,t[0],t[1],t[2])}return e.apply(r,t)}var A,D,x=Object.prototype,_=x.hasOwnProperty,S=x.toString,d=x.propertyIsEnumerable,E=(A=Object.keys,D=Object,function(e){return A(D(e))}),p=Math.max,h=!d.call({valueOf:1},"valueOf");function a(e,r){var t=i(e)||function(b){return function(R){return function(I){return!!I&&typeof I=="object"}(R)&&u(R)}(b)&&_.call(b,"callee")&&(!d.call(b,"callee")||S.call(b)==C)}(e)?function(b,R){for(var I=-1,k=Array(b);++I<b;)k[I]=R(I);return k}(e.length,String):[],s=t.length,y=!!s;for(var f in e)!r&&!_.call(e,f)||y&&(f=="length"||n(f,s))||t.push(f);return t}function o(e,r,t){var s=e[r];_.call(e,r)&&l(s,t)&&(t!==void 0||r in e)||(e[r]=t)}function n(e,r){return!!(r=r==null?T:r)&&(typeof e=="number"||P.test(e))&&e>-1&&e%1==0&&e<r}function v(e){var r=e&&e.constructor;return e===(typeof r=="function"&&r.prototype||x)}function l(e,r){return e===r||e!=e&&r!=r}var i=Array.isArray;function u(e){return e!=null&&function(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=T}(e.length)&&!function(r){var t=g(r)?S.call(r):"";return t==L||t==M}(e)}function g(e){var r=typeof e;return!!e&&(r=="object"||r=="function")}var c,m=(c=function(e,r){if(h||v(r)||u(r))(function(s,y,f,b){f||(f={});for(var R=-1,I=y.length;++R<I;){var k=y[R],F=b?b(f[k],s[k],k,f,s):void 0;o(f,k,F===void 0?s[k]:F)}})(r,function(s){return u(s)?a(s):function(y){if(!v(y))return E(y);var f=[];for(var b in Object(y))_.call(y,b)&&b!="constructor"&&f.push(b);return f}(s)}(r),e);else for(var t in r)_.call(r,t)&&o(e,t,r[t])},function(e,r){return r=p(r===void 0?e.length-1:r,0),function(){for(var t=arguments,s=-1,y=p(t.length-r,0),f=Array(y);++s<y;)f[s]=t[r+s];s=-1;for(var b=Array(r+1);++s<r;)b[s]=t[s];return b[r]=f,B(e,this,b)}}(function(e,r){var t=-1,s=r.length,y=s>1?r[s-1]:void 0,f=s>2?r[2]:void 0;for(y=c.length>3&&typeof y=="function"?(s--,y):void 0,f&&function(R,I,k){if(!g(k))return!1;var F=typeof I;return!!(F=="number"?u(k)&&n(I,k.length):F=="string"&&I in k)&&l(k[I],R)}(r[0],r[1],f)&&(y=s<3?void 0:y,s=1),e=Object(e);++t<s;){var b=r[t];b&&c(e,b,t,y)}return e}));N.exports=m},640:function(N,T,C){var L,M;(function(P,B){"use strict";L=function(){var A=function(){},D="undefined",x=typeof window!==D&&typeof window.navigator!==D&&/Trident\/|MSIE /.test(window.navigator.userAgent),_=["trace","debug","info","warn","error"];function S(i,u){var g=i[u];if(typeof g.bind=="function")return g.bind(i);try{return Function.prototype.bind.call(g,i)}catch{return function(){return Function.prototype.apply.apply(g,[i,arguments])}}}function d(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function E(i){return i==="debug"&&(i="log"),typeof console!==D&&(i==="trace"&&x?d:console[i]!==void 0?S(console,i):console.log!==void 0?S(console,"log"):A)}function p(i,u){for(var g=0;g<_.length;g++){var c=_[g];this[c]=g<i?A:this.methodFactory(c,i,u)}this.log=this.debug}function h(i,u,g){return function(){typeof console!==D&&(p.call(this,u,g),this[i].apply(this,arguments))}}function a(i,u,g){return E(i)||h.apply(this,arguments)}function o(i,u,g){var c,m=this;u=u==null?"WARN":u;var e="loglevel";function r(f){var b=(_[f]||"silent").toUpperCase();if(typeof window!==D&&e){try{return void(window.localStorage[e]=b)}catch{}try{window.document.cookie=encodeURIComponent(e)+"="+b+";"}catch{}}}function t(){var f;if(typeof window!==D&&e){try{f=window.localStorage[e]}catch{}if(typeof f===D)try{var b=window.document.cookie,R=b.indexOf(encodeURIComponent(e)+"=");R!==-1&&(f=/^([^;]+)/.exec(b.slice(R))[1])}catch{}return m.levels[f]===void 0&&(f=void 0),f}}function s(){if(typeof window!==D&&e){try{return void window.localStorage.removeItem(e)}catch{}try{window.document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof i=="string"?e+=":"+i:typeof i=="symbol"&&(e=void 0),m.name=i,m.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},m.methodFactory=g||a,m.getLevel=function(){return c},m.setLevel=function(f,b){if(typeof f=="string"&&m.levels[f.toUpperCase()]!==void 0&&(f=m.levels[f.toUpperCase()]),!(typeof f=="number"&&f>=0&&f<=m.levels.SILENT))throw"log.setLevel() called with invalid level: "+f;if(c=f,b!==!1&&r(f),p.call(m,f,i),typeof console===D&&f<m.levels.SILENT)return"No console available for logging"},m.setDefaultLevel=function(f){u=f,t()||m.setLevel(f,!1)},m.resetLevel=function(){m.setLevel(u,!1),s()},m.enableAll=function(f){m.setLevel(m.levels.TRACE,f)},m.disableAll=function(f){m.setLevel(m.levels.SILENT,f)};var y=t();y==null&&(y=u),m.setLevel(y,!1)}var n=new o,v={};n.getLogger=function(i){if(typeof i!="symbol"&&typeof i!="string"||i==="")throw new TypeError("You must supply a name when creating a logger.");var u=v[i];return u||(u=v[i]=new o(i,n.getLevel(),n.methodFactory)),u};var l=typeof window!==D?window.log:void 0;return n.noConflict=function(){return typeof window!==D&&window.log===n&&(window.log=l),n},n.getLoggers=function(){return v},n.default=n,n},(M=typeof L=="function"?L.call(T,C,T,N):L)===void 0||(N.exports=M)})()},375:function(N,T){"use strict";var C=Object.prototype.hasOwnProperty;function L(P){try{return decodeURIComponent(P.replace(/\+/g," "))}catch{return null}}function M(P){try{return encodeURIComponent(P)}catch{return null}}T.stringify=function(P,B){B=B||"";var A,D,x=[];for(D in typeof B!="string"&&(B="?"),P)if(C.call(P,D)){if((A=P[D])||A!=null&&!isNaN(A)||(A=""),D=M(D),A=M(A),D===null||A===null)continue;x.push(D+"="+A)}return x.length?B+x.join("&"):""},T.parse=function(P){for(var B,A=/([^=?#&]+)=?([^&]*)/g,D={};B=A.exec(P);){var x=L(B[1]),_=L(B[2]);x===null||_===null||x in D||(D[x]=_)}return D}},558:function(){}},se={};function z(N){var T=se[N];if(T!==void 0)return T.exports;var C=se[N]={exports:{}};return ie[N].call(C.exports,C,C.exports,z),C.exports}return z.n=function(N){var T=N&&N.__esModule?function(){return N.default}:function(){return N};return z.d(T,{a:T}),T},z.d=function(N,T){for(var C in T)z.o(T,C)&&!z.o(N,C)&&Object.defineProperty(N,C,{enumerable:!0,get:T[C]})},z.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),z.o=function(N,T){return Object.prototype.hasOwnProperty.call(N,T)},z(80)}()},typeof Qt=="object"&&typeof hr=="object"?hr.exports=ee():typeof Qt=="object"?Qt.mux=ee():J.mux=ee()})()});var $t=Fr((Nt,vr)=>{typeof window!="undefined"&&function(ee,ie){typeof Nt=="object"&&typeof vr=="object"?vr.exports=ie():typeof define=="function"&&define.amd?define([],ie):typeof Nt=="object"?Nt.Hls=ie():ee.Hls=ie()}(Nt,()=>(()=>{var J={"./src/config.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{enableStreamingMode:()=>r,hlsDefaultConfig:()=>c,mergeConfig:()=>e});var C=T("./src/controller/abr-controller.ts"),L=T("./src/controller/audio-stream-controller.ts"),M=T("./src/controller/audio-track-controller.ts"),P=T("./src/controller/subtitle-stream-controller.ts"),B=T("./src/controller/subtitle-track-controller.ts"),A=T("./src/controller/buffer-controller.ts"),D=T("./src/controller/timeline-controller.ts"),x=T("./src/controller/cap-level-controller.ts"),_=T("./src/controller/fps-controller.ts"),S=T("./src/controller/eme-controller.ts"),d=T("./src/controller/cmcd-controller.ts"),E=T("./src/utils/xhr-loader.ts"),p=T("./src/utils/fetch-loader.ts"),h=T("./src/utils/cues.ts"),a=T("./src/utils/mediakeys-helper.ts"),o=T("./src/utils/logger.ts");function n(){return n=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var y=arguments[s];for(var f in y)Object.prototype.hasOwnProperty.call(y,f)&&(t[f]=y[f])}return t},n.apply(this,arguments)}function v(t,s){var y=Object.keys(t);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(t);s&&(f=f.filter(function(b){return Object.getOwnPropertyDescriptor(t,b).enumerable})),y.push.apply(y,f)}return y}function l(t){for(var s=1;s<arguments.length;s++){var y=arguments[s]!=null?arguments[s]:{};s%2?v(Object(y),!0).forEach(function(f){i(t,f,y[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(y)):v(Object(y)).forEach(function(f){Object.defineProperty(t,f,Object.getOwnPropertyDescriptor(y,f))})}return t}function i(t,s,y){return s=u(s),s in t?Object.defineProperty(t,s,{value:y,enumerable:!0,configurable:!0,writable:!0}):t[s]=y,t}function u(t){var s=g(t,"string");return typeof s=="symbol"?s:String(s)}function g(t,s){if(typeof t!="object"||t===null)return t;var y=t[Symbol.toPrimitive];if(y!==void 0){var f=y.call(t,s||"default");if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}var c=l(l({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:E.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:C.default,bufferController:A.default,capLevelController:x.default,fpsController:_.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,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:a.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},m()),{},{subtitleStreamController:P.SubtitleStreamController,subtitleTrackController:B.default,timelineController:D.TimelineController,audioStreamController:L.default,audioTrackController:M.default,emeController:S.default,cmcdController:d.default});function m(){return{cueHandler:h.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 e(t,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 n({},t,s)}function r(t){var s=t.loader;if(s!==p.default&&s!==E.default)o.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1;else{var y=(0,p.fetchSupported)();y&&(t.loader=p.default,t.progressive=!0,t.enableSoftwareAES=!0,o.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>E});var C=T("./src/polyfills/number.ts"),L=T("./src/utils/ewma-bandwidth-estimator.ts"),M=T("./src/events.ts"),P=T("./src/errors.ts"),B=T("./src/types/loader.ts"),A=T("./src/utils/logger.ts");function D(p,h){for(var a=0;a<h.length;a++){var o=h[a];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(p,_(o.key),o)}}function x(p,h,a){return h&&D(p.prototype,h),a&&D(p,a),Object.defineProperty(p,"prototype",{writable:!1}),p}function _(p){var h=S(p,"string");return typeof h=="symbol"?h:String(h)}function S(p,h){if(typeof p!="object"||p===null)return p;var a=p[Symbol.toPrimitive];if(a!==void 0){var o=a.call(p,h||"default");if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(h==="string"?String:Number)(p)}var d=function(){function p(a){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=a;var o=a.config;this.bwEstimator=new L.default(o.abrEwmaSlowVoD,o.abrEwmaFastVoD,o.abrEwmaDefaultEstimate),this.registerListeners()}var h=p.prototype;return h.registerListeners=function(){var o=this.hls;o.on(M.Events.FRAG_LOADING,this.onFragLoading,this),o.on(M.Events.FRAG_LOADED,this.onFragLoaded,this),o.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),o.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.on(M.Events.ERROR,this.onError,this)},h.unregisterListeners=function(){var o=this.hls;o.off(M.Events.FRAG_LOADING,this.onFragLoading,this),o.off(M.Events.FRAG_LOADED,this.onFragLoaded,this),o.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),o.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.off(M.Events.ERROR,this.onError,this)},h.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},h.onFragLoading=function(o,n){var v=n.frag;if(v.type===B.PlaylistLevelType.MAIN&&!this.timer){var l;this.fragCurrent=v,this.partCurrent=(l=n.part)!=null?l:null,this.timer=self.setInterval(this.onCheck,100)}},h.onLevelLoaded=function(o,n){var v=this.hls.config;n.details.live?this.bwEstimator.update(v.abrEwmaSlowLive,v.abrEwmaFastLive):this.bwEstimator.update(v.abrEwmaSlowVoD,v.abrEwmaFastVoD)},h._abandonRulesCheck=function(){var o=this.fragCurrent,n=this.partCurrent,v=this.hls,l=v.autoLevelEnabled,i=v.media;if(!(!o||!i)){var u=n?n.stats:o.stats,g=n?n.duration:o.duration;if(u.aborted||u.loaded&&u.loaded===u.total||o.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!l||i.paused||!i.playbackRate||!i.readyState)){var c=v.mainForwardBufferInfo;if(c!==null){var m=performance.now()-u.loading.start,e=Math.abs(i.playbackRate);if(!(m<=500*g/e)){var r=u.loaded&&u.loading.first,t=this.bwEstimator.getEstimate(),s=v.levels,y=v.minAutoLevel,f=s[o.level],b=u.total||Math.max(u.loaded,Math.round(g*f.maxBitrate/8)),R=r?u.loaded*1e3/m:0,I=R?(b-u.loaded)/R:b*8/t,k=c.len/e;if(!(I<=k)){var F=Number.POSITIVE_INFINITY,K;for(K=o.level-1;K>y;K--){var H=s[K].maxBitrate;if(F=R?g*H/(8*.8*R):g*H/t,F<k)break}F>=I||(A.logger.warn("Fragment "+o.sn+(n?" part "+n.index:"")+" of level "+o.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+K+`
9
+ Current BW estimate: `+((0,C.isFiniteNumber)(t)?(t/1024).toFixed(3):"Unknown")+` Kb/s
10
+ Estimated load time for current fragment: `+I.toFixed(3)+` s
11
+ Estimated load time for the next fragment: `+F.toFixed(3)+` s
12
+ Time to underbuffer: `+k.toFixed(3)+" s"),v.nextLoadLevel=K,r&&this.bwEstimator.sample(m,u.loaded),this.clearTimer(),(o.loader||o.keyLoader)&&(this.fragCurrent=this.partCurrent=null,o.abortRequests()),v.trigger(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:o,part:n,stats:u}))}}}}}},h.onFragLoaded=function(o,n){var v=n.frag,l=n.part;if(v.type===B.PlaylistLevelType.MAIN&&(0,C.isFiniteNumber)(v.sn)){var i=l?l.stats:v.stats,u=l?l.duration:v.duration;if(this.clearTimer(),this.lastLoadedFragLevel=v.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var g=this.hls.levels[v.level],c=(g.loaded?g.loaded.bytes:0)+i.loaded,m=(g.loaded?g.loaded.duration:0)+u;g.loaded={bytes:c,duration:m},g.realBitrate=Math.round(8*c/m)}if(v.bitrateTest){var e={stats:i,frag:v,part:l,id:v.type};this.onFragBuffered(M.Events.FRAG_BUFFERED,e)}}},h.onFragBuffered=function(o,n){var v=n.frag,l=n.part,i=l?l.stats:v.stats;if(!i.aborted&&!(v.type!==B.PlaylistLevelType.MAIN||v.sn==="initSegment")){var u=i.parsing.end-i.loading.start;this.bwEstimator.sample(u,i.loaded),i.bwEstimate=this.bwEstimator.getEstimate(),v.bitrateTest?this.bitrateTestDelay=u/1e3:this.bitrateTestDelay=0}},h.onError=function(o,n){var v;if(((v=n.frag)===null||v===void 0?void 0:v.type)===B.PlaylistLevelType.MAIN){if(n.type===P.ErrorTypes.KEY_SYSTEM_ERROR){this.clearTimer();return}switch(n.details){case P.ErrorDetails.FRAG_LOAD_ERROR:case P.ErrorDetails.FRAG_LOAD_TIMEOUT:case P.ErrorDetails.KEY_LOAD_ERROR:case P.ErrorDetails.KEY_LOAD_TIMEOUT:this.clearTimer();break;default:break}}},h.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},h.getNextABRAutoLevel=function(){var o=this.fragCurrent,n=this.partCurrent,v=this.hls,l=v.maxAutoLevel,i=v.config,u=v.minAutoLevel,g=v.media,c=n?n.duration:o?o.duration:0,m=g&&g.playbackRate!==0?Math.abs(g.playbackRate):1,e=this.bwEstimator?this.bwEstimator.getEstimate():i.abrEwmaDefaultEstimate,r=v.mainForwardBufferInfo,t=(r?r.len:0)/m,s=this.findBestLevel(e,u,l,t,i.abrBandWidthFactor,i.abrBandWidthUpFactor);if(s>=0)return s;A.logger.trace((t?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var y=c?Math.min(c,i.maxStarvationDelay):i.maxStarvationDelay,f=i.abrBandWidthFactor,b=i.abrBandWidthUpFactor;if(!t){var R=this.bitrateTestDelay;if(R){var I=c?Math.min(c,i.maxLoadingDelay):i.maxLoadingDelay;y=I-R,A.logger.trace("bitrate test took "+Math.round(1e3*R)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*y)+" ms"),f=b=1}}return s=this.findBestLevel(e,u,l,t+y,f,b),Math.max(s,0)},h.findBestLevel=function(o,n,v,l,i,u){for(var g,c=this.fragCurrent,m=this.partCurrent,e=this.lastLoadedFragLevel,r=this.hls.levels,t=r[e],s=!!(t!=null&&(g=t.details)!==null&&g!==void 0&&g.live),y=t==null?void 0:t.codecSet,f=m?m.duration:c?c.duration:0,b=v;b>=n;b--){var R=r[b];if(!(!R||y&&R.codecSet!==y)){var I=R.details,k=(m?I==null?void 0:I.partTarget:I==null?void 0:I.averagetargetduration)||f,F=void 0;b<=e?F=i*o:F=u*o;var K=r[b].maxBitrate,H=K*k/F;if(A.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+b+"/"+Math.round(F)+"/"+K+"/"+k+"/"+l+"/"+H),F>K&&(H===0||!(0,C.isFiniteNumber)(H)||s&&!this.bitrateTestDelay||H<l))return b}}return-1},x(p,[{key:"nextAutoLevel",get:function(){var o=this._nextAutoLevel,n=this.bwEstimator;if(o!==-1&&!n.canEstimate())return o;var v=this.getNextABRAutoLevel();return o!==-1&&this.hls.levels[v].loadError?o:(o!==-1&&(v=Math.min(o,v)),v)},set:function(o){this._nextAutoLevel=o}}]),p}();let E=d},"./src/controller/audio-stream-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>i});var C=T("./src/polyfills/number.ts"),L=T("./src/controller/base-stream-controller.ts"),M=T("./src/events.ts"),P=T("./src/utils/buffer-helper.ts"),B=T("./src/controller/fragment-tracker.ts"),A=T("./src/types/level.ts"),D=T("./src/types/loader.ts"),x=T("./src/loader/fragment.ts"),_=T("./src/demux/chunk-cache.ts"),S=T("./src/demux/transmuxer-interface.ts"),d=T("./src/types/transmuxer.ts"),E=T("./src/controller/fragment-finders.ts"),p=T("./src/utils/discontinuities.ts"),h=T("./src/errors.ts");function a(){return a=Object.assign?Object.assign.bind():function(u){for(var g=1;g<arguments.length;g++){var c=arguments[g];for(var m in c)Object.prototype.hasOwnProperty.call(c,m)&&(u[m]=c[m])}return u},a.apply(this,arguments)}function o(u,g){u.prototype=Object.create(g.prototype),u.prototype.constructor=u,n(u,g)}function n(u,g){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(m,e){return m.__proto__=e,m},n(u,g)}var v=100,l=function(u){o(g,u);function g(m,e,r){var t;return t=u.call(this,m,e,r,"[audio-stream-controller]")||this,t.videoBuffer=null,t.videoTrackCC=-1,t.waitingVideoCC=-1,t.audioSwitch=!1,t.trackId=-1,t.waitingData=null,t.mainDetails=null,t.bufferFlushed=!1,t.cachedTrackLoadedData=null,t._registerListeners(),t}var c=g.prototype;return c.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},c._registerListeners=function(){var e=this.hls;e.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(M.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(M.Events.ERROR,this.onError,this),e.on(M.Events.BUFFER_RESET,this.onBufferReset,this),e.on(M.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(M.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var e=this.hls;e.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(M.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(M.Events.ERROR,this.onError,this),e.off(M.Events.BUFFER_RESET,this.onBufferReset,this),e.off(M.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(M.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onInitPtsFound=function(e,r){var t=r.frag,s=r.id,y=r.initPTS;if(s==="main"){var f=t.cc;this.initPTS[t.cc]=y,this.log("InitPTS for cc: "+f+" found from main: "+y),this.videoTrackCC=f,this.state===L.State.WAITING_INIT_PTS&&this.tick()}},c.startLoad=function(e){if(!this.levels){this.startPosition=e,this.state=L.State.STOPPED;return}var r=this.lastCurrentTime;this.stopLoad(),this.setInterval(v),this.fragLoadError=0,r>0&&e===-1?(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),e=r,this.state=L.State.IDLE):(this.loadedmetadata=!1,this.state=L.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},c.doTick=function(){switch(this.state){case L.State.IDLE:this.doTickIdle();break;case L.State.WAITING_TRACK:{var e,r=this.levels,t=this.trackId,s=r==null||(e=r[t])===null||e===void 0?void 0:e.details;if(s){if(this.waitForCdnTuneIn(s))break;this.state=L.State.WAITING_INIT_PTS}break}case L.State.FRAG_LOADING_WAITING_RETRY:{var y,f=performance.now(),b=this.retryDate;(!b||f>=b||(y=this.media)!==null&&y!==void 0&&y.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 R=this.waitingData;if(R){var I=R.frag,k=R.part,F=R.cache,K=R.complete;if(this.initPTS[I.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=L.State.FRAG_LOADING;var H=F.flush(),j={frag:I,part:k,payload:H,networkDetails:null};this._handleFragmentLoadProgress(j),K&&u.prototype._handleFragmentLoadComplete.call(this,j)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+I.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var Y=this.getLoadPosition(),Q=P.BufferHelper.bufferInfo(this.mediaBuffer,Y,this.config.maxBufferHole),q=(0,E.fragmentWithinToleranceTest)(Q.end,this.config.maxFragLookUpTolerance,I);q<0&&(this.log("Waiting fragment cc ("+I.cc+") @ "+I.start+" cancelled because another fragment at "+Q.end+" is needed"),this.clearWaitingFragment())}}else this.state=L.State.IDLE}}this.onTickEnd()},c.clearWaitingFragment=function(){var e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=L.State.IDLE)},c.resetLoadingState=function(){this.clearWaitingFragment(),u.prototype.resetLoadingState.call(this)},c.onTickEnd=function(){var e=this.media;!e||!e.readyState||(this.lastCurrentTime=e.currentTime)},c.doTickIdle=function(){var e=this.hls,r=this.levels,t=this.media,s=this.trackId,y=e.config;if(!(!r||!r[s])&&!(!t&&(this.startFragRequested||!y.startFragPrefetch))){var f=r[s],b=f.details;if(!b||b.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(b)){this.state=L.State.WAITING_TRACK;return}var R=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&R&&(this.bufferFlushed=!1,this.afterBufferFlushed(R,x.ElementaryStreamTypes.AUDIO,D.PlaylistLevelType.AUDIO));var I=this.getFwdBufferInfo(R,D.PlaylistLevelType.AUDIO);if(I!==null){var k=this.audioSwitch;if(!k&&this._streamEnded(I,b)){e.trigger(M.Events.BUFFER_EOS,{type:"audio"}),this.state=L.State.ENDED;return}var F=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,D.PlaylistLevelType.MAIN),K=I.len,H=this.getMaxBufferLength(F==null?void 0:F.len);if(!(K>=H&&!k)){var j=b.fragments,Y=j[0].start,Q=I.end;if(k&&t){var q=this.getLoadPosition();Q=q,b.PTSKnown&&q<Y&&(I.end>Y||I.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),t.currentTime=Y+.05)}if(!(F&&Q>F.end+b.targetduration)&&!((!F||!F.len)&&I.len)){var ne=this.getNextFragment(Q,b);if(!ne){this.bufferFlushed=!0;return}this.loadFragment(ne,b,Q)}}}}},c.getMaxBufferLength=function(e){var r=u.prototype.getMaxBufferLength.call(this);return e?Math.max(r,e):r},c.onMediaDetaching=function(){this.videoBuffer=null,u.prototype.onMediaDetaching.call(this)},c.onAudioTracksUpdated=function(e,r){var t=r.audioTracks;this.resetTransmuxer(),this.levels=t.map(function(s){return new A.Level(s)})},c.onAudioTrackSwitching=function(e,r){var t=!!r.url;this.trackId=r.id;var s=this.fragCurrent;s&&s.abortRequests(),this.fragCurrent=null,this.clearWaitingFragment(),t?this.setInterval(v):this.resetTransmuxer(),t?(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(e,r){this.mainDetails=r.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(M.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},c.onAudioTrackLoaded=function(e,r){var t;if(this.mainDetails==null){this.cachedTrackLoadedData=r;return}var s=this.levels,y=r.details,f=r.id;if(!s){this.warn("Audio tracks were reset while loading level "+f);return}this.log("Track "+f+" loaded ["+y.startSN+","+y.endSN+"],duration:"+y.totalduration);var b=s[f],R=0;if(y.live||(t=b.details)!==null&&t!==void 0&&t.live){var I=this.mainDetails;if(y.fragments[0]||(y.deltaUpdateFailed=!0),y.deltaUpdateFailed||!I)return;!b.details&&y.hasProgramDateTime&&I.hasProgramDateTime?((0,p.alignMediaPlaylistByPDT)(y,I),R=y.fragments[0].start):R=this.alignPlaylists(y,b.details)}b.details=y,this.levelLastLoaded=f,!this.startFragRequested&&(this.mainDetails||!y.live)&&this.setStartPosition(b.details,R),this.state===L.State.WAITING_TRACK&&!this.waitForCdnTuneIn(y)&&(this.state=L.State.IDLE),this.tick()},c._handleFragmentLoadProgress=function(e){var r,t=e.frag,s=e.part,y=e.payload,f=this.config,b=this.trackId,R=this.levels;if(!R){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+t.sn+" of level "+t.level+" will not be buffered");return}var I=R[b];console.assert(I,"Audio track is defined on fragment load progress");var k=I.details;console.assert(k,"Audio track details are defined on fragment load progress");var F=f.defaultAudioCodec||I.audioCodec||"mp4a.40.2",K=this.transmuxer;K||(K=this.transmuxer=new S.default(this.hls,D.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var H=this.initPTS[t.cc],j=(r=t.initSegment)===null||r===void 0?void 0:r.data;if(H!==void 0){var Y=!1,Q=s?s.index:-1,q=Q!==-1,ne=new d.ChunkMetadata(t.level,t.sn,t.stats.chunkCount,y.byteLength,Q,q);K.push(y,j,F,"",t,s,k.totalduration,Y,ne,H)}else{this.log("Unknown video PTS for cc "+t.cc+", waiting for video PTS before demuxing audio frag "+t.sn+" of ["+k.startSN+" ,"+k.endSN+"],track "+b);var te=this.waitingData=this.waitingData||{frag:t,part:s,cache:new _.default,complete:!1},ae=te.cache;ae.push(new Uint8Array(y)),this.waitingVideoCC=this.videoTrackCC,this.state=L.State.WAITING_INIT_PTS}},c._handleFragmentLoadComplete=function(e){if(this.waitingData){this.waitingData.complete=!0;return}u.prototype._handleFragmentLoadComplete.call(this,e)},c.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},c.onBufferCreated=function(e,r){var t=r.tracks.audio;t&&(this.mediaBuffer=t.buffer||null),r.tracks.video&&(this.videoBuffer=r.tracks.video.buffer||null)},c.onFragBuffered=function(e,r){var t=r.frag,s=r.part;if(t.type!==D.PlaylistLevelType.AUDIO){if(!this.loadedmetadata&&t.type===D.PlaylistLevelType.MAIN){var y;(y=this.videoBuffer||this.media)!==null&&y!==void 0&&y.buffered.length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(t)){this.warn("Fragment "+t.sn+(s?" p: "+s.index:"")+" of level "+t.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}t.sn!=="initSegment"&&(this.fragPrevious=t,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(t,s)},c.onError=function(e,r){if(r.type===h.ErrorTypes.KEY_SYSTEM_ERROR){this.onFragmentOrKeyLoadError(D.PlaylistLevelType.AUDIO,r);return}switch(r.details){case h.ErrorDetails.FRAG_LOAD_ERROR:case h.ErrorDetails.FRAG_LOAD_TIMEOUT:case h.ErrorDetails.FRAG_PARSING_ERROR:case h.ErrorDetails.KEY_LOAD_ERROR:case h.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(D.PlaylistLevelType.AUDIO,r);break;case h.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case h.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==L.State.ERROR&&this.state!==L.State.STOPPED&&(this.state=r.fatal?L.State.ERROR:L.State.IDLE,this.warn(r.details+" while loading frag, switching to "+this.state+" state"));break;case h.ErrorDetails.BUFFER_FULL_ERROR:if(r.parent==="audio"&&(this.state===L.State.PARSING||this.state===L.State.PARSED)){var t=!0,s=this.getFwdBufferInfo(this.mediaBuffer,D.PlaylistLevelType.AUDIO);s&&s.len>.5&&(t=!this.reduceMaxBufferLength(s.len)),t&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,u.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},c.onBufferFlushed=function(e,r){var t=r.type;t===x.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0,this.state===L.State.ENDED&&(this.state=L.State.IDLE))},c._handleTransmuxComplete=function(e){var r,t="audio",s=this.hls,y=e.remuxResult,f=e.chunkMeta,b=this.getCurrentContext(f);if(!b){this.warn("The loading context changed while buffering fragment "+f.sn+" of level "+f.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(f.level);return}var R=b.frag,I=b.part,k=b.level.details,F=y.audio,K=y.text,H=y.id3,j=y.initSegment;if(!(this.fragContextChanged(R)||!k)){if(this.state=L.State.PARSING,this.audioSwitch&&F&&this.completeAudioSwitch(),j!=null&&j.tracks&&(this._bufferInitSegment(j.tracks,R,f),s.trigger(M.Events.FRAG_PARSING_INIT_SEGMENT,{frag:R,id:t,tracks:j.tracks})),F){var Y=F.startPTS,Q=F.endPTS,q=F.startDTS,ne=F.endDTS;I&&(I.elementaryStreams[x.ElementaryStreamTypes.AUDIO]={startPTS:Y,endPTS:Q,startDTS:q,endDTS:ne}),R.setElementaryStreamInfo(x.ElementaryStreamTypes.AUDIO,Y,Q,q,ne),this.bufferFragmentData(F,R,I,f)}if(H!=null&&(r=H.samples)!==null&&r!==void 0&&r.length){var te=a({id:t,frag:R,details:k},H);s.trigger(M.Events.FRAG_PARSING_METADATA,te)}if(K){var ae=a({id:t,frag:R,details:k},K);s.trigger(M.Events.FRAG_PARSING_USERDATA,ae)}}},c._bufferInitSegment=function(e,r,t){if(this.state===L.State.PARSING){e.video&&delete e.video;var s=e.audio;if(!!s){s.levelCodec=s.codec,s.id="audio",this.log("Init audio buffer, container:"+s.container+", codecs[parsed]=["+s.codec+"]"),this.hls.trigger(M.Events.BUFFER_CODECS,e);var y=s.initSegment;if(y!=null&&y.byteLength){var f={type:"audio",frag:r,part:null,chunkMeta:t,parent:r.type,data:y};this.hls.trigger(M.Events.BUFFER_APPENDING,f)}this.tick()}}},c.loadFragment=function(e,r,t){var s=this.fragmentTracker.getState(e);this.fragCurrent=e,(this.audioSwitch||s===B.FragmentState.NOT_LOADED||s===B.FragmentState.PARTIAL)&&(e.sn==="initSegment"?this._loadInitSegment(e,r):r.live&&!(0,C.isFiniteNumber)(this.initPTS[e.cc])?(this.log("Waiting for video PTS in continuity counter "+e.cc+" of live stream before loading audio fragment "+e.sn+" of level "+this.trackId),this.state=L.State.WAITING_INIT_PTS):(this.startFragRequested=!0,u.prototype.loadFragment.call(this,e,r,t)))},c.completeAudioSwitch=function(){var e=this.hls,r=this.media,t=this.trackId;r&&(this.log("Switching audio track : flushing all audio"),u.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,e.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:t})},g}(L.default);let i=l},"./src/controller/audio-track-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>E});var C=T("./src/events.ts"),L=T("./src/errors.ts"),M=T("./src/controller/base-playlist-controller.ts"),P=T("./src/types/loader.ts");function B(p,h){for(var a=0;a<h.length;a++){var o=h[a];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(p,D(o.key),o)}}function A(p,h,a){return h&&B(p.prototype,h),a&&B(p,a),Object.defineProperty(p,"prototype",{writable:!1}),p}function D(p){var h=x(p,"string");return typeof h=="symbol"?h:String(h)}function x(p,h){if(typeof p!="object"||p===null)return p;var a=p[Symbol.toPrimitive];if(a!==void 0){var o=a.call(p,h||"default");if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(h==="string"?String:Number)(p)}function _(p,h){p.prototype=Object.create(h.prototype),p.prototype.constructor=p,S(p,h)}function S(p,h){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,n){return o.__proto__=n,o},S(p,h)}var d=function(p){_(h,p);function h(o){var n;return n=p.call(this,o,"[audio-track-controller]")||this,n.tracks=[],n.groupId=null,n.tracksInGroup=[],n.trackId=-1,n.trackName="",n.selectDefaultTrack=!0,n.registerListeners(),n}var a=h.prototype;return a.registerListeners=function(){var n=this.hls;n.on(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),n.on(C.Events.LEVEL_LOADING,this.onLevelLoading,this),n.on(C.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),n.on(C.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.on(C.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var n=this.hls;n.off(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),n.off(C.Events.LEVEL_LOADING,this.onLevelLoading,this),n.off(C.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),n.off(C.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.off(C.Events.ERROR,this.onError,this)},a.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,p.prototype.destroy.call(this)},a.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},a.onManifestParsed=function(n,v){this.tracks=v.audioTracks||[]},a.onAudioTrackLoaded=function(n,v){var l=v.id,i=v.details,u=this.tracksInGroup[l];if(!u){this.warn("Invalid audio track id "+l);return}var g=u.details;u.details=v.details,this.log("audioTrack "+l+" loaded ["+i.startSN+"-"+i.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,v,g))},a.onLevelLoading=function(n,v){this.switchLevel(v.level)},a.onLevelSwitching=function(n,v){this.switchLevel(v.level)},a.switchLevel=function(n){var v=this.hls.levels[n];if(!!(v!=null&&v.audioGroupIds)){var l=v.audioGroupIds[v.urlId];if(this.groupId!==l){this.groupId=l;var i=this.tracks.filter(function(g){return!l||g.groupId===l});this.selectDefaultTrack&&!i.some(function(g){return g.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=i;var u={audioTracks:i};this.log("Updating audio tracks, "+i.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(C.Events.AUDIO_TRACKS_UPDATED,u),this.selectInitialTrack()}}},a.onError=function(n,v){p.prototype.onError.call(this,n,v),!(v.fatal||!v.context)&&v.context.type===P.PlaylistContextType.AUDIO_TRACK&&v.context.id===this.trackId&&v.context.groupId===this.groupId&&this.retryLoadingOrFail(v)},a.setAudioTrack=function(n){var v=this.tracksInGroup;if(n<0||n>=v.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var l=v[this.trackId];this.log("Now switching to audio-track index "+n);var i=v[n],u=i.id,g=i.groupId,c=g===void 0?"":g,m=i.name,e=i.type,r=i.url;if(this.trackId=n,this.trackName=m,this.selectDefaultTrack=!1,this.hls.trigger(C.Events.AUDIO_TRACK_SWITCHING,{id:u,groupId:c,name:m,type:e,url:r}),!(i.details&&!i.details.live)){var t=this.switchParams(i.url,l==null?void 0:l.details);this.loadPlaylist(t)}},a.selectInitialTrack=function(){var n=this.tracksInGroup;console.assert(n.length,"Initial audio track should be selected when tracks are known");var v=this.trackName,l=this.findTrackId(v)||this.findTrackId();l!==-1?this.setAudioTrack(l):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(C.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},a.findTrackId=function(n){for(var v=this.tracksInGroup,l=0;l<v.length;l++){var i=v[l];if((!this.selectDefaultTrack||i.default)&&(!n||n===i.name))return i.id}return-1},a.loadPlaylist=function(n){p.prototype.loadPlaylist.call(this);var v=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(v)){var l=v.id,i=v.groupId,u=v.url;if(n)try{u=n.addDirectives(u)}catch(g){this.warn("Could not construct new URL with HLS Delivery Directives: "+g)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(C.Events.AUDIO_TRACK_LOADING,{url:u,id:l,groupId:i,deliveryDirectives:n||null})}},A(h,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(n){this.selectDefaultTrack=!1,this.setAudioTrack(n)}}]),h}(M.default);let E=d},"./src/controller/base-playlist-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>B});var C=T("./src/types/level.ts"),L=T("./src/controller/level-helper.ts"),M=T("./src/utils/logger.ts"),P=T("./src/errors.ts"),B=function(){function A(x,_){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=M.logger.log.bind(M.logger,_+":"),this.warn=M.logger.warn.bind(M.logger,_+":"),this.hls=x}var D=A.prototype;return D.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},D.onError=function(_,S){S.fatal&&(S.type===P.ErrorTypes.NETWORK_ERROR||S.type===P.ErrorTypes.KEY_SYSTEM_ERROR)&&this.stopLoad()},D.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},D.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.requestScheduled=-1,this.loadPlaylist()},D.stopLoad=function(){this.canLoad=!1,this.clearTimer()},D.switchParams=function(_,S){var d=S==null?void 0:S.renditionReports;if(d)for(var E=0;E<d.length;E++){var p=d[E],h=void 0;try{h=new self.URL(p.URI,S.url).href}catch(v){M.logger.warn("Could not construct new URL for Rendition Report: "+v),h=p.URI||""}if(h===_.slice(-h.length)){var a=parseInt(p["LAST-MSN"])||(S==null?void 0:S.lastPartSn),o=parseInt(p["LAST-PART"])||(S==null?void 0:S.lastPartIndex);if(this.hls.config.lowLatencyMode){var n=Math.min(S.age-S.partTarget,S.targetduration);o>=0&&n>S.partTarget&&(o+=1)}return new C.HlsUrlParameters(a,o>=0?o:void 0,C.HlsSkip.No)}}},D.loadPlaylist=function(_){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},D.shouldLoadTrack=function(_){return this.canLoad&&_&&!!_.url&&(!_.details||_.details.live)},D.playlistLoaded=function(_,S,d){var E=this,p=S.details,h=S.stats,a=self.performance.now(),o=h.loading.first?Math.max(0,a-h.loading.first):0;if(p.advancedDateTime=Date.now()-o,p.live||d!=null&&d.live){if(p.reloaded(d),d&&this.log("live playlist "+_+" "+(p.advanced?"REFRESHED "+p.lastPartSn+"-"+p.lastPartIndex:"MISSED")),d&&p.fragments.length>0&&(0,L.mergeDetails)(d,p),!this.canLoad||!p.live)return;var n,v=void 0,l=void 0;if(p.canBlockReload&&p.endSN&&p.advanced){var i=this.hls.config.lowLatencyMode,u=p.lastPartSn,g=p.endSN,c=p.lastPartIndex,m=c!==-1,e=u===g,r=i?0:c;m?(v=e?g+1:u,l=e?r:c+1):v=g+1;var t=p.age,s=t+p.ageHeader,y=Math.min(s-p.partTarget,p.targetduration*1.5);if(y>0){if(d&&y>d.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+d.tuneInGoal+" to: "+y+" with playlist age: "+p.age),y=0;else{var f=Math.floor(y/p.targetduration);if(v+=f,l!==void 0){var b=Math.round(y%p.targetduration/p.partTarget);l+=b}this.log("CDN Tune-in age: "+p.ageHeader+"s last advanced "+t.toFixed(2)+"s goal: "+y+" skip sn "+f+" to part "+l)}p.tuneInGoal=y}if(n=this.getDeliveryDirectives(p,S.deliveryDirectives,v,l),i||!e){this.loadPlaylist(n);return}}else n=this.getDeliveryDirectives(p,S.deliveryDirectives,v,l);var R=this.hls.mainForwardBufferInfo,I=R?R.end-R.len:0,k=(p.edge-I)*1e3,F=(0,L.computeReloadInterval)(p,k);p.updated?a>this.requestScheduled+F&&(this.requestScheduled=h.loading.start):this.requestScheduled=-1,v!==void 0&&p.canBlockReload?this.requestScheduled=h.loading.first+F-(p.partTarget*1e3||1e3):this.requestScheduled=(this.requestScheduled===-1?a:this.requestScheduled)+F;var K=this.requestScheduled-a;K=Math.max(0,K),this.log("reload live playlist "+_+" in "+Math.round(K)+" ms"),this.timer=self.setTimeout(function(){return E.loadPlaylist(n)},K)}else this.clearTimer()},D.getDeliveryDirectives=function(_,S,d,E){var p=(0,C.getSkipValue)(_,d);return S!=null&&S.skip&&_.deltaUpdateFailed&&(d=S.msn,E=S.part,p=C.HlsSkip.No),new C.HlsUrlParameters(d,E,p)},D.retryLoadingOrFail=function(_){var S=this,d=this.hls.config,E=this.retryCount<d.levelLoadingMaxRetry;if(E){var p;if(this.requestScheduled=-1,this.retryCount++,_.details.indexOf("LoadTimeOut")>-1&&(p=_.context)!==null&&p!==void 0&&p.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+_.details+'"'),this.loadPlaylist();else{var h=Math.min(Math.pow(2,this.retryCount)*d.levelLoadingRetryDelay,d.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return S.loadPlaylist()},h),this.warn("retry playlist loading #"+this.retryCount+" in "+h+' ms after "'+_.details+'"')}}else this.warn('cannot recover from error "'+_.details+'"'),this.clearTimer(),_.fatal=!0;return E},A}()},"./src/controller/base-stream-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{State:()=>m,default:()=>e});var C=T("./src/polyfills/number.ts"),L=T("./src/task-loop.ts"),M=T("./src/controller/fragment-tracker.ts"),P=T("./src/utils/buffer-helper.ts"),B=T("./src/utils/logger.ts"),A=T("./src/events.ts"),D=T("./src/errors.ts"),x=T("./src/types/transmuxer.ts"),_=T("./src/utils/mp4-tools.ts"),S=T("./src/utils/discontinuities.ts"),d=T("./src/controller/fragment-finders.ts"),E=T("./src/controller/level-helper.ts"),p=T("./src/loader/fragment-loader.ts"),h=T("./src/crypt/decrypter.ts"),a=T("./src/utils/time-ranges.ts"),o=T("./src/types/loader.ts");function n(r,t){for(var s=0;s<t.length;s++){var y=t[s];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(r,l(y.key),y)}}function v(r,t,s){return t&&n(r.prototype,t),s&&n(r,s),Object.defineProperty(r,"prototype",{writable:!1}),r}function l(r){var t=i(r,"string");return typeof t=="symbol"?t:String(t)}function i(r,t){if(typeof r!="object"||r===null)return r;var s=r[Symbol.toPrimitive];if(s!==void 0){var y=s.call(r,t||"default");if(typeof y!="object")return y;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function u(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function g(r,t){r.prototype=Object.create(t.prototype),r.prototype.constructor=r,c(r,t)}function c(r,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(y,f){return y.__proto__=f,y},c(r,t)}var m={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"},e=function(r){g(t,r);function t(y,f,b,R){var I;return I=r.call(this)||this,I.hls=void 0,I.fragPrevious=null,I.fragCurrent=null,I.fragmentTracker=void 0,I.transmuxer=null,I._state=m.STOPPED,I.media=null,I.mediaBuffer=null,I.config=void 0,I.bitrateTest=!1,I.lastCurrentTime=0,I.nextLoadPosition=0,I.startPosition=0,I.loadedmetadata=!1,I.fragLoadError=0,I.retryDate=0,I.levels=null,I.fragmentLoader=void 0,I.keyLoader=void 0,I.levelLastLoaded=null,I.startFragRequested=!1,I.decrypter=void 0,I.initPTS=[],I.onvseeking=null,I.onvended=null,I.logPrefix="",I.log=void 0,I.warn=void 0,I.logPrefix=R,I.log=B.logger.log.bind(B.logger,R+":"),I.warn=B.logger.warn.bind(B.logger,R+":"),I.hls=y,I.fragmentLoader=new p.default(y.config),I.keyLoader=b,I.fragmentTracker=f,I.config=y.config,I.decrypter=new h.default(y.config),y.on(A.Events.LEVEL_SWITCHING,I.onLevelSwitching,u(I)),I}var s=t.prototype;return s.doTick=function(){this.onTickEnd()},s.onTickEnd=function(){},s.startLoad=function(f){},s.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort();var f=this.fragCurrent;f&&(f.abortRequests(),this.fragmentTracker.removeFragment(f)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=m.STOPPED},s._streamEnded=function(f,b){if(b.live||f.nextStart||!f.end||!this.media)return!1;var R=b.partList;if(R!=null&&R.length){var I=R[R.length-1],k=P.BufferHelper.isBuffered(this.media,I.start+I.duration/2);return k}var F=b.fragments[b.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(F)},s.getLevelDetails=function(){if(this.levels&&this.levelLastLoaded!==null){var f;return(f=this.levels[this.levelLastLoaded])===null||f===void 0?void 0:f.details}},s.onMediaAttached=function(f,b){var R=this.media=this.mediaBuffer=b.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),R.addEventListener("seeking",this.onvseeking),R.addEventListener("ended",this.onvended);var I=this.config;this.levels&&I.autoStartLoad&&this.state===m.STOPPED&&this.startLoad(I.startPosition)},s.onMediaDetaching=function(){var f=this.media;f!=null&&f.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),f&&this.onvseeking&&this.onvended&&(f.removeEventListener("seeking",this.onvseeking),f.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},s.onMediaSeeking=function(){var f=this.config,b=this.fragCurrent,R=this.media,I=this.mediaBuffer,k=this.state,F=R?R.currentTime:0,K=P.BufferHelper.bufferInfo(I||R,F,f.maxBufferHole);if(this.log("media seeking to "+((0,C.isFiniteNumber)(F)?F.toFixed(3):F)+", state: "+k),this.state===m.ENDED)this.resetLoadingState();else if(b){var H=f.maxFragLookUpTolerance,j=b.start-H,Y=b.start+b.duration+H;if(!K.len||Y<K.start||j>K.end){var Q=F>Y;(F<j||Q)&&(Q&&b.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),b.abortRequests()),this.resetLoadingState())}}R&&(this.lastCurrentTime=F),!this.loadedmetadata&&!K.len&&(this.nextLoadPosition=this.startPosition=F),this.tickImmediate()},s.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},s.onLevelSwitching=function(f,b){this.fragLoadError=0},s.onHandlerDestroying=function(){this.stopLoad(),r.prototype.onHandlerDestroying.call(this)},s.onHandlerDestroyed=function(){this.state=m.STOPPED,this.hls.off(A.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,r.prototype.onHandlerDestroyed.call(this)},s.loadFragment=function(f,b,R){this._loadFragForPlayback(f,b,R)},s._loadFragForPlayback=function(f,b,R){var I=this,k=function(K){if(I.fragContextChanged(f)){I.warn("Fragment "+f.sn+(K.part?" p: "+K.part.index:"")+" of level "+f.level+" was dropped during download."),I.fragmentTracker.removeFragment(f);return}f.stats.chunkCount++,I._handleFragmentLoadProgress(K)};this._doFragLoad(f,b,R,k).then(function(F){if(!!F){I.fragLoadError=0;var K=I.state;if(I.fragContextChanged(f)){(K===m.FRAG_LOADING||!I.fragCurrent&&K===m.PARSING)&&(I.fragmentTracker.removeFragment(f),I.state=m.IDLE);return}"payload"in F&&(I.log("Loaded fragment "+f.sn+" of level "+f.level),I.hls.trigger(A.Events.FRAG_LOADED,F)),I._handleFragmentLoadComplete(F)}}).catch(function(F){I.state===m.STOPPED||I.state===m.ERROR||(I.warn(F),I.resetFragmentLoading(f))})},s.flushMainBuffer=function(f,b,R){if(R===void 0&&(R=null),!!(f-b)){var I={startOffset:f,endOffset:b,type:R};this.fragLoadError=0,this.hls.trigger(A.Events.BUFFER_FLUSHING,I)}},s._loadInitSegment=function(f,b){var R=this;this._doFragLoad(f,b).then(function(I){if(!I||R.fragContextChanged(f)||!R.levels)throw new Error("init load aborted");return I}).then(function(I){var k=R.hls,F=I.payload,K=f.decryptdata;if(F&&F.byteLength>0&&K&&K.key&&K.iv&&K.method==="AES-128"){var H=self.performance.now();return R.decrypter.decrypt(new Uint8Array(F),K.key.buffer,K.iv.buffer).then(function(j){var Y=self.performance.now();return k.trigger(A.Events.FRAG_DECRYPTED,{frag:f,payload:j,stats:{tstart:H,tdecrypt:Y}}),I.payload=j,I})}return I}).then(function(I){var k=R.fragCurrent,F=R.hls,K=R.levels;if(!K)throw new Error("init load aborted, missing levels");var H=K[f.level].details;console.assert(H,"Level details are defined when init segment is loaded");var j=f.stats;R.state=m.IDLE,R.fragLoadError=0,f.data=new Uint8Array(I.payload),j.parsing.start=j.buffering.start=self.performance.now(),j.parsing.end=j.buffering.end=self.performance.now(),I.frag===k&&F.trigger(A.Events.FRAG_BUFFERED,{stats:j,frag:k,part:null,id:f.type}),R.tick()}).catch(function(I){R.state===m.STOPPED||R.state===m.ERROR||(R.warn(I),R.resetFragmentLoading(f))})},s.fragContextChanged=function(f){var b=this.fragCurrent;return!f||!b||f.level!==b.level||f.sn!==b.sn||f.urlId!==b.urlId},s.fragBufferedComplete=function(f,b){var R,I,k=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+f.type+" sn: "+f.sn+(b?" part: "+b.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+f.level+" "+(k?a.default.toString(P.BufferHelper.getBuffered(k)):"(detached)")),this.state=m.IDLE,k&&(!this.loadedmetadata&&f.type==o.PlaylistLevelType.MAIN&&k.buffered.length&&((R=this.fragCurrent)===null||R===void 0?void 0:R.sn)===((I=this.fragPrevious)===null||I===void 0?void 0:I.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},s.seekToStartPos=function(){},s._handleFragmentLoadComplete=function(f){var b=this.transmuxer;if(!!b){var R=f.frag,I=f.part,k=f.partsLoaded,F=!k||k.length===0||k.some(function(H){return!H}),K=new x.ChunkMetadata(R.level,R.sn,R.stats.chunkCount+1,0,I?I.index:-1,!F);b.flush(K)}},s._handleFragmentLoadProgress=function(f){},s._doFragLoad=function(f,b,R,I){var k,F=this;if(R===void 0&&(R=null),!this.levels)throw new Error("frag load aborted, missing levels");var K=null;if(f.encrypted&&!((k=f.decryptdata)!==null&&k!==void 0&&k.key)?(this.log("Loading key for "+f.sn+" of ["+b.startSN+"-"+b.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+f.level),this.state=m.KEY_LOADING,this.fragCurrent=f,K=this.keyLoader.load(f).then(function(q){if(!F.fragContextChanged(q.frag))return F.hls.trigger(A.Events.KEY_LOADED,q),q}),this.hls.trigger(A.Events.KEY_LOADING,{frag:f}),this.throwIfFragContextChanged("KEY_LOADING")):!f.encrypted&&b.encryptedFragments.length&&this.keyLoader.loadClear(f,b.encryptedFragments),R=Math.max(f.start,R||0),this.config.lowLatencyMode&&b){var H=b.partList;if(H&&I){R>f.end&&b.fragmentHint&&(f=b.fragmentHint);var j=this.getNextPart(H,f,R);if(j>-1){var Y=H[j];return this.log("Loading part sn: "+f.sn+" p: "+Y.index+" cc: "+f.cc+" of playlist ["+b.startSN+"-"+b.endSN+"] parts [0-"+j+"-"+(H.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+f.level+", target: "+parseFloat(R.toFixed(3))),this.nextLoadPosition=Y.start+Y.duration,this.state=m.FRAG_LOADING,this.hls.trigger(A.Events.FRAG_LOADING,{frag:f,part:H[j],targetBufferTime:R}),this.throwIfFragContextChanged("FRAG_LOADING parts"),K?K.then(function(q){return!q||F.fragContextChanged(q.frag)?null:F.doFragPartsLoad(f,H,j,I)}).catch(function(q){return F.handleFragLoadError(q)}):this.doFragPartsLoad(f,H,j,I).catch(function(q){return F.handleFragLoadError(q)})}else if(!f.url||this.loadedEndOfParts(H,R))return Promise.resolve(null)}}this.log("Loading fragment "+f.sn+" cc: "+f.cc+" "+(b?"of ["+b.startSN+"-"+b.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+f.level+", target: "+parseFloat(R.toFixed(3))),(0,C.isFiniteNumber)(f.sn)&&!this.bitrateTest&&(this.nextLoadPosition=f.start+f.duration),this.state=m.FRAG_LOADING,this.hls.trigger(A.Events.FRAG_LOADING,{frag:f,targetBufferTime:R}),this.throwIfFragContextChanged("FRAG_LOADING");var Q=this.config.progressive;return Q&&K?K.then(function(q){return!q||F.fragContextChanged(q==null?void 0:q.frag)?null:F.fragmentLoader.load(f,I)}).catch(function(q){return F.handleFragLoadError(q)}):Promise.all([this.fragmentLoader.load(f,Q?I:void 0),K]).then(function(q){var ne=q[0];return!Q&&ne&&I&&I(ne),ne}).catch(function(q){return F.handleFragLoadError(q)})},s.throwIfFragContextChanged=function(f){if(this.fragCurrent===null)throw new Error("frag load aborted, context changed in "+f)},s.doFragPartsLoad=function(f,b,R,I){var k=this;return new Promise(function(F,K){var H=[],j=function Y(Q){var q=b[Q];k.fragmentLoader.loadPart(f,q,I).then(function(ne){H[q.index]=ne;var te=ne.part;k.hls.trigger(A.Events.FRAG_LOADED,ne);var ae=b[Q+1];if(ae&&ae.fragment===f)Y(Q+1);else return F({frag:f,part:te,partsLoaded:H})}).catch(K)};j(R)})},s.handleFragLoadError=function(f){if("data"in f){var b=f.data;f.data&&b.details===D.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(b.frag,b.part):this.hls.trigger(A.Events.ERROR,b)}else this.hls.trigger(A.Events.ERROR,{type:D.ErrorTypes.OTHER_ERROR,details:D.ErrorDetails.INTERNAL_EXCEPTION,err:f,fatal:!0});return null},s._handleTransmuxerFlush=function(f){var b=this.getCurrentContext(f);if(!b||this.state!==m.PARSING){!this.fragCurrent&&this.state!==m.STOPPED&&this.state!==m.ERROR&&(this.state=m.IDLE);return}var R=b.frag,I=b.part,k=b.level,F=self.performance.now();R.stats.parsing.end=F,I&&(I.stats.parsing.end=F),this.updateLevelTiming(R,I,k,f.partial)},s.getCurrentContext=function(f){var b=this.levels,R=f.level,I=f.sn,k=f.part;if(!b||!b[R])return this.warn("Levels object was unset while buffering fragment "+I+" of level "+R+". The current chunk will not be buffered."),null;var F=b[R],K=k>-1?(0,E.getPartWith)(F,I,k):null,H=K?K.fragment:(0,E.getFragmentWithSN)(F,I,this.fragCurrent);return H?{frag:H,part:K,level:F}:null},s.bufferFragmentData=function(f,b,R,I){if(!(!f||this.state!==m.PARSING)){var k=f.data1,F=f.data2,K=k;if(k&&F&&(K=(0,_.appendUint8Array)(k,F)),!(!K||!K.length)){var H={type:f.type,frag:b,part:R,chunkMeta:I,parent:b.type,data:K};this.hls.trigger(A.Events.BUFFER_APPENDING,H),f.dropped&&f.independent&&!R&&this.flushBufferGap(b)}}},s.flushBufferGap=function(f){var b=this.media;if(!!b){if(!P.BufferHelper.isBuffered(b,b.currentTime)){this.flushMainBuffer(0,f.start);return}var R=b.currentTime,I=P.BufferHelper.bufferInfo(b,R,0),k=f.duration,F=Math.min(this.config.maxFragLookUpTolerance*2,k*.25),K=Math.max(Math.min(f.start-F,I.end-F),R+F);f.start-K>F&&this.flushMainBuffer(K,f.start)}},s.getFwdBufferInfo=function(f,b){var R=this.config,I=this.getLoadPosition();if(!(0,C.isFiniteNumber)(I))return null;var k=P.BufferHelper.bufferInfo(f,I,R.maxBufferHole);if(k.len===0&&k.nextStart!==void 0){var F=this.fragmentTracker.getBufferedFrag(I,b);if(F&&k.nextStart<F.end)return P.BufferHelper.bufferInfo(f,I,Math.max(k.nextStart,R.maxBufferHole))}return k},s.getMaxBufferLength=function(f){var b=this.config,R;return f?R=Math.max(8*b.maxBufferSize/f,b.maxBufferLength):R=b.maxBufferLength,Math.min(R,b.maxMaxBufferLength)},s.reduceMaxBufferLength=function(f){var b=this.config,R=f||b.maxBufferLength;return b.maxMaxBufferLength>=R?(b.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+b.maxMaxBufferLength+"s"),!0):!1},s.getNextFragment=function(f,b){var R=b.fragments,I=R.length;if(!I)return null;var k=this.config,F=R[0].start,K;if(b.live){var H=k.initialLiveManifestSize;if(I<H)return this.warn("Not enough fragments to start playback (have: "+I+", need: "+H+")"),null;!b.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(K=this.getInitialLiveFragment(b,R),this.startPosition=K?this.hls.liveSyncPosition||K.start:f)}else f<=F&&(K=R[0]);if(!K){var j=k.lowLatencyMode?b.partEnd:b.fragmentEnd;K=this.getFragmentAtPosition(f,j,b)}return this.mapToInitFragWhenRequired(K)},s.mapToInitFragWhenRequired=function(f){return f!=null&&f.initSegment&&!(f!=null&&f.initSegment.data)&&!this.bitrateTest?f.initSegment:f},s.getNextPart=function(f,b,R){for(var I=-1,k=!1,F=!0,K=0,H=f.length;K<H;K++){var j=f[K];if(F=F&&!j.independent,I>-1&&R<j.start)break;var Y=j.loaded;Y?I=-1:(k||j.independent||F)&&j.fragment===b&&(I=K),k=Y}return I},s.loadedEndOfParts=function(f,b){var R=f[f.length-1];return R&&b>R.start&&R.loaded},s.getInitialLiveFragment=function(f,b){var R=this.fragPrevious,I=null;if(R){if(f.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+R.programDateTime),I=(0,d.findFragmentByPDT)(b,R.endProgramDateTime,this.config.maxFragLookUpTolerance)),!I){var k=R.sn+1;if(k>=f.startSN&&k<=f.endSN){var F=b[k-f.startSN];R.cc===F.cc&&(I=F,this.log("Live playlist, switching playlist, load frag with next SN: "+I.sn))}I||(I=(0,d.findFragWithCC)(b,R.cc),I&&this.log("Live playlist, switching playlist, load frag with same CC: "+I.sn))}}else{var K=this.hls.liveSyncPosition;K!==null&&(I=this.getFragmentAtPosition(K,this.bitrateTest?f.fragmentEnd:f.edge,f))}return I},s.getFragmentAtPosition=function(f,b,R){var I=this.config,k=this.fragPrevious,F=R.fragments,K=R.endSN,H=R.fragmentHint,j=I.maxFragLookUpTolerance,Y=!!(I.lowLatencyMode&&R.partList&&H);Y&&H&&!this.bitrateTest&&(F=F.concat(H),K=H.sn);var Q;if(f<b){var q=f>b-j?0:j;Q=(0,d.findFragmentByPTS)(k,F,f,q)}else Q=F[F.length-1];if(Q){var ne=Q.sn-R.startSN;if(this.fragmentTracker.getState(Q)===M.FragmentState.OK&&(k=Q),k&&Q.sn===k.sn&&!Y){var te=k&&Q.level===k.level;if(te){var ae=F[ne+1];Q.sn<K&&this.fragmentTracker.getState(ae)!==M.FragmentState.OK?(this.log("SN "+Q.sn+" just loaded, load next one: "+ae.sn),Q=ae):Q=null}}}return Q},s.synchronizeToLiveEdge=function(f){var b=this.config,R=this.media;if(!!R){var I=this.hls.liveSyncPosition,k=R.currentTime,F=f.fragments[0].start,K=f.edge,H=k>=F-b.maxFragLookUpTolerance&&k<=K;if(I!==null&&R.duration>I&&(k<I||!H)){var j=b.liveMaxLatencyDuration!==void 0?b.liveMaxLatencyDuration:b.liveMaxLatencyDurationCount*f.targetduration;(!H&&R.readyState<4||k<K-j)&&(this.loadedmetadata||(this.nextLoadPosition=I),R.readyState&&(this.warn("Playback: "+k.toFixed(3)+" is located too far from the end of live sliding playlist: "+K+", reset currentTime to : "+I.toFixed(3)),R.currentTime=I))}}},s.alignPlaylists=function(f,b){var R=this.levels,I=this.levelLastLoaded,k=this.fragPrevious,F=I!==null?R[I]:null,K=f.fragments.length;if(!K)return this.warn("No fragments in live playlist"),0;var H=f.fragments[0].start,j=!b,Y=f.alignedSliding&&(0,C.isFiniteNumber)(H);if(j||!Y&&!H){(0,S.alignStream)(k,F,f);var Q=f.fragments[0].start;return this.log("Live playlist sliding: "+Q.toFixed(2)+" start-sn: "+(b?b.startSN:"na")+"->"+f.startSN+" prev-sn: "+(k?k.sn:"na")+" fragments: "+K),Q}return H},s.waitForCdnTuneIn=function(f){var b=3;return f.live&&f.canBlockReload&&f.partTarget&&f.tuneInGoal>Math.max(f.partHoldBack,f.partTarget*b)},s.setStartPosition=function(f,b){var R=this.startPosition;if(R<b&&(R=-1),R===-1||this.lastCurrentTime===-1){var I=f.startTimeOffset;(0,C.isFiniteNumber)(I)?(R=b+I,I<0&&(R+=f.totalduration),R=Math.min(Math.max(b,R),b+f.totalduration),this.log("Start time offset "+I+" found in playlist, adjust startPosition to "+R),this.startPosition=R):f.live?R=this.hls.liveSyncPosition||b:this.startPosition=R=0,this.lastCurrentTime=R}this.nextLoadPosition=R},s.getLoadPosition=function(){var f=this.media,b=0;return this.loadedmetadata&&f?b=f.currentTime:this.nextLoadPosition&&(b=this.nextLoadPosition),b},s.handleFragLoadAborted=function(f,b){this.transmuxer&&f.sn!=="initSegment"&&f.stats.aborted&&(this.warn("Fragment "+f.sn+(b?" part"+b.index:"")+" of level "+f.level+" was aborted"),this.resetFragmentLoading(f))},s.resetFragmentLoading=function(f){(!this.fragCurrent||!this.fragContextChanged(f)&&this.state!==m.FRAG_LOADING_WAITING_RETRY)&&(this.state=m.IDLE)},s.onFragmentOrKeyLoadError=function(f,b){if(b.fatal){this.stopLoad(),this.state=m.ERROR;return}var R=this.config;if(b.chunkMeta){var I=this.getCurrentContext(b.chunkMeta);I&&(b.frag=I.frag,b.levelRetry=!0,this.fragLoadError=R.fragLoadingMaxRetry)}var k=b.frag;if(!(!k||k.type!==f)){var F=this.fragCurrent;if(console.assert(F&&k.sn===F.sn&&k.level===F.level&&k.urlId===F.urlId,"Frag load error must match current frag to retry"),this.fragLoadError+1<=R.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var K=Math.min(Math.pow(2,this.fragLoadError)*R.fragLoadingRetryDelay,R.fragLoadingMaxRetryTimeout);this.warn("Fragment "+k.sn+" of "+f+" "+k.level+" failed to load, retrying in "+K+"ms"),this.retryDate=self.performance.now()+K,this.fragLoadError++,this.state=m.FRAG_LOADING_WAITING_RETRY}else b.levelRetry?(f===o.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=m.IDLE):(B.logger.error(b.details+" reaches max retry, redispatch as fatal ..."),b.fatal=!0,this.hls.stopLoad(),this.state=m.ERROR)}},s.afterBufferFlushed=function(f,b,R){if(!!f){var I=P.BufferHelper.getBuffered(f);this.fragmentTracker.detectEvictedFragments(b,I,R),this.state===m.ENDED&&this.resetLoadingState()}},s.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=m.IDLE},s.resetStartWhenNotLoaded=function(f){if(!this.loadedmetadata){this.startFragRequested=!1;var b=this.levels?this.levels[f].details:null;b!=null&&b.live?(this.startPosition=-1,this.setStartPosition(b,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},s.updateLevelTiming=function(f,b,R,I){var k=this,F=R.details;console.assert(!!F,"level.details must be defined");var K=Object.keys(f.elementaryStreams).reduce(function(H,j){var Y=f.elementaryStreams[j];if(Y){var Q=Y.endPTS-Y.startPTS;if(Q<=0)return k.warn("Could not parse fragment "+f.sn+" "+j+" duration reliably ("+Q+")"),H||!1;var q=I?0:(0,E.updateFragPTSDTS)(F,f,Y.startPTS,Y.endPTS,Y.startDTS,Y.endDTS);return k.hls.trigger(A.Events.LEVEL_PTS_UPDATED,{details:F,level:R,drift:q,type:j,frag:f,start:Y.startPTS,end:Y.endPTS}),!0}return H},!1);K||(this.warn("Found no media in fragment "+f.sn+" of level "+R.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=m.PARSED,this.hls.trigger(A.Events.FRAG_PARSED,{frag:f,part:b})},s.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},v(t,[{key:"state",get:function(){return this._state},set:function(f){var b=this._state;b!==f&&(this._state=f,this.log(b+"->"+f))}}]),t}(L.default)},"./src/controller/buffer-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>d});var C=T("./src/polyfills/number.ts"),L=T("./src/events.ts"),M=T("./src/utils/logger.ts"),P=T("./src/errors.ts"),B=T("./src/utils/buffer-helper.ts"),A=T("./src/utils/mediasource-helper.ts"),D=T("./src/loader/fragment.ts"),x=T("./src/controller/buffer-operation-queue.ts"),_=(0,A.getMediaSource)(),S=/([ha]vc.)(?:\.[^.,]+)+/,d=function(){function E(h){var a=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.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var o=a.hls,n=a.media,v=a.mediaSource;M.logger.log("[buffer-controller]: Media source opened"),n&&(a.updateMediaElementDuration(),o.trigger(L.Events.MEDIA_ATTACHED,{media:n})),v&&v.removeEventListener("sourceopen",a._onMediaSourceOpen),a.checkPendingTracks()},this._onMediaSourceClose=function(){M.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){M.logger.log("[buffer-controller]: Media source ended")},this.hls=h,this._initSourceBuffer(),this.registerListeners()}var p=E.prototype;return p.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},p.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},p.registerListeners=function(){var a=this.hls;a.on(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(L.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(L.Events.BUFFER_RESET,this.onBufferReset,this),a.on(L.Events.BUFFER_APPENDING,this.onBufferAppending,this),a.on(L.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.on(L.Events.BUFFER_EOS,this.onBufferEos,this),a.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),a.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),a.on(L.Events.FRAG_PARSED,this.onFragParsed,this),a.on(L.Events.FRAG_CHANGED,this.onFragChanged,this)},p.unregisterListeners=function(){var a=this.hls;a.off(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(L.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(L.Events.BUFFER_RESET,this.onBufferReset,this),a.off(L.Events.BUFFER_APPENDING,this.onBufferAppending,this),a.off(L.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.off(L.Events.BUFFER_EOS,this.onBufferEos,this),a.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),a.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),a.off(L.Events.FRAG_PARSED,this.onFragParsed,this),a.off(L.Events.FRAG_CHANGED,this.onFragChanged,this)},p._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new x.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},p.onManifestParsed=function(a,o){var n=2;(o.audio&&!o.video||!o.altAudio)&&(n=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=n,this.details=null,M.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},p.onMediaAttaching=function(a,o){var n=this.media=o.media;if(n&&_){var v=this.mediaSource=new _;v.addEventListener("sourceopen",this._onMediaSourceOpen),v.addEventListener("sourceended",this._onMediaSourceEnded),v.addEventListener("sourceclose",this._onMediaSourceClose),n.src=self.URL.createObjectURL(v),this._objectUrl=n.src}},p.onMediaDetaching=function(){var a=this.media,o=this.mediaSource,n=this._objectUrl;if(o){if(M.logger.log("[buffer-controller]: media source detaching"),o.readyState==="open")try{o.endOfStream()}catch(v){M.logger.warn("[buffer-controller]: onMediaDetaching: "+v.message+" while calling endOfStream")}this.onBufferReset(),o.removeEventListener("sourceopen",this._onMediaSourceOpen),o.removeEventListener("sourceended",this._onMediaSourceEnded),o.removeEventListener("sourceclose",this._onMediaSourceClose),a&&(n&&self.URL.revokeObjectURL(n),a.src===n?(a.removeAttribute("src"),a.load()):M.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 a=this;this.getSourceBufferTypes().forEach(function(o){var n=a.sourceBuffer[o];try{n&&(a.removeBufferListeners(o),a.mediaSource&&a.mediaSource.removeSourceBuffer(n),a.sourceBuffer[o]=void 0)}catch(v){M.logger.warn("[buffer-controller]: Failed to reset the "+o+" buffer",v)}}),this._initSourceBuffer()},p.onBufferCodecs=function(a,o){var n=this,v=this.getSourceBufferTypes().length;Object.keys(o).forEach(function(l){if(v){var i=n.tracks[l];if(i&&typeof i.buffer.changeType=="function"){var u=o[l],g=u.id,c=u.codec,m=u.levelCodec,e=u.container,r=u.metadata,t=(i.levelCodec||i.codec).replace(S,"$1"),s=(m||c).replace(S,"$1");if(t!==s){var y=e+";codecs="+(m||c);n.appendChangeType(l,y),M.logger.log("[buffer-controller]: switching codec "+t+" to "+s),n.tracks[l]={buffer:i.buffer,codec:c,container:e,levelCodec:m,metadata:r,id:g}}}}else n.pendingTracks[l]=o[l]}),!v&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},p.appendChangeType=function(a,o){var n=this,v=this.operationQueue,l={execute:function(){var u=n.sourceBuffer[a];u&&(M.logger.log("[buffer-controller]: changing "+a+" sourceBuffer type to "+o),u.changeType(o)),v.shiftAndExecuteNext(a)},onStart:function(){},onComplete:function(){},onError:function(u){M.logger.warn("[buffer-controller]: Failed to change "+a+" SourceBuffer type",u)}};v.append(l,a)},p.onBufferAppending=function(a,o){var n=this,v=this.hls,l=this.operationQueue,i=this.tracks,u=o.data,g=o.type,c=o.frag,m=o.part,e=o.chunkMeta,r=e.buffering[g],t=self.performance.now();r.start=t;var s=c.stats.buffering,y=m?m.stats.buffering:null;s.start===0&&(s.start=t),y&&y.start===0&&(y.start=t);var f=i.audio,b=!1;g==="audio"&&(f==null?void 0:f.container)==="audio/mpeg"&&(b=!this.lastMpegAudioChunk||e.id===1||this.lastMpegAudioChunk.sn!==e.sn,this.lastMpegAudioChunk=e);var R=c.start,I={execute:function(){if(r.executeStart=self.performance.now(),b){var F=n.sourceBuffer[g];if(F){var K=R-F.timestampOffset;Math.abs(K)>=.1&&(M.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+R+" (delta: "+K+") sn: "+c.sn+")"),F.timestampOffset=R)}}n.appendExecutor(u,g)},onStart:function(){},onComplete:function(){var F=self.performance.now();r.executeEnd=r.end=F,s.first===0&&(s.first=F),y&&y.first===0&&(y.first=F);var K=n.sourceBuffer,H={};for(var j in K)H[j]=B.BufferHelper.getBuffered(K[j]);n.appendError=0,n.hls.trigger(L.Events.BUFFER_APPENDED,{type:g,frag:c,part:m,chunkMeta:e,parent:c.type,timeRanges:H})},onError:function(F){M.logger.error("[buffer-controller]: Error encountered while trying to append to the "+g+" SourceBuffer",F);var K={type:P.ErrorTypes.MEDIA_ERROR,parent:c.type,details:P.ErrorDetails.BUFFER_APPEND_ERROR,err:F,fatal:!1};F.code===DOMException.QUOTA_EXCEEDED_ERR?K.details=P.ErrorDetails.BUFFER_FULL_ERROR:(n.appendError++,K.details=P.ErrorDetails.BUFFER_APPEND_ERROR,n.appendError>v.config.appendErrorMaxRetry&&(M.logger.error("[buffer-controller]: Failed "+v.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),K.fatal=!0,v.stopLoad())),v.trigger(L.Events.ERROR,K)}};l.append(I,g)},p.onBufferFlushing=function(a,o){var n=this,v=this.operationQueue,l=function(u){return{execute:n.removeExecutor.bind(n,u,o.startOffset,o.endOffset),onStart:function(){},onComplete:function(){n.hls.trigger(L.Events.BUFFER_FLUSHED,{type:u})},onError:function(c){M.logger.warn("[buffer-controller]: Failed to remove from "+u+" SourceBuffer",c)}}};o.type?v.append(l(o.type),o.type):this.getSourceBufferTypes().forEach(function(i){v.append(l(i),i)})},p.onFragParsed=function(a,o){var n=this,v=o.frag,l=o.part,i=[],u=l?l.elementaryStreams:v.elementaryStreams;u[D.ElementaryStreamTypes.AUDIOVIDEO]?i.push("audiovideo"):(u[D.ElementaryStreamTypes.AUDIO]&&i.push("audio"),u[D.ElementaryStreamTypes.VIDEO]&&i.push("video"));var g=function(){var m=self.performance.now();v.stats.buffering.end=m,l&&(l.stats.buffering.end=m);var e=l?l.stats:v.stats;n.hls.trigger(L.Events.FRAG_BUFFERED,{frag:v,part:l,stats:e,id:v.type})};i.length===0&&M.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+v.type+" level: "+v.level+" sn: "+v.sn),this.blockBuffers(g,i)},p.onFragChanged=function(a,o){this.flushBackBuffer()},p.onBufferEos=function(a,o){var n=this,v=this.getSourceBufferTypes().reduce(function(l,i){var u=n.sourceBuffer[i];return u&&(!o.type||o.type===i)&&(u.ending=!0,u.ended||(u.ended=!0,M.logger.log("[buffer-controller]: "+i+" sourceBuffer now EOS"))),l&&!!(!u||u.ended)},!0);v&&(M.logger.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){n.getSourceBufferTypes().forEach(function(i){var u=n.sourceBuffer[i];u&&(u.ending=!1)});var l=n.mediaSource;if(!l||l.readyState!=="open"){l&&M.logger.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+l.readyState);return}M.logger.log("[buffer-controller]: Calling mediaSource.endOfStream()"),l.endOfStream()}))},p.onLevelUpdated=function(a,o){var n=o.details;!n.fragments.length||(this.details=n,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},p.flushBackBuffer=function(){var a=this.hls,o=this.details,n=this.media,v=this.sourceBuffer;if(!(!n||o===null)){var l=this.getSourceBufferTypes();if(!!l.length){var i=o.live&&a.config.liveBackBufferLength!==null?a.config.liveBackBufferLength:a.config.backBufferLength;if(!(!(0,C.isFiniteNumber)(i)||i<0)){var u=n.currentTime,g=o.levelTargetDuration,c=Math.max(i,g),m=Math.floor(u/g)*g-c;l.forEach(function(e){var r=v[e];if(r){var t=B.BufferHelper.getBuffered(r);if(t.length>0&&m>t.start(0)){if(a.trigger(L.Events.BACK_BUFFER_REACHED,{bufferEnd:m}),o.live)a.trigger(L.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:m});else if(r.ended&&t.end(t.length-1)-u<g*2){M.logger.info("[buffer-controller]: Cannot flush "+e+" back buffer while SourceBuffer is in ended state");return}a.trigger(L.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:m,type:e})}}})}}}},p.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var a=this.details,o=this.hls,n=this.media,v=this.mediaSource,l=a.fragments[0].start+a.totalduration,i=n.duration,u=(0,C.isFiniteNumber)(v.duration)?v.duration:0;a.live&&o.config.liveDurationInfinity?(M.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),v.duration=1/0,this.updateSeekableRange(a)):(l>u&&l>i||!(0,C.isFiniteNumber)(i))&&(M.logger.log("[buffer-controller]: Updating Media Source duration to "+l.toFixed(3)),v.duration=l)}},p.updateSeekableRange=function(a){var o=this.mediaSource,n=a.fragments,v=n.length;if(v&&a.live&&o!==null&&o!==void 0&&o.setLiveSeekableRange){var l=Math.max(0,n[0].start),i=Math.max(l,l+a.totalduration);o.setLiveSeekableRange(l,i)}},p.checkPendingTracks=function(){var a=this.bufferCodecEventsExpected,o=this.operationQueue,n=this.pendingTracks,v=Object.keys(n).length;if(v&&!a||v===2){this.createSourceBuffers(n),this.pendingTracks={};var l=this.getSourceBufferTypes();if(l.length===0){this.hls.trigger(L.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}l.forEach(function(i){o.executeNext(i)})}},p.createSourceBuffers=function(a){var o=this.sourceBuffer,n=this.mediaSource;if(!n)throw Error("createSourceBuffers called when mediaSource was null");var v=0;for(var l in a)if(!o[l]){var i=a[l];if(!i)throw Error("source buffer exists for track "+l+", however track does not");var u=i.levelCodec||i.codec,g=i.container+";codecs="+u;M.logger.log("[buffer-controller]: creating sourceBuffer("+g+")");try{var c=o[l]=n.addSourceBuffer(g),m=l;this.addBufferListener(m,"updatestart",this._onSBUpdateStart),this.addBufferListener(m,"updateend",this._onSBUpdateEnd),this.addBufferListener(m,"error",this._onSBUpdateError),this.tracks[l]={buffer:c,codec:u,container:i.container,levelCodec:i.levelCodec,metadata:i.metadata,id:i.id},v++}catch(e){M.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+e.message),this.hls.trigger(L.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,mimeType:g})}}v&&this.hls.trigger(L.Events.BUFFER_CREATED,{tracks:this.tracks})},p._onSBUpdateStart=function(a){var o=this.operationQueue,n=o.current(a);n.onStart()},p._onSBUpdateEnd=function(a){var o=this.operationQueue,n=o.current(a);n.onComplete(),o.shiftAndExecuteNext(a)},p._onSBUpdateError=function(a,o){M.logger.error("[buffer-controller]: "+a+" SourceBuffer error",o),this.hls.trigger(L.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var n=this.operationQueue.current(a);n&&n.onError(o)},p.removeExecutor=function(a,o,n){var v=this.media,l=this.mediaSource,i=this.operationQueue,u=this.sourceBuffer,g=u[a];if(!v||!l||!g){M.logger.warn("[buffer-controller]: Attempting to remove from the "+a+" SourceBuffer, but it does not exist"),i.shiftAndExecuteNext(a);return}var c=(0,C.isFiniteNumber)(v.duration)?v.duration:1/0,m=(0,C.isFiniteNumber)(l.duration)?l.duration:1/0,e=Math.max(0,o),r=Math.min(n,c,m);r>e&&!g.ending?(g.ended=!1,M.logger.log("[buffer-controller]: Removing ["+e+","+r+"] from the "+a+" SourceBuffer"),console.assert(!g.updating,a+" sourceBuffer must not be updating"),g.remove(e,r)):i.shiftAndExecuteNext(a)},p.appendExecutor=function(a,o){var n=this.operationQueue,v=this.sourceBuffer,l=v[o];if(!l){M.logger.warn("[buffer-controller]: Attempting to append to the "+o+" SourceBuffer, but it does not exist"),n.shiftAndExecuteNext(o);return}l.ended=!1,console.assert(!l.updating,o+" sourceBuffer must not be updating"),l.appendBuffer(a)},p.blockBuffers=function(a,o){var n=this;if(o===void 0&&(o=this.getSourceBufferTypes()),!o.length){M.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(a);return}var v=this.operationQueue,l=o.map(function(i){return v.appendBlocker(i)});Promise.all(l).then(function(){a(),o.forEach(function(i){var u=n.sourceBuffer[i];(!u||!u.updating)&&v.shiftAndExecuteNext(i)})})},p.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},p.addBufferListener=function(a,o,n){var v=this.sourceBuffer[a];if(!!v){var l=n.bind(this,a);this.listeners[a].push({event:o,listener:l}),v.addEventListener(o,l)}},p.removeBufferListeners=function(a){var o=this.sourceBuffer[a];!o||this.listeners[a].forEach(function(n){o.removeEventListener(n.event,n.listener)})},E}()},"./src/controller/buffer-operation-queue.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>L});var C=T("./src/utils/logger.ts"),L=function(){function M(B){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=B}var P=M.prototype;return P.append=function(A,D){var x=this.queues[D];x.push(A),x.length===1&&this.buffers[D]&&this.executeNext(D)},P.insertAbort=function(A,D){var x=this.queues[D];x.unshift(A),this.executeNext(D)},P.appendBlocker=function(A){var D,x=new Promise(function(S){D=S}),_={execute:D,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(_,A),x},P.executeNext=function(A){var D=this.buffers,x=this.queues,_=D[A],S=x[A];if(S.length){var d=S[0];try{d.execute()}catch(E){C.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),d.onError(E),(!_||!_.updating)&&(S.shift(),this.executeNext(A))}}},P.shiftAndExecuteNext=function(A){this.queues[A].shift(),this.executeNext(A)},P.current=function(A){return this.queues[A][0]},M}()},"./src/controller/cap-level-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>D});var C=T("./src/events.ts");function L(x,_){for(var S=0;S<_.length;S++){var d=_[S];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(x,P(d.key),d)}}function M(x,_,S){return _&&L(x.prototype,_),S&&L(x,S),Object.defineProperty(x,"prototype",{writable:!1}),x}function P(x){var _=B(x,"string");return typeof _=="symbol"?_:String(_)}function B(x,_){if(typeof x!="object"||x===null)return x;var S=x[Symbol.toPrimitive];if(S!==void 0){var d=S.call(x,_||"default");if(typeof d!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(_==="string"?String:Number)(x)}var A=function(){function x(S){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=S,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var _=x.prototype;return _.setStreamController=function(d){this.streamController=d},_.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},_.registerListeners=function(){var d=this.hls;d.on(C.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),d.on(C.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),d.on(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.on(C.Events.BUFFER_CODECS,this.onBufferCodecs,this),d.on(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},_.unregisterListener=function(){var d=this.hls;d.off(C.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),d.off(C.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),d.off(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.off(C.Events.BUFFER_CODECS,this.onBufferCodecs,this),d.off(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},_.onFpsDropLevelCapping=function(d,E){x.isLevelAllowed(E.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(E.droppedLevel)},_.onMediaAttaching=function(d,E){this.media=E.media instanceof HTMLVideoElement?E.media:null,this.clientRect=null},_.onManifestParsed=function(d,E){var p=this.hls;this.restrictedLevels=[],this.firstLevel=E.firstLevel,p.config.capLevelToPlayerSize&&E.video&&this.startCapping()},_.onBufferCodecs=function(d,E){var p=this.hls;p.config.capLevelToPlayerSize&&E.video&&this.startCapping()},_.onMediaDetaching=function(){this.stopCapping()},_.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var d=this.hls.levels;if(d.length){var E=this.hls;E.autoLevelCapping=this.getMaxLevel(d.length-1),E.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=E.autoLevelCapping}}},_.getMaxLevel=function(d){var E=this,p=this.hls.levels;if(!p.length)return-1;var h=p.filter(function(a,o){return x.isLevelAllowed(o,E.restrictedLevels)&&o<=d});return this.clientRect=null,x.getMaxLevelByMediaSize(h,this.mediaWidth,this.mediaHeight)},_.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())},_.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},_.getDimensions=function(){if(this.clientRect)return this.clientRect;var d=this.media,E={width:0,height:0};if(d){var p=d.getBoundingClientRect();E.width=p.width,E.height=p.height,!E.width&&!E.height&&(E.width=p.right-p.left||d.width||0,E.height=p.bottom-p.top||d.height||0)}return this.clientRect=E,E},x.isLevelAllowed=function(d,E){return E===void 0&&(E=[]),E.indexOf(d)===-1},x.getMaxLevelByMediaSize=function(d,E,p){if(!d||!d.length)return-1;for(var h=function(l,i){return i?l.width!==i.width||l.height!==i.height:!0},a=d.length-1,o=0;o<d.length;o+=1){var n=d[o];if((n.width>=E||n.height>=p)&&h(n,d[o+1])){a=o;break}}return a},M(x,[{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 d=1;if(!this.hls.config.ignoreDevicePixelRatio)try{d=self.devicePixelRatio}catch{}return d}}]),x}();let D=A},"./src/controller/cmcd-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>p});var C=T("./src/events.ts"),L=T("./src/types/cmcd.ts"),M=T("./src/utils/buffer-helper.ts"),P=T("./src/utils/logger.ts");function B(h,a){for(var o=0;o<a.length;o++){var n=a[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(h,D(n.key),n)}}function A(h,a,o){return a&&B(h.prototype,a),o&&B(h,o),Object.defineProperty(h,"prototype",{writable:!1}),h}function D(h){var a=x(h,"string");return typeof a=="symbol"?a:String(a)}function x(h,a){if(typeof h!="object"||h===null)return h;var o=h[Symbol.toPrimitive];if(o!==void 0){var n=o.call(h,a||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(h)}function _(h,a){var o=typeof Symbol!="undefined"&&h[Symbol.iterator]||h["@@iterator"];if(o)return(o=o.call(h)).next.bind(o);if(Array.isArray(h)||(o=S(h))||a&&h&&typeof h.length=="number"){o&&(h=o);var n=0;return function(){return n>=h.length?{done:!0}:{done:!1,value:h[n++]}}}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 S(h,a){if(!!h){if(typeof h=="string")return d(h,a);var o=Object.prototype.toString.call(h).slice(8,-1);if(o==="Object"&&h.constructor&&(o=h.constructor.name),o==="Map"||o==="Set")return Array.from(h);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return d(h,a)}}function d(h,a){(a==null||a>h.length)&&(a=h.length);for(var o=0,n=new Array(a);o<a;o++)n[o]=h[o];return n}function E(){return E=Object.assign?Object.assign.bind():function(h){for(var a=1;a<arguments.length;a++){var o=arguments[a];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(h[n]=o[n])}return h},E.apply(this,arguments)}var p=function(){function h(o){var n=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(){n.initialized&&(n.starved=!0),n.buffering=!0},this.onPlaying=function(){n.initialized||(n.initialized=!0),n.buffering=!1},this.applyPlaylistData=function(i){try{n.apply(i,{ot:L.CMCDObjectType.MANIFEST,su:!n.initialized})}catch(u){P.logger.warn("Could not generate manifest CMCD data.",u)}},this.applyFragmentData=function(i){try{var u=i.frag,g=n.hls.levels[u.level],c=n.getObjectType(u),m={d:u.duration*1e3,ot:c};(c===L.CMCDObjectType.VIDEO||c===L.CMCDObjectType.AUDIO||c==L.CMCDObjectType.MUXED)&&(m.br=g.bitrate/1e3,m.tb=n.getTopBandwidth(c)/1e3,m.bl=n.getBufferLength(c)),n.apply(i,m)}catch(e){P.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=o;var v=this.config=o.config,l=v.cmcd;l!=null&&(v.pLoader=this.createPlaylistLoader(),v.fLoader=this.createFragmentLoader(),this.sid=l.sessionId||h.uuid(),this.cid=l.contentId,this.useHeaders=l.useHeaders===!0,this.registerListeners())}var a=h.prototype;return a.registerListeners=function(){var n=this.hls;n.on(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(C.Events.MEDIA_DETACHED,this.onMediaDetached,this),n.on(C.Events.BUFFER_CREATED,this.onBufferCreated,this)},a.unregisterListeners=function(){var n=this.hls;n.off(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(C.Events.MEDIA_DETACHED,this.onMediaDetached,this),n.off(C.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},a.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},a.onMediaAttached=function(n,v){this.media=v.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},a.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},a.onBufferCreated=function(n,v){var l,i;this.audioBuffer=(l=v.tracks.audio)===null||l===void 0?void 0:l.buffer,this.videoBuffer=(i=v.tracks.video)===null||i===void 0?void 0:i.buffer},a.createData=function(){var n;return{v:L.CMCDVersion,sf:L.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(n=this.media)===null||n===void 0?void 0:n.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},a.apply=function(n,v){v===void 0&&(v={}),E(v,this.createData());var l=v.ot===L.CMCDObjectType.INIT||v.ot===L.CMCDObjectType.VIDEO||v.ot===L.CMCDObjectType.MUXED;if(this.starved&&l&&(v.bs=!0,v.su=!0,this.starved=!1),v.su==null&&(v.su=this.buffering),this.useHeaders){var i=h.toHeaders(v);if(!Object.keys(i).length)return;n.headers||(n.headers={}),E(n.headers,i)}else{var u=h.toQuery(v);if(!u)return;n.url=h.appendQueryToUri(n.url,u)}},a.getObjectType=function(n){var v=n.type;if(v==="subtitle")return L.CMCDObjectType.TIMED_TEXT;if(n.sn==="initSegment")return L.CMCDObjectType.INIT;if(v==="audio")return L.CMCDObjectType.AUDIO;if(v==="main")return this.hls.audioTracks.length?L.CMCDObjectType.VIDEO:L.CMCDObjectType.MUXED},a.getTopBandwidth=function(n){var v=0,l,i=this.hls;if(n===L.CMCDObjectType.AUDIO)l=i.audioTracks;else{var u=i.maxAutoLevel,g=u>-1?u+1:i.levels.length;l=i.levels.slice(0,g)}for(var c=_(l),m;!(m=c()).done;){var e=m.value;e.bitrate>v&&(v=e.bitrate)}return v>0?v:NaN},a.getBufferLength=function(n){var v=this.hls.media,l=n===L.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!l||!v)return NaN;var i=M.BufferHelper.bufferInfo(l,v.currentTime,this.config.maxBufferHole);return i.len*1e3},a.createPlaylistLoader=function(){var n=this.config.pLoader,v=this.applyPlaylistData,l=n||this.config.loader;return function(){function i(g){this.loader=void 0,this.loader=new l(g)}var u=i.prototype;return u.destroy=function(){this.loader.destroy()},u.abort=function(){this.loader.abort()},u.load=function(c,m,e){v(c),this.loader.load(c,m,e)},A(i,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),i}()},a.createFragmentLoader=function(){var n=this.config.fLoader,v=this.applyFragmentData,l=n||this.config.loader;return function(){function i(g){this.loader=void 0,this.loader=new l(g)}var u=i.prototype;return u.destroy=function(){this.loader.destroy()},u.abort=function(){this.loader.abort()},u.load=function(c,m,e){v(c),this.loader.load(c,m,e)},A(i,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),i}()},h.uuid=function(){var n=URL.createObjectURL(new Blob),v=n.toString();return URL.revokeObjectURL(n),v.slice(v.lastIndexOf("/")+1)},h.serialize=function(n){for(var v=[],l=function(I){return!Number.isNaN(I)&&I!=null&&I!==""&&I!==!1},i=function(I){return Math.round(I)},u=function(I){return i(I/100)*100},g=function(I){return encodeURIComponent(I)},c={br:i,d:i,bl:u,dl:u,mtp:u,nor:g,rtp:u,tb:i},m=Object.keys(n||{}).sort(),e=_(m),r;!(r=e()).done;){var t=r.value,s=n[t];if(!!l(s)&&!(t==="v"&&s===1)&&!(t=="pr"&&s===1)){var y=c[t];y&&(s=y(s));var f=typeof s,b=void 0;t==="ot"||t==="sf"||t==="st"?b=t+"="+s:f==="boolean"?b=t:f==="number"?b=t+"="+s:b=t+"="+JSON.stringify(s),v.push(b)}}return v.join(",")},h.toHeaders=function(n){for(var v=Object.keys(n),l={},i=["Object","Request","Session","Status"],u=[{},{},{},{}],g={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},c=0,m=v;c<m.length;c++){var e=m[c],r=g[e]!=null?g[e]:1;u[r][e]=n[e]}for(var t=0;t<u.length;t++){var s=h.serialize(u[t]);s&&(l["CMCD-"+i[t]]=s)}return l},h.toQuery=function(n){return"CMCD="+encodeURIComponent(h.serialize(n))},h.appendQueryToUri=function(n,v){if(!v)return n;var l=n.includes("?")?"&":"?";return""+n+l+v},h}()},"./src/controller/eme-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>c});var C=T("./src/events.ts"),L=T("./src/errors.ts"),M=T("./src/utils/logger.ts"),P=T("./src/utils/mediakeys-helper.ts"),B=T("./src/utils/keysystem-util.ts"),A=T("./src/utils/numeric-encoding-utils.ts"),D=T("./src/loader/level-key.ts"),x=T("./src/utils/hex.ts"),_=T("./src/utils/mp4-tools.ts"),S=T("./node_modules/eventemitter3/index.js"),d=T.n(S);function E(m,e){m.prototype=Object.create(e.prototype),m.prototype.constructor=m,n(m,e)}function p(m){var e=typeof Map=="function"?new Map:void 0;return p=function(t){if(t===null||!o(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(t))return e.get(t);e.set(t,s)}function s(){return h(t,arguments,v(this).constructor)}return s.prototype=Object.create(t.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),n(s,t)},p(m)}function h(m,e,r){return a()?h=Reflect.construct.bind():h=function(s,y,f){var b=[null];b.push.apply(b,y);var R=Function.bind.apply(s,b),I=new R;return f&&n(I,f.prototype),I},h.apply(null,arguments)}function a(){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 o(m){return Function.toString.call(m).indexOf("[native code]")!==-1}function n(m,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,s){return t.__proto__=s,t},n(m,e)}function v(m){return v=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},v(m)}var l=3,i="[eme]",u=function(){function m(r){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=m.CDMCleanupPromise?[m.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=M.logger.debug.bind(M.logger,i),this.log=M.logger.log.bind(M.logger,i),this.warn=M.logger.warn.bind(M.logger,i),this.error=M.logger.error.bind(M.logger,i),this.hls=r,this.config=r.config,this.registerListeners()}var e=m.prototype;return e.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null},e.registerListeners=function(){this.hls.on(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(C.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(C.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},e.unregisterListeners=function(){this.hls.off(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(C.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(C.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},e.getLicenseServerUrl=function(t){var s=this.config,y=s.drmSystems,f=s.widevineLicenseUrl,b=y[t];if(b)return b.licenseUrl;if(t===P.KeySystems.WIDEVINE&&f)return f;throw new Error('no license server URL configured for key-system "'+t+'"')},e.getServerCertificateUrl=function(t){var s=this.config.drmSystems,y=s[t];if(y)return y.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+t+'"]')},e.attemptKeySystemAccess=function(t){var s=this,y=this.hls.levels,f=function(k,F,K){return!!k&&K.indexOf(k)===F},b=y.map(function(I){return I.audioCodec}).filter(f),R=y.map(function(I){return I.videoCodec}).filter(f);return b.length+R.length===0&&R.push("avc1.42e01e"),new Promise(function(I,k){var F=function K(H){var j=H.shift();s.getMediaKeysPromise(j,b,R).then(function(Y){return I({keySystem:j,mediaKeys:Y})}).catch(function(Y){H.length?K(H):Y instanceof g?k(Y):k(new g({type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_ACCESS,error:Y,fatal:!0},Y.message))})};F(t)})},e.requestMediaKeySystemAccess=function(t,s){var y=this.config.requestMediaKeySystemAccessFunc;if(typeof y!="function"){var f="Configured requestMediaKeySystemAccess is not a function "+y;return P.requestMediaKeySystemAccess===null&&self.location.protocol==="http:"&&(f="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(f))}return y(t,s)},e.getMediaKeysPromise=function(t,s,y){var f=this,b=(0,P.getSupportedMediaKeySystemConfigurations)(t,s,y,this.config.drmSystemOptions),R=this.keySystemAccessPromises[t],I=R==null?void 0:R.keySystemAccess;if(!I){this.log('Requesting encrypted media "'+t+'" key-system access with config: '+JSON.stringify(b)),I=this.requestMediaKeySystemAccess(t,b);var k=this.keySystemAccessPromises[t]={keySystemAccess:I};return I.catch(function(F){f.log('Failed to obtain access to key-system "'+t+'": '+F)}),I.then(function(F){f.log('Access for key-system "'+F.keySystem+'" obtained');var K=f.fetchServerCertificate(t);return f.log('Create media-keys for "'+t+'"'),k.mediaKeys=F.createMediaKeys().then(function(H){return f.log('Media-keys created for "'+t+'"'),K.then(function(j){return j?f.setMediaKeysServerCertificate(H,t,j):H})}),k.mediaKeys.catch(function(H){f.error('Failed to create media-keys for "'+t+'"}: '+H)}),k.mediaKeys})}return I.then(function(){return R.mediaKeys})},e.createMediaKeySessionContext=function(t){var s=t.decryptdata,y=t.keySystem,f=t.mediaKeys;console.assert(!!f,"mediaKeys is defined"),this.log('Creating key-system session "'+y+'" keyId: '+x.default.hexDump(s.keyId||[]));var b=f.createSession(),R={decryptdata:s,keySystem:y,mediaKeys:f,mediaKeysSession:b,keyStatus:"status-pending"};return this.mediaKeySessions.push(R),R},e.renewKeySession=function(t){var s=t.decryptdata;if(s.pssh){var y=this.createMediaKeySessionContext(t),f=this.getKeyIdString(s),b="cenc";this.keyIdToKeySessionPromise[f]=this.generateRequestWithPreferredKeySession(y,b,s.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)},e.getKeyIdString=function(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(t.keyId===null)throw new Error("keyId is null");return x.default.hexDump(t.keyId)},e.updateKeySession=function(t,s){var y,f=t.mediaKeysSession;return this.log('Updating key-session "'+f.sessionId+'" for keyID '+x.default.hexDump(((y=t.decryptdata)===null||y===void 0?void 0:y.keyId)||[])+`
14
+ } (data length: `+(s&&s.byteLength)+")"),f.update(s)},e.selectKeySystemFormat=function(t){var s=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+t.sn+" "+t.type+": "+t.level+") key formats "+s.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(s)),this.keyFormatPromise},e.getKeyFormatPromise=function(t){var s=this;return new Promise(function(y,f){var b=(0,P.getKeySystemsForConfig)(s.config),R=t.map(P.keySystemFormatToKeySystemDomain).filter(function(I){return!!I&&b.indexOf(I)!==-1});return s.getKeySystemSelectionPromise(R).then(function(I){var k=I.keySystem,F=(0,P.keySystemDomainToKeySystemFormat)(k);F?y(F):f(new Error('Unable to find format for key-system "'+k+'"'))}).catch(f)})},e.loadKey=function(t){var s=this,y=t.keyInfo.decryptdata,f=this.getKeyIdString(y),b="(keyId: "+f+' format: "'+y.keyFormat+'" method: '+y.method+" uri: "+y.uri+")";this.log("Starting session for key "+b);var R=this.keyIdToKeySessionPromise[f];return R||(R=this.keyIdToKeySessionPromise[f]=this.getKeySystemForKeyPromise(y).then(function(I){var k=I.keySystem,F=I.mediaKeys;return s.throwIfDestroyed(),s.log("Handle encrypted media sn: "+t.frag.sn+" "+t.frag.type+": "+t.frag.level+" using key "+b),s.attemptSetMediaKeys(k,F).then(function(){s.throwIfDestroyed();var K=s.createMediaKeySessionContext({keySystem:k,mediaKeys:F,decryptdata:y}),H="cenc";return s.generateRequestWithPreferredKeySession(K,H,y.pssh,"playlist-key")})}),R.catch(function(I){return s.handleError(I)})),R},e.throwIfDestroyed=function(t){if(t===void 0&&(t="Invalid state"),!this.hls)throw new Error("invalid state")},e.handleError=function(t){!this.hls||(this.error(t.message),t instanceof g?this.hls.trigger(C.Events.ERROR,t.data):this.hls.trigger(C.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))},e.getKeySystemForKeyPromise=function(t){var s=this.getKeyIdString(t),y=this.keyIdToKeySessionPromise[s];if(!y){var f=(0,P.keySystemFormatToKeySystemDomain)(t.keyFormat),b=f?[f]:(0,P.getKeySystemsForConfig)(this.config);return this.attemptKeySystemAccess(b)}return y},e.getKeySystemSelectionPromise=function(t){if(t.length||(t=(0,P.getKeySystemsForConfig)(this.config)),t.length===0)throw new g({type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(t)},e._onMediaEncrypted=function(t){var s=this,y=t.initDataType,f=t.initData;if(this.debug('"'+t.type+'" event: init data type: "'+y+'"'),f!==null){var b,R;if(y==="sinf"&&this.config.drmSystems[P.KeySystems.FAIRPLAY]){var I=(0,_.bin2str)(new Uint8Array(f));try{var k=(0,A.base64Decode)(JSON.parse(I).sinf),F=(0,_.parseSinf)(new Uint8Array(k));if(!F)return;b=F.subarray(8,24),R=P.KeySystems.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{var K=(0,_.parsePssh)(f);if(K===null)return;K.version===0&&K.systemId===P.KeySystemIds.WIDEVINE&&K.data&&(b=K.data.subarray(8,24)),R=(0,P.keySystemIdToKeySystemDomain)(K.systemId)}if(!(!R||!b)){for(var H=x.default.hexDump(b),j=this.keyIdToKeySessionPromise,Y=this.mediaKeySessions,Q=j[H],q=function(ue){var ce=Y[ue],le=ce.decryptdata;if(le.pssh||!le.keyId)return"continue";var fe=x.default.hexDump(le.keyId);if(H===fe||le.uri.replace(/-/g,"").indexOf(H)!==-1)return Q=j[fe],delete j[fe],le.pssh=new Uint8Array(f),le.keyId=b,Q=j[H]=Q.then(function(){return s.generateRequestWithPreferredKeySession(ce,y,f,"encrypted-event-key-match")}),"break"},ne=0;ne<Y.length;ne++){var te=q(ne);if(te!=="continue"&&te==="break")break}Q||(Q=j[H]=this.getKeySystemSelectionPromise([R]).then(function(ae){var ue,ce=ae.keySystem,le=ae.mediaKeys;s.throwIfDestroyed();var fe=new D.LevelKey("ISO-23001-7",H,(ue=(0,P.keySystemDomainToKeySystemFormat)(ce))!=null?ue:"");return fe.pssh=new Uint8Array(f),fe.keyId=b,s.attemptSetMediaKeys(ce,le).then(function(){s.throwIfDestroyed();var de=s.createMediaKeySessionContext({decryptdata:fe,keySystem:ce,mediaKeys:le});return s.generateRequestWithPreferredKeySession(de,y,f,"encrypted-event-no-match")})})),Q.catch(function(ae){return s.handleError(ae)})}}},e._onWaitingForKey=function(t){this.log('"'+t.type+'" event')},e.attemptSetMediaKeys=function(t,s){var y=this,f=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+t+'"');var b=Promise.all(f).then(function(){if(!y.media)throw new Error("Attempted to set mediaKeys without media element attached");return y.media.setMediaKeys(s)});return this.setMediaKeysQueue.push(b),b.then(function(){y.log('Media-keys set for "'+t+'"'),f.push(b),y.setMediaKeysQueue=y.setMediaKeysQueue.filter(function(R){return f.indexOf(R)===-1})})},e.generateRequestWithPreferredKeySession=function(t,s,y,f){var b,R,I=this,k=(b=this.config.drmSystems)===null||b===void 0||(R=b[t.keySystem])===null||R===void 0?void 0:R.generateRequest;if(k)try{var F=k.call(this.hls,s,y,t);if(!F)throw new Error("Invalid response from configured generateRequest filter");s=F.initDataType,y=t.decryptdata.pssh=F.initData?new Uint8Array(F.initData):null}catch(Q){var K;if(this.warn(Q.message),(K=this.hls)!==null&&K!==void 0&&K.config.debug)throw Q}if(y===null)return this.log('Skipping key-session request for "'+f+'" (no initData)'),Promise.resolve(t);var H=this.getKeyIdString(t.decryptdata);this.log('Generating key-session request for "'+f+'": '+H+" (init data type: "+s+" length: "+(y?y.byteLength:null)+")");var j=new(d());t.mediaKeysSession.onmessage=function(Q){var q=t.mediaKeysSession;if(!q){j.emit("error",new Error("invalid state"));return}var ne=Q.messageType,te=Q.message;I.log('"'+ne+'" message event for session "'+q.sessionId+'" message size: '+te.byteLength),ne==="license-request"||ne==="license-renewal"?I.renewLicense(t,te).catch(function(ae){I.handleError(ae),j.emit("error",ae)}):ne==="license-release"?t.keySystem===P.KeySystems.FAIRPLAY&&(I.updateKeySession(t,(0,B.strToUtf8array)("acknowledged")),I.removeSession(t)):I.warn('unhandled media key message type "'+ne+'"')},t.mediaKeysSession.onkeystatuseschange=function(Q){var q=t.mediaKeysSession;if(!q){j.emit("error",new Error("invalid state"));return}I.onKeyStatusChange(t);var ne=t.keyStatus;j.emit("keyStatus",ne),ne==="expired"&&(I.warn(t.keySystem+" expired for key "+H),I.renewKeySession(t))};var Y=new Promise(function(Q,q){j.on("error",q),j.on("keyStatus",function(ne){ne.startsWith("usable")?Q():ne==="output-restricted"?q(new g({type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):ne==="internal-error"?q(new g({type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+ne+'"')):ne==="expired"?q(new Error("key expired while generating request")):I.warn('unhandled key status change "'+ne+'"')})});return t.mediaKeysSession.generateRequest(s,y).then(function(){var Q;I.log('Request generated for key-session "'+((Q=t.mediaKeysSession)===null||Q===void 0?void 0:Q.sessionId)+'" keyId: '+H)}).catch(function(Q){throw new g({type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_SESSION,error:Q,fatal:!1},"Error generating key-session request: "+Q)}).then(function(){return Y}).catch(function(Q){throw j.removeAllListeners(),I.removeSession(t),Q}).then(function(){return j.removeAllListeners(),t})},e.onKeyStatusChange=function(t){var s=this;t.mediaKeysSession.keyStatuses.forEach(function(y,f){s.log('key status change "'+y+'" for keyStatuses keyId: '+x.default.hexDump("buffer"in f?new Uint8Array(f.buffer,f.byteOffset,f.byteLength):new Uint8Array(f))+" session keyId: "+x.default.hexDump(new Uint8Array(t.decryptdata.keyId||[]))+" uri: "+t.decryptdata.uri),t.keyStatus=y})},e.fetchServerCertificate=function(t){var s=this;return new Promise(function(y,f){var b=s.getServerCertificateUrl(t);if(!b)return y();s.log('Fetching serverCertificate for "'+t+'"');var R=new XMLHttpRequest;R.open("GET",b,!0),R.responseType="arraybuffer",R.onreadystatechange=function(){R.readyState===XMLHttpRequest.DONE&&(R.status===200?y(R.response):f(new g({type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:R},'"'+t+'" certificate request XHR failed ('+b+"). Status: "+R.status+" ("+R.statusText+")")))},R.send()})},e.setMediaKeysServerCertificate=function(t,s,y){var f=this;return new Promise(function(b,R){t.setServerCertificate(y).then(function(I){f.log("setServerCertificate "+(I?"success":"not supported by CDM")+" ("+(y==null?void 0:y.byteLength)+') on "'+s+'"'),b(t)}).catch(function(I){R(new g({type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:I,fatal:!0},I.message))})})},e.renewLicense=function(t,s){var y=this;return this.requestLicense(t,new Uint8Array(s)).then(function(f){return y.updateKeySession(t,new Uint8Array(f)).catch(function(b){throw new g({type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:b,fatal:!0},b.message)})})},e.setupLicenseXHR=function(t,s,y,f){var b=this,R=this.config.licenseXhrSetup;return R?Promise.resolve().then(function(){if(!y.decryptdata)throw new Error("Key removed");return R.call(b.hls,t,s,y,f)}).catch(function(I){if(!y.decryptdata)throw I;return t.open("POST",s,!0),R.call(b.hls,t,s,y,f)}).then(function(I){t.readyState||t.open("POST",s,!0);var k=I||f;return{xhr:t,licenseChallenge:k}}):(t.open("POST",s,!0),Promise.resolve({xhr:t,licenseChallenge:f}))},e.requestLicense=function(t,s){var y=this;return new Promise(function(f,b){var R=y.getLicenseServerUrl(t.keySystem);y.log("Sending license request to URL: "+R);var I=new XMLHttpRequest;I.responseType="arraybuffer",I.onreadystatechange=function(){if(!y.hls||!t.mediaKeysSession)return b(new Error("invalid state"));if(I.readyState===4)if(I.status===200){y._requestLicenseFailureCount=0;var k=I.response;y.log("License received "+(k instanceof ArrayBuffer?k.byteLength:k));var F=y.config.licenseResponseCallback;if(F)try{k=F.call(y.hls,I,R,t)}catch(H){y.error(H)}f(k)}else if(y._requestLicenseFailureCount++,y._requestLicenseFailureCount>l||I.status>=400&&I.status<500)b(new g({type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:I},"License Request XHR failed ("+R+"). Status: "+I.status+" ("+I.statusText+")"));else{var K=l-y._requestLicenseFailureCount+1;y.warn("Retrying license request, "+K+" attempts left"),y.requestLicense(t,s).then(f,b)}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=I,y.setupLicenseXHR(I,R,t,s).then(function(k){var F=k.xhr,K=k.licenseChallenge;F.send(K)})})},e.onMediaAttached=function(t,s){if(!!this.config.emeEnabled){var y=s.media;this.media=y,y.addEventListener("encrypted",this.onMediaEncrypted),y.addEventListener("waitingforkey",this.onWaitingForKey)}},e.onMediaDetached=function(){var t=this,s=this.media,y=this.mediaKeySessions;s&&(s.removeEventListener("encrypted",this.onMediaEncrypted),s.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},D.LevelKey.clearKeyUriToKeyIdMap();var f=y.length;m.CDMCleanupPromise=Promise.all(y.map(function(b){return t.removeSession(b)}).concat(s==null?void 0:s.setMediaKeys(null).catch(function(b){t.log("Could not clear media keys: "+b+". media.src: "+(s==null?void 0:s.src))}))).then(function(){f&&(t.log("finished closing key sessions and clearing media keys"),y.length=0)}).catch(function(b){t.log("Could not close sessions and clear media keys: "+b+". media.src: "+(s==null?void 0:s.src))})},e.onManifestLoaded=function(t,s){var y=s.sessionKeys;if(!(!y||!this.config.emeEnabled)&&!this.keyFormatPromise){var f=y.reduce(function(b,R){return b.indexOf(R.keyFormat)===-1&&b.push(R.keyFormat),b},[]);this.log("Selecting key-system from session-keys "+f.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(f)}},e.removeSession=function(t){var s=this,y=t.mediaKeysSession,f=t.licenseXhr;if(y){this.log("Remove licenses and keys and close session "+y.sessionId),y.onmessage=null,y.onkeystatuseschange=null,f&&f.readyState!==XMLHttpRequest.DONE&&f.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;var b=this.mediaKeySessions.indexOf(t);return b>-1&&this.mediaKeySessions.splice(b,1),y.remove().catch(function(R){s.log("Could not remove session: "+R)}).then(function(){return y.close()}).catch(function(R){s.log("Could not close session: "+R)})}},m}();u.CDMCleanupPromise=void 0;var g=function(m){E(e,m);function e(r,t){var s;return s=m.call(this,t)||this,s.data=void 0,s.data=r,r.err=r.error,s}return e}(p(Error));let c=u},"./src/controller/fps-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>P});var C=T("./src/events.ts"),L=T("./src/utils/logger.ts"),M=function(){function B(D){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=D,this.registerListeners()}var A=B.prototype;return A.setStreamController=function(x){this.streamController=x},A.registerListeners=function(){this.hls.on(C.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},A.unregisterListeners=function(){this.hls.off(C.Events.MEDIA_ATTACHING,this.onMediaAttaching)},A.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},A.onMediaAttaching=function(x,_){var S=this.hls.config;if(S.capLevelOnFPSDrop){var d=_.media instanceof self.HTMLVideoElement?_.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),S.fpsDroppedMonitoringPeriod)}},A.checkFPS=function(x,_,S){var d=performance.now();if(_){if(this.lastTime){var E=d-this.lastTime,p=S-this.lastDroppedFrames,h=_-this.lastDecodedFrames,a=1e3*p/E,o=this.hls;if(o.trigger(C.Events.FPS_DROP,{currentDropped:p,currentDecoded:h,totalDroppedFrames:S}),a>0&&p>o.config.fpsDroppedMonitoringThreshold*h){var n=o.currentLevel;L.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+n),n>0&&(o.autoLevelCapping===-1||o.autoLevelCapping>=n)&&(n=n-1,o.trigger(C.Events.FPS_DROP_LEVEL_CAPPING,{level:n,droppedLevel:o.currentLevel}),o.autoLevelCapping=n,this.streamController.nextLevelSwitch())}}this.lastTime=d,this.lastDroppedFrames=S,this.lastDecodedFrames=_}},A.checkFPSInterval=function(){var x=this.media;if(x)if(this.isVideoPlaybackQualityAvailable){var _=x.getVideoPlaybackQuality();this.checkFPS(x,_.totalVideoFrames,_.droppedVideoFrames)}else this.checkFPS(x,x.webkitDecodedFrameCount,x.webkitDroppedFrameCount)},B}();let P=M},"./src/controller/fragment-finders.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{findFragWithCC:()=>D,findFragmentByPDT:()=>M,findFragmentByPTS:()=>P,fragmentWithinToleranceTest:()=>B,pdtWithinToleranceTest:()=>A});var C=T("./src/polyfills/number.ts"),L=T("./src/utils/binary-search.ts");function M(x,_,S){if(_===null||!Array.isArray(x)||!x.length||!(0,C.isFiniteNumber)(_))return null;var d=x[0].programDateTime;if(_<(d||0))return null;var E=x[x.length-1].endProgramDateTime;if(_>=(E||0))return null;S=S||0;for(var p=0;p<x.length;++p){var h=x[p];if(A(_,S,h))return h}return null}function P(x,_,S,d){S===void 0&&(S=0),d===void 0&&(d=0);var E=null;if(x?E=_[x.sn-_[0].sn+1]||null:S===0&&_[0].start===0&&(E=_[0]),E&&B(S,d,E)===0)return E;var p=L.default.search(_,B.bind(null,S,d));return p&&(p!==x||!E)?p:E}function B(x,_,S){if(x===void 0&&(x=0),_===void 0&&(_=0),S.start<=x&&S.start+S.duration>x)return 0;var d=Math.min(_,S.duration+(S.deltaPTS?S.deltaPTS:0));return S.start+S.duration-d<=x?1:S.start-d>x&&S.start?-1:0}function A(x,_,S){var d=Math.min(_,S.duration+(S.deltaPTS?S.deltaPTS:0))*1e3,E=S.endProgramDateTime||0;return E-d>x}function D(x,_){return L.default.search(x,function(S){return S.cc<_?1:S.cc>_?-1:0})}},"./src/controller/fragment-tracker.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{FragmentState:()=>M,FragmentTracker:()=>P});var C=T("./src/events.ts"),L=T("./src/types/loader.ts"),M;(function(D){D.NOT_LOADED="NOT_LOADED",D.APPENDING="APPENDING",D.PARTIAL="PARTIAL",D.OK="OK"})(M||(M={}));var P=function(){function D(_){this.activeFragment=null,this.activeParts=null,this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=_,this._registerListeners()}var x=D.prototype;return x._registerListeners=function(){var S=this.hls;S.on(C.Events.BUFFER_APPENDED,this.onBufferAppended,this),S.on(C.Events.FRAG_BUFFERED,this.onFragBuffered,this),S.on(C.Events.FRAG_LOADED,this.onFragLoaded,this)},x._unregisterListeners=function(){var S=this.hls;S.off(C.Events.BUFFER_APPENDED,this.onBufferAppended,this),S.off(C.Events.FRAG_BUFFERED,this.onFragBuffered,this),S.off(C.Events.FRAG_LOADED,this.onFragLoaded,this)},x.destroy=function(){this._unregisterListeners(),this.fragments=this.endListFragments=this.timeRanges=this.activeFragment=this.activeParts=null},x.getAppendedFrag=function(S,d){if(d===L.PlaylistLevelType.MAIN){var E=this.activeFragment,p=this.activeParts;if(!E)return null;if(p)for(var h=p.length;h--;){var a=p[h],o=a?a.end:E.appendedPTS;if(a.start<=S&&o!==void 0&&S<=o)return h>9&&(this.activeParts=p.slice(h-9)),a}else if(E.start<=S&&E.appendedPTS!==void 0&&S<=E.appendedPTS)return E}return this.getBufferedFrag(S,d)},x.getBufferedFrag=function(S,d){for(var E=this.fragments,p=Object.keys(E),h=p.length;h--;){var a=E[p[h]];if((a==null?void 0:a.body.type)===d&&a.buffered){var o=a.body;if(o.start<=S&&S<=o.end)return o}}return null},x.detectEvictedFragments=function(S,d,E){var p=this;this.timeRanges&&(this.timeRanges[S]=d),Object.keys(this.fragments).forEach(function(h){var a=p.fragments[h];if(!!a){if(!a.buffered&&!a.loaded){a.body.type===E&&p.removeFragment(a.body);return}var o=a.range[S];!o||o.time.some(function(n){var v=!p.isTimeBuffered(n.startPTS,n.endPTS,d);return v&&p.removeFragment(a.body),v})}})},x.detectPartialFragments=function(S){var d=this,E=this.timeRanges,p=S.frag,h=S.part;if(!(!E||p.sn==="initSegment")){var a=A(p),o=this.fragments[a];!o||(Object.keys(E).forEach(function(n){var v=p.elementaryStreams[n];if(!!v){var l=E[n],i=h!==null||v.partial===!0;o.range[n]=d.getBufferedTimes(p,h,i,l)}}),o.loaded=null,Object.keys(o.range).length?(o.buffered=!0,o.body.endList&&(this.endListFragments[o.body.type]=o)):this.removeFragment(o.body))}},x.fragBuffered=function(S){var d=A(S),E=this.fragments[d];E&&(E.loaded=null,E.buffered=!0)},x.getBufferedTimes=function(S,d,E,p){for(var h={time:[],partial:E},a=d?d.start:S.start,o=d?d.end:S.end,n=S.minEndPTS||o,v=S.maxStartPTS||a,l=0;l<p.length;l++){var i=p.start(l)-this.bufferPadding,u=p.end(l)+this.bufferPadding;if(v>=i&&n<=u){h.time.push({startPTS:Math.max(a,p.start(l)),endPTS:Math.min(o,p.end(l))});break}else if(a<u&&o>i)h.partial=!0,h.time.push({startPTS:Math.max(a,p.start(l)),endPTS:Math.min(o,p.end(l))});else if(o<=i)break}return h},x.getPartialFragment=function(S){var d=null,E,p,h,a=0,o=this.bufferPadding,n=this.fragments;return Object.keys(n).forEach(function(v){var l=n[v];!l||B(l)&&(p=l.body.start-o,h=l.body.end+o,S>=p&&S<=h&&(E=Math.min(S-p,h-S),a<=E&&(d=l.body,a=E)))}),d},x.isEndListAppended=function(S){var d=this.endListFragments[S];return d!==void 0&&(d.buffered||B(d))},x.getState=function(S){var d=A(S),E=this.fragments[d];return E?E.buffered?B(E)?M.PARTIAL:M.OK:M.APPENDING:M.NOT_LOADED},x.isTimeBuffered=function(S,d,E){for(var p,h,a=0;a<E.length;a++){if(p=E.start(a)-this.bufferPadding,h=E.end(a)+this.bufferPadding,S>=p&&d<=h)return!0;if(d<=p)return!1}return!1},x.onFragLoaded=function(S,d){var E=d.frag,p=d.part;if(!(E.sn==="initSegment"||E.bitrateTest||p)){var h=A(E);this.fragments[h]={body:E,loaded:d,buffered:!1,range:Object.create(null)}}},x.onBufferAppended=function(S,d){var E=this,p=d.frag,h=d.part,a=d.timeRanges;if(p.type===L.PlaylistLevelType.MAIN)if(this.activeFragment!==p&&(this.activeFragment=p,p.appendedPTS=void 0),h){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(h)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach(function(n){var v=a[n];if(E.detectEvictedFragments(n,v),!h&&p.type===L.PlaylistLevelType.MAIN){var l=p.elementaryStreams[n];if(!l)return;for(var i=0;i<v.length;i++){var u=v.end(i);u<=l.endPTS&&u>l.startPTS?p.appendedPTS=Math.max(u,p.appendedPTS||0):p.appendedPTS=l.endPTS}}})},x.onFragBuffered=function(S,d){this.detectPartialFragments(d)},x.hasFragment=function(S){var d=A(S);return!!this.fragments[d]},x.removeFragmentsInRange=function(S,d,E){var p=this;Object.keys(this.fragments).forEach(function(h){var a=p.fragments[h];if(!!a&&a.buffered){var o=a.body;o.type===E&&o.start<d&&o.end>S&&p.removeFragment(o)}})},x.removeFragment=function(S){var d=A(S);S.stats.loaded=0,S.clearElementaryStreamInfo(),S.appendedPTS=void 0,delete this.fragments[d],S.endList&&delete this.endListFragments[S.type]},x.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activeFragment=null,this.activeParts=null},D}();function B(D){var x,_;return D.buffered&&(((x=D.range.video)===null||x===void 0?void 0:x.partial)||((_=D.range.audio)===null||_===void 0?void 0:_.partial))}function A(D){return D.type+"_"+D.level+"_"+D.urlId+"_"+D.sn}},"./src/controller/gap-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{MAX_START_GAP_JUMP:()=>A,SKIP_BUFFER_HOLE_STEP_SECONDS:()=>D,SKIP_BUFFER_RANGE_START:()=>x,STALL_MINIMUM_DURATION_MS:()=>B,default:()=>_});var C=T("./src/utils/buffer-helper.ts"),L=T("./src/errors.ts"),M=T("./src/events.ts"),P=T("./src/utils/logger.ts"),B=250,A=2,D=.1,x=.05,_=function(){function S(E,p,h,a){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=E,this.media=p,this.fragmentTracker=h,this.hls=a}var d=S.prototype;return d.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},d.poll=function(p,h){var a=this.config,o=this.media,n=this.stalled;if(o!==null){var v=o.currentTime,l=o.seeking,i=this.seeking&&!l,u=!this.seeking&&l;if(this.seeking=l,v!==p){if(this.moved=!0,n!==null){if(this.stallReported){var g=self.performance.now()-n;P.logger.warn("playback not stuck anymore @"+v+", after "+Math.round(g)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((u||i)&&(this.stalled=null),!(o.paused&&!l||o.ended||o.playbackRate===0||!C.BufferHelper.getBuffered(o).length)){var c=C.BufferHelper.bufferInfo(o,v,0),m=c.len>0,e=c.nextStart||0;if(!(!m&&!e)){if(l){var r=c.len>A,t=!e||h&&h.start<=v||e-v>A&&!this.fragmentTracker.getPartialFragment(v);if(r||t)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var s,y=Math.max(e,c.start||0)-v,f=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,b=f==null||(s=f.details)===null||s===void 0?void 0:s.live,R=b?f.details.targetduration*2:A;if(y>0&&y<=R){this._trySkipBufferHole(null);return}}var I=self.performance.now();if(n===null){this.stalled=I;return}var k=I-n;if(!(!l&&k>=B&&(this._reportStall(c),!this.media))){var F=C.BufferHelper.bufferInfo(o,v,a.maxBufferHole);this._tryFixBufferStall(F,k)}}}}},d._tryFixBufferStall=function(p,h){var a=this.config,o=this.fragmentTracker,n=this.media;if(n!==null){var v=n.currentTime,l=o.getPartialFragment(v);if(l){var i=this._trySkipBufferHole(l);if(i||!this.media)return}p.len>a.maxBufferHole&&h>a.highBufferWatchdogPeriod*1e3&&(P.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},d._reportStall=function(p){var h=this.hls,a=this.media,o=this.stallReported;!o&&a&&(this.stallReported=!0,P.logger.warn("Playback stalling at @"+a.currentTime+" due to low buffer ("+JSON.stringify(p)+")"),h.trigger(M.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p.len}))},d._trySkipBufferHole=function(p){var h=this.config,a=this.hls,o=this.media;if(o===null)return 0;for(var n=o.currentTime,v=0,l=C.BufferHelper.getBuffered(o),i=0;i<l.length;i++){var u=l.start(i);if(n+h.maxBufferHole>=v&&n<u){var g=Math.max(u+x,o.currentTime+D);return P.logger.warn("skipping hole, adjusting currentTime from "+n+" to "+g),this.moved=!0,this.stalled=null,o.currentTime=g,p&&a.trigger(M.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+n+" to "+g,frag:p}),g}v=l.end(i)}return 0},d._tryNudgeBuffer=function(){var p=this.config,h=this.hls,a=this.media,o=this.nudgeRetry;if(a!==null){var n=a.currentTime;if(this.nudgeRetry++,o<p.nudgeMaxRetry){var v=n+(o+1)*p.nudgeOffset;P.logger.warn("Nudging 'currentTime' from "+n+" to "+v),a.currentTime=v,h.trigger(M.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else P.logger.error("Playhead still not moving while enough data buffered @"+n+" after "+p.nudgeMaxRetry+" nudges"),h.trigger(M.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},S}()},"./src/controller/id3-track-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>p});var C=T("./src/polyfills/number.ts"),L=T("./src/events.ts"),M=T("./src/utils/texttrack-utils.ts"),P=T("./src/demux/id3.ts"),B=T("./src/loader/date-range.ts"),A=T("./src/types/demuxer.ts"),D=.25;function x(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var _=function(){var h=x();try{new h(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function S(h,a){return h.getTime()/1e3-a}function d(h){return Uint8Array.from(h.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var E=function(){function h(o){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=o,this._registerListeners()}var a=h.prototype;return a.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},a._registerListeners=function(){var n=this.hls;n.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(L.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),n.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),n.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},a._unregisterListeners=function(){var n=this.hls;n.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(L.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),n.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),n.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},a.onMediaAttached=function(n,v){this.media=v.media},a.onMediaDetaching=function(){!this.id3Track||((0,M.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},a.onManifestLoading=function(){this.dateRangeCuesAppended={}},a.createTrack=function(n){var v=this.getID3Track(n.textTracks);return v.mode="hidden",v},a.getID3Track=function(n){if(!!this.media){for(var v=0;v<n.length;v++){var l=n[v];if(l.kind==="metadata"&&l.label==="id3")return(0,M.sendAddTrackEvent)(l,this.media),l}return this.media.addTextTrack("metadata","id3")}},a.onFragParsingMetadata=function(n,v){if(!!this.media){var l=this.hls.config,i=l.enableEmsgMetadataCues,u=l.enableID3MetadataCues;if(!(!i&&!u)){var g=v.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var c=x(),m=0;m<g.length;m++){var e=g[m].type;if(!(e===A.MetadataSchema.emsg&&!i||!u)){var r=P.getID3Frames(g[m].data);if(r){var t=g[m].pts,s=t+g[m].duration;s>_&&(s=_);var y=s-t;y<=0&&(s=t+D);for(var f=0;f<r.length;f++){var b=r[f];if(!P.isTimeStampFrame(b)){this.updateId3CueEnds(t);var R=new c(t,s,"");R.value=b,e&&(R.type=e),this.id3Track.addCue(R)}}}}}}}},a.updateId3CueEnds=function(n){var v,l=(v=this.id3Track)===null||v===void 0?void 0:v.cues;if(l)for(var i=l.length;i--;){var u=l[i];u.startTime<n&&u.endTime===_&&(u.endTime=n)}},a.onBufferFlushing=function(n,v){var l=v.startOffset,i=v.endOffset,u=v.type,g=this.id3Track,c=this.hls;if(!!c){var m=c.config,e=m.enableEmsgMetadataCues,r=m.enableID3MetadataCues;if(g&&(e||r)){var t;u==="audio"?t=function(y){return y.type===A.MetadataSchema.audioId3&&r}:u==="video"?t=function(y){return y.type===A.MetadataSchema.emsg&&e}:t=function(y){return y.type===A.MetadataSchema.audioId3&&r||y.type===A.MetadataSchema.emsg&&e},(0,M.removeCuesInRange)(g,l,i,t)}}},a.onLevelUpdated=function(n,v){var l=this,i=v.details;if(!(!this.media||!i.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var u=this.dateRangeCuesAppended,g=this.id3Track,c=i.dateRanges,m=Object.keys(c);if(g)for(var e=Object.keys(u).filter(function(I){return!m.includes(I)}),r=function(k){var F=e[k];Object.keys(u[F].cues).forEach(function(K){g.removeCue(u[F].cues[K])}),delete u[F]},t=e.length;t--;)r(t);var s=i.fragments[i.fragments.length-1];if(!(m.length===0||!(0,C.isFiniteNumber)(s==null?void 0:s.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var y=s.programDateTime/1e3-s.start,f=x(),b=function(k){var F=m[k],K=c[F],H=u[F],j=(H==null?void 0:H.cues)||{},Y=(H==null?void 0:H.durationKnown)||!1,Q=S(K.startDate,y),q=_,ne=K.endDate;if(ne)q=S(ne,y),Y=!0;else if(K.endOnNext&&!Y){var te=m.reduce(function(de,xe){var Ae=c[xe];return Ae.class===K.class&&Ae.id!==xe&&Ae.startDate>K.startDate&&de.push(Ae),de},[]).sort(function(de,xe){return de.startDate.getTime()-xe.startDate.getTime()})[0];te&&(q=S(te.startDate,y),Y=!0)}for(var ae=Object.keys(K.attr),ue=0;ue<ae.length;ue++){var ce=ae[ue];if(!(ce===B.DateRangeAttribute.ID||ce===B.DateRangeAttribute.CLASS||ce===B.DateRangeAttribute.START_DATE||ce===B.DateRangeAttribute.DURATION||ce===B.DateRangeAttribute.END_DATE||ce===B.DateRangeAttribute.END_ON_NEXT)){var le=j[ce];if(le)Y&&!H.durationKnown&&(le.endTime=q);else{var fe=K.attr[ce];le=new f(Q,q,""),(ce===B.DateRangeAttribute.SCTE35_OUT||ce===B.DateRangeAttribute.SCTE35_IN)&&(fe=d(fe)),le.value={key:ce,data:fe},le.type=A.MetadataSchema.dateRange,l.id3Track.addCue(le),j[ce]=le}}}u[F]={cues:j,dateRange:K,durationKnown:Y}},R=0;R<m.length;R++)b(R)}}},h}();let p=E},"./src/controller/latency-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>x});var C=T("./src/errors.ts"),L=T("./src/events.ts"),M=T("./src/utils/logger.ts");function P(_,S){for(var d=0;d<S.length;d++){var E=S[d];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(_,A(E.key),E)}}function B(_,S,d){return S&&P(_.prototype,S),d&&P(_,d),Object.defineProperty(_,"prototype",{writable:!1}),_}function A(_){var S=D(_,"string");return typeof S=="symbol"?S:String(S)}function D(_,S){if(typeof _!="object"||_===null)return _;var d=_[Symbol.toPrimitive];if(d!==void 0){var E=d.call(_,S||"default");if(typeof E!="object")return E;throw new TypeError("@@toPrimitive must return a primitive value.")}return(S==="string"?String:Number)(_)}var x=function(){function _(d){var E=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 E.timeupdate()},this.hls=d,this.config=d.config,this.registerListeners()}var S=_.prototype;return S.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},S.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)},S.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)},S.onMediaAttached=function(E,p){this.media=p.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},S.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},S.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},S.onLevelUpdated=function(E,p){var h=p.details;this.levelDetails=h,h.advanced&&this.timeupdate(),!h.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},S.onError=function(E,p){p.details===C.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,M.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},S.timeupdate=function(){var E=this.media,p=this.levelDetails;if(!(!E||!p)){this.currentTime=E.currentTime;var h=this.computeLatency();if(h!==null){this._latency=h;var a=this.config,o=a.lowLatencyMode,n=a.maxLiveSyncPlaybackRate;if(!(!o||n===1)){var v=this.targetLatency;if(v!==null){var l=h-v,i=Math.min(this.maxLatency,v+p.targetduration),u=l<i;if(p.live&&u&&l>.05&&this.forwardBufferLength>1){var g=Math.min(2,Math.max(1,n)),c=Math.round(2/(1+Math.exp(-.75*l-this.edgeStalled))*20)/20;E.playbackRate=Math.min(g,Math.max(1,c))}else E.playbackRate!==1&&E.playbackRate!==0&&(E.playbackRate=1)}}}}},S.estimateLiveEdge=function(){var E=this.levelDetails;return E===null?null:E.edge+E.age},S.computeLatency=function(){var E=this.estimateLiveEdge();return E===null?null:E-this.currentTime},B(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var E=this.config,p=this.levelDetails;return E.liveMaxLatencyDuration!==void 0?E.liveMaxLatencyDuration:p?E.liveMaxLatencyDurationCount*p.targetduration:0}},{key:"targetLatency",get:function(){var E=this.levelDetails;if(E===null)return null;var p=E.holdBack,h=E.partHoldBack,a=E.targetduration,o=this.config,n=o.liveSyncDuration,v=o.liveSyncDurationCount,l=o.lowLatencyMode,i=this.hls.userConfig,u=l&&h||p;(i.liveSyncDuration||i.liveSyncDurationCount||u===0)&&(u=n!==void 0?n:v*a);var g=a,c=1;return u+Math.min(this.stallCount*c,g)}},{key:"liveSyncPosition",get:function(){var E=this.estimateLiveEdge(),p=this.targetLatency,h=this.levelDetails;if(E===null||p===null||h===null)return null;var a=h.edge,o=E-p-this.edgeStalled,n=a-h.totalduration,v=a-(this.config.lowLatencyMode&&h.partTarget||h.targetduration);return Math.min(Math.max(n,o),v)}},{key:"drift",get:function(){var E=this.levelDetails;return E===null?1:E.drift}},{key:"edgeStalled",get:function(){var E=this.levelDetails;if(E===null)return 0;var p=(this.config.lowLatencyMode&&E.partTarget||E.targetduration)*3;return Math.max(E.age-p,0)}},{key:"forwardBufferLength",get:function(){var E=this.media,p=this.levelDetails;if(!E||!p)return 0;var h=E.buffered.length;return(h?E.buffered.end(h-1):p.edge)-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>o});var C=T("./src/types/level.ts"),L=T("./src/events.ts"),M=T("./src/errors.ts"),P=T("./src/utils/codecs.ts"),B=T("./src/controller/level-helper.ts"),A=T("./src/controller/base-playlist-controller.ts"),D=T("./src/types/loader.ts");function x(){return x=Object.assign?Object.assign.bind():function(n){for(var v=1;v<arguments.length;v++){var l=arguments[v];for(var i in l)Object.prototype.hasOwnProperty.call(l,i)&&(n[i]=l[i])}return n},x.apply(this,arguments)}function _(n,v){for(var l=0;l<v.length;l++){var i=v[l];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,d(i.key),i)}}function S(n,v,l){return v&&_(n.prototype,v),l&&_(n,l),Object.defineProperty(n,"prototype",{writable:!1}),n}function d(n){var v=E(n,"string");return typeof v=="symbol"?v:String(v)}function E(n,v){if(typeof n!="object"||n===null)return n;var l=n[Symbol.toPrimitive];if(l!==void 0){var i=l.call(n,v||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(v==="string"?String:Number)(n)}function p(n,v){n.prototype=Object.create(v.prototype),n.prototype.constructor=n,h(n,v)}function h(n,v){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,u){return i.__proto__=u,i},h(n,v)}var a=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),o=function(n){p(v,n);function v(i){var u;return u=n.call(this,i,"[level-controller]")||this,u._levels=[],u._firstLevel=-1,u._startLevel=void 0,u.currentLevelIndex=-1,u.manualLevelIndex=-1,u.onParsedComplete=void 0,u._registerListeners(),u}var l=v.prototype;return l._registerListeners=function(){var u=this.hls;u.on(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),u.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(L.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),u.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(L.Events.ERROR,this.onError,this)},l._unregisterListeners=function(){var u=this.hls;u.off(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),u.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(L.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),u.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(L.Events.ERROR,this.onError,this)},l.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,n.prototype.destroy.call(this)},l.startLoad=function(){var u=this._levels;u.forEach(function(g){g.loadError=0}),n.prototype.startLoad.call(this)},l.onManifestLoaded=function(u,g){var c=[],m=[],e=[],r,t={},s,y=!1,f=!1,b=!1;if(g.levels.forEach(function(F){var K=F.attrs;y=y||!!(F.width&&F.height),f=f||!!F.videoCodec,b=b||!!F.audioCodec,a&&F.audioCodec&&F.audioCodec.indexOf("mp4a.40.34")!==-1&&(F.audioCodec=void 0);var H=F.bitrate+"-"+F.attrs.RESOLUTION+"-"+F.attrs.CODECS;s=t[H],s?s.url.push(F.url):(s=new C.Level(F),t[H]=s,c.push(s)),K&&(K.AUDIO&&(0,B.addGroupId)(s,"audio",K.AUDIO),K.SUBTITLES&&(0,B.addGroupId)(s,"text",K.SUBTITLES))}),(y||f)&&b&&(c=c.filter(function(F){var K=F.videoCodec,H=F.width,j=F.height;return!!K||!!(H&&j)})),c=c.filter(function(F){var K=F.audioCodec,H=F.videoCodec;return(!K||(0,P.isCodecSupportedInMp4)(K,"audio"))&&(!H||(0,P.isCodecSupportedInMp4)(H,"video"))}),g.audioTracks&&(m=g.audioTracks.filter(function(F){return!F.audioCodec||(0,P.isCodecSupportedInMp4)(F.audioCodec,"audio")}),(0,B.assignTrackIdsByGroup)(m)),g.subtitles&&(e=g.subtitles,(0,B.assignTrackIdsByGroup)(e)),c.length>0){r=c[0].bitrate,c.sort(function(F,K){return F.attrs["HDCP-LEVEL"]!==K.attrs["HDCP-LEVEL"]?(F.attrs["HDCP-LEVEL"]||"")>(K.attrs["HDCP-LEVEL"]||"")?1:-1:F.bitrate!==K.bitrate?F.bitrate-K.bitrate:F.attrs.SCORE!==K.attrs.SCORE?F.attrs.decimalFloatingPoint("SCORE")-K.attrs.decimalFloatingPoint("SCORE"):y&&F.height!==K.height?F.height-K.height:0}),this._levels=c;for(var R=0;R<c.length;R++)if(c[R].bitrate===r){this._firstLevel=R,this.log("manifest loaded, "+c.length+" level(s) found, first bitrate: "+r);break}var I=b&&!f,k={levels:c,audioTracks:m,subtitleTracks:e,sessionData:g.sessionData,sessionKeys:g.sessionKeys,firstLevel:this._firstLevel,stats:g.stats,audio:b,video:f,altAudio:!I&&m.some(function(F){return!!F.url})};this.hls.trigger(L.Events.MANIFEST_PARSED,k),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:g.url,reason:"no level with compatible codecs found in manifest"})},l.onError=function(u,g){var c,m;if(n.prototype.onError.call(this,u,g),!g.fatal){var e=g.context,r=this._levels[this.currentLevelIndex];if(e&&(e.type===D.PlaylistContextType.AUDIO_TRACK&&r.audioGroupIds&&e.groupId===r.audioGroupIds[r.urlId]||e.type===D.PlaylistContextType.SUBTITLE_TRACK&&r.textGroupIds&&e.groupId===r.textGroupIds[r.urlId])){this.redundantFailover(this.currentLevelIndex);return}var t=!1,s=!0,y;switch(g.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:if(g.frag){var f=g.frag.type===D.PlaylistLevelType.MAIN?g.frag.level:this.currentLevelIndex,b=this._levels[f];b?(b.fragmentError++,b.fragmentError>this.hls.config.fragLoadingMaxRetry&&(y=f)):y=f}break;case M.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var R=r.attrs["HDCP-LEVEL"];R&&(this.hls.maxHdcpLevel=C.HdcpLevels[C.HdcpLevels.indexOf(R)-1],this.warn('Restricting playback to HDCP-LEVEL of "'+this.hls.maxHdcpLevel+'" or lower'))}case M.ErrorDetails.FRAG_PARSING_ERROR:case M.ErrorDetails.KEY_SYSTEM_NO_SESSION:y=((c=g.frag)===null||c===void 0?void 0:c.type)===D.PlaylistLevelType.MAIN?g.frag.level:this.currentLevelIndex,g.levelRetry=!1;break;case M.ErrorDetails.LEVEL_LOAD_ERROR:case M.ErrorDetails.LEVEL_LOAD_TIMEOUT:e&&(e.deliveryDirectives&&(s=!1),y=e.level),t=!0;break;case M.ErrorDetails.REMUX_ALLOC_ERROR:y=(m=g.level)!=null?m:this.currentLevelIndex,t=!0;break}y!==void 0&&this.recoverLevel(g,y,t,s)}},l.recoverLevel=function(u,g,c,m){var e=u.details,r=this._levels[g];if(r.loadError++,c){var t=this.retryLoadingOrFail(u);if(t)u.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(m){var s=r.url.length;if(s>1&&r.loadError<s)u.levelRetry=!0,this.redundantFailover(g);else if(this.manualLevelIndex===-1){for(var y=-1,f=this._levels,b=f.length;b--;){var R=(b+this.currentLevelIndex)%f.length;if(R!==this.currentLevelIndex&&f[R].loadError===0){y=R;break}}y>-1&&this.currentLevelIndex!==y?(this.warn(e+": switch to "+y),u.levelRetry=!0,this.hls.nextAutoLevel=y):u.levelRetry===!1&&(u.fatal=!0)}}},l.redundantFailover=function(u){var g=this._levels[u],c=g.url.length;if(c>1){var m=(g.urlId+1)%c;this.warn("Switching to redundant URL-id "+m),this._levels.forEach(function(e){e.urlId=m}),this.level=u}},l.onFragLoaded=function(u,g){var c=g.frag;if(c!==void 0&&c.type===D.PlaylistLevelType.MAIN){var m=this._levels[c.level];m!==void 0&&(m.fragmentError=0,m.loadError=0)}},l.onLevelLoaded=function(u,g){var c,m=g.level,e=g.details,r=this._levels[m];if(!r){var t;this.warn("Invalid level index "+m),(t=g.deliveryDirectives)!==null&&t!==void 0&&t.skip&&(e.deltaUpdateFailed=!0);return}m===this.currentLevelIndex?(r.fragmentError===0&&(r.loadError=0,this.retryCount=0),this.playlistLoaded(m,g,r.details)):(c=g.deliveryDirectives)!==null&&c!==void 0&&c.skip&&(e.deltaUpdateFailed=!0)},l.onAudioTrackSwitched=function(u,g){var c=this.hls.levels[this.currentLevelIndex];if(!!c&&c.audioGroupIds){for(var m=-1,e=this.hls.audioTracks[g.id].groupId,r=0;r<c.audioGroupIds.length;r++)if(c.audioGroupIds[r]===e){m=r;break}m!==c.urlId&&(c.urlId=m,this.startLoad())}},l.loadPlaylist=function(u){n.prototype.loadPlaylist.call(this);var g=this.currentLevelIndex,c=this._levels[g];if(this.canLoad&&c&&c.url.length>0){var m=c.urlId,e=c.url[m];if(u)try{e=u.addDirectives(e)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log("Attempt loading level index "+g+(u?" at sn "+u.msn+" part "+u.part:"")+" with URL-id "+m+" "+e),this.clearTimer(),this.hls.trigger(L.Events.LEVEL_LOADING,{url:e,level:g,id:m,deliveryDirectives:u||null})}},l.removeLevel=function(u,g){var c=function(r,t){return t!==g},m=this._levels.filter(function(e,r){return r!==u?!0:e.url.length>1&&g!==void 0?(e.url=e.url.filter(c),e.audioGroupIds&&(e.audioGroupIds=e.audioGroupIds.filter(c)),e.textGroupIds&&(e.textGroupIds=e.textGroupIds.filter(c)),e.urlId=0,!0):!1}).map(function(e,r){var t=e.details;return t!=null&&t.fragments&&t.fragments.forEach(function(s){s.level=r}),e});this._levels=m,this.hls.trigger(L.Events.LEVELS_UPDATED,{levels:m})},S(v,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(u){var g,c=this._levels;if(c.length!==0&&!(this.currentLevelIndex===u&&(g=c[u])!==null&&g!==void 0&&g.details)){if(u<0||u>=c.length){var m=u<0;if(this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.OTHER_ERROR,details:M.ErrorDetails.LEVEL_SWITCH_ERROR,level:u,fatal:m,reason:"invalid level idx"}),m)return;u=Math.min(u,c.length-1)}this.clearTimer();var e=this.currentLevelIndex,r=c[e],t=c[u];this.log("switching to level "+u+" from "+e),this.currentLevelIndex=u;var s=x({},t,{level:u,maxBitrate:t.maxBitrate,uri:t.uri,urlId:t.urlId});delete s._urlId,this.hls.trigger(L.Events.LEVEL_SWITCHING,s);var y=t.details;if(!y||y.live){var f=this.switchParams(t.uri,r==null?void 0:r.details);this.loadPlaylist(f)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(u){this.manualLevelIndex=u,this._startLevel===void 0&&(this._startLevel=u),u!==-1&&(this.level=u)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(u){this._firstLevel=u}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var u=this.hls.config.startLevel;return u!==void 0?u:this._firstLevel}else return this._startLevel},set:function(u){this._startLevel=u}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(u){this.level=u,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=u)}}]),v}(A.default)},"./src/controller/level-helper.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{addGroupId:()=>B,addSliding:()=>a,adjustSliding:()=>h,assignTrackIdsByGroup:()=>A,computeReloadInterval:()=>o,getFragmentWithSN:()=>n,getPartWith:()=>v,mapFragmentIntersection:()=>p,mapPartIntersection:()=>E,mergeDetails:()=>S,updateFragPTSDTS:()=>_,updatePTS:()=>D});var C=T("./src/polyfills/number.ts"),L=T("./src/utils/logger.ts"),M=T("./src/loader/date-range.ts");function P(){return P=Object.assign?Object.assign.bind():function(l){for(var i=1;i<arguments.length;i++){var u=arguments[i];for(var g in u)Object.prototype.hasOwnProperty.call(u,g)&&(l[g]=u[g])}return l},P.apply(this,arguments)}function B(l,i,u){switch(i){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(u);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(u);break}}function A(l){var i={};l.forEach(function(u){var g=u.groupId||"";u.id=i[g]=i[g]||0,i[g]++})}function D(l,i,u){var g=l[i],c=l[u];x(g,c)}function x(l,i){var u=i.startPTS;if((0,C.isFiniteNumber)(u)){var g=0,c;i.sn>l.sn?(g=u-l.start,c=l):(g=l.start-u,c=i),c.duration!==g&&(c.duration=g)}else if(i.sn>l.sn){var m=l.cc===i.cc;m&&l.minEndPTS?i.start=l.start+(l.minEndPTS-l.start):i.start=l.start+l.duration}else i.start=Math.max(l.start-i.duration,0)}function _(l,i,u,g,c,m){var e=g-u;e<=0&&(L.logger.warn("Fragment should have a positive duration",i),g=u+i.duration,m=c+i.duration);var r=u,t=g,s=i.startPTS,y=i.endPTS;if((0,C.isFiniteNumber)(s)){var f=Math.abs(s-u);(0,C.isFiniteNumber)(i.deltaPTS)?i.deltaPTS=Math.max(f,i.deltaPTS):i.deltaPTS=f,r=Math.max(u,s),u=Math.min(u,s),c=Math.min(c,i.startDTS),t=Math.min(g,y),g=Math.max(g,y),m=Math.max(m,i.endDTS)}i.duration=g-u;var b=u-i.start;i.start=i.startPTS=u,i.maxStartPTS=r,i.startDTS=c,i.endPTS=g,i.minEndPTS=t,i.endDTS=m;var R=i.sn;if(!l||R<l.startSN||R>l.endSN)return 0;var I,k=R-l.startSN,F=l.fragments;for(F[k]=i,I=k;I>0;I--)x(F[I],F[I-1]);for(I=k;I<F.length-1;I++)x(F[I],F[I+1]);return l.fragmentHint&&x(F[F.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,b}function S(l,i){for(var u=null,g=l.fragments,c=g.length-1;c>=0;c--){var m=g[c].initSegment;if(m){u=m;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var e=0,r;if(p(l,i,function(I,k){I.relurl&&(e=I.cc-k.cc),(0,C.isFiniteNumber)(I.startPTS)&&(0,C.isFiniteNumber)(I.endPTS)&&(k.start=k.startPTS=I.startPTS,k.startDTS=I.startDTS,k.appendedPTS=I.appendedPTS,k.maxStartPTS=I.maxStartPTS,k.endPTS=I.endPTS,k.endDTS=I.endDTS,k.minEndPTS=I.minEndPTS,k.duration=I.endPTS-I.startPTS,k.duration&&(r=k),i.PTSKnown=i.alignedSliding=!0),k.elementaryStreams=I.elementaryStreams,k.loader=I.loader,k.stats=I.stats,k.urlId=I.urlId,I.initSegment&&(k.initSegment=I.initSegment,u=I.initSegment)}),u){var t=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;t.forEach(function(I){var k;(!I.initSegment||I.initSegment.relurl===((k=u)===null||k===void 0?void 0:k.relurl))&&(I.initSegment=u)})}if(i.skippedSegments)if(i.deltaUpdateFailed=i.fragments.some(function(I){return!I}),i.deltaUpdateFailed){L.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var s=i.skippedSegments;s--;)i.fragments.shift();i.startSN=i.fragments[0].sn,i.startCC=i.fragments[0].cc}else i.canSkipDateRanges&&(i.dateRanges=d(l.dateRanges,i.dateRanges,i.recentlyRemovedDateranges));var y=i.fragments;if(e){L.logger.warn("discontinuity sliding from playlist, take drift into account");for(var f=0;f<y.length;f++)y[f].cc+=e}i.skippedSegments&&(i.startCC=i.fragments[0].cc),E(l.partList,i.partList,function(I,k){k.elementaryStreams=I.elementaryStreams,k.stats=I.stats}),r?_(i,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):h(l,i),y.length&&(i.totalduration=i.edge-y[0].start),i.driftStartTime=l.driftStartTime,i.driftStart=l.driftStart;var b=i.advancedDateTime;if(i.advanced&&b){var R=i.edge;i.driftStart||(i.driftStartTime=b,i.driftStart=R),i.driftEndTime=b,i.driftEnd=R}else i.driftEndTime=l.driftEndTime,i.driftEnd=l.driftEnd,i.advancedDateTime=l.advancedDateTime}function d(l,i,u){var g=P({},l);return u&&u.forEach(function(c){delete g[c]}),Object.keys(i).forEach(function(c){var m=new M.DateRange(i[c].attr,g[c]);m.isValid?g[c]=m:L.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(i[c].attr)+'"')}),g}function E(l,i,u){if(l&&i)for(var g=0,c=0,m=l.length;c<=m;c++){var e=l[c],r=i[c+g];e&&r&&e.index===r.index&&e.fragment.sn===r.fragment.sn?u(e,r):g--}}function p(l,i,u){for(var g=i.skippedSegments,c=Math.max(l.startSN,i.startSN)-i.startSN,m=(l.fragmentHint?1:0)+(g?i.endSN:Math.min(l.endSN,i.endSN))-i.startSN,e=i.startSN-l.startSN,r=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,t=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,s=c;s<=m;s++){var y=t[e+s],f=r[s];g&&!f&&s<g&&(f=i.fragments[s]=y),y&&f&&u(y,f)}}function h(l,i){var u=i.startSN+i.skippedSegments-l.startSN,g=l.fragments;u<0||u>=g.length||a(i,g[u].start)}function a(l,i){if(i){for(var u=l.fragments,g=l.skippedSegments;g<u.length;g++)u[g].start+=i;l.fragmentHint&&(l.fragmentHint.start+=i)}}function o(l,i){i===void 0&&(i=1/0);var u=1e3*l.targetduration;if(l.updated){var g=l.fragments,c=4;if(g.length&&u*c>i){var m=g[g.length-1].duration*1e3;m<u&&(u=m)}}else u/=2;return Math.round(u)}function n(l,i,u){if(!l||!l.details)return null;var g=l.details,c=g.fragments[i-g.startSN];return c||(c=g.fragmentHint,c&&c.sn===i)?c:i<g.startSN&&u&&u.sn===i?u:null}function v(l,i,u){if(!l||!l.details)return null;var g=l.details.partList;if(g)for(var c=g.length;c--;){var m=g[c];if(m.index===u&&m.fragment.sn===i)return m}return null}},"./src/controller/stream-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>i});var C=T("./src/polyfills/number.ts"),L=T("./src/controller/base-stream-controller.ts"),M=T("./src/is-supported.ts"),P=T("./src/events.ts"),B=T("./src/utils/buffer-helper.ts"),A=T("./src/controller/fragment-tracker.ts"),D=T("./src/types/loader.ts"),x=T("./src/loader/fragment.ts"),_=T("./src/demux/transmuxer-interface.ts"),S=T("./src/types/transmuxer.ts"),d=T("./src/controller/gap-controller.ts"),E=T("./src/errors.ts");function p(u,g){for(var c=0;c<g.length;c++){var m=g[c];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,a(m.key),m)}}function h(u,g,c){return g&&p(u.prototype,g),c&&p(u,c),Object.defineProperty(u,"prototype",{writable:!1}),u}function a(u){var g=o(u,"string");return typeof g=="symbol"?g:String(g)}function o(u,g){if(typeof u!="object"||u===null)return u;var c=u[Symbol.toPrimitive];if(c!==void 0){var m=c.call(u,g||"default");if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(u)}function n(u,g){u.prototype=Object.create(g.prototype),u.prototype.constructor=u,v(u,g)}function v(u,g){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(m,e){return m.__proto__=e,m},v(u,g)}var l=100,i=function(u){n(g,u);function g(m,e,r){var t;return t=u.call(this,m,e,r,"[stream-controller]")||this,t.audioCodecSwap=!1,t.gapController=null,t.level=-1,t._forceStartLoad=!1,t.altAudio=!1,t.audioOnly=!1,t.fragPlaying=null,t.onvplaying=null,t.onvseeked=null,t.fragLastKbps=0,t.couldBacktrack=!1,t.backtrackFragment=null,t.audioCodecSwitch=!1,t.videoBuffer=null,t._registerListeners(),t}var c=g.prototype;return c._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_LOADED,this.onLevelLoaded,this),e.on(P.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(P.Events.ERROR,this.onError,this),e.on(P.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(P.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(P.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(P.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(P.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(P.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._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_LOADED,this.onLevelLoaded,this),e.off(P.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(P.Events.ERROR,this.onError,this),e.off(P.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(P.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(P.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(P.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(P.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(P.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},c.startLoad=function(e){if(this.levels){var r=this.lastCurrentTime,t=this.hls;if(this.stopLoad(),this.setInterval(l),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var s=t.startLevel;s===-1&&(t.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=t.nextAutoLevel),this.level=t.nextLoadLevel=s,this.loadedmetadata=!1}r>0&&e===-1&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),e=r),this.state=L.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=L.State.STOPPED},c.stopLoad=function(){this._forceStartLoad=!1,u.prototype.stopLoad.call(this)},c.doTick=function(){switch(this.state){case L.State.IDLE:this.doTickIdle();break;case L.State.WAITING_LEVEL:{var e,r=this.levels,t=this.level,s=r==null||(e=r[t])===null||e===void 0?void 0:e.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 y,f=self.performance.now(),b=this.retryDate;(!b||f>=b||(y=this.media)!==null&&y!==void 0&&y.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=L.State.IDLE)}break;default:break}this.onTickEnd()},c.onTickEnd=function(){u.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},c.doTickIdle=function(){var e=this.hls,r=this.levelLastLoaded,t=this.levels,s=this.media,y=e.config,f=e.nextLoadLevel;if(!(r===null||!s&&(this.startFragRequested||!y.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!t||!t[f])){var b=t[f],R=this.getMainFwdBufferInfo();if(R!==null){var I=this.getLevelDetails();if(I&&this._streamEnded(R,I)){var k={};this.altAudio&&(k.type="video"),this.hls.trigger(P.Events.BUFFER_EOS,k),this.state=L.State.ENDED;return}this.level=e.nextLoadLevel=f;var F=b.details;if(!F||this.state===L.State.WAITING_LEVEL||F.live&&this.levelLastLoaded!==f){this.level=f,this.state=L.State.WAITING_LEVEL;return}var K=R.len,H=this.getMaxBufferLength(b.maxBitrate);if(!(K>=H)){this.backtrackFragment&&this.backtrackFragment.start>R.end&&(this.backtrackFragment=null);var j=this.backtrackFragment?this.backtrackFragment.start:R.end,Y=this.getNextFragment(j,F);if(this.couldBacktrack&&!this.fragPrevious&&Y&&Y.sn!=="initSegment"&&this.fragmentTracker.getState(Y)!==A.FragmentState.OK){var Q,q=((Q=this.backtrackFragment)!=null?Q:Y).sn,ne=q-F.startSN,te=F.fragments[ne-1];te&&Y.cc===te.cc&&(Y=te,this.fragmentTracker.removeFragment(te))}else this.backtrackFragment&&R.len&&(this.backtrackFragment=null);if(Y&&this.fragmentTracker.getState(Y)===A.FragmentState.OK&&this.nextLoadPosition>j){var ae=this.audioOnly&&!this.altAudio?x.ElementaryStreamTypes.AUDIO:x.ElementaryStreamTypes.VIDEO,ue=(ae===x.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;ue&&this.afterBufferFlushed(ue,ae,D.PlaylistLevelType.MAIN),Y=this.getNextFragment(this.nextLoadPosition,F)}!Y||(Y.initSegment&&!Y.initSegment.data&&!this.bitrateTest&&(Y=Y.initSegment),this.loadFragment(Y,F,j))}}}},c.loadFragment=function(e,r,t){var s,y=this.fragmentTracker.getState(e);this.fragCurrent=e,y===A.FragmentState.NOT_LOADED?e.sn==="initSegment"?this._loadInitSegment(e,r):this.bitrateTest?(this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e,r)):(this.startFragRequested=!0,u.prototype.loadFragment.call(this,e,r,t)):y===A.FragmentState.APPENDING?this.reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e):((s=this.media)===null||s===void 0?void 0:s.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},c.getAppendedFrag=function(e){var r=this.fragmentTracker.getAppendedFrag(e,D.PlaylistLevelType.MAIN);return r&&"fragment"in r?r.fragment:r},c.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,D.PlaylistLevelType.MAIN)},c.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},c.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},c.nextLevelSwitch=function(){var e=this.levels,r=this.media;if(r!=null&&r.readyState){var t,s=this.getAppendedFrag(r.currentTime);if(s&&s.start>1&&this.flushMainBuffer(0,s.start-1),!r.paused&&e){var y=this.hls.nextLoadLevel,f=e[y],b=this.fragLastKbps;b&&this.fragCurrent?t=this.fragCurrent.duration*f.maxBitrate/(1e3*b)+1:t=0}else t=0;var R=this.getBufferedFrag(r.currentTime+t);if(R){var I=this.followingBufferedFrag(R);if(I){this.abortCurrentFrag();var k=I.maxStartPTS?I.maxStartPTS:I.start,F=I.duration,K=Math.max(R.end,k+Math.min(Math.max(F-this.config.maxFragLookUpTolerance,F*.5),F*.75));this.flushMainBuffer(K,Number.POSITIVE_INFINITY)}}}},c.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&e.abortRequests(),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()},c.flushMainBuffer=function(e,r){u.prototype.flushMainBuffer.call(this,e,r,this.altAudio?"video":null)},c.onMediaAttached=function(e,r){u.prototype.onMediaAttached.call(this,e,r);var t=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),t.addEventListener("playing",this.onvplaying),t.addEventListener("seeked",this.onvseeked),this.gapController=new d.default(this.config,t,this.fragmentTracker,this.hls)},c.onMediaDetaching=function(){var e=this.media;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),u.prototype.onMediaDetaching.call(this)},c.onMediaPlaying=function(){this.tick()},c.onMediaSeeked=function(){var e=this.media,r=e?e.currentTime:null;(0,C.isFiniteNumber)(r)&&this.log("Media seeked to "+r.toFixed(3)),this.tick()},c.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(P.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},c.onManifestParsed=function(e,r){var t=!1,s=!1,y;r.levels.forEach(function(f){y=f.audioCodec,y&&(y.indexOf("mp4a.40.2")!==-1&&(t=!0),y.indexOf("mp4a.40.5")!==-1&&(s=!0))}),this.audioCodecSwitch=t&&s&&!(0,M.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},c.onLevelLoading=function(e,r){var t=this.levels;if(!(!t||this.state!==L.State.IDLE)){var s=t[r.level];(!s.details||s.details.live&&this.levelLastLoaded!==r.level||this.waitForCdnTuneIn(s.details))&&(this.state=L.State.WAITING_LEVEL)}},c.onLevelLoaded=function(e,r){var t,s=this.levels,y=r.level,f=r.details,b=f.totalduration;if(!s){this.warn("Levels were reset while loading level "+y);return}this.log("Level "+y+" loaded ["+f.startSN+","+f.endSN+"], cc ["+f.startCC+", "+f.endCC+"] duration:"+b);var R=this.fragCurrent;R&&(this.state===L.State.FRAG_LOADING||this.state===L.State.FRAG_LOADING_WAITING_RETRY)&&R.level!==r.level&&R.loader&&(this.state=L.State.IDLE,this.backtrackFragment=null,R.abortRequests());var I=s[y],k=0;if(f.live||(t=I.details)!==null&&t!==void 0&&t.live){if(f.fragments[0]||(f.deltaUpdateFailed=!0),f.deltaUpdateFailed)return;k=this.alignPlaylists(f,I.details)}if(I.details=f,this.levelLastLoaded=y,this.hls.trigger(P.Events.LEVEL_UPDATED,{details:f,level:y}),this.state===L.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(f))return;this.state=L.State.IDLE}this.startFragRequested?f.live&&this.synchronizeToLiveEdge(f):this.setStartPosition(f,k),this.tick()},c._handleFragmentLoadProgress=function(e){var r,t=e.frag,s=e.part,y=e.payload,f=this.levels;if(!f){this.warn("Levels were reset while fragment load was in progress. Fragment "+t.sn+" of level "+t.level+" will not be buffered");return}var b=f[t.level],R=b.details;if(!R){this.warn("Dropping fragment "+t.sn+" of level "+t.level+" after level details were reset");return}var I=b.videoCodec,k=R.PTSKnown||!R.live,F=(r=t.initSegment)===null||r===void 0?void 0:r.data,K=this._getAudioCodec(b),H=this.transmuxer=this.transmuxer||new _.default(this.hls,D.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),j=s?s.index:-1,Y=j!==-1,Q=new S.ChunkMetadata(t.level,t.sn,t.stats.chunkCount,y.byteLength,j,Y),q=this.initPTS[t.cc];H.push(y,F,K,I,t,s,R.totalduration,k,Q,q)},c.onAudioTrackSwitching=function(e,r){var t=this.altAudio,s=!!r.url,y=r.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 f=this.fragCurrent;f&&(this.log("Switching to main audio track, cancel main fragment load"),f.abortRequests()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var b=this.hls;t&&b.trigger(P.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),b.trigger(P.Events.AUDIO_TRACK_SWITCHED,{id:y})}},c.onAudioTrackSwitched=function(e,r){var t=r.id,s=!!this.hls.audioTracks[t].url;if(s){var y=this.videoBuffer;y&&this.mediaBuffer!==y&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=y)}this.altAudio=s,this.tick()},c.onBufferCreated=function(e,r){var t=r.tracks,s,y,f=!1;for(var b in t){var R=t[b];if(R.id==="main"){if(y=b,s=R,b==="video"){var I=t[b];I&&(this.videoBuffer=I.buffer)}}else f=!0}f&&s?(this.log("Alternate track found, use "+y+".buffered to schedule main fragment loading"),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media},c.onFragBuffered=function(e,r){var t=r.frag,s=r.part;if(!(t&&t.type!==D.PlaylistLevelType.MAIN)){if(this.fragContextChanged(t)){this.warn("Fragment "+t.sn+(s?" p: "+s.index:"")+" of level "+t.level+" finished buffering, but was aborted. state: "+this.state),this.state===L.State.PARSED&&(this.state=L.State.IDLE);return}var y=s?s.stats:t.stats;this.fragLastKbps=Math.round(8*y.total/(y.buffering.end-y.loading.first)),t.sn!=="initSegment"&&(this.fragPrevious=t),this.fragBufferedComplete(t,s)}},c.onError=function(e,r){if(r.type===E.ErrorTypes.KEY_SYSTEM_ERROR){this.onFragmentOrKeyLoadError(D.PlaylistLevelType.MAIN,r);return}switch(r.details){case E.ErrorDetails.FRAG_LOAD_ERROR:case E.ErrorDetails.FRAG_LOAD_TIMEOUT:case E.ErrorDetails.FRAG_PARSING_ERROR:case E.ErrorDetails.KEY_LOAD_ERROR:case E.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(D.PlaylistLevelType.MAIN,r);break;case E.ErrorDetails.LEVEL_LOAD_ERROR:case E.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==L.State.ERROR&&(r.fatal?(this.warn(""+r.details),this.state=L.State.ERROR):!r.levelRetry&&this.state===L.State.WAITING_LEVEL&&(this.state=L.State.IDLE));break;case E.ErrorDetails.BUFFER_FULL_ERROR:if(r.parent==="main"&&(this.state===L.State.PARSING||this.state===L.State.PARSED)){var t=!0,s=this.getFwdBufferInfo(this.media,D.PlaylistLevelType.MAIN);s&&s.len>.5&&(t=!this.reduceMaxBufferLength(s.len)),t&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},c.checkBuffer=function(){var e=this.media,r=this.gapController;if(!(!e||!r||!e.readyState)){if(this.loadedmetadata||!B.BufferHelper.getBuffered(e).length){var t=this.state!==L.State.IDLE?this.fragCurrent:null;r.poll(this.lastCurrentTime,t)}this.lastCurrentTime=e.currentTime}},c.onFragLoadEmergencyAborted=function(){this.state=L.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},c.onBufferFlushed=function(e,r){var t=r.type;if(t!==x.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var s=(t===x.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(s,t,D.PlaylistLevelType.MAIN)}},c.onLevelsUpdated=function(e,r){this.levels=r.levels},c.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},c.seekToStartPos=function(){var e=this.media;if(!!e){var r=e.currentTime,t=this.startPosition;if(t>=0&&r<t){if(e.seeking){this.log("could not seek to "+t+", already seeking at "+r);return}var s=B.BufferHelper.getBuffered(e),y=s.length?s.start(0):0,f=y-t;f>0&&(f<this.config.maxBufferHole||f<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+f+" to match buffer start"),t+=f,this.startPosition=t),this.log("seek to target start position "+t+" from current time "+r),e.currentTime=t}}},c._getAudioCodec=function(e){var r=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r.indexOf("mp4a.40.5")!==-1?r="mp4a.40.2":r="mp4a.40.5"),r},c._loadBitrateTestFrag=function(e,r){var t=this;e.bitrateTest=!0,this._doFragLoad(e,r).then(function(s){var y=t.hls;if(!(!s||y.nextLoadLevel||t.fragContextChanged(e))){t.fragLoadError=0,t.state=L.State.IDLE,t.startFragRequested=!1,t.bitrateTest=!1;var f=e.stats;f.parsing.start=f.parsing.end=f.buffering.start=f.buffering.end=self.performance.now(),y.trigger(P.Events.FRAG_LOADED,s),e.bitrateTest=!1}})},c._handleTransmuxComplete=function(e){var r,t="main",s=this.hls,y=e.remuxResult,f=e.chunkMeta,b=this.getCurrentContext(f);if(!b){this.warn("The loading context changed while buffering fragment "+f.sn+" of level "+f.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(f.level);return}var R=b.frag,I=b.part,k=b.level,F=y.video,K=y.text,H=y.id3,j=y.initSegment,Y=k.details,Q=this.altAudio?void 0:y.audio;if(!this.fragContextChanged(R)){if(this.state=L.State.PARSING,j){j.tracks&&(this._bufferInitSegment(k,j.tracks,R,f),s.trigger(P.Events.FRAG_PARSING_INIT_SEGMENT,{frag:R,id:t,tracks:j.tracks}));var q=j.initPTS,ne=j.timescale;(0,C.isFiniteNumber)(q)&&(this.initPTS[R.cc]=q,s.trigger(P.Events.INIT_PTS_FOUND,{frag:R,id:t,initPTS:q,timescale:ne}))}if(F&&y.independent!==!1){if(Y){var te=F.startPTS,ae=F.endPTS,ue=F.startDTS,ce=F.endDTS;if(I)I.elementaryStreams[F.type]={startPTS:te,endPTS:ae,startDTS:ue,endDTS:ce};else if(F.firstKeyFrame&&F.independent&&f.id===1&&(this.couldBacktrack=!0),F.dropped&&F.independent){var le=this.getMainFwdBufferInfo(),fe=(le?le.end:this.getLoadPosition())+this.config.maxBufferHole,de=F.firstKeyFramePTS?F.firstKeyFramePTS:te;if(fe<de-this.config.maxBufferHole){this.backtrack(R);return}R.setElementaryStreamInfo(F.type,R.start,ae,R.start,ce,!0)}R.setElementaryStreamInfo(F.type,te,ae,ue,ce),this.backtrackFragment&&(this.backtrackFragment=R),this.bufferFragmentData(F,R,I,f)}}else if(y.independent===!1){this.backtrack(R);return}if(Q){var xe=Q.startPTS,Ae=Q.endPTS,Ie=Q.startDTS,Re=Q.endDTS;I&&(I.elementaryStreams[x.ElementaryStreamTypes.AUDIO]={startPTS:xe,endPTS:Ae,startDTS:Ie,endDTS:Re}),R.setElementaryStreamInfo(x.ElementaryStreamTypes.AUDIO,xe,Ae,Ie,Re),this.bufferFragmentData(Q,R,I,f)}if(Y&&H!==null&&H!==void 0&&(r=H.samples)!==null&&r!==void 0&&r.length){var Oe={id:t,frag:R,details:Y,samples:H.samples};s.trigger(P.Events.FRAG_PARSING_METADATA,Oe)}if(Y&&K){var Pe={id:t,frag:R,details:Y,samples:K.samples};s.trigger(P.Events.FRAG_PARSING_USERDATA,Pe)}}},c._bufferInitSegment=function(e,r,t,s){var y=this;if(this.state===L.State.PARSING){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var f=r.audio,b=r.video,R=r.audiovideo;if(f){var I=e.audioCodec,k=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(I&&(I.indexOf("mp4a.40.5")!==-1?I="mp4a.40.2":I="mp4a.40.5"),f.metadata.channelCount!==1&&k.indexOf("firefox")===-1&&(I="mp4a.40.5")),k.indexOf("android")!==-1&&f.container!=="audio/mpeg"&&(I="mp4a.40.2",this.log("Android: force audio codec to "+I)),e.audioCodec&&e.audioCodec!==I&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+I+'"'),f.levelCodec=I,f.id="main",this.log("Init audio buffer, container:"+f.container+", codecs[selected/level/parsed]=["+(I||"")+"/"+(e.audioCodec||"")+"/"+f.codec+"]")}b&&(b.levelCodec=e.videoCodec,b.id="main",this.log("Init video buffer, container:"+b.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+b.codec+"]")),R&&this.log("Init audiovideo buffer, container:"+R.container+", codecs[level/parsed]=["+(e.attrs.CODECS||"")+"/"+R.codec+"]"),this.hls.trigger(P.Events.BUFFER_CODECS,r),Object.keys(r).forEach(function(F){var K=r[F],H=K.initSegment;H!=null&&H.byteLength&&y.hls.trigger(P.Events.BUFFER_APPENDING,{type:F,data:H,frag:t,part:null,chunkMeta:s,parent:t.type})}),this.tick()}},c.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,D.PlaylistLevelType.MAIN)},c.backtrack=function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=L.State.IDLE},c.checkFragmentChanged=function(){var e=this.media,r=null;if(e&&e.readyState>1&&e.seeking===!1){var t=e.currentTime;if(B.BufferHelper.isBuffered(e,t)?r=this.getAppendedFrag(t):B.BufferHelper.isBuffered(e,t+.1)&&(r=this.getAppendedFrag(t+.1)),r){this.backtrackFragment=null;var s=this.fragPlaying,y=r.level;(!s||r.sn!==s.sn||s.level!==y||r.urlId!==s.urlId)&&(this.fragPlaying=r,this.hls.trigger(P.Events.FRAG_CHANGED,{frag:r}),(!s||s.level!==y)&&this.hls.trigger(P.Events.LEVEL_SWITCHED,{level:y}))}}},h(g,[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}},{key:"currentProgramDateTime",get:function(){var e=this.media;if(e){var r=e.currentTime,t=this.currentFrag;if(t&&(0,C.isFiniteNumber)(r)&&(0,C.isFiniteNumber)(t.programDateTime)){var s=t.programDateTime+(r-t.start)*1e3;return new Date(s)}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),g}(L.default)},"./src/controller/subtitle-stream-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{SubtitleStreamController:()=>n});var C=T("./src/events.ts"),L=T("./src/utils/buffer-helper.ts"),M=T("./src/controller/fragment-finders.ts"),P=T("./src/utils/discontinuities.ts"),B=T("./src/controller/level-helper.ts"),A=T("./src/controller/fragment-tracker.ts"),D=T("./src/controller/base-stream-controller.ts"),x=T("./src/types/loader.ts"),_=T("./src/types/level.ts");function S(l,i){for(var u=0;u<i.length;u++){var g=i[u];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(l,E(g.key),g)}}function d(l,i,u){return i&&S(l.prototype,i),u&&S(l,u),Object.defineProperty(l,"prototype",{writable:!1}),l}function E(l){var i=p(l,"string");return typeof i=="symbol"?i:String(i)}function p(l,i){if(typeof l!="object"||l===null)return l;var u=l[Symbol.toPrimitive];if(u!==void 0){var g=u.call(l,i||"default");if(typeof g!="object")return g;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(l)}function h(l,i){l.prototype=Object.create(i.prototype),l.prototype.constructor=l,a(l,i)}function a(l,i){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,c){return g.__proto__=c,g},a(l,i)}var o=500,n=function(l){h(i,l);function i(g,c,m){var e;return e=l.call(this,g,c,m,"[subtitle-stream-controller]")||this,e.levels=[],e.currentTrackId=-1,e.tracksBuffered=[],e.mainDetails=null,e._registerListeners(),e}var u=i.prototype;return u.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},u._registerListeners=function(){var c=this.hls;c.on(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(C.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(C.Events.ERROR,this.onError,this),c.on(C.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),c.on(C.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),c.on(C.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),c.on(C.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),c.on(C.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),c.on(C.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u._unregisterListeners=function(){var c=this.hls;c.off(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(C.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(C.Events.ERROR,this.onError,this),c.off(C.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),c.off(C.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),c.off(C.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),c.off(C.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),c.off(C.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),c.off(C.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u.startLoad=function(c){this.stopLoad(),this.state=D.State.IDLE,this.setInterval(o),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=c,this.tick()},u.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},u.onLevelLoaded=function(c,m){this.mainDetails=m.details},u.onSubtitleFragProcessed=function(c,m){var e=m.frag,r=m.success;if(this.fragPrevious=e,this.state=D.State.IDLE,!!r){var t=this.tracksBuffered[this.currentTrackId];if(!!t){for(var s,y=e.start,f=0;f<t.length;f++)if(y>=t[f].start&&y<=t[f].end){s=t[f];break}var b=e.start+e.duration;s?s.end=b:(s={start:y,end:b},t.push(s)),this.fragmentTracker.fragBuffered(e)}}},u.onBufferFlushing=function(c,m){var e=m.startOffset,r=m.endOffset;if(e===0&&r!==Number.POSITIVE_INFINITY){var t=this.currentTrackId,s=this.levels;if(!s.length||!s[t]||!s[t].details)return;var y=s[t].details,f=y.targetduration,b=r-f;if(b<=0)return;m.endOffsetSubtitles=Math.max(0,b),this.tracksBuffered.forEach(function(R){for(var I=0;I<R.length;){if(R[I].end<=b){R.shift();continue}else if(R[I].start<b)R[I].start=b;else break;I++}}),this.fragmentTracker.removeFragmentsInRange(e,b,x.PlaylistLevelType.SUBTITLE)}},u.onFragBuffered=function(c,m){if(!this.loadedmetadata&&m.frag.type===x.PlaylistLevelType.MAIN){var e;(e=this.media)!==null&&e!==void 0&&e.buffered.length&&(this.loadedmetadata=!0)}},u.onError=function(c,m){var e=m.frag;!e||e.type!==x.PlaylistLevelType.SUBTITLE||(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state=D.State.IDLE)},u.onSubtitleTracksUpdated=function(c,m){var e=this,r=m.subtitleTracks;this.tracksBuffered=[],this.levels=r.map(function(t){return new _.Level(t)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(t){e.tracksBuffered[t.id]=[]}),this.mediaBuffer=null},u.onSubtitleTrackSwitch=function(c,m){if(this.currentTrackId=m.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var e=this.levels[this.currentTrackId];e!=null&&e.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,e&&this.setInterval(o)},u.onSubtitleTrackLoaded=function(c,m){var e,r=m.details,t=m.id,s=this.currentTrackId,y=this.levels;if(!!y.length){var f=y[s];if(!(t>=y.length||t!==s||!f)){this.mediaBuffer=this.mediaBufferTimeRanges;var b=0;if(r.live||(e=f.details)!==null&&e!==void 0&&e.live){var R=this.mainDetails;if(r.deltaUpdateFailed||!R)return;var I=R.fragments[0];f.details?(b=this.alignPlaylists(r,f.details),b===0&&I&&(b=I.start,(0,B.addSliding)(r,b))):r.hasProgramDateTime&&R.hasProgramDateTime?((0,P.alignMediaPlaylistByPDT)(r,R),b=r.fragments[0].start):I&&(b=I.start,(0,B.addSliding)(r,b))}if(f.details=r,this.levelLastLoaded=t,!this.startFragRequested&&(this.mainDetails||!r.live)&&this.setStartPosition(f.details,b),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===D.State.IDLE){var k=(0,M.findFragmentByPTS)(null,r.fragments,this.media.currentTime,0);k||(this.warn("Subtitle playlist not aligned with playback"),f.details=void 0)}}}},u._handleFragmentLoadComplete=function(c){var m=this,e=c.frag,r=c.payload,t=e.decryptdata,s=this.hls;if(!this.fragContextChanged(e)&&r&&r.byteLength>0&&t&&t.key&&t.iv&&t.method==="AES-128"){var y=performance.now();this.decrypter.decrypt(new Uint8Array(r),t.key.buffer,t.iv.buffer).then(function(f){var b=performance.now();s.trigger(C.Events.FRAG_DECRYPTED,{frag:e,payload:f,stats:{tstart:y,tdecrypt:b}})}).catch(function(f){m.warn(f.name+": "+f.message),m.state=D.State.IDLE})}},u.doTick=function(){if(!this.media){this.state=D.State.IDLE;return}if(this.state===D.State.IDLE){var c=this.currentTrackId,m=this.levels;if(!m.length||!m[c]||!m[c].details)return;var e=m[c].details,r=e.targetduration,t=this.config,s=this.getLoadPosition(),y=L.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],s-r,t.maxBufferHole),f=y.end,b=y.len,R=this.getFwdBufferInfo(this.media,x.PlaylistLevelType.MAIN),I=this.getMaxBufferLength(R==null?void 0:R.len)+r;if(b>I)return;console.assert(e,"Subtitle track details are defined on idle subtitle stream controller tick");var k=e.fragments,F=k.length,K=e.edge,H=null,j=this.fragPrevious;if(f<K){var Y=t.maxFragLookUpTolerance;H=(0,M.findFragmentByPTS)(j,k,Math.max(k[0].start,f),Y),!H&&j&&j.start<k[0].start&&(H=k[0])}else H=k[F-1];if(!H)return;H=this.mapToInitFragWhenRequired(H),this.fragmentTracker.getState(H)===A.FragmentState.NOT_LOADED&&this.loadFragment(H,e,f)}},u.getMaxBufferLength=function(c){var m=l.prototype.getMaxBufferLength.call(this);return c?Math.max(m,c):m},u.loadFragment=function(c,m,e){this.fragCurrent=c,c.sn==="initSegment"?this._loadInitSegment(c,m):(this.startFragRequested=!0,l.prototype.loadFragment.call(this,c,m,e))},d(i,[{key:"mediaBufferTimeRanges",get:function(){return new v(this.tracksBuffered[this.currentTrackId]||[])}}]),i}(D.default),v=function(i){this.buffered=void 0;var u=function(c,m,e){if(m=m>>>0,m>e-1)throw new DOMException("Failed to execute '"+c+"' on 'TimeRanges': The index provided ("+m+") is greater than the maximum bound ("+e+")");return i[m][c]};this.buffered={get length(){return i.length},end:function(c){return u("end",c,i.length)},start:function(c){return u("start",c,i.length)}}}},"./src/controller/subtitle-track-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>p});var C=T("./src/events.ts"),L=T("./src/utils/texttrack-utils.ts"),M=T("./src/controller/base-playlist-controller.ts"),P=T("./src/types/loader.ts");function B(h,a){for(var o=0;o<a.length;o++){var n=a[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(h,D(n.key),n)}}function A(h,a,o){return a&&B(h.prototype,a),o&&B(h,o),Object.defineProperty(h,"prototype",{writable:!1}),h}function D(h){var a=x(h,"string");return typeof a=="symbol"?a:String(a)}function x(h,a){if(typeof h!="object"||h===null)return h;var o=h[Symbol.toPrimitive];if(o!==void 0){var n=o.call(h,a||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(h)}function _(h,a){h.prototype=Object.create(a.prototype),h.prototype.constructor=h,S(h,a)}function S(h,a){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,v){return n.__proto__=v,n},S(h,a)}var d=function(h){_(a,h);function a(n){var v;return v=h.call(this,n,"[subtitle-track-controller]")||this,v.media=null,v.tracks=[],v.groupId=null,v.tracksInGroup=[],v.trackId=-1,v.selectDefaultTrack=!0,v.queuedDefaultTrack=-1,v.trackChangeListener=function(){return v.onTextTracksChanged()},v.asyncPollTrackChange=function(){return v.pollTrackChange(0)},v.useTextTrackPolling=!1,v.subtitlePollingInterval=-1,v._subtitleDisplay=!0,v.registerListeners(),v}var o=a.prototype;return o.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,h.prototype.destroy.call(this)},o.registerListeners=function(){var v=this.hls;v.on(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),v.on(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),v.on(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.on(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.on(C.Events.LEVEL_LOADING,this.onLevelLoading,this),v.on(C.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),v.on(C.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),v.on(C.Events.ERROR,this.onError,this)},o.unregisterListeners=function(){var v=this.hls;v.off(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),v.off(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),v.off(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.off(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.off(C.Events.LEVEL_LOADING,this.onLevelLoading,this),v.off(C.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),v.off(C.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),v.off(C.Events.ERROR,this.onError,this)},o.onMediaAttached=function(v,l){this.media=l.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))},o.pollTrackChange=function(v){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,v)},o.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 v=E(this.media.textTracks);v.forEach(function(l){(0,L.clearCurrentCues)(l)}),this.subtitleTrack=-1,this.media=null}},o.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},o.onManifestParsed=function(v,l){this.tracks=l.subtitleTracks},o.onSubtitleTrackLoaded=function(v,l){var i=l.id,u=l.details,g=this.trackId,c=this.tracksInGroup[g];if(!c){this.warn("Invalid subtitle track id "+i);return}var m=c.details;c.details=l.details,this.log("subtitle track "+i+" loaded ["+u.startSN+"-"+u.endSN+"]"),i===this.trackId&&(this.retryCount=0,this.playlistLoaded(i,l,m))},o.onLevelLoading=function(v,l){this.switchLevel(l.level)},o.onLevelSwitching=function(v,l){this.switchLevel(l.level)},o.switchLevel=function(v){var l=this.hls.levels[v];if(!!(l!=null&&l.textGroupIds)){var i=l.textGroupIds[l.urlId];if(this.groupId!==i){var u=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,g=this.tracks.filter(function(e){return!i||e.groupId===i});this.tracksInGroup=g;var c=this.findTrackId(u==null?void 0:u.name)||this.findTrackId();this.groupId=i;var m={subtitleTracks:g};this.log("Updating subtitle tracks, "+g.length+' track(s) found in "'+i+'" group-id'),this.hls.trigger(C.Events.SUBTITLE_TRACKS_UPDATED,m),c!==-1&&this.setSubtitleTrack(c,u)}}},o.findTrackId=function(v){for(var l=this.tracksInGroup,i=0;i<l.length;i++){var u=l[i];if((!this.selectDefaultTrack||u.default)&&(!v||v===u.name))return u.id}return-1},o.onError=function(v,l){h.prototype.onError.call(this,v,l),!(l.fatal||!l.context)&&l.context.type===P.PlaylistContextType.SUBTITLE_TRACK&&l.context.id===this.trackId&&l.context.groupId===this.groupId&&this.retryLoadingOrFail(l)},o.loadPlaylist=function(v){h.prototype.loadPlaylist.call(this);var l=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(l)){var i=l.id,u=l.groupId,g=l.url;if(v)try{g=v.addDirectives(g)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(C.Events.SUBTITLE_TRACK_LOADING,{url:g,id:i,groupId:u,deliveryDirectives:v||null})}},o.toggleTrackModes=function(v){var l=this,i=this.media,u=this.trackId;if(!!i){var g=E(i.textTracks),c=g.filter(function(r){return r.groupId===l.groupId});if(v===-1)[].slice.call(g).forEach(function(r){r.mode="disabled"});else{var m=c[u];m&&(m.mode="disabled")}var e=c[v];e&&(e.mode=this.subtitleDisplay?"showing":"hidden")}},o.setSubtitleTrack=function(v,l){var i,u=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=v;return}if(this.trackId!==v&&this.toggleTrackModes(v),!(this.trackId===v&&(v===-1||(i=u[v])!==null&&i!==void 0&&i.details)||v<-1||v>=u.length)){this.clearTimer();var g=u[v];if(this.log("Switching to subtitle track "+v),this.trackId=v,g){var c=g.id,m=g.groupId,e=m===void 0?"":m,r=g.name,t=g.type,s=g.url;this.hls.trigger(C.Events.SUBTITLE_TRACK_SWITCH,{id:c,groupId:e,name:r,type:t,url:s});var y=this.switchParams(g.url,l==null?void 0:l.details);this.loadPlaylist(y)}else this.hls.trigger(C.Events.SUBTITLE_TRACK_SWITCH,{id:v})}},o.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var v=-1,l=E(this.media.textTracks),i=0;i<l.length;i++)if(l[i].mode==="hidden")v=i;else if(l[i].mode==="showing"){v=i;break}this.subtitleTrack!==v&&(this.subtitleTrack=v)}},A(a,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(v){this._subtitleDisplay=v,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(v){this.selectDefaultTrack=!1;var l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(v,l)}}]),a}(M.default);function E(h){for(var a=[],o=0;o<h.length;o++){var n=h[o];n.kind==="subtitles"&&n.label&&a.push(h[o])}return a}let p=d},"./src/controller/timeline-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{TimelineController:()=>d});var C=T("./src/polyfills/number.ts"),L=T("./src/events.ts"),M=T("./src/utils/cea-608-parser.ts"),P=T("./src/utils/output-filter.ts"),B=T("./src/utils/webvtt-parser.ts"),A=T("./src/utils/texttrack-utils.ts"),D=T("./src/utils/imsc1-ttml-parser.ts"),x=T("./src/utils/mp4-tools.ts"),_=T("./src/types/loader.ts"),S=T("./src/utils/logger.ts"),d=function(){function a(n){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=h(),this.captionsProperties=void 0,this.hls=n,this.config=n.config,this.Cues=n.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 v=new P.default(this,"textTrack1"),l=new P.default(this,"textTrack2"),i=new P.default(this,"textTrack3"),u=new P.default(this,"textTrack4");this.cea608Parser1=new M.default(1,v,l),this.cea608Parser2=new M.default(3,i,u)}n.on(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),n.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),n.on(L.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),n.on(L.Events.FRAG_LOADING,this.onFragLoading,this),n.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),n.on(L.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),n.on(L.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),n.on(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.on(L.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),n.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=a.prototype;return o.destroy=function(){var v=this.hls;v.off(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),v.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.off(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),v.off(L.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),v.off(L.Events.FRAG_LOADING,this.onFragLoading,this),v.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),v.off(L.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),v.off(L.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),v.off(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),v.off(L.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),v.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(v,l,i,u,g){for(var c=!1,m=g.length;m--;){var e=g[m],r=p(e[0],e[1],l,i);if(r>=0&&(e[0]=Math.min(e[0],l),e[1]=Math.max(e[1],i),c=!0,r/(i-l)>.5))return}if(c||g.push([l,i]),this.config.renderTextTracksNatively){var t=this.captionsTracks[v];this.Cues.newCue(t,l,i,u)}else{var s=this.Cues.newCue(null,l,i,u);this.hls.trigger(L.Events.CUES_PARSED,{type:"captions",cues:s,track:v})}},o.onInitPtsFound=function(v,l){var i=this,u=l.frag,g=l.id,c=l.initPTS,m=l.timescale,e=this.unparsedVttFrags;g==="main"&&(this.initPTS[u.cc]=c,this.timescale[u.cc]=m),e.length&&(this.unparsedVttFrags=[],e.forEach(function(r){i.onFragLoaded(L.Events.FRAG_LOADED,r)}))},o.getExistingTrack=function(v){var l=this.media;if(l)for(var i=0;i<l.textTracks.length;i++){var u=l.textTracks[i];if(u[v])return u}return null},o.createCaptionsTrack=function(v){this.config.renderTextTracksNatively?this.createNativeTrack(v):this.createNonNativeTrack(v)},o.createNativeTrack=function(v){if(!this.captionsTracks[v]){var l=this.captionsProperties,i=this.captionsTracks,u=this.media,g=l[v],c=g.label,m=g.languageCode,e=this.getExistingTrack(v);if(e)i[v]=e,(0,A.clearCurrentCues)(i[v]),(0,A.sendAddTrackEvent)(i[v],u);else{var r=this.createTextTrack("captions",c,m);r&&(r[v]=!0,i[v]=r)}}},o.createNonNativeTrack=function(v){if(!this.nonNativeCaptionsTracks[v]){var l=this.captionsProperties[v];if(!!l){var i=l.label,u={_id:v,label:i,kind:"captions",default:l.media?!!l.media.default:!1,closedCaptions:l.media};this.nonNativeCaptionsTracks[v]=u,this.hls.trigger(L.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[u]})}}},o.createTextTrack=function(v,l,i){var u=this.media;if(!!u)return u.addTextTrack(v,l,i)},o.onMediaAttaching=function(v,l){this.media=l.media,this._cleanTracks()},o.onMediaDetaching=function(){var v=this.captionsTracks;Object.keys(v).forEach(function(l){(0,A.clearCurrentCues)(v[l]),delete v[l]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=h(),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 v=this.media;if(!!v){var l=v.textTracks;if(l)for(var i=0;i<l.length;i++)(0,A.clearCurrentCues)(l[i])}},o.onSubtitleTracksUpdated=function(v,l){var i=this;this.textTracks=[];var u=l.subtitleTracks||[],g=u.some(function(r){return r.textCodec===D.IMSC1_CODEC});if(this.config.enableWebVTT||g&&this.config.enableIMSC1){var c=this.tracks&&u&&this.tracks.length===u.length;if(this.tracks=u||[],this.config.renderTextTracksNatively){var m=this.media?this.media.textTracks:[];this.tracks.forEach(function(r,t){var s;if(t<m.length){for(var y=null,f=0;f<m.length;f++)if(E(m[f],r)){y=m[f];break}y&&(s=y)}if(s)(0,A.clearCurrentCues)(s);else{var b=i._captionsOrSubtitlesFromCharacteristics(r);s=i.createTextTrack(b,r.name,r.lang),s&&(s.mode="disabled")}s&&(s.groupId=r.groupId,i.textTracks.push(s))})}else if(!c&&this.tracks&&this.tracks.length){var e=this.tracks.map(function(r){return{label:r.name,kind:r.type.toLowerCase(),default:r.default,subtitleTrack:r}});this.hls.trigger(L.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}},o._captionsOrSubtitlesFromCharacteristics=function(v){var l;if((l=v.attrs)!==null&&l!==void 0&&l.CHARACTERISTICS){var i=/transcribes-spoken-dialog/gi.test(v.attrs.CHARACTERISTICS),u=/describes-music-and-sound/gi.test(v.attrs.CHARACTERISTICS);if(i&&u)return"captions"}return"subtitles"},o.onManifestLoaded=function(v,l){var i=this;this.config.enableCEA708Captions&&l.captions&&l.captions.forEach(function(u){var g=/(?:CC|SERVICE)([1-4])/.exec(u.instreamId);if(!!g){var c="textTrack"+g[1],m=i.captionsProperties[c];!m||(m.label=u.name,u.lang&&(m.languageCode=u.lang),m.media=u)}})},o.closedCaptionsForLevel=function(v){var l=this.hls.levels[v.level];return l==null?void 0:l.attrs["CLOSED-CAPTIONS"]},o.onFragLoading=function(v,l){var i=this.cea608Parser1,u=this.cea608Parser2,g=this.lastSn,c=this.lastPartIndex;if(!(!this.enabled||!(i&&u))&&l.frag.type===_.PlaylistLevelType.MAIN){var m,e,r=l.frag.sn,t=(m=l==null||(e=l.part)===null||e===void 0?void 0:e.index)!=null?m:-1;r===g+1||r===g&&t===c+1||(i.reset(),u.reset()),this.lastSn=r,this.lastPartIndex=t}},o.onFragLoaded=function(v,l){var i=l.frag,u=l.payload,g=this.initPTS,c=this.unparsedVttFrags;if(i.type===_.PlaylistLevelType.SUBTITLE)if(u.byteLength){if(!(0,C.isFiniteNumber)(g[i.cc])){c.push(l),g.length&&this.hls.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Missing initial subtitle PTS")});return}var m=i.decryptdata,e="stats"in l;if(m==null||!m.encrypted||e){var r=this.tracks[i.level],t=this.vttCCs;t[i.cc]||(t[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),r&&r.textCodec===D.IMSC1_CODEC?this._parseIMSC1(i,u):this._parseVTTs(i,u,t)}}else this.hls.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(v,l){var i=this,u=this.hls;(0,D.parseIMSC1)(l,this.initPTS[v.cc],this.timescale[v.cc],function(g){i._appendCues(g,v.level),u.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:v})},function(g){S.logger.log("Failed to parse IMSC1: "+g),u.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:v,error:g})})},o._parseVTTs=function(v,l,i){var u,g=this,c=this.hls,m=(u=v.initSegment)!==null&&u!==void 0&&u.data?(0,x.appendUint8Array)(v.initSegment.data,new Uint8Array(l)):l;(0,B.parseWebVTT)(m,this.initPTS[v.cc],this.timescale[v.cc],i,v.cc,v.start,function(e){g._appendCues(e,v.level),c.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:v})},function(e){g._fallbackToIMSC1(v,l),S.logger.log("Failed to parse VTT cue: "+e),c.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:v,error:e})})},o._fallbackToIMSC1=function(v,l){var i=this,u=this.tracks[v.level];u.textCodec||(0,D.parseIMSC1)(l,this.initPTS[v.cc],this.timescale[v.cc],function(){u.textCodec=D.IMSC1_CODEC,i._parseIMSC1(v,l)},function(){u.textCodec="wvtt"})},o._appendCues=function(v,l){var i=this.hls;if(this.config.renderTextTracksNatively){var u=this.textTracks[l];if(!u||u.mode==="disabled")return;v.forEach(function(m){return(0,A.addCueToTrack)(u,m)})}else{var g=this.tracks[l];if(!g)return;var c=g.default?"default":"subtitles"+l;i.trigger(L.Events.CUES_PARSED,{type:"subtitles",cues:v,track:c})}},o.onFragDecrypted=function(v,l){var i=l.frag;if(i.type===_.PlaylistLevelType.SUBTITLE){if(!(0,C.isFiniteNumber)(this.initPTS[i.cc])){this.unparsedVttFrags.push(l);return}this.onFragLoaded(L.Events.FRAG_LOADED,l)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(v,l){var i=this.cea608Parser1,u=this.cea608Parser2;if(!(!this.enabled||!(i&&u))){var g=l.frag,c=l.samples;if(!(g.type===_.PlaylistLevelType.MAIN&&this.closedCaptionsForLevel(g)==="NONE"))for(var m=0;m<c.length;m++){var e=c[m].bytes;if(e){var r=this.extractCea608Data(e);i.addData(c[m].pts,r[0]),u.addData(c[m].pts,r[1])}}}},o.onBufferFlushing=function(v,l){var i=l.startOffset,u=l.endOffset,g=l.endOffsetSubtitles,c=l.type,m=this.media;if(!(!m||m.currentTime<u)){if(!c||c==="video"){var e=this.captionsTracks;Object.keys(e).forEach(function(t){return(0,A.removeCuesInRange)(e[t],i,u)})}if(this.config.renderTextTracksNatively&&i===0&&g!==void 0){var r=this.textTracks;Object.keys(r).forEach(function(t){return(0,A.removeCuesInRange)(r[t],i,g)})}}},o.extractCea608Data=function(v){for(var l=[[],[]],i=v[0]&31,u=2,g=0;g<i;g++){var c=v[u++],m=127&v[u++],e=127&v[u++];if(!(m===0&&e===0)){var r=(4&c)!==0;if(r){var t=3&c;(t===0||t===1)&&(l[t].push(m),l[t].push(e))}}}return l},a}();function E(a,o){return a&&a.label===o.name&&!(a.textTrack1||a.textTrack2)}function p(a,o,n,v){return Math.min(o,v)-Math.max(a,n)}function h(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>C});var C=function(){function L(P,B){this.subtle=void 0,this.aesIV=void 0,this.subtle=P,this.aesIV=B}var M=L.prototype;return M.decrypt=function(B,A){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},A,B)},L}()},"./src/crypt/aes-decryptor.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>M,removePadding:()=>L});var C=T("./src/utils/typed-array.ts");function L(P){var B=P.byteLength,A=B&&new DataView(P.buffer).getUint8(B-1);return A?(0,C.sliceUint8)(P,0,B-A):P}var M=function(){function P(){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 B=P.prototype;return B.uint8ArrayToUint32Array_=function(D){for(var x=new DataView(D),_=new Uint32Array(4),S=0;S<4;S++)_[S]=x.getUint32(S*4);return _},B.initTable=function(){var D=this.sBox,x=this.invSBox,_=this.subMix,S=_[0],d=_[1],E=_[2],p=_[3],h=this.invSubMix,a=h[0],o=h[1],n=h[2],v=h[3],l=new Uint32Array(256),i=0,u=0,g=0;for(g=0;g<256;g++)g<128?l[g]=g<<1:l[g]=g<<1^283;for(g=0;g<256;g++){var c=u^u<<1^u<<2^u<<3^u<<4;c=c>>>8^c&255^99,D[i]=c,x[c]=i;var m=l[i],e=l[m],r=l[e],t=l[c]*257^c*16843008;S[i]=t<<24|t>>>8,d[i]=t<<16|t>>>16,E[i]=t<<8|t>>>24,p[i]=t,t=r*16843009^e*65537^m*257^i*16843008,a[c]=t<<24|t>>>8,o[c]=t<<16|t>>>16,n[c]=t<<8|t>>>24,v[c]=t,i?(i=m^l[l[l[r^m]]],u^=l[l[u]]):i=u=1}},B.expandKey=function(D){for(var x=this.uint8ArrayToUint32Array_(D),_=!0,S=0;S<x.length&&_;)_=x[S]===this.key[S],S++;if(!_){this.key=x;var d=this.keySize=x.length;if(d!==4&&d!==6&&d!==8)throw new Error("Invalid aes key size="+d);var E=this.ksRows=(d+6+1)*4,p,h,a=this.keySchedule=new Uint32Array(E),o=this.invKeySchedule=new Uint32Array(E),n=this.sBox,v=this.rcon,l=this.invSubMix,i=l[0],u=l[1],g=l[2],c=l[3],m,e;for(p=0;p<E;p++){if(p<d){m=a[p]=x[p];continue}e=m,p%d===0?(e=e<<8|e>>>24,e=n[e>>>24]<<24|n[e>>>16&255]<<16|n[e>>>8&255]<<8|n[e&255],e^=v[p/d|0]<<24):d>6&&p%d===4&&(e=n[e>>>24]<<24|n[e>>>16&255]<<16|n[e>>>8&255]<<8|n[e&255]),a[p]=m=(a[p-d]^e)>>>0}for(h=0;h<E;h++)p=E-h,h&3?e=a[p]:e=a[p-4],h<4||p<=4?o[h]=e:o[h]=i[n[e>>>24]]^u[n[e>>>16&255]]^g[n[e>>>8&255]]^c[n[e&255]],o[h]=o[h]>>>0}},B.networkToHostOrderSwap=function(D){return D<<24|(D&65280)<<8|(D&16711680)>>8|D>>>24},B.decrypt=function(D,x,_){for(var S=this.keySize+6,d=this.invKeySchedule,E=this.invSBox,p=this.invSubMix,h=p[0],a=p[1],o=p[2],n=p[3],v=this.uint8ArrayToUint32Array_(_),l=v[0],i=v[1],u=v[2],g=v[3],c=new Int32Array(D),m=new Int32Array(c.length),e,r,t,s,y,f,b,R,I,k,F,K,H,j,Y=this.networkToHostOrderSwap;x<c.length;){for(I=Y(c[x]),k=Y(c[x+1]),F=Y(c[x+2]),K=Y(c[x+3]),y=I^d[0],f=K^d[1],b=F^d[2],R=k^d[3],H=4,j=1;j<S;j++)e=h[y>>>24]^a[f>>16&255]^o[b>>8&255]^n[R&255]^d[H],r=h[f>>>24]^a[b>>16&255]^o[R>>8&255]^n[y&255]^d[H+1],t=h[b>>>24]^a[R>>16&255]^o[y>>8&255]^n[f&255]^d[H+2],s=h[R>>>24]^a[y>>16&255]^o[f>>8&255]^n[b&255]^d[H+3],y=e,f=r,b=t,R=s,H=H+4;e=E[y>>>24]<<24^E[f>>16&255]<<16^E[b>>8&255]<<8^E[R&255]^d[H],r=E[f>>>24]<<24^E[b>>16&255]<<16^E[R>>8&255]<<8^E[y&255]^d[H+1],t=E[b>>>24]<<24^E[R>>16&255]<<16^E[y>>8&255]<<8^E[f&255]^d[H+2],s=E[R>>>24]<<24^E[y>>16&255]<<16^E[f>>8&255]<<8^E[b&255]^d[H+3],m[x]=Y(e^l),m[x+1]=Y(s^i),m[x+2]=Y(t^u),m[x+3]=Y(r^g),l=I,i=k,u=F,g=K,x=x+4}return m.buffer},P}()},"./src/crypt/decrypter.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>x});var C=T("./src/crypt/aes-crypto.ts"),L=T("./src/crypt/fast-aes-key.ts"),M=T("./src/crypt/aes-decryptor.ts"),P=T("./src/utils/logger.ts"),B=T("./src/utils/mp4-tools.ts"),A=T("./src/utils/typed-array.ts"),D=16,x=function(){function _(d,E){var p=E===void 0?{}:E,h=p.removePKCS7Padding,a=h===void 0?!0:h;if(this.logEnabled=!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.useSoftware=void 0,this.useSoftware=d.enableSoftwareAES,this.removePKCS7Padding=a,a)try{var o=self.crypto;o&&(this.subtle=o.subtle||o.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var S=_.prototype;return S.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},S.isSync=function(){return this.useSoftware},S.flush=function(){var E=this.currentResult,p=this.remainderData;if(!E||p)return P.logger.error("[softwareDecrypt] "+(p?"overflow bytes: "+p.byteLength:"no result")),this.reset(),null;var h=new Uint8Array(E);return this.reset(),this.removePKCS7Padding?(0,M.removePadding)(h):h},S.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},S.decrypt=function(E,p,h){var a=this;return this.useSoftware?new Promise(function(o,n){a.softwareDecrypt(new Uint8Array(E),p,h);var v=a.flush();v?o(v.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(E),p,h)},S.softwareDecrypt=function(E,p,h){var a=this.currentIV,o=this.currentResult,n=this.remainderData;this.logOnce("JS AES decrypt"),n&&(E=(0,B.appendUint8Array)(n,E),this.remainderData=null);var v=this.getValidChunk(E);if(!v.length)return null;a&&(h=a);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new M.default),l.expandKey(p);var i=o;return this.currentResult=l.decrypt(v.buffer,0,h),this.currentIV=(0,A.sliceUint8)(v,-16).buffer,i||null},S.webCryptoDecrypt=function(E,p,h){var a=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(n){if(!o)return Promise.reject(new Error("web crypto not initialized"));a.logOnce("WebCrypto AES decrypt");var v=new C.default(o,new Uint8Array(h));return v.decrypt(E.buffer,n)}).catch(function(n){return P.logger.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+n.name+": "+n.message),a.onWebCryptoError(E,p,h)})},S.onWebCryptoError=function(E,p,h){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(E,p,h);var a=this.flush();if(a)return a.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},S.getValidChunk=function(E){var p=E,h=E.length-E.length%D;return h!==E.length&&(p=(0,A.sliceUint8)(E,0,h),this.remainderData=(0,A.sliceUint8)(E,h)),p},S.logOnce=function(E){!this.logEnabled||(P.logger.log("[decrypter]: "+E),this.logEnabled=!1)},_}()},"./src/crypt/fast-aes-key.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>C});var C=function(){function L(P,B){this.subtle=void 0,this.key=void 0,this.subtle=P,this.key=B}var M=L.prototype;return M.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},L}()},"./src/demux/aacdemuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>x});var C=T("./src/demux/base-audio-demuxer.ts"),L=T("./src/demux/adts.ts"),M=T("./src/utils/logger.ts"),P=T("./src/demux/id3.ts");function B(_,S){_.prototype=Object.create(S.prototype),_.prototype.constructor=_,A(_,S)}function A(_,S){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,p){return E.__proto__=p,E},A(_,S)}var D=function(_){B(S,_);function S(E,p){var h;return h=_.call(this)||this,h.observer=void 0,h.config=void 0,h.observer=E,h.config=p,h}var d=S.prototype;return d.resetInitSegment=function(p,h,a,o){_.prototype.resetInitSegment.call(this,p,h,a,o),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:h,duration:o,inputTimeScale:9e4,dropped:0}},S.probe=function(p){if(!p)return!1;for(var h=P.getID3Data(p,0)||[],a=h.length,o=p.length;a<o;a++)if(L.probe(p,a))return M.logger.log("ADTS sync word found !"),!0;return!1},d.canParse=function(p,h){return L.canParse(p,h)},d.appendFrame=function(p,h,a){L.initTrackConfig(p,this.observer,h,a,p.manifestCodec);var o=L.appendFrame(p,h,a,this.basePTS,this.frameIndex);if(o&&o.missing===0)return o},S}(C.default);let x=D},"./src/demux/adts.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{appendFrame:()=>a,canGetFrameLength:()=>x,canParse:()=>S,getAudioConfig:()=>P,getFrameDuration:()=>p,getFullFrameLength:()=>D,getHeaderLength:()=>A,initTrackConfig:()=>E,isHeader:()=>_,isHeaderPattern:()=>B,parseFrameHeader:()=>h,probe:()=>d});var C=T("./src/utils/logger.ts"),L=T("./src/errors.ts"),M=T("./src/events.ts");function P(o,n,v,l){var i,u,g,c,m=navigator.userAgent.toLowerCase(),e=l,r=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];i=((n[v+2]&192)>>>6)+1;var t=(n[v+2]&60)>>>2;if(t>r.length-1){o.trigger(M.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+t});return}return g=(n[v+2]&1)<<2,g|=(n[v+3]&192)>>>6,C.logger.log("manifest codec:"+l+", ADTS type:"+i+", samplingIndex:"+t),/firefox/i.test(m)?t>=6?(i=5,c=new Array(4),u=t-3):(i=2,c=new Array(2),u=t):m.indexOf("android")!==-1?(i=2,c=new Array(2),u=t):(i=5,c=new Array(4),l&&(l.indexOf("mp4a.40.29")!==-1||l.indexOf("mp4a.40.5")!==-1)||!l&&t>=6?u=t-3:((l&&l.indexOf("mp4a.40.2")!==-1&&(t>=6&&g===1||/vivaldi/i.test(m))||!l&&g===1)&&(i=2,c=new Array(2)),u=t)),c[0]=i<<3,c[0]|=(t&14)>>1,c[1]|=(t&1)<<7,c[1]|=g<<3,i===5&&(c[1]|=(u&14)>>1,c[2]=(u&1)<<7,c[2]|=8,c[3]=0),{config:c,samplerate:r[t],channelCount:g,codec:"mp4a.40."+i,manifestCodec:e}}function B(o,n){return o[n]===255&&(o[n+1]&246)===240}function A(o,n){return o[n+1]&1?7:9}function D(o,n){return(o[n+3]&3)<<11|o[n+4]<<3|(o[n+5]&224)>>>5}function x(o,n){return n+5<o.length}function _(o,n){return n+1<o.length&&B(o,n)}function S(o,n){return x(o,n)&&B(o,n)&&D(o,n)<=o.length-n}function d(o,n){if(_(o,n)){var v=A(o,n);if(n+v>=o.length)return!1;var l=D(o,n);if(l<=v)return!1;var i=n+l;return i===o.length||_(o,i)}return!1}function E(o,n,v,l,i){if(!o.samplerate){var u=P(n,v,l,i);if(!u)return;o.config=u.config,o.samplerate=u.samplerate,o.channelCount=u.channelCount,o.codec=u.codec,o.manifestCodec=u.manifestCodec,C.logger.log("parsed codec:"+o.codec+", rate:"+u.samplerate+", channels:"+u.channelCount)}}function p(o){return 9216e4/o}function h(o,n){var v=A(o,n);if(n+v<=o.length){var l=D(o,n)-v;if(l>0)return{headerLength:v,frameLength:l}}}function a(o,n,v,l,i){var u=p(o.samplerate),g=l+i*u,c=h(n,v),m;if(c){var e=c.frameLength,r=c.headerLength,t=r+e,s=Math.max(0,v+t-n.length);s?(m=new Uint8Array(t-r),m.set(n.subarray(v+r,n.length),0)):m=n.subarray(v+r,v+t);var y={unit:m,pts:g};return s||o.samples.push(y),{sample:y,length:t,missing:s}}var f=n.length-v;m=new Uint8Array(f),m.set(n.subarray(v,n.length),0);var b={unit:m,pts:g};return{sample:b,length:f,missing:-1}}},"./src/demux/base-audio-demuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>_,initPTSFn:()=>x});var C=T("./src/polyfills/number.ts"),L=T("./src/demux/id3.ts"),M=T("./src/types/demuxer.ts"),P=T("./src/demux/dummy-demuxed-track.ts"),B=T("./src/utils/mp4-tools.ts"),A=T("./src/utils/typed-array.ts"),D=function(){function S(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var d=S.prototype;return d.resetInitSegment=function(p,h,a,o){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},d.resetTimeStamp=function(p){this.initPTS=p,this.resetContiguity()},d.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},d.canParse=function(p,h){return!1},d.appendFrame=function(p,h,a){},d.demux=function(p,h){this.cachedData&&(p=(0,B.appendUint8Array)(this.cachedData,p),this.cachedData=null);var a=L.getID3Data(p,0),o=a?a.length:0,n,v=this._audioTrack,l=this._id3Track,i=a?L.getTimeStamp(a):void 0,u=p.length;for((this.basePTS===null||this.frameIndex===0&&(0,C.isFiniteNumber)(i))&&(this.basePTS=x(i,h,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),a&&a.length>0&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:a,type:M.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});o<u;){if(this.canParse(p,o)){var g=this.appendFrame(v,p,o);g?(this.frameIndex++,this.lastPTS=g.sample.pts,o+=g.length,n=o):o=u}else L.canParse(p,o)?(a=L.getID3Data(p,o),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:a,type:M.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),o+=a.length,n=o):o++;if(o===u&&n!==u){var c=(0,A.sliceUint8)(p,n);this.cachedData?this.cachedData=(0,B.appendUint8Array)(this.cachedData,c):this.cachedData=c}}return{audioTrack:v,videoTrack:(0,P.dummyTrack)(),id3Track:l,textTrack:(0,P.dummyTrack)()}},d.demuxSampleAes=function(p,h,a){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},d.flush=function(p){var h=this.cachedData;return h&&(this.cachedData=null,this.demux(h,0)),{audioTrack:this._audioTrack,videoTrack:(0,P.dummyTrack)(),id3Track:this._id3Track,textTrack:(0,P.dummyTrack)()}},d.destroy=function(){},S}(),x=function(d,E,p){return(0,C.isFiniteNumber)(d)?d*90:E*9e4+(p||0)};let _=D},"./src/demux/chunk-cache.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>C});var C=function(){function M(){this.chunks=[],this.dataLength=0}var P=M.prototype;return P.push=function(A){this.chunks.push(A),this.dataLength+=A.length},P.flush=function(){var A=this.chunks,D=this.dataLength,x;if(A.length)A.length===1?x=A[0]:x=L(A,D);else return new Uint8Array(0);return this.reset(),x},P.reset=function(){this.chunks.length=0,this.dataLength=0},M}();function L(M,P){for(var B=new Uint8Array(P),A=0,D=0;D<M.length;D++){var x=M[D];B.set(x,A),A+=x.length}return B}},"./src/demux/dummy-demuxed-track.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{dummyTrack:()=>C});function C(L,M){return L===void 0&&(L=""),M===void 0&&(M=9e4),{type:L,id:-1,pid:-1,inputTimeScale:M,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>M});var C=T("./src/utils/logger.ts"),L=function(){function P(A){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=A,this.bytesAvailable=A.byteLength,this.word=0,this.bitsAvailable=0}var B=P.prototype;return B.loadWord=function(){var D=this.data,x=this.bytesAvailable,_=D.byteLength-x,S=new Uint8Array(4),d=Math.min(4,x);if(d===0)throw new Error("no bytes available");S.set(D.subarray(_,_+d)),this.word=new DataView(S.buffer).getUint32(0),this.bitsAvailable=d*8,this.bytesAvailable-=d},B.skipBits=function(D){var x;D=Math.min(D,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>D?(this.word<<=D,this.bitsAvailable-=D):(D-=this.bitsAvailable,x=D>>3,D-=x<<3,this.bytesAvailable-=x,this.loadWord(),this.word<<=D,this.bitsAvailable-=D)},B.readBits=function(D){var x=Math.min(this.bitsAvailable,D),_=this.word>>>32-x;if(D>32&&C.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=x,this.bitsAvailable>0)this.word<<=x;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return x=D-x,x>0&&this.bitsAvailable?_<<x|this.readBits(x):_},B.skipLZ=function(){var D;for(D=0;D<this.bitsAvailable;++D)if((this.word&2147483648>>>D)!==0)return this.word<<=D,this.bitsAvailable-=D,D;return this.loadWord(),D+this.skipLZ()},B.skipUEG=function(){this.skipBits(1+this.skipLZ())},B.skipEG=function(){this.skipBits(1+this.skipLZ())},B.readUEG=function(){var D=this.skipLZ();return this.readBits(D+1)-1},B.readEG=function(){var D=this.readUEG();return 1&D?1+D>>>1:-1*(D>>>1)},B.readBoolean=function(){return this.readBits(1)===1},B.readUByte=function(){return this.readBits(8)},B.readUShort=function(){return this.readBits(16)},B.readUInt=function(){return this.readBits(32)},B.skipScalingList=function(D){for(var x=8,_=8,S,d=0;d<D;d++)_!==0&&(S=this.readEG(),_=(x+S+256)%256),x=_===0?x:_},B.readSPS=function(){var D=0,x=0,_=0,S=0,d,E,p,h=this.readUByte.bind(this),a=this.readBits.bind(this),o=this.readUEG.bind(this),n=this.readBoolean.bind(this),v=this.skipBits.bind(this),l=this.skipEG.bind(this),i=this.skipUEG.bind(this),u=this.skipScalingList.bind(this);h();var g=h();if(a(5),v(3),h(),i(),g===100||g===110||g===122||g===244||g===44||g===83||g===86||g===118||g===128){var c=o();if(c===3&&v(1),i(),i(),v(1),n())for(E=c!==3?8:12,p=0;p<E;p++)n()&&(p<6?u(16):u(64))}i();var m=o();if(m===0)o();else if(m===1)for(v(1),l(),l(),d=o(),p=0;p<d;p++)l();i(),v(1);var e=o(),r=o(),t=a(1);t===0&&v(1),v(1),n()&&(D=o(),x=o(),_=o(),S=o());var s=[1,1];if(n()&&n()){var y=h();switch(y){case 1:s=[1,1];break;case 2:s=[12,11];break;case 3:s=[10,11];break;case 4:s=[16,11];break;case 5:s=[40,33];break;case 6:s=[24,11];break;case 7:s=[20,11];break;case 8:s=[32,11];break;case 9:s=[80,33];break;case 10:s=[18,11];break;case 11:s=[15,11];break;case 12:s=[64,33];break;case 13:s=[160,99];break;case 14:s=[4,3];break;case 15:s=[3,2];break;case 16:s=[2,1];break;case 255:{s=[h()<<8|h(),h()<<8|h()];break}}}return{width:Math.ceil((e+1)*16-D*2-x*2),height:(2-t)*(r+1)*16-(t?2:4)*(_+S),pixelRatio:s}},B.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},P}();let M=L},"./src/demux/id3.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{canParse:()=>B,decodeFrame:()=>S,getID3Data:()=>M,getID3Frames:()=>_,getTimeStamp:()=>A,isFooter:()=>L,isHeader:()=>C,isTimeStampFrame:()=>D,testables:()=>o,utf8ArrayToStr:()=>a});var C=function(i,u){return u+10<=i.length&&i[u]===73&&i[u+1]===68&&i[u+2]===51&&i[u+3]<255&&i[u+4]<255&&i[u+6]<128&&i[u+7]<128&&i[u+8]<128&&i[u+9]<128},L=function(i,u){return u+10<=i.length&&i[u]===51&&i[u+1]===68&&i[u+2]===73&&i[u+3]<255&&i[u+4]<255&&i[u+6]<128&&i[u+7]<128&&i[u+8]<128&&i[u+9]<128},M=function(i,u){for(var g=u,c=0;C(i,u);){c+=10;var m=P(i,u+6);c+=m,L(i,u+10)&&(c+=10),u+=c}if(c>0)return i.subarray(g,g+c)},P=function(i,u){var g=0;return g=(i[u]&127)<<21,g|=(i[u+1]&127)<<14,g|=(i[u+2]&127)<<7,g|=i[u+3]&127,g},B=function(i,u){return C(i,u)&&P(i,u+6)+10<=i.length-u},A=function(i){for(var u=_(i),g=0;g<u.length;g++){var c=u[g];if(D(c))return h(c)}},D=function(i){return i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp"},x=function(i){var u=String.fromCharCode(i[0],i[1],i[2],i[3]),g=P(i,4),c=10;return{type:u,size:g,data:i.subarray(c,c+g)}},_=function(i){for(var u=0,g=[];C(i,u);){var c=P(i,u+6);u+=10;for(var m=u+c;u+8<m;){var e=x(i.subarray(u)),r=S(e);r&&g.push(r),u+=e.size+10}L(i,u)&&(u+=10)}return g},S=function(i){return i.type==="PRIV"?d(i):i.type[0]==="W"?p(i):E(i)},d=function(i){if(!(i.size<2)){var u=a(i.data,!0),g=new Uint8Array(i.data.subarray(u.length+1));return{key:i.type,info:u,data:g.buffer}}},E=function(i){if(!(i.size<2)){if(i.type==="TXXX"){var u=1,g=a(i.data.subarray(u),!0);u+=g.length+1;var c=a(i.data.subarray(u));return{key:i.type,info:g,data:c}}var m=a(i.data.subarray(1));return{key:i.type,data:m}}},p=function(i){if(i.type==="WXXX"){if(i.size<2)return;var u=1,g=a(i.data.subarray(u),!0);u+=g.length+1;var c=a(i.data.subarray(u));return{key:i.type,info:g,data:c}}var m=a(i.data);return{key:i.type,data:m}},h=function(i){if(i.data.byteLength===8){var u=new Uint8Array(i.data),g=u[3]&1,c=(u[4]<<23)+(u[5]<<15)+(u[6]<<7)+u[7];return c/=45,g&&(c+=4772185884e-2),Math.round(c)}},a=function(i,u){u===void 0&&(u=!1);var g=v();if(g){var c=g.decode(i);if(u){var m=c.indexOf("\0");return m!==-1?c.substring(0,m):c}return c.replace(/\0/g,"")}for(var e=i.length,r,t,s,y="",f=0;f<e;){if(r=i[f++],r===0&&u)return y;if(r===0||r===3)continue;switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:y+=String.fromCharCode(r);break;case 12:case 13:t=i[f++],y+=String.fromCharCode((r&31)<<6|t&63);break;case 14:t=i[f++],s=i[f++],y+=String.fromCharCode((r&15)<<12|(t&63)<<6|(s&63)<<0);break;default:}}return y},o={decodeTextFrame:E},n;function v(){return!n&&typeof self.TextDecoder!="undefined"&&(n=new self.TextDecoder("utf-8")),n}},"./src/demux/mp3demuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>x});var C=T("./src/demux/base-audio-demuxer.ts"),L=T("./src/demux/id3.ts"),M=T("./src/utils/logger.ts"),P=T("./src/demux/mpegaudio.ts");function B(_,S){_.prototype=Object.create(S.prototype),_.prototype.constructor=_,A(_,S)}function A(_,S){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,p){return E.__proto__=p,E},A(_,S)}var D=function(_){B(S,_);function S(){return _.apply(this,arguments)||this}var d=S.prototype;return d.resetInitSegment=function(p,h,a,o){_.prototype.resetInitSegment.call(this,p,h,a,o),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:h,duration:o,inputTimeScale:9e4,dropped:0}},S.probe=function(p){if(!p)return!1;for(var h=L.getID3Data(p,0)||[],a=h.length,o=p.length;a<o;a++)if(P.probe(p,a))return M.logger.log("MPEG Audio sync word found !"),!0;return!1},d.canParse=function(p,h){return P.canParse(p,h)},d.appendFrame=function(p,h,a){if(this.basePTS!==null)return P.appendFrame(p,h,a,this.basePTS,this.frameIndex)},S}(C.default);let x=D},"./src/demux/mp4demuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>D});var C=T("./src/polyfills/number.ts"),L=T("./src/types/demuxer.ts"),M=T("./src/utils/mp4-tools.ts"),P=T("./src/demux/dummy-demuxed-track.ts"),B=/\/emsg[-/]ID3/i,A=function(){function x(S,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 _=x.prototype;return _.resetTimeStamp=function(){},_.resetInitSegment=function(d,E,p,h){var a=this.videoTrack=(0,P.dummyTrack)("video",1),o=this.audioTrack=(0,P.dummyTrack)("audio",1),n=this.txtTrack=(0,P.dummyTrack)("text",1);if(this.id3Track=(0,P.dummyTrack)("id3",1),this.timeOffset=0,!(!d||!d.byteLength)){var v=(0,M.parseInitSegment)(d);if(v.video){var l=v.video,i=l.id,u=l.timescale,g=l.codec;a.id=i,a.timescale=n.timescale=u,a.codec=g}if(v.audio){var c=v.audio,m=c.id,e=c.timescale,r=c.codec;o.id=m,o.timescale=e,o.codec=r}n.id=M.RemuxerTrackIdConfig.text,a.sampleDuration=0,a.duration=o.duration=h}},_.resetContiguity=function(){},x.probe=function(d){return d=d.length>16384?d.subarray(0,16384):d,(0,M.findBox)(d,["moof"]).length>0},_.demux=function(d,E){this.timeOffset=E;var p=d,h=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(p=(0,M.appendUint8Array)(this.remainderData,d));var o=(0,M.segmentValidRange)(p);this.remainderData=o.remainder,h.samples=o.valid||new Uint8Array}else h.samples=p;var n=this.extractID3Track(h,E);return a.samples=(0,M.parseSamples)(E,h),{videoTrack:h,audioTrack:this.audioTrack,id3Track:n,textTrack:this.txtTrack}},_.flush=function(){var d=this.timeOffset,E=this.videoTrack,p=this.txtTrack;E.samples=this.remainderData||new Uint8Array,this.remainderData=null;var h=this.extractID3Track(E,this.timeOffset);return p.samples=(0,M.parseSamples)(d,E),{videoTrack:E,audioTrack:(0,P.dummyTrack)(),id3Track:h,textTrack:(0,P.dummyTrack)()}},_.extractID3Track=function(d,E){var p=this.id3Track;if(d.samples.length){var h=(0,M.findBox)(d.samples,["emsg"]);h&&h.forEach(function(a){var o=(0,M.parseEmsg)(a);if(B.test(o.schemeIdUri)){var n=(0,C.isFiniteNumber)(o.presentationTime)?o.presentationTime/o.timeScale:E+o.presentationTimeDelta/o.timeScale,v=o.eventDuration===4294967295?Number.POSITIVE_INFINITY:o.eventDuration/o.timeScale;v<=.001&&(v=Number.POSITIVE_INFINITY);var l=o.payload;p.samples.push({data:l,len:l.byteLength,dts:n,pts:n,type:L.MetadataSchema.emsg,duration:v})}})}return p},_.demuxSampleAes=function(d,E,p){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},_.destroy=function(){},x}();let D=A},"./src/demux/mpegaudio.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{appendFrame:()=>A,canParse:()=>S,isHeader:()=>_,isHeaderPattern:()=>x,parseHeader:()=>D,probe:()=>d});var C=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],M=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],P=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],B=[0,1,1,4];function A(E,p,h,a,o){if(!(h+24>p.length)){var n=D(p,h);if(n&&h+n.frameLength<=p.length){var v=n.samplesPerFrame*9e4/n.sampleRate,l=a+o*v,i={unit:p.subarray(h,h+n.frameLength),pts:l,dts:l};return E.config=[],E.channelCount=n.channelCount,E.samplerate=n.sampleRate,E.samples.push(i),{sample:i,length:n.frameLength,missing:0}}}}function D(E,p){var h=E[p+1]>>3&3,a=E[p+1]>>1&3,o=E[p+2]>>4&15,n=E[p+2]>>2&3;if(h!==1&&o!==0&&o!==15&&n!==3){var v=E[p+2]>>1&1,l=E[p+3]>>6,i=h===3?3-a:a===3?3:4,u=L[i*14+o-1]*1e3,g=h===3?0:h===2?1:2,c=M[g*3+n],m=l===3?1:2,e=P[h][a],r=B[a],t=e*8*r,s=Math.floor(e*u/c+v)*r;if(C===null){var y=navigator.userAgent||"",f=y.match(/Chrome\/(\d+)/i);C=f?parseInt(f[1]):0}var b=!!C&&C<=87;return b&&a===2&&u>=224e3&&l===0&&(E[p+3]=E[p+3]|128),{sampleRate:c,channelCount:m,frameLength:s,samplesPerFrame:t}}}function x(E,p){return E[p]===255&&(E[p+1]&224)===224&&(E[p+1]&6)!==0}function _(E,p){return p+1<E.length&&x(E,p)}function S(E,p){var h=4;return x(E,p)&&h<=E.length-p}function d(E,p){if(p+1<E.length&&x(E,p)){var h=4,a=D(E,p),o=h;a!=null&&a.frameLength&&(o=a.frameLength);var n=p+o;return n===E.length||_(E,n)}return!1}},"./src/demux/sample-aes.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>P});var C=T("./src/crypt/decrypter.ts"),L=T("./src/utils/mp4-tools.ts"),M=function(){function B(D,x,_){this.keyData=void 0,this.decrypter=void 0,this.keyData=_,this.decrypter=new C.default(x,{removePKCS7Padding:!1})}var A=B.prototype;return A.decryptBuffer=function(x){return this.decrypter.decrypt(x,this.keyData.key.buffer,this.keyData.iv.buffer)},A.decryptAacSample=function(x,_,S){var d=this,E=x[_].unit;if(!(E.length<=16)){var p=E.subarray(16,E.length-E.length%16),h=p.buffer.slice(p.byteOffset,p.byteOffset+p.length);this.decryptBuffer(h).then(function(a){var o=new Uint8Array(a);E.set(o,16),d.decrypter.isSync()||d.decryptAacSamples(x,_+1,S)})}},A.decryptAacSamples=function(x,_,S){for(;;_++){if(_>=x.length){S();return}if(!(x[_].unit.length<32)&&(this.decryptAacSample(x,_,S),!this.decrypter.isSync()))return}},A.getAvcEncryptedData=function(x){for(var _=Math.floor((x.length-48)/160)*16+16,S=new Int8Array(_),d=0,E=32;E<x.length-16;E+=160,d+=16)S.set(x.subarray(E,E+16),d);return S},A.getAvcDecryptedUnit=function(x,_){for(var S=new Uint8Array(_),d=0,E=32;E<x.length-16;E+=160,d+=16)x.set(S.subarray(d,d+16),E);return x},A.decryptAvcSample=function(x,_,S,d,E){var p=this,h=(0,L.discardEPB)(E.data),a=this.getAvcEncryptedData(h);this.decryptBuffer(a.buffer).then(function(o){E.data=p.getAvcDecryptedUnit(h,o),p.decrypter.isSync()||p.decryptAvcSamples(x,_,S+1,d)})},A.decryptAvcSamples=function(x,_,S,d){if(x instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;_++,S=0){if(_>=x.length){d();return}for(var E=x[_].units;!(S>=E.length);S++){var p=E[S];if(!(p.data.length<=48||p.type!==1&&p.type!==5)&&(this.decryptAvcSample(x,_,S,d,p),!this.decrypter.isSync()))return}}},B}();let P=M},"./src/demux/transmuxer-interface.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>S});var C=T("./src/demux/webworkify-webpack.js"),L=T("./src/events.ts"),M=T("./src/demux/transmuxer.ts"),P=T("./src/utils/logger.ts"),B=T("./src/errors.ts"),A=T("./src/utils/mediasource-helper.ts"),D=T("./node_modules/eventemitter3/index.js"),x=T.n(D),_=(0,A.getMediaSource)()||{isTypeSupported:function(){return!1}},S=function(){function d(p,h,a,o){var n=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var v=p.config;this.hls=p,this.id=h,this.useWorker=!!v.enableWorker,this.onTransmuxComplete=a,this.onFlush=o;var l=function(m,e){e=e||{},e.frag=n.frag,e.id=n.id,n.hls.trigger(m,e)};this.observer=new D.EventEmitter,this.observer.on(L.Events.FRAG_DECRYPTED,l),this.observer.on(L.Events.ERROR,l);var i={mp4:_.isTypeSupported("video/mp4"),mpeg:_.isTypeSupported("audio/mpeg"),mp3:_.isTypeSupported('audio/mp4; codecs="mp3"')},u=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"){P.logger.log("demuxing in webworker");var g;try{g=this.worker=(0,C.default)("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),g.addEventListener("message",this.onwmsg),g.onerror=function(c){n.useWorker=!1,P.logger.warn("Exception in webworker, fallback to inline"),n.hls.trigger(L.Events.ERROR,{type:B.ErrorTypes.OTHER_ERROR,details:B.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},g.postMessage({cmd:"init",typeSupported:i,vendor:u,id:h,config:JSON.stringify(v)})}catch(c){P.logger.warn("Error in worker:",c),P.logger.error("Error while initializing DemuxerWorker, fallback to inline"),g&&self.URL.revokeObjectURL(g.objectURL),this.transmuxer=new M.default(this.observer,i,v,u,h),this.worker=null}}else this.transmuxer=new M.default(this.observer,i,v,u,h)}var E=d.prototype;return E.destroy=function(){var h=this.worker;if(h)h.removeEventListener("message",this.onwmsg),h.terminate(),this.worker=null,this.onwmsg=void 0;else{var a=this.transmuxer;a&&(a.destroy(),this.transmuxer=null)}var o=this.observer;o&&o.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},E.push=function(h,a,o,n,v,l,i,u,g,c){var m,e,r=this;g.transmuxing.start=self.performance.now();var t=this.transmuxer,s=this.worker,y=l?l.start:v.start,f=v.decryptdata,b=this.frag,R=!(b&&v.cc===b.cc),I=!(b&&g.level===b.level),k=b?g.sn-b.sn:-1,F=this.part?g.part-this.part.index:-1,K=k===0&&g.id>1&&g.id===(b==null?void 0:b.stats.chunkCount),H=!I&&(k===1||k===0&&(F===1||K&&F<=0)),j=self.performance.now();(I||k||v.stats.parsing.start===0)&&(v.stats.parsing.start=j),l&&(F||!H)&&(l.stats.parsing.start=j);var Y=!(b&&((m=v.initSegment)===null||m===void 0?void 0:m.url)===((e=b.initSegment)===null||e===void 0?void 0:e.url)),Q=new M.TransmuxState(R,H,u,I,y,Y);if(!H||R||Y){P.logger.log("[transmuxer-interface, "+v.type+"]: Starting new transmux session for sn: "+g.sn+" p: "+g.part+" level: "+g.level+" id: "+g.id+`
15
+ discontinuity: `+R+`
16
+ trackSwitch: `+I+`
17
+ contiguous: `+H+`
18
+ accurateTimeOffset: `+u+`
19
+ timeOffset: `+y+`
20
+ initSegmentChange: `+Y);var q=new M.TransmuxConfig(o,n,a,i,c);this.configureTransmuxer(q)}if(this.frag=v,this.part=l,s)s.postMessage({cmd:"demux",data:h,decryptdata:f,chunkMeta:g,state:Q},h instanceof ArrayBuffer?[h]:[]);else if(t){var ne=t.push(h,f,g,Q);(0,M.isPromise)(ne)?(t.async=!0,ne.then(function(te){r.handleTransmuxComplete(te)}).catch(function(te){r.transmuxerError(te,g,"transmuxer-interface push error")})):(t.async=!1,this.handleTransmuxComplete(ne))}},E.flush=function(h){var a=this;h.transmuxing.start=self.performance.now();var o=this.transmuxer,n=this.worker;if(n)n.postMessage({cmd:"flush",chunkMeta:h});else if(o){var v=o.flush(h),l=(0,M.isPromise)(v);l||o.async?((0,M.isPromise)(v)||(v=Promise.resolve(v)),v.then(function(i){a.handleFlushResult(i,h)}).catch(function(i){a.transmuxerError(i,h,"transmuxer-interface flush error")})):this.handleFlushResult(v,h)}},E.transmuxerError=function(h,a,o){!this.hls||this.hls.trigger(L.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:a,fatal:!1,error:h,err:h,reason:o})},E.handleFlushResult=function(h,a){var o=this;h.forEach(function(n){o.handleTransmuxComplete(n)}),this.onFlush(a)},E.onWorkerMessage=function(h){var a=h.data,o=this.hls;switch(a.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(a.data);break}case"flush":{this.onFlush(a.data);break}case"workerLog":P.logger[a.data.logType]&&P.logger[a.data.logType](a.data.message);break;default:{a.data=a.data||{},a.data.frag=this.frag,a.data.id=this.id,o.trigger(a.event,a.data);break}}},E.configureTransmuxer=function(h){var a=this.worker,o=this.transmuxer;a?a.postMessage({cmd:"configure",config:h}):o&&o.configure(h)},E.handleTransmuxComplete=function(h){h.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(h)},d}()},"./src/demux/transmuxer-worker.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>D});var C=T("./src/demux/transmuxer.ts"),L=T("./src/events.ts"),M=T("./src/utils/logger.ts"),P=T("./node_modules/eventemitter3/index.js"),B=T.n(P),A=T("./src/errors.ts");function D(E){var p=new P.EventEmitter,h=function(n,v){E.postMessage({event:n,data:v})};p.on(L.Events.FRAG_DECRYPTED,h),p.on(L.Events.ERROR,h);var a=function(){var n=function(i){var u=function(c){h("workerLog",{logType:i,message:c})};M.logger[i]=u};for(var v in M.logger)n(v)};E.addEventListener("message",function(o){var n=o.data;switch(n.cmd){case"init":{var v=JSON.parse(n.config);E.transmuxer=new C.default(p,n.typeSupported,v,n.vendor,n.id),(0,M.enableLogs)(v.debug,n.id),a(),h("init",null);break}case"configure":{E.transmuxer.configure(n.config);break}case"demux":{var l=E.transmuxer.push(n.data,n.decryptdata,n.chunkMeta,n.state);(0,C.isPromise)(l)?(E.transmuxer.async=!0,l.then(function(c){x(E,c)}).catch(function(c){h(L.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:c,err:c,reason:"transmuxer-worker push error"})})):(E.transmuxer.async=!1,x(E,l));break}case"flush":{var i=n.chunkMeta,u=E.transmuxer.flush(i),g=(0,C.isPromise)(u);g||E.transmuxer.async?((0,C.isPromise)(u)||(u=Promise.resolve(u)),u.then(function(c){S(E,c,i)}).catch(function(c){h(L.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:c,err:c,reason:"transmuxer-worker flush error"})})):S(E,u,i);break}default:break}})}function x(E,p){if(d(p.remuxResult))return!1;var h=[],a=p.remuxResult,o=a.audio,n=a.video;return o&&_(h,o),n&&_(h,n),E.postMessage({event:"transmuxComplete",data:p},h),!0}function _(E,p){p.data1&&E.push(p.data1.buffer),p.data2&&E.push(p.data2.buffer)}function S(E,p,h){var a=p.reduce(function(o,n){return x(E,n)||o},!1);a||E.postMessage({event:"transmuxComplete",data:p[0]}),E.postMessage({event:"flush",data:h})}function d(E){return!E.audio&&!E.video&&!E.text&&!E.id3&&!E.initSegment}},"./src/demux/transmuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{TransmuxConfig:()=>n,TransmuxState:()=>v,default:()=>p,isPromise:()=>o});var C=T("./src/events.ts"),L=T("./src/errors.ts"),M=T("./src/crypt/decrypter.ts"),P=T("./src/demux/aacdemuxer.ts"),B=T("./src/demux/mp4demuxer.ts"),A=T("./src/demux/tsdemuxer.ts"),D=T("./src/demux/mp3demuxer.ts"),x=T("./src/remux/mp4-remuxer.ts"),_=T("./src/remux/passthrough-remuxer.ts"),S=T("./src/utils/logger.ts"),d;try{d=self.performance.now.bind(self.performance)}catch{S.logger.debug("Unable to use Performance API on this environment"),d=self.Date.now}var E=[{demux:B.default,remux:_.default},{demux:A.default,remux:x.default},{demux:P.default,remux:x.default},{demux:D.default,remux:x.default}],p=function(){function l(u,g,c,m,e){this.async=!1,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=u,this.typeSupported=g,this.config=c,this.vendor=m,this.id=e}var i=l.prototype;return i.configure=function(g){this.transmuxConfig=g,this.decrypter&&this.decrypter.reset()},i.push=function(g,c,m,e){var r=this,t=m.transmuxing;t.executeStart=d();var s=new Uint8Array(g),y=this.currentTransmuxState,f=this.transmuxConfig;e&&(this.currentTransmuxState=e);var b=e||y,R=b.contiguous,I=b.discontinuity,k=b.trackSwitch,F=b.accurateTimeOffset,K=b.timeOffset,H=b.initSegmentChange,j=f.audioCodec,Y=f.videoCodec,Q=f.defaultInitPts,q=f.duration,ne=f.initSegmentData,te=h(s,c);if(te&&te.method==="AES-128"){var ae=this.getDecrypter();if(ae.isSync()){var ue=ae.softwareDecrypt(s,te.key.buffer,te.iv.buffer);if(!ue)return t.executeEnd=d(),a(m);s=new Uint8Array(ue)}else return this.decryptionPromise=ae.webCryptoDecrypt(s,te.key.buffer,te.iv.buffer).then(function(de){var xe=r.push(de,null,m);return r.decryptionPromise=null,xe}),this.decryptionPromise}var ce=this.needsProbing(I,k);ce&&this.configureTransmuxer(s),(I||k||H||ce)&&this.resetInitSegment(ne,j,Y,q,c),(I||H||ce)&&this.resetInitialTimestamp(Q),R||this.resetContiguity();var le=this.transmux(s,te,K,F,m),fe=this.currentTransmuxState;return fe.contiguous=!0,fe.discontinuity=!1,fe.trackSwitch=!1,t.executeEnd=d(),le},i.flush=function(g){var c=this,m=g.transmuxing;m.executeStart=d();var e=this.decrypter,r=this.currentTransmuxState,t=this.decryptionPromise;if(t)return t.then(function(){return c.flush(g)});var s=[],y=r.timeOffset;if(e){var f=e.flush();f&&s.push(this.push(f,null,g))}var b=this.demuxer,R=this.remuxer;if(!b||!R)return this.observer.emit(C.Events.ERROR,C.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),m.executeEnd=d(),[a(g)];var I=b.flush(y);return o(I)?I.then(function(k){return c.flushRemux(s,k,g),s}):(this.flushRemux(s,I,g),s)},i.flushRemux=function(g,c,m){var e=c.audioTrack,r=c.videoTrack,t=c.id3Track,s=c.textTrack,y=this.currentTransmuxState,f=y.accurateTimeOffset,b=y.timeOffset;S.logger.log("[transmuxer.ts]: Flushed fragment "+m.sn+(m.part>-1?" p: "+m.part:"")+" of level "+m.level);var R=this.remuxer.remux(e,r,t,s,b,f,!0,this.id);g.push({remuxResult:R,chunkMeta:m}),m.transmuxing.executeEnd=d()},i.resetInitialTimestamp=function(g){var c=this.demuxer,m=this.remuxer;!c||!m||(c.resetTimeStamp(g),m.resetTimeStamp(g))},i.resetContiguity=function(){var g=this.demuxer,c=this.remuxer;!g||!c||(g.resetContiguity(),c.resetNextTimestamp())},i.resetInitSegment=function(g,c,m,e,r){var t=this.demuxer,s=this.remuxer;!t||!s||(t.resetInitSegment(g,c,m,e),s.resetInitSegment(g,c,m,r))},i.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},i.transmux=function(g,c,m,e,r){var t;return c&&c.method==="SAMPLE-AES"?t=this.transmuxSampleAes(g,c,m,e,r):t=this.transmuxUnencrypted(g,m,e,r),t},i.transmuxUnencrypted=function(g,c,m,e){var r=this.demuxer.demux(g,c,!1,!this.config.progressive),t=r.audioTrack,s=r.videoTrack,y=r.id3Track,f=r.textTrack,b=this.remuxer.remux(t,s,y,f,c,m,!1,this.id);return{remuxResult:b,chunkMeta:e}},i.transmuxSampleAes=function(g,c,m,e,r){var t=this;return this.demuxer.demuxSampleAes(g,c,m).then(function(s){var y=t.remuxer.remux(s.audioTrack,s.videoTrack,s.id3Track,s.textTrack,m,e,!1,t.id);return{remuxResult:y,chunkMeta:r}})},i.configureTransmuxer=function(g){for(var c=this.config,m=this.observer,e=this.typeSupported,r=this.vendor,t,s=0,y=E.length;s<y;s++)if(E[s].demux.probe(g)){t=E[s];break}t||(S.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),t={demux:B.default,remux:_.default});var f=this.demuxer,b=this.remuxer,R=t.remux,I=t.demux;(!b||!(b instanceof R))&&(this.remuxer=new R(m,c,e,r)),(!f||!(f instanceof I))&&(this.demuxer=new I(m,c,e),this.probe=I.probe)},i.needsProbing=function(g,c){return!this.demuxer||!this.remuxer||g||c},i.getDecrypter=function(){var g=this.decrypter;return g||(g=this.decrypter=new M.default(this.config)),g},l}();function h(l,i){var u=null;return l.byteLength>0&&i!=null&&i.key!=null&&i.iv!==null&&i.method!=null&&(u=i),u}var a=function(i){return{remuxResult:{},chunkMeta:i}};function o(l){return"then"in l&&l.then instanceof Function}var n=function(i,u,g,c,m){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=i,this.videoCodec=u,this.initSegmentData=g,this.duration=c,this.defaultInitPts=m},v=function(i,u,g,c,m,e){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=i,this.contiguous=u,this.accurateTimeOffset=g,this.trackSwitch=c,this.timeOffset=m,this.initSegmentChange=e}},"./src/demux/tsdemuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>v});var C=T("./src/demux/adts.ts"),L=T("./src/demux/mpegaudio.ts"),M=T("./src/demux/exp-golomb.ts"),P=T("./src/demux/sample-aes.ts"),B=T("./src/events.ts"),A=T("./src/utils/mp4-tools.ts"),D=T("./src/utils/logger.ts"),x=T("./src/errors.ts"),_=T("./src/types/demuxer.ts");function S(){return S=Object.assign?Object.assign.bind():function(l){for(var i=1;i<arguments.length;i++){var u=arguments[i];for(var g in u)Object.prototype.hasOwnProperty.call(u,g)&&(l[g]=u[g])}return l},S.apply(this,arguments)}var d=188,E=function(){function l(u,g,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=u,this.config=g,this.typeSupported=c}l.probe=function(g){var c=l.syncOffset(g);return c>0&&D.logger.warn("MPEG2-TS detected but first sync word found @ offset "+c),c!==-1},l.syncOffset=function(g){for(var c=Math.min(d*5,g.length-d*2)+1,m=0;m<c;){if(g[m]===71&&g[m+d]===71)return m;m++}return-1},l.createTrack=function(g,c){return{container:g==="video"||g==="audio"?"video/mp2t":void 0,type:g,id:A.RemuxerTrackIdConfig[g],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:g==="audio"?c:void 0}};var i=l.prototype;return i.resetInitSegment=function(g,c,m,e){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=l.createTrack("video"),this._audioTrack=l.createTrack("audio",e),this._id3Track=l.createTrack("id3"),this._txtTrack=l.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=c,this.videoCodec=m,this._duration=e},i.resetTimeStamp=function(){},i.resetContiguity=function(){var g=this._audioTrack,c=this._avcTrack,m=this._id3Track;g&&(g.pesData=null),c&&(c.pesData=null),m&&(m.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},i.demux=function(g,c,m,e){m===void 0&&(m=!1),e===void 0&&(e=!1),m||(this.sampleAes=null);var r,t=this._avcTrack,s=this._audioTrack,y=this._id3Track,f=this._txtTrack,b=t.pid,R=t.pesData,I=s.pid,k=y.pid,F=s.pesData,K=y.pesData,H=null,j=this.pmtParsed,Y=this._pmtId,Q=g.length;if(this.remainderData&&(g=(0,A.appendUint8Array)(this.remainderData,g),Q=g.length,this.remainderData=null),Q<d&&!e)return this.remainderData=g,{audioTrack:s,videoTrack:t,id3Track:y,textTrack:f};var q=Math.max(0,l.syncOffset(g));Q-=(Q-q)%d,Q<g.byteLength&&!e&&(this.remainderData=new Uint8Array(g.buffer,Q,g.buffer.byteLength-Q));for(var ne=0,te=q;te<Q;te+=d)if(g[te]===71){var ae=!!(g[te+1]&64),ue=((g[te+1]&31)<<8)+g[te+2],ce=(g[te+3]&48)>>4,le=void 0;if(ce>1){if(le=te+5+g[te+4],le===te+d)continue}else le=te+4;switch(ue){case b:ae&&(R&&(r=o(R))&&this.parseAVCPES(t,f,r,!1),R={data:[],size:0}),R&&(R.data.push(g.subarray(le,te+d)),R.size+=te+d-le);break;case I:if(ae){if(F&&(r=o(F)))switch(s.segmentCodec){case"aac":this.parseAACPES(s,r);break;case"mp3":this.parseMPEGPES(s,r);break}F={data:[],size:0}}F&&(F.data.push(g.subarray(le,te+d)),F.size+=te+d-le);break;case k:ae&&(K&&(r=o(K))&&this.parseID3PES(y,r),K={data:[],size:0}),K&&(K.data.push(g.subarray(le,te+d)),K.size+=te+d-le);break;case 0:ae&&(le+=g[le]+1),Y=this._pmtId=h(g,le);break;case Y:{ae&&(le+=g[le]+1);var fe=a(g,le,this.typeSupported,m);b=fe.avc,b>0&&(t.pid=b),I=fe.audio,I>0&&(s.pid=I,s.segmentCodec=fe.segmentCodec),k=fe.id3,k>0&&(y.pid=k),H!==null&&!j&&(D.logger.log("unknown PID '"+H+"' in TS found"),H=null,te=q-188),j=this.pmtParsed=!0;break}case 17:case 8191:break;default:H=ue;break}}else ne++;ne>0&&this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:x.ErrorTypes.MEDIA_ERROR,details:x.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+ne+" TS packet/s that do not start with 0x47"}),t.pesData=R,s.pesData=F,y.pesData=K;var de={audioTrack:s,videoTrack:t,id3Track:y,textTrack:f};return e&&this.extractRemainingSamples(de),de},i.flush=function(){var g=this.remainderData;this.remainderData=null;var c;return g?c=this.demux(g,-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(g){var c=g.audioTrack,m=g.videoTrack,e=g.id3Track,r=g.textTrack,t=m.pesData,s=c.pesData,y=e.pesData,f;if(t&&(f=o(t))?(this.parseAVCPES(m,r,f,!0),m.pesData=null):m.pesData=t,s&&(f=o(s))){switch(c.segmentCodec){case"aac":this.parseAACPES(c,f);break;case"mp3":this.parseMPEGPES(c,f);break}c.pesData=null}else s!=null&&s.size&&D.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=s;y&&(f=o(y))?(this.parseID3PES(e,f),e.pesData=null):e.pesData=y},i.demuxSampleAes=function(g,c,m){var e=this.demux(g,m,!0,!this.config.progressive),r=this.sampleAes=new P.default(this.observer,this.config,c);return this.decrypt(e,r)},i.decrypt=function(g,c){return new Promise(function(m){var e=g.audioTrack,r=g.videoTrack;e.samples&&e.segmentCodec==="aac"?c.decryptAacSamples(e.samples,0,function(){r.samples?c.decryptAvcSamples(r.samples,0,0,function(){m(g)}):m(g)}):r.samples&&c.decryptAvcSamples(r.samples,0,0,function(){m(g)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(g,c,m,e){var r=this,t=this.parseAVCNALu(g,m.data),s=!1,y=this.avcSample,f,b=!1;m.data=null,y&&t.length&&!g.audFound&&(n(y,g),y=this.avcSample=p(!1,m.pts,m.dts,"")),t.forEach(function(R){switch(R.type){case 1:{f=!0,y||(y=r.avcSample=p(!0,m.pts,m.dts,"")),s&&(y.debug+="NDR "),y.frame=!0;var I=R.data;if(b&&I.length>4){var k=new M.default(I).readSliceType();(k===2||k===4||k===7||k===9)&&(y.key=!0)}break}case 5:f=!0,y||(y=r.avcSample=p(!0,m.pts,m.dts,"")),s&&(y.debug+="IDR "),y.key=!0,y.frame=!0;break;case 6:{f=!0,s&&y&&(y.debug+="SEI "),(0,A.parseSEIMessageFromNALu)(R.data,1,m.pts,c.samples);break}case 7:if(f=!0,b=!0,s&&y&&(y.debug+="SPS "),!g.sps){var F=new M.default(R.data),K=F.readSPS();g.width=K.width,g.height=K.height,g.pixelRatio=K.pixelRatio,g.sps=[R.data],g.duration=r._duration;for(var H=R.data.subarray(1,4),j="avc1.",Y=0;Y<3;Y++){var Q=H[Y].toString(16);Q.length<2&&(Q="0"+Q),j+=Q}g.codec=j}break;case 8:f=!0,s&&y&&(y.debug+="PPS "),g.pps||(g.pps=[R.data]);break;case 9:f=!1,g.audFound=!0,y&&n(y,g),y=r.avcSample=p(!1,m.pts,m.dts,s?"AUD ":"");break;case 12:f=!0;break;default:f=!1,y&&(y.debug+="unknown NAL "+R.type+" ");break}if(y&&f){var q=y.units;q.push(R)}}),e&&y&&(n(y,g),this.avcSample=null)},i.getLastNalUnit=function(g){var c,m=this.avcSample,e;if((!m||m.units.length===0)&&(m=g[g.length-1]),(c=m)!==null&&c!==void 0&&c.units){var r=m.units;e=r[r.length-1]}return e},i.parseAVCNALu=function(g,c){var m=c.byteLength,e=g.naluState||0,r=e,t=[],s=0,y,f,b,R=-1,I=0;for(e===-1&&(R=0,I=c[0]&31,e=0,s=1);s<m;){if(y=c[s++],!e){e=y?0:1;continue}if(e===1){e=y?0:2;continue}if(!y)e=3;else if(y===1){if(R>=0){var k={data:c.subarray(R,s-e-1),type:I};t.push(k)}else{var F=this.getLastNalUnit(g.samples);if(F&&(r&&s<=4-r&&F.state&&(F.data=F.data.subarray(0,F.data.byteLength-r)),f=s-e-1,f>0)){var K=new Uint8Array(F.data.byteLength+f);K.set(F.data,0),K.set(c.subarray(0,f),F.data.byteLength),F.data=K,F.state=0}}s<m?(b=c[s]&31,R=s,I=b,e=0):e=-1}else e=0}if(R>=0&&e>=0){var H={data:c.subarray(R,m),type:I,state:e};t.push(H)}if(t.length===0){var j=this.getLastNalUnit(g.samples);if(j){var Y=new Uint8Array(j.data.byteLength+c.byteLength);Y.set(j.data,0),Y.set(c,j.data.byteLength),j.data=Y}}return g.naluState=e,t},i.parseAACPES=function(g,c){var m=0,e=this.aacOverFlow,r=c.data;if(e){this.aacOverFlow=null;var t=e.missing,s=e.sample.unit.byteLength;if(t===-1){var y=new Uint8Array(s+r.byteLength);y.set(e.sample.unit,0),y.set(r,s),r=y}else{var f=s-t;e.sample.unit.set(r.subarray(0,t),f),g.samples.push(e.sample),m=e.missing}}var b,R;for(b=m,R=r.length;b<R-1&&!C.isHeader(r,b);b++);if(b!==m){var I,k;if(b<R-1?(I="AAC PES did not start with ADTS header,offset:"+b,k=!1):(I="no ADTS header found in AAC PES",k=!0),D.logger.warn("parsing error:"+I),this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:x.ErrorTypes.MEDIA_ERROR,details:x.ErrorDetails.FRAG_PARSING_ERROR,fatal:k,reason:I}),k)return}C.initTrackConfig(g,this.observer,r,b,this.audioCodec);var F;if(c.pts!==void 0)F=c.pts;else if(e){var K=C.getFrameDuration(g.samplerate);F=e.sample.pts+K}else{D.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var H=0,j;b<R;)if(j=C.appendFrame(g,r,b,F,H),b+=j.length,j.missing){this.aacOverFlow=j;break}else for(H++;b<R-1&&!C.isHeader(r,b);b++);},i.parseMPEGPES=function(g,c){var m=c.data,e=m.length,r=0,t=0,s=c.pts;if(s===void 0){D.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;t<e;)if(L.isHeader(m,t)){var y=L.appendFrame(g,m,t,s,r);if(y)t+=y.length,r++;else break}else t++},i.parseID3PES=function(g,c){if(c.pts===void 0){D.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var m=S({},c,{type:this._avcTrack?_.MetadataSchema.emsg:_.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});g.samples.push(m)},l}();function p(l,i,u,g){return{key:l,frame:!1,pts:i,dts:u,units:[],debug:g,length:0}}function h(l,i){return(l[i+10]&31)<<8|l[i+11]}function a(l,i,u,g){var c={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},m=(l[i+1]&15)<<8|l[i+2],e=i+3+m-4,r=(l[i+10]&15)<<8|l[i+11];for(i+=12+r;i<e;){var t=(l[i+1]&31)<<8|l[i+2];switch(l[i]){case 207:if(!g){D.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:c.audio===-1&&(c.audio=t);break;case 21:c.id3===-1&&(c.id3=t);break;case 219:if(!g){D.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:c.avc===-1&&(c.avc=t);break;case 3:case 4:u.mpeg!==!0&&u.mp3!==!0?D.logger.log("MPEG audio found, not supported in this browser"):c.audio===-1&&(c.audio=t,c.segmentCodec="mp3");break;case 36:D.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((l[i+3]&15)<<8|l[i+4])+5}return c}function o(l){var i=0,u,g,c,m,e,r=l.data;if(!l||l.size===0)return null;for(;r[0].length<19&&r.length>1;){var t=new Uint8Array(r[0].length+r[1].length);t.set(r[0]),t.set(r[1],r[0].length),r[0]=t,r.splice(1,1)}u=r[0];var s=(u[0]<<16)+(u[1]<<8)+u[2];if(s===1){if(g=(u[4]<<8)+u[5],g&&g>l.size-6)return null;var y=u[7];y&192&&(m=(u[9]&14)*536870912+(u[10]&255)*4194304+(u[11]&254)*16384+(u[12]&255)*128+(u[13]&254)/2,y&64?(e=(u[14]&14)*536870912+(u[15]&255)*4194304+(u[16]&254)*16384+(u[17]&255)*128+(u[18]&254)/2,m-e>54e5&&(D.logger.warn(Math.round((m-e)/9e4)+"s delta between PTS and DTS, align them"),m=e)):e=m),c=u[8];var f=c+9;if(l.size<=f)return null;l.size-=f;for(var b=new Uint8Array(l.size),R=0,I=r.length;R<I;R++){u=r[R];var k=u.byteLength;if(f)if(f>k){f-=k;continue}else u=u.subarray(f),k-=f,f=0;b.set(u,i),i+=k}return g&&(g-=c+3),{data:b,pts:m,dts:e,len:g}}return null}function n(l,i){if(l.units.length&&l.frame){if(l.pts===void 0){var u=i.samples,g=u.length;if(g){var c=u[g-1];l.pts=c.pts,l.dts=c.dts}else{i.dropped++;return}}i.samples.push(l)}l.debug.length&&D.logger.log(l.pts+"/"+l.dts+":"+l.debug)}let v=E},"./src/demux/webworkify-webpack.js":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>d});var C=function(){var p=ENTRY_MODULE,h={},a=function n(v){var l=h[v];if(l!==void 0)return l.exports;var i=h[v]={exports:{}};return p[v].call(i.exports,i,i.exports,n),i.exports};a.m=p,function(){a.n=function(n){var v=n&&n.__esModule?function(){return n.default}:function(){return n};return a.d(v,{a:v}),v}}(),function(){a.d=function(n,v){for(var l in v)a.o(v,l)&&!a.o(n,l)&&Object.defineProperty(n,l,{enumerable:!0,get:v[l]})}}(),function(){a.o=function(n,v){return Object.prototype.hasOwnProperty.call(n,v)}}(),function(){a.r=function(n){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}}();var o=a(ENTRY_MODULE);return o.default||o},L=C.toString().split("ENTRY_MODULE"),M="[\\.|\\-|\\+|\\w|/|@]+",P="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+M+").*?\\)";function B(E){return(E+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function A(E){return!isNaN(1*E)}function D(E,p,h){var a={};a[h]=[];var o=p.toString().replace(/^"[^"]+"/,"function"),n=o.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||o.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!n)return a;for(var v=n[1],l=new RegExp("(\\\\n|\\W)"+B(v)+P,"g"),i;i=l.exec(o);)i[3]!=="dll-reference"&&a[h].push(i[3]);for(l=new RegExp("\\("+B(v)+'\\("(dll-reference\\s('+M+'))"\\)\\)'+P,"g");i=l.exec(o);)E[i[2]]||(a[h].push(i[1]),E[i[2]]=T(i[1]).m),a[i[2]]=a[i[2]]||[],a[i[2]].push(i[4]);for(var u=Object.keys(a),g=0;g<u.length;g++)for(var c=0;c<a[u[g]].length;c++)A(a[u[g]][c])&&(a[u[g]][c]=1*a[u[g]][c]);return a}function x(E){var p=Object.keys(E);return p.reduce(function(h,a){return h||E[a].length>0},!1)}function _(E,p){for(var h={main:[p]},a={main:[]},o={main:{}};x(h);)for(var n=Object.keys(h),v=0;v<n.length;v++){var l=n[v],i=h[l],u=i.pop();if(o[l]=o[l]||{},!(o[l][u]||!E[l][u])){o[l][u]=!0,a[l]=a[l]||[],a[l].push(u);for(var g=D(E,E[l][u],l),c=Object.keys(g),m=0;m<c.length;m++)h[c[m]]=h[c[m]]||[],h[c[m]]=h[c[m]].concat(g[c[m]])}}return a}function S(E,p,h,a){var o=E[a].map(function(n){return'"'+n+'": '+p[a][n].toString().replace(/^"[^"]+"/,"function")}).join(",");return L[0]+"{"+o+"}"+L[1]+'"'+h+'"'+L[2]}function d(E,p){p=p||{};var h={main:T.m},a=p.all?{main:Object.keys(h.main)}:_(h,E),o="";Object.keys(a).filter(function(u){return u!=="main"}).forEach(function(u){for(var g=0;a[u][g];)g++;a[u].push(g),h[u][g]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",o=o+("var "+u+" = ("+S(a,h,g,modules)+`)();
21
+ `)}),o=o+("new (("+S(a,h,E,"main")+")())(self);");var n=new window.Blob([o],{type:"text/javascript"}),v=window.URL||window.webkitURL||window.mozURL||window.msURL,l=v.createObjectURL(n),i=new window.Worker(l);return i.objectURL=l,i}},"./src/errors.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{ErrorDetails:()=>L,ErrorTypes:()=>C});var C;(function(M){M.NETWORK_ERROR="networkError",M.MEDIA_ERROR="mediaError",M.KEY_SYSTEM_ERROR="keySystemError",M.MUX_ERROR="muxError",M.OTHER_ERROR="otherError"})(C||(C={}));var L;(function(M){M.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",M.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",M.KEY_SYSTEM_NO_SESSION="keySystemNoSession",M.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",M.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",M.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",M.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",M.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",M.MANIFEST_LOAD_ERROR="manifestLoadError",M.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",M.MANIFEST_PARSING_ERROR="manifestParsingError",M.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",M.LEVEL_EMPTY_ERROR="levelEmptyError",M.LEVEL_LOAD_ERROR="levelLoadError",M.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",M.LEVEL_SWITCH_ERROR="levelSwitchError",M.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",M.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",M.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",M.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",M.FRAG_LOAD_ERROR="fragLoadError",M.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",M.FRAG_DECRYPT_ERROR="fragDecryptError",M.FRAG_PARSING_ERROR="fragParsingError",M.REMUX_ALLOC_ERROR="remuxAllocError",M.KEY_LOAD_ERROR="keyLoadError",M.KEY_LOAD_TIMEOUT="keyLoadTimeOut",M.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",M.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",M.BUFFER_APPEND_ERROR="bufferAppendError",M.BUFFER_APPENDING_ERROR="bufferAppendingError",M.BUFFER_STALLED_ERROR="bufferStalledError",M.BUFFER_FULL_ERROR="bufferFullError",M.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",M.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",M.INTERNAL_EXCEPTION="internalException",M.INTERNAL_ABORTED="aborted",M.UNKNOWN="unknown"})(L||(L={}))},"./src/events.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{Events:()=>C});var C;(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"})(C||(C={}))},"./src/hls.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>g});var C=T("./node_modules/url-toolkit/src/url-toolkit.js"),L=T.n(C),M=T("./src/loader/playlist-loader.ts"),P=T("./src/controller/id3-track-controller.ts"),B=T("./src/controller/latency-controller.ts"),A=T("./src/controller/level-controller.ts"),D=T("./src/controller/fragment-tracker.ts"),x=T("./src/loader/key-loader.ts"),_=T("./src/controller/stream-controller.ts"),S=T("./src/is-supported.ts"),d=T("./src/utils/logger.ts"),E=T("./src/config.ts"),p=T("./node_modules/eventemitter3/index.js"),h=T.n(p),a=T("./src/events.ts"),o=T("./src/errors.ts"),n=T("./src/types/level.ts");function v(c,m){for(var e=0;e<m.length;e++){var r=m[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(c,i(r.key),r)}}function l(c,m,e){return m&&v(c.prototype,m),e&&v(c,e),Object.defineProperty(c,"prototype",{writable:!1}),c}function i(c){var m=u(c,"string");return typeof m=="symbol"?m:String(m)}function u(c,m){if(typeof c!="object"||c===null)return c;var e=c[Symbol.toPrimitive];if(e!==void 0){var r=e.call(c,m||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(m==="string"?String:Number)(c)}var g=function(){c.isSupported=function(){return(0,S.isSupported)()};function c(e){e===void 0&&(e={}),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._maxHdcpLevel=null,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 r=this.config=(0,E.mergeConfig)(c.DefaultConfig,e);this.userConfig=e,(0,d.enableLogs)(r.debug,"Hls instance"),this._autoLevelCapping=-1,r.progressive&&(0,E.enableStreamingMode)(r);var t=r.abrController,s=r.bufferController,y=r.capLevelController,f=r.fpsController,b=this.abrController=new t(this),R=this.bufferController=new s(this),I=this.capLevelController=new y(this),k=new f(this),F=new M.default(this),K=new P.default(this),H=this.levelController=new A.default(this),j=new D.FragmentTracker(this),Y=new x.default(this.config),Q=this.streamController=new _.default(this,j,Y);I.setStreamController(Q),k.setStreamController(Q);var q=[F,H,Q];this.networkControllers=q;var ne=[b,R,I,k,K,j];this.audioTrackController=this.createController(r.audioTrackController,q);var te=r.audioStreamController;te&&q.push(new te(this,j,Y)),this.subtitleTrackController=this.createController(r.subtitleTrackController,q);var ae=r.subtitleStreamController;ae&&q.push(new ae(this,j,Y)),this.createController(r.timelineController,ne),Y.emeController=this.emeController=this.createController(r.emeController,ne),this.cmcdController=this.createController(r.cmcdController,ne),this.latencyController=this.createController(B.default,ne),this.coreComponents=ne}var m=c.prototype;return m.createController=function(r,t){if(r){var s=new r(this);return t&&t.push(s),s}return null},m.on=function(r,t,s){s===void 0&&(s=this),this._emitter.on(r,t,s)},m.once=function(r,t,s){s===void 0&&(s=this),this._emitter.once(r,t,s)},m.removeAllListeners=function(r){this._emitter.removeAllListeners(r)},m.off=function(r,t,s,y){s===void 0&&(s=this),this._emitter.off(r,t,s,y)},m.listeners=function(r){return this._emitter.listeners(r)},m.emit=function(r,t,s){return this._emitter.emit(r,t,s)},m.trigger=function(r,t){if(this.config.debug)return this.emit(r,r,t);try{return this.emit(r,r,t)}catch(s){d.logger.error("An internal error happened while handling event "+r+'. Error message: "'+s.message+'". Here is a stacktrace:',s),this.trigger(a.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:r,error:s})}return!1},m.listenerCount=function(r){return this._emitter.listenerCount(r)},m.destroy=function(){d.logger.log("destroy"),this.trigger(a.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(r){return r.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(r){return r.destroy()}),this.coreComponents.length=0},m.attachMedia=function(r){d.logger.log("attachMedia"),this._media=r,this.trigger(a.Events.MEDIA_ATTACHING,{media:r})},m.detachMedia=function(){d.logger.log("detachMedia"),this.trigger(a.Events.MEDIA_DETACHING,void 0),this._media=null},m.loadSource=function(r){this.stopLoad();var t=this.media,s=this.url,y=this.url=C.buildAbsoluteURL(self.location.href,r,{alwaysNormalize:!0});d.logger.log("loadSource:"+y),t&&s&&s!==y&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(t)),this.trigger(a.Events.MANIFEST_LOADING,{url:r})},m.startLoad=function(r){r===void 0&&(r=-1),d.logger.log("startLoad("+r+")"),this.networkControllers.forEach(function(t){t.startLoad(r)})},m.stopLoad=function(){d.logger.log("stopLoad"),this.networkControllers.forEach(function(r){r.stopLoad()})},m.swapAudioCodec=function(){d.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},m.recoverMediaError=function(){d.logger.log("recoverMediaError");var r=this._media;this.detachMedia(),r&&this.attachMedia(r)},m.removeLevel=function(r,t){t===void 0&&(t=0),this.levelController.removeLevel(r,t)},l(c,[{key:"levels",get:function(){var r=this.levelController.levels;return r||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(r){d.logger.log("set currentLevel:"+r),this.loadLevel=r,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(r){d.logger.log("set nextLevel:"+r),this.levelController.manualLevel=r,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(r){d.logger.log("set loadLevel:"+r),this.levelController.manualLevel=r}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(r){this.levelController.nextLoadLevel=r}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(r){d.logger.log("set firstLevel:"+r),this.levelController.firstLevel=r}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(r){d.logger.log("set startLevel:"+r),r!==-1&&(r=Math.max(r,this.minAutoLevel)),this.levelController.startLevel=r}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(r){var t=!!r;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(r){this._autoLevelCapping!==r&&(d.logger.log("set autoLevelCapping:"+r),this._autoLevelCapping=r)}},{key:"bandwidthEstimate",get:function(){var r=this.abrController.bwEstimator;return r?r.getEstimate():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(r){n.HdcpLevels.indexOf(r)>-1&&(this._maxHdcpLevel=r)}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var r=this.levels,t=this.config.minAutoBitrate;if(!r)return 0;for(var s=r.length,y=0;y<s;y++)if(r[y].maxBitrate>=t)return y;return 0}},{key:"maxAutoLevel",get:function(){var r=this.levels,t=this.autoLevelCapping,s=this.maxHdcpLevel,y;if(t===-1&&r&&r.length?y=r.length-1:y=t,s)for(var f=y;f--;){var b=r[f].attrs["HDCP-LEVEL"];if(b&&b<=s)return f}return y}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(r){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,r)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var r=this.audioTrackController;return r?r.audioTracks:[]}},{key:"audioTrack",get:function(){var r=this.audioTrackController;return r?r.audioTrack:-1},set:function(r){var t=this.audioTrackController;t&&(t.audioTrack=r)}},{key:"subtitleTracks",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTrack:-1},set:function(r){var t=this.subtitleTrackController;t&&(t.subtitleTrack=r)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var r=this.subtitleTrackController;return r?r.subtitleDisplay:!1},set:function(r){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=r)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(r){this.config.lowLatencyMode=r}},{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.3.1"}},{key:"Events",get:function(){return a.Events}},{key:"ErrorTypes",get:function(){return o.ErrorTypes}},{key:"ErrorDetails",get:function(){return o.ErrorDetails}},{key:"DefaultConfig",get:function(){return c.defaultConfig?c.defaultConfig:E.hlsDefaultConfig},set:function(r){c.defaultConfig=r}}]),c}();g.defaultConfig=void 0},"./src/is-supported.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{changeTypeSupported:()=>P,isSupported:()=>M});var C=T("./src/utils/mediasource-helper.ts");function L(){return self.SourceBuffer||self.WebKitSourceBuffer}function M(){var B=(0,C.getMediaSource)();if(!B)return!1;var A=L(),D=B&&typeof B.isTypeSupported=="function"&&B.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),x=!A||A.prototype&&typeof A.prototype.appendBuffer=="function"&&typeof A.prototype.remove=="function";return!!D&&!!x}function P(){var B,A=L();return typeof(A==null||(B=A.prototype)===null||B===void 0?void 0:B.changeType)=="function"}},"./src/loader/date-range.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{DateRange:()=>S,DateRangeAttribute:()=>_});var C=T("./src/polyfills/number.ts"),L=T("./src/utils/attr-list.ts"),M=T("./src/utils/logger.ts");function P(){return P=Object.assign?Object.assign.bind():function(d){for(var E=1;E<arguments.length;E++){var p=arguments[E];for(var h in p)Object.prototype.hasOwnProperty.call(p,h)&&(d[h]=p[h])}return d},P.apply(this,arguments)}function B(d,E){for(var p=0;p<E.length;p++){var h=E[p];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(d,D(h.key),h)}}function A(d,E,p){return E&&B(d.prototype,E),p&&B(d,p),Object.defineProperty(d,"prototype",{writable:!1}),d}function D(d){var E=x(d,"string");return typeof E=="symbol"?E:String(E)}function x(d,E){if(typeof d!="object"||d===null)return d;var p=d[Symbol.toPrimitive];if(p!==void 0){var h=p.call(d,E||"default");if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(d)}var _;(function(d){d.ID="ID",d.CLASS="CLASS",d.START_DATE="START-DATE",d.DURATION="DURATION",d.END_DATE="END-DATE",d.END_ON_NEXT="END-ON-NEXT",d.PLANNED_DURATION="PLANNED-DURATION",d.SCTE35_OUT="SCTE35-OUT",d.SCTE35_IN="SCTE35-IN"})(_||(_={}));var S=function(){function d(E,p){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,p){var h=p.attr;for(var a in h)if(Object.prototype.hasOwnProperty.call(E,a)&&E[a]!==h[a]){M.logger.warn('DATERANGE tag attribute: "'+a+'" does not match for tags with ID: "'+E.ID+'"'),this._badValueForSameId=a;break}E=P(new L.AttrList({}),h,E)}if(this.attr=E,this._startDate=new Date(E[_.START_DATE]),_.END_DATE in this.attr){var o=new Date(this.attr[_.END_DATE]);(0,C.isFiniteNumber)(o.getTime())&&(this._endDate=o)}}return A(d,[{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 p=this.duration;return p!==null?new Date(this._startDate.getTime()+p*1e3):null}},{key:"duration",get:function(){if(_.DURATION in this.attr){var p=this.attr.decimalFloatingPoint(_.DURATION);if((0,C.isFiniteNumber)(p))return p}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&&(0,C.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),d}()},"./src/loader/fragment-loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{LoadError:()=>p,default:()=>d});var C=T("./src/polyfills/number.ts"),L=T("./src/errors.ts");function M(h,a){h.prototype=Object.create(a.prototype),h.prototype.constructor=h,x(h,a)}function P(h){var a=typeof Map=="function"?new Map:void 0;return P=function(n){if(n===null||!D(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a!="undefined"){if(a.has(n))return a.get(n);a.set(n,v)}function v(){return B(n,arguments,_(this).constructor)}return v.prototype=Object.create(n.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),x(v,n)},P(h)}function B(h,a,o){return A()?B=Reflect.construct.bind():B=function(v,l,i){var u=[null];u.push.apply(u,l);var g=Function.bind.apply(v,u),c=new g;return i&&x(c,i.prototype),c},B.apply(null,arguments)}function A(){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(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function x(h,a){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,v){return n.__proto__=v,n},x(h,a)}function _(h){return _=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},_(h)}var S=Math.pow(2,17),d=function(){function h(o){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=o}var a=h.prototype;return a.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},a.abort=function(){this.loader&&this.loader.abort()},a.load=function(n,v){var l=this,i=n.url;if(!i)return Promise.reject(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,networkDetails:null},"Fragment does not have a "+(i?"part list":"url")));this.abort();var u=this.config,g=u.fLoader,c=u.loader;return new Promise(function(m,e){l.loader&&l.loader.destroy();var r=l.loader=n.loader=g?new g(u):new c(u),t=E(n),s={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:n.sn==="initSegment"?1/0:S};n.stats=r.stats,r.load(t,s,{onSuccess:function(f,b,R,I){l.resetLoader(n,r);var k=f.data;R.resetIV&&n.decryptdata&&(n.decryptdata.iv=new Uint8Array(k.slice(0,16)),k=k.slice(16)),m({frag:n,part:null,payload:k,networkDetails:I})},onError:function(f,b,R){l.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,response:f,networkDetails:R}))},onAbort:function(f,b,R){l.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:n,networkDetails:R}))},onTimeout:function(f,b,R){l.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:n,networkDetails:R}))},onProgress:function(f,b,R,I){v&&v({frag:n,part:null,payload:R,networkDetails:I})}})})},a.loadPart=function(n,v,l){var i=this;this.abort();var u=this.config,g=u.fLoader,c=u.loader;return new Promise(function(m,e){i.loader&&i.loader.destroy();var r=i.loader=n.loader=g?new g(u):new c(u),t=E(n,v),s={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:S};v.stats=r.stats,r.load(t,s,{onSuccess:function(f,b,R,I){i.resetLoader(n,r),i.updateStatsFromPart(n,v);var k={frag:n,part:v,payload:f.data,networkDetails:I};l(k),m(k)},onError:function(f,b,R){i.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,part:v,response:f,networkDetails:R}))},onAbort:function(f,b,R){n.stats.aborted=v.stats.aborted,i.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:n,part:v,networkDetails:R}))},onTimeout:function(f,b,R){i.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:n,part:v,networkDetails:R}))}})})},a.updateStatsFromPart=function(n,v){var l=n.stats,i=v.stats,u=i.total;if(l.loaded+=i.loaded,u){var g=Math.round(n.duration/v.duration),c=Math.min(Math.round(l.loaded/u),g),m=g-c,e=m*Math.round(l.loaded/c);l.total=l.loaded+e}else l.total=Math.max(l.loaded,l.total);var r=l.loading,t=i.loading;r.start?r.first+=t.first-t.start:(r.start=t.start,r.first=t.first),r.end=t.end},a.resetLoader=function(n,v){n.loader=null,this.loader===v&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),v.destroy()},h}();function E(h,a){a===void 0&&(a=null);var o=a||h,n={frag:h,part:a,responseType:"arraybuffer",url:o.url,headers:{},rangeStart:0,rangeEnd:0},v=o.byteRangeStartOffset,l=o.byteRangeEndOffset;if((0,C.isFiniteNumber)(v)&&(0,C.isFiniteNumber)(l)){var i,u=v,g=l;if(h.sn==="initSegment"&&((i=h.decryptdata)===null||i===void 0?void 0:i.method)==="AES-128"){var c=l-v;c%16&&(g=l+(16-c%16)),v!==0&&(n.resetIV=!0,u=v-16)}n.rangeStart=u,n.rangeEnd=g}return n}var p=function(h){M(a,h);function a(o){for(var n,v=arguments.length,l=new Array(v>1?v-1:0),i=1;i<v;i++)l[i-1]=arguments[i];return n=h.call.apply(h,[this].concat(l))||this,n.data=void 0,n.data=o,n}return a}(P(Error))},"./src/loader/fragment.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{BaseSegment:()=>E,ElementaryStreamTypes:()=>d,Fragment:()=>p,Part:()=>h});var C=T("./src/polyfills/number.ts"),L=T("./node_modules/url-toolkit/src/url-toolkit.js"),M=T.n(L),P=T("./src/loader/load-stats.ts");function B(a,o){a.prototype=Object.create(o.prototype),a.prototype.constructor=a,A(a,o)}function A(a,o){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,l){return v.__proto__=l,v},A(a,o)}function D(a,o){for(var n=0;n<o.length;n++){var v=o[n];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(a,_(v.key),v)}}function x(a,o,n){return o&&D(a.prototype,o),n&&D(a,n),Object.defineProperty(a,"prototype",{writable:!1}),a}function _(a){var o=S(a,"string");return typeof o=="symbol"?o:String(o)}function S(a,o){if(typeof a!="object"||a===null)return a;var n=a[Symbol.toPrimitive];if(n!==void 0){var v=n.call(a,o||"default");if(typeof v!="object")return v;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(a)}var d;(function(a){a.AUDIO="audio",a.VIDEO="video",a.AUDIOVIDEO="audiovideo"})(d||(d={}));var E=function(){function a(n){var v;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(v={},v[d.AUDIO]=null,v[d.VIDEO]=null,v[d.AUDIOVIDEO]=null,v),this.baseurl=n}var o=a.prototype;return o.setByteRange=function(v,l){var i=v.split("@",2),u=[];i.length===1?u[0]=l?l.byteRangeEndOffset:0:u[0]=parseInt(i[1]),u[1]=parseInt(i[0])+u[0],this._byteRange=u},x(a,[{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=(0,L.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(v){this._url=v}}]),a}(),p=function(a){B(o,a);function o(v,l){var i;return i=a.call(this,l)||this,i._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkeys=void 0,i.type=void 0,i.loader=null,i.keyLoader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.appendedPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new P.LoadStats,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.type=v,i}var n=o.prototype;return n.setKeyFormat=function(l){if(this.levelkeys){var i=this.levelkeys[l];i&&!this._decryptdata&&(this._decryptdata=i.getDecryptData(this.sn))}},n.abortRequests=function(){var l,i;(l=this.loader)===null||l===void 0||l.abort(),(i=this.keyLoader)===null||i===void 0||i.abort()},n.setElementaryStreamInfo=function(l,i,u,g,c,m){m===void 0&&(m=!1);var e=this.elementaryStreams,r=e[l];if(!r){e[l]={startPTS:i,endPTS:u,startDTS:g,endDTS:c,partial:m};return}r.startPTS=Math.min(r.startPTS,i),r.endPTS=Math.max(r.endPTS,u),r.startDTS=Math.min(r.startDTS,g),r.endDTS=Math.max(r.endDTS,c)},n.clearElementaryStreamInfo=function(){var l=this.elementaryStreams;l[d.AUDIO]=null,l[d.VIDEO]=null,l[d.AUDIOVIDEO]=null},x(o,[{key:"decryptdata",get:function(){var l=this.levelkeys;if(!l&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var i=this.levelkeys.identity;if(i)this._decryptdata=i.getDecryptData(this.sn);else{var u=Object.keys(this.levelkeys);if(u.length===1)return this._decryptdata=this.levelkeys[u[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!(0,C.isFiniteNumber)(this.programDateTime))return null;var l=(0,C.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+l*1e3}},{key:"encrypted",get:function(){var l;if((l=this._decryptdata)!==null&&l!==void 0&&l.encrypted)return!0;if(this.levelkeys){var i=Object.keys(this.levelkeys),u=i.length;if(u>1||u===1&&this.levelkeys[i[0]].encrypted)return!0}return!1}}]),o}(E),h=function(a){B(o,a);function o(n,v,l,i,u){var g;g=a.call(this,l)||this,g.fragOffset=0,g.duration=0,g.gap=!1,g.independent=!1,g.relurl=void 0,g.fragment=void 0,g.index=void 0,g.stats=new P.LoadStats,g.duration=n.decimalFloatingPoint("DURATION"),g.gap=n.bool("GAP"),g.independent=n.bool("INDEPENDENT"),g.relurl=n.enumeratedString("URI"),g.fragment=v,g.index=i;var c=n.enumeratedString("BYTERANGE");return c&&g.setByteRange(c,u),u&&(g.fragOffset=u.fragOffset+u.duration),g}return x(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 v=this.elementaryStreams;return!!(v.audio||v.video||v.audiovideo)}}]),o}(E)},"./src/loader/key-loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>M});var C=T("./src/errors.ts"),L=T("./src/loader/fragment-loader.ts"),M=function(){function P(A){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=A}var B=P.prototype;return B.abort=function(){for(var D in this.keyUriToKeyInfo){var x=this.keyUriToKeyInfo[D].loader;x&&x.abort()}},B.detach=function(){for(var D in this.keyUriToKeyInfo){var x=this.keyUriToKeyInfo[D];(x.mediaKeySessionContext||x.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[D]}},B.destroy=function(){this.detach();for(var D in this.keyUriToKeyInfo){var x=this.keyUriToKeyInfo[D].loader;x&&x.destroy()}this.keyUriToKeyInfo={}},B.createKeyLoadError=function(D,x,_,S){return x===void 0&&(x=C.ErrorDetails.KEY_LOAD_ERROR),new L.LoadError({type:C.ErrorTypes.NETWORK_ERROR,details:x,fatal:!1,frag:D,networkDetails:_})},B.loadClear=function(D,x){var _=this;if(this.emeController&&this.config.emeEnabled)for(var S=D.sn,d=D.cc,E=function(o){var n=x[o];if(d<=n.cc&&(S==="initSegment"||S<n.sn))return _.emeController.selectKeySystemFormat(n).then(function(v){n.setKeyFormat(v)}),"break"},p=0;p<x.length;p++){var h=E(p);if(h==="break")break}},B.load=function(D){var x=this;return!D.decryptdata&&D.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(D).then(function(_){return x.loadInternal(D,_)}):this.loadInternal(D)},B.loadInternal=function(D,x){var _,S;x&&D.setKeyFormat(x);var d=D.decryptdata;if(!d){var E=x?"Expected frag.decryptdata to be defined after setting format "+x:"Missing decryption data on fragment in onKeyLoading";return Promise.reject(this.createKeyLoadError(D,C.ErrorDetails.KEY_LOAD_ERROR,null,E))}var p=d.uri;if(!p)return Promise.reject(this.createKeyLoadError(D,C.ErrorDetails.KEY_LOAD_ERROR,null,'Invalid key URI: "'+p+'"'));var h=this.keyUriToKeyInfo[p];if((_=h)!==null&&_!==void 0&&_.decryptdata.key)return d.key=h.decryptdata.key,Promise.resolve({frag:D,keyInfo:h});if((S=h)!==null&&S!==void 0&&S.keyLoadPromise){var a;switch((a=h.mediaKeySessionContext)===null||a===void 0?void 0:a.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return h.keyLoadPromise}}switch(h=this.keyUriToKeyInfo[p]={decryptdata:d,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},d.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return d.keyFormat==="identity"?this.loadKeyHTTP(h,D):this.loadKeyEME(h,D);case"AES-128":return this.loadKeyHTTP(h,D);default:return Promise.reject(this.createKeyLoadError(D,C.ErrorDetails.KEY_LOAD_ERROR,null,'Key supplied with unsupported METHOD: "'+d.method+'"'))}},B.loadKeyEME=function(D,x){var _={frag:x,keyInfo:D};if(this.emeController&&this.config.emeEnabled){var S=this.emeController.loadKey(_);if(S)return(D.keyLoadPromise=S.then(function(d){return D.mediaKeySessionContext=d,_})).catch(function(d){throw D.keyLoadPromise=null,d})}return Promise.resolve(_)},B.loadKeyHTTP=function(D,x){var _=this,S=this.config,d=S.loader,E=new d(S);return x.keyLoader=D.loader=E,D.keyLoadPromise=new Promise(function(p,h){var a={keyInfo:D,frag:x,responseType:"arraybuffer",url:D.decryptdata.uri},o={timeout:S.fragLoadingTimeOut,maxRetry:0,retryDelay:S.fragLoadingRetryDelay,maxRetryDelay:S.fragLoadingMaxRetryTimeout,highWaterMark:0},n={onSuccess:function(l,i,u,g){var c=u.frag,m=u.keyInfo,e=u.url;if(!c.decryptdata||m!==_.keyUriToKeyInfo[e])return h(_.createKeyLoadError(c,C.ErrorDetails.KEY_LOAD_ERROR,g,"after key load, decryptdata unset or changed"));m.decryptdata.key=c.decryptdata.key=new Uint8Array(l.data),c.keyLoader=null,m.loader=null,p({frag:c,keyInfo:m})},onError:function(l,i,u){_.resetLoader(i),h(_.createKeyLoadError(x,C.ErrorDetails.KEY_LOAD_ERROR,u))},onTimeout:function(l,i,u){_.resetLoader(i),h(_.createKeyLoadError(x,C.ErrorDetails.KEY_LOAD_TIMEOUT,u))},onAbort:function(l,i,u){_.resetLoader(i),h(_.createKeyLoadError(x,C.ErrorDetails.INTERNAL_ABORTED,u))}};E.load(a,o,n)})},B.resetLoader=function(D){var x=D.frag,_=D.keyInfo,S=D.url,d=_.loader;x.keyLoader===d&&(x.keyLoader=null,_.loader=null),delete this.keyUriToKeyInfo[S],d&&d.destroy()},P}()},"./src/loader/level-details.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{LevelDetails:()=>D});var C=T("./src/polyfills/number.ts");function L(x,_){for(var S=0;S<_.length;S++){var d=_[S];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(x,P(d.key),d)}}function M(x,_,S){return _&&L(x.prototype,_),S&&L(x,S),Object.defineProperty(x,"prototype",{writable:!1}),x}function P(x){var _=B(x,"string");return typeof _=="symbol"?_:String(_)}function B(x,_){if(typeof x!="object"||x===null)return x;var S=x[Symbol.toPrimitive];if(S!==void 0){var d=S.call(x,_||"default");if(typeof d!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(_==="string"?String:Number)(x)}var A=10,D=function(){function x(S){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.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.encryptedFragments=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=S}var _=x.prototype;return _.reloaded=function(d){if(!d){this.advanced=!0,this.updated=!0;return}var E=this.lastPartSn-d.lastPartSn,p=this.lastPartIndex-d.lastPartIndex;this.updated=this.endSN!==d.endSN||!!p||!!E,this.advanced=this.endSN>d.endSN||E>0||E===0&&p>0,this.updated||this.advanced?this.misses=Math.floor(d.misses*.6):this.misses=d.misses+1,this.availabilityDelay=d.availabilityDelay},M(x,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?(0,C.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||A}},{key:"drift",get:function(){var d=this.driftEndTime-this.driftStartTime;if(d>0){var E=this.driftEnd-this.driftStart;return E*1e3/d}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var d;return(d=this.partList)!==null&&d!==void 0&&d.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var d;return(d=this.fragments)!==null&&d!==void 0&&d.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 d;return(d=this.partList)!==null&&d!==void 0&&d.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var d;return(d=this.partList)!==null&&d!==void 0&&d.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),x}()},"./src/loader/level-key.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{LevelKey:()=>D});var C=T("./src/utils/keysystem-util.ts"),L=T("./src/utils/mediakeys-helper.ts"),M=T("./src/utils/mp4-tools.ts"),P=T("./src/utils/logger.ts"),B=T("./src/utils/numeric-encoding-utils.ts"),A={},D=function(){_.clearKeyUriToKeyIdMap=function(){A={}};function _(d,E,p,h,a){h===void 0&&(h=[1]),a===void 0&&(a=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=d,this.uri=E,this.keyFormat=p,this.keyFormatVersions=h,this.iv=a,this.encrypted=d?d!=="NONE":!1,this.isCommonEncryption=this.encrypted&&d!=="AES-128"}var S=_.prototype;return S.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;switch(this.keyFormat){case"identity":return this.method==="SAMPLE-AES";case L.KeySystemFormats.FAIRPLAY:case L.KeySystemFormats.WIDEVINE:case L.KeySystemFormats.PLAYREADY:case L.KeySystemFormats.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1},S.getDecryptData=function(E){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof E!="number"&&(this.method==="AES-128"&&!this.iv&&P.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),E=0);var p=x(E),h=new _(this.method,this.uri,"identity",this.keyFormatVersions,p);return h}var a=(0,C.convertDataUriToArrayBytes)(this.uri);if(a)switch(this.keyFormat){case L.KeySystemFormats.WIDEVINE:this.pssh=a,a.length>=22&&(this.keyId=a.subarray(a.length-22,a.length-6));break;case L.KeySystemFormats.PLAYREADY:{var o=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=(0,M.mp4pssh)(o,null,a);var n=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/2),v=String.fromCharCode.apply(null,Array.from(n)),l=v.substring(v.indexOf("<"),v.length),i=new DOMParser,u=i.parseFromString(l,"text/xml"),g=u.getElementsByTagName("KID")[0];if(g){var c=g.childNodes[0]?g.childNodes[0].nodeValue:g.getAttribute("VALUE");if(c){var m=(0,B.base64Decode)(c).subarray(0,16);(0,C.changeEndianness)(m),this.keyId=m}}break}default:{var e=a.subarray(0,16);if(e.length!==16){var r=new Uint8Array(16);r.set(e,16-e.length),e=r}this.keyId=e;break}}if(!this.keyId||this.keyId.byteLength!==16){var t=A[this.uri];if(!t){var s=Object.keys(A).length%Number.MAX_SAFE_INTEGER;t=new Uint8Array(16);var y=new DataView(t.buffer,12,4);y.setUint32(0,s),A[this.uri]=t}this.keyId=t}return this},_}();function x(_){for(var S=new Uint8Array(16),d=12;d<16;d++)S[d]=_>>8*(15-d)&255;return S}},"./src/loader/load-stats.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{LoadStats:()=>C});var C=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":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>o});var C=T("./src/polyfills/number.ts"),L=T("./node_modules/url-toolkit/src/url-toolkit.js"),M=T.n(L),P=T("./src/loader/date-range.ts"),B=T("./src/loader/fragment.ts"),A=T("./src/loader/level-details.ts"),D=T("./src/loader/level-key.ts"),x=T("./src/utils/attr-list.ts"),_=T("./src/utils/logger.ts"),S=T("./src/utils/codecs.ts");function d(){return d=Object.assign?Object.assign.bind():function(c){for(var m=1;m<arguments.length;m++){var e=arguments[m];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(c[r]=e[r])}return c},d.apply(this,arguments)}var E=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+|#EXT-X-SESSION-KEY:([^\n\r]*)[\r\n]+/g,p=/#EXT-X-MEDIA:(.*)/g,h=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),a=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("|")),o=function(){function c(){}return c.findGroup=function(e,r){for(var t=0;t<e.length;t++){var s=e[t];if(s.id===r)return s}},c.convertAVC1ToAVCOTI=function(e){var r=e.split(".");if(r.length>2){var t=r.shift()+".";return t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).slice(-4),t}return e},c.resolve=function(e,r){return(0,L.buildAbsoluteURL)(r,e,{alwaysNormalize:!0})},c.parseMasterPlaylist=function(e,r){var t=[],s=[],y={},f=[],b=!1;E.lastIndex=0;for(var R;(R=E.exec(e))!=null;)if(R[1]){var I,k=new x.AttrList(R[1]),F={attrs:k,bitrate:k.decimalInteger("AVERAGE-BANDWIDTH")||k.decimalInteger("BANDWIDTH"),name:k.NAME,url:c.resolve(R[2],r)},K=k.decimalResolution("RESOLUTION");K&&(F.width=K.width,F.height=K.height),v((k.CODECS||"").split(/[ ,]+/).filter(function(q){return q}),F),F.videoCodec&&F.videoCodec.indexOf("avc1")!==-1&&(F.videoCodec=c.convertAVC1ToAVCOTI(F.videoCodec)),(I=F.unknownCodecs)!==null&&I!==void 0&&I.length||s.push(F),t.push(F)}else if(R[3]){var H=new x.AttrList(R[3]);H["DATA-ID"]&&(b=!0,y[H["DATA-ID"]]=H)}else if(R[4]){var j=R[4],Y=n(j,r);Y.encrypted&&Y.isSupported()?f.push(Y):_.logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+j+'"')}var Q=s.length>0&&s.length<t.length;return{levels:Q?s:t,sessionData:b?y:null,sessionKeys:f.length?f:null}},c.parseMasterPlaylistMedia=function(e,r,t,s){s===void 0&&(s=[]);var y,f=[],b=0;for(p.lastIndex=0;(y=p.exec(e))!==null;){var R=new x.AttrList(y[1]);if(R.TYPE===t){var I={attrs:R,bitrate:0,id:b++,groupId:R["GROUP-ID"],instreamId:R["INSTREAM-ID"],name:R.NAME||R.LANGUAGE||"",type:t,default:R.bool("DEFAULT"),autoselect:R.bool("AUTOSELECT"),forced:R.bool("FORCED"),lang:R.LANGUAGE,url:R.URI?c.resolve(R.URI,r):""};if(s.length){var k=c.findGroup(s,I.groupId)||s[0];l(I,k,"audioCodec"),l(I,k,"textCodec")}f.push(I)}}return f},c.parseLevelPlaylist=function(e,r,t,s,y){var f=new A.LevelDetails(r),b=f.fragments,R=null,I=0,k=0,F=0,K=0,H=null,j=new B.Fragment(s,r),Y,Q,q,ne=-1,te=!1;for(h.lastIndex=0,f.m3u8=e;(Y=h.exec(e))!==null;){te&&(te=!1,j=new B.Fragment(s,r),j.start=F,j.sn=I,j.cc=K,j.level=t,R&&(j.initSegment=R,j.rawProgramDateTime=R.rawProgramDateTime,R.rawProgramDateTime=null));var ae=Y[1];if(ae){j.duration=parseFloat(ae);var ue=(" "+Y[2]).slice(1);j.title=ue||null,j.tagList.push(ue?["INF",ae,ue]:["INF",ae])}else if(Y[3]){if((0,C.isFiniteNumber)(j.duration)){if(j.start=F,q){j.levelkeys=q;var ce=f.encryptedFragments;j.levelkeys&&Object.keys(j.levelkeys).some(function(et){return j.levelkeys[et].isCommonEncryption})&&(!ce.length||ce[ce.length-1].levelkeys!==q)&&ce.push(j)}j.sn=I,j.level=t,j.cc=K,j.urlId=y,b.push(j),j.relurl=(" "+Y[3]).slice(1),u(j,H),H=j,F+=j.duration,I++,k=0,te=!0}}else if(Y[4]){var le=(" "+Y[4]).slice(1);H?j.setByteRange(le,H):j.setByteRange(le)}else if(Y[5])j.rawProgramDateTime=(" "+Y[5]).slice(1),j.tagList.push(["PROGRAM-DATE-TIME",j.rawProgramDateTime]),ne===-1&&(ne=b.length);else{if(Y=Y[0].match(a),!Y){_.logger.warn("No matches on slow regex match for level playlist!");continue}for(Q=1;Q<Y.length&&typeof Y[Q]=="undefined";Q++);var fe=(" "+Y[Q]).slice(1),de=(" "+Y[Q+1]).slice(1),xe=Y[Q+2]?(" "+Y[Q+2]).slice(1):"";switch(fe){case"PLAYLIST-TYPE":f.type=de.toUpperCase();break;case"MEDIA-SEQUENCE":I=f.startSN=parseInt(de);break;case"SKIP":{var Ae=new x.AttrList(de),Ie=Ae.decimalInteger("SKIPPED-SEGMENTS");if((0,C.isFiniteNumber)(Ie)){f.skippedSegments=Ie;for(var Re=Ie;Re--;)b.unshift(null);I+=Ie}var Oe=Ae.enumeratedString("RECENTLY-REMOVED-DATERANGES");Oe&&(f.recentlyRemovedDateranges=Oe.split(" "));break}case"TARGETDURATION":f.targetduration=parseFloat(de);break;case"VERSION":f.version=parseInt(de);break;case"EXTM3U":break;case"ENDLIST":f.live=!1;break;case"#":(de||xe)&&j.tagList.push(xe?[de,xe]:[de]);break;case"DISCONTINUITY":K++,j.tagList.push(["DIS"]);break;case"GAP":j.tagList.push([fe]);break;case"BITRATE":j.tagList.push([fe,de]);break;case"DATERANGE":{var Pe=new x.AttrList(de),Ce=new P.DateRange(Pe,f.dateRanges[Pe.ID]);Ce.isValid||f.skippedSegments?f.dateRanges[Ce.id]=Ce:_.logger.warn('Ignoring invalid DATERANGE tag: "'+de+'"'),j.tagList.push(["EXT-X-DATERANGE",de]);break}case"DISCONTINUITY-SEQUENCE":K=parseInt(de);break;case"KEY":{var Le=n(de,r);if(Le.isSupported()){if(Le.method==="NONE"){q=void 0;break}q||(q={}),q[Le.keyFormat]&&(q=d({},q)),q[Le.keyFormat]=Le}else _.logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+de+'"');break}case"START":{var ke=new x.AttrList(de),Be=ke.decimalFloatingPoint("TIME-OFFSET");(0,C.isFiniteNumber)(Be)&&(f.startTimeOffset=Be);break}case"MAP":{var we=new x.AttrList(de);if(j.duration){var Ye=new B.Fragment(s,r);g(Ye,we,t,q),R=Ye,j.initSegment=R,R.rawProgramDateTime&&!j.rawProgramDateTime&&(j.rawProgramDateTime=R.rawProgramDateTime)}else g(j,we,t,q),R=j,te=!0;break}case"SERVER-CONTROL":{var Xe=new x.AttrList(de);f.canBlockReload=Xe.bool("CAN-BLOCK-RELOAD"),f.canSkipUntil=Xe.optionalFloat("CAN-SKIP-UNTIL",0),f.canSkipDateRanges=f.canSkipUntil>0&&Xe.bool("CAN-SKIP-DATERANGES"),f.partHoldBack=Xe.optionalFloat("PART-HOLD-BACK",0),f.holdBack=Xe.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var rt=new x.AttrList(de);f.partTarget=rt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var ze=f.partList;ze||(ze=f.partList=[]);var it=k>0?ze[ze.length-1]:void 0,nt=k++,Je=new B.Part(new x.AttrList(de),j,r,nt,it);ze.push(Je),j.duration+=Je.duration;break}case"PRELOAD-HINT":{var Ne=new x.AttrList(de);f.preloadHint=Ne;break}case"RENDITION-REPORT":{var Ke=new x.AttrList(de);f.renditionReports=f.renditionReports||[],f.renditionReports.push(Ke);break}default:_.logger.warn("line parsed but not handled: "+Y);break}}}H&&!H.relurl?(b.pop(),F-=H.duration,f.partList&&(f.fragmentHint=H)):f.partList&&(u(j,H),j.cc=K,f.fragmentHint=j);var Ze=b.length,ft=b[0],Me=b[Ze-1];if(F+=f.skippedSegments*f.targetduration,F>0&&Ze&&Me){f.averagetargetduration=F/Ze;var qe=Me.sn;f.endSN=qe!=="initSegment"?qe:0,f.live||(Me.endList=!0),ft&&(f.startCC=ft.cc)}else f.endSN=0,f.startCC=0;return f.fragmentHint&&(F+=f.fragmentHint.duration),f.totalduration=F,f.endCC=K,ne>0&&i(b,ne),f},c}();function n(c,m){var e,r,t=new x.AttrList(c),s=(e=t.enumeratedString("METHOD"))!=null?e:"",y=t.URI,f=t.hexadecimalInteger("IV"),b=t.enumeratedString("KEYFORMATVERSIONS"),R=(r=t.enumeratedString("KEYFORMAT"))!=null?r:"identity";y&&t.IV&&!f&&_.logger.error("Invalid IV: "+t.IV);var I=y?o.resolve(y,m):"",k=(b||"1").split("/").map(Number).filter(Number.isFinite);return new D.LevelKey(s,I,R,k,f)}function v(c,m){["video","audio","text"].forEach(function(e){var r=c.filter(function(s){return(0,S.isCodecType)(s,e)});if(r.length){var t=r.filter(function(s){return s.lastIndexOf("avc1",0)===0||s.lastIndexOf("mp4a",0)===0});m[e+"Codec"]=t.length>0?t[0]:r[0],c=c.filter(function(s){return r.indexOf(s)===-1})}}),m.unknownCodecs=c}function l(c,m,e){var r=m[e];r&&(c[e]=r)}function i(c,m){for(var e=c[m],r=m;r--;){var t=c[r];if(!t)return;t.programDateTime=e.programDateTime-t.duration*1e3,e=t}}function u(c,m){c.rawProgramDateTime?c.programDateTime=Date.parse(c.rawProgramDateTime):m!=null&&m.programDateTime&&(c.programDateTime=m.endProgramDateTime),(0,C.isFiniteNumber)(c.programDateTime)||(c.programDateTime=null,c.rawProgramDateTime=null)}function g(c,m,e,r){c.relurl=m.URI,m.BYTERANGE&&c.setByteRange(m.BYTERANGE),c.level=e,c.sn="initSegment",r&&(c.levelkeys=r),c.initSegment=null}},"./src/loader/playlist-loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>d});var C=T("./src/polyfills/number.ts"),L=T("./src/events.ts"),M=T("./src/errors.ts"),P=T("./src/utils/logger.ts"),B=T("./src/loader/m3u8-parser.ts"),A=T("./src/types/loader.ts"),D=T("./src/utils/attr-list.ts");function x(E){var p=E.type;switch(p){case A.PlaylistContextType.AUDIO_TRACK:return A.PlaylistLevelType.AUDIO;case A.PlaylistContextType.SUBTITLE_TRACK:return A.PlaylistLevelType.SUBTITLE;default:return A.PlaylistLevelType.MAIN}}function _(E,p){var h=E.url;return(h===void 0||h.indexOf("data:")===0)&&(h=p.url),h}var S=function(){function E(h){this.hls=void 0,this.loaders=Object.create(null),this.hls=h,this.registerListeners()}var p=E.prototype;return p.startLoad=function(a){},p.stopLoad=function(){this.destroyInternalLoaders()},p.registerListeners=function(){var a=this.hls;a.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(L.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.on(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.unregisterListeners=function(){var a=this.hls;a.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(L.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.off(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.createInternalLoader=function(a){var o=this.hls.config,n=o.pLoader,v=o.loader,l=n||v,i=new l(o);return a.loader=i,this.loaders[a.type]=i,i},p.getInternalLoader=function(a){return this.loaders[a.type]},p.resetInternalLoader=function(a){this.loaders[a]&&delete this.loaders[a]},p.destroyInternalLoaders=function(){for(var a in this.loaders){var o=this.loaders[a];o&&o.destroy(),this.resetInternalLoader(a)}},p.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},p.onManifestLoading=function(a,o){var n=o.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:A.PlaylistContextType.MANIFEST,url:n,deliveryDirectives:null})},p.onLevelLoading=function(a,o){var n=o.id,v=o.level,l=o.url,i=o.deliveryDirectives;this.load({id:n,groupId:null,level:v,responseType:"text",type:A.PlaylistContextType.LEVEL,url:l,deliveryDirectives:i})},p.onAudioTrackLoading=function(a,o){var n=o.id,v=o.groupId,l=o.url,i=o.deliveryDirectives;this.load({id:n,groupId:v,level:null,responseType:"text",type:A.PlaylistContextType.AUDIO_TRACK,url:l,deliveryDirectives:i})},p.onSubtitleTrackLoading=function(a,o){var n=o.id,v=o.groupId,l=o.url,i=o.deliveryDirectives;this.load({id:n,groupId:v,level:null,responseType:"text",type:A.PlaylistContextType.SUBTITLE_TRACK,url:l,deliveryDirectives:i})},p.load=function(a){var o,n=this.hls.config,v=this.getInternalLoader(a);if(v){var l=v.context;if(l&&l.url===a.url){P.logger.trace("[playlist-loader]: playlist request ongoing");return}P.logger.log("[playlist-loader]: aborting previous loader for type: "+a.type),v.abort()}var i,u,g,c;switch(a.type){case A.PlaylistContextType.MANIFEST:i=n.manifestLoadingMaxRetry,u=n.manifestLoadingTimeOut,g=n.manifestLoadingRetryDelay,c=n.manifestLoadingMaxRetryTimeout;break;case A.PlaylistContextType.LEVEL:case A.PlaylistContextType.AUDIO_TRACK:case A.PlaylistContextType.SUBTITLE_TRACK:i=0,u=n.levelLoadingTimeOut;break;default:i=n.levelLoadingMaxRetry,u=n.levelLoadingTimeOut,g=n.levelLoadingRetryDelay,c=n.levelLoadingMaxRetryTimeout;break}if(v=this.createInternalLoader(a),(o=a.deliveryDirectives)!==null&&o!==void 0&&o.part){var m;if(a.type===A.PlaylistContextType.LEVEL&&a.level!==null?m=this.hls.levels[a.level].details:a.type===A.PlaylistContextType.AUDIO_TRACK&&a.id!==null?m=this.hls.audioTracks[a.id].details:a.type===A.PlaylistContextType.SUBTITLE_TRACK&&a.id!==null&&(m=this.hls.subtitleTracks[a.id].details),m){var e=m.partTarget,r=m.targetduration;e&&r&&(u=Math.min(Math.max(e*3,r*.8)*1e3,u))}}var t={timeout:u,maxRetry:i,retryDelay:g,maxRetryDelay:c,highWaterMark:0},s={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};v.load(a,t,s)},p.loadsuccess=function(a,o,n,v){v===void 0&&(v=null),this.resetInternalLoader(n.type);var l=a.data;if(l.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(a,n,"no EXTM3U delimiter",v);return}o.parsing.start=performance.now(),l.indexOf("#EXTINF:")>0||l.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(a,o,n,v):this.handleMasterPlaylist(a,o,n,v)},p.loaderror=function(a,o,n){n===void 0&&(n=null),this.handleNetworkError(o,n,!1,a)},p.loadtimeout=function(a,o,n){n===void 0&&(n=null),this.handleNetworkError(o,n,!0)},p.handleMasterPlaylist=function(a,o,n,v){var l=this.hls,i=a.data,u=_(a,n),g=B.default.parseMasterPlaylist(i,u),c=g.levels,m=g.sessionData,e=g.sessionKeys;if(!c.length){this.handleManifestParsingError(a,n,"no level found in manifest",v);return}var r=c.map(function(R){return{id:R.attrs.AUDIO,audioCodec:R.audioCodec}}),t=c.map(function(R){return{id:R.attrs.SUBTITLES,textCodec:R.textCodec}}),s=B.default.parseMasterPlaylistMedia(i,u,"AUDIO",r),y=B.default.parseMasterPlaylistMedia(i,u,"SUBTITLES",t),f=B.default.parseMasterPlaylistMedia(i,u,"CLOSED-CAPTIONS");if(s.length){var b=s.some(function(R){return!R.url});!b&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(P.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),s.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new D.AttrList({}),bitrate:0,url:""}))}l.trigger(L.Events.MANIFEST_LOADED,{levels:c,audioTracks:s,subtitles:y,captions:f,url:u,stats:o,networkDetails:v,sessionData:m,sessionKeys:e})},p.handleTrackOrLevelPlaylist=function(a,o,n,v){var l=this.hls,i=n.id,u=n.level,g=n.type,c=_(a,n),m=(0,C.isFiniteNumber)(i)?i:0,e=(0,C.isFiniteNumber)(u)?u:m,r=x(n),t=B.default.parseLevelPlaylist(a.data,c,e,r,m);if(!t.fragments.length){l.trigger(L.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:c,reason:"no fragments found in level",level:typeof n.level=="number"?n.level:void 0});return}if(g===A.PlaylistContextType.MANIFEST){var s={attrs:new D.AttrList({}),bitrate:0,details:t,name:"",url:c};l.trigger(L.Events.MANIFEST_LOADED,{levels:[s],audioTracks:[],url:c,stats:o,networkDetails:v,sessionData:null,sessionKeys:null})}o.parsing.end=performance.now(),n.levelDetails=t,this.handlePlaylistLoaded(a,o,n,v)},p.handleManifestParsingError=function(a,o,n,v){this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:o.type===A.PlaylistContextType.MANIFEST,url:a.url,reason:n,response:a,context:o,networkDetails:v})},p.handleNetworkError=function(a,o,n,v){n===void 0&&(n=!1),P.logger.warn("[playlist-loader]: A network "+(n?"timeout":"error")+" occurred while loading "+a.type+" level: "+a.level+" id: "+a.id+' group-id: "'+a.groupId+'"');var l=M.ErrorDetails.UNKNOWN,i=!1,u=this.getInternalLoader(a);switch(a.type){case A.PlaylistContextType.MANIFEST:l=n?M.ErrorDetails.MANIFEST_LOAD_TIMEOUT:M.ErrorDetails.MANIFEST_LOAD_ERROR,i=!0;break;case A.PlaylistContextType.LEVEL:l=n?M.ErrorDetails.LEVEL_LOAD_TIMEOUT:M.ErrorDetails.LEVEL_LOAD_ERROR,i=!1;break;case A.PlaylistContextType.AUDIO_TRACK:l=n?M.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:M.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,i=!1;break;case A.PlaylistContextType.SUBTITLE_TRACK:l=n?M.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:M.ErrorDetails.SUBTITLE_LOAD_ERROR,i=!1;break}u&&this.resetInternalLoader(a.type);var g={type:M.ErrorTypes.NETWORK_ERROR,details:l,fatal:i,url:a.url,loader:u,context:a,networkDetails:o};v&&(g.response=v),this.hls.trigger(L.Events.ERROR,g)},p.handlePlaylistLoaded=function(a,o,n,v){var l=n.type,i=n.level,u=n.id,g=n.groupId,c=n.loader,m=n.levelDetails,e=n.deliveryDirectives;if(!(m!=null&&m.targetduration)){this.handleManifestParsingError(a,n,"invalid target duration",v);return}if(!!c)switch(m.live&&(c.getCacheAge&&(m.ageHeader=c.getCacheAge()||0),(!c.getCacheAge||isNaN(m.ageHeader))&&(m.ageHeader=0)),l){case A.PlaylistContextType.MANIFEST:case A.PlaylistContextType.LEVEL:this.hls.trigger(L.Events.LEVEL_LOADED,{details:m,level:i||0,id:u||0,stats:o,networkDetails:v,deliveryDirectives:e});break;case A.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(L.Events.AUDIO_TRACK_LOADED,{details:m,id:u||0,groupId:g||"",stats:o,networkDetails:v,deliveryDirectives:e});break;case A.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(L.Events.SUBTITLE_TRACK_LOADED,{details:m,id:u||0,groupId:g||"",stats:o,networkDetails:v,deliveryDirectives:e});break}},E}();let d=S},"./src/polyfills/number.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{MAX_SAFE_INTEGER:()=>L,isFiniteNumber:()=>C});var C=Number.isFinite||function(M){return typeof M=="number"&&isFinite(M)},L=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>L});var C=function(){function M(){}return M.getSilentFrame=function(B,A){switch(B){case"mp4a.40.2":if(A===1)return new Uint8Array([0,200,0,128,35,128]);if(A===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(A===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(A===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(A===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(A===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(A===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(A===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(A===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}},M}();let L=C},"./src/remux/mp4-generator.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>M});var C=Math.pow(2,32)-1,L=function(){function P(){}return P.init=function(){P.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 A;for(A in P.types)P.types.hasOwnProperty(A)&&(P.types[A]=[A.charCodeAt(0),A.charCodeAt(1),A.charCodeAt(2),A.charCodeAt(3)]);var D=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]),x=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]);P.HDLR_TYPES={video:D,audio:x};var _=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),S=new Uint8Array([0,0,0,0,0,0,0,0]);P.STTS=P.STSC=P.STCO=S,P.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),P.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),P.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),P.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]),p=new Uint8Array([0,0,0,1]);P.FTYP=P.box(P.types.ftyp,d,p,d,E),P.DINF=P.box(P.types.dinf,P.box(P.types.dref,_))},P.box=function(A){for(var D=8,x=arguments.length,_=new Array(x>1?x-1:0),S=1;S<x;S++)_[S-1]=arguments[S];for(var d=_.length,E=d;d--;)D+=_[d].byteLength;var p=new Uint8Array(D);for(p[0]=D>>24&255,p[1]=D>>16&255,p[2]=D>>8&255,p[3]=D&255,p.set(A,4),d=0,D=8;d<E;d++)p.set(_[d],D),D+=_[d].byteLength;return p},P.hdlr=function(A){return P.box(P.types.hdlr,P.HDLR_TYPES[A])},P.mdat=function(A){return P.box(P.types.mdat,A)},P.mdhd=function(A,D){D*=A;var x=Math.floor(D/(C+1)),_=Math.floor(D%(C+1));return P.box(P.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,A>>24&255,A>>16&255,A>>8&255,A&255,x>>24,x>>16&255,x>>8&255,x&255,_>>24,_>>16&255,_>>8&255,_&255,85,196,0,0]))},P.mdia=function(A){return P.box(P.types.mdia,P.mdhd(A.timescale,A.duration),P.hdlr(A.type),P.minf(A))},P.mfhd=function(A){return P.box(P.types.mfhd,new Uint8Array([0,0,0,0,A>>24,A>>16&255,A>>8&255,A&255]))},P.minf=function(A){return A.type==="audio"?P.box(P.types.minf,P.box(P.types.smhd,P.SMHD),P.DINF,P.stbl(A)):P.box(P.types.minf,P.box(P.types.vmhd,P.VMHD),P.DINF,P.stbl(A))},P.moof=function(A,D,x){return P.box(P.types.moof,P.mfhd(A),P.traf(x,D))},P.moov=function(A){for(var D=A.length,x=[];D--;)x[D]=P.trak(A[D]);return P.box.apply(null,[P.types.moov,P.mvhd(A[0].timescale,A[0].duration)].concat(x).concat(P.mvex(A)))},P.mvex=function(A){for(var D=A.length,x=[];D--;)x[D]=P.trex(A[D]);return P.box.apply(null,[P.types.mvex].concat(x))},P.mvhd=function(A,D){D*=A;var x=Math.floor(D/(C+1)),_=Math.floor(D%(C+1)),S=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,A>>24&255,A>>16&255,A>>8&255,A&255,x>>24,x>>16&255,x>>8&255,x&255,_>>24,_>>16&255,_>>8&255,_&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 P.box(P.types.mvhd,S)},P.sdtp=function(A){var D=A.samples||[],x=new Uint8Array(4+D.length),_,S;for(_=0;_<D.length;_++)S=D[_].flags,x[_+4]=S.dependsOn<<4|S.isDependedOn<<2|S.hasRedundancy;return P.box(P.types.sdtp,x)},P.stbl=function(A){return P.box(P.types.stbl,P.stsd(A),P.box(P.types.stts,P.STTS),P.box(P.types.stsc,P.STSC),P.box(P.types.stsz,P.STSZ),P.box(P.types.stco,P.STCO))},P.avc1=function(A){var D=[],x=[],_,S,d;for(_=0;_<A.sps.length;_++)S=A.sps[_],d=S.byteLength,D.push(d>>>8&255),D.push(d&255),D=D.concat(Array.prototype.slice.call(S));for(_=0;_<A.pps.length;_++)S=A.pps[_],d=S.byteLength,x.push(d>>>8&255),x.push(d&255),x=x.concat(Array.prototype.slice.call(S));var E=P.box(P.types.avcC,new Uint8Array([1,D[3],D[4],D[5],255,224|A.sps.length].concat(D).concat([A.pps.length]).concat(x))),p=A.width,h=A.height,a=A.pixelRatio[0],o=A.pixelRatio[1];return P.box(P.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,p>>8&255,p&255,h>>8&255,h&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,P.box(P.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),P.box(P.types.pasp,new Uint8Array([a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255])))},P.esds=function(A){var D=A.config.length;return new Uint8Array([0,0,0,0,3,23+D,0,1,0,4,15+D,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([D]).concat(A.config).concat([6,1,2]))},P.mp4a=function(A){var D=A.samplerate;return P.box(P.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,A.channelCount,0,16,0,0,0,0,D>>8&255,D&255,0,0]),P.box(P.types.esds,P.esds(A)))},P.mp3=function(A){var D=A.samplerate;return P.box(P.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,A.channelCount,0,16,0,0,0,0,D>>8&255,D&255,0,0]))},P.stsd=function(A){return A.type==="audio"?A.segmentCodec==="mp3"&&A.codec==="mp3"?P.box(P.types.stsd,P.STSD,P.mp3(A)):P.box(P.types.stsd,P.STSD,P.mp4a(A)):P.box(P.types.stsd,P.STSD,P.avc1(A))},P.tkhd=function(A){var D=A.id,x=A.duration*A.timescale,_=A.width,S=A.height,d=Math.floor(x/(C+1)),E=Math.floor(x%(C+1));return P.box(P.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,D>>24&255,D>>16&255,D>>8&255,D&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,_>>8&255,_&255,0,0,S>>8&255,S&255,0,0]))},P.traf=function(A,D){var x=P.sdtp(A),_=A.id,S=Math.floor(D/(C+1)),d=Math.floor(D%(C+1));return P.box(P.types.traf,P.box(P.types.tfhd,new Uint8Array([0,0,0,0,_>>24,_>>16&255,_>>8&255,_&255])),P.box(P.types.tfdt,new Uint8Array([1,0,0,0,S>>24,S>>16&255,S>>8&255,S&255,d>>24,d>>16&255,d>>8&255,d&255])),P.trun(A,x.length+16+20+8+16+8+8),x)},P.trak=function(A){return A.duration=A.duration||4294967295,P.box(P.types.trak,P.tkhd(A),P.mdia(A))},P.trex=function(A){var D=A.id;return P.box(P.types.trex,new Uint8Array([0,0,0,0,D>>24,D>>16&255,D>>8&255,D&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},P.trun=function(A,D){var x=A.samples||[],_=x.length,S=12+16*_,d=new Uint8Array(S),E,p,h,a,o,n;for(D+=8+S,d.set([A.type==="video"?1:0,0,15,1,_>>>24&255,_>>>16&255,_>>>8&255,_&255,D>>>24&255,D>>>16&255,D>>>8&255,D&255],0),E=0;E<_;E++)p=x[E],h=p.duration,a=p.size,o=p.flags,n=p.cts,d.set([h>>>24&255,h>>>16&255,h>>>8&255,h&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,o.degradPrio&240<<8,o.degradPrio&15,n>>>24&255,n>>>16&255,n>>>8&255,n&255],12+16*E);return P.box(P.types.trun,d)},P.initSegment=function(A){P.types||P.init();var D=P.moov(A),x=new Uint8Array(P.FTYP.byteLength+D.byteLength);return x.set(P.FTYP),x.set(D,P.FTYP.byteLength),x},P}();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;let M=L},"./src/remux/mp4-remuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>a,flushTextTrackMetadataCueSamples:()=>v,flushTextTrackUserdataCueSamples:()=>l,normalizePts:()=>o});var C=T("./src/polyfills/number.ts"),L=T("./src/remux/aac-helper.ts"),M=T("./src/remux/mp4-generator.ts"),P=T("./src/events.ts"),B=T("./src/errors.ts"),A=T("./src/utils/logger.ts"),D=T("./src/types/loader.ts"),x=T("./src/utils/timescale-conversion.ts");function _(){return _=Object.assign?Object.assign.bind():function(g){for(var c=1;c<arguments.length;c++){var m=arguments[c];for(var e in m)Object.prototype.hasOwnProperty.call(m,e)&&(g[e]=m[e])}return g},_.apply(this,arguments)}var S=10*1e3,d=1024,E=1152,p=null,h=null,a=function(){function g(m,e,r,t){if(t===void 0&&(t=""),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=m,this.config=e,this.typeSupported=r,this.ISGenerated=!1,p===null){var s=navigator.userAgent||"",y=s.match(/Chrome\/(\d+)/i);p=y?parseInt(y[1]):0}if(h===null){var f=navigator.userAgent.match(/Safari\/(\d+)/i);h=f?parseInt(f[1]):0}}var c=g.prototype;return c.destroy=function(){},c.resetTimeStamp=function(e){A.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},c.resetNextTimestamp=function(){A.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},c.resetInitSegment=function(){A.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},c.getVideoStartPts=function(e){var r=!1,t=e.reduce(function(s,y){var f=y.pts-s;return f<-4294967296?(r=!0,o(s,y.pts)):f>0?s:y.pts},e[0].pts);return r&&A.logger.debug("PTS rollover detected"),t},c.remux=function(e,r,t,s,y,f,b,R){var I,k,F,K,H,j,Y=y,Q=y,q=e.pid>-1,ne=r.pid>-1,te=r.samples.length,ae=e.samples.length>0,ue=b&&te>0||te>1,ce=(!q||ae)&&(!ne||ue)||this.ISGenerated||b;if(ce){this.ISGenerated||(F=this.generateIS(e,r,y));var le=this.isVideoContiguous,fe=-1,de;if(ue&&(fe=n(r.samples),!le&&this.config.forceKeyFrameOnDiscontinuity))if(j=!0,fe>0){A.logger.warn("[mp4-remuxer]: Dropped "+fe+" out of "+te+" video samples due to a missing keyframe");var xe=this.getVideoStartPts(r.samples);r.samples=r.samples.slice(fe),r.dropped+=fe,Q+=(r.samples[0].pts-xe)/r.inputTimeScale,de=Q}else fe===-1&&(A.logger.warn("[mp4-remuxer]: No keyframe found out of "+te+" video samples"),j=!1);if(this.ISGenerated){if(ae&&ue){var Ae=this.getVideoStartPts(r.samples),Ie=o(e.samples[0].pts,Ae)-Ae,Re=Ie/r.inputTimeScale;Y+=Math.max(0,Re),Q+=Math.max(0,-Re)}if(ae){if(e.samplerate||(A.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),F=this.generateIS(e,r,y)),k=this.remuxAudio(e,Y,this.isAudioContiguous,f,ne||ue||R===D.PlaylistLevelType.AUDIO?Q:void 0),ue){var Oe=k?k.endPTS-k.startPTS:0;r.inputTimeScale||(A.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),F=this.generateIS(e,r,y)),I=this.remuxVideo(r,Q,le,Oe)}}else ue&&(I=this.remuxVideo(r,Q,le,0));I&&(I.firstKeyFrame=fe,I.independent=fe!==-1,I.firstKeyFramePTS=de)}}return this.ISGenerated&&(t.samples.length&&(H=v(t,y,this._initPTS,this._initDTS)),s.samples.length&&(K=l(s,y,this._initPTS))),{audio:k,video:I,initSegment:F,independent:j,text:K,id3:H}},c.generateIS=function(e,r,t){var s=e.samples,y=r.samples,f=this.typeSupported,b={},R=!(0,C.isFiniteNumber)(this._initPTS),I="audio/mp4",k,F,K;if(R&&(k=F=1/0),e.config&&s.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":f.mpeg?(I="audio/mpeg",e.codec=""):f.mp3&&(e.codec="mp3");break}b.audio={id:"audio",container:I,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&f.mpeg?new Uint8Array(0):M.default.initSegment([e]),metadata:{channelCount:e.channelCount}},R&&(K=e.inputTimeScale,k=F=s[0].pts-Math.round(K*t))}if(r.sps&&r.pps&&y.length&&(r.timescale=r.inputTimeScale,b.video={id:"main",container:"video/mp4",codec:r.codec,initSegment:M.default.initSegment([r]),metadata:{width:r.width,height:r.height}},R)){K=r.inputTimeScale;var H=this.getVideoStartPts(y),j=Math.round(K*t);F=Math.min(F,o(y[0].dts,H)-j),k=Math.min(k,H-j)}if(Object.keys(b).length)return this.ISGenerated=!0,R&&(this._initPTS=k,this._initDTS=F),{tracks:b,initPTS:k,timescale:K}},c.remuxVideo=function(e,r,t,s){var y=e.inputTimeScale,f=e.samples,b=[],R=f.length,I=this._initPTS,k=this.nextAvcDts,F=8,K=this.videoSampleDuration,H,j,Y=Number.POSITIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,q=!1;if(!t||k===null){var ne=r*y,te=f[0].pts-o(f[0].dts,f[0].pts);k=ne-te}for(var ae=0;ae<R;ae++){var ue=f[ae];ue.pts=o(ue.pts-I,k),ue.dts=o(ue.dts-I,k),ue.dts<f[ae>0?ae-1:ae].dts&&(q=!0)}q&&f.sort(function(ut,wt){var ar=ut.dts-wt.dts,sr=ut.pts-wt.pts;return ar||sr}),H=f[0].dts,j=f[f.length-1].dts;var ce=j-H,le=ce?Math.round(ce/(R-1)):K||e.inputTimeScale/30;if(t){var fe=H-k,de=fe>le,xe=fe<-1;if((de||xe)&&(de?A.logger.warn("AVC: "+(0,x.toMsFromMpegTsClock)(fe,!0)+" ms ("+fe+"dts) hole between fragments detected, filling it"):A.logger.warn("AVC: "+(0,x.toMsFromMpegTsClock)(-fe,!0)+" ms ("+fe+"dts) overlapping between fragments detected"),!xe||k>f[0].pts)){H=k;var Ae=f[0].pts-fe;f[0].dts=H,f[0].pts=Ae,A.logger.log("Video: First PTS/DTS adjusted: "+(0,x.toMsFromMpegTsClock)(Ae,!0)+"/"+(0,x.toMsFromMpegTsClock)(H,!0)+", delta: "+(0,x.toMsFromMpegTsClock)(fe,!0)+" ms")}}H=Math.max(0,H);for(var Ie=0,Re=0,Oe=0;Oe<R;Oe++){for(var Pe=f[Oe],Ce=Pe.units,Le=Ce.length,ke=0,Be=0;Be<Le;Be++)ke+=Ce[Be].data.length;Re+=ke,Ie+=Le,Pe.length=ke,Pe.dts=Math.max(Pe.dts,H),Y=Math.min(Pe.pts,Y),Q=Math.max(Pe.pts,Q)}j=f[R-1].dts;var we=Re+4*Ie+8,Ye;try{Ye=new Uint8Array(we)}catch{this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:B.ErrorTypes.MUX_ERROR,details:B.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:we,reason:"fail allocating video mdat "+we});return}var Xe=new DataView(Ye.buffer);Xe.setUint32(0,we),Ye.set(M.default.types.mdat,4);for(var rt=!1,ze=Number.POSITIVE_INFINITY,it=Number.POSITIVE_INFINITY,nt=Number.NEGATIVE_INFINITY,Je=Number.NEGATIVE_INFINITY,Ne=0;Ne<R;Ne++){for(var Ke=f[Ne],Ze=Ke.units,ft=0,Me=0,qe=Ze.length;Me<qe;Me++){var et=Ze[Me],_t=et.data,mt=et.data.byteLength;Xe.setUint32(F,mt),F+=4,Ye.set(_t,F),F+=mt,ft+=4+mt}var pt=void 0;if(Ne<R-1)K=f[Ne+1].dts-Ke.dts,pt=f[Ne+1].pts-Ke.pts;else{var Rt=this.config,Tt=Ne>0?Ke.dts-f[Ne-1].dts:le;if(pt=Ne>0?Ke.pts-f[Ne-1].pts:le,Rt.stretchShortVideoTrack&&this.nextAudioPts!==null){var Gt=Math.floor(Rt.maxBufferHole*y),It=(s?Y+s*y:this.nextAudioPts)-Ke.pts;It>Gt?(K=It-Tt,K<0?K=Tt:rt=!0,A.logger.log("[mp4-remuxer]: It is approximately "+It/90+" ms to the next segment; using duration "+K/90+" ms for the last video frame.")):K=Tt}else K=Tt}var tr=Math.round(Ke.pts-Ke.dts);ze=Math.min(ze,K),nt=Math.max(nt,K),it=Math.min(it,pt),Je=Math.max(Je,pt),b.push(new i(Ke.key,K,ft,tr))}if(b.length){if(p){if(p<70){var Ot=b[0].flags;Ot.dependsOn=2,Ot.isNonSync=0}}else if(h&&Je-it<nt-ze&&le/nt<.025&&b[0].cts===0){A.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var St=H,lt=0,Ht=b.length;lt<Ht;lt++){var Ct=St+b[lt].duration,jt=St+b[lt].cts;if(lt<Ht-1){var Mt=Ct+b[lt+1].cts;b[lt].duration=Mt-jt}else b[lt].duration=lt?b[lt-1].duration:le;b[lt].cts=0,St=Ct}}}console.assert(K!==null,"mp4SampleDuration must be computed"),K=rt||!K?le:K,this.nextAvcDts=k=j+K,this.videoSampleDuration=K,this.isVideoContiguous=!0;var rr=M.default.moof(e.sequenceNumber++,H,_({},e,{samples:b})),ir="video",nr={data1:rr,data2:Ye,startPTS:Y/y,endPTS:(Q+K)/y,startDTS:H/y,endDTS:k/y,type:ir,hasAudio:!1,hasVideo:!0,nb:b.length,dropped:e.dropped};return e.samples=[],e.dropped=0,console.assert(Ye.length,"MDAT length must not be zero"),nr},c.remuxAudio=function(e,r,t,s,y){var f=e.inputTimeScale,b=e.samplerate?e.samplerate:f,R=f/b,I=e.segmentCodec==="aac"?d:E,k=I*R,F=this._initPTS,K=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,H=[],j=y!==void 0,Y=e.samples,Q=K?0:8,q=this.nextAudioPts||-1,ne=r*f;if(this.isAudioContiguous=t=t||Y.length&&q>0&&(s&&Math.abs(ne-q)<9e3||Math.abs(o(Y[0].pts-F,ne)-q)<20*k),Y.forEach(function(et){et.pts=o(et.pts-F,ne)}),!t||q<0){if(Y=Y.filter(function(et){return et.pts>=0}),!Y.length)return;y===0?q=0:s&&!j?q=Math.max(0,ne):q=Y[0].pts}if(e.segmentCodec==="aac")for(var te=this.config.maxAudioFramesDrift,ae=0,ue=q;ae<Y.length;ae++){var ce=Y[ae],le=ce.pts,fe=le-ue,de=Math.abs(1e3*fe/f);if(fe<=-te*k&&j)ae===0&&(A.logger.warn("Audio frame @ "+(le/f).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*fe/f)+" ms."),this.nextAudioPts=q=ue=le);else if(fe>=te*k&&de<S&&j){var xe=Math.round(fe/k);ue=le-xe*k,ue<0&&(xe--,ue+=k),ae===0&&(this.nextAudioPts=q=ue),A.logger.warn("[mp4-remuxer]: Injecting "+xe+" audio frame @ "+(ue/f).toFixed(3)+"s due to "+Math.round(1e3*fe/f)+" ms gap.");for(var Ae=0;Ae<xe;Ae++){var Ie=Math.max(ue,0),Re=L.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Re||(A.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Re=ce.unit.subarray()),Y.splice(ae,0,{unit:Re,pts:Ie}),ue+=k,ae++}}ce.pts=ue,ue+=k}for(var Oe=null,Pe=null,Ce,Le=0,ke=Y.length;ke--;)Le+=Y[ke].unit.byteLength;for(var Be=0,we=Y.length;Be<we;Be++){var Ye=Y[Be],Xe=Ye.unit,rt=Ye.pts;if(Pe!==null){var ze=H[Be-1];ze.duration=Math.round((rt-Pe)/R)}else if(t&&e.segmentCodec==="aac"&&(rt=q),Oe=rt,Le>0){Le+=Q;try{Ce=new Uint8Array(Le)}catch{this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:B.ErrorTypes.MUX_ERROR,details:B.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Le,reason:"fail allocating audio mdat "+Le});return}if(!K){var it=new DataView(Ce.buffer);it.setUint32(0,Le),Ce.set(M.default.types.mdat,4)}}else return;Ce.set(Xe,Q);var nt=Xe.byteLength;Q+=nt,H.push(new i(!0,I,nt,0)),Pe=rt}var Je=H.length;if(!!Je){var Ne=H[H.length-1];this.nextAudioPts=q=Pe+R*Ne.duration;var Ke=K?new Uint8Array(0):M.default.moof(e.sequenceNumber++,Oe/R,_({},e,{samples:H}));e.samples=[];var Ze=Oe/f,ft=q/f,Me="audio",qe={data1:Ke,data2:Ce,startPTS:Ze,endPTS:ft,startDTS:Ze,endDTS:ft,type:Me,hasAudio:!0,hasVideo:!1,nb:Je};return this.isAudioContiguous=!0,console.assert(Ce.length,"MDAT length must not be zero"),qe}},c.remuxEmptyAudio=function(e,r,t,s){var y=e.inputTimeScale,f=e.samplerate?e.samplerate:y,b=y/f,R=this.nextAudioPts,I=(R!==null?R:s.startDTS*y)+this._initDTS,k=s.endDTS*y+this._initDTS,F=b*d,K=Math.ceil((k-I)/F),H=L.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(A.logger.warn("[mp4-remuxer]: remux empty Audio"),!H){A.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var j=[],Y=0;Y<K;Y++){var Q=I+Y*F;j.push({unit:H,pts:Q,dts:Q})}return e.samples=j,this.remuxAudio(e,r,t,!1)},g}();function o(g,c){var m;if(c===null)return g;for(c<g?m=-8589934592:m=8589934592;Math.abs(g-c)>4294967296;)g+=m;return g}function n(g){for(var c=0;c<g.length;c++)if(g[c].key)return c;return-1}function v(g,c,m,e){var r=g.samples.length;if(!!r){for(var t=g.inputTimeScale,s=0;s<r;s++){var y=g.samples[s];y.pts=o(y.pts-m,c*t)/t,y.dts=o(y.dts-e,c*t)/t}var f=g.samples;return g.samples=[],{samples:f}}}function l(g,c,m){var e=g.samples.length;if(!!e){for(var r=g.inputTimeScale,t=0;t<e;t++){var s=g.samples[t];s.pts=o(s.pts-m,c*r)/r}g.samples.sort(function(f,b){return f.pts-b.pts});var y=g.samples;return g.samples=[],{samples:y}}}var i=function(c,m,e,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=m,this.size=e,this.cts=r,this.flags=new u(c)},u=function(c){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=c?2:1,this.isNonSync=c?0:1}},"./src/remux/passthrough-remuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>x});var C=T("./src/polyfills/number.ts"),L=T("./src/remux/mp4-remuxer.ts"),M=T("./src/utils/mp4-tools.ts"),P=T("./src/loader/fragment.ts"),B=T("./src/utils/logger.ts"),A=function(){function _(){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 S=_.prototype;return S.destroy=function(){},S.resetTimeStamp=function(E){this.initPTS=E,this.lastEndTime=null},S.resetNextTimestamp=function(){this.lastEndTime=null},S.resetInitSegment=function(E,p,h,a){this.audioCodec=p,this.videoCodec=h,this.generateInitSegment((0,M.patchEncyptionData)(E,a)),this.emitInitSegment=!0},S.generateInitSegment=function(E){var p=this.audioCodec,h=this.videoCodec;if(!E||!E.byteLength){this.initTracks=void 0,this.initData=void 0;return}var a=this.initData=(0,M.parseInitSegment)(E);p||(p=D(a.audio,P.ElementaryStreamTypes.AUDIO)),h||(h=D(a.video,P.ElementaryStreamTypes.VIDEO));var o={};a.audio&&a.video?o.audiovideo={container:"video/mp4",codec:p+","+h,initSegment:E,id:"main"}:a.audio?o.audio={container:"audio/mp4",codec:p,initSegment:E,id:"audio"}:a.video?o.video={container:"video/mp4",codec:h,initSegment:E,id:"main"}:B.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},S.remux=function(E,p,h,a,o){var n,v=this.initPTS,l=this.lastEndTime,i={audio:void 0,video:void 0,text:a,id3:h,initSegment:void 0};(0,C.isFiniteNumber)(l)||(l=this.lastEndTime=o||0);var u=p.samples;if(!u||!u.length)return i;var g={initPTS:void 0,timescale:1},c=this.initData;if((!c||!c.length)&&(this.generateInitSegment(u),c=this.initData),!c||!c.length)return B.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(g.tracks=this.initTracks,this.emitInitSegment=!1);var m=(0,M.getStartDTS)(c,u);(0,C.isFiniteNumber)(v)||(this.initPTS=g.initPTS=v=m-o);var e=(0,M.getDuration)(u,c),r=E?m-v:l,t=r+e;(0,M.offsetStartDTS)(c,u,v),e>0?this.lastEndTime=t:(B.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var s=!!c.audio,y=!!c.video,f="";s&&(f+="audio"),y&&(f+="video");var b={data1:u,startPTS:r,startDTS:r,endPTS:t,endDTS:t,type:f,hasAudio:s,hasVideo:y,nb:1,dropped:0};i.audio=b.type==="audio"?b:void 0,i.video=b.type!=="audio"?b:void 0,i.initSegment=g;var R=(n=this.initPTS)!=null?n:0;return i.id3=(0,L.flushTextTrackMetadataCueSamples)(h,o,R,R),a.samples.length&&(i.text=(0,L.flushTextTrackUserdataCueSamples)(a,o,R)),i},_}();function D(_,S){var d=_==null?void 0:_.codec;return d&&d.length>4?d:d==="hvc1"||d==="hev1"?"hvc1.1.c.L120.90":d==="av01"?"av01.0.04M.08":d==="avc1"||S===P.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}let x=A},"./src/task-loop.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>C});var C=function(){function L(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var M=L.prototype;return M.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},M.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},M.onHandlerDestroyed=function(){},M.hasInterval=function(){return!!this._tickInterval},M.hasNextTick=function(){return!!this._tickTimer},M.setInterval=function(B){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,B),!0)},M.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},M.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},M.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},M.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},M.doTick=function(){},L}()},"./src/types/cmcd.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{CMCDObjectType:()=>L,CMCDStreamType:()=>P,CMCDStreamingFormat:()=>M,CMCDVersion:()=>C});var C=1,L;(function(B){B.MANIFEST="m",B.AUDIO="a",B.VIDEO="v",B.MUXED="av",B.INIT="i",B.CAPTION="c",B.TIMED_TEXT="tt",B.KEY="k",B.OTHER="o"})(L||(L={}));var M;(function(B){B.DASH="d",B.HLS="h",B.SMOOTH="s",B.OTHER="o"})(M||(M={}));var P;(function(B){B.VOD="v",B.LIVE="l"})(P||(P={}))},"./src/types/demuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{MetadataSchema:()=>C});var C;(function(L){L.audioId3="org.id3",L.dateRange="com.apple.quicktime.HLS",L.emsg="https://aomedia.org/emsg/ID3"})(C||(C={}))},"./src/types/level.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{HdcpLevels:()=>B,HlsSkip:()=>A,HlsUrlParameters:()=>x,Level:()=>_,getSkipValue:()=>D});function C(S,d){for(var E=0;E<d.length;E++){var p=d[E];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(S,M(p.key),p)}}function L(S,d,E){return d&&C(S.prototype,d),E&&C(S,E),Object.defineProperty(S,"prototype",{writable:!1}),S}function M(S){var d=P(S,"string");return typeof d=="symbol"?d:String(d)}function P(S,d){if(typeof S!="object"||S===null)return S;var E=S[Symbol.toPrimitive];if(E!==void 0){var p=E.call(S,d||"default");if(typeof p!="object")return p;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(S)}var B=["NONE","TYPE-0","TYPE-1","TYPE-2",null],A;(function(S){S.No="",S.Yes="YES",S.v2="v2"})(A||(A={}));function D(S,d){var E=S.canSkipUntil,p=S.canSkipDateRanges,h=S.endSN,a=d!==void 0?d-h:0;return E&&a<E?p?A.v2:A.Yes:A.No}var x=function(){function S(E,p,h){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=E,this.part=p,this.skip=h}var d=S.prototype;return d.addDirectives=function(p){var h=new self.URL(p);return this.msn!==void 0&&h.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&h.searchParams.set("_HLS_part",this.part.toString()),this.skip&&h.searchParams.set("_HLS_skip",this.skip),h.href},S}(),_=function(){function S(d){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=[d.url],this.attrs=d.attrs,this.bitrate=d.bitrate,d.details&&(this.details=d.details),this.id=d.id||0,this.name=d.name,this.width=d.width||0,this.height=d.height||0,this.audioCodec=d.audioCodec,this.videoCodec=d.videoCodec,this.unknownCodecs=d.unknownCodecs,this.codecSet=[d.videoCodec,d.audioCodec].filter(function(E){return E}).join(",").replace(/\.[^.,]+/g,"")}return L(S,[{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(E){var p=E%this.url.length;this._urlId!==p&&(this.details=void 0,this._urlId=p)}}]),S}()},"./src/types/loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{PlaylistContextType:()=>C,PlaylistLevelType:()=>L});var C;(function(M){M.MANIFEST="manifest",M.LEVEL="level",M.AUDIO_TRACK="audioTrack",M.SUBTITLE_TRACK="subtitleTrack"})(C||(C={}));var L;(function(M){M.MAIN="main",M.AUDIO="audio",M.SUBTITLE="subtitle"})(L||(L={}))},"./src/types/transmuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{ChunkMetadata:()=>C});var C=function(P,B,A,D,x,_){D===void 0&&(D=0),x===void 0&&(x=-1),_===void 0&&(_=!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=P,this.sn=B,this.id=A,this.size=D,this.part=x,this.partial=_};function L(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{AttrList:()=>M});var C=/^(\d+)x(\d+)$/,L=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,M=function(){function P(A){typeof A=="string"&&(A=P.parseAttrList(A));for(var D in A)A.hasOwnProperty(D)&&(this[D]=A[D])}var B=P.prototype;return B.decimalInteger=function(D){var x=parseInt(this[D],10);return x>Number.MAX_SAFE_INTEGER?1/0:x},B.hexadecimalInteger=function(D){if(this[D]){var x=(this[D]||"0x").slice(2);x=(x.length&1?"0":"")+x;for(var _=new Uint8Array(x.length/2),S=0;S<x.length/2;S++)_[S]=parseInt(x.slice(S*2,S*2+2),16);return _}else return null},B.hexadecimalIntegerAsNumber=function(D){var x=parseInt(this[D],16);return x>Number.MAX_SAFE_INTEGER?1/0:x},B.decimalFloatingPoint=function(D){return parseFloat(this[D])},B.optionalFloat=function(D,x){var _=this[D];return _?parseFloat(_):x},B.enumeratedString=function(D){return this[D]},B.bool=function(D){return this[D]==="YES"},B.decimalResolution=function(D){var x=C.exec(this[D]);if(x!==null)return{width:parseInt(x[1],10),height:parseInt(x[2],10)}},P.parseAttrList=function(D){var x,_={},S='"';for(L.lastIndex=0;(x=L.exec(D))!==null;){var d=x[2];d.indexOf(S)===0&&d.lastIndexOf(S)===d.length-1&&(d=d.slice(1,-1)),_[x[1]]=d}return _},P}()},"./src/utils/binary-search.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>L});var C={search:function(P,B){for(var A=0,D=P.length-1,x=null,_=null;A<=D;){x=(A+D)/2|0,_=P[x];var S=B(_);if(S>0)A=x+1;else if(S<0)D=x-1;else return _}return null}};let L=C},"./src/utils/buffer-helper.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{BufferHelper:()=>M});var C=T("./src/utils/logger.ts"),L={length:0,start:function(){return 0},end:function(){return 0}},M=function(){function P(){}return P.isBuffered=function(A,D){try{if(A){for(var x=P.getBuffered(A),_=0;_<x.length;_++)if(D>=x.start(_)&&D<=x.end(_))return!0}}catch{}return!1},P.bufferInfo=function(A,D,x){try{if(A){var _=P.getBuffered(A),S=[],d;for(d=0;d<_.length;d++)S.push({start:_.start(d),end:_.end(d)});return this.bufferedInfo(S,D,x)}}catch{}return{len:0,start:D,end:D,nextStart:void 0}},P.bufferedInfo=function(A,D,x){D=Math.max(0,D),A.sort(function(i,u){var g=i.start-u.start;return g||u.end-i.end});var _=[];if(x)for(var S=0;S<A.length;S++){var d=_.length;if(d){var E=_[d-1].end;A[S].start-E<x?A[S].end>E&&(_[d-1].end=A[S].end):_.push(A[S])}else _.push(A[S])}else _=A;for(var p=0,h,a=D,o=D,n=0;n<_.length;n++){var v=_[n].start,l=_[n].end;if(D+x>=v&&D<l)a=v,o=l,p=o-D;else if(D+x<v){h=v;break}}return{len:p,start:a||0,end:o||0,nextStart:h}},P.getBuffered=function(A){try{return A.buffered}catch(D){return C.logger.log("failed to get media.buffered",D),L}},P}()},"./src/utils/cea-608-parser.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{CaptionScreen:()=>n,Row:()=>o,default:()=>c});var C=T("./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},M=function(e){var r=e;return L.hasOwnProperty(e)&&(r=L[e]),String.fromCharCode(r)},P=15,B=100,A={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},D={17:2,18:4,21:6,22:8,23:10,19:13,20:15},x={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},_={25:2,26:4,29:6,30:8,31:10,27:13,28:15},S=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],d;(function(m){m[m.ERROR=0]="ERROR",m[m.TEXT=1]="TEXT",m[m.WARNING=2]="WARNING",m[m.INFO=2]="INFO",m[m.DEBUG=3]="DEBUG",m[m.DATA=3]="DATA"})(d||(d={}));var E=function(){function m(){this.time=null,this.verboseLevel=d.ERROR}var e=m.prototype;return e.log=function(t,s){if(this.verboseLevel>=t){var y=typeof s=="function"?s():s;C.logger.log(this.time+" ["+t+"] "+y)}},m}(),p=function(e){for(var r=[],t=0;t<e.length;t++)r.push(e[t].toString(16));return r},h=function(){function m(r,t,s,y,f){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=r||"white",this.underline=t||!1,this.italics=s||!1,this.background=y||"black",this.flash=f||!1}var e=m.prototype;return e.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},e.setStyles=function(t){for(var s=["foreground","underline","italics","background","flash"],y=0;y<s.length;y++){var f=s[y];t.hasOwnProperty(f)&&(this[f]=t[f])}},e.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},e.equals=function(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash},e.copy=function(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash},e.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},m}(),a=function(){function m(r,t,s,y,f,b){this.uchar=void 0,this.penState=void 0,this.uchar=r||" ",this.penState=new h(t,s,y,f,b)}var e=m.prototype;return e.reset=function(){this.uchar=" ",this.penState.reset()},e.setChar=function(t,s){this.uchar=t,this.penState.copy(s)},e.setPenState=function(t){this.penState.copy(t)},e.equals=function(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)},e.copy=function(t){this.uchar=t.uchar,this.penState.copy(t.penState)},e.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},m}(),o=function(){function m(r){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var t=0;t<B;t++)this.chars.push(new a);this.logger=r,this.pos=0,this.currPenState=new h}var e=m.prototype;return e.equals=function(t){for(var s=!0,y=0;y<B;y++)if(!this.chars[y].equals(t.chars[y])){s=!1;break}return s},e.copy=function(t){for(var s=0;s<B;s++)this.chars[s].copy(t.chars[s])},e.isEmpty=function(){for(var t=!0,s=0;s<B;s++)if(!this.chars[s].isEmpty()){t=!1;break}return t},e.setCursor=function(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(d.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>B&&(this.logger.log(d.DEBUG,"Too large cursor position "+this.pos),this.pos=B)},e.moveCursor=function(t){var s=this.pos+t;if(t>1)for(var y=this.pos+1;y<s+1;y++)this.chars[y].setPenState(this.currPenState);this.setCursor(s)},e.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},e.insertChar=function(t){var s=this;t>=144&&this.backSpace();var y=M(t);if(this.pos>=B){this.logger.log(d.ERROR,function(){return"Cannot insert "+t.toString(16)+" ("+y+") at position "+s.pos+". Skipping it!"});return}this.chars[this.pos].setChar(y,this.currPenState),this.moveCursor(1)},e.clearFromPos=function(t){var s;for(s=t;s<B;s++)this.chars[s].reset()},e.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},e.clearToEndOfRow=function(){this.clearFromPos(this.pos)},e.getTextString=function(){for(var t=[],s=!0,y=0;y<B;y++){var f=this.chars[y].uchar;f!==" "&&(s=!1),t.push(f)}return s?"":t.join("")},e.setPenStyles=function(t){this.currPenState.setStyles(t);var s=this.chars[this.pos];s.setPenState(this.currPenState)},m}(),n=function(){function m(r){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var t=0;t<P;t++)this.rows.push(new o(r));this.logger=r,this.currRow=P-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var e=m.prototype;return e.reset=function(){for(var t=0;t<P;t++)this.rows[t].clear();this.currRow=P-1},e.equals=function(t){for(var s=!0,y=0;y<P;y++)if(!this.rows[y].equals(t.rows[y])){s=!1;break}return s},e.copy=function(t){for(var s=0;s<P;s++)this.rows[s].copy(t.rows[s])},e.isEmpty=function(){for(var t=!0,s=0;s<P;s++)if(!this.rows[s].isEmpty()){t=!1;break}return t},e.backSpace=function(){var t=this.rows[this.currRow];t.backSpace()},e.clearToEndOfRow=function(){var t=this.rows[this.currRow];t.clearToEndOfRow()},e.insertChar=function(t){var s=this.rows[this.currRow];s.insertChar(t)},e.setPen=function(t){var s=this.rows[this.currRow];s.setPenStyles(t)},e.moveCursor=function(t){var s=this.rows[this.currRow];s.moveCursor(t)},e.setCursor=function(t){this.logger.log(d.INFO,"setCursor: "+t);var s=this.rows[this.currRow];s.setCursor(t)},e.setPAC=function(t){this.logger.log(d.INFO,function(){return"pacData = "+JSON.stringify(t)});var s=t.row-1;if(this.nrRollUpRows&&s<this.nrRollUpRows-1&&(s=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==s){for(var y=0;y<P;y++)this.rows[y].clear();var f=this.currRow+1-this.nrRollUpRows,b=this.lastOutputScreen;if(b){var R=b.rows[f].cueStartTime,I=this.logger.time;if(R&&I!==null&&R<I)for(var k=0;k<this.nrRollUpRows;k++)this.rows[s-this.nrRollUpRows+k+1].copy(b.rows[f+k])}}this.currRow=s;var F=this.rows[this.currRow];if(t.indent!==null){var K=t.indent,H=Math.max(K-1,0);F.setCursor(t.indent),t.color=F.chars[H].penState.foreground}var j={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(j)},e.setBkgData=function(t){this.logger.log(d.INFO,function(){return"bkgData = "+JSON.stringify(t)}),this.backSpace(),this.setPen(t),this.insertChar(32)},e.setRollUpRows=function(t){this.nrRollUpRows=t},e.rollUp=function(){var t=this;if(this.nrRollUpRows===null){this.logger.log(d.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(d.TEXT,function(){return t.getDisplayText()});var s=this.currRow+1-this.nrRollUpRows,y=this.rows.splice(s,1)[0];y.clear(),this.rows.splice(this.currRow,0,y),this.logger.log(d.INFO,"Rolling up")},e.getDisplayText=function(t){t=t||!1;for(var s=[],y="",f=-1,b=0;b<P;b++){var R=this.rows[b].getTextString();R&&(f=b+1,t?s.push("Row "+f+": '"+R+"'"):s.push(R.trim()))}return s.length>0&&(t?y="["+s.join(" | ")+"]":y=s.join(`
22
+ `)),y},e.getTextAndFormat=function(){return this.rows},m}(),v=function(){function m(r,t,s){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=r,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new n(s),this.nonDisplayedMemory=new n(s),this.lastOutputScreen=new n(s),this.currRollUpRow=this.displayedMemory.rows[P-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=s}var e=m.prototype;return e.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[P-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},e.getHandler=function(){return this.outputFilter},e.setHandler=function(t){this.outputFilter=t},e.setPAC=function(t){this.writeScreen.setPAC(t)},e.setBkgData=function(t){this.writeScreen.setBkgData(t)},e.setMode=function(t){t!==this.mode&&(this.mode=t,this.logger.log(d.INFO,function(){return"MODE="+t}),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=t)},e.insertChars=function(t){for(var s=this,y=0;y<t.length;y++)this.writeScreen.insertChar(t[y]);var f=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(d.INFO,function(){return f+": "+s.writeScreen.getDisplayText(!0)}),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(d.TEXT,function(){return"DISPLAYED: "+s.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},e.ccRCL=function(){this.logger.log(d.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},e.ccBS=function(){this.logger.log(d.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},e.ccAOF=function(){},e.ccAON=function(){},e.ccDER=function(){this.logger.log(d.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},e.ccRU=function(t){this.logger.log(d.INFO,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)},e.ccFON=function(){this.logger.log(d.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},e.ccRDC=function(){this.logger.log(d.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},e.ccTR=function(){this.logger.log(d.INFO,"TR"),this.setMode("MODE_TEXT")},e.ccRTD=function(){this.logger.log(d.INFO,"RTD"),this.setMode("MODE_TEXT")},e.ccEDM=function(){this.logger.log(d.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},e.ccCR=function(){this.logger.log(d.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},e.ccENM=function(){this.logger.log(d.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},e.ccEOC=function(){var t=this;if(this.logger.log(d.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(d.TEXT,function(){return"DISP: "+t.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},e.ccTO=function(t){this.logger.log(d.INFO,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)},e.ccMIDROW=function(t){var s={flash:!1};if(s.underline=t%2===1,s.italics=t>=46,s.italics)s.foreground="white";else{var y=Math.floor(t/2)-16,f=["white","green","blue","cyan","red","yellow","magenta"];s.foreground=f[y]}this.logger.log(d.INFO,"MIDROW: "+JSON.stringify(s)),this.writeScreen.setPen(s)},e.outputDataUpdate=function(t){t===void 0&&(t=!1);var s=this.logger.time;s!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=s:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,s,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:s),this.lastOutputScreen.copy(this.displayedMemory))},e.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},m}(),l=function(){function m(r,t,s){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var y=new E;this.channels=[null,new v(r,t,y),new v(r+1,s,y)],this.cmdHistory=g(),this.logger=y}var e=m.prototype;return e.getHandler=function(t){return this.channels[t].getHandler()},e.setHandler=function(t,s){this.channels[t].setHandler(s)},e.addData=function(t,s){var y,f,b,R=!1;this.logger.time=t;for(var I=0;I<s.length;I+=2)if(f=s[I]&127,b=s[I+1]&127,!(f===0&&b===0)){if(this.logger.log(d.DATA,"["+p([s[I],s[I+1]])+"] -> ("+p([f,b])+")"),y=this.parseCmd(f,b),y||(y=this.parseMidrow(f,b)),y||(y=this.parsePAC(f,b)),y||(y=this.parseBackgroundAttributes(f,b)),!y&&(R=this.parseChars(f,b),R)){var k=this.currentChannel;if(k&&k>0){var F=this.channels[k];F.insertChars(R)}else this.logger.log(d.WARNING,"No channel found yet. TEXT-MODE?")}!y&&!R&&this.logger.log(d.WARNING,"Couldn't parse cleaned data "+p([f,b])+" orig: "+p([s[I],s[I+1]]))}},e.parseCmd=function(t,s){var y=this.cmdHistory,f=(t===20||t===28||t===21||t===29)&&s>=32&&s<=47,b=(t===23||t===31)&&s>=33&&s<=35;if(!(f||b))return!1;if(u(t,s,y))return i(null,null,y),this.logger.log(d.DEBUG,"Repeated command ("+p([t,s])+") is dropped"),!0;var R=t===20||t===21||t===23?1:2,I=this.channels[R];return t===20||t===21||t===28||t===29?s===32?I.ccRCL():s===33?I.ccBS():s===34?I.ccAOF():s===35?I.ccAON():s===36?I.ccDER():s===37?I.ccRU(2):s===38?I.ccRU(3):s===39?I.ccRU(4):s===40?I.ccFON():s===41?I.ccRDC():s===42?I.ccTR():s===43?I.ccRTD():s===44?I.ccEDM():s===45?I.ccCR():s===46?I.ccENM():s===47&&I.ccEOC():I.ccTO(s-32),i(t,s,y),this.currentChannel=R,!0},e.parseMidrow=function(t,s){var y=0;if((t===17||t===25)&&s>=32&&s<=47){if(t===17?y=1:y=2,y!==this.currentChannel)return this.logger.log(d.ERROR,"Mismatch channel in midrow parsing"),!1;var f=this.channels[y];return f?(f.ccMIDROW(s),this.logger.log(d.DEBUG,"MIDROW ("+p([t,s])+")"),!0):!1}return!1},e.parsePAC=function(t,s){var y,f=this.cmdHistory,b=(t>=17&&t<=23||t>=25&&t<=31)&&s>=64&&s<=127,R=(t===16||t===24)&&s>=64&&s<=95;if(!(b||R))return!1;if(u(t,s,f))return i(null,null,f),!0;var I=t<=23?1:2;s>=64&&s<=95?y=I===1?A[t]:x[t]:y=I===1?D[t]:_[t];var k=this.channels[I];return k?(k.setPAC(this.interpretPAC(y,s)),i(t,s,f),this.currentChannel=I,!0):!1},e.interpretPAC=function(t,s){var y,f={color:null,italics:!1,indent:null,underline:!1,row:t};return s>95?y=s-96:y=s-64,f.underline=(y&1)===1,y<=13?f.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(y/2)]:y<=15?(f.italics=!0,f.color="white"):f.indent=Math.floor((y-16)/2)*4,f},e.parseChars=function(t,s){var y,f=null,b=null;if(t>=25?(y=2,b=t-8):(y=1,b=t),b>=17&&b<=19){var R;b===17?R=s+80:b===18?R=s+112:R=s+144,this.logger.log(d.INFO,"Special char '"+M(R)+"' in channel "+y),f=[R]}else t>=32&&t<=127&&(f=s===0?[t]:[t,s]);if(f){var I=p(f);this.logger.log(d.DEBUG,"Char codes = "+I.join(",")),i(t,s,this.cmdHistory)}return f},e.parseBackgroundAttributes=function(t,s){var y=(t===16||t===24)&&s>=32&&s<=47,f=(t===23||t===31)&&s>=45&&s<=47;if(!(y||f))return!1;var b,R={};t===16||t===24?(b=Math.floor((s-32)/2),R.background=S[b],s%2===1&&(R.background=R.background+"_semi")):s===45?R.background="transparent":(R.foreground="black",s===47&&(R.underline=!0));var I=t<=23?1:2,k=this.channels[I];return k.setBkgData(R),i(t,s,this.cmdHistory),!0},e.reset=function(){for(var t=0;t<Object.keys(this.channels).length;t++){var s=this.channels[t];s&&s.reset()}this.cmdHistory=g()},e.cueSplitAtTime=function(t){for(var s=0;s<this.channels.length;s++){var y=this.channels[s];y&&y.cueSplitAtTime(t)}},m}();function i(m,e,r){r.a=m,r.b=e}function u(m,e,r){return r.a===m&&r.b===e}function g(){return{a:null,b:null}}let c=l},"./src/utils/codecs.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{isCodecSupportedInMp4:()=>M,isCodecType:()=>L});var C={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,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,dva1:!0,dvav:!0,dvh1:!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(P,B){var A=C[B];return!!A&&A[P.slice(0,4)]===!0}function M(P,B){return MediaSource.isTypeSupported((B||"video")+'/mp4;codecs="'+P+'"')}},"./src/utils/cues.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>A});var C=T("./src/utils/vttparser.ts"),L=T("./src/utils/webvtt-parser.ts"),M=T("./src/utils/texttrack-utils.ts"),P=/\s/,B={newCue:function(x,_,S,d){for(var E=[],p,h,a,o,n,v=self.VTTCue||self.TextTrackCue,l=0;l<d.rows.length;l++)if(p=d.rows[l],a=!0,o=0,n="",!p.isEmpty()){for(var i=0;i<p.chars.length;i++)P.test(p.chars[i].uchar)&&a?o++:(n+=p.chars[i].uchar,a=!1);p.cueStartTime=_,_===S&&(S+=1e-4),o>=16?o--:o++;var u=(0,C.fixLineBreaks)(n.trim()),g=(0,L.generateCueId)(_,S,u);(!x||!x.cues||!x.cues.getCueById(g))&&(h=new v(_,S,u),h.id=g,h.line=l+1,h.align="left",h.position=10+Math.min(80,Math.floor(o*8/32)*10),E.push(h))}return x&&E.length&&(E.sort(function(c,m){return c.line==="auto"||m.line==="auto"?0:c.line>8&&m.line>8?m.line-c.line:c.line-m.line}),E.forEach(function(c){return(0,M.addCueToTrack)(x,c)})),E}};let A=B},"./src/utils/discontinuities.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{adjustSlidingStart:()=>x,alignMediaPlaylistByPDT:()=>E,alignPDT:()=>d,alignStream:()=>_,findDiscontinuousReferenceFrag:()=>A,findFirstFragWithCC:()=>P,shouldAlignOnDiscontinuities:()=>B});var C=T("./src/polyfills/number.ts"),L=T("./src/utils/logger.ts"),M=T("./src/controller/level-helper.ts");function P(p,h){for(var a=null,o=0,n=p.length;o<n;o++){var v=p[o];if(v&&v.cc===h){a=v;break}}return a}function B(p,h,a){return!!(h.details&&(a.endCC>a.startCC||p&&p.cc<a.startCC))}function A(p,h,a){a===void 0&&(a=0);var o=p.fragments,n=h.fragments;if(!n.length||!o.length){L.logger.log("No fragments to align");return}var v=P(o,n[0].cc);if(!v||v&&!v.startPTS){L.logger.log("No frag in previous level to align on");return}return v}function D(p,h){if(p){var a=p.start+h;p.start=p.startPTS=a,p.endPTS=a+p.duration}}function x(p,h){for(var a=h.fragments,o=0,n=a.length;o<n;o++)D(a[o],p);h.fragmentHint&&D(h.fragmentHint,p),h.alignedSliding=!0}function _(p,h,a){!h||(S(p,a,h),!a.alignedSliding&&h.details&&d(a,h.details),!a.alignedSliding&&h.details&&!a.skippedSegments&&(0,M.adjustSliding)(h.details,a))}function S(p,h,a){if(B(p,a,h)){var o=A(a.details,h);o&&(0,C.isFiniteNumber)(o.start)&&(L.logger.log("Adjusting PTS using last level due to CC increase within current level "+h.url),x(o.start,h))}}function d(p,h){if(!(!h.fragments.length||!p.hasProgramDateTime||!h.hasProgramDateTime)){var a=h.fragments[0].programDateTime,o=p.fragments[0].programDateTime,n=(o-a)/1e3+h.fragments[0].start;n&&(0,C.isFiniteNumber)(n)&&(L.logger.log("Adjusting PTS using programDateTime delta "+(o-a)+"ms, sliding:"+n.toFixed(3)+" "+p.url+" "),x(n,p))}}function E(p,h){if(!(!p.hasProgramDateTime||!h.hasProgramDateTime)){var a=p.fragments,o=h.fragments;if(!(!a.length||!o.length)){var n=Math.round(o.length/2)-1,v=o[n],l=P(a,v.cc)||a[Math.round(a.length/2)-1],i=v.programDateTime,u=l.programDateTime;if(!(i===null||u===null)){var g=(u-i)/1e3-(l.start-v.start);x(g,p)}}}}},"./src/utils/ewma-bandwidth-estimator.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>M});var C=T("./src/utils/ewma.ts"),L=function(){function P(A,D,x){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=x,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new C.default(A),this.fast_=new C.default(D)}var B=P.prototype;return B.update=function(D,x){var _=this.slow_,S=this.fast_;this.slow_.halfLife!==D&&(this.slow_=new C.default(D,_.getEstimate(),_.getTotalWeight())),this.fast_.halfLife!==x&&(this.fast_=new C.default(x,S.getEstimate(),S.getTotalWeight()))},B.sample=function(D,x){D=Math.max(D,this.minDelayMs_);var _=8*x,S=D/1e3,d=_/S;this.fast_.sample(S,d),this.slow_.sample(S,d)},B.canEstimate=function(){var D=this.fast_;return D&&D.getTotalWeight()>=this.minWeight_},B.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},B.destroy=function(){},P}();let M=L},"./src/utils/ewma.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>L});var C=function(){function M(B,A,D){A===void 0&&(A=0),D===void 0&&(D=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=B,this.alpha_=B?Math.exp(Math.log(.5)/B):0,this.estimate_=A,this.totalWeight_=D}var P=M.prototype;return P.sample=function(A,D){var x=Math.pow(this.alpha_,A);this.estimate_=D*(1-x)+x*this.estimate_,this.totalWeight_+=A},P.getTotalWeight=function(){return this.totalWeight_},P.getEstimate=function(){if(this.alpha_){var A=1-Math.pow(this.alpha_,this.totalWeight_);if(A)return this.estimate_/A}return this.estimate_},M}();let L=C},"./src/utils/fetch-loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>n,fetchSupported:()=>E});var C=T("./src/polyfills/number.ts"),L=T("./src/loader/load-stats.ts"),M=T("./src/demux/chunk-cache.ts");function P(v,l){v.prototype=Object.create(l.prototype),v.prototype.constructor=v,_(v,l)}function B(v){var l=typeof Map=="function"?new Map:void 0;return B=function(u){if(u===null||!x(u))return u;if(typeof u!="function")throw new TypeError("Super expression must either be null or a function");if(typeof l!="undefined"){if(l.has(u))return l.get(u);l.set(u,g)}function g(){return A(u,arguments,S(this).constructor)}return g.prototype=Object.create(u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),_(g,u)},B(v)}function A(v,l,i){return D()?A=Reflect.construct.bind():A=function(g,c,m){var e=[null];e.push.apply(e,c);var r=Function.bind.apply(g,e),t=new r;return m&&_(t,m.prototype),t},A.apply(null,arguments)}function D(){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 x(v){return Function.toString.call(v).indexOf("[native code]")!==-1}function _(v,l){return _=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,g){return u.__proto__=g,u},_(v,l)}function S(v){return S=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},S(v)}function d(){return d=Object.assign?Object.assign.bind():function(v){for(var l=1;l<arguments.length;l++){var i=arguments[l];for(var u in i)Object.prototype.hasOwnProperty.call(i,u)&&(v[u]=i[u])}return v},d.apply(this,arguments)}function E(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var p=function(){function v(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||a,this.controller=new self.AbortController,this.stats=new L.LoadStats}var l=v.prototype;return l.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},l.abortInternal=function(){var u=this.response;(!u||!u.ok)&&(this.stats.aborted=!0,this.controller.abort())},l.abort=function(){var u;this.abortInternal(),(u=this.callbacks)!==null&&u!==void 0&&u.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},l.load=function(u,g,c){var m=this,e=this.stats;if(e.loading.start)throw new Error("Loader can only be used once.");e.loading.start=self.performance.now();var r=h(u,this.controller.signal),t=c.onProgress,s=u.responseType==="arraybuffer",y=s?"byteLength":"length";this.context=u,this.config=g,this.callbacks=c,this.request=this.fetchSetup(u,r),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){m.abortInternal(),c.onTimeout(e,u,m.response)},g.timeout),self.fetch(this.request).then(function(f){if(m.response=m.loader=f,!f.ok){var b=f.status,R=f.statusText;throw new o(R||"fetch, bad network response",b,f)}return e.loading.first=Math.max(self.performance.now(),e.loading.start),e.total=parseInt(f.headers.get("Content-Length")||"0"),t&&(0,C.isFiniteNumber)(g.highWaterMark)?m.loadProgressively(f,e,u,g.highWaterMark,t):s?f.arrayBuffer():f.text()}).then(function(f){var b=m.response;self.clearTimeout(m.requestTimeout),e.loading.end=Math.max(self.performance.now(),e.loading.first);var R=f[y];R&&(e.loaded=e.total=R);var I={url:b.url,data:f};t&&!(0,C.isFiniteNumber)(g.highWaterMark)&&t(e,u,f,b),c.onSuccess(I,e,u,b)}).catch(function(f){if(self.clearTimeout(m.requestTimeout),!e.aborted){var b=f&&f.code||0,R=f?f.message:null;c.onError({code:b,text:R},u,f?f.details:null)}})},l.getCacheAge=function(){var u=null;if(this.response){var g=this.response.headers.get("age");u=g?parseFloat(g):null}return u},l.loadProgressively=function(u,g,c,m,e){m===void 0&&(m=0);var r=new M.default,t=u.body.getReader(),s=function y(){return t.read().then(function(f){if(f.done)return r.dataLength&&e(g,c,r.flush(),u),Promise.resolve(new ArrayBuffer(0));var b=f.value,R=b.length;return g.loaded+=R,R<m||r.dataLength?(r.push(b),r.dataLength>=m&&e(g,c,r.flush(),u)):e(g,c,b,u),y()}).catch(function(){return Promise.reject()})};return s()},v}();function h(v,l){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:l,headers:new self.Headers(d({},v.headers))};return v.rangeEnd&&i.headers.set("Range","bytes="+v.rangeStart+"-"+String(v.rangeEnd-1)),i}function a(v,l){return new self.Request(v.url,l)}var o=function(v){P(l,v);function l(i,u,g){var c;return c=v.call(this,i)||this,c.code=void 0,c.details=void 0,c.code=u,c.details=g,c}return l}(B(Error));let n=p},"./src/utils/hex.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>L});var C={hexDump:function(P){for(var B="",A=0;A<P.length;A++){var D=P[A].toString(16);D.length<2&&(D="0"+D),B+=D}return B}};let L=C},"./src/utils/imsc1-ttml-parser.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{IMSC1_CODEC:()=>x,parseIMSC1:()=>E});var C=T("./src/utils/mp4-tools.ts"),L=T("./src/utils/vttparser.ts"),M=T("./src/utils/vttcue.ts"),P=T("./src/demux/id3.ts"),B=T("./src/utils/timescale-conversion.ts"),A=T("./src/utils/webvtt-parser.ts");function D(){return D=Object.assign?Object.assign.bind():function(c){for(var m=1;m<arguments.length;m++){var e=arguments[m];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(c[r]=e[r])}return c},D.apply(this,arguments)}var x="stpp.ttml.im1t",_=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,S=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,d={left:"start",center:"center",right:"end",start:"start",end:"end"};function E(c,m,e,r,t){var s=(0,C.findBox)(new Uint8Array(c),["mdat"]);if(s.length===0){t(new Error("Could not parse IMSC1 mdat"));return}var y=s.map(function(b){return(0,P.utf8ArrayToStr)(b)}),f=(0,B.toTimescaleFromScale)(m,1,e);try{y.forEach(function(b){return r(p(b,f))})}catch(b){t(b)}}function p(c,m){var e=new DOMParser,r=e.parseFromString(c,"text/xml"),t=r.getElementsByTagName("tt")[0];if(!t)throw new Error("Invalid ttml");var s={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},y=Object.keys(s).reduce(function(k,F){return k[F]=t.getAttribute("ttp:"+F)||s[F],k},{}),f=t.getAttribute("xml:space")!=="preserve",b=a(h(t,"styling","style")),R=a(h(t,"layout","region")),I=h(t,"body","[begin]");return[].map.call(I,function(k){var F=o(k,f);if(!F||!k.hasAttribute("begin"))return null;var K=i(k.getAttribute("begin"),y),H=i(k.getAttribute("dur"),y),j=i(k.getAttribute("end"),y);if(K===null)throw l(k);if(j===null){if(H===null)throw l(k);j=K+H}var Y=new M.default(K-m,j-m,F);Y.id=(0,A.generateCueId)(Y.startTime,Y.endTime,Y.text);var Q=R[k.getAttribute("region")],q=b[k.getAttribute("style")],ne=n(Q,q,b),te=ne.textAlign;if(te){var ae=d[te];ae&&(Y.lineAlign=ae),Y.align=te}return D(Y,ne),Y}).filter(function(k){return k!==null})}function h(c,m,e){var r=c.getElementsByTagName(m)[0];return r?[].slice.call(r.querySelectorAll(e)):[]}function a(c){return c.reduce(function(m,e){var r=e.getAttribute("xml:id");return r&&(m[r]=e),m},{})}function o(c,m){return[].slice.call(c.childNodes).reduce(function(e,r,t){var s;return r.nodeName==="br"&&t?e+`
23
+ `:(s=r.childNodes)!==null&&s!==void 0&&s.length?o(r,m):m?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function n(c,m,e){var r="http://www.w3.org/ns/ttml#styling",t=null,s=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],y=c!=null&&c.hasAttribute("style")?c.getAttribute("style"):null;return y&&e.hasOwnProperty(y)&&(t=e[y]),s.reduce(function(f,b){var R=v(m,r,b)||v(c,r,b)||v(t,r,b);return R&&(f[b]=R),f},{})}function v(c,m,e){return c&&c.hasAttributeNS(m,e)?c.getAttributeNS(m,e):null}function l(c){return new Error("Could not parse ttml timestamp "+c)}function i(c,m){if(!c)return null;var e=(0,L.parseTimeStamp)(c);return e===null&&(_.test(c)?e=u(c,m):S.test(c)&&(e=g(c,m))),e}function u(c,m){var e=_.exec(c),r=(e[4]|0)+(e[5]|0)/m.subFrameRate;return(e[1]|0)*3600+(e[2]|0)*60+(e[3]|0)+r/m.frameRate}function g(c,m){var e=S.exec(c),r=Number(e[1]),t=e[2];switch(t){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/m.frameRate;case"t":return r/m.tickRate}return r}},"./src/utils/keysystem-util.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{changeEndianness:()=>M,convertDataUriToArrayBytes:()=>P,strToUtf8array:()=>B});var C=T("./src/utils/numeric-encoding-utils.ts");function L(A){var D=B(A).subarray(0,16),x=new Uint8Array(16);return x.set(D,16-D.length),x}function M(A){var D=function(_,S,d){var E=_[S];_[S]=_[d],_[d]=E};D(A,0,3),D(A,1,2),D(A,4,5),D(A,6,7)}function P(A){var D=A.split(":"),x=null;if(D[0]==="data"&&D.length===2){var _=D[1].split(";"),S=_[_.length-1].split(",");if(S.length===2){var d=S[0]==="base64",E=S[1];d?(_.splice(-1,1),x=(0,C.base64Decode)(E)):x=L(E)}}return x}function B(A){return Uint8Array.from(unescape(encodeURIComponent(A)),function(D){return D.charCodeAt(0)})}},"./src/utils/logger.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{enableLogs:()=>A,logger:()=>D});var C=function(){},L={trace:C,debug:C,log:C,warn:C,info:C,error:C},M=L;function P(x){var _=self.console[x];return _?_.bind(self.console,"["+x+"] >"):C}function B(x){for(var _=arguments.length,S=new Array(_>1?_-1:0),d=1;d<_;d++)S[d-1]=arguments[d];S.forEach(function(E){M[E]=x[E]?x[E].bind(x):P(E)})}function A(x,_){if(self.console&&x===!0||typeof x=="object"){B(x,"debug","log","info","warn","error");try{M.log('Debug logs enabled for "'+_+'"')}catch{M=L}}else M=L}var D=M},"./src/utils/mediakeys-helper.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{KeySystemFormats:()=>L,KeySystemIds:()=>P,KeySystems:()=>C,getKeySystemsForConfig:()=>D,getSupportedMediaKeySystemConfigurations:()=>_,keySystemDomainToKeySystemFormat:()=>A,keySystemFormatToKeySystemDomain:()=>M,keySystemIdToKeySystemDomain:()=>B,requestMediaKeySystemAccess:()=>x});var C;(function(d){d.CLEARKEY="org.w3.clearkey",d.FAIRPLAY="com.apple.fps",d.PLAYREADY="com.microsoft.playready",d.WIDEVINE="com.widevine.alpha"})(C||(C={}));var L;(function(d){d.CLEARKEY="org.w3.clearkey",d.FAIRPLAY="com.apple.streamingkeydelivery",d.PLAYREADY="com.microsoft.playready",d.WIDEVINE="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"})(L||(L={}));function M(d){switch(d){case L.FAIRPLAY:return C.FAIRPLAY;case L.PLAYREADY:return C.PLAYREADY;case L.WIDEVINE:return C.WIDEVINE;case L.CLEARKEY:return C.CLEARKEY}}var P;(function(d){d.WIDEVINE="edef8ba979d64acea3c827dcd51d21ed"})(P||(P={}));function B(d){if(d===P.WIDEVINE)return C.WIDEVINE}function A(d){switch(d){case C.FAIRPLAY:return L.FAIRPLAY;case C.PLAYREADY:return L.PLAYREADY;case C.WIDEVINE:return L.WIDEVINE;case C.CLEARKEY:return L.CLEARKEY}}function D(d){var E=d.drmSystems,p=d.widevineLicenseUrl,h=E?[C.FAIRPLAY,C.WIDEVINE,C.PLAYREADY,C.CLEARKEY].filter(function(a){return!!E[a]}):[];return!h[C.WIDEVINE]&&p&&h.push(C.WIDEVINE),h}var x=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function _(d,E,p,h){var a;switch(d){case C.FAIRPLAY:a=["cenc","sinf"];break;case C.WIDEVINE:case C.PLAYREADY:a=["cenc"];break;case C.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+d)}return S(a,E,p,h)}function S(d,E,p,h){var a={initDataTypes:d,persistentState:h.persistentState||"not-allowed",distinctiveIdentifier:h.distinctiveIdentifier||"not-allowed",sessionTypes:h.sessionTypes||[h.sessionType||"temporary"],audioCapabilities:E.map(function(o){return{contentType:'audio/mp4; codecs="'+o+'"',robustness:h.audioRobustness||"",encryptionScheme:h.audioEncryptionScheme||null}}),videoCapabilities:p.map(function(o){return{contentType:'video/mp4; codecs="'+o+'"',robustness:h.videoRobustness||"",encryptionScheme:h.videoEncryptionScheme||null}})};return[a]}},"./src/utils/mediasource-helper.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{getMediaSource:()=>C});function C(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{RemuxerTrackIdConfig:()=>x,appendUint8Array:()=>m,bin2str:()=>_,computeRawDurationFromSamples:()=>u,discardEPB:()=>y,findBox:()=>h,getDuration:()=>i,getStartDTS:()=>l,mp4Box:()=>b,mp4pssh:()=>R,offsetStartDTS:()=>g,parseEmsg:()=>f,parseInitSegment:()=>o,parsePssh:()=>I,parseSEIMessageFromNALu:()=>s,parseSamples:()=>e,parseSegmentIndex:()=>a,parseSinf:()=>v,patchEncyptionData:()=>n,readSint32:()=>E,readUint16:()=>S,readUint32:()=>d,segmentValidRange:()=>c,writeUint32:()=>p});var C=T("./src/loader/fragment.ts"),L=T("./src/utils/typed-array.ts"),M=T("./src/demux/id3.ts"),P=T("./src/utils/logger.ts"),B=T("./src/utils/hex.ts"),A=Math.pow(2,32)-1,D=[].push,x={video:1,audio:2,id3:3,text:4};function _(k){return String.fromCharCode.apply(null,k)}function S(k,F){var K=k[F]<<8|k[F+1];return K<0?65536+K:K}function d(k,F){var K=E(k,F);return K<0?4294967296+K:K}function E(k,F){return k[F]<<24|k[F+1]<<16|k[F+2]<<8|k[F+3]}function p(k,F,K){k[F]=K>>24,k[F+1]=K>>16&255,k[F+2]=K>>8&255,k[F+3]=K&255}function h(k,F){var K=[];if(!F.length)return K;for(var H=k.byteLength,j=0;j<H;){var Y=d(k,j),Q=_(k.subarray(j+4,j+8)),q=Y>1?j+Y:H;if(Q===F[0])if(F.length===1)K.push(k.subarray(j+8,q));else{var ne=h(k.subarray(j+8,q),F.slice(1));ne.length&&D.apply(K,ne)}j=q}return K}function a(k){var F=[],K=k[0],H=8,j=d(k,H);H+=4;var Y=0,Q=0;K===0?H+=8:H+=16,H+=2;var q=k.length+Q,ne=S(k,H);H+=2;for(var te=0;te<ne;te++){var ae=H,ue=d(k,ae);ae+=4;var ce=ue&2147483647,le=(ue&2147483648)>>>31;if(le===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var fe=d(k,ae);ae+=4,F.push({referenceSize:ce,subsegmentDuration:fe,info:{duration:fe/j,start:q,end:q+ce-1}}),q+=ce,ae+=4,H=ae}return{earliestPresentationTime:Y,timescale:j,version:K,referencesCount:ne,references:F}}function o(k){for(var F=[],K=h(k,["moov","trak"]),H=0;H<K.length;H++){var j=K[H],Y=h(j,["tkhd"])[0];if(Y){var Q=Y[0],q=Q===0?12:20,ne=d(Y,q),te=h(j,["mdia","mdhd"])[0];if(te){Q=te[0],q=Q===0?12:20;var ae=d(te,q),ue=h(j,["mdia","hdlr"])[0];if(ue){var ce=_(ue.subarray(8,12)),le={soun:C.ElementaryStreamTypes.AUDIO,vide:C.ElementaryStreamTypes.VIDEO}[ce];if(le){var fe=h(j,["mdia","minf","stbl","stsd"])[0],de=void 0;fe&&(de=_(fe.subarray(12,16))),F[ne]={timescale:ae,type:le},F[le]={timescale:ae,id:ne,codec:de}}}}}}var xe=h(k,["moov","mvex","trex"]);return xe.forEach(function(Ae){var Ie=d(Ae,4),Re=F[Ie];Re&&(Re.default={duration:d(Ae,12),flags:d(Ae,20)})}),F}function n(k,F){if(!k||!F)return k;var K=F.keyId;if(K&&F.isCommonEncryption){var H=h(k,["moov","trak"]);H.forEach(function(j){var Y=h(j,["mdia","minf","stbl","stsd"])[0],Q=Y.subarray(8),q=h(Q,["enca"]),ne=q.length>0;ne||(q=h(Q,["encv"])),q.forEach(function(te){var ae=ne?te.subarray(28):te.subarray(78),ue=h(ae,["sinf"]);ue.forEach(function(ce){var le=v(ce);if(le){var fe=le.subarray(8,24);fe.some(function(de){return de!==0})||(P.logger.log("[eme] Patching keyId in 'enc"+(ne?"a":"v")+">sinf>>tenc' box: "+B.default.hexDump(fe)+" -> "+B.default.hexDump(K)),le.set(K,8))}})})})}return k}function v(k){var F=h(k,["schm"])[0];if(F){var K=_(F.subarray(4,8));if(K==="cbcs"||K==="cenc")return h(k,["schi","tenc"])[0]}return P.logger.error("[eme] missing 'schm' box"),null}function l(k,F){return h(F,["moof","traf"]).reduce(function(K,H){var j=h(H,["tfdt"])[0],Y=j[0],Q=h(H,["tfhd"]).reduce(function(q,ne){var te=d(ne,4),ae=k[te];if(ae){var ue=d(j,4);Y===1&&(ue*=Math.pow(2,32),ue+=d(j,8));var ce=ae.timescale||9e4,le=ue/ce;if(isFinite(le)&&(q===null||le<q))return le}return q},null);return Q!==null&&isFinite(Q)&&(K===null||Q<K)?Q:K},null)||0}function i(k,F){for(var K=0,H=0,j=0,Y=h(k,["moof","traf"]),Q=0;Q<Y.length;Q++){var q=Y[Q],ne=h(q,["tfhd"])[0],te=d(ne,4),ae=F[te];if(!!ae){var ue=ae.default,ce=d(ne,0)|(ue==null?void 0:ue.flags),le=ue==null?void 0:ue.duration;ce&8&&(ce&2?le=d(ne,12):le=d(ne,8));for(var fe=ae.timescale||9e4,de=h(q,["trun"]),xe=0;xe<de.length;xe++){if(K=u(de[xe]),!K&&le){var Ae=d(de[xe],4);K=le*Ae}ae.type===C.ElementaryStreamTypes.VIDEO?H+=K/fe:ae.type===C.ElementaryStreamTypes.AUDIO&&(j+=K/fe)}}}if(H===0&&j===0){for(var Ie=0,Re=h(k,["sidx"]),Oe=0;Oe<Re.length;Oe++){var Pe=a(Re[Oe]);Pe!=null&&Pe.references&&(Ie+=Pe.references.reduce(function(Ce,Le){return Ce+Le.info.duration||0},0))}return Ie}return H||j}function u(k){var F=d(k,0),K=8;F&1&&(K+=4),F&4&&(K+=4);for(var H=0,j=d(k,4),Y=0;Y<j;Y++){if(F&256){var Q=d(k,K);H+=Q,K+=4}F&512&&(K+=4),F&1024&&(K+=4),F&2048&&(K+=4)}return H}function g(k,F,K){h(F,["moof","traf"]).forEach(function(H){h(H,["tfhd"]).forEach(function(j){var Y=d(j,4),Q=k[Y];if(!!Q){var q=Q.timescale||9e4;h(H,["tfdt"]).forEach(function(ne){var te=ne[0],ae=d(ne,4);if(te===0)ae-=K*q,ae=Math.max(ae,0),p(ne,4,ae);else{ae*=Math.pow(2,32),ae+=d(ne,8),ae-=K*q,ae=Math.max(ae,0);var ue=Math.floor(ae/(A+1)),ce=Math.floor(ae%(A+1));p(ne,4,ue),p(ne,8,ce)}})}})})}function c(k){var F={valid:null,remainder:null},K=h(k,["moof"]);if(K){if(K.length<2)return F.remainder=k,F}else return F;var H=K[K.length-1];return F.valid=(0,L.sliceUint8)(k,0,H.byteOffset-8),F.remainder=(0,L.sliceUint8)(k,H.byteOffset-8),F}function m(k,F){var K=new Uint8Array(k.length+F.length);return K.set(k),K.set(F,k.length),K}function e(k,F){var K=[],H=F.samples,j=F.timescale,Y=F.id,Q=!1,q=h(H,["moof"]);return q.map(function(ne){var te=ne.byteOffset-8,ae=h(ne,["traf"]);ae.map(function(ue){var ce=h(ue,["tfdt"]).map(function(le){var fe=le[0],de=d(le,4);return fe===1&&(de*=Math.pow(2,32),de+=d(le,8)),de/j})[0];return ce!==void 0&&(k=ce),h(ue,["tfhd"]).map(function(le){var fe=d(le,4),de=d(le,0)&16777215,xe=(de&1)!==0,Ae=(de&2)!==0,Ie=(de&8)!==0,Re=0,Oe=(de&16)!==0,Pe=0,Ce=(de&32)!==0,Le=8;fe===Y&&(xe&&(Le+=8),Ae&&(Le+=4),Ie&&(Re=d(le,Le),Le+=4),Oe&&(Pe=d(le,Le),Le+=4),Ce&&(Le+=4),F.type==="video"&&(Q=r(F.codec)),h(ue,["trun"]).map(function(ke){var Be=ke[0],we=d(ke,0)&16777215,Ye=(we&1)!==0,Xe=0,rt=(we&4)!==0,ze=(we&256)!==0,it=0,nt=(we&512)!==0,Je=0,Ne=(we&1024)!==0,Ke=(we&2048)!==0,Ze=0,ft=d(ke,4),Me=8;Ye&&(Xe=d(ke,Me),Me+=4),rt&&(Me+=4);for(var qe=Xe+te,et=0;et<ft;et++){if(ze?(it=d(ke,Me),Me+=4):it=Re,nt?(Je=d(ke,Me),Me+=4):Je=Pe,Ne&&(Me+=4),Ke&&(Be===0?Ze=d(ke,Me):Ze=E(ke,Me),Me+=4),F.type===C.ElementaryStreamTypes.VIDEO)for(var _t=0;_t<Je;){var mt=d(H,qe);if(qe+=4,t(Q,H[qe])){var pt=H.subarray(qe,qe+mt);s(pt,Q?2:1,k+Ze/j,K)}qe+=mt,_t+=mt+4}k+=it/j}}))})})}),K}function r(k){if(!k)return!1;var F=k.indexOf("."),K=F<0?k:k.substring(0,F);return K==="hvc1"||K==="hev1"||K==="dvh1"||K==="dvhe"}function t(k,F){if(k){var K=F>>1&63;return K===39||K===40}else{var H=F&31;return H===6}}function s(k,F,K,H){var j=y(k),Y=0;Y+=F;for(var Q=0,q=0,ne=!1,te=0;Y<j.length;){Q=0;do{if(Y>=j.length)break;te=j[Y++],Q+=te}while(te===255);q=0;do{if(Y>=j.length)break;te=j[Y++],q+=te}while(te===255);var ae=j.length-Y;if(!ne&&Q===4&&Y<j.length){ne=!0;var ue=j[Y++];if(ue===181){var ce=S(j,Y);if(Y+=2,ce===49){var le=d(j,Y);if(Y+=4,le===1195456820){var fe=j[Y++];if(fe===3){var de=j[Y++],xe=31&de,Ae=64&de,Ie=Ae?2+xe*3:0,Re=new Uint8Array(Ie);if(Ae){Re[0]=de;for(var Oe=1;Oe<Ie;Oe++)Re[Oe]=j[Y++]}H.push({type:fe,payloadType:Q,pts:K,bytes:Re})}}}}}else if(Q===5&&q<ae){if(ne=!0,q>16){for(var Pe=[],Ce=0;Ce<16;Ce++){var Le=j[Y++].toString(16);Pe.push(Le.length==1?"0"+Le:Le),(Ce===3||Ce===5||Ce===7||Ce===9)&&Pe.push("-")}for(var ke=q-16,Be=new Uint8Array(ke),we=0;we<ke;we++)Be[we]=j[Y++];H.push({payloadType:Q,pts:K,uuid:Pe.join(""),userData:(0,M.utf8ArrayToStr)(Be),userDataBytes:Be})}}else if(q<ae)Y+=q;else if(q>ae)break}}function y(k){for(var F=k.byteLength,K=[],H=1;H<F-2;)k[H]===0&&k[H+1]===0&&k[H+2]===3?(K.push(H+2),H+=2):H++;if(K.length===0)return k;var j=F-K.length,Y=new Uint8Array(j),Q=0;for(H=0;H<j;Q++,H++)Q===K[0]&&(Q++,K.shift()),Y[H]=k[Q];return Y}function f(k){var F=k[0],K="",H="",j=0,Y=0,Q=0,q=0,ne=0,te=0;if(F===0){for(;_(k.subarray(te,te+1))!=="\0";)K+=_(k.subarray(te,te+1)),te+=1;for(K+=_(k.subarray(te,te+1)),te+=1;_(k.subarray(te,te+1))!=="\0";)H+=_(k.subarray(te,te+1)),te+=1;H+=_(k.subarray(te,te+1)),te+=1,j=d(k,12),Y=d(k,16),q=d(k,20),ne=d(k,24),te=28}else if(F===1){te+=4,j=d(k,te),te+=4;var ae=d(k,te);te+=4;var ue=d(k,te);for(te+=4,Q=Math.pow(2,32)*ae+ue,Number.isSafeInteger(Q)||(Q=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),q=d(k,te),te+=4,ne=d(k,te),te+=4;_(k.subarray(te,te+1))!=="\0";)K+=_(k.subarray(te,te+1)),te+=1;for(K+=_(k.subarray(te,te+1)),te+=1;_(k.subarray(te,te+1))!=="\0";)H+=_(k.subarray(te,te+1)),te+=1;H+=_(k.subarray(te,te+1)),te+=1}var ce=k.subarray(te,k.byteLength);return{schemeIdUri:K,value:H,timeScale:j,presentationTime:Q,presentationTimeDelta:Y,eventDuration:q,id:ne,payload:ce}}function b(k){for(var F=arguments.length,K=new Array(F>1?F-1:0),H=1;H<F;H++)K[H-1]=arguments[H];for(var j=K.length,Y=8,Q=j;Q--;)Y+=K[Q].byteLength;var q=new Uint8Array(Y);for(q[0]=Y>>24&255,q[1]=Y>>16&255,q[2]=Y>>8&255,q[3]=Y&255,q.set(k,4),Q=0,Y=8;Q<j;Q++)q.set(K[Q],Y),Y+=K[Q].byteLength;return q}function R(k,F,K){if(k.byteLength!==16)throw new RangeError("Invalid system id");var H,j;if(F){H=1,j=new Uint8Array(F.length*16);for(var Y=0;Y<F.length;Y++){var Q=F[Y];if(Q.byteLength!==16)throw new RangeError("Invalid key");j.set(Q,Y*16)}}else H=0,j=new Uint8Array;var q;H>0?(q=new Uint8Array(4),F.length>0&&new DataView(q.buffer).setUint32(0,F.length,!1)):q=new Uint8Array;var ne=new Uint8Array(4);return K&&K.byteLength>0&&new DataView(ne.buffer).setUint32(0,K.byteLength,!1),b([112,115,115,104],new Uint8Array([H,0,0,0]),k,q,j,ne,K||new Uint8Array)}function I(k){if(!(k instanceof ArrayBuffer)||k.byteLength<32)return null;var F={version:0,systemId:"",kids:null,data:null},K=new DataView(k),H=K.getUint32(0);if(k.byteLength!==H&&H>44)return null;var j=K.getUint32(4);if(j!==1886614376||(F.version=K.getUint32(8)>>>24,F.version>1))return null;F.systemId=B.default.hexDump(new Uint8Array(k,12,16));var Y=K.getUint32(28);if(F.version===0){if(H-32<Y)return null;F.data=new Uint8Array(k,32,Y)}else if(F.version===1){F.kids=[];for(var Q=0;Q<Y;Q++)F.kids.push(new Uint8Array(k,32+Q*16,16))}return F}},"./src/utils/numeric-encoding-utils.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{base64Decode:()=>A,base64DecodeToStr:()=>M,base64Encode:()=>P,base64ToBase64Url:()=>C,base64UrlEncode:()=>B,strToBase64Encode:()=>L});function C(D){return D.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function L(D){return btoa(D)}function M(D){return atob(D)}function P(D){return btoa(String.fromCharCode.apply(String,D))}function B(D){return C(P(D))}function A(D){return Uint8Array.from(atob(D),function(x){return x.charCodeAt(0)})}},"./src/utils/output-filter.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>C});var C=function(){function L(P,B){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=P,this.trackName=B}var M=L.prototype;return M.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},M.newCue=function(B,A,D){(this.startTime===null||this.startTime>B)&&(this.startTime=B),this.endTime=A,this.screen=D,this.timelineController.createCaptionsTrack(this.trackName)},M.reset=function(){this.cueRanges=[],this.startTime=null},L}()},"./src/utils/texttrack-utils.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{addCueToTrack:()=>M,clearCurrentCues:()=>P,getCuesInRange:()=>D,removeCuesInRange:()=>B,sendAddTrackEvent:()=>L});var C=T("./src/utils/logger.ts");function L(x,_){var S;try{S=new Event("addtrack")}catch{S=document.createEvent("Event"),S.initEvent("addtrack",!1,!1)}S.track=x,_.dispatchEvent(S)}function M(x,_){var S=x.mode;if(S==="disabled"&&(x.mode="hidden"),x.cues&&!x.cues.getCueById(_.id))try{if(x.addCue(_),!x.cues.getCueById(_.id))throw new Error("addCue is failed for: "+_)}catch(E){C.logger.debug("[texttrack-utils]: "+E);var d=new self.TextTrackCue(_.startTime,_.endTime,_.text);d.id=_.id,x.addCue(d)}S==="disabled"&&(x.mode=S)}function P(x){var _=x.mode;if(_==="disabled"&&(x.mode="hidden"),x.cues)for(var S=x.cues.length;S--;)x.removeCue(x.cues[S]);_==="disabled"&&(x.mode=_)}function B(x,_,S,d){var E=x.mode;if(E==="disabled"&&(x.mode="hidden"),x.cues&&x.cues.length>0)for(var p=D(x.cues,_,S),h=0;h<p.length;h++)(!d||d(p[h]))&&x.removeCue(p[h]);E==="disabled"&&(x.mode=E)}function A(x,_){if(_<x[0].startTime)return 0;var S=x.length-1;if(_>x[S].endTime)return-1;for(var d=0,E=S;d<=E;){var p=Math.floor((E+d)/2);if(_<x[p].startTime)E=p-1;else if(_>x[p].startTime&&d<S)d=p+1;else return p}return x[d].startTime-_<_-x[E].startTime?d:E}function D(x,_,S){var d=[],E=A(x,_);if(E>-1)for(var p=E,h=x.length;p<h;p++){var a=x[p];if(a.startTime>=_&&a.endTime<=S)d.push(a);else if(a.startTime>S)return d}return d}},"./src/utils/time-ranges.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>L});var C={toString:function(P){for(var B="",A=P.length,D=0;D<A;D++)B+="["+P.start(D).toFixed(3)+","+P.end(D).toFixed(3)+"]";return B}};let L=C},"./src/utils/timescale-conversion.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{toMpegTsClockFromTimescale:()=>B,toMsFromMpegTsClock:()=>P,toTimescaleFromBase:()=>L,toTimescaleFromScale:()=>M});var C=9e4;function L(A,D,x,_){x===void 0&&(x=1),_===void 0&&(_=!1);var S=A*D*x;return _?Math.round(S):S}function M(A,D,x,_){return x===void 0&&(x=1),_===void 0&&(_=!1),L(A,D,1/x,_)}function P(A,D){return D===void 0&&(D=!1),L(A,1e3,1/C,D)}function B(A,D){return D===void 0&&(D=1),L(A,C,1/D)}},"./src/utils/typed-array.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{sliceUint8:()=>C});function C(L,M,P){return Uint8Array.prototype.slice?L.slice(M,P):new Uint8Array(Array.prototype.slice.call(L,M,P))}},"./src/utils/vttcue.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>C});let C=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var L=["","lr","rl"],M=["start","middle","end","left","right"];function P(_,S){if(typeof S!="string"||!Array.isArray(_))return!1;var d=S.toLowerCase();return~_.indexOf(d)?d:!1}function B(_){return P(L,_)}function A(_){return P(M,_)}function D(_){for(var S=arguments.length,d=new Array(S>1?S-1:0),E=1;E<S;E++)d[E-1]=arguments[E];for(var p=1;p<arguments.length;p++){var h=arguments[p];for(var a in h)_[a]=h[a]}return _}function x(_,S,d){var E=this,p={enumerable:!0};E.hasBeenReset=!1;var h="",a=!1,o=_,n=S,v=d,l=null,i="",u=!0,g="auto",c="start",m=50,e="middle",r=50,t="middle";Object.defineProperty(E,"id",D({},p,{get:function(){return h},set:function(y){h=""+y}})),Object.defineProperty(E,"pauseOnExit",D({},p,{get:function(){return a},set:function(y){a=!!y}})),Object.defineProperty(E,"startTime",D({},p,{get:function(){return o},set:function(y){if(typeof y!="number")throw new TypeError("Start time must be set to a number.");o=y,this.hasBeenReset=!0}})),Object.defineProperty(E,"endTime",D({},p,{get:function(){return n},set:function(y){if(typeof y!="number")throw new TypeError("End time must be set to a number.");n=y,this.hasBeenReset=!0}})),Object.defineProperty(E,"text",D({},p,{get:function(){return v},set:function(y){v=""+y,this.hasBeenReset=!0}})),Object.defineProperty(E,"region",D({},p,{get:function(){return l},set:function(y){l=y,this.hasBeenReset=!0}})),Object.defineProperty(E,"vertical",D({},p,{get:function(){return i},set:function(y){var f=B(y);if(f===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=f,this.hasBeenReset=!0}})),Object.defineProperty(E,"snapToLines",D({},p,{get:function(){return u},set:function(y){u=!!y,this.hasBeenReset=!0}})),Object.defineProperty(E,"line",D({},p,{get:function(){return g},set:function(y){if(typeof y!="number"&&y!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");g=y,this.hasBeenReset=!0}})),Object.defineProperty(E,"lineAlign",D({},p,{get:function(){return c},set:function(y){var f=A(y);if(!f)throw new SyntaxError("An invalid or illegal string was specified.");c=f,this.hasBeenReset=!0}})),Object.defineProperty(E,"position",D({},p,{get:function(){return m},set:function(y){if(y<0||y>100)throw new Error("Position must be between 0 and 100.");m=y,this.hasBeenReset=!0}})),Object.defineProperty(E,"positionAlign",D({},p,{get:function(){return e},set:function(y){var f=A(y);if(!f)throw new SyntaxError("An invalid or illegal string was specified.");e=f,this.hasBeenReset=!0}})),Object.defineProperty(E,"size",D({},p,{get:function(){return r},set:function(y){if(y<0||y>100)throw new Error("Size must be between 0 and 100.");r=y,this.hasBeenReset=!0}})),Object.defineProperty(E,"align",D({},p,{get:function(){return t},set:function(y){var f=A(y);if(!f)throw new SyntaxError("An invalid or illegal string was specified.");t=f,this.hasBeenReset=!0}})),E.displayState=void 0}return x.prototype.getCueAsHTML=function(){var _=self.WebVTT;return _.convertCueToDOMTree(self,this.text)},x}()},"./src/utils/vttparser.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{VTTParser:()=>S,fixLineBreaks:()=>_,parseTimeStamp:()=>M});var C=T("./src/utils/vttcue.ts"),L=function(){function d(){}var E=d.prototype;return E.decode=function(h,a){if(!h)return"";if(typeof h!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(h))},d}();function M(d){function E(h,a,o,n){return(h|0)*3600+(a|0)*60+(o|0)+parseFloat(n||0)}var p=d.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return p?parseFloat(p[2])>59?E(p[2],p[3],0,p[4]):E(p[1],p[2],p[3],p[4]):null}var P=function(){function d(){this.values=Object.create(null)}var E=d.prototype;return E.set=function(h,a){!this.get(h)&&a!==""&&(this.values[h]=a)},E.get=function(h,a,o){return o?this.has(h)?this.values[h]:a[o]:this.has(h)?this.values[h]:a},E.has=function(h){return h in this.values},E.alt=function(h,a,o){for(var n=0;n<o.length;++n)if(a===o[n]){this.set(h,a);break}},E.integer=function(h,a){/^-?\d+$/.test(a)&&this.set(h,parseInt(a,10))},E.percent=function(h,a){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(a)){var o=parseFloat(a);if(o>=0&&o<=100)return this.set(h,o),!0}return!1},d}();function B(d,E,p,h){var a=h?d.split(h):[d];for(var o in a)if(typeof a[o]=="string"){var n=a[o].split(p);if(n.length===2){var v=n[0],l=n[1];E(v,l)}}}var A=new C.default(0,0,""),D=A.align==="middle"?"middle":"center";function x(d,E,p){var h=d;function a(){var v=M(d);if(v===null)throw new Error("Malformed timestamp: "+h);return d=d.replace(/^[^\sa-zA-Z-]+/,""),v}function o(v,l){var i=new P;B(v,function(c,m){var e;switch(c){case"region":for(var r=p.length-1;r>=0;r--)if(p[r].id===m){i.set(c,p[r].region);break}break;case"vertical":i.alt(c,m,["rl","lr"]);break;case"line":e=m.split(","),i.integer(c,e[0]),i.percent(c,e[0])&&i.set("snapToLines",!1),i.alt(c,e[0],["auto"]),e.length===2&&i.alt("lineAlign",e[1],["start",D,"end"]);break;case"position":e=m.split(","),i.percent(c,e[0]),e.length===2&&i.alt("positionAlign",e[1],["start",D,"end","line-left","line-right","auto"]);break;case"size":i.percent(c,m);break;case"align":i.alt(c,m,["start",D,"end","left","right"]);break}},/:/,/\s/),l.region=i.get("region",null),l.vertical=i.get("vertical","");var u=i.get("line","auto");u==="auto"&&A.line===-1&&(u=-1),l.line=u,l.lineAlign=i.get("lineAlign","start"),l.snapToLines=i.get("snapToLines",!0),l.size=i.get("size",100),l.align=i.get("align",D);var g=i.get("position","auto");g==="auto"&&A.position===50&&(g=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=g}function n(){d=d.replace(/^\s+/,"")}if(n(),E.startTime=a(),n(),d.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+h);d=d.slice(3),n(),E.endTime=a(),n(),o(d,E)}function _(d){return d.replace(/<br(?: \/)?>/gi,`
24
+ `)}var S=function(){function d(){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 E=d.prototype;return E.parse=function(h){var a=this;h&&(a.buffer+=a.decoder.decode(h,{stream:!0}));function o(){var g=a.buffer,c=0;for(g=_(g);c<g.length&&g[c]!=="\r"&&g[c]!==`
25
+ `;)++c;var m=g.slice(0,c);return g[c]==="\r"&&++c,g[c]===`
26
+ `&&++c,a.buffer=g.slice(c),m}function n(g){B(g,function(c,m){},/:/)}try{var v="";if(a.state==="INITIAL"){if(!/\r\n|\n/.test(a.buffer))return this;v=o();var l=v.match(/^()?WEBVTT([ \t].*)?$/);if(!l||!l[0])throw new Error("Malformed WebVTT signature.");a.state="HEADER"}for(var i=!1;a.buffer;){if(!/\r\n|\n/.test(a.buffer))return this;switch(i?i=!1:v=o(),a.state){case"HEADER":/:/.test(v)?n(v):v||(a.state="ID");continue;case"NOTE":v||(a.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(v)){a.state="NOTE";break}if(!v)continue;if(a.cue=new C.default(0,0,""),a.state="CUE",v.indexOf("-->")===-1){a.cue.id=v;continue}case"CUE":if(!a.cue){a.state="BADCUE";continue}try{x(v,a.cue,a.regionList)}catch{a.cue=null,a.state="BADCUE";continue}a.state="CUETEXT";continue;case"CUETEXT":{var u=v.indexOf("-->")!==-1;if(!v||u&&(i=!0)){a.oncue&&a.cue&&a.oncue(a.cue),a.cue=null,a.state="ID";continue}if(a.cue===null)continue;a.cue.text&&(a.cue.text+=`
27
+ `),a.cue.text+=v}continue;case"BADCUE":v||(a.state="ID")}}}catch{a.state==="CUETEXT"&&a.cue&&a.oncue&&a.oncue(a.cue),a.cue=null,a.state=a.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},E.flush=function(){var h=this;try{if((h.cue||h.state==="HEADER")&&(h.buffer+=`
26
28
 
27
- `,u.parse()),u.state==="INITIAL"||u.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){u.onparsingerror&&u.onparsingerror(e)}return u.onflush&&u.onflush(),this},E}()},"./src/utils/webvtt-parser.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"generateCueId",function(){return D}),m.d(R,"parseWebVTT",function(){return g});var M=m("./src/polyfills/number.ts"),_=m("./src/utils/vttparser.ts"),L=m("./src/demux/id3.ts"),C=m("./src/utils/timescale-conversion.ts"),b=m("./src/remux/mp4-remuxer.ts"),O=/\r\n|\n\r|\n|\r/g,A=function(u,e,s){return s===void 0&&(s=0),u.slice(s,s+e.length)===e},y=function(u){var e=parseInt(u.slice(-3)),s=parseInt(u.slice(-6,-4)),c=parseInt(u.slice(-9,-7)),v=u.length>9?parseInt(u.substring(0,u.indexOf(":"))):0;if(!Object(M.isFiniteNumber)(e)||!Object(M.isFiniteNumber)(s)||!Object(M.isFiniteNumber)(c)||!Object(M.isFiniteNumber)(v))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+u);return e+=1e3*s,e+=60*1e3*c,e+=60*60*1e3*v,e},T=function(u){for(var e=5381,s=u.length;s;)e=e*33^u.charCodeAt(--s);return(e>>>0).toString()};function D(p,u,e){return T(p.toString())+T(u.toString())+T(e)}var E=function(u,e,s){var c=u[e],v=u[c.prevCC];if(!v||!v.new&&c.new){u.ccOffset=u.presentationOffset=c.start,c.new=!1;return}for(;(i=v)!==null&&i!==void 0&&i.new;){var i;u.ccOffset+=c.start-v.start,c.new=!1,c=v,v=u[c.prevCC]}u.presentationOffset=s};function g(p,u,e,s,c,v,i,r){var o=new _.VTTParser,d=Object(L.utf8ArrayToStr)(new Uint8Array(p)).trim().replace(O,`
29
+ `,h.parse()),h.state==="INITIAL"||h.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(a){h.onparsingerror&&h.onparsingerror(a)}return h.onflush&&h.onflush(),this},d}()},"./src/utils/webvtt-parser.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{generateCueId:()=>S,parseWebVTT:()=>E});var C=T("./src/polyfills/number.ts"),L=T("./src/utils/vttparser.ts"),M=T("./src/demux/id3.ts"),P=T("./src/utils/timescale-conversion.ts"),B=T("./src/remux/mp4-remuxer.ts"),A=/\r\n|\n\r|\n|\r/g,D=function(h,a,o){return o===void 0&&(o=0),h.slice(o,o+a.length)===a},x=function(h){var a=parseInt(h.slice(-3)),o=parseInt(h.slice(-6,-4)),n=parseInt(h.slice(-9,-7)),v=h.length>9?parseInt(h.substring(0,h.indexOf(":"))):0;if(!(0,C.isFiniteNumber)(a)||!(0,C.isFiniteNumber)(o)||!(0,C.isFiniteNumber)(n)||!(0,C.isFiniteNumber)(v))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+h);return a+=1e3*o,a+=60*1e3*n,a+=60*60*1e3*v,a},_=function(h){for(var a=5381,o=h.length;o;)a=a*33^h.charCodeAt(--o);return(a>>>0).toString()};function S(p,h,a){return _(p.toString())+_(h.toString())+_(a)}var d=function(h,a,o){var n=h[a],v=h[n.prevCC];if(!v||!v.new&&n.new){h.ccOffset=h.presentationOffset=n.start,n.new=!1;return}for(;(l=v)!==null&&l!==void 0&&l.new;){var l;h.ccOffset+=n.start-v.start,n.new=!1,n=v,v=h[n.prevCC]}h.presentationOffset=o};function E(p,h,a,o,n,v,l,i){var u=new L.VTTParser,g=(0,M.utf8ArrayToStr)(new Uint8Array(p)).trim().replace(A,`
28
30
  `).split(`
29
- `),t=[],n=Object(C.toMpegTsClockFromTimescale)(u,e),l="00:00.000",a=0,f=0,h,S=!0;o.oncue=function(x){var P=s[c],k=s.ccOffset,B=(a-n)/9e4;P!=null&&P.new&&(f!==void 0?k=s.ccOffset=P.start:E(s,c,B)),B&&(k=B-s.presentationOffset);var U=x.endTime-x.startTime,W=Object(b.normalizePts)((x.startTime+k-f)*9e4,v*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)},o.onparsingerror=function(x){h=x},o.onflush=function(){if(h){r(h);return}i(t)},d.forEach(function(x){if(S)if(A(x,"X-TIMESTAMP-MAP=")){S=!1,x.slice(16).split(",").forEach(function(P){A(P,"LOCAL:")?l=P.slice(6):A(P,"MPEGTS:")&&(a=parseInt(P.slice(7)))});try{f=y(l)/1e3}catch(P){h=P}return}else x===""&&(S=!1);o.parse(x+`
30
- `)}),o.flush()}},"./src/utils/xhr-loader.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/utils/logger.ts"),_=m("./src/loader/load-stats.ts"),L=/^age:\s*[\d.]+\s*$/m,C=function(){function b(A){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=A?A.xhrSetup:null,this.stats=new _.LoadStats,this.retryDelay=0}var O=b.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 g=this.xhrSetup;try{if(g)try{g(D,T.url)}catch{D.open("GET",T.url,!0),g(D,T.url)}D.readyState||D.open("GET",T.url,!0);var p=this.context.headers;if(p)for(var u in p)D.setRequestHeader(u,p[u])}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,g=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 u,e;if(y.responseType==="arraybuffer"?(u=T.response,e=u.byteLength):(u=T.responseText,e=u.length),D.loaded=D.total=e,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(D,y,u,T),!this.callbacks)return;var c={url:T.responseURL,data:u};this.callbacks.onSuccess(c,D,y,T)}else D.retry>=g.maxRetry||p>=400&&p<499?(M.logger.error(p+" while loading "+y.url),this.callbacks.onError({code:p,text:T.statusText},y,T)):(M.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,g.maxRetryDelay),D.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout)}},O.loadtimeout=function(){M.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&&L.test(this.loader.getAllResponseHeaders())){var T=this.loader.getResponseHeader("age");y=T?parseFloat(T):null}return y},b}();R.default=C}}).default})});var Xt=jt(Lr()),Tt=jt(Ht());var At=class extends Error{constructor(m,M=At.MEDIA_ERR_CUSTOM,_){var L;super(m);this.name="MediaError",this.code=M,this.fatal=_!=null?_:M>=At.MEDIA_ERR_NETWORK&&M<=At.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(L=At.defaultMessages[this.code])!=null?L:"")}},Ne=At;Ne.MEDIA_ERR_ABORTED=1,Ne.MEDIA_ERR_NETWORK=2,Ne.MEDIA_ERR_DECODE=3,Ne.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Ne.MEDIA_ERR_ENCRYPTED=5,Ne.MEDIA_ERR_CUSTOM=100,Ne.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 cr=jt(Ht());var lr=(j,R)=>j in R,Vt={ANY:"any",MUTED:"muted"},wt={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},ur={MSE:"mse",NATIVE:"native"},Yt={HEADER:"header",QUERY:"query",NONE:"none"},Hi=Object.values(Yt),ht={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},zt={HLS:ht.M3U8},Vi=Object.keys(zt),Yi=[...Object.values(ht),"hls","HLS"];var yt=(j,R,m,M)=>{j.addEventListener(R,m,M),j.addEventListener("teardown",()=>{j.removeEventListener(R,m)},{once:!0})};function Ar(j,R,m){R&&m>R&&(m=R);for(let M=0;M<j.length;M++)if(j.start(M)<=m&&j.end(M)>=m)return!0;return!1}var _r=j=>{let R=j.indexOf("?");if(R<0)return[j];let m=j.slice(0,R),M=j.slice(R);return[m,M]},fr=j=>{let R=j.type;if(R){let M=R.toUpperCase();return lr(M,zt)?zt[M]:R}let{src:m}=j;return m?Oi(m):""},Oi=j=>{let R="";try{R=new URL(j).pathname}catch{console.error("invalid url")}let m=R.lastIndexOf(".");if(m<0)return"";let _=R.slice(m+1).toUpperCase();return lr(_,ht)?ht[_]:""};var bi=Object.values(Vt),Or=j=>typeof j=="boolean"||typeof j=="string"&&bi.includes(j),br=({autoplay:j},R,m)=>{let M=!1,_=!1,L=Or(j)?j:!!j,C=()=>{M||yt(R,"playing",()=>{M=!0},{once:!0})};if(C(),yt(R,"loadstart",()=>{M=!1,C(),dr(R,L)},{once:!0}),yt(R,"loadstart",()=>{m||(_=!Number.isFinite(R.duration)),dr(R,L)},{once:!0}),m&&m.once(cr.default.Events.LEVEL_LOADED,(O,A)=>{var y;_=(y=A.details.live)!=null?y:!1}),!L){let O=()=>{!_||(m!=null&&m.liveSyncPosition?R.currentTime=m.liveSyncPosition:Number.isFinite(R.seekable.end(0))&&(R.currentTime=R.seekable.end(0)))};m&&yt(R,"play",()=>{R.preload==="metadata"?m.once(cr.default.Events.LEVEL_UPDATED,O):O()},{once:!0})}return O=>{M||(L=Or(O)?O:!!O,dr(R,L))}},dr=(j,R)=>{if(!R)return;let m=j.muted,M=()=>j.muted=m;switch(R){case Vt.ANY:j.play().catch(()=>{j.muted=!0,j.play().catch(M)});break;case Vt.MUTED:j.muted=!0,j.play().catch(M);break;default:j.play().catch(()=>{});break}};var Rr=({preload:j,src:R},m,M)=>{let _=T=>{T!=null&&["","none","metadata","auto"].includes(T)?m.setAttribute("preload",T):m.removeAttribute("preload")};if(!M)return _(j),_;let L=!1,C=!1,b=M.config.maxBufferLength,O=M.config.maxBufferSize,A=T=>{_(T);let D=T!=null?T:m.preload;C||D==="none"||(D==="metadata"?(M.config.maxBufferLength=1,M.config.maxBufferSize=1):(M.config.maxBufferLength=b,M.config.maxBufferSize=O),y())},y=()=>{!L&&R&&(L=!0,M.loadSource(R))};return yt(m,"play",()=>{C=!0,M.config.maxBufferLength=b,M.config.maxBufferSize=O,y()},{once:!0}),A(j),A};var _t=jt(Ht());function Pr(j,R){R.on(_t.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(_,{tracks:L})=>{L.forEach(C=>{var A;let b=(A=C.subtitleTrack)!=null?A:C.closedCaptions,O=R.subtitleTracks.findIndex(({lang:y,name:T,type:D})=>y==(b==null?void 0:b.lang)&&T===C.label&&D.toLowerCase()===C.kind);Ir(j,C.kind,C.label,b==null?void 0:b.lang,`${C.kind}${O}`)})});let m=()=>{var C;if(!R.subtitleTracks.length)return;let _=Array.from(j.textTracks).find(b=>b.id&&b.mode==="showing"&&["subtitles","captions"].includes(b.kind)),L=`${(C=R.subtitleTracks[R.subtitleTrack])==null?void 0:C.type.toLowerCase()}${R.subtitleTrack}`;if(_&&(R.subtitleTrack<0||(_==null?void 0:_.id)!==L)){let b=R.subtitleTracks.findIndex(({lang:O,name:A,type:y})=>O==_.language&&A===_.label&&y.toLowerCase()===_.kind);R.subtitleTrack=b}_&&(_==null?void 0:_.id)===L&&_.cues&&Array.from(_.cues).forEach(b=>{_.addCue(b)})};j.textTracks.addEventListener("change",m),R.on(_t.default.Events.CUES_PARSED,(_,{track:L,cues:C})=>{let b=j.textTracks.getTrackById(L);if(!b)return;let O=b.mode==="disabled";O&&(b.mode="hidden"),C.forEach(A=>{var y;(y=b.cues)!=null&&y.getCueById(A.id)||b.addCue(A)}),O&&(b.mode="disabled")}),R.once(_t.default.Events.DESTROYING,()=>{j.textTracks.removeEventListener("change",m),j.querySelectorAll("track[data-removeondestroy]").forEach(L=>{L.remove()})});let M=()=>{Array.from(j.textTracks).forEach(_=>{var L,C;if(!["subtitles","caption"].includes(_.kind)&&_.label==="thumbnails"){if(!((L=_.cues)!=null&&L.length)){let b=j.querySelector('track[label="thumbnails"]'),O=(C=b==null?void 0:b.getAttribute("src"))!=null?C:"";b==null||b.removeAttribute("src"),setTimeout(()=>{b==null||b.setAttribute("src",O)},0)}_.mode!=="hidden"&&(_.mode="hidden")}})};R.once(_t.default.Events.MANIFEST_LOADED,M),R.once(_t.default.Events.MEDIA_ATTACHED,M)}function Ir(j,R,m,M,_){let L=document.createElement("track");return L.kind=R,L.label=m,M&&(L.srclang=M),_&&(L.id=_),L.track.mode="disabled",L.setAttribute("data-removeondestroy",""),j.append(L),L.track}function Ri(j,R){let m=Array.prototype.find.call(j.querySelectorAll("track"),M=>M.track===R);m==null||m.remove()}var Mr,Cr,Pi=(Cr=(Mr=globalThis==null?void 0:globalThis.navigator)==null?void 0:Mr.userAgent)!=null?Cr:"",Ii=Pi.toLowerCase().indexOf("android")!==-1,Ot=new WeakMap,kr="mux.com",Fr,wr,Br=(wr=(Fr=Tt.default).isSupported)==null?void 0:wr.call(Fr),Mi=Ii,hn=()=>Xt.default.utils.now(),Ci=Xt.default.utils.generateUUID,vn=(j,{domain:R=kr}={})=>{if(!j)return;let[m,M=""]=_r(j);return`https://stream.${R}/${m}.m3u8${M}`},Fi=j=>{if(!j)return;let[R]=j.split("?");return R||void 0},wi=j=>{if(!j||!j.startsWith("https://stream."))return;let[R]=new URL(j).pathname.slice(1).split(".m3u8");return R||void 0},ki=j=>{var R,m,M;return(R=j==null?void 0:j.metadata)!=null&&R.video_id?j.metadata.video_id:Nr(j)&&(M=(m=Fi(j.playbackId))!=null?m:wi(j.src))!=null?M:j.src},gn=j=>{var R;return(R=Ot.get(j))==null?void 0:R.error},mn=(j,R,m)=>{Bi(R,m);let{metadata:M={}}=j,{view_session_id:_=Ci()}=M,L=ki(j);M.view_session_id=_,M.video_id=L,j.metadata=M,Ot.set(R,{});let C=Ui(j,R);Ki(j,R,C),Wi(j,R,C);let b=br(j,R,C),O=Rr(j,R,C);return{engine:C,setAutoplay:b,setPreload:O}},Bi=(j,R)=>{let m=R==null?void 0:R.engine;m&&(m.detachMedia(),m.destroy()),(j==null?void 0:j.mux)&&!j.mux.deleted&&(j.mux.destroy(),delete j.mux),j&&(j.removeAttribute("src"),j.load(),j.removeEventListener("error",Wr),j.removeEventListener("error",hr),j.removeEventListener("durationchange",Kr),Ot.delete(j),j.dispatchEvent(new Event("teardown")))};function Ur(j,R){var A;let m=fr(j);if(!(m===ht.M3U8))return!0;let _=!m||((A=R.canPlayType(m))!=null?A:!0),{preferPlayback:L}=j,C=L===ur.MSE,b=L===ur.NATIVE;return _&&(b||!(Br&&(C||Mi)))}var Ui=(j,R)=>{let{debug:m,streamType:M,startTime:_=-1,metadata:L,preferCmcd:C}=j,O=fr(j)===ht.M3U8,A=Ur(j,R);if(O&&!A&&Br){let y={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},T=Ni(M),D=C!==Yt.NONE?{useHeaders:C===Yt.HEADER,sessionId:L.view_session_id,contentId:L.video_id}:void 0;return new Tt.default({debug:m,startPosition:_,cmcd:D,...y,...T})}},Ni=j=>[wt.LIVE,wt.DVR].includes(j)?{backBufferLength:8}:[wt.LL_LIVE,wt.LL_DVR].includes(j)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},Nr=({playbackId:j,src:R,customDomain:m})=>{if(j)return!0;if(typeof R!="string")return!1;let M=window==null?void 0:window.location.href,_=new URL(R,M).hostname.toLocaleLowerCase();return _.includes(kr)||!!m&&_.includes(m.toLocaleLowerCase())},Ki=(j,R,m)=>{var L;let{envKey:M}=j,_=Nr(j);if(M||_){let{playerInitTime:C,playerSoftwareName:b,playerSoftwareVersion:O,beaconCollectionDomain:A,debug:y,disableCookies:T}=j,D={...j.metadata,video_title:((L=j==null?void 0:j.metadata)==null?void 0:L.video_title)||void 0},E=g=>typeof g.player_error_code=="string"?!1:typeof j.errorTranslator=="function"?j.errorTranslator(g):g;Xt.default.monitor(R,{debug:y,beaconCollectionDomain:A,hlsjs:m,Hls:m?Tt.default:void 0,automaticErrorTracking:!1,errorTranslator:E,disableCookies:T,data:{...M?{env_key:M}:{},player_software_name:b,player_software:b,player_software_version:O,player_init_time:C,...D}})}},Wi=(j,R,m)=>{var L;let M=Ur(j,R),{src:_}=j;R&&M?(typeof _=="string"?(R.setAttribute("src",_),j.startTime&&(((L=Ot.get(R))!=null?L:{}).startTime=j.startTime,R.addEventListener("durationchange",Kr,{once:!0}))):R.removeAttribute("src"),R.addEventListener("error",Wr),R.addEventListener("error",hr)):m&&_?(m.on(Tt.default.Events.ERROR,(C,b)=>{let O={[Tt.default.ErrorTypes.NETWORK_ERROR]:Ne.MEDIA_ERR_NETWORK,[Tt.default.ErrorTypes.MEDIA_ERROR]:Ne.MEDIA_ERR_DECODE},A=new Ne("",O[b.type]);A.fatal=b.fatal,A.data=b,R.dispatchEvent(new CustomEvent("error",{detail:A}))}),R.addEventListener("error",hr),Pr(R,m),m.attachMedia(R)):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 Kr(j){var M;let R=j.target,m=(M=Ot.get(R))==null?void 0:M.startTime;if(!!m&&Ar(R.seekable,R.duration,m)){let _=R.preload==="auto";_&&(R.preload="none"),R.currentTime=m,_&&(R.preload="auto")}}async function Wr(j){if(!j.isTrusted)return;j.stopImmediatePropagation();let R=j.target;if(!(R!=null&&R.error))return;let{message:m,code:M}=R.error,_=new Ne(m,M);if(R.src&&(M!==Ne.MEDIA_ERR_DECODE||M!==void 0))try{let{status:L}=await fetch(R.src);_.data={response:{code:L}}}catch{}R.dispatchEvent(new CustomEvent("error",{detail:_}))}function hr(j){var M,_;if(!(j instanceof CustomEvent)||!(j.detail instanceof Ne))return;let R=j.target,m=j.detail;!m||!m.fatal||(((M=Ot.get(R))!=null?M:{}).error=m,(_=R.mux)==null||_.emit("error",{player_error_code:m.code,player_error_message:m.message}))}})();
31
+ `),c=[],m=(0,P.toMpegTsClockFromTimescale)(h,a),e="00:00.000",r=0,t=0,s,y=!0;u.oncue=function(f){var b=o[n],R=o.ccOffset,I=(r-m)/9e4;b!=null&&b.new&&(t!==void 0?R=o.ccOffset=b.start:d(o,n,I)),I&&(R=I-o.presentationOffset);var k=f.endTime-f.startTime,F=(0,B.normalizePts)((f.startTime+R-t)*9e4,v*9e4)/9e4;f.startTime=Math.max(F,0),f.endTime=Math.max(F+k,0);var K=f.text.trim();f.text=decodeURIComponent(encodeURIComponent(K)),f.id||(f.id=S(f.startTime,f.endTime,K)),f.endTime>0&&c.push(f)},u.onparsingerror=function(f){s=f},u.onflush=function(){if(s){i(s);return}l(c)},g.forEach(function(f){if(y)if(D(f,"X-TIMESTAMP-MAP=")){y=!1,f.slice(16).split(",").forEach(function(b){D(b,"LOCAL:")?e=b.slice(6):D(b,"MPEGTS:")&&(r=parseInt(b.slice(7)))});try{t=x(e)/1e3}catch(b){s=b}return}else f===""&&(y=!1);u.parse(f+`
32
+ `)}),u.flush()}},"./src/utils/xhr-loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>B});var C=T("./src/utils/logger.ts"),L=T("./src/loader/load-stats.ts"),M=/^age:\s*[\d.]+\s*$/m,P=function(){function A(x){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=x?x.xhrSetup:null,this.stats=new L.LoadStats,this.retryDelay=0}var D=A.prototype;return D.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},D.abortInternal=function(){var _=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),_&&(_.onreadystatechange=null,_.onprogress=null,_.readyState!==4&&(this.stats.aborted=!0,_.abort()))},D.abort=function(){var _;this.abortInternal(),(_=this.callbacks)!==null&&_!==void 0&&_.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},D.load=function(_,S,d){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=_,this.config=S,this.callbacks=d,this.retryDelay=S.retryDelay,this.loadInternal()},D.loadInternal=function(){var _=this.config,S=this.context;if(!!_){var d=this.loader=new self.XMLHttpRequest,E=this.stats;E.loading.first=0,E.loaded=0;var p=this.xhrSetup;try{if(p)try{p(d,S.url)}catch{d.open("GET",S.url,!0),p(d,S.url)}d.readyState||d.open("GET",S.url,!0);var h=this.context.headers;if(h)for(var a in h)d.setRequestHeader(a,h[a])}catch(o){this.callbacks.onError({code:d.status,text:o.message},S,d);return}S.rangeEnd&&d.setRequestHeader("Range","bytes="+S.rangeStart+"-"+(S.rangeEnd-1)),d.onreadystatechange=this.readystatechange.bind(this),d.onprogress=this.loadprogress.bind(this),d.responseType=S.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),_.timeout),d.send()}},D.readystatechange=function(){var _=this.context,S=this.loader,d=this.stats;if(!(!_||!S)){var E=S.readyState,p=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){S.onreadystatechange=null,S.onprogress=null;var h=S.status,a=S.responseType==="arraybuffer";if(h>=200&&h<300&&(a&&S.response||S.responseText!==null)){d.loading.end=Math.max(self.performance.now(),d.loading.first);var o,n;if(a?(o=S.response,n=o.byteLength):(o=S.responseText,n=o.length),d.loaded=d.total=n,!this.callbacks)return;var v=this.callbacks.onProgress;if(v&&v(d,_,o,S),!this.callbacks)return;var l={url:S.responseURL,data:o};this.callbacks.onSuccess(l,d,_,S)}else d.retry>=p.maxRetry||h>=400&&h<499?(C.logger.error(h+" while loading "+_.url),this.callbacks.onError({code:h,text:S.statusText},_,S)):(C.logger.warn(h+" while loading "+_.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,p.maxRetryDelay),d.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),p.timeout)}},D.loadtimeout=function(){C.logger.warn("timeout while loading "+this.context.url);var _=this.callbacks;_&&(this.abortInternal(),_.onTimeout(this.stats,this.context,this.loader))},D.loadprogress=function(_){var S=this.stats;S.loaded=_.loaded,_.lengthComputable&&(S.total=_.total)},D.getCacheAge=function(){var _=null;if(this.loader&&M.test(this.loader.getAllResponseHeaders())){var S=this.loader.getResponseHeader("age");_=S?parseFloat(S):null}return _},A}();let B=P},"./node_modules/eventemitter3/index.js":z=>{"use strict";var N=Object.prototype.hasOwnProperty,T="~";function C(){}Object.create&&(C.prototype=Object.create(null),new C().__proto__||(T=!1));function L(A,D,x){this.fn=A,this.context=D,this.once=x||!1}function M(A,D,x,_,S){if(typeof x!="function")throw new TypeError("The listener must be a function");var d=new L(x,_||A,S),E=T?T+D:D;return A._events[E]?A._events[E].fn?A._events[E]=[A._events[E],d]:A._events[E].push(d):(A._events[E]=d,A._eventsCount++),A}function P(A,D){--A._eventsCount===0?A._events=new C:delete A._events[D]}function B(){this._events=new C,this._eventsCount=0}B.prototype.eventNames=function(){var D=[],x,_;if(this._eventsCount===0)return D;for(_ in x=this._events)N.call(x,_)&&D.push(T?_.slice(1):_);return Object.getOwnPropertySymbols?D.concat(Object.getOwnPropertySymbols(x)):D},B.prototype.listeners=function(D){var x=T?T+D:D,_=this._events[x];if(!_)return[];if(_.fn)return[_.fn];for(var S=0,d=_.length,E=new Array(d);S<d;S++)E[S]=_[S].fn;return E},B.prototype.listenerCount=function(D){var x=T?T+D:D,_=this._events[x];return _?_.fn?1:_.length:0},B.prototype.emit=function(D,x,_,S,d,E){var p=T?T+D:D;if(!this._events[p])return!1;var h=this._events[p],a=arguments.length,o,n;if(h.fn){switch(h.once&&this.removeListener(D,h.fn,void 0,!0),a){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,x),!0;case 3:return h.fn.call(h.context,x,_),!0;case 4:return h.fn.call(h.context,x,_,S),!0;case 5:return h.fn.call(h.context,x,_,S,d),!0;case 6:return h.fn.call(h.context,x,_,S,d,E),!0}for(n=1,o=new Array(a-1);n<a;n++)o[n-1]=arguments[n];h.fn.apply(h.context,o)}else{var v=h.length,l;for(n=0;n<v;n++)switch(h[n].once&&this.removeListener(D,h[n].fn,void 0,!0),a){case 1:h[n].fn.call(h[n].context);break;case 2:h[n].fn.call(h[n].context,x);break;case 3:h[n].fn.call(h[n].context,x,_);break;case 4:h[n].fn.call(h[n].context,x,_,S);break;default:if(!o)for(l=1,o=new Array(a-1);l<a;l++)o[l-1]=arguments[l];h[n].fn.apply(h[n].context,o)}}return!0},B.prototype.on=function(D,x,_){return M(this,D,x,_,!1)},B.prototype.once=function(D,x,_){return M(this,D,x,_,!0)},B.prototype.removeListener=function(D,x,_,S){var d=T?T+D:D;if(!this._events[d])return this;if(!x)return P(this,d),this;var E=this._events[d];if(E.fn)E.fn===x&&(!S||E.once)&&(!_||E.context===_)&&P(this,d);else{for(var p=0,h=[],a=E.length;p<a;p++)(E[p].fn!==x||S&&!E[p].once||_&&E[p].context!==_)&&h.push(E[p]);h.length?this._events[d]=h.length===1?h[0]:h:P(this,d)}return this},B.prototype.removeAllListeners=function(D){var x;return D?(x=T?T+D:D,this._events[x]&&P(this,x)):(this._events=new C,this._eventsCount=0),this},B.prototype.off=B.prototype.removeListener,B.prototype.addListener=B.prototype.on,B.prefixed=T,B.EventEmitter=B,z.exports=B},"./node_modules/url-toolkit/src/url-toolkit.js":function(z){(function(N){var T=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,C=/^(?=([^\/?#]*))\1([^]*)$/,L=/(?:\/|^)\.(?=\/)/g,M=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,P={buildAbsoluteURL:function(B,A,D){if(D=D||{},B=B.trim(),A=A.trim(),!A){if(!D.alwaysNormalize)return B;var x=P.parseURL(B);if(!x)throw new Error("Error trying to parse base URL.");return x.path=P.normalizePath(x.path),P.buildURLFromParts(x)}var _=P.parseURL(A);if(!_)throw new Error("Error trying to parse relative URL.");if(_.scheme)return D.alwaysNormalize?(_.path=P.normalizePath(_.path),P.buildURLFromParts(_)):A;var S=P.parseURL(B);if(!S)throw new Error("Error trying to parse base URL.");if(!S.netLoc&&S.path&&S.path[0]!=="/"){var d=C.exec(S.path);S.netLoc=d[1],S.path=d[2]}S.netLoc&&!S.path&&(S.path="/");var E={scheme:S.scheme,netLoc:_.netLoc,path:null,params:_.params,query:_.query,fragment:_.fragment};if(!_.netLoc&&(E.netLoc=S.netLoc,_.path[0]!=="/"))if(!_.path)E.path=S.path,_.params||(E.params=S.params,_.query||(E.query=S.query));else{var p=S.path,h=p.substring(0,p.lastIndexOf("/")+1)+_.path;E.path=P.normalizePath(h)}return E.path===null&&(E.path=D.alwaysNormalize?P.normalizePath(_.path):_.path),P.buildURLFromParts(E)},parseURL:function(B){var A=T.exec(B);return A?{scheme:A[1]||"",netLoc:A[2]||"",path:A[3]||"",params:A[4]||"",query:A[5]||"",fragment:A[6]||""}:null},normalizePath:function(B){for(B=B.split("").reverse().join("").replace(L,"");B.length!==(B=B.replace(M,"")).length;);return B.split("").reverse().join("")},buildURLFromParts:function(B){return B.scheme+B.netLoc+B.path+B.params+B.query+B.fragment}};z.exports=P})(this)}},ee={};function ie(z){var N=ee[z];if(N!==void 0)return N.exports;var T=ee[z]={exports:{}};return J[z].call(T.exports,T,T.exports,ie),T.exports}ie.m=J,ie.n=z=>{var N=z&&z.__esModule?()=>z.default:()=>z;return ie.d(N,{a:N}),N},ie.d=(z,N)=>{for(var T in N)ie.o(N,T)&&!ie.o(z,T)&&Object.defineProperty(z,T,{enumerable:!0,get:N[T]})},ie.o=(z,N)=>Object.prototype.hasOwnProperty.call(z,N),ie.r=z=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(z,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(z,"__esModule",{value:!0})};var se=ie("./src/hls.ts");return se=se.default,se})())});var er=zt(Ur()),xt=zt($t());var At=class extends Error{constructor(ie,se=At.MEDIA_ERR_CUSTOM,z){var N;super(ie);this.name="MediaError",this.code=se,this.fatal=z!=null?z:se>=At.MEDIA_ERR_NETWORK&&se<=At.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(N=At.defaultMessages[this.code])!=null?N:"")}},$e=At;$e.MEDIA_ERR_ABORTED=1,$e.MEDIA_ERR_NETWORK=2,$e.MEDIA_ERR_DECODE=3,$e.MEDIA_ERR_SRC_NOT_SUPPORTED=4,$e.MEDIA_ERR_ENCRYPTED=5,$e.MEDIA_ERR_CUSTOM=100,$e.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 Er=zt($t());var Xi=J=>J==null,gr=(J,ee)=>Xi(ee)?!1:J in ee,Jt={ANY:"any",MUTED:"muted"},Kt={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},mr={MSE:"mse",NATIVE:"native"},Zt={HEADER:"header",QUERY:"query",NONE:"none"},hn=Object.values(Zt),Et={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},qt={HLS:Et.M3U8},vn=Object.keys(qt),gn=[...Object.values(Et),"hls","HLS"];var yt=(J,ee,ie,se,z=J)=>{z.addEventListener(ee,ie,se),J.addEventListener("teardown",()=>{z.removeEventListener(ee,ie)},{once:!0})};function Br(J,ee,ie){ee&&ie>ee&&(ie=ee);for(let se=0;se<J.length;se++)if(J.start(se)<=ie&&J.end(se)>=ie)return!0;return!1}var Nr=J=>{let ee=J.indexOf("?");if(ee<0)return[J];let ie=J.slice(0,ee),se=J.slice(ee);return[ie,se]},pr=J=>{let ee=J.type;if(ee){let se=ee.toUpperCase();return gr(se,qt)?qt[se]:ee}let{src:ie}=J;return ie?zi(ie):""},zi=J=>{let ee="";try{ee=new URL(J).pathname}catch{console.error("invalid url")}let ie=ee.lastIndexOf(".");if(ie<0)return"";let z=ee.slice(ie+1).toUpperCase();return gr(z,Et)?Et[z]:""};var Qi=Object.values(Jt),Kr=J=>typeof J=="boolean"||typeof J=="string"&&Qi.includes(J),Wr=({autoplay:J},ee,ie)=>{let se=!1,z=!1,N=Kr(J)?J:!!J,T=()=>{se||yt(ee,"playing",()=>{se=!0},{once:!0})};if(T(),yt(ee,"loadstart",()=>{se=!1,T(),yr(ee,N)},{once:!0}),yt(ee,"loadstart",()=>{ie||(z=!Number.isFinite(ee.duration)),yr(ee,N)},{once:!0}),ie&&ie.once(Er.default.Events.LEVEL_LOADED,(L,M)=>{var P;z=(P=M.details.live)!=null?P:!1}),!N){let L=()=>{!z||(ie!=null&&ie.liveSyncPosition?ee.currentTime=ie.liveSyncPosition:Number.isFinite(ee.seekable.end(0))&&(ee.currentTime=ee.seekable.end(0)))};ie&&yt(ee,"play",()=>{ee.preload==="metadata"?ie.once(Er.default.Events.LEVEL_UPDATED,L):L()},{once:!0})}return L=>{se||(N=Kr(L)?L:!!L,yr(ee,N))}},yr=(J,ee)=>{if(!ee)return;let ie=J.muted,se=()=>J.muted=ie;switch(ee){case Jt.ANY:J.play().catch(()=>{J.muted=!0,J.play().catch(se)});break;case Jt.MUTED:J.muted=!0,J.play().catch(se);break;default:J.play().catch(()=>{});break}};var Gr=({preload:J,src:ee},ie,se)=>{let z=B=>{B!=null&&["","none","metadata","auto"].includes(B)?ie.setAttribute("preload",B):ie.removeAttribute("preload")};if(!se)return z(J),z;let N=!1,T=!1,C=se.config.maxBufferLength,L=se.config.maxBufferSize,M=B=>{z(B);let A=B!=null?B:ie.preload;T||A==="none"||(A==="metadata"?(se.config.maxBufferLength=1,se.config.maxBufferSize=1):(se.config.maxBufferLength=C,se.config.maxBufferSize=L),P())},P=()=>{!N&&ee&&(N=!0,se.loadSource(ee))};return yt(ie,"play",()=>{T=!0,se.config.maxBufferLength=C,se.config.maxBufferSize=L,P()},{once:!0}),M(J),M};var bt=zt($t());function Hr(J,ee){ee.on(bt.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(z,{tracks:N})=>{N.forEach(T=>{var M;let C=(M=T.subtitleTrack)!=null?M:T.closedCaptions,L=ee.subtitleTracks.findIndex(({lang:P,name:B,type:A})=>P==(C==null?void 0:C.lang)&&B===T.label&&A.toLowerCase()===T.kind);_r(J,T.kind,T.label,C==null?void 0:C.lang,`${T.kind}${L}`)})});let ie=()=>{var T;if(!ee.subtitleTracks.length)return;let z=Array.from(J.textTracks).find(C=>C.id&&C.mode==="showing"&&["subtitles","captions"].includes(C.kind)),N=`${(T=ee.subtitleTracks[ee.subtitleTrack])==null?void 0:T.type.toLowerCase()}${ee.subtitleTrack}`;if(z&&(ee.subtitleTrack<0||(z==null?void 0:z.id)!==N)){let C=ee.subtitleTracks.findIndex(({lang:L,name:M,type:P})=>L==z.language&&M===z.label&&P.toLowerCase()===z.kind);ee.subtitleTrack=C}z&&(z==null?void 0:z.id)===N&&z.cues&&Array.from(z.cues).forEach(C=>{z.addCue(C)})};J.textTracks.addEventListener("change",ie),ee.on(bt.default.Events.CUES_PARSED,(z,{track:N,cues:T})=>{let C=J.textTracks.getTrackById(N);if(!C)return;let L=C.mode==="disabled";L&&(C.mode="hidden"),T.forEach(M=>{var P;(P=C.cues)!=null&&P.getCueById(M.id)||C.addCue(M)}),L&&(C.mode="disabled")}),ee.once(bt.default.Events.DESTROYING,()=>{J.textTracks.removeEventListener("change",ie),J.querySelectorAll("track[data-removeondestroy]").forEach(N=>{N.remove()})});let se=()=>{Array.from(J.textTracks).forEach(z=>{var N,T;if(!["subtitles","caption"].includes(z.kind)&&z.label==="thumbnails"){if(!((N=z.cues)!=null&&N.length)){let C=J.querySelector('track[label="thumbnails"]'),L=(T=C==null?void 0:C.getAttribute("src"))!=null?T:"";C==null||C.removeAttribute("src"),setTimeout(()=>{C==null||C.setAttribute("src",L)},0)}z.mode!=="hidden"&&(z.mode="hidden")}})};ee.once(bt.default.Events.MANIFEST_LOADED,se),ee.once(bt.default.Events.MEDIA_ATTACHED,se)}function _r(J,ee,ie,se,z){let N=document.createElement("track");return N.kind=ee,N.label=ie,se&&(N.srclang=se),z&&(N.id=z),N.track.mode="disabled",N.setAttribute("data-removeondestroy",""),J.append(N),N.track}function $i(J,ee){let ie=Array.prototype.find.call(J.querySelectorAll("track"),se=>se.track===ee);ie==null||ie.remove()}var Wt="cuepoints",Tr=Object.freeze({label:Wt}),xr=(J,{label:ee=Wt}=Tr)=>{var ie;return(ie=Array.from(J.querySelectorAll("track")).find(se=>se.track.label===ee&&se.track.kind==="metadata"))==null?void 0:ie.track};async function jr(J,ee,ie=Tr){let se=xr(J,ie);if(!se){let{label:z=Wt}=ie;se=_r(J,"metadata",z),se.mode="hidden",await new Promise(N=>setTimeout(()=>N(void 0),0))}return[...ee].sort(({time:z},{time:N})=>N-z).forEach(({time:z,value:N})=>{var B,A;let T=Array.prototype.findIndex.call(se==null?void 0:se.cues,D=>D.startTime>=z),C=(B=se==null?void 0:se.cues)==null?void 0:B[T],L=C?C.startTime:Number.isFinite(J.duration)?J.duration:Number.MAX_SAFE_INTEGER,M=(A=se==null?void 0:se.cues)==null?void 0:A[T-1];M&&(M.endTime=z);let P=new VTTCue(z,L,JSON.stringify(N!=null?N:null));se.addCue(P)}),se}var Vr=J=>({time:J.startTime,value:JSON.parse(J.text)});function Ji(J,ee={label:Wt}){let ie=xr(J,ee);return ie!=null&&ie.cues?Array.from(ie.cues,se=>Vr(se)):[]}function Yr(J,ee={label:Wt}){var se;let ie=xr(J,ee);if(!!((se=ie==null?void 0:ie.activeCues)!=null&&se.length))return Vr(ie.activeCues[0])}async function Xr(J,ee=Tr){let ie=await jr(J,[],ee);return yt(J,"cuechange",()=>{let se=Yr(J);if(se){let z=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:se});J.dispatchEvent(z)}},{},ie),ie}var zr,Qr,Zi=(Qr=(zr=globalThis==null?void 0:globalThis.navigator)==null?void 0:zr.userAgent)!=null?Qr:"",qi=Zi.toLowerCase().indexOf("android")!==-1,Pt=new WeakMap,Zr="mux.com",$r,Jr,qr=(Jr=($r=xt.default).isSupported)==null?void 0:Jr.call($r),en=qi,Fn=()=>er.default.utils.now(),tn=er.default.utils.generateUUID,Un=(J,{domain:ee=Zr}={})=>{if(!J)return;let[ie,se=""]=Nr(J);return`https://stream.${ee}/${ie}.m3u8${se}`},rn=J=>{if(!J)return;let[ee]=J.split("?");return ee||void 0},nn=J=>{if(!J||!J.startsWith("https://stream."))return;let[ee]=new URL(J).pathname.slice(1).split(".m3u8");return ee||void 0},an=J=>{var ee,ie,se;return(ee=J==null?void 0:J.metadata)!=null&&ee.video_id?J.metadata.video_id:ti(J)&&(se=(ie=rn(J.playbackId))!=null?ie:nn(J.src))!=null?se:J.src},Bn=J=>{var ee;return(ee=Pt.get(J))==null?void 0:ee.error},Nn=(J,ee,ie)=>{sn(ee,ie);let{metadata:se={}}=J,{view_session_id:z=tn()}=se,N=an(J);se.view_session_id=z,se.video_id=N,J.metadata=se,Pt.set(ee,{});let T=on(J,ee);un(J,ee,T),fn(J,ee,T),Xr(ee);let C=Wr(J,ee,T),L=Gr(J,ee,T);return{engine:T,setAutoplay:C,setPreload:L}},sn=(J,ee)=>{let ie=ee==null?void 0:ee.engine;ie&&(ie.detachMedia(),ie.destroy()),(J==null?void 0:J.mux)&&!J.mux.deleted&&(J.mux.destroy(),delete J.mux),J&&(J.removeAttribute("src"),J.load(),J.removeEventListener("error",ii),J.removeEventListener("error",Sr),J.removeEventListener("durationchange",ri),Pt.delete(J),J.dispatchEvent(new Event("teardown")))};function ei(J,ee){var M;let ie=pr(J);if(!(ie===Et.M3U8))return!0;let z=!ie||((M=ee.canPlayType(ie))!=null?M:!0),{preferPlayback:N}=J,T=N===mr.MSE,C=N===mr.NATIVE;return z&&(C||!(qr&&(T||en)))}var on=(J,ee)=>{let{debug:ie,streamType:se,startTime:z=-1,metadata:N,preferCmcd:T}=J,L=pr(J)===Et.M3U8,M=ei(J,ee);if(L&&!M&&qr){let P={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},B=ln(se),A=T!==Zt.NONE?{useHeaders:T===Zt.HEADER,sessionId:N.view_session_id,contentId:N.video_id}:void 0;return new xt.default({debug:ie,startPosition:z,cmcd:A,...P,...B})}},ln=J=>[Kt.LIVE,Kt.DVR].includes(J)?{backBufferLength:8}:[Kt.LL_LIVE,Kt.LL_DVR].includes(J)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},ti=({playbackId:J,src:ee,customDomain:ie})=>{if(J)return!0;if(typeof ee!="string")return!1;let se=window==null?void 0:window.location.href,z=new URL(ee,se).hostname.toLocaleLowerCase();return z.includes(Zr)||!!ie&&z.includes(ie.toLocaleLowerCase())},un=(J,ee,ie)=>{var N;let{envKey:se}=J,z=ti(J);if(se||z){let{playerInitTime:T,playerSoftwareName:C,playerSoftwareVersion:L,beaconCollectionDomain:M,debug:P,disableCookies:B}=J,A={...J.metadata,video_title:((N=J==null?void 0:J.metadata)==null?void 0:N.video_title)||void 0},D=x=>typeof x.player_error_code=="string"?!1:typeof J.errorTranslator=="function"?J.errorTranslator(x):x;er.default.monitor(ee,{debug:P,beaconCollectionDomain:M,hlsjs:ie,Hls:ie?xt.default:void 0,automaticErrorTracking:!1,errorTranslator:D,disableCookies:B,data:{...se?{env_key:se}:{},player_software_name:C,player_software:C,player_software_version:L,player_init_time:T,...A}})}},fn=(J,ee,ie)=>{var N;let se=ei(J,ee),{src:z}=J;ee&&se?(typeof z=="string"?(ee.setAttribute("src",z),J.startTime&&(((N=Pt.get(ee))!=null?N:{}).startTime=J.startTime,ee.addEventListener("durationchange",ri,{once:!0}))):ee.removeAttribute("src"),ee.addEventListener("error",ii),ee.addEventListener("error",Sr)):ie&&z?(ie.on(xt.default.Events.ERROR,(T,C)=>{let L={[xt.default.ErrorTypes.NETWORK_ERROR]:$e.MEDIA_ERR_NETWORK,[xt.default.ErrorTypes.MEDIA_ERROR]:$e.MEDIA_ERR_DECODE},M=new $e("",L[C.type]);M.fatal=C.fatal,M.data=C,ee.dispatchEvent(new CustomEvent("error",{detail:M}))}),ee.addEventListener("error",Sr),Hr(ee,ie),ie.attachMedia(ee)):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 ri(J){var se;let ee=J.target,ie=(se=Pt.get(ee))==null?void 0:se.startTime;if(!!ie&&Br(ee.seekable,ee.duration,ie)){let z=ee.preload==="auto";z&&(ee.preload="none"),ee.currentTime=ie,z&&(ee.preload="auto")}}async function ii(J){if(!J.isTrusted)return;J.stopImmediatePropagation();let ee=J.target;if(!(ee!=null&&ee.error))return;let{message:ie,code:se}=ee.error,z=new $e(ie,se);if(ee.src&&(se!==$e.MEDIA_ERR_DECODE||se!==void 0))try{let{status:N}=await fetch(ee.src);z.data={response:{code:N}}}catch{}ee.dispatchEvent(new CustomEvent("error",{detail:z}))}function Sr(J){var se,z;if(!(J instanceof CustomEvent)||!(J.detail instanceof $e))return;let ee=J.target,ie=J.detail;!ie||!ie.fatal||(((se=Pt.get(ee))!=null?se:{}).error=ie,(z=ee.mux)==null||z.emit("error",{player_error_code:ie.code,player_error_message:ie.message}))}})();
31
33
  /*!
32
34
  * JavaScript Cookie v2.1.3
33
35
  * https://github.com/js-cookie/js-cookie
@@ -37,7 +39,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37
39
  */
38
40
  /*!
39
41
  * mux-embed
40
- * @version 4.14.0
42
+ * @version 4.17.0
41
43
  * @copyright 2022 Mux, Inc
42
44
  */
43
45
  //# sourceMappingURL=playback-core.js.map